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

class ConsigneeControllers extends CI_Controller {

//...............State construct............

	 	public function __construct(){
		parent::__construct();
		$this->load->library("form_validation");
		$this->load->model("ConsigneeModel");

		$this->load->library('upload');
			

    }

    //...............End construct............

//...............State index function............



	public function index()
    	{

				$result['front_all_info'] = $this->StateModel->selectFrontInfo();
				$result['front_districtall_info'] = $this->DistrictModel->selectFrontInfo();


        	$this->load->view('admin/header');
 	//	$this->load->view('add_sub_gallery');
 			$this->load->view('admin/add_reporter', $result);

	}

	public function add_consignee()
    	{


			$this->load->view('admin/header');
 	
 			$this->load->view('admin/add_consignee');
			

	}




	//...............End index function............


	//...............State insert insertGalleryInfo............


		public function insertInfo(){
		$data = array(

			'NAME' => $this->input->post('NAME'),
			'mobile_no' => $this->input->post('mobile_no'),
			'address' => $this->input->post('address'),
			'gst_no' => $this->input->post('gst_no')
				


		);

    	$id = $this->ConsigneeModel->insertInfo('consignee_tb', $data);

		if($id){
			$this->session->set_flashdata('msg', 'data inserted.');
			$this->load->view('admin/header');
 	
			$this->load->view('admin/add_consignee');
		}else{
			$this->session->set_flashdata('msg', 'error...');
			$this->load->view('admin/header');
 	
			$this->load->view('admin/add_consignee');
		}
	}




	//...............End insert uploadFiles............



	//...............State Manage Subgallerty............





		public function manageInfo()
    	{
        	$this->load->view('admin/header');	

 	$result['all_info'] = $this->ConsigneeModel->selectInfo();

       		$this->load->view('admin/manage_consignee', $result);

	   }






		//...............End Manage Subgallerty............

			//...............State Get ID Wise Subgallery Info ............

			 function getInfoById() {
     $id = $this->uri->segment(3);
		   $result['single_data'] = $this->ConsigneeModel->getInfoById($id);

	   $this->load->view('admin/header');
       $this->load->view('admin/edit_consignee', $result);
      }



       function updateInfoById() {

    $id= $this->input->post('id');

      $data = array(
		'NAME' => $this->input->post('NAME'),
		'mobile_no' => $this->input->post('mobile_no'),
		'address' => $this->input->post('address'),
		'gst_no' => $this->input->post('gst_no'),
	  'STATUS' => $this->input->post('STATUS')

      ) ;
$this->ConsigneeModel->updateInfoById($id,$data);

$this->load->view('admin/header');	

$result['all_info'] = $this->ConsigneeModel->selectInfo();

		  $this->load->view('admin/manage_consignee', $result);

	
}
   	//...............End Update Subgallery By ID ............



		public function deleteInfo()
			{
		 $id = $this->uri->segment(3);

		//	print_r($id); die;

			$this->ConsigneeModel->deleteInfo($id);

			$this->load->view('admin/header');	

			$result['all_info'] = $this->ConsigneeModel->selectInfo();
			
					  $this->load->view('admin/manage_consignee', $result);
			}

}
