File: /home/cafsindia/ntc_cafsinfotech_in_bk/application/controllers/Receiving_history.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Base_controller.php");
class Receiving_history extends Base_controller{
public function __construct(){
parent::__construct('receiving_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_receiving_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_receiving_id){
$this->db->select('warehouse_product.product_name,product_receiving.repacking,warehouse_information.warehouse_name, product_receiving.temperature, product_receiving.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_receiving.location_space, product_receiving.batch_no, product_receiving.stock_expiry_date, product_receiving.price, product_receiving.quantity');
$this->db->from('product_receiving');
$this->db->join('warehouse_product', 'warehouse_product.prime_warehouse_product_id = product_receiving.product_id','inner');
$this->db->join('warehouse_information', 'warehouse_information.prime_warehouse_information_id = product_receiving.warehouse_name','inner');
$this->db->join('warehouse_locations', 'warehouse_locations.prime_warehouse_locations_id = product_receiving.location','inner');
$this->db->join('zct_19', 'zct_19.cw_zct_19_id = product_receiving.product_type','inner');
$this->db->where('product_receiving.order_receiving_id',$order_receiving_id);
$this->db->where('product_receiving.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->from('order_receiving');
$this->db->join('customer', 'customer.prime_customer_id = order_receiving.customer_id','inner');
$this->db->where('order_receiving.trans_status', 1);
if($search){
$this->db->group_start();
$this->db->like('order_receiving_id',$search);
$this->db->or_like('customer_name',$search);
if(strpos($search, '-') !== false){
$this->db->or_like('entry_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(entry_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_receiving_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;
}
}
?>