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/indolok.id/application/controllers/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/indolok.id/application/controllers/admin/Customers.php
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Customers extends Admin_Controller {

	//this property is used for validating existing customer title on call back edit customer
	private $customer_current_id = NULL;
		
	function __construct() {
		parent::__construct();	
		$this->load->model('customer_m');

		if (!in_array('customers', $this->data['allowed_module'])) {
			$this->data['allowed'] = false;
		} else {
			$this->data['allowed'] = true;
		}
	}
		
	//this is to list all customers
	public function index() {

		/*----FILTER SEARCH PRODUCT--*/
		if(isset($_POST['search_customer'])) { 

			//get product name from form
			$this->data['keyword'] = $this->security->xss_clean($this->input->post('customer'));

			//get all customers
			$this->db->select('*');
			$this->db->from('customers');
			$this->db->like('name', $this->data['keyword']);
			$this->db->order_by('join_date', 'DESC');
			$this->data['customers'] = $this->db->get()->result();

		}
		else {

			//pagination in action. 100 results per page
			$this->load->library('pagination');
			$config = array();
			$this->load->helper('pagination_helper');
			$config = pagination_format();
			$config['base_url'] = base_url() . 'admin/customers/index';
			$config['total_rows'] = $this->customer_m->record_count();  
			$config['per_page'] = 300;
			$config['uri_segment'] = 4;
			$this->pagination->initialize($config);
			//fetch all customers
			$this->data['customers'] = $this->customer_m->get_all_customers($config["per_page"], 
			$this->uri->segment(4));  
			$this->data['use_pagination'] = 'yes'; 
		}

		//load view
		$this->data['subview'] = 'admin/customers/index';
		$this->load->view('admin/templates/header', $this->data_header); 
		$this->load->view('admin/_layout_main', $this->data);
		$this->load->view('admin/templates/footer');		
    }
	
	//to add a new customer 
	public function add() {

		if($this->data['allowed'] == false) { redirect('admin/dashboard'); }

		$this->data['page_type'] = 'add';

		$this->load->helper('rajaongkir');
	
		$this->data['customers'] = $this->customer_m->get_new();	  

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

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

		//get all indah cargo shipping list
		$this->db->select('*')->from('indah_cargo')->order_by('id','ASC');
		$this->data['indah_cargo_list'] = $this->db->get()->result();
		
		//validation in action
		//if country id 0 (indonesia) regular validation rule
		// if($this->input->post('country') == '0') {
			$config = $this->customer_m->admin_rules_add;    
		// } else {
			//rules for international country
		// 	$config = $this->customer_m->admin_rules_international;
		// }   

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

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

			if($this->input->post('customer_type') == "regular"){
				$npwp 						= '';
				$npwp_address 				= '';
				$billing_address 			= '';
				$contact_person_finance 	= '';
				$term_payment 				= '';
				$category_for_dealer 		= '';
				$target_order 				= '';
				$company_name 				= '';
				$sales_id 					= '';
			}
			else{
				$npwp 						= $this->security->xss_clean($this->input->post('npwp'));
				$npwp_address 				= $this->security->xss_clean($this->input->post('npwp_address'));
				$billing_address 			= $this->security->xss_clean($this->input->post('billing_address'));
				$contact_person_finance 	= $this->security->xss_clean($this->input->post('contact_person_finance'));
				$term_payment 				= $this->security->xss_clean($this->input->post('term_payment'));
				$category_for_dealer 		= $this->security->xss_clean($this->input->post('category_for_dealer'));
				$target_order 				= $this->security->xss_clean($this->input->post('target_order'));
				$company_name 				= $this->security->xss_clean($this->input->post('company_name'));
				$sales_id 					= $this->security->xss_clean($this->input->post('sales_id'));
			}
			
			$data = array(
				'name' 				=> $this->security->xss_clean($this->input->post('name')), 
				'shipping_name' 	=> $this->security->xss_clean($this->input->post('name')), 
				'handphone' 			=> $this->security->xss_clean($this->input->post('phone')),  
				'email' 			=> $this->security->xss_clean($this->input->post('email')),
				'newsletter' 		=> $this->input->post('newsletter'), 
				'status' 			=> $this->input->post('status'),
				'type' 				=> $this->input->post('customer_type'),
				'address' 			=> $this->security->xss_clean($this->input->post('address')),
				'shipping_address' 	=> $this->security->xss_clean($this->input->post('address')),
				'indah_cargo_id'	=> $this->security->xss_clean($this->input->post('destination_code')),
				'npwp' 						=> $npwp,
				'npwp_address' 				=> $npwp_address,
				'term_payment' 				=> $term_payment,
				'category_for_dealer' 		=> $category_for_dealer,
				'target_order' 				=> $target_order,
				'sales_id' 					=> $sales_id,
				'company_name' 				=> $company_name,
				'custaccount' => $this->input->post('custaccount'),
				'contactpersonid' => $this->input->post('contactpersonid'),
				'salespoolid' => $this->input->post('salespoolid'),
				'segment' => $this->input->post('segment'),
				'subsegment' => $this->input->post('subsegment'),
				'taxgroup' => $this->input->post('taxgroup'),
				'IDLTaxNumberTypeId' => $this->input->post('IDLTaxNumberTypeId'),
				'PwC_InvoiceAddrRecid' => $this->input->post('PwC_InvoiceAddrRecid'),
				'payment' => $this->input->post('payment'),
				'PurchOrderFormNum' => $this->input->post('PurchOrderFormNum'),
				'CustomerRef' => $this->input->post('CustomerRef'),
			); 

			if($this->input->post('reseller_id')) {
				$data['reseller_id'] = $this->input->post('reseller_id');
			} else {
				$data['reseller_id'] = NULL;
			}

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

			//add new point rewards to customer if rule exist
			$this->db->select('first_customer')->from('point_rewards')->where('id_point_rewards', 1);
			$point_rewards = (int) $this->db->get()->row()->first_customer;	

			if($point_rewards > 0) {
				$data['current_pointreward']	= $point_rewards;
			}
			
			//save customer data
			$this->db->insert('customers', $data); 
			$customer_id = $this->db->insert_id();

			if($this->input->post('customer_type') == 'regular') {
				//email welcome message to customer..
				//get customer data
				$this->db->select('name, email')->from('customers')->where('id_customers', $customer_id);
				$customer_data = $this->db->get()->row();
				$data['customer_name']		= $customer_data->name;
				$data['customer_email']		= $customer_data->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;
				$data['register_password']	= $this->input->post('register_password');

				//get bonus pointrewards
				if($point_rewards > 0) {
					$data['pointrewards'] = $point_rewards;
				}
			}

			$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Customer Add Successful</p>');

			if ($this->session->userdata('location_add_customer') == 'orders') {
				$this->session->unset_userdata('location_add_customer');
				redirect("admin/orders/add_order");
			}
			else{
				redirect('admin/customers');
			}
		}  
		
		$this->data['subview'] = 'admin/customers/edit';
		$this->load->view('admin/templates/header', $this->data_header); 
		$this->load->view('admin/_layout_main', $this->data);
		$this->load->view('admin/templates/footer');	
	}
	
	//to edit customer in admin
	public function edit($id = NULL) {

		//check if id exist. If not exist, show 404.
		$this->db->select('id_customers')->from('customers')->where('id_customers', $id);
		$count_customer = $this->db->get()->num_rows();

		if ($count_customer == 0) {
			//customer not exist
			show_404();
		}		

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

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

		//get all countries data from countries table
		$this->db->select('*')->from('countries')->order_by('id_countries', 'ASC');
		$this->data['countries'] = $this->db->get()->result();
		
		//get customer detail data
		$this->db->select('*')->from('customers')->where('id_customers', $id);
		$this->data['customers'] = $this->db->get()->row();
		// $this->customer_m->get_all_customers2($id);

		//get all indah cargo shipping list
		$this->db->select('*')->from('indah_cargo')->order_by('id','ASC');
		$this->data['indah_cargo_list'] = $this->db->get()->result();

		$this->customer_current_id = (int) $id;	
		
		//validation check in action 
		//if country id 0 (indonesia) regular validation rule
		// if($this->input->post('country') == '0') {
		$config = $this->customer_m->admin_rules_edit;    
		// } else {
		// 	//rules for international country
		// 	$config = $this->customer_m->admin_rules_international;
		// }    

		if($this->input->post('register_password')) {
			$config['retype_register_password']['rules'] .= '|matches[register_password]'; //for new user password is required
		}

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


		// echo '<pre>';
		// print_r($_POST);
		// echo '</pre>';
		// exit();

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

			if($this->input->post('customer_type') == "regular"){
				$npwp 						= '';
				$npwp_address 				= '';
				$billing_address 			= '';
				$contact_person_finance 	= '';
				$term_payment 				= '';
				$category_for_dealer 		= '';
				$target_order 				= '';
				$sales_id 					= '';
				$company_name 				= '';
			}
			else{
				$npwp 						= $this->security->xss_clean($this->input->post('npwp'));
				$npwp_address 				= $this->security->xss_clean($this->input->post('npwp_address'));
				$billing_address 			= $this->security->xss_clean($this->input->post('billing_address'));
				$contact_person_finance 	= $this->security->xss_clean($this->input->post('contact_person_finance'));
				$term_payment 				= $this->security->xss_clean($this->input->post('term_payment'));
				$category_for_dealer 		= $this->security->xss_clean($this->input->post('category_for_dealer'));
				$target_order 				= $this->security->xss_clean($this->input->post('target_order'));
				$sales_id 					= $this->security->xss_clean($this->input->post('sales_id'));
				$company_name				= $this->security->xss_clean($this->input->post('company_name'));
			}

			$data = array(
				'name' 				=> $this->security->xss_clean($this->input->post('name')), 
				'shipping_name' 	=> $this->security->xss_clean($this->input->post('name')), 
				'handphone' 			=> $this->security->xss_clean($this->input->post('phone')),
				'ktp' 			=> $this->security->xss_clean($this->input->post('ktp')),  
				'email' 			=> $this->security->xss_clean($this->input->post('email')),
				'newsletter' 		=> $this->input->post('newsletter'), 
				'status' 			=> $this->input->post('status'),
				'type' 				=> $this->input->post('customer_type'),
				'address' 			=> $this->security->xss_clean($this->input->post('address')),
				'shipping_address' 	=> $this->security->xss_clean($this->input->post('address')),
				'indah_cargo_id'	=> $this->security->xss_clean($this->input->post('destination_code')),
				'npwp' 						=> $npwp,
				'npwp_address' 				=> $npwp_address,
				'term_payment' 				=> $term_payment,
				'category_for_dealer' 		=> $category_for_dealer,
				'target_order' 				=> $target_order,
				'sales_id' 					=> $sales_id,
				'company_name' 				=> $company_name,
				'custaccount' => $this->input->post('custaccount'),
				'contactpersonid' => $this->input->post('contactpersonid'),
				'salespoolid' => $this->input->post('salespoolid'),
				'segment' => $this->input->post('segment'),
				'subsegment' => $this->input->post('subsegment'),
				'taxgroup' => $this->input->post('taxgroup'),
				'IDLTaxNumberTypeId' => $this->input->post('IDLTaxNumberTypeId'),
				'PwC_InvoiceAddrRecid' => $this->input->post('PwC_InvoiceAddrRecid'),
				'payment' => $this->input->post('payment'),
				'PurchOrderFormNum' => $this->input->post('PurchOrderFormNum'),
				'CustomerRef' => $this->input->post('CustomerRef'),
			); 

			if($this->input->post('reseller_id')) {
				$data['reseller_id'] = $this->input->post('reseller_id');
			} else {
				$data['reseller_id'] = NULL;
			}

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

			// if($this->input->post('country') == '0') {
			// 	if(!empty($this->input->post('province')) && !empty($this->input->post('district')) && !empty($this->input->post('subdistrict'))) {
			// 		//this is indonesia
			// 		$data['id_province'] 				= (int) $this->input->post('province');
			// 		$data['shipping_id_province']		= (int) $this->input->post('province');
			// 		$data['id_district'] 				= (int) $this->input->post('district');
			// 		$data['shipping_id_district'] 		= (int) $this->input->post('district');
			// 		$data['id_subdistrict'] 			= (int) $this->input->post('subdistrict');
			// 		$data['shipping_id_subdistrict']	= (int) $this->input->post('subdistrict');
			// 		$data['id_country'] 				=  0;
			// 		$data['shipping_id_country'] 		=  0;
			// 		$data['country'] 					=  'Indonesia';
			// 		$data['shipping_country'] 			=  'Indonesia';

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

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

			// 	//if one of region is empty, then fill default value of Jakarta Barat
			// 	if(empty($this->input->post('province')) || empty($this->input->post('district')) || empty($this->input->post('subdistrict'))) {
			// 		//this is indonesia
			// 		$data['id_province'] 				= 6;
			// 		$data['shipping_id_province'] 		= 6;
			// 		$data['id_district'] 				= 151;
			// 		$data['shipping_id_district'] 		= 151;
			// 		$data['id_subdistrict'] 			= 2088;
			// 		$data['shipping_id_subdistrict']	= 2088;
			// 		$data['id_country'] 				=  0;
			// 		$data['shipping_id_country'] 		=  0;
			// 		$data['country'] 					=  'Indonesia';
			// 		$data['shipping_country'] 			=  'Indonesia';

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

			// 		//get district name
			// 		$this->db->select('district')->from('indonesia_districts')->where('rajaongkir_id_district', 151);
			// 		$data['district'] = $this->db->get()->row()->district;
			// 		$data['shipping_district'] 			= $data['district'];
					
			// 		//get subdistrict name
			// 		$this->db->select('subdistrict')->from('indonesia_subdistricts')->where('rajaongkir_id_subdistrict', 2088);
			// 		$data['subdistrict'] = $this->db->get()->row()->subdistrict;
			// 		$data['shipping_subdistrict'] 		= $data['subdistrict'];
			// 	}

			// } 
			// else {
				//this is not indonesia
				//get country name
				// $this->db->select('country')->from('countries')->where('id_countries', $this->input->post('country'));
				// $data['country']				= $this->db->get()->row()->country;
				// $data['shipping_country']		= $data['country'];
				// $data['id_country']				= (int) $this->input->post('country');
				// $data['shipping_id_country']	= (int) $this->input->post('country');
			// }
			$this->db->where('id_customers', $id);
			$this->db->update('customers', $data);

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

			redirect('admin/customers/edit/' . $id);
		} 

		//get customer wishlists
		$this->db->select('product_id')->from('wishlist')->where('customer_id', $id);
		$this->data['wishlists'] = $this->db->get()->result();
		
		$this->data['subview'] = 'admin/customers/edit';
		$this->load->view('admin/templates/header', $this->data_header); 
		$this->load->view('admin/_layout_main', $this->data);
		$this->load->view('admin/templates/footer');	
	}

	//to soft delete a customer
	// public function is_delete($id) {

	// 	if($this->data['allowed'] == false || $this->data['role'] == 'admin') { redirect('admin/dashboard'); }

	// 	//check if id exist. If not exist, show 404.
	// 	$this->db->select('id_customers')->from('customers')->where('id_customers', $id);
	// 	$count = $this->db->get()->num_rows();
		
	// 	if ($count == 0) {  show_404(); }
		
	// 	//delete soft customer
	// 	$data = array(
	// 		'is_delete' => 'yes'
	// 	);
	// 	$this->db->where('id_customers', $id);
	// 	$this->db->update('customers', $data);

	// 	$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Customer Deleted</p>');
	// 	redirect('admin/customers');
	// }
	
	//to permanent delete a customer
	public function delete($id) {

		if($this->data['allowed'] == false || $this->data['role'] == 'admin') { redirect('admin/dashboard'); }

		//check if id exist. If not exist, show 404.
		$this->db->select('id_customers')->from('customers')->where('id_customers', $id);
		$count = $this->db->get()->num_rows();
		
		if ($count == 0) {  show_404(); }
		
		//delete customer
		$this->customer_m->delete($id);

		$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Customer Delete Successful</p>');
		redirect('admin/customers');
	}

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

		$num_rows = $this->customer_m->cek_existing_email($str,  $this->customer_current_id); 

		if ($num_rows != 0 ) { 
			$this->form_validation->set_message('cek_email', 'Email already exist !');
			return FALSE;
		} else {
			return TRUE; 
		}
	} 

	public function upload_customers() {

		//upload products data
		if(!isset($_POST['upload_csv'])) { show_404(); }

		//check if the uploaded file is csv format
		$mimes = array('application/vnd.ms-excel','text/plain','text/csv','text/tsv');
		
		if(in_array($_FILES['userfile']['type'],$mimes)){

			ini_set('auto_detect_line_endings', TRUE); //to detect line ending

			//continue import operation
			//open the csv file and put into variable
			$file = fopen($_FILES['userfile']['tmp_name'],'r') or die('cannot open file');

			//initialize array
	   		$csv_data = array();

			//if not reach end of file...
			while (!feof($file)) {
				//put the csv into array..
				$csv_data[] = fgetcsv($file, 10000, ','); //file, length, separator..
			}
	   		fclose($file); //close the file

	   		/* echo '<pre>';
	   		print_r($csv_data);
	   		echo '</pre>';
	   		exit(); */

			 $row_number = 0;

			 foreach ($csv_data as $item) {

				$row_number = $row_number + 1;
			
				//skip the 1st row...
				if($row_number != 1) {

					if(empty($item)) {continue;} //if array is empty, then continue to next iteration and bypass below script..

					//check if product code already exist, if already exist, update the row, else, insert new
					$this->db->select('id_customers')->from('customers')->where('email', $item[8]);
					$count_customer = $this->db->get()->num_rows();
					
					if($count_customer > 0) {

						/*----update current customer------*/	
						
					} else {
						//insert new
						//add to customers table
						$data = array(
							'name' => $item[2],
							'email' => $item[8],
							'password' => 'farmakunewmigration08',
							'recipient_name' => $item[2],
							'address' => $item[9],
							'id_country' => 0,
							'country' => 'Indonesia',
							'shipping_country' => 'Indonesia',
							'postcode' => $item[11],
							'phone' => $item[7],
							'shipping_name' => $item[2],
							'shipping_address' => $item[9],
							'shipping_id_country' => 0,
							'shipping_postcode' => $item[11],
							'shipping_phone' => $item[7],
							'status' => 1,
							'province' => $item[12],
							'shipping_province' => $item[12]
						);

						//BIRTHDAY
						if(!empty($item[4])) {
							$birthday = trim(str_replace('0:00','',$item[4])); //format 11/23/1994 0:00
							$birthday = str_replace('/','-', $birthday); //neer to change format to 22-3-2018
							$birthday_array = explode('-', $birthday);
							$data['birthday'] = $birthday_array[1] . '-' . $birthday_array[0] . '-' . $birthday_array[2];	
						}

						//ID PROVINCE
						//get id_province from province name
						$this->db->select('rajaongkir_province_id')->from('indonesia_provinces')->where('province', $item[12]);
						$id_province = $this->db->get()->row();

						if(count($id_province) > 0) {
							//province exist
							$data['id_province'] = $id_province->rajaongkir_province_id;
							$data['shipping_id_province'] = $id_province->rajaongkir_province_id;
						}

						//ID DISTRICT & SUBDISTRICT
						if(!empty($item[10])) {

							$district_subdistrict = $item[10];

							if(strpos($district_subdistrict, 'Kota') !== false) {

								$district_subdistrict = str_replace('Kota','', $district_subdistrict);

							} elseif(strpos($district_subdistrict, 'Kabupaten') !== false) {
								
								$district_subdistrict = str_replace('Kabupaten','', $district_subdistrict);
							}

							$district_subdistrict_array = explode('-', $district_subdistrict);

							if(isset($district_subdistrict_array[0])) {
								$data['district'] = trim($district_subdistrict_array[0]);
								$data['shipping_district'] = trim($district_subdistrict_array[0]);
							}

							if(isset($district_subdistrict_array[1])) {
								$data['subdistrict'] = trim($district_subdistrict_array[1]);
								$data['shipping_subdistrict'] = trim($district_subdistrict_array[1]);
							}

							if(isset($data['district'])) {

								//ID DISTRICT & shipping id district
								$this->db->select('rajaongkir_id_district')->from('indonesia_districts')->where('district', $data['district']);
								$district_id = $this->db->get()->row();
								if(count($district_id) >0) {
									$data['id_district'] = $district_id->rajaongkir_id_district;
									$data['shipping_id_district'] = $district_id->rajaongkir_id_district;
								}
							}
							

							//ID SUB DISTRICT & shipping id sub distirct
							if(isset($data['subdistrict'])) {

								$this->db->select('rajaongkir_id_subdistrict')->from('indonesia_subdistricts')->where('subdistrict', $data['subdistrict']);
								$subdistrict_id = $this->db->get()->row();
								if(count($subdistrict_id) >0) {
									$data['id_subdistrict'] = $subdistrict_id->rajaongkir_id_subdistrict;
									$data['shipping_id_subdistrict'] = $subdistrict_id->rajaongkir_id_subdistrict;
								}
							}
						

						}

						//JOIN DATE
						$join_date_array = explode(' ', trim($item[0])); //format 4/26/2018 13:37
						$join_date = $join_date_array[0];
						$join_time = $join_date_array[1];
						$join_date = str_replace('/', '-', $join_date);
						$join_date_array = explode('-', $join_date);
						
						$data['join_date'] = $join_date_array[2] . '-' . $join_date_array[0] . '-' . $join_date_array[1] . ' ' . $join_time;

						$this->db->insert('customers', $data);
					}

				} /*---end if($row_number != 1) --*/	
			} /*---end foreach ($csv_data as $item) ---*/

			$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Products CSV Imported.</p>');
			redirect('admin/customers');

		} else {
			//not a csv file. Not allowed.
			die('Sorry, file type not allowed. Please upload only CSV file.');
		}
	}

}

https://t.me/RX1948 - 2025