https://t.me/RX1948
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/rabbithabit.com/public_html/application/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/www/rabbithabit.com/public_html/application/controllers/Account.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Account extends Customer_Controller {

	function __construct() {
		
		parent::__construct();

		if(isset($this->session->userdata('customer')['customer_type'])) {
			if($this->session->userdata('customer')['customer_type'] == 'guest') {
				redirect('welcome');
			}
		}
		$this->load->model('customer_m'); 
		$this->load->library('form_validation');
	}

	function index() { 
		redirect('account/profile');

		//get SEO
		if($this->session->userdata('site_lang') == 'english') {
			$this->lang->load('homepage', 'english');
		} else {
			$this->lang->load('homepage', 'indonesian'); 
		}
		$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->load->view('template/header', $this->data_header); 
		$this->load->view('account/index');
		$this->load->view('template/footer', $this->data_footer); 
	}

	function profile() { 

		//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['dropship_summarypage'])) { 	
			$this->session->set_userdata('dropship_summarypage', TRUE);
		}

		$this->data_header['page_title'] = 'My Profile';

		$id_customer = (int) $this->session->userdata('customer')['customer_id'];

		$data['customer'] = $this->customer_m->get_customer($id_customer);

		//LOAD LANGUAGE FILES FOR profile
		if($this->session->userdata('site_lang') == 'english') {
			$this->lang->load('myprofile', 'english');
		} else {
			$this->lang->load('myprofile', 'indonesian');
		}

		//get SEO
		$this->data_header['browser_title'] =  ucwords($this->data_header['website_name']) . ' - My Account'; 
		$this->data_header['meta_description'] = ucwords($this->data_header['website_name']) . ' - My Account'; 
		$this->load->view("themes/$this->theme_no/header", $this->data_header);
		$this->load->view('account/profile', $data); 
		$this->load->view("themes/$this->theme_no/footer", $this->data_footer); 
	}

	function invite_friend(){
		$this->data_header['page_title'] = 'Invite Friend';

		$id_customer = (int) $this->session->userdata('customer')['customer_id'];

		/*get friends email*/
		$data['friends_email'] = $this->db->select('*')->from('invite_friend')->where('id_customers',$id_customer)->order_by('id_invite_friend', 'ASC')->get()->result();

		//LOAD LANGUAGE FILES FOR profile
		if($this->session->userdata('site_lang') == 'english') {
			$this->lang->load('myprofile', 'english');
		} else {
			$this->lang->load('myprofile', 'indonesian');
		}

		//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;  

		$this->load->view('template/header', $this->data_header);
		$this->load->view('account/invite_friend',$data); 
		$this->load->view('template/footer', $this->data_footer);

	}

	function invite_friend_add(){
		$data = array(
			'id_customers' 	=> (int) $this->session->userdata('customer')['customer_id'], 
			'email'			=> $this->security->xss_clean($this->input->post('email'))
		);

		/*cek email pribad*/
		$cek_email_pribadi = $this->db->select('email')->from('customers')->where('id_customers',$data['id_customers'])->get()->row()->email;
		if($data['email'] == $cek_email_pribadi){
			$this->session->set_flashdata('success', '<br>
				<p style="background:red; color:white; padding:5px; font-weight:bold;">Cannot Add Your Email.</p>');
			redirect('account/invite_friend');
		}

		/*cek duplikat email*/
		$cek_email = $this->db->select('email')->from('invite_friend')->where('id_customers',$data['id_customers'])->where('email',$data['email'])->get()->row()->email;
		if($cek_email == null){
			$this->db->insert('invite_friend',$data);
			$this->session->set_flashdata('success', '<br>
				<p style="background:green; color:white; padding:5px; font-weight:bold;">Add Friends Email Success.</p>');
			redirect('account/invite_friend');
		}
		else{
			$this->session->set_flashdata('success', '<br>
				<p style="background:red; color:white; padding:5px; font-weight:bold;">Email Already Added.</p>');
			redirect('account/invite_friend');
		}
	}

	function invite_friend_send_email($id){
		/*get friends email*/
		$data['customer_email'] = $this->db->select('email')->from('invite_friend')->where('id_invite_friend',$id)->get()->row()->email;

		//get website data
			$this->db->select('logo, from_email, website_name, email_smtp_host, email_smtp_port, email_smtp_password, email_smtp')->from('configuration')->where('id_configuration', 1);
			$website_data = $this->db->get()->row();
			$data['logo'] = $website_data->logo;
			$data['website_name'] = $website_data->website_name;
			
			$this->load->library('email');
			//get email setting 
			$config['protocol']		= 'smtp';
			$config['smtp_host'] 	= $website_data->email_smtp_host; 
			$config['smtp_port'] 	= $website_data->email_smtp_port;
			$config['smtp_user'] 	= $website_data->email_smtp; 
			$config['smtp_pass'] 	= $website_data->email_smtp_password;
			$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->email->initialize($config);
			$this->email->from($website_data->from_email, $website_data->website_name);
			$this->email->to($data['customer_email']); 
			$this->email->subject('Anda Telah Diundang'); 
			
			$email = $this->load->view('email/invite_friend', $data, TRUE);  

			$this->email->message($email);	    
			$this->email->send();  
		//----end send email 

		$this->session->set_flashdata('success', '<br>
			<p style="background:green; color:white; padding:5px; font-weight:bold;">Email Has Been Send.</p>');
		redirect('account/invite_friend');
	}

	function invite_friend_delete($id){

		$data = array(
			'id_invite_friend' => $id
		);

		$this->db->delete('invite_friend',$data);

		$this->session->set_flashdata('success', '<br>
			<p style="background:green; color:white; padding:5px; font-weight:bold;">Delete Email Success.</p>');
		redirect('account/invite_friend');
	}

	function update_profile() {

		if (!isset($_POST['update_profile'])) { 
			redirect('account/profile'); 
		}

		//validation in action
		$rules = array(
			'name' => array(
				'field'=>'name', 
				'label'=>'Name', 
				'rules'=>'trim|required'),	

			'phone' => array(
				'field'=>'phone', 
				'label'=>'Phone', 
				'rules'=>'trim|required|callback__cek_phone'),	

			'register_email' => array(
				'field'=>'register_email', 
				'label'=>'Register Email', 
				'rules'=>'trim|required|callback__cek_email'),	
			
		);   

		$this->form_validation->set_rules($rules); 
		$this->form_validation->set_error_delimiters('<div class="error">', '</div>');

		if($this->form_validation->run($this) == FALSE) {  
		
			$this->profile();

		} else {

			$day 	= $this->input->post('day');
			$month 	= $this->input->post('month');
			$year 	= $this->input->post('year');

			$data = array(
				'name'				=> $this->security->xss_clean($this->input->post('name')),
				'recipient_name' 	=> $this->security->xss_clean($this->input->post('name')), 
				'shipping_name' 	=> $this->security->xss_clean($this->input->post('name')),
				'sex_type'			=> $this->input->post('gender'),	
				'birthday' 			=> $day.'-'.$month.'-'.$year, 
				'phone'				=> $this->security->xss_clean($this->input->post('phone')),
				'shipping_phone'	=> $this->security->xss_clean($this->input->post('phone')),
				'email'				=> $this->security->xss_clean($this->input->post('register_email')),
			);

			if($this->input->post('newsletter') == 'yes') {
				$data['newsletter'] = 'yes';
			} else {
				$data['newsletter'] = 'no';
			}

			$id_customer = (int) $this->session->userdata('customer')['customer_id'];

			$this->customer_m->update_profile($id_customer, $data); 

			// $ecustomer_data = array(
			// 	'customer_name' => $this->security->xss_clean($this->input->post('name')), 
			// );
			// $this->session->set_userdata(array('customer' => $ecustomer_data));
 

			$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:10px; padding:5px; font-weight:bold;">Profile Edit Sukses</p>');
			
			if ($this->session->userdata('dropship_summarypage') == TRUE) {
				$this->session->unset_userdata('dropship_summarypage'); 	
				redirect('summary');	
			} else {
				redirect('account/profile');
			}	
		}

	}

	//callback function validation register new handphone
	function _cek_phone($str) {

		$num_rows = $this->customer_m->cek_existing_phone($str, (int) $this->session->userdata('customer')['customer_id']); 

		if ($num_rows != 0 ) { 
			$this->form_validation->set_message('_cek_phone', 'Nomor Handphone sudah terdaftar !');
			return FALSE;
		} else {
			return TRUE; 
		}
	} 

	//callback function validation register new email
	function _cek_email($str) {

		$num_rows = $this->customer_m->cek_existing_email($str, (int) $this->session->userdata('customer')['customer_id']); 

		if ($num_rows != 0 ) { 
			$this->form_validation->set_message('_cek_email', 'Email sudah terdaftar !');
			return FALSE;
		} else {
			return TRUE; 
		}
	} 

	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->data_header['page_title'] = 'Change Shipping Address';

		$id_customer = (int) $this->session->userdata('customer')['customer_id'];

		$data['shipping'] = $this->customer_m->get_shipping($id_customer);   

		//get all countries data from countries table
		$this->db->select('*')->from('countries')->order_by('id_countries', 'ASC');
		$data['countries'] = $this->db->get()->result();

		//get all provinces data from provinces table
		$this->db->select('rajaongkir_province_id, province')->from('indonesia_provinces')->order_by('rajaongkir_province_id', 'ASC');
		$data['provinces'] = $this->db->get()->result();

		//get all shipping province data
		$data['shipping_provinces'] = $data['provinces'];

      	$current_province_id = $data['shipping']->id_province;

      	$current_shipping_province_id = $data['shipping']->shipping_id_province;

		//get all initial districts based on stored province
		$this->db->select('rajaongkir_id_district, district')->from('indonesia_districts')->where('indonesia_id_province', $current_province_id);  
		$data['district_lists'] = $this->db->get()->result();

		//get all initial shipping districts based on stored province
		$this->db->select('rajaongkir_id_district, district')->from('indonesia_districts')->where('indonesia_id_province', $current_shipping_province_id);  
		$data['shipping_district_lists'] = $this->db->get()->result();

		$current_district_id = $data['shipping']->id_district;
		$current_shipping_district_id = $data['shipping']->shipping_id_district;

		//get all initial subdistricts lists
		$this->db->select('rajaongkir_id_subdistrict, subdistrict')->from('indonesia_subdistricts')->where('indonesia_id_district', $current_district_id);  
		$data['subdistrict_lists'] = $this->db->get()->result();

		//get all initial shipping subdistricts lists
		$this->db->select('rajaongkir_id_subdistrict, subdistrict')->from('indonesia_subdistricts')->where('indonesia_id_district', $current_shipping_district_id);  
		$data['shipping_subdistrict_lists'] = $this->db->get()->result();

		//LOAD LANGUAGE FILES FOR ACCOUNT ADDRESS 
		if($this->session->userdata('site_lang') == 'english') {
			$this->lang->load('register_login', 'english');
		} else {
			$this->lang->load('register_login', 'indonesian');
		}

		//get SEO
		$this->data_header['browser_title'] =  ucwords($this->data_header['website_name']) . ' - Address'; 
		$this->data_header['meta_description'] = ucwords($this->data_header['website_name']) . ' - Address'; 
		$this->load->view("themes/$this->theme_no/header", $this->data_header);
		$this->load->view('account/shipping', $data); 
		$this->load->view("themes/$this->theme_no/footer", $this->data_footer); 
	}

	function update_shipping() {

		if (!isset($_POST['update_shipping'])) {
			redirect('account/shipping');
		}

		//validation in action
		//if country id 0 (indonesia) regular validation rule
	
		$rules = $this->customer_m->shipping_rules;   

		$this->form_validation->set_rules($rules); 
		$this->form_validation->set_error_delimiters('<div class="error">', '</div>');

		if($this->form_validation->run($this) == FALSE) {  
			//echo validation_errors(); 
			$this->shipping();  

		} else { 

			$data = array(
				'postcode' => $this->security->xss_clean($this->input->post('postcode')),
				'address' => $this->security->xss_clean($this->input->post('address')),
				'shipping_postcode' => $this->security->xss_clean($this->input->post('shipping_postcode')),
				'shipping_address' => $this->security->xss_clean($this->input->post('shipping_address'))
			);

			//UPDATE BILLING ADDRESS
			$data['id_province'] = (int) $this->input->post('shipping_province');
			$data['id_district'] = (int) $this->input->post('shipping_district');
			$data['id_subdistrict'] = (int) $this->input->post('shipping_subdistrict');
			$data['id_country'] =  0;
			$data['country'] =  'Indonesia';

			//get province name
			$this->db->select('province')->from('indonesia_provinces')->where('rajaongkir_province_id', (int) $this->input->post('shipping_province'));
			$data['province'] = $this->db->get()->row()->province;

			//get district name
			$this->db->select('district')->from('indonesia_districts')->where('rajaongkir_id_district', (int) $this->input->post('shipping_district'));
			$data['district'] = $this->db->get()->row()->district;

			//get subdistrict name
			$this->db->select('subdistrict')->from('indonesia_subdistricts')->where('rajaongkir_id_subdistrict', (int) $this->input->post('shipping_subdistrict'));
			$data['subdistrict'] = $this->db->get()->row()->subdistrict;
				
			//UPDATE SHIPPING ADDRESS
			//this is indonesia
			$data['shipping_id_province'] = (int) $this->input->post('shipping_province');
			$data['shipping_id_district'] = (int) $this->input->post('shipping_district');
			$data['shipping_id_subdistrict'] = (int) $this->input->post('shipping_subdistrict');
			$data['shipping_id_country'] =  0;
			$data['shipping_country'] =  'Indonesia';

			//get province name
			$this->db->select('province')->from('indonesia_provinces')->where('rajaongkir_province_id', (int) $this->input->post('shipping_province'));
			$data['shipping_province'] = $this->db->get()->row()->province;
			
			//get district name
			$this->db->select('district')->from('indonesia_districts')->where('rajaongkir_id_district', (int) $this->input->post('shipping_district'));
			$data['shipping_district'] = $this->db->get()->row()->district;

			//get subdistrict name
			$this->db->select('subdistrict')->from('indonesia_subdistricts')->where('rajaongkir_id_subdistrict', (int) $this->input->post('shipping_subdistrict'));
			$data['shipping_subdistrict'] = $this->db->get()->row()->subdistrict;
				
			$id_customer = (int) $this->session->userdata('customer')['customer_id'];

			$this->customer_m->update_shipping($id_customer, $data);  

			$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:10px; padding:5px; font-weight:bold;">Edit Alamat Kirim Sukses</p>');

			if ($this->session->userdata('shipping_summarypage') == TRUE) {
				
				$this->session->unset_userdata('shipping_summarypage'); 	
				
				redirect('summary');	

			} else {
				redirect('account/shipping');
			}	
		}
	}

	function change_password() { 
		
		$this->data_header['page_title'] = 'Change Password';

		$id_customer = (int) $this->session->userdata('customer')['customer_id'];

		$data['customer'] = $this->customer_m->get_customer($id_customer);

		//LOAD LANGUAGE FILES FOR profile & change password
		if($this->session->userdata('site_lang') == 'english') {
			$this->lang->load('myprofile', 'english');
		} else {
			$this->lang->load('myprofile', 'indonesian');
		}

		//get SEO
		$this->data_header['browser_title'] =  ucwords($this->data_header['website_name']) . ' - Change Password'; 
		$this->data_header['meta_description'] = ucwords($this->data_header['website_name']) . ' - Change Password'; 
		$this->load->view("themes/$this->theme_no/header", $this->data_header);
		$this->load->view('account/change_password', $data); 
		$this->load->view("themes/$this->theme_no/footer", $this->data_footer); 
	}

	function update_change_password() {

		if (!isset($_POST['change_password'])) {  
			redirect('account/change_password'); 
		}

		//validation in action
		$rules = array(
			'password_old' => array(
				'field'=>'password_old', 
				'label'=>'Old Password', 
				'rules'=>'trim|required|callback__cek_oldpassword'),	
			
			'password' => array(
				'field'=>'password', 
				'label'=>'Password', 
				'rules'=>'trim|required'),

			'confirm_password' => array(
				'field'=>'confirm_password', 
				'label'=>'Confirm Password', 
				'rules'=>'trim|required|matches[password]'),	
		);   

		$this->form_validation->set_rules($rules); 
		$this->form_validation->set_error_delimiters('<div class="error">', '</div>');

		if($this->form_validation->run($this) == FALSE) {  
		
			$this->change_password();

		} else {

			$data = array();
			
			if ($this->input->post('password')) {
				$data['password'] = $this->customer_m->hash($this->input->post('password'));
			}

			$id_customer = (int) $this->session->userdata('customer')['customer_id'];

			$this->customer_m->update_profile($id_customer, $data); 

			$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:10px; padding:5px; font-weight:bold;">Password sukses dirubah</p>');
			 
			redirect('account/change_password');
			
		}

	}	

	function _cek_oldpassword($str) {

		$password = $this->customer_m->hash($str);

		//check if password exist..
		$this->db->select('id_customers')->from('customers')->where('password', $password)->where('id_customers', (int) $this->session->userdata('customer')['customer_id']);
		$count_password = $this->db->get()->num_rows();

		if($count_password == 0) {
			$this->form_validation->set_message('_cek_oldpassword', 'Password tidak cocok !');
			return FALSE;
		} else {
			return TRUE;
		}

	}

	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); 

		//LOAD LANGUAGE FILES 
		if($this->session->userdata('site_lang') == 'english') {
			$this->lang->load('order_history', 'english');
		} else {
			$this->lang->load('order_history', 'indonesian');
		}

		//get SEO
		$this->data_header['browser_title'] =  ucwords($this->data_header['website_name']) . ' - Order History'; 
		$this->data_header['meta_description'] = ucwords($this->data_header['website_name']) . ' - Order History'; 
		$this->load->view("themes/$this->theme_no/header", $this->data_header);
		$this->load->view('account/order_history', $data); 
		$this->load->view("themes/$this->theme_no/footer", $this->data_footer); 
	}

	public function point_rewards() { 

		$q_point_rewards = $this->db->get_where("point_rewards",array(
			'id_point_rewards'=>1
		))->row(); 

		if ($q_point_rewards->active == 'no') {
			show_404();
		}

		$this->load->model('order_m');

		$this->data_header['page_title'] = 'My Point rewards';

		$id_customer = (int) $this->session->userdata('customer')['customer_id'];

		$data['order_history'] = $this->order_m->get_order_history($id_customer); 

		//get customer current point rewards
		$this->db->select('current_pointreward')->from('customers')->where('id_customers', $this->session->userdata('customer')['customer_id']);
		$data['current_point'] = $this->db->get()->row()->current_pointreward;

		//LOAD LANGUAGE FILES
		if($this->session->userdata('site_lang') == 'english') {
			$this->lang->load('pointrewards', 'english');
		} else {
			$this->lang->load('pointrewards', 'indonesian');
		}

		//get SEO
		$this->data_header['browser_title'] =  ucwords($this->data_header['website_name']) . ' - Point Reward'; 
		$this->data_header['meta_description'] = ucwords($this->data_header['website_name']) . ' - Point Reward'; 
		$this->load->view("themes/$this->theme_no/header", $this->data_header);
		$this->load->view('account/point_rewards', $data); 
		$this->load->view("themes/$this->theme_no/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');

		$query = $this->db->select('*')
				->from('orders')
				->where('id_orders', $data['order_id'])
				->get()
				->row();
		$data['data_order'] = $query;

		$this->data_header['page_title'] = 'Payment Confirmation';

		//LOAD LANGUAGE FILES 
		if($this->session->userdata('site_lang') == 'english') {
			$this->lang->load('payment_confirmation', 'english');
		} else {
			$this->lang->load('payment_confirmation', 'indonesian');
		}

		//get SEO
		$this->data_header['browser_title'] =  ucwords($this->data_header['website_name']) . ' - Payment Confirmation'; 
		$this->data_header['meta_description'] = ucwords($this->data_header['website_name']) . ' - Payment Confirmation'; 

		$this->load->view("themes/$this->theme_no/header", $this->data_header);
		$this->load->view('account/payment_confirmation', $data); 
		$this->load->view("themes/$this->theme_no/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'
              ),
			array(
                 'field'   => 'account_number',
                 'label'   => 'Account Number',
                 'rules'   => 'required|trim'
              )
        );

		$this->form_validation->set_rules($config); 

		$this->form_validation->set_error_delimiters('<div class="error">', '</div>');

		if($this->form_validation->run($this) == FALSE) { 

			$data['order_id'] = (int) $this->input->post('order_id'); 
			$data_header['page_title'] = 'Payment Confirmation';

			//LOAD LANGUAGE FILES 
			if($this->session->userdata('site_lang') == 'english') {
				$this->lang->load('payment_confirmation', 'english');
			} else {
				$this->lang->load('payment_confirmation', 'indonesian');
			}

			//get SEO
			$this->data_header['browser_title'] =  ucwords($this->data_header['website_name']) . ' - Payment Confirmation'; 
			$this->data_header['meta_description'] = ucwords($this->data_header['website_name']) . ' - Payment Confirmation'; 
			$this->load->view("themes/$this->theme_no/header", $this->data_header);
			$this->load->view('account/payment_confirmation', $data); 
			$this->load->view("themes/$this->theme_no/footer", $this->data_footer); 

		} else {

			//check & processing IMAGE 1	
			if ($_FILES['receipt_file']['size'] !== 0) { 	
				$config['upload_path'] 		= './uploads/receipt_file/'; 
				$config['allowed_types'] 	= 'jpeg|jpg|png|pdf'; 
				$config['max_size']			= '5000';
				$this->load->library('upload', $config); 
				$this->upload->initialize($config); 
				if (!$this->upload->do_upload('receipt_file')) {
					echo $this->upload->display_errors();die;
					$this->session->set_flashdata('receipt_file_error', '<br>
					<p style="background:red; color:white; padding:5px; font-weight:bold;">Image Upload Error. Wrong format.</p>');
					//echo $this->upload->display_errors(); exit();
					redirect('account/payment_confirmation');
				} else {
					$image = $this->upload->data();
					$image_name =  $image['file_name'];
				}
			}

			$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 = $this->security->xss_clean(ucwords($this->input->post('account_name')));
			$account_number = $this->security->xss_clean(ucwords($this->input->post('account_number')));

			$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>From Acc Name: ' . $account_name . '</p>' . 
			'<p>From Acc No: ' . $account_number . '</p>' .
			'<p>Receipt file: <a href="'.base_url('uploads/receipt_file/').$image_name.'">' . $image_name . '</a></p>';

			$case_payment = $this->input->post('case_payment');

			$data = array(
				'payment_confirm' => 1,
				'payment_confirm_details' => $payment_confirm_details,				
			);

			if($case_payment == 'ke-2'){
				$data = array(
					'payment_confirm_remaining' => 1,
					'payment_confirm_details_remaining' => $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
			//get customer name
			$customer_id = (int) $this->session->userdata('customer')['customer_id'];
			$this->db->select('name')->from('customers')->where('id_customers', $customer_id);
			$data['customer_name'] = $this->db->get()->row()->name;
			//get website data
			$this->db->select('logo, from_email, website_name, email_smtp_host, email_smtp_port, email_smtp_password, email_smtp')->from('configuration')->where('id_configuration', 1);
			$website_data = $this->db->get()->row();
			$data['logo'] = $website_data->logo;
			$data['website_name'] = $website_data->website_name;
			$this->load->model('configuration_m');
			$data['emails'] = $this->configuration_m->get_emails();  
			$data['bank'] = $this->configuration_m->get_bank();   
			$data['title'] = 'Customer Payment Confirmation'; 

			if($case_payment == 'ke-2'){ 
				$data['title'] = 'Customer Payment Confirmation 2'; 
			}

			$this->load->library('email');
			//get email setting 
			$config['protocol'] = 'smtp';
			$config['smtp_host'] = $website_data->email_smtp_host; 
			$config['smtp_port'] = $website_data->email_smtp_port;
			$config['smtp_user'] = $website_data->email_smtp; 
			$config['smtp_pass'] = $website_data->email_smtp_password;
			$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->email->initialize($config);
			$this->email->from($data['emails']->from_email, $data['emails']->website_name);
			$this->email->to($data['emails']->from_email); 
			$this->email->subject('Customer Payment Confirmation'); 

			if($case_payment == 'ke-2'){
				$this->email->subject('Customer Payment Confirmation 2'); 
			}
			
			$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 .= "<tr><td><strong>Account Number:</strong> </td><td>" . $account_number . "</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();  
			//----end send email 
			$this->session->set_flashdata('success', '<br><p style="background:green; 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');	
		}
	}

}

https://t.me/RX1948 - 2025