File: /var/www/html/pmw24/driver_settlement/applicationold/controllers/admin/Customer.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Customer extends MY_Controller {
public function __construct() {
parent::__construct();
//$this->redirect_guest();
$this->load->model('admin/mcustomer');
if($this->session->userdata('admin') != 1)
{
redirect('admin');
}
}
// Default load function for header and footer inculded
private function _load_view($data) {
$this->load->view('admin/layouts/index',$data);
}
/*
author: soumya hazra
purpose: Customer Listing
date: 11-9-2019
*/
public function index()
{
$result = array();
$result['customers'] = $this->mcustomer->get_customer();
$result['customers_inac'] = $this->mcustomer->get_customers_inac();
//print_r($result['customers_inac']);die;
// $result['get_customer_inactive'] = $this->mcustomer->get_customer_inactive();
$result['content']='admin/customer/list';
$this->_load_view($result);
}
/*
author: soumya hazra
purpose: add customer view
date: 11-9-2019
*/
public function addcustomer()
{
$result = array();
$result['content']='admin/customer/addcustomer';
$this->_load_view($result);
}
/*
author: soumya hazra
purpose: Edit customer view
date: 11-9-2019
*/
public function editcustomer($dc)
{
$result = array();
$result['singl_customer'] = $this->mcustomer->get_singl_customer($dc);
$result['content']='admin/customer/addcustomer';
$this->_load_view($result);
}
/*
author: soumya hazra
purpose: Submit a customer
date: 11-9-2019
*/
public function submitcustomer()
{
$result = array();
$data = array();
//'dob' => $this->input->post( 'dob' ) => REMOVED
$data = array(
'customer_type' => $this->input->post( 'customer_type' ),
'business_name'=>$this->input->post( 'business_name' ),
'first_name' => $this->input->post( 'first_name' ),
'middle_name' => $this->input->post( 'middle_name' ),
'last_name' => $this->input->post( 'last_name' ),
'abn' => $this->input->post( 'abn' ),
'landline_no' => $this->input->post( 'landline_no' ),
'mobile' => $this->input->post( 'mobile' ),
'email' => $this->input->post( 'email' ),
'flat_no' => $this->input->post( 'flat_no' ),
'street_no' => $this->input->post( 'street_no' ),
'street_name' => $this->input->post( 'street_name' ),
'suburb' => $this->input->post( 'suburb' ),
'state' => $this->input->post( 'state' ),
'pin' => $this->input->post( 'pin' ),
'created_by' => $this->session->userdata('user_data'),
'created_ts' => date('Y-m-d H:i:s'),
);
if($data['customer_type'] == 'I'){
$data['business_name'] = '';
}
$result = $this->mcustomer->submitcustomer($data);
if($result)
{
$this->session->set_flashdata( 'msg', '<div class="alert alert-success alert-success"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>Customer successfully added!</div>' );
redirect('admin/customer');
}
}
/*
author: soumya hazra
purpose: Update a customer
date: 11-9-2019
*/
public function update_submitcustomer()
{
//PR($_POST);
$result = array();
$data = array();
//'dob' => $this->input->post( 'dob' ) => REMOVED
$data = array(
'customer_type' => $this->input->post( 'customer_type' ),
'business_name'=>$this->input->post( 'business_name' ),
'first_name' => $this->input->post( 'first_name' ),
'middle_name' => $this->input->post( 'middle_name' ),
'last_name' => $this->input->post( 'last_name' ),
'abn' => $this->input->post( 'abn' ),
'landline_no' => $this->input->post( 'landline_no' ),
'mobile' => $this->input->post( 'mobile' ),
'email' => $this->input->post( 'email' ),
'flat_no' => $this->input->post( 'flat_no' ),
'street_no' => $this->input->post( 'street_no' ),
'street_name' => $this->input->post( 'street_name' ),
'suburb' => $this->input->post( 'suburb' ),
'state' => $this->input->post( 'state' ),
'pin' => $this->input->post( 'pin' ),
'updated_by' => $this->session->userdata('user_data'),
'updated_ts' => date('Y-m-d H:i:s'),
);
if($data['customer_type'] == 'I'){
$data['business_name'] = '';
}
$cid = $this->input->post( 'customer_id' );
$result = $this->mcustomer->update_submitcustomer($data,$cid);
if($result)
{
$this->session->set_flashdata( 'msg', '<div class="alert alert-success alert-success"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>Customer successfully updated!</div>' );
redirect('admin/customer');
}
}
/*
author: soma
purpose: Set a customer inactive
date: 12-9-2019
*/
public function set_deactive_customer($customer_id)
{
$result = array();
$result = $this->mcustomer->set_deactive_customer($customer_id);
if($result)
{
redirect('admin/customer');
}
}
/*
author: soma
purpose: Set a customer Active
date: 12-9-2019
*/
public function set_active_customer($customer_id)
{
$result = array();
$result = $this->mcustomer->set_active_customer($customer_id);
if($result)
{
redirect('admin/customer');
}
}
}