<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Sales_Pos_Model extends CI_Model {
  
  private $tableName = 'sales';
  
  function __construct() 
  {
    /* Call the Model constructor */
    parent::__construct();
  }
  
function js_data_sales_list_ajax($term,$srh_warehouse_id)

 {
	 
	// echo "srh_warehouse_id:$srh_warehouse_id";

	    $this->db->select('s.*');
		$this->db->from('sales s');
		
		$this->db->order_by("s.sale_id", "desc");
		//$this->db->group_by('p.product_id');
		$cat_query='';
		
		//$sql="(p.product_name LIKE '%$term%' OR p.product_code LIKE '%$term%' OR p.product_oem_part_number LIKE '%$term%' OR p.product_part_no LIKE '%$term%') $cat_query";
		
		
		
	
		
		//$sql="(i.pis_number LIKE '%$term%' OR p.product_name LIKE '%$term%' OR p.product_code LIKE '%$term%' OR p.product_oem_part_number LIKE '%$term%' OR p.product_part_no LIKE '%$term%') AND p.product_sn_exissts='1' $cat_query";
		
		//echo $sql;
		$cat_query='';
		if($srh_warehouse_id){
			$cat_query="AND warehouse_id='$srh_warehouse_id'";
		}
		
		
		$sql="(s.sale_reference_no LIKE '%$term%') $cat_query";

		$this->db->where($sql);

		$this->db->limit(50, 0);
		$query = $this->db->get();
		//echo $this->db->last_query();
		return $query->result_array();

	}	
}