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

class DestinationControllers extends CI_Controller {

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

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

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

    }

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

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





	public function add_destination()
    	{


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

	}




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


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


		public function insertInfo(){
		$data = array(

			'NAME' => $this->input->post('NAME')
		


		);

    	$id = $this->DestinationModel->insertInfo('destination_tb', $data);

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




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



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





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

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

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

	   }






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

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

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

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



       function updateInfoById() {

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

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

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

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

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

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

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



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

		//	print_r($id); die;

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

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

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

}
