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

class Sales_Pos extends CI_Controller {

    var $main_menu_name = "sales";
	var $sub_menu_name = "sales";

	public function __construct()
	{
		parent::__construct();

		$this->load->model('Sales_Model');
		$this->load->model('Supplier_Model');
		$this->load->model('Warehouse_Model');
		$this->load->model('Common_Model');
		$this->load->model('Tax_Rates_Model');
		$this->load->model('Customer_Model');
		$this->load->model('Sales_Return_Model');
		$this->load->model('Cus_Pricing_Model');
		$this->load->model('Country_Model');
		$this->load->model('Transfer_Model');
		$this->load->model('Purchases_Model');
		$this->load->model('User_Model');
		$this->load->model('Product_Damage_Model');//
		$this->load->model('Product_Models');//
		$this->load->model('category_models');
		$this->load->model('Sales_Pos_Model');
		
	}
	
	//Sales list page load
	public function get_return_details()
	{
	    
	   // error_reporting(E_ALL);
		/* 
		$data['sales'] = $this->Sales_Model->get_all_sales();
		$data['main_menu_name'] = $this->main_menu_name;
		$data['sub_menu_name'] = $this->sub_menu_name;
		
		$data['warehouse_list'] = $this->Warehouse_Model->get_all_warehouse();
		*/
		
		
	
		$sale_id=1;
		$disMsg='';
		$error=0;
		$sale_id=$this->input->get('sale_id');
		$data['sale_id']=$sale_id;
		
		
		$data['sale_item_list']= $this->Sales_Model->get_sale_item_list_by_sale_id($sale_id);
		$data['sale_details']= $this->Sales_Model->get_sale_info($sale_id);
		$data['sale_id']=$sale_id;
		
		
		//get suppliers list
		$data['suppliers'] = $this->Supplier_Model->get_all_supplier();
		$data['warehouse_list'] = $this->Warehouse_Model->get_all_warehouse();
		$data['tax_rates_list'] = $this->Tax_Rates_Model->get_all_tax_rates();
		$data['customer_list'] = array();//$this->Customer_Model->get_all_customers();
		$data['status_list'] = $this->Common_Model->get_all_status();
			$data['bank_list'] = $this->Sales_Model->get_all_bank();
			
			$data['rep_list'] = $this->User_Model->getSalesRep();
			
			
		
		$details=strip_tags($this->load->view('sales_return_add_pos',$data));
		
		
		//echo json_encode(array('sale_id'=>$sale_id,'error'=>"$error",'disMsg'=>$disMsg,'details'=>$details));
		 
        //
	}
	
	
	public function js_data_sales_list_ajax(){
        $str = $this->input->post('search_string');
		$srh_warehouse_id = $this->input->get('srh_warehouse_id');
		$service_item_avalable = $this->input->post('service_item_avalable');
		$cat_srh = $this->input->post('cat_srh');
		$subcategory = $this->input->post('subcategory');
		
	//	echo "srh_warehouse_id:".$srh_warehouse_id;
		
		//echo "test";
       // $result = $this->Service_Model->get_product_sn($str);
	 //  $str='';
	 //  $srh_warehouse_id='';
		 $result=$this->Sales_Pos_Model->js_data_sales_list_ajax($str,$srh_warehouse_id);
        echo json_encode($result);
    }
	
	
	
}
