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

class Print_ctrl extends user_index {
 
	
	public function __construct(){ 
		parent::__construct();
		$data = array();
		$this->load->model('admin_model');	
		$this->load->model('loading_model');	
	} 
	 
	
	/*-------- load print loading vehicle  entry details by authentication officer page ------------*/
	public function print_autho_view_loading($lul_id){	
		if($this->user['panel_type']=='1' && in_array("1", $this->u_roles)){		
			$data['sdata'] 				= array();
			$data['subview'] 			= 'print/print_autho_view_loading';
			$data['active_cls'] 		= 'loadaa_lcs';		
			$data['sdata']['lul_data'] 			= $this->loading_model->get_loading_list('Loading',$lul_id,'','','','','0');
			// echo $this->db->last_query();return;
			$data['sdata']['luml_data'] 		= $this->loading_model->get_loading_or_unloading_meterial_list($lul_id.'','');		

			$data['lul_details']['lul_print_status'] 			= '0';
			
			$edit_lul = $this->admin_model->update_data('loading_unloading_list','lul_id',$lul_id,$data['lul_details']);

			$this->load->view('common/sidepanel',$data);
		}else{
			redirect('login_ctrl/logout');
		}
	}
	

	/*----------------- load print loading vehicle  entry details by loading officer page -----------------*/
	public function print_load_o_view_loading($lul_id){	
		$data['sdata'] 				= array();
		$data['subview'] 			= 'print/print_load_o_view_loading';
		$data['active_cls'] 		= 'loadaa_lcs';		
		$data['sdata']['lul_data'] 			= $this->loading_model->get_loading_list('Loading',$lul_id,'','','','');
		// echo $this->db->last_query();return;
		$data['sdata']['luml_data'] 		= $this->loading_model->get_loading_or_unloading_meterial_list($lul_id.'','');		

		$data['lul_details']['lul_print_status'] 			= '0';
		
		$edit_lul = $this->admin_model->update_data('loading_unloading_list','lul_id',$lul_id,$data['lul_details']);

		$this->load->view('common/sidepanel',$data);
	}

	/*------- load print loading vehicle  entry details by autherie vehilce entry  officer page -------*/
	public function print_avso_view_loading($lul_id){	
		$data['sdata'] 				= array();
		$data['subview'] 			= 'print/print_avso_view_loading';
		$data['active_cls'] 		= 'loadaa_lcs';		
		$data['sdata']['lul_data'] 			= $this->loading_model->get_loading_list('Loading',$lul_id,'','','','');
		// echo $this->db->last_query();return;
		$data['sdata']['luml_data'] 		= $this->loading_model->get_loading_or_unloading_meterial_list($lul_id.'','');		

		$data['lul_details']['lul_print_status'] 			= '0';
		
		$edit_lul = $this->admin_model->update_data('loading_unloading_list','lul_id',$lul_id,$data['lul_details']);

		$this->load->view('common/sidepanel',$data);
	}

	/*------- load print loading vehicle  entry details by despatch officer page -------*/
	public function print_despatch_view_loading($lul_id){
		if(($this->user['panel_type']=='2' && in_array("2", $this->u_roles)) || ($this->user['panel_type']=='3' && in_array("3", $this->u_roles))){		
			$data['sdata'] 				= array();
			$data['subview'] 			= 'print/print_despatch_view_loading';
			$data['active_cls'] 		= 'loadaa_lcs';		
			$data['sdata']['lul_data'] 			= $this->loading_model->get_loading_list('Loading',$lul_id,'','','','');
			// echo $this->db->last_query();return;
			$data['sdata']['luml_data'] 		= $this->loading_model->get_loading_or_unloading_meterial_list($lul_id.'','');		

			$data['lul_details']['lul_print_status'] 			= '0';
			
			$edit_lul = $this->admin_model->update_data('loading_unloading_list','lul_id',$lul_id,$data['lul_details']);

			$this->load->view('common/sidepanel',$data);
		}else{
			redirect('login_ctrl/logout');
		}
	}
	

	/*-------- load print unloading vehicle  entry details by authentication officer page ------------*/
	public function print_autho_view_unloading($lul_id){	
		$data['sdata'] 				= array();
		$data['subview'] 			= 'print/print_autho_view_unloading';
		$data['active_cls'] 		= 'unloadaa_cls';		
		$data['sdata']['lul_data'] 			= $this->loading_model->get_loading_list('Unloading',$lul_id);
		// echo $this->db->last_query();return;
		$data['sdata']['luml_data'] 		= $this->loading_model->get_loading_or_unloading_meterial_list($lul_id.'','');		

		$data['lul_details']['lul_print_status'] 			= '0';
		
		$edit_lul = $this->admin_model->update_data('loading_unloading_list','lul_id',$lul_id,$data['lul_details']);

		$this->load->view('common/sidepanel',$data);
	}
	
 
	/*----------------- load print unloading vehicle  entry details by loading officer page -----------------*/
	public function print_unload_o_view_loading($lul_id){	
		$data['sdata'] 				= array();
		$data['subview'] 			= 'print/print_unload_o_view_loading';
		$data['active_cls'] 		= 'unloadaa_cls';		
		$data['sdata']['lul_data'] 			= $this->loading_model->get_loading_list('Unloading',$lul_id,'','','','');
		// echo $this->db->last_query();return;
		$data['sdata']['luml_data'] 		= $this->loading_model->get_loading_or_unloading_meterial_list($lul_id.'','');		

		$data['lul_details']['lul_print_status'] 			= '0';
		
		$edit_lul = $this->admin_model->update_data('loading_unloading_list','lul_id',$lul_id,$data['lul_details']);

		$this->load->view('common/sidepanel',$data);
	}
	
	/*------- load print unloading vehicle  entry details by despatch officer page -------*/
	public function print_despatch_view_unloading($lul_id){	
		if(($this->user['panel_type']=='2' && in_array("2", $this->u_roles)) || ($this->user['panel_type']=='3' && in_array("3", $this->u_roles))){	
			$data['sdata'] 				= array();
			$data['subview'] 			= 'print/print_despatch_view_unloading';
			$data['active_cls'] 		= 'unloadaa_cls';		
			$data['sdata']['lul_data'] 			= $this->loading_model->get_loading_list('Unloading',$lul_id,'','','','');
			// echo $this->db->last_query();return;
			$data['sdata']['luml_data'] 		= $this->loading_model->get_loading_or_unloading_meterial_list($lul_id.'','');		

			$data['lul_details']['lul_print_status'] 			= '0';
			
			$edit_lul = $this->admin_model->update_data('loading_unloading_list','lul_id',$lul_id,$data['lul_details']);

			$this->load->view('common/sidepanel',$data);
		}else{
			redirect('login_ctrl/logout');
		}
	}
	

	/*------- gate pass print view unloading -------*/
	public function print_gate_pass_view_unloading($lul_id){	
		$data['sdata'] 				= array();
		$data['subview'] 			= 'print/print_gate_pass_view_unloading';
		$data['active_cls'] 		= 'unloadaa_cls';		
		$data['sdata']['lul_data'] 			= $this->loading_model->get_loading_list('Unloading',$lul_id,'','','','');
		// echo $this->db->last_query();return;
		$data['sdata']['luml_data'] 		= $this->loading_model->get_loading_or_unloading_meterial_list($lul_id.'','');		

		$data['lul_details']['lul_print_status'] 			= '0';
		
		$edit_lul = $this->admin_model->update_data('loading_unloading_list','lul_id',$lul_id,$data['lul_details']);

		$this->load->view('common/sidepanel',$data);
	}
}
