Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /var/www/kanvakanva.com/public_html/application/controllers/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Payment_confirmation extends Public_Controller { function __construct() { parent::__construct(); } public function index() { $this->data_header['browser_title'] = 'Payment Confirmation'; $this->data_header['meta_description'] = 'Payment Confirmation'; $this->data_header['meta_keywords'] = 'Payment Confirmation'; $data['title'] = 'Payment Confirmation'; $this->load->view('template/header', $this->data_header); $this->load->view('payment_confirmation'); $this->load->view('template/footer'); } public function load_payment_page($hash_string = 'null') { //string example: dfewsvdd-200 if($this->input->get('order_id')) { $hash_string_array = explode('-', $this->input->get('order_id')); //check if the $hash_string is correct $rowcount = $this->db->select('id_orders')->from('orders')->where('payment_confirmation_string', $this->input->get('order_id'))->where('id_orders', (int) $hash_string_array[1])->get()->num_rows(); } else { $hash_string_array = explode('-', $hash_string); //check if the $hash_string is correct $rowcount = $this->db->select('id_orders')->from('orders')->where('payment_confirmation_string', $hash_string)->where('id_orders', (int) $hash_string_array[1])->get()->num_rows(); } if ($rowcount == 1) { $this->data_header['browser_title'] = 'Payment Confirmation'; $this->data_header['meta_description'] = 'Payment Confirmation'; $this->data_header['meta_keywords'] = 'Payment Confirmation'; $data['title'] = 'Payment Confirmation'; $data_order['order_id'] = $hash_string_array[1]; $data_order['hash_string'] = $hash_string_array[0]; $this->load->view('template/header', $this->data_header); $this->load->view('upload_receipt', $data_order); $this->load->view('template/footer'); } else { redirect('payment_confirmation'); } } public function update_confirmation() { if (!isset($_POST['update_paymentconfirmation'])) { redirect('payment_confirmation/load_payment_page/' . $this->input->post('hash_string') . '-' . $this->input->post('order_id')); } //validation in action $config = array( array( 'field' => 'payment_date', 'label' => 'Payment Date', 'rules' => 'trim|required' ), array( 'field' => 'total_amount', 'label' => 'Total Amount', 'rules' => 'trim|required|numeric' ), array( 'field' => 'to_bank', 'label' => 'To Bank', 'rules' => 'trim' ), array( 'field' => 'from_bank', 'label' => 'From Bank', 'rules' => 'trim|required' ), array( 'field' => 'account_name', 'label' => 'Account Name', 'rules' => 'required|trim' ), ); $this->load->library('form_validation'); $this->form_validation->set_rules($config); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); if($this->form_validation->run() == FALSE) { $data['order_id'] = $this->input->post('order_id'); $data['hash_string'] = $this->input->post('hash_string'); $this->data_header['page_title'] = 'Payment Confirmation'; $this->data_header['browser_title'] = 'Payment Confirmation'; $this->data_header['meta_description'] = 'Payment Confirmation'; $this->data_header['meta_keywords'] = 'Payment Confirmation'; $this->load->view('template/header', $this->data_header); $this->load->view('upload_receipt', $data); $this->load->view('template/footer', $this->data_footer); } else { $payment_date = explode('-', $this->input->post('payment_date')); $new_payment_date = $payment_date['2'] . '-' . $payment_date['1'] . '-' . $payment_date['0']; $total_amount = (int) $this->input->post('total_amount'); $to_bank = ucwords($this->input->post('to_bank')); $from_bank = ucwords($this->input->post('from_bank')); $account_name = ucwords($this->input->post('account_name')); $payment_confirm_details = '<p>Payment Date: ' . $new_payment_date . '</p>' . '<p>Payment Amount: Rp ' . number_format($total_amount) . '</p>' . '<p>To Bank: ' . $to_bank . '</p>' . '<p>From Bank: ' . $from_bank . '</p>' . '<p>Acc Name: ' . $account_name . '</p>'; $data = array( 'payment_confirm' => 1, 'payment_confirm_details' => $payment_confirm_details, ); $order_id = (int) $this->input->post('order_id'); $this->db->where('id_orders', $order_id); $this->db->update('orders', $data); //sending email //----SEND EMAIL TO ADMIN WEBSITE $config['protocol'] = 'smtp'; $config['smtp_host'] = 'ssl://smtp.gmail.com'; //change this $config['smtp_port'] = '465'; $config['smtp_user'] = 'info@kanvakanva.com'; //change this $config['smtp_pass'] = 'Akunk4nva'; //change this $config['mailtype'] = 'html'; $config['charset'] = 'iso-8859-1'; $config['wordwrap'] = TRUE; $config['newline'] = "\r\n"; //use double quotes to comply with RFC 822 standard $this->load->library('email'); $this->email->initialize($config); $this->email->from('info@kanvakanva.com', 'Kanva2'); $this->email->to('info@kanvakanva.com'); $this->email->subject('Order Confirmation'); $myMessage = '<html><body>'; $myMessage .= '<table style="border-color: #666;" cellpadding="10">'; $myMessage .= "<tr><td><strong>Order No:</strong> </td><td>" . $order_id . "</td></tr>"; $myMessage .= "<tr><td><strong>Payment Date:</strong> </td><td>" . $this->input->post('payment_date') . "</td></tr>"; $myMessage .= "<tr><td><strong>Amount: Rp </strong> </td><td>" . number_format($total_amount) . "</td></tr>"; $myMessage .= "<tr><td><strong>To Bank:</strong> </td><td>" . $to_bank . "</td></tr>"; $myMessage .= "<tr><td><strong>From bank:</strong> </td><td>" . $from_bank . "</td></tr>"; $myMessage .= "<tr><td><strong>Account Name:</strong> </td><td>" . $account_name . "</td></tr>"; $myMessage .= "</table>"; $myMessage .= "<p>Please verify the payment, and change the payment status at Admin Dashboard.</p>"; $myMessage .= "</body></html>"; $this->email->message($myMessage); $this->email->send(); $this->session->set_flashdata('success', '<br><p style="background:#564E52; color:white; padding:10px; padding:5px; font-weight:bold;">Payment Confirmation Success. We will verify your payment and notify You back.</p>'); $redirect_string = 'payment_confirmation/load_payment_page/' . $this->input->post('hash_string') . '-' . $this->input->post('order_id'); redirect($redirect_string); } } }