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 defined('BASEPATH') OR exit('No direct script access allowed'); class Account extends Customer_Controller { public function __construct() { parent::__construct(); $this->load->model('customer_m'); //get SEO $this->db->select('website_name, meta_keywords')->from('configuration')->where('id_configuration', 1); $website_name = $this->db->get()->row(); $this->data_header['browser_title'] = ucwords($website_name->website_name) . ' - My Account'; $this->data_header['meta_description'] = ucwords($website_name->website_name) . ' - My Account'; $this->data_header['meta_keywords'] = $website_name->meta_keywords; } public function index() { $data['point'] = $this->customer_m->get_point(); $this->load->view('template/header', $this->data_header); $this->load->view('account/index', $data); $this->load->view('template/footer', $this->data_footer); } public function profile() { $this->data_header['page_title'] = 'My Profile'; $id_customer = (int) $this->session->userdata('customer')['customer_id']; $data['point'] = $this->customer_m->get_point(); $data['customer'] = $this->customer_m->get_customer($id_customer); $data['birthday_check'] = $this->db->query("SELECT birthday FROM customers WHERE id_customers='$id_customer'")->row('birthday'); $this->load->view('template/header', $this->data_header); $this->load->view('account/profile', $data); $this->load->view('template/footer', $this->data_footer); } public function update_profile() { if (!isset($_POST['update_profile'])) { redirect('account/profile'); } //validation in action $rules = $this->customer_m->profile_rules; $this->form_validation->set_rules($rules); if($this->form_validation->run() == FALSE) { $this->profile(); } else { if (! $this->input->post('password')) { $data = array( 'name' => $this->input->post('name'), ); } else { $data = array( 'name' => $this->input->post('name'), 'password' => $this->customer_m->hash($this->input->post('password')), ); } $id_customer = (int) $this->session->userdata('customer')['customer_id']; if($this->input->post('birthday')){ $birthday_check = $this->db->query("SELECT birthday FROM customers WHERE id_customers='$id_customer'")->row('birthday'); if($birthday_check == null || $birthday_check == '0000-00-00'){ $data['birthday'] = $this->input->post('birthday'); /* ------- GET BIRTHDAY POINT ------- */ $id_customer = (int) $this->session->userdata('customer')['customer_id']; $this->db->select('last_check_birthday'); $this->db->from('customers'); $this->db->where('id_customers', $id_customer); $last_check_bd = $this->db->get()->row('last_check_birthday'); $today = date("Y-m-d"); if($last_check_bd != $today){ $this->db->select('signup,birthday'); $this->db->from('reward_config'); $this->db->where('id_reward_config', '1'); $reward = $this->db->get()->row(); $signup_reward = $reward->signup; $birthday_reward = $reward->birthday; if($birthday_reward > 0){ $rev_bd = explode('-',$this->input->post('birthday')); $tgl_bd = $rev_bd[2]; $bln_bd = $rev_bd[1]; if($tgl_bd == date('d') && $bln_bd == date('m')){ $data_point = array( 'id_customers' => $id_customer, 'title' => "Birthday Reward", 'point' => $birthday_reward, 'created_at' => date("Y-m-d H:i:s") ); $this->db->insert('get_point', $data_point); $point = $this->customer_m->get_point(); $data_cust = array( 'point' => $point + $signup_reward, 'last_check_birthday' => date("Y-m-d") ); $this->db->where('id_customers', $id_customer); $this->db->update('customers', $data_cust); }else{ $data_cust = array( 'last_check_birthday' => date("Y-m-d") ); $this->db->where('id_customers', $id_customer); $this->db->update('customers', $data_cust); } }else{ $data_cust = array( 'last_check_birthday' => date("Y-m-d") ); $this->db->where('id_customers', $id_customer); $this->db->update('customers', $data_cust); } } /* ------- END GET BIRTHDAY POINT ------- */ } } $this->customer_m->update_profile($id_customer, $data); $this->session->set_flashdata('success', '<br><p style="background:#564E52; color:white; padding:10px; padding:5px; font-weight:bold;">Profile Edit Successful</p>'); redirect('account/profile'); } } public function shipping() { //this is to check whether from summary page want to update shipping details. if yes, then later redirect back to summary page if (isset($_POST['shipping_summarypage'])) { $this->session->set_userdata('shipping_summarypage', TRUE); } // $this->load->helper('rajaongkir'); $this->data_header['page_title'] = 'Change Shipping Details'; $id_customer = (int) $this->session->userdata('customer')['customer_id']; //add default address into address table if not exist yet $count_address = $this->db->select('id_address')->from('address')->where('id_customers', (int) $this->session->userdata('customer')['customer_id'])->get()->num_rows(); if($count_address == 0) { $customer_data = $this->db->select('*')->from('customers')->where('id_customers', (int) $this->session->userdata('customer')['customer_id'])->get()->row(); $data = array( 'id_customers' => $customer_data->id_customers, 'recipient_name' => $customer_data->recipient_name, 'recipient_name' => $customer_data->recipient_name, 'address' => $customer_data->address, 'address' => $customer_data->address, 'id_province' => $customer_data->id_province, 'id_district' => $customer_data->id_district, 'id_subdistrict' => $customer_data->id_subdistrict, 'province' => $customer_data->province, 'district' => $customer_data->district, 'subdistrict' => $customer_data->subdistrict, 'country' => $customer_data->country, 'postcode' => $customer_data->postcode, 'phone' => $customer_data->phone, 'address_name' => 'Default Address' ); $this->db->insert('address', $data); } $data['address'] = $this->customer_m->get_shipping_address($id_customer); $data['current_addr'] = $this->customer_m->get_shipping($id_customer); $data['point'] = $this->customer_m->get_point(); //get all province data from RajaOngkir.com API // $data['provinces'] = get_rajaongkir_data('province'); //get from helper file //get all initial districts based on stored province // $current_province_id = $data['shipping']->id_province; // $data['district_lists'] = get_rajaongkir_data('city?province=' . (int) $current_province_id); //get from helper file // $current_district_id = $data['shipping']->id_district; // $data['subdistrict_lists'] = get_rajaongkir_data('subdistrict?city=' . (int) $current_district_id); //get from helper file $this->load->view('template/header', $this->data_header); $this->load->view('account/shipping2', $data); $this->load->view('template/footer', $this->data_footer); } public function edit_shipping($id_address = null) { $id_customer = (int) $this->session->userdata('customer')['customer_id']; $data['point'] = $this->customer_m->get_point(); $data['customer'] = $this->customer_m->get_customer($id_customer); //validation in action $rules = $this->customer_m->shipping_rules; $this->form_validation->set_rules($rules); if($this->form_validation->run() == FALSE) { $this->load->helper('rajaongkir'); $this->data_header['page_title'] = 'Edit Shipping Details'; $id_customer = (int) $this->session->userdata('customer')['customer_id']; if ($id_address == null ) { $data['shipping'] = $this->customer_m->get_shipping($id_customer); } else { $data['shipping'] = $this->customer_m->get_address($id_address); $data['id_address'] = $id_address; } //get all province data from RajaOngkir.com API $data['provinces'] = get_rajaongkir_data('province'); //get from helper file //get all initial districts based on stored province $current_province_id = $data['shipping']->id_province; $data['district_lists'] = get_rajaongkir_data('city?province=' . (int) $current_province_id); //get from helper file $current_district_id = $data['shipping']->id_district; $data['subdistrict_lists'] = get_rajaongkir_data('subdistrict?city=' . (int) $current_district_id); //get from helper file $this->load->view('template/header', $this->data_header); $this->load->view('account/new_shipping', $data); $this->load->view('template/footer', $this->data_footer); } else { $data = array( 'recipient_name' => $this->input->post('recipient_name'), 'address_name' => $this->input->post('address_name'), 'country' => $this->input->post('country'), 'postcode' => $this->input->post('postcode'), 'phone' => $this->input->post('phone'), 'address' => $this->input->post('address'), 'id_province' => (int) $this->input->post('province'), 'id_district' => (int) $this->input->post('district'), 'id_subdistrict' => (int) $this->input->post('subdistrict'), ); $this->load->helper('rajaongkir'); //get province name by id_province from RajaOngkir $province = get_rajaongkir_data('province?id=' . (int) $this->input->post('province')); //get from helper file $data['province'] = $province['rajaongkir']['results']['province']; //get district /city name by id_district from RajaOngkir $district = get_rajaongkir_data('city?id=' . (int) $this->input->post('district')); //get from helper file $data['district'] = $district['rajaongkir']['results']['city_name']; //get subdistrict $subdistrict = get_rajaongkir_data('subdistrict?id=' . (int) $this->input->post('subdistrict')); //get from helper file $data['subdistrict'] = $subdistrict['rajaongkir']['results']['subdistrict_name']; $id_customer = (int) $this->session->userdata('customer')['customer_id']; // $this->customer_m->update_shipping($id_customer, $data); if ( trim( $this->input->post('id_address') ) == "" ) { $this->customer_m->add_address($id_customer, $data); $this->session->set_flashdata('success', '<br><p style="background:#564E52; color:white; padding:10px; padding:5px; font-weight:bold;">Shipping Add Successful</p>'); } else { $this->customer_m->update_address( $this->input->post('id_address') , $id_customer, $data); $this->session->set_flashdata('success', '<br><p style="background:#564E52; color:white; padding:10px; padding:5px; font-weight:bold;">Shipping Edit Successful</p>'); } // if ($this->session->userdata('shipping_summarypage') == TRUE) { // $this->session->unset_userdata('shipping_summarypage'); // redirect('summary'); // } else { redirect('account/shipping'); // } } } public function delete_address($id_address) { $this->db->where('id_address', $id_address); $this->db->delete('address'); $this->session->set_flashdata('success', '<br><p style="background:#564E52; color:white; padding:10px; padding:5px; font-weight:bold;">Shipping Delete Successful</p>'); redirect('account/shipping'); } public function set_default_address() { if (isset($_POST['shipping_summarypage'])) { $this->session->set_userdata('shipping_summarypage', TRUE); } $id_address = $this->input->post('default_address'); $data = (array) $this->customer_m->get_address($id_address); unset($data['id_address']); unset($data['address_name']); $this->db->where('id_customers', $data['id_customers'] ); $this->db->update('customers', $data); if ($this->session->userdata('shipping_summarypage') == TRUE) { $this->session->unset_userdata('shipping_summarypage'); redirect('summary'); } else { redirect('account/shipping'); } } public function order_history() { $this->load->model('order_m'); $this->data_header['page_title'] = 'Order History'; $id_customer = (int) $this->session->userdata('customer')['customer_id']; $data['order_history'] = $this->order_m->get_order_history($id_customer); $data['point'] = $this->customer_m->get_point(); $this->load->view('template/header', $this->data_header); $this->load->view('account/order_history', $data); $this->load->view('template/footer', $this->data_footer); } public function payment_confirmation() { if (!isset($_POST['confirm_payment'])) { redirect('account/order_history'); } $data['order_id'] = (int) $this->input->post('order_id'); $data['point'] = $this->customer_m->get_point(); $this->data_header['page_title'] = 'Payment Confirmation'; $this->load->view('template/header', $this->data_header); $this->load->view('account/payment_confirmation', $data); $this->load->view('template/footer', $this->data_footer); } public function update_paymentconfirmation() { if (!isset($_POST['update_paymentconfirmation'])) { redirect('account/order_history'); } //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->form_validation->set_rules($config); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); if($this->form_validation->run() == FALSE) { $data['order_id'] = (int) $this->input->post('order_id'); $data_header['page_title'] = 'Payment Confirmation'; $this->load->view('template/header', $data_header); $this->load->view('account/payment_confirmation', $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('account/order_history'); } } public function ajax_get_district() { //test if ajax call to prevent direct access if (!$this->input->is_ajax_request()) { exit('No direct script access allowed'); } $province_id = (int) $this->input->post('id_province'); //get list of districts $this->db->select('*'); $this->db->from('districts'); $this->db->where('id_provinces', $province_id); $this->db->order_by('name', 'ASC'); $query = $this->db->get(); $data['districts'] = $query->result(); //get current selected district $id_customer = (int) $this->session->userdata('customer')['customer_id']; $data['shipping'] = $this->customer_m->get_shipping($id_customer); $this->load->view('ajax_get_district', $data); } public function ajax_edit_district() { //test if ajax call to prevent direct access if (!$this->input->is_ajax_request()) { exit('No direct script access allowed'); } $this->load->helper('rajaongkir'); $province_id = (int) $this->input->post('id_province'); //get list of districts /cities from RajaOngkir.com API $data['districts'] = get_rajaongkir_data('city?province=' . $province_id); //get from helper file $this->load->view('ajax_edit_district', $data); } public function ajax_edit_subdistrict() { //test if ajax call to prevent direct access if (!$this->input->is_ajax_request()) { exit('No direct script access allowed'); } $this->load->helper('rajaongkir'); $district_id = (int) $this->input->post('id_district'); //get list of subdistricts /cities from RajaOngkir.com API $data['subdistricts'] = get_rajaongkir_data('subdistrict?city=' . $district_id); //get from helper file $this->load->view('ajax_edit_subdistrict', $data); } public function point_history() { $this->data_header['page_title'] = 'Point History'; $data['point_history'] = $this->customer_m->get_point_history(); $data['point'] = $this->customer_m->get_point(); $this->load->view('template/header', $this->data_header); $this->load->view('account/point_history', $data); $this->load->view('template/footer', $this->data_footer); } }