File: /home/cafsindia/ntc_cafsinfotech_in_bk/application/controllers/Dispatch_history.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Base_controller.php");
class Dispatch_history extends Base_controller{
public function __construct(){
parent::__construct('dispatch_history');
if(!$this->Appconfig->isAppvalid()){
redirect('config');
}
$this->collect_base_info();
}
// LOAD PAGE WITH TABLE DATA
public function index(){
$data['table_headers']= $this->xss_clean(get_dispatch_headers());
$data['load_customer_info']= $this->get_load_customer_name();
$this->load->view("$this->control_name/manage",$data);
}
//LOAD MODEL PAGE VIEW WITH DATA
public function view($order_dispatch_id){
$this->db->select('warehouse_product.product_name,product_dispatch.repacking,warehouse_information.warehouse_name, product_dispatch.temperature, product_dispatch.tonnes,zct_19.cw_zct_19_id, zct_19.cw_zct_19_value as product_type,warehouse_locations.floor_number,warehouse_locations.bin_or_floor_location, product_dispatch.location_space, product_dispatch.batch_no, product_dispatch.stock_expiry_date, product_dispatch.price, product_dispatch.quantity');
$this->db->from('product_dispatch');
$this->db->join('warehouse_product', 'warehouse_product.prime_warehouse_product_id = product_dispatch.product_id','inner');
$this->db->join('warehouse_information', 'warehouse_information.prime_warehouse_information_id = product_dispatch.warehouse_name','inner');
$this->db->join('warehouse_locations', 'warehouse_locations.prime_warehouse_locations_id = product_dispatch.location','inner');
$this->db->join('zct_19', 'zct_19.cw_zct_19_id = product_dispatch.product_type','inner');
$this->db->where('product_dispatch.order_dispatch_id',$order_dispatch_id);
$this->db->where('product_dispatch.trans_status',1);
$order_receiving_list = $this->db->get();
$data['product_data'] = $order_receiving_list->result();
$this->load->view("$this->control_name/view_product",$data);
}
//LOAD PAGE TABLE VIEW WITH DATA BASED ON SEARCH FILTERS
public function search(){
$search = $this->input->get('search');
$limit = $this->input->get('limit');
$offset = $this->input->get('offset');
$sort = $this->input->get('sort');
$order = $this->input->get('order');
$start_date = str_replace("/","-",$this->input->get('start_date'));
$end_date = str_replace("/","-",$this->input->get('end_date'));
$from_date = date('Y-m-d',strtotime($start_date));
$to_date = date('Y-m-d',strtotime($end_date));
$customer_name = $this->input->get('customer_name');
//$this->db->select('');
$this->db->from('order_dispatch');
$this->db->join('customer', 'customer.prime_customer_id = order_dispatch.customer_id','inner');
$this->db->where('order_dispatch.trans_status', 1);
if($search){
$this->db->group_start();
$this->db->like('order_dispatch_id',$search);
$this->db->or_like('customer_name',$search);
if(strpos($search, '-') !== false){
$this->db->or_like('dispatch_date', date('Y-m-d',strtotime($search)));
}
$this->db->group_end();
}
$this->db->group_start();
$filters_sts = array();
foreach($customer_name as $key=>$value){
if($value){ $filters_sts[] = $value; }
}
if(count($filters_sts) > 0){
$this->db->where_in('customer.prime_customer_id', $filters_sts);
}
$this->db->where('DATE_FORMAT(dispatch_date, "%Y-%m-%d") BETWEEN '. $this->db->escape($from_date).' AND '.$this->db->escape($to_date));
$this->db->group_end();
$this->db->order_by($sort,$order);
$receiving_data = $this->db->get();
$receiving_rslt = $receiving_data->result();
$num_rows = $receiving_data->num_rows();
$datarows=array();
foreach($receiving_rslt as $receiving){
$datarows[]=get_dispatch_datarows($receiving,$this);
}
echo json_encode(array('total'=>$num_rows,'rows'=>$datarows));
}
//GET CUSTUMER NAME FOR FILTERS
public function get_load_customer_name(){
$this->db->select('prime_customer_id,customer_name');
$this->db->from('customer');
$this->db->where('trans_status',1);
$customer_info = $this->db->get()->result();
foreach($customer_info as $row){
$load_customer_type[$row->prime_customer_id] = $row->customer_name;
}
return $load_customer_type;
}
}
?>