<?php	if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Company_branch extends CI_Controller {

	function __construct()	{
		parent::__construct();
		$this->load->model('master_model');
    //$this->lang->load('masters', '');
    $language = $this->session->userdata('language'); 
        if ($language=='hindi') {
               $this->lang->load('hindi', '');
        }else{
              $this->lang->load('masters', '');
            }
            //error_reporting(E_ALL);
	}

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

	function list_company_branch($query_id = 0, $sort_by = 'company_branch_id', $sort_order = 'asc', $offset = 0,$sort_type=0) {
		admin_auth();
    //error_reporting(E_ALL);
    $limit = LIMIT_PER_PAGE;
    $submit=check_injections_filter($this->input->post('search')); 
		$this->page_data['page_title']="List of Company Branch";
		$this->page_data['bredcrum']=array(
			 							'Masters'=>'#',
										'Company Branch'=>'#',
										'List Company Branch'=>'#',
										);
		 $condition = array();

                       //Shreyas changed join to left to show all the records
                            //$condition[] = array('where',TABLE_COMPANY.'.company_id',$company_id);
                            $condition[] = array('join',TABLE_COUNTRY,TABLE_COUNTRY.'.country_id ='.TABLE_COMPANY_BRANCH.'.country_id','left');
                            $condition[] = array('join',TABLE_STATE,TABLE_STATE.'.state_id ='.TABLE_COMPANY_BRANCH.'.state_id','left');
                             $condition[] = array('join',TABLE_CITY,TABLE_CITY.'.city_id ='.TABLE_COMPANY_BRANCH.'.city_id','left');

                             $this->page_data['contact_person_name']='';
                             $this->page_data['branch_company_name']='';
                             $this->page_data['branch_mobile_no']='';

    // if(isset($submit) && !empty($submit))

    // {
                            $this->load->library('NF_Query_search');
                            $this->nf_query_search->load_query($query_id);
                            $query_array = array(
                                        'branch_company_name'=>$this->input->get('branch_company_name'),
                                        'branch_mobile_no'=>$this->input->get('branch_mobile_no'),
                                        'contact_person_name'=>$this->input->get('contact_person_name'),

                            );
                      $branch_company_name=check_injections_filter($query_array['branch_company_name']);
                      $branch_mobile_no=check_injections_filter($query_array['branch_mobile_no']);
                      $contact_person_name=check_injections_filter($query_array['contact_person_name']);

         // $branch_company_name=check_injections_filter($this->input->post('branch_company_name'));
         // $branch_mobile_no=check_injections_filter($this->input->post('branch_mobile_no'));
         // $contact_person_name=check_injections_filter($this->input->post('contact_person_name'));
       
         if ($branch_company_name!='') {
            $condition[]=array('like',TABLE_COMPANY_BRANCH.'.company_branch_name',$branch_company_name);
          $this->page_data['branch_company_name']=$branch_company_name;
         }else{
          $this->page_data['branch_company_name']='';
         }

        if ($branch_mobile_no!='') {
          $condition[]=array('like',TABLE_COMPANY_BRANCH.' .branch_mobile_no',$branch_mobile_no);
          $this->page_data['branch_mobile_no']=$branch_mobile_no;
        }else{
          $this->page_data['branch_mobile_no']='';
        }
        if ($contact_person_name!='') {
          $condition[]=array('like',TABLE_COMPANY_BRANCH.'.contact_person_name',$contact_person_name);
          $this->page_data['contact_person_name']=$contact_person_name;
        }else{
          $this->page_data['contact_person_name']='';
        }
        
           $this->page_data['fields'] = array(
              'company_branch_name' => 'Branch Company Name',
              'branch_mobile_no' => 'Branch Mobile Number',
              'contact_person_name' => 'Contact Person Name',
            );


    //}

                          $sort_columns = array('company_branch_name','branch_mobile_no','contact_person_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'=>TABLE_COMPANY_BRANCH.'.is_active,company_branch_id,company_branch_name,branch_mobile_no,'.TABLE_COMPANY_BRANCH.'.std_code,contact_person_name',
                                  'table_name'=>TABLE_COMPANY_BRANCH,
                                  'group_by_field'=>'company_branch_name',
                                  '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'=>TABLE_COMPANY_BRANCH.'.is_active,company_branch_id,company_branch_name,branch_mobile_no,'.TABLE_COMPANY_BRANCH.'.std_code,contact_person_name',
                                  'table_name'=>TABLE_COMPANY_BRANCH,
                                  'group_by_field'=>'company_branch_name',
                                  'condition'=> $condition,
                            );
                           $search_data=$this->master_model->select_data($search_full_array);
                           //dump($this->db->last_query()); 
                            $cnt_all_rows=count($search_data);
                           //$cnt_all_rows=count($results);
                          if(!empty($results)&& is_array($results))
                           {
                            $this->page_data['branch'] = $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/company_branch/list_company_branch/$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;
      $this->page_data['sort_type'] = $sort_type;
      //$data['purpose'] = $purpose;
      $this->page_data['query_id'] = $query_id;
                           // $condition[] = array('where','users.is_active');

                            // $select_array=array(
                            //     'table_name'=>TABLE_COMPANY_BRANCH,
                            //     'table_fields'=>TABLE_COMPANY_BRANCH.'.is_active,company_branch_id,company_branch_name,branch_mobile_no,'.TABLE_COMPANY_BRANCH.'.std_code,contact_person_name',
                            //     'condition'=>$condition,
                            //     'limit'=>'',
                            //     'offset'=>''
                            // );
                            // $branch['branch']=$this->master_model->select_data($select_array);
                          // dump($this->db->last_query());
                            // if(!empty($branch['branch'])&& is_array($branch['branch'])){
							
				                        // $this->page_data['branch'] =  $branch['branch'];
		 	

  	                         //  }
      
  	                       $this->load->view('gc/company_branch_list',$this->page_data);

		
	}
  function search_company_branch()
  {
   
    $query_array = array(
            'branch_company_name' =>check_injections_filter($this->input->post('branch_company_name')),
            'branch_mobile_no' => check_injections_filter($this->input->post('branch_mobile_no')),
            'contact_person_name' => check_injections_filter($this->input->post('contact_person_name')),
            
          );
    $this->load->library('NF_Query_search');
    $query_id = $this->nf_query_search->save_query($query_array);     
    
    redirect('gc/company_branch/list_company_branch/'.$query_id);   
  }
	
	function view_company_branch($company_branch_id) {
		admin_auth();
		//$id=$this->encrypt->decode($company_branch_id);
		$id=encrypt_decrypt_parameters($company_branch_id,'decrypt');
		$this->page_data['page_title']="View Company Branch";
		$this->page_data['bredcrum']=array(
										'Masters'=>'#',
										'Company Branch'=>'#',
										'List Company Branch'=>site_url('gc/company_branch/list_company_branch'),
										'View Company Branch'=>'#',
										);


                            $condition = array();
                            $condition[] = array('where','company_branch_id',$id);
                            $condition[] = array('join',TABLE_COUNTRY,TABLE_COUNTRY.'.country_id ='.TABLE_COMPANY_BRANCH.'.country_id','left');
                            $condition[] = array('join',TABLE_STATE,TABLE_STATE.'.state_id ='.TABLE_COMPANY_BRANCH.'.state_id','left');
                             $condition[] = array('join',TABLE_CITY,TABLE_CITY.'.city_id ='.TABLE_COMPANY_BRANCH.'.city_id','left');
                             $condition[] = array('join',TABLE_BRANCH_SALABLE_GEOGRAPHY,TABLE_BRANCH_SALABLE_GEOGRAPHY.'.branch_salable_geography_id ='.TABLE_COMPANY_BRANCH.'.branch_salable_geography','left');
                           // $condition[] = array('where','users.is_active');

                            $select_array=array(
                                'table_name'=>TABLE_COMPANY_BRANCH,
                                'table_fields'=>TABLE_COMPANY_BRANCH.'.is_active,company_branch_id,company_branch_name,branch_mobile_no,contact_person_name,'.TABLE_COMPANY_BRANCH.'.std_code,'.TABLE_CITY.'.city_name,state_name,country_name,company_branch_address1,company_branch_address2,postal_code,branch_salable_geography,branch_email_id,company_branch_gst_no,company_branch_pan_no,'.TABLE_BRANCH_SALABLE_GEOGRAPHY.'.saleble_geography_name,branch_salable_geography_id',
                                'condition'=>$condition,
                                'limit'=>'',
                                'offset'=>''
                            );
                            $branch['branch']=$this->master_model->select_data($select_array);
                           
                            if(!empty($branch['branch'])&& is_array($branch['branch'])){
							
				                   $this->page_data['branch'] =  $branch['branch'];
		 	

  	                          }
      
  	                       $this->load->view('gc/company_branch_view',$this->page_data);
	}
	
	function manage_company_branch($company_branch_id=""){

        admin_auth();
  $this->page_data['comp_Branch_Company_Name']=$this->lang->line('comp_Branch_Company_Name', FALSE);
  $this->page_data['comp_Branch_PAN_Number']=$this->lang->line('comp_Branch_PAN_Number', FALSE);
  $this->page_data['comp_Branch_GST_Number']=$this->lang->line('comp_Branch_GST_Number', FALSE);
  $this->page_data['comp_Branch_Address_line_1']=$this->lang->line('comp_Branch_Address_line_1', FALSE);
  $this->page_data['comp_Branch_Address_line_2']=$this->lang->line('comp_Branch_Address_line_2', FALSE);
  $this->page_data['comp_Branch_Saleble_Geography']=$this->lang->line('comp_Branch_Saleble_Geography', FALSE);
  $this->page_data['comp_Branch_Email_Id']=$this->lang->line('comp_Branch_Email_Id', FALSE);
  $this->page_data['comp_Branch_Mobile_Number']=$this->lang->line('comp_Branch_Mobile_Number', FALSE);
  $this->page_data['comp_Branch_Country']=$this->lang->line('comp_Branch_Country', FALSE);
  $this->page_data['comp_Branch_State']=$this->lang->line('comp_Branch_State', FALSE);
  $this->page_data['comp_Branch_City']=$this->lang->line('comp_Branch_City', FALSE);
  $this->page_data['comp_Branch_Postal_Code']=$this->lang->line('comp_Branch_Postal_Code', FALSE);
  $this->page_data['comp_Branch_Contact_Person_Name']=$this->lang->line('comp_Branch_Contact_Person_Name', FALSE);

       // $id=$this->encrypt->decode($company_branch_id);
		$id=encrypt_decrypt_parameters($company_branch_id,'decrypt');
		//$this->page_data['state']= $this->fetch_state();
		$this->page_data['country']=$this->fetch_country();
		//$this->page_data['city']=$this->fetch_city();
		$this->page_data['geography']=$this->fetch_geography();
		
		if ($id){
        $this->page_data['page_title']="Edit Company Branch";
        $this->page_data['bredcrum']=array(
                    'Masters'=>'#',
                      'Company Branch'=>'#',
                      'List Company Branch'=>site_url(COMPANY_BRANCH.'list_company_branch'),
                    'Edit Company Branch'=>'#',
                    );
          $this->page_data['check']='edit';
    }else{
        $this->page_data['page_title']="Add Company Branch";
        $this->page_data['bredcrum']=array(
                    'Masters'=>'#',
                      'Company Branch'=>'#',
                    'Add Company Branch'=>'#',
                    );
        $this->page_data['check']='';
    }
		
		


		 	if (!$id) {
            
	         $this->load->view('gc/company_branch_manage.php',$this->page_data);

		    }else{
                     
                            $condition[] = array('where','company_branch_id',$id);
                            $condition[] = array('join',TABLE_COUNTRY,TABLE_COUNTRY.'.country_id ='.TABLE_COMPANY_BRANCH.'.country_id','left');
                            $condition[] = array('join',TABLE_STATE,TABLE_STATE.'.state_id ='.TABLE_COMPANY_BRANCH.'.state_id','left');
                            $condition[] = array('join',TABLE_CITY,TABLE_CITY.'.city_id ='.TABLE_COMPANY_BRANCH.'.city_id','left');
                            $condition[] = array('join',TABLE_BRANCH_SALABLE_GEOGRAPHY,	TABLE_BRANCH_SALABLE_GEOGRAPHY.'.branch_salable_geography_id ='.TABLE_COMPANY_BRANCH.'.branch_salable_geography','left');

                            $select_array=array(
                                'table_name'=>TABLE_COMPANY_BRANCH,
                                'table_fields'=>TABLE_COMPANY_BRANCH.'.is_active,company_branch_id,company_branch_name,branch_mobile_no,contact_person_name,'.TABLE_COMPANY_BRANCH.'.std_code,'.TABLE_CITY.'.city_name,state_name,country_name,company_branch_address1,company_branch_address2,postal_code,branch_salable_geography,branch_email_id,company_branch_gst_no,company_branch_pan_no,'.TABLE_STATE.'.state_id,'.TABLE_COUNTRY.'.country_id,'.TABLE_CITY.'.city_id,'.TABLE_BRANCH_SALABLE_GEOGRAPHY.'.saleble_geography_name,branch_salable_geography_id',
                                'condition'=>$condition,
                                'limit'=>'',
                                'offset'=>''
                            );
                            $company_branch['company_branch']=$this->master_model->select_data($select_array);

		
		if(!empty($company_branch['company_branch'] )&& is_array($company_branch['company_branch']))
			{
				 $this->page_data['company_branch'] = $company_branch['company_branch'] ;
				 
  	  			 
  	        }
		 $this->load->view('gc/company_branch_manage.php',$this->page_data);
	
	}
}
    function fetch_country(){
    	admin_auth();
      $condition[] = array('where','is_active','1');
    	$selected_array = array( 
			                   'table_name' =>TABLE_COUNTRY,
			                   'table_fields' => 'country_id,country_name,is_active',
			                   'order_by_field'=>'country_name',
                         'condition'=>$condition,
                         'order'=>'ASC',
                         'limit'=>'',
                         'offset'=>''
		);

		return $this->master_model->select_data($selected_array);		         
    }

     
    function add_company_branch(){
     	admin_auth();
      
        $id = check_injections_filter($this->input->post('hidden'));
    	$company_branch_name = check_injections_filter($this->input->post('company_branch_name'));
        $branch_pan = check_injections_filter($this->input->post('branch_pan'));
        $branch_gst = check_injections_filter($this->input->post('branch_gst'));
        $std_code = check_injections_filter($this->input->post('std_code'));
        $branch_addressl1 = check_injections_filter($this->input->post('branch_addressl1'));
        $branch_addressl2 = check_injections_filter($this->input->post('branch_addressl2'));
        $country_id = $this->input->post('country_id');
        $geography_id = check_injections_filter($this->input->post('geography_id'));
        $state_id = $this->input->post('state_id');
        $city_id = $this->input->post('city_id');
        $postalcode = check_injections_filter($this->input->post('postalcode'));
        $contact_person_name = check_injections_filter($this->input->post('contact_person_name'));
        $branch_mobile = check_injections_filter($this->input->post('branch_mobile'));
        $branch_email = check_injections_filter($this->input->post('branch_email'));
        $user_id = $this->session->userdata('user_id');

       /*  $this->form_validation->set_rules('company_branch_name', 'Company Branch Name', 'required');
        //$this->form_validation->set_rules('branch_pan', 'Pan Number', 'required');  
        //$this->form_validation->set_rules('branch_gst', 'GST Number', 'required');  
        $this->form_validation->set_rules('branch_addressl1', 'Address', 'required');  
        $this->form_validation->set_rules('postalcode', 'Postal Code', 'required');  
        $this->form_validation->set_rules('contact_person_name', 'Contact Person Name', 'required');  
        $this->form_validation->set_rules('branch_mobile', 'Mobile Number', 'required');  
        $this->form_validation->set_rules('branch_email', 'Branch Email', 'required');    
    	  if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('gc/city_manage.php');
        }else{ */

            $condition[] = array('where','company_branch_name',$company_branch_name);
            $condition[] = array('where','company_branch_gst_no',$branch_gst);
            $condition[] = array('where','company_branch_pan_no',$branch_pan);
            if ($id) {
                         
                $condition[] = array('where','branch_mobile_no',$branch_mobile);
                $condition[] = array('where_not_in','company_branch_id',$id);
            }else{
               
                $condition[] = array('or_where','branch_mobile_no',$branch_mobile);
               
      
            }
              $selected_array=array(
                'table_name' =>TABLE_COMPANY_BRANCH,              
                'table_fields'=>'branch_mobile_no,company_branch_gst_no,company_branch_pan_no',
                'order_by_field'=>'Asc',
                'limit'=>'',
                'offset'=>'',
                'condition'=>$condition           
              );
       
              $company_branch['company_branch'] = $this->master_model->select_data($selected_array);
             
              if(!empty($company_branch['company_branch']))
               {                   
                 $this->session->set_flashdata('message','Company Branch already present');
                 redirect('gc/company_branch/manage_company_branch');
               }else{
                 if (!$id) {
                    $company_data=array(
                            'company_branch_name' => $company_branch_name,
                            'company_branch_pan_no' =>$branch_pan,
                            'country_id' =>$country_id,
                            'company_branch_gst_no' => $branch_gst,
                            'company_branch_address1' =>$branch_addressl1,
                            'company_branch_address2' =>$branch_addressl2,
                            'branch_salable_geography' =>$geography_id ,
                            'city_id' =>  $city_id,
                             'postal_code'=>$postalcode,
                            'state_id' =>$state_id,
                            'branch_mobile_no' =>$branch_mobile,
                            'std_code'=>$std_code,
                            'branch_email_id' =>$branch_email,
                            'contact_person_name'=> $contact_person_name,
                            'created_on' => date("Y-m-d H:i:s"),
                            'created_by' =>$user_id,
                            'modified_by' => '',  
                            'modified_on' => date("Y-m-d H:i:s")               
                          );
                  $this->session->set_flashdata('message','Company Branch inserted successfully');
                  $this->master_model->insert_record(TABLE_COMPANY_BRANCH, $company_data);
                  redirect('gc/company_branch/list_company_branch');
                 }else{
                    $this->session->set_flashdata('message','Company Branch updated  successfully');
                      $company_data=array(
                          'company_branch_name' => $company_branch_name,
                          'company_branch_pan_no' =>$branch_pan,
                          'country_id' =>$country_id,
                          'company_branch_gst_no' => $branch_gst,
                          'company_branch_address1' =>$branch_addressl1,
                          'company_branch_address2' =>$branch_addressl2,
                          'branch_salable_geography' =>$geography_id ,
                          'city_id' =>  $city_id,
                          'postal_code'=>$postalcode,
                          'state_id' =>$state_id,
                          'branch_mobile_no' =>$branch_mobile,
                          'std_code'=>$std_code,
                          'branch_email_id' =>$branch_email,
                          'contact_person_name'=> $contact_person_name,
                          'created_on' => date("Y-m-d H:i:s"),
                          'created_by' =>$user_id,
                          'modified_by' =>$user_id, 
                          'modified_on' => date("Y-m-d H:i:s")
                
                         );
                    $condition=array('company_branch_id'=>$id);
                    $this->master_model->update_record(TABLE_COMPANY_BRANCH,$company_data,$condition);
                    redirect('gc/company_branch/list_company_branch');  
              }
            }
        //}
                
	}
  
  function get_state()
  {
    $country_id=$this->input->post('country_id');
    $state_id=$this->input->post('state_id');
    //$access_branch= $this->session->userdata('access_branch');
       
      $salse_person_cond = array();
    $salse_person_cond[] = array('where','country_id',$country_id);
    // if ($access_branch!='') {
  //            $salse_person_cond[]  = array('where_in','b.company_branch_id',$access_branch);
  //       }
    $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)
    {
      $selected='';

             if ($row['state_id']==$state_id) 

       {

        $selected='selected="selected"';

       }

      $output .= '<option value='.$row['state_id'].' '.$selected.'>'.$row['state_name'].'</option>';

    }
          echo $output; 
  }
  function get_std_code()
  {
      $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_COUNTRY,
                'table_fields'=>'std_code',
                'condition'=>$salse_person_cond,
                'limit'=>'',
                'offset'=>''
                );
    $salse_person_data = $this->master_model->select_data($select_array);
    $output='';
    
    foreach($salse_person_data as $row)
    {
      $output .= $row['std_code'];

    }
          echo $output; 
    }
  
  function get_city()
  {
    $state_id=$this->input->post('state_id');
    $city_id=$this->input->post('city_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_name,city_id,is_active,state_id',
                '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);
    //print_r($salse_person_data);
    $output='<option value="">Select City</option>';
    
    foreach($salse_person_data as $row)
    {
      $selected='';

       if ($row['city_id']==$city_id) 

       {

        $selected='selected="selected"';

       }
      $output .= '<option value='.$row['city_id'].' '.$selected.'>'.$row['city_name'].'</option>';

    }
          echo $output; 
    }
     function disable_company_branch($company_branch_id){
     	admin_auth();
     	//$id=$this->encrypt->decode($company_branch_id);
		$id=encrypt_decrypt_parameters($company_branch_id,'decrypt');
     	$user_id = $this->session->userdata('user_id'); 
     $company_branch_data=array(
								'is_active' =>'0',								
								'created_on' => date("Y-m-d H:i:s"),
								'created_by' =>$user_id,
								'modified_by' => $user_id,	
								'modified_on' => date("Y-m-d H:i:s")								
					    );
     	$condition=array('company_branch_id'=>$id);
     	$this->session->set_flashdata('message',' Company Branch is disable');
		$this->master_model->update_record(TABLE_COMPANY_BRANCH,$company_branch_data,$condition);
		redirect('gc/company_branch/list_company_branch');
    }
      function enable_company_branch($company_branch_id){
      	admin_auth();
      //	$id=$this->encrypt->decode($company_branch_id);
		$id=encrypt_decrypt_parameters($company_branch_id,'decrypt');
      	$user_id = $this->session->userdata('user_id'); 
      $company_branch_data=array(
								'is_active' =>'1',								
								'created_on' => date("Y-m-d H:i:s"),
								'created_by' =>$user_id,
								'modified_by' => $user_id,	
								'modified_on' => date("Y-m-d H:i:s")								
					    );
     	$condition=array('company_branch_id'=>$id);
     	$this->session->set_flashdata('message','Company Branch is enable');
		$this->master_model->update_record(TABLE_COMPANY_BRANCH,$company_branch_data,$condition);
		redirect('gc/company_branch/list_company_branch');
    }
    function fetch_geography(){
    	admin_auth();
    	$condition[] = array('where','is_active','1');
    	$selected_array = array( 
			                   'table_name' =>TABLE_BRANCH_SALABLE_GEOGRAPHY,
			                   'table_fields' => 'branch_salable_geography_id,saleble_geography_name',
			                   'order_by_field'=>'Asc',
			                   'condition'=>$condition,
                         'limit'=>'',
                         'offset'=>''
		);

		return $this->master_model->select_data($selected_array);		         
    }
	
}