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

class ConsignorControllers extends CI_Controller {

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

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

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

    }

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

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

	

	public function add_consignor()
    	{


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

	}




	//...............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->ConsignorModel->insertInfo('consignor_tb', $data);

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




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



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





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

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

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

	   }






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

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

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

	   $this->load->view('admin/header');
       $this->load->view('admin/edit_consignor', $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->ConsignorModel->updateInfoById($id,$data);

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

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

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

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



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

		//	print_r($id); die;

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

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

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

}
