<?php	if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Refill_due_report extends CI_Controller {
	function __construct()	{
		parent::__construct();
		//$this->lang->load('masters', '');
		 $language = $this->session->userdata('language'); 
        if ($language=='hindi') {
               $this->lang->load('hindi', '');
        }else{
              $this->lang->load('masters', '');
            }
	}

	function index()	{	
		$this->refill_due_date_reports();
	}
	function refill_due_date_reports(){

 		$this->_page_data['lable_refill_due_country']=$this->lang->line('lable_refill_due_country', FALSE);
 		$this->_page_data['lable_refill_due_state']=$this->lang->line('lable_refill_due_state', FALSE);
 		$this->_page_data['lable_refill_due_city']=$this->lang->line('lable_refill_due_city', FALSE);
 		$this->_page_data['lable_refill_due_customer_name']=$this->lang->line('lable_refill_due_customer_name', FALSE);
 		$this->_page_data['lable_refill_due_dispenser_name']=$this->lang->line('lable_refill_due_dispenser_name', FALSE);
 		$this->_page_data['lable_refill_due_report']=$this->lang->line('lable_refill_due_report', FALSE);

		$this->_page_data['page_title']="Refill Due Data Report";
		$this->_page_data['bredcrum']=array(
			                            'Reports'=>'#',
			                            'Refill Due Data Report'=>'#',
										//'Manage Customer Master'=>'#',
									
										);
										
		$country_cond = array();
		$country_cond[] = array('where','is_active','1');
		$select_array = array(
								'table_name'=>TABLE_COUNTRY,
								'table_fields'=>'country_name,country_id',
								'condition'=>$country_cond,
								'sort_by'=>'country_id',
								'order_by_field'=>'country_name',
								'order'=>'ASC',
								'limit'=>'',
								'offset'=>''
								);
		$customer_data=$this->master_model->select_data($select_array);
		$customer_cnt_data=count($customer_data);
		$this->_page_data['country_array'] = '';
		if($customer_cnt_data > 0)
		{
			foreach($customer_data as $cKey => $cValue)
			{
				$this->_page_data['country_array'][''] = 'Select Country Name';
				$this->_page_data['country_array'][$cValue['country_id']] = $cValue['country_name'];
			}
		}
		//shreyas changed customer to ajax on 16/8/2019
		// $customer_cond = array();
		// $customer_cond[] = array('where','is_active','1');
		// $select_array = array(
		// 						'table_name'=>TABLE_CUSTOMER,
		// 						'table_fields'=>'customer_name,customer_id',
		// 						'condition'=>$customer_cond,
		// 						'sort_by'=>'customer_id',
		// 						'order_by_field'=>'customer_name',
		// 						'order'=>'ASC',
		// 						'limit'=>'',
		// 						'offset'=>''
		// 						);
		// $customer_data=$this->master_model->select_data($select_array);
		// $customer_cnt_data=count($customer_data);
		// $this->_page_data['customer_array'] = '';
		// if($customer_cnt_data > 0)
		// {
		// 	foreach($customer_data as $cKey => $cValue)
		// 	{
		// 		$this->_page_data['customer_array'][''] = 'Select Customer Name';
		// 		$this->_page_data['customer_array'][$cValue['customer_id']] = $cValue['customer_name'];
		// 	}
		// }
		
		$refill_cond = array();
		$refill_cond[] = array('where','is_active','1');
		$refill_cond[] = array('where','product_type','dispenser');
		$select_array = array(
								'table_name'=>TABLE_PRODUCT,
								'table_fields'=>'product_name,product_id',
								'condition'=>$refill_cond,
								'sort_by'=>'product_id',
								'order_by_field'=>'product_name',
								'order'=>'ASC',
								'limit'=>'',
								'offset'=>''
								);
		$refill_data=$this->master_model->select_data($select_array);
		$refill_cnt_data=count($refill_data);
		$this->_page_data['refill_array'] = '';
		if($refill_cnt_data > 0)
		{
			foreach($refill_data as $cKey => $cValue)
			{
				$this->_page_data['refill_array'][''] = 'Select Dispenser Name';
				$this->_page_data['refill_array'][$cValue['product_id']] = $cValue['product_name'];
			}
		}
		
		$this->_page_data['form_action'] = 'gc/refill_due_report/search_refill_due';
		$this->load->view('gc/refill_due_date_report.php',$this->_page_data);
	}
	function refill_due_date_reports_list($query_id = 0, $sort_by = 'dispenser_sales_id', $sort_order = 'asc', $offset = 0,$sort_type=''){
		admin_auth();
		//error_reporting(E_ALL);
        $limit = LIMIT_PER_PAGE;
		$this->_page_data['page_title']="Refill Due Data Report";
		$this->_page_data['bredcrum']=array(
			 							'Reports'=>'#',
			                            'Refill Due Data Report'=>'#',
										//'Manage Customer Master'=>'#',
									
										);
		
		$access_branch= $this->session->userdata('access_branch');

		$this->load->library('NF_Query_search');
		$this->nf_query_search->load_query($query_id);

		$query_array = array(
 				'country_id'=>$this->input->get('country_id'),
 				'state_id'=>$this->input->get('state_id'),
 				'city_id'=>$this->input->get('city_id'),
 				'customer_id'=>$this->input->get('customer_id'),
 				'dispenser_id'=>$this->input->get('dispenser_id'),
 				'refill_due'=>$this->input->get('refill_due'),

		);
		$country_id=check_injections_filter($query_array['country_id']);
		$state_id=check_injections_filter($query_array['state_id']);
		$city_id=check_injections_filter($query_array['city_id']);		
		$customer_id=check_injections_filter($query_array['customer_id']);
		$dispenser_id=check_injections_filter($query_array['dispenser_id']);
		$refill_due=check_injections_filter($query_array['refill_due']);
		
		// $country_id = check_injections_filter($this->input->post('country_id'));
		// $state_id = check_injections_filter($this->input->post('state_id'));
		// $city_id = check_injections_filter($this->input->post('city_id'));
		// $customer_id = check_injections_filter($this->input->post('customer_id'));
		// $dispenser_id = check_injections_filter($this->input->post('dispenser_id'));
		// $refill_due = check_injections_filter($this->input->post('refill_due'));

		$this->_page_data['excel_country_id']=$country_id;
		$this->_page_data['excel_state_id']=$state_id;
		$this->_page_data['excel_city_id']=$city_id;
		$this->_page_data['excel_customer_id']=$customer_id;
		$this->_page_data['excel_dispenser_id']=$dispenser_id;
		$this->_page_data['excel_refill_due']=$refill_due;

     	$export=$this->input->post('excel_export');
		 if ($export=='1') {
			$country_id = check_injections_filter($this->input->post('excel_country_id'));
			$state_id = check_injections_filter($this->input->post('excel_state_id'));
			$city_id = check_injections_filter($this->input->post('excel_city_id'));
			$customer_id = check_injections_filter($this->input->post('excel_customer_id'));
			$dispenser_id = check_injections_filter($this->input->post('excel_dispenser_id'));
			$refill_due = check_injections_filter($this->input->post('excel_refill_due'));
	     }
										
		//print_r($this->input->post());
        //$condition[] = array('join',TABLE_USERS.' as u','u.user_id = b.sales_person_id','inner');
		 if ($access_branch!='') 
		{
			 $acb =  explode( ',',$access_branch);
			 $condition[] = array('where_in','b.company_branch_id',$acb);
		}
        if ($customer_id>"0") {
        		
			$customer_name=get_data_value(TABLE_CUSTOMER,'customer_name','customer_id',$customer_id,'where');
			$this->_page_data['dis_customer_name']=$customer_name;
			$condition[] = array('where','b.customer_id',$customer_id);
		}
		else{
			$this->_page_data['dis_customer_name']='';
		}

		if ($country_id>"0") {
        	
			$country_name=get_data_value(TABLE_COUNTRY,'country_name','country_id',$country_id,'where');
			$this->_page_data['dis_country_name']=$country_name;
			$condition[] = array('where','d.country_id',$country_id);
		}else{
			$this->_page_data['dis_country_name']='';
		}
		if ($state_id>"0") {
        		
			$state_name=get_data_value(TABLE_STATE,'state_name','state_id',$state_id,'where');
			$this->_page_data['dis_state_name']=$state_name;
			$condition[] = array('where','d.state_id',$state_id);
		}else{
			$this->_page_data['dis_state_name']='';
		}
		
		if ($city_id>"0") {
        	
			$city_name=get_data_value(TABLE_CITY,'city_name','city_id',$city_id,'where');
			$this->_page_data['dis_city_name']=$city_name;
			$condition[] = array('where','d.city_id',$city_id);
		}else{
			$this->_page_data['dis_city_name']='';
		}
        
         if ($refill_due=="10") {
        	$this->_page_data['refill_due_for']="Today's Refill Due";
       		$qry_part = 'a.next_refill_date = ( CURDATE( ) ) ';
       	}elseif($refill_due=="1"){
       		$this->_page_data['refill_due_for']="All Previous Refill Due";
       		$qry_part = 'a.next_refill_date < ( CURDATE( ) ) ';
       	}
		elseif($refill_due=="7"){
       		$this->_page_data['refill_due_for']="Next 7 days refill due";
       		$qry_part = 'a.next_refill_date BETWEEN NOW( ) AND DATE_ADD( NOW( ) , INTERVAL 7 DAY )';
       	
		}elseif($refill_due=="15"){
       		$this->_page_data['refill_due_for']="Next 15 days refill due";
       		$qry_part = 'a.next_refill_date BETWEEN NOW( ) AND DATE_ADD( NOW( ) , INTERVAL 15 DAY ) ';
       	
		}elseif($refill_due=="30"){
       		$this->_page_data['refill_due_for']="Next 30 days refill due";
       		$qry_part = 'a.next_refill_date BETWEEN NOW( ) AND DATE_ADD( NOW( ) , INTERVAL 30 DAY ) ';
       	}else{
       		$this->_page_data['refill_due_for']="";
       	}
		
		if($qry_part!="")
		{
			$condition[] = array('where',$qry_part);
		}
				
		if($dispenser_id!="")
		{
			$product_name=get_data_value(TABLE_PRODUCT,'product_name','product_id',$dispenser_id,'where');
			$this->_page_data['dis_product_name']=$product_name;
			$condition[] = array('where','b.product_id',$dispenser_id);
		}else{
			$this->_page_data['dis_product_name']='';
		}


		
		$condition[] = array('join',TABLE_DISPENSER_REFILL_DETAILS.' as a','b.dispenser_sales_id = a.dispenser_sales_id','inner');
		//$condition[] = array('join',TABLE_DISPENSER_SALES.' as f','f.dispenser_sales_id = b.dispenser_sales_id','inner');
		$condition[] = array('join',TABLE_PRODUCT.' as p','a.product_id = p.product_id','inner');
		$condition[] = array('join',TABLE_PRODUCT.' as p1','b.product_id = p1.product_id','inner');
        $condition[] = array('join',TABLE_CUSTOMER.' as c','c.customer_id = b.customer_id','inner');
        $condition[] = array('join',TABLE_CUSTOMER_ADDRESSS.' as d','c.customer_id = d.customer_id','inner');
        $condition[] = array('join',TABLE_CITY.' as e','d.city_id = e.city_id','inner');
        // $selected_array=array(
        //                       'table_name'=>TABLE_DISPENSER_SALES.' as b',
        //                       'table_fields'=>'b.dispenser_sales_id,p1.product_name as dispenser,b.sales_type,a.dispenser_refill_details_id,c.customer_name,p.dispenser_name, p.product_name as refill_name, b.dispenser_quantity, a.refill_location, b.installation_date,a.refill_date, a.next_refill_date, a.duration_days, b.comments, a.product_id, a.dispenser_sales_id, b.dispenser_sales_id,b.product_id, b.customer_id, p.product_id,c.customer_id,e.city_name',
        //                        'condition'=>$condition,
        //                        'limit'=>'',
        //                        'order_by_field'=>'a.next_refill_date',
        //                        'order'=>'DESC',
        //                        'group_by_field'=>'b.dispenser_sales_id',
        //                        'offset'=>''
        //                       );

        //$refill_sale['refill_sale'] = $this->master_model->select_data($selected_array);

         $this->_page_data['fields'] = array(
							'installation_date' => 'Date',
							'customer_name' => 'Customer Name',
							'city_name' => 'City',
							'dispenser' => 'Dispenser',
							'refill_name' => 'Refill',
							'' => 'Last refill date',
						);

        $sort_columns = array('refill_name','installation_date','refill_date','customer_name','city_name');
			$search_array=array(
							'limit' => $limit,
							'offset' => $offset,
							'sort_by' => $sort_by,
							'sort_type' => $sort_type,
							'sort_order' => $sort_order,
							'sort_columns'=> $sort_columns,
							'table_fields'=>'b.dispenser_sales_id,p1.product_name as dispenser,b.product_id as dispenser_id,b.sales_type,a.dispenser_refill_details_id,c.customer_name,p.dispenser_name, p.product_name as refill_name, b.dispenser_quantity, a.refill_location, b.installation_date,a.refill_date, a.next_refill_date, a.duration_days, b.comments, a.product_id, a.dispenser_sales_id, b.dispenser_sales_id,b.product_id, b.customer_id, p.product_id,c.customer_id,e.city_name',
							'group_by_field'=>'b.dispenser_sales_id',
							'table_name'=>TABLE_DISPENSER_SALES.' as b',
							'cond'=> $condition,
							);
			$results = $this->master_model->search($search_array);
			$search_full_array=array(
							'limit' => '',
							'offset' => '',
							'sort_by' => $sort_by,
							'sort_type' => $sort_type,
							'sort_order' => $sort_order,
							'sort_columns'=> $sort_columns,
							'table_fields'=>'b.dispenser_sales_id,p1.product_name as dispenser,b.product_id as dispenser_id,b.sales_type,a.dispenser_refill_details_id,c.customer_name,p.dispenser_name, p.product_name as refill_name, b.dispenser_quantity, a.refill_location, b.installation_date,a.refill_date, a.next_refill_date, a.duration_days, b.comments, a.product_id, a.dispenser_sales_id, b.dispenser_sales_id,b.product_id, b.customer_id, p.product_id,c.customer_id,e.city_name',
							'group_by_field'=>'b.dispenser_sales_id',
							'table_name'=>TABLE_DISPENSER_SALES.' as b',
							'condition'=> $condition,
							);
			$search_data=$this->master_model->select_data($search_full_array);			
		    $cnt_all_rows=count($search_data);
			// /dump($this->db->last_query());
        if ($customer_id) {
        		
			foreach($results  as $k=>$v){

               $this->_page_data['customer'] = $v['customer_name'];
               $this->_page_data['customer_name'] = " For ". $this->_page_data['customer'];
            }
		}
		if(!empty($results)&& is_array($results))
		{
			$this->_page_data['refill_sale'] = $results['rows'];
			$this->_page_data['num_results'] = $cnt_all_rows;
		}
		else
		{
			$results='';
		}
		$this->_page_data['offset'] = $offset;
			/// pagination
			$this->load->library('pagination');
			$config = array();
			$config['base_url'] = site_url("gc/refill_due_report/refill_due_date_reports_list/$query_id/$sort_by/$sort_order");
			$config['total_rows'] = $this->_page_data['num_results'];
			$config['per_page'] = $limit;
			$config['uri_segment'] = 7;
			$config['full_tag_open'] = '<span class=\'paging\'>';
			$config['full_tag_close'] = '</span>';
			$config['first_link'] = 'First';
			$config['prev_link'] = '<<';
			$config['next_link'] = '>>';
			$config['last_link'] = 'Last';
			$this->pagination->initialize($config);
			
			$this->_page_data['pagination'] = $this->pagination->create_links();
			$this->_page_data['sort_by'] = $sort_by;
			$this->_page_data['sort_order'] = $sort_order;
			//$data['purpose'] = $purpose;
			$this->_page_data['query_id'] = $query_id;
		
  	    // if ($export=='1') {
  	    // 	$this->load->view('gc/refill_due_date_report_list_excel.php',$this->_page_data);
  	    // }else{
  	    	
			$this->load->view('gc/refill_due_date_report_list.php',$this->_page_data);
  	    //}
		//$this->load->view('gc/refill_due_date_report_list.php',$this->_page_data);
	}
	function search_refill_due()
	{

		$query_array = array(
						'country_id' =>check_injections_filter($this->input->post('country_id')),
						'state_id' => check_injections_filter($this->input->post('state_id')),
						'city_id' => check_injections_filter($this->input->post('city_id')),
						
						'customer_id' =>check_injections_filter($this->input->post('customer_id')),
						'dispenser_id' => check_injections_filter($this->input->post('dispenser_id')),
						'refill_due' => check_injections_filter($this->input->post('refill_due')),
					);
		$this->load->library('NF_Query_search');
		$query_id = $this->nf_query_search->save_query($query_array);			
		
		redirect('gc/refill_due_report/refill_due_date_reports_list/'.$query_id);		
	}
	function excel_refill_due(){

	    $export=$this->input->post('excel_export');		 
	    $country_id = check_injections_filter($this->input->post('excel_country_id'));
		$state_id = check_injections_filter($this->input->post('excel_state_id'));
		$city_id = check_injections_filter($this->input->post('excel_city_id'));
		$customer_id = check_injections_filter($this->input->post('excel_customer_id'));
		$dispenser_id = check_injections_filter($this->input->post('excel_dispenser_id'));
		$refill_due = check_injections_filter($this->input->post('excel_refill_due'));

		

		if ($customer_id>"0") {
        		
			$customer_name=get_data_value(TABLE_CUSTOMER,'customer_name','customer_id',$customer_id,'where');
			$this->_page_data['dis_customer_name']=$customer_name;
			$condition[] = array('where','b.customer_id',$customer_id);
		}

		if ($country_id>"0") {
        	
			$country_name=get_data_value(TABLE_COUNTRY,'country_name','country_id',$country_id,'where');
			$this->_page_data['dis_country_name']=$country_name;
			$condition[] = array('where','d.country_id',$country_id);
		}
		if ($state_id>"0") {
        		
			$state_name=get_data_value(TABLE_STATE,'state_name','state_id',$state_id,'where');
			$this->_page_data['dis_state_name']=$state_name;
			$condition[] = array('where','d.state_id',$state_id);
		}
		
		if ($city_id>"0") {
        	
			$city_name=get_data_value(TABLE_CITY,'city_name','city_id',$city_id,'where');
			$this->_page_data['dis_city_name']=$city_name;
			$condition[] = array('where','d.city_id',$city_id);
		}
        
         if ($refill_due=="10") {
        	$this->_page_data['refill_due_for']="Today's Refill Due";
       		$qry_part = 'a.next_refill_date = ( CURDATE( ) ) ';
       	}elseif($refill_due=="1"){
       		$this->_page_data['refill_due_for']="All Previous Refill Due";
       		$qry_part = 'a.next_refill_date < ( CURDATE( ) ) ';
       	}
		elseif($refill_due=="7"){
       		$this->_page_data['refill_due_for']="Next 7 days refill due";
       		$qry_part = 'a.next_refill_date BETWEEN NOW( ) AND DATE_ADD( NOW( ) , INTERVAL 7 DAY )';
       	
		}elseif($refill_due=="15"){
       		$this->_page_data['refill_due_for']="Next 15 days refill due";
       		$qry_part = 'a.next_refill_date BETWEEN NOW( ) AND DATE_ADD( NOW( ) , INTERVAL 15 DAY ) ';
       	
		}elseif($refill_due=="30"){
       		$this->_page_data['refill_due_for']="Next 30 days refill due";
       		$qry_part = 'a.next_refill_date BETWEEN NOW( ) AND DATE_ADD( NOW( ) , INTERVAL 30 DAY ) ';
       	}
		
		if($qry_part!="")
		{
			$condition[] = array('where',$qry_part);
		}
				
		if($dispenser_id!="")
		{
			$product_name=get_data_value(TABLE_PRODUCT,'product_name','product_id',$dispenser_id,'where');
			$this->_page_data['dis_product_name']=$product_name;
			$condition[] = array('where','b.product_id',$dispenser_id);
		}
		$condition[] = array('join',TABLE_DISPENSER_REFILL_DETAILS.' as a','b.dispenser_sales_id = a.dispenser_sales_id','inner');
		$condition[] = array('join',TABLE_PRODUCT.' as p','a.product_id = p.product_id','inner');
		$condition[] = array('join',TABLE_PRODUCT.' as p1','b.product_id = p1.product_id','inner');
        $condition[] = array('join',TABLE_CUSTOMER.' as c','c.customer_id = b.customer_id','inner');
        $condition[] = array('join',TABLE_CUSTOMER_ADDRESSS.' as d','c.customer_id = d.customer_id','inner');
        $condition[] = array('join',TABLE_CITY.' as e','d.city_id = e.city_id','inner');

        $selected_array=array(
                              'table_name'=>TABLE_DISPENSER_SALES.' as b',
                              'table_fields'=>'b.dispenser_sales_id,p1.product_name as dispenser,b.sales_type,a.dispenser_refill_details_id,c.customer_name,p.dispenser_name, p.product_name as refill_name, b.dispenser_quantity, a.refill_location, b.installation_date,a.refill_date, a.next_refill_date, a.duration_days, b.comments, a.product_id, a.dispenser_sales_id, b.dispenser_sales_id,b.product_id, b.customer_id, p.product_id,c.customer_id,e.city_name',
                               'condition'=>$condition,
                               'limit'=>'',
                               'order_by_field'=>'a.next_refill_date',
                               'order'=>'DESC',
                               'group_by_field'=>'b.dispenser_sales_id',
                               'offset'=>''
                              );
        $refill_sale['refill_sale'] = $this->master_model->select_data($selected_array);
        if ($customer_id) {
        		
			foreach($refill_sale['refill_sale']  as $k=>$v){

               $this->_page_data['customer'] = $v['customer_name'];
               $this->_page_data['customer_name'] = " For ". $this->_page_data['customer'];
            }
		}
		 if(!empty($refill_sale['refill_sale'] )&& is_array($refill_sale['refill_sale'] )){


				  $this->_page_data['refill_sale'] = $refill_sale['refill_sale'];
		 	
  	    } 
		$this->load->view('gc/refill_due_date_report_list_excel.php',$this->_page_data);	


		
	}
	function change_refill(){

		$this->_page_data['page_title']="Refill Due Data Report";
		$this->_page_data['bredcrum']=array(
			 							'Reports'=>'#',
			                            'Refill Due Data Report'=>'#',
										//'Manage Customer Master'=>'#',
									
										);
		$this->load->view('gc/change_refill.php',$this->_page_data);
	}
	
	function get_state()
	{
		$country_id=$this->input->post('country_id');
       
	    $salse_person_cond = array();
		$salse_person_cond[] = array('where','country_id',$country_id);
		$salse_person_cond[] = array('where','is_active','1');
		$select_array = array(
								'table_name'=>TABLE_STATE,
								'table_fields'=>'state_id,state_name',
								'condition'=>$salse_person_cond,
								'sort_by'=>'state_name',
								'order_by_field'=>'state_name',
								'order'=>'ASC',
								'limit'=>'',
								'offset'=>''
								);
		$salse_person_data = $this->master_model->select_data($select_array);
		$output='<option value="">Select State</option>';
		
		foreach($salse_person_data as $row)
		{
		  $output .= '<option value='.$row['state_id'].'>'.$row['state_name'].'</option>';

		}
          echo $output;	
    }
	
	function get_city()
	{
		$state_id=$this->input->post('state_id');
       
	    $salse_person_cond = array();
		$salse_person_cond[] = array('where','state_id',$state_id);
		$salse_person_cond[] = array('where','is_active','1');
		$select_array = array(
								'table_name'=>TABLE_CITY,
								'table_fields'=>'city_id,city_name',
								'condition'=>$salse_person_cond,
								'sort_by'=>'city_name',
								'order_by_field'=>'city_name',
								'order'=>'ASC',
								'limit'=>'',
								'offset'=>''
								);
		$salse_person_data = $this->master_model->select_data($select_array);
		$output='<option value="">Select City</option>';
		
		foreach($salse_person_data as $row)
		{
		  $output .= '<option value='.$row['city_id'].'>'.$row['city_name'].'</option>';

		}
          echo $output;	
    }
    function customer(){
    	$customer_cond = array();
    	$access_branch= $this->session->userdata('access_branch');
    	if ($access_branch) {
    	 $acb =  explode( ',',$access_branch);
		 $customer_cond[] = array('where_in','company_branch_id',$acb);# code...
    	}
		
		$customer_cond[] = array('where','is_active','1');
		$select_array = array(
								'table_name'=>TABLE_CUSTOMER,
								'table_fields'=>'customer_name,customer_id',
								'condition'=>$customer_cond,
								'sort_by'=>'customer_id',
								'order_by_field'=>'customer_name',
								'group_by_field'=>'customer_name',
								'order'=>'ASC',
								'limit'=>'',
								'offset'=>''
								);
		$customer_data=$this->master_model->select_data($select_array);
		//dump($this->db->last_query());
		$customer_cnt_data=count($customer_data);
		if($customer_cnt_data > 0)
		{
			$output='';
		 		foreach($customer_data as $row)
                     {
                  		 // $output .= '<option value="'.$row->state_id.'">'.$row->state_name.'</option>';
                  		  $output .= '<option value='.$row['customer_id'].'>'.$row['customer_name'].'</option>';

                     }

          echo $output;
		}
    }
}