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

class Manager extends CI_Controller {	
		
	
	
	public function showInventories($mode){
			$this->load->model('model_manager');
			$this->load->library('Pagination');
			
			$pageLimit=10;
			$data["mode"] = $mode;
		if ($mode == 1) {
			$totalRows=count($this->model_manager->getAllActiveInventories());			
			$m_inventories = $this->model_manager->getAllActiveInventories();
			$data['m_inventories'] = $m_inventories;						
		} elseif ($mode==2){
			$totalRows=count($this->model_manager->getAllUnactiveInventories());
			$m_inventories = $this->model_manager->getAllUnactiveInventories();
			$data['m_inventories'] = $m_inventories;
		} else {
			$totalRows=$this->model_manager->getCountArchiveInventories();
			$configuration=$this->getConfigurationForPagination($pageLimit, base_url('manager/showInventories/3/'), $totalRows, 4);	
			$data['m_inventories'] = $this->model_manager->fetchAllArchiveInventories($pageLimit, $this->uri->segment(4));
			$this->pagination->initialize($configuration);
		}
		$this->load->view('include/header');
		$this->load->view('manager/manager_inventories', $data);
		$this->load->view('include/footer');	
	} 	
	
	public function searchArchiveInventories($mode){
		
		$this->load->model('model_manager');
		$searchStr = $this->input->post('inventory_search');
		if(intval($searchStr)==0){
			$searchStr = mb_strtoupper($searchStr);
		}else{
			$searchStr = intval($searchStr);	
		}
		
		if(isset($searchStr) AND !empty($searchStr)){
			$data['m_inventories'] = $this->model_manager->searchArchiveInventories($searchStr);
			$data['mode'] = $mode;
			$this->load->view('include/header');
			$this->load->view('manager/manager_inventories', $data);
			$this->load->view('include/footer');			
		} else {
			redirect(base_url('manager/showInventories/3'));						
		}
	}
	
	public function getConfigurationForPagination($pageLimit, $base_url, $totalRows, $uriSegment){
		$configuration=array();
		$configuration['per_page'] = $pageLimit;
		$configuration['base_url'] = $base_url;	
		$configuration['total_rows'] = $totalRows;
		$configuration['uri_segment'] = intval($uriSegment);
		
		$configuration['full_tag_open'] = '<ul class="pagination">';
  		$configuration['full_tag_close'] = '</ul></div><!--pagination-->';
		$configuration['first_link'] = '&laquo;';
		$configuration['first_tag_open'] = '<li class="prev page">';
		$configuration['first_tag_close'] = '</li>';
		$configuration['last_link'] = '&raquo;';
		$configuration['last_tag_open'] = '<li class="next page">';
		$configuration['last_tag_close'] = '</li>';
		$configuration['next_link'] = '&rarr;';
		$configuration['next_tag_open'] = '<li class="next page">';
		$configuration['next_tag_close'] = '</li>';
		$configuration['prev_link'] = '&larr;';
		$configuration['prev_tag_open'] = '<li class="prev page">';
		$configuration['prev_tag_close'] = '</li>';
		$configuration['cur_tag_open'] = '<li><a href="" class="active">';
		$configuration['cur_tag_close'] = '</a></li>';
		$configuration['num_tag_open'] = '<li class="page">';
		$configuration['num_tag_close'] = '</li>';
		
		return $configuration;
	} 	
	
	public function redirectChooseCustomerNewInventory(){
		$this->load->library('Pagination');
		$this->load->model('model_manager');
		$total_rows = $this->model_manager->getCountCustomers();
		$configuration = array();
		
		$configuration['base_url'] = base_url() . 'manager/redirectChooseCustomerNewInventory';
		$configuration['total_rows'] = $total_rows;
		$configuration['per_page']	= 10;			
		$data['Customers'] = $this->model_manager->fetchCustomers($configuration['per_page'],$this->uri->segment(3));
		
		$configuration['full_tag_open'] = '<ul class="pagination">';
  		$configuration['full_tag_close'] = '</ul></div><!--pagination-->';
		$configuration['first_link'] = '&laquo;';
		$configuration['first_tag_open'] = '<li class="prev page">';
		$configuration['first_tag_close'] = '</li>';
		$configuration['last_link'] = '&raquo;';
		$configuration['last_tag_open'] = '<li class="next page">';
		$configuration['last_tag_close'] = '</li>';
		$configuration['next_link'] = '&rarr;';
		$configuration['next_tag_open'] = '<li class="next page">';
		$configuration['next_tag_close'] = '</li>';
		$configuration['prev_link'] = '&larr;';
		$configuration['prev_tag_open'] = '<li class="prev page">';
		$configuration['prev_tag_close'] = '</li>';
		$configuration['cur_tag_open'] = '<li><a href="" class="active">';
		$configuration['cur_tag_close'] = '</a></li>';
		$configuration['num_tag_open'] = '<li class="page">';
		$configuration['num_tag_close'] = '</li>';

		$this->pagination->initialize($configuration);
		
		$this->load->view('include/header');
		$this->load->view('manager/manager_inventory_create', $data);
		$this->load->view('include/footer');	
	}	
	
	public function redirectCreateNewInventory($id_cus){
		$this->load->model('model_manager');
		$this->load->model('model_vehicles');
		
		if($id_cus==0){
			$data['checkCustomer']=FALSE;
		} else {
			$data['checkCustomer']=$this->model_manager->getCustomerInfo($id_cus);
		}
		
		$data['customers']=$this->model_manager->getCustomersInfo();
		$data['engageTimes']=$this->model_manager->getReservations();
		$data['vehicles']=$this->model_vehicles->getAllActiveVehicles();			
		
		$this->redirectToFormForNewInventory($data);			
	}
	
	public function redirectToFormForNewInventory($data){
		$this->load->view('include/header');
		$this->load->view('manager/manager_inventory_create_2', $data);
		$this->load->view('include/footer');
	}
	
	public function saveNewInventory($id_cus){
		$this->load->helper(array('form', 'url'));
		$this->load->model('model_manager');
		
		$range = $this->input->post('newDriveRange');
		$inventoryType = $this->input->post('newTypeInventory');
		$driveTime = $this->input->post('newDriveTimeHours').":".$this->input->post('newDriveTimeMinutes').":00";
		$dateTimeJoin = substr($this->input->post('newInventoryJoinDate'),6,4)."-".substr($this->input->post('newInventoryJoinDate'),3,2)."-".substr($this->input->post('newInventoryJoinDate'),0,2)." ".$this->input->post('newInventoryJoinHours').":".$this->input->post('newInventoryJoinMinutes').":00";
		$dateTimeStart = substr($this->input->post('newInventoryStartDate'),6,4)."-".substr($this->input->post('newInventoryStartDate'),3,2)."-".substr($this->input->post('newInventoryStartDate'),0,2)." ".$this->input->post('newInventoryStartHours').":".$this->input->post('newInventoryStartMinutes').":00";
		$dateTimeEnd = substr($this->input->post('newInventoryEndDate'),6,4)."-".substr($this->input->post('newInventoryEndDate'),3,2)."-".substr($this->input->post('newInventoryEndDate'),0,2)." ".$this->input->post('newInventoryEndHours').":".$this->input->post('newInventoryEndMinutes').":00";	
		
		$vehicles = $this->input->post('vehicle');
						
		if($id_cus==0){															
			$companyName = $this->input->post('newNameCompany');
			$companyCity = $this->input->post('newCityCompany');
			$companyStreet = explode(' ',$this->input->post('newStreetCompany'),2)['0'];
			$statusCompare = $this->model_manager->existsNewCustomer(strtoupper($companyName),strtoupper($companyCity),strtoupper($companyStreet));
			
			if($statusCompare==FALSE){
				$companyStreetNumer = explode(' ',$this->input->post('newStreetCompany'),2)['1'];
				$postCode = $this->input->post('newStreetPostCodeCompany');
				$companyType = $this->input->post('newTypeCompany');
				$this->model_manager->saveNewInventoryNewCustomer($companyName, $companyCity, $companyStreet, $companyStreetNumer, $postCode, $companyType, $range, $inventoryType, $driveTime, $dateTimeJoin, $dateTimeStart, $dateTimeEnd, $vehicles);					
			}else{
				$this->model_manager->saveNewInventoryOldCustomer($statusCompare, $range, $inventoryType, $driveTime, $dateTimeJoin, $dateTimeStart, $dateTimeEnd, $vehicles);							
			}			
		}else{				
			$this->model_manager->saveNewInventoryOldCustomer($id_cus, $range, $inventoryType, $driveTime, $dateTimeJoin, $dateTimeStart, $dateTimeEnd, $vehicles);			
		}
		
	
		redirect(base_url('manager/showInventories/1'));
	}
	
	public function cancelInventory($mode, $id_inv){
		$this->load->model('model_inventory');
		
		$allEmployees = $this->model_inventory->getEmployeesForCancel($id_inv);
		$inventory = $this->model_inventory->DetailOfInventory($id_inv);

		foreach($allEmployees as $employee){
			foreach($employee as $e){			
				$configuration = Array (
					'protocol' => 'smtp',
					'smtp_host' => 'smtp.webglobe.sk',
					'smtp_port' =>	2525,
					'smtp_user' => 'no-reply@martinbendik.studenthosting.sk',
					'smtp_pass' => 'w81H9Ppl'
				);		
				
				$this->load->library('email', $configuration);			
				$this->email->set_newline("\r\n");
				
				$this->email->from('no-reply@martinbendik.studenthosting.sk', 'no-reply');
				$this->email->to($e->Email);
				$this->email->subject('Zrušenie inventúry');
				$this->email->message('
Dobrý deň '.$e->Meno.' '.$e->Priezvisko.',

z technický príčin bola inventúra, na ktorú ste boli prihlasený zrušená.

Detail zrušenej inventúry:

Zákazník:				'.$inventory->Nazov_spolocnosti.' - '.$inventory->Mesto.'
Dátum a čas nástupu:    '.$inventory->Datum_zaciatku.' 
Dátum a čas konca: 		'.$inventory->Datum_konca.'

Ďakujeme na pochopenie. S pozdravom, manažér spoločosti.

V informačnom systéme sa môžete prihlásiť na inú ohlasenú inventúru.
					
				');				
				$this->email->send();									
			}			
		}
		
		$this->model_inventory->deleteInventory($id_inv);
		redirect(base_url('manager/showInventories/'.$mode));
	}
		
	
	
	public function redirectInventoryDetail($modeInv, $modeDet, $id_inv){
		$this->load->model('model_lead_employee');
		
		$data['modeDet']=$modeDet;
		$data['modeInv']=$modeInv;
		$data['id_inv']=$id_inv;		
		
		switch ($modeDet) {
    		case 1:
        		$data['inventoryInfo'] = $this->model_lead_employee->getGeneralInventoryInfo($id_inv); 
				$data['idCustomer'] = $this->model_lead_employee->getCustomerId($id_inv);
				$this->load->library('googlemaps');
				$config = array();
				$config['center'] = $data['inventoryInfo']->GPS;
				$config['map_height'] = 374;
				$config['map_width'] = 600;
				
				$marker = array();
				$marker['position'] = $data['inventoryInfo']->GPS;
	 
				$this->googlemaps->add_marker($marker);
				$this->googlemaps->initialize($config);
				$data['map'] = $this->googlemaps->create_map();
				$this->load->view('include/header2', $data);
			break;
    		case 2:
				$data['idCustomer'] = $this->model_lead_employee->getCustomerId($id_inv);
       			$data['inventoryInfo'] = $this->model_lead_employee->getOnlyInventoryReservations($id_inv);
				$this->load->view('include/header');
       		break;
			case 3:
				$data['idCustomer'] = $this->model_lead_employee->getCustomerId($id_inv);
       			$data['inventoryInfo'] = $this->model_lead_employee->getInventoryReport($id_inv);
				$this->load->view('include/header');
       		break;
		}					
		$this->load->view('manager/manager_inventory_detail', $data);
		$this->load->view('include/footer');	
	}
	
	public function getAllCustomers(){
		$this->load->library('Pagination');
		$this->load->model('model_manager');
		$total_rows = $this->model_manager->getCountCustomers();
		$configuration = array();
		
		$configuration['base_url'] = base_url() . 'manager/getAllCustomers';
		$configuration['total_rows'] = $total_rows;
		$configuration['per_page']	= 10;			
		$data['Customers'] = $this->model_manager->fetchCustomers($configuration['per_page'],$this->uri->segment(3));
		
		$configuration['full_tag_open'] = '<ul class="pagination">';
  		$configuration['full_tag_close'] = '</ul></div><!--pagination-->';
		$configuration['first_link'] = '&laquo;';
		$configuration['first_tag_open'] = '<li class="prev page">';
		$configuration['first_tag_close'] = '</li>';
		$configuration['last_link'] = '&raquo;';
		$configuration['last_tag_open'] = '<li class="next page">';
		$configuration['last_tag_close'] = '</li>';
		$configuration['next_link'] = '&rarr;';
		$configuration['next_tag_open'] = '<li class="next page">';
		$configuration['next_tag_close'] = '</li>';
		$configuration['prev_link'] = '&larr;';
		$configuration['prev_tag_open'] = '<li class="prev page">';
		$configuration['prev_tag_close'] = '</li>';
		$configuration['cur_tag_open'] = '<li><a href="" class="active">';
		$configuration['cur_tag_close'] = '</a></li>';
		$configuration['num_tag_open'] = '<li class="page">';
		$configuration['num_tag_close'] = '</li>';

		$this->pagination->initialize($configuration);
		
		$this->load->view('include/header');
		$this->load->view('manager/manager_customers_show', $data);
		$this->load->view('include/footer');
	}
	
	public function redirectCreateCustomer(){
		$this->load->model('model_manager');
		$data['customers']=$this->model_manager->getCustomersInfo();
		$this->load->view('include/header');
		$this->load->view('manager/manager_customer_create',$data);
		$this->load->view('include/footer');
	}
	 
	public function redirectDetailCustomer($mode,$id_cus){

		$data['mode']=$mode;
		$data['id_cus']=$id_cus;
		switch($mode){
			case 1:
				$this->load->model('model_manager');
				$this->load->library('googlemaps');
				
				$data['Customer'] = $this->model_manager->getCustomerDetail($id_cus);
				$data['countInventories'] = $this->model_manager->getCountCustomerInventories($id_cus);
				$data['lastInventory'] = $this->model_manager->getLastInventory($id_cus);						
				
				$configuration = array();
				$configuration['center'] = $data['Customer']->GPS;	
				$configuration['map_height'] = 374;
				$configuration['map_width'] = 600;	
					
				$marker = array();
				$marker['position'] = $data['Customer']->GPS;			
				
				$this->googlemaps->add_marker($marker);				
				$this->googlemaps->initialize($configuration);				
				$data['map'] = $this->googlemaps->create_map();	
					
				$this->showCustomerDetailGeneral($data); 				
			break;
			case 2: 
				$this->load->model('model_inventory');
				$data['inventories'] =  $this->model_inventory->getCustomersInventories($id_cus);
				$this->showCustomerDetailInventories($data);	
			break;
		}					
	}
	
	public function showCustomerDetailGeneral($data){
		$this->load->view('include/header2', $data);
		$this->load->view('manager/manager_customer_detail', $data);
		$this->load->view('include/footer');	
	}
	
	public function showCustomerDetailInventories($data){
		$this->load->view('include/header');
		$this->load->view('manager/manager_customer_detail', $data);
		$this->load->view('include/footer');	
	}
	
	public function searchCustomer(){
		$this->load->model('model_manager');
		$Company = $this->input->post('search');
		if(intval($Company)==0){
			$Company = mb_strtoupper($Company);
		}else{
			$Company = intval($Company);	
		}
		
		if(isset($Company) AND !empty($Company)){
			$data['Customers'] = $this->model_manager->searchCustomer($Company);
			$this->load->view('include/header');
			$this->load->view('manager/manager_inventory_create', $data);
			$this->load->view('include/footer');
		} else {
			redirect(base_url().'main/m_createInventory');
		}
	}
	
	public function redirectEditCustomer($id_cus){
		$this->load->model('model_manager');
		$data['Customer'] = $this->model_manager->getCustomerInfo($id_cus);
		
		$this->load->view('include/header');
		$this->load->view('manager/manager_customer_edit', $data);
		$this->load->view('include/footer');	
	}
	
	public function saveEditedCustomer($id_cus){
		
			$address = urlencode($this->input->post('editUlica') . ' ' . $this->input->post('editCislo') . ' ' . $this->input->post('editMesto'));			
			$mapLink = "http://maps.google.com/maps/api/geocode/json?sensor=false&address=" . $address;			
			
				$URL = curl_init();			
				curl_setopt($URL, CURLOPT_URL, $mapLink);
				curl_setopt($URL, CURLOPT_HEADER, 0);
				curl_setopt($URL, CURLOPT_RETURNTRANSFER, 1);
				
				$aData = curl_exec($URL);				
				curl_close($URL);
				$data = json_decode ( $aData );
		    
		    if ($data=='ZERO_RESULTS'){;
				$coordinates=null;
			} else {
				$coordinates = $data->results[0]->geometry->location->lat . ',' . $data->results[0]->geometry->location->lng;					
			}
			
			$this->load->model('model_manager');
			$this->model_manager->saveCustomer(	$id_cus,
										   		$this->input->post('editNazovSpolocnosti'),
										   		$this->input->post('editDruhSpolocnosti'),
										   		$this->input->post('editMesto'),
												$this->input->post('editUlica'),
										   		$this->input->post('editCislo'),
										   		$this->input->post('editPSC'),
										   		$coordinates);
			redirect(base_url() . 'manager/redirectDetailCustomer/1/'.$id_cus);								   	
	}	
	
	public function searchCustomer2(){
		$this->load->model('model_manager');
		$Company = $this->input->post('search');
		if(intval($Company)==0){
			$Company = mb_strtoupper($Company);
		}else{
			$Company = intval($Company);	
		}
		if(isset($Company) AND !empty($Company)){
			$data['Customers'] = $this->model_manager->searchCustomer($Company);
			$this->load->view('include/header');
			$this->load->view('manager/manager_customers_show', $data);
			$this->load->view('include/footer');
		} else {
			redirect(base_url().'manager/getAllCustomers');
		}
	}
	
	public function createNewCustomer(){
			$this->load->helper(array('form', 'url'));
			$this->load->model('model_manager');
			
			$address = urlencode($this->input->post('newUlicaSpolocnosti') . ' ' . $this->input->post('newCisloSpolocnosti') . ' ' . $this->input->post('newMestoSpolocnosti'));
			$mapLink = "http://maps.google.com/maps/api/geocode/json?sensor=false&address=" . $address;
				
				$URL = curl_init();			
				curl_setopt($URL, CURLOPT_URL, $mapLink);
				curl_setopt($URL, CURLOPT_HEADER, 0);
				curl_setopt($URL, CURLOPT_RETURNTRANSFER, 1);
				
				$aData = curl_exec($URL);				
				curl_close($URL);
				$data = json_decode ( $aData );
			
			if ($data->status=='ZERO_RESULTS'){
				$coordinates=null;
			} else {
				$coordinates = $data->results[0]->geometry->location->lat . ',' . $data->results[0]->geometry->location->lng;					
			}
					
			$id_cus=$this->model_manager->CreateCustomer($this->input->post('newNazovSpolocnosti'),
												 $this->input->post('newDruhSpolocnosti'),	
												 $this->input->post('newMestoSpolocnosti'),	
												 $this->input->post('newUlicaSpolocnosti'),	
												 $this->input->post('newCisloSpolocnosti'),
												 $this->input->post('newPSCSpolocnosti'),
												 $coordinates	
												);
	
			redirect(base_url('manager/redirectDetailCustomer/1/'.$id_cus));
	}
	
	public function showVehicles($mode){
		$this->load->model('model_vehicles');
		
		if ($mode==1){			
			$data['Vehicles'] = $this->model_vehicles->getAllVehicles2();
			$data['active'] = 1;
		} elseif ($mode==2) {
			$data['Vehicles'] = $this->model_vehicles->getAllActiveVehicles();
			$data['active'] = 2;
		} else {
			$data['Vehicles'] = $this->model_vehicles->getAllUnactiveVehicles();
			$data['active'] = 3;
		}		
		$this->load->view('include/header');
		$this->load->view('manager/manager_vehicles_show', $data);
		$this->load->view('include/footer');
	}
	
	public function redirectNewVehicle(){
		$this->load->view('include/header');
		$this->load->view('manager/manager_vehicle_create');
		$this->load->view('include/footer');
		
	}
	
	public function createNewVehicle(){
		$this->load->helper(array('form', 'url'));
		$this->load->library('form_validation');
		
		$this->form_validation->set_rules('newNazovVozidla', 'Názov vozidla', 'required');
		$this->form_validation->set_rules('newSPZVozidla', 'ŠPZ vozidla', 'required');
		$this->form_validation->set_rules('newPocetMiestVozidla', 'Počet miest vozidla', 'required');					
		
		if ($this->form_validation->run()==FALSE){
			$this->load->view('include/header');
			$this->load->view('manager/manager_vehicle_create');
			$this->load->view('include/footer');	
		} else {
			$this->load->model('model_vehicles');
			$this->model_vehicles->createNewVehicle($this->input->post('newNazovVozidla'),$this->input->post('newSPZVozidla'),$this->input->post('newPocetMiestVozidla'),$this->input->post('newAktivitaVozidla'));
			redirect(base_url() . 'manager/showVehicles/1');	
		}
	}
	
	public function showDetailVehicleActive($active,$modeDet,$id_voz,$dateRes){
		$data['active']=$active;
		$data['modeDet']=$modeDet;
		$data['id_voz']=$id_voz;
		$data['dateRes']=$dateRes;
		$this->load->model('model_vehicles');
		switch ($modeDet){
			case 1:
				$data['vehicle'] = $this->model_vehicles->getVehicleInfo($id_voz);	 
			break;	
			case 2:	
				$totalRows=$this->model_vehicles->getCountVehicleActiveInventories($id_voz);
				$data['inventories'] = $this->model_vehicles->fetchVehicleActiveInventories($id_voz, 10, $this->uri->segment(7));					
				$configuration=$this->getConfigurationForPagination(10, base_url('manager/showDetailVehicleActive/'.$active.'/'.$modeDet.'/'.$id_voz.'/'.$dateRes), $totalRows, 7);	
				$this->pagination->initialize($configuration);			
			break;
			case 3: 
				$totalRows=$this->model_vehicles->getCountVehicleArchiveInventories($id_voz);
				$data['inventories'] = $this->model_vehicles->fetchVehicleArchiveInventories($id_voz, 10, $this->uri->segment(7));					
				$configuration=$this->getConfigurationForPagination(10, base_url('manager/showDetailVehicleActive/'.$active.'/'.$modeDet.'/'.$id_voz.'/'.$dateRes), $totalRows, 7);	
				$this->pagination->initialize($configuration);							
			break;
		}
		
		/*ss
		$data10['whereBack']=$whereBack;
		$this->load->library('Pagination');		
						
				 
		$configuration10 = array();	
		$configuration10['base_url'] = base_url() . 'manager/showDetailVehicleActive/'. $id_voz;		
		$configuration10['per_page'] = 8;
		if($whereBack==NULL){
			$configuration10['uri_segment'] = 4;	
		}else{
			$configuration10['uri_segment'] = 5;
		}
								
		$configuration10['total_rows'] = $this->model_vehicles->getCountVehicleActiveInventories($id_voz);										
		
		$configuration10['full_tag_open'] = '<div><ul class="pagination">';
  		$configuration10['full_tag_close'] = '</ul></div><!--pagination-->';
		$configuration10['first_link'] = '&laquo;';
		$configuration10['first_tag_open'] = '<li class="prev page">';
		$configuration10['first_tag_close'] = '</li>';
		$configuration10['last_link'] = '&raquo;';
		$configuration10['last_tag_open'] = '<li class="next page">';
		$configuration10['last_tag_close'] = '</li>';
		$configuration10['next_link'] = '&rarr;';
		$configuration10['next_tag_open'] = '<li class="next page">';
		$configuration10['next_tag_close'] = '</li>';
		$configuration10['prev_link'] = '&larr;';
		$configuration10['prev_tag_open'] = '<li class="prev page">';
		$configuration10['prev_tag_close'] = '</li>';
		$configuration10['cur_tag_open'] = '<li><a href="" class="active">';
		$configuration10['cur_tag_close'] = '</a></li>';
		$configuration10['num_tag_open'] = '<li class="page">';
		$configuration10['num_tag_close'] = '</li>';
		
		$this->pagination->initialize($configuration10);
				
		$data10['Vehicle'] = $this->model_vehicles->getVehicleInfo($id_voz);	
		if($whereBack==NULL){
			$data10['Inventories'] = $this->model_vehicles->fetchVehicleActiveInventories($id_voz, $configuration10['per_page'], $this->uri->segment(4));	
		}else{
			$data10['Inventories'] = $this->model_vehicles->fetchVehicleActiveInventories($id_voz, $configuration10['per_page'], $this->uri->segment(5));
		}
		
		$data10['Active'] = 1;*/
		
		$this->load->view('include/header');
		$this->load->view('manager/manager_vehicle_detail',$data);
		$this->load->view('include/footer');	
	}
	
	public function showDetailVehicleArchive($id_voz){
		$this->load->library('Pagination');		
		$this->load->model('model_vehicles');				
				
		$configuration11 = array();	
		$configuration11['base_url'] = base_url() . 'manager/showDetailVehicleArchive/'. $id_voz .'/2';		
		$configuration11['per_page'] = 8;
		$configuration11['uri_segment'] = 4;						
		$configuration11['total_rows'] = $this->model_vehicles->getCountVehicleArchiveInventories($id_voz);										
		
		$configuration11['full_tag_open'] = '<div><ul class="pagination">';
  		$configuration11['full_tag_close'] = '</ul></div><!--pagination-->';
		$configuration11['first_link'] = '&laquo;';
		$configuration11['first_tag_open'] = '<li class="prev page">';
		$configuration11['first_tag_close'] = '</li>';
		$configuration11['last_link'] = '&raquo;';
		$configuration11['last_tag_open'] = '<li class="next page">';
		$configuration11['last_tag_close'] = '</li>';
		$configuration11['next_link'] = '&rarr;';
		$configuration11['next_tag_open'] = '<li class="next page">';
		$configuration11['next_tag_close'] = '</li>';
		$configuration11['prev_link'] = '&larr;';
		$configuration11['prev_tag_open'] = '<li class="prev page">';
		$configuration11['prev_tag_close'] = '</li>';
		$configuration11['cur_tag_open'] = '<li><a href="" class="active">';
		$configuration11['cur_tag_close'] = '</a></li>';
		$configuration11['num_tag_open'] = '<li class="page">';
		$configuration11['num_tag_close'] = '</li>';
		
		$this->pagination->initialize($configuration11);
			
		$data11['Vehicle'] = $this->model_vehicles->getVehicleInfo($id_voz);	
		if ($this->model_vehicles->fetchVehicleArchiveInventories($id_voz, $configuration11['per_page'], $this->uri->segment(5))==false){
			$data11['Inventories']=null;
		} else {
		$data11['Inventories'] = $this->model_vehicles->fetchVehicleArchiveInventories($id_voz, $configuration11['per_page'], $this->uri->segment(5));			
		}

		$data11['Active'] = 2;
		
		$this->load->view('include/header');
		$this->load->view('manager/manager_vehicle_detail',$data11);
		$this->load->view('include/footer');	
	}
	
	public function redirectEditVehicle($id_voz){
		$this->load->model('model_vehicles');
		$data['Vehicle']=$this->model_vehicles->getVehicleInfo($id_voz);
		$data['Inventories']=$this->model_vehicles->getVehicleActiveInventories($id_voz);
		
		$this->load->view('include/header');
		$this->load->view('manager/manager_vehicle_edit',$data);
		$this->load->view('include/footer');
	}
	
	public function vehicleEditSave($id_voz){
		$this->load->model('model_vehicles');
		$this->model_vehicles->updateVehicleInfo($id_voz,$this->input->post('editVehicleName'),$this->input->post('editVehicleSPZ'),$this->input->post('editVehicleNumberSeats'));
		
		redirect(base_url('manager/showDetailVehicleActive/1/1/'.$id_voz.'/0'));		
	}
	
	public function setActivity($id_voz,$activity){
		$this->load->model('model_vehicles');
		$this->model_vehicles->setVehicleActivity($id_voz,$activity);
		
		redirect(base_url() . 'manager/redirectEditVehicle/'. $id_voz);
	}
	
	public function changeVehicles($id_inv,$id_voz){
		$this->load->model('model_vehicles');
		$this->model_vehicles->swapInventoryVehicle($id_inv,$id_voz,$this->input->post('changeInventoryVehicle'));
		
		redirect(base_url() . 'manager/redirectEditVehicle/'. $id_voz);
	}
	
	
	//REZERVACIE
	
	public function getReservations($date){
		$this->load->helper('date');
		$this->load->model('model_reservations');
		if ($date==0){
			$today=$this->model_reservations->getDate();
			$today=$today->DNESOK;	
		} else {
			$today=$date;
		}

		$data['today'] = $today;
		$data['vehicles'] = $this->model_reservations->getIDActiveVehicles();
				
		$this->load->view('include/header');
		$this->load->view('manager/manager_reservations',$data);
		$this->load->view('include/footer');		
	}
	
	public function redirectGetReservations(){
		if ($this->input->post('setRedirectDate')=="Vyberte"){
			redirect(base_url() . 'manager/getReservations/0');	
		} else {
			redirect(base_url() . 'manager/getReservations/'.$this->input->post('setRedirectDate'));
		}
		
	}	
	
	
	 
	// ZAMESTNANCI
	public function getAllEmployees(){
		$this->load->library('Pagination');
		$this->load->model('model_manager');		
		
		$totalRows = $this->model_manager->getCountAllEmployees();				
		$configuration = array();
		$pageLimit = 10;
						
		$data['Employees'] = $this->model_manager->fetchAllEmployees($pageLimit,$this->uri->segment(3));
		$data['Active'] = 0;		
		$configuration = $this->getConfigurationForPagination($pageLimit, base_url('manager/getAllEmployees/'), $totalRows, 3);		
		
		$this->pagination->initialize($configuration);		
		$this->redirectShowAllEmployees($data);
	}
	
	public function redirectShowAllEmployees($data){
		$this->load->view('include/header');
		$this->load->view('manager/manager_employees_show', $data);
		$this->load->view('include/footer');	
	}
	
	
	
	public function getManagers(){
		$this->load->library('Pagination');
		$this->load->model('model_manager');
		$total_rows = $this->model_manager->getCountManagers();
		
		
		$configuration3 = array();
		$configuration3['base_url'] = base_url() . 'manager/getAllEmployees/';		
		$configuration3['per_page'] = 10;
		
		$configuration3['total_rows'] = $total_rows;
		$fetch = $this->model_manager->fetchManagers($configuration3['per_page'],$this->uri->segment(3));
		$data3['Employees'] = $fetch;
		$data3['Active'] = 1;
		
		$configuration3['full_tag_open'] = '<ul class="pagination">';
  		$configuration3['full_tag_close'] = '</ul></div><!--pagination-->';
		$configuration3['first_link'] = '&laquo;';
		$configuration3['first_tag_open'] = '<li class="prev page">';
		$configuration3['first_tag_close'] = '</li>';
		$configuration3['last_link'] = '&raquo;';
		$configuration3['last_tag_open'] = '<li class="next page">';
		$configuration3['last_tag_close'] = '</li>';
		$configuration3['next_link'] = '&rarr;';
		$configuration3['next_tag_open'] = '<li class="next page">';
		$configuration3['next_tag_close'] = '</li>';
		$configuration3['prev_link'] = '&larr;';
		$configuration3['prev_tag_open'] = '<li class="prev page">';
		$configuration3['prev_tag_close'] = '</li>';
		$configuration3['cur_tag_open'] = '<li><a href="" class="active">';
		$configuration3['cur_tag_close'] = '</a></li>';
		$configuration3['num_tag_open'] = '<li class="page">';
		$configuration3['num_tag_close'] = '</li>';		
		
		$this->pagination->initialize($configuration3);
		$this->load->view('include/header');
		$this->load->view('manager/manager_employees_show', $data3);
		$this->load->view('include/footer');	
	}
	
	public function getLeadEmployees(){
		$this->load->library('Pagination');
		$this->load->model('model_manager');
		$total_rows = $this->model_manager->getCountLeadEmployees();
		
		
		$configuration4 = array();
		$configuration4['base_url'] = base_url() . 'manager/getAllEmployees/';		
		$configuration4['per_page'] = 10;
		
		$configuration4['total_rows'] = $total_rows;
		$fetch = $this->model_manager->fetchLeadEmployees($configuration4['per_page'],$this->uri->segment(3));
		$data4['Employees'] = $fetch;
		$data4['Active'] = 2;
		
		$configuration4['full_tag_open'] = '<ul class="pagination">';
  		$configuration4['full_tag_close'] = '</ul></div><!--pagination-->';
		$configuration4['first_link'] = '&laquo;';
		$configuration4['first_tag_open'] = '<li class="prev page">';
		$configuration4['first_tag_close'] = '</li>';
		$configuration4['last_link'] = '&raquo;';
		$configuration4['last_tag_open'] = '<li class="next page">';
		$configuration4['last_tag_close'] = '</li>';
		$configuration4['next_link'] = '&rarr;';
		$configuration4['next_tag_open'] = '<li class="next page">';
		$configuration4['next_tag_close'] = '</li>';
		$configuration4['prev_link'] = '&larr;';
		$configuration4['prev_tag_open'] = '<li class="prev page">';
		$configuration4['prev_tag_close'] = '</li>';
		$configuration4['cur_tag_open'] = '<li><a href="" class="active">';
		$configuration4['cur_tag_close'] = '</a></li>';
		$configuration4['num_tag_open'] = '<li class="page">';
		$configuration4['num_tag_close'] = '</li>';		
		
		$this->pagination->initialize($configuration4);
		$this->load->view('include/header');
		$this->load->view('manager/manager_employees_show', $data4);
		$this->load->view('include/footer');	
	}
	
	public function getDrivers(){
		$this->load->library('Pagination');
		$this->load->model('model_manager');
		$total_rows = $this->model_manager->getCountDrivers();
		
		
		$configuration5 = array();
		$configuration5['base_url'] = base_url() . 'manager/getAllEmployees/';		
		$configuration5['per_page'] = 10;
		
		$configuration5['total_rows'] = $total_rows;
		$fetch = $this->model_manager->fetchDrivers($configuration5['per_page'],$this->uri->segment(3));
		$data5['Employees'] = $fetch;
		$data5['Active'] = 3;
		
		$configuration5['full_tag_open'] = '<ul class="pagination">';
  		$configuration5['full_tag_close'] = '</ul></div><!--pagination-->';
		$configuration5['first_link'] = '&laquo;';
		$configuration5['first_tag_open'] = '<li class="prev page">';
		$configuration5['first_tag_close'] = '</li>';
		$configuration5['last_link'] = '&raquo;';
		$configuration5['last_tag_open'] = '<li class="next page">';
		$configuration5['last_tag_close'] = '</li>';
		$configuration5['next_link'] = '&rarr;';
		$configuration5['next_tag_open'] = '<li class="next page">';
		$configuration5['next_tag_close'] = '</li>';
		$configuration5['prev_link'] = '&larr;';
		$configuration5['prev_tag_open'] = '<li class="prev page">';
		$configuration5['prev_tag_close'] = '</li>';
		$configuration5['cur_tag_open'] = '<li><a href="" class="active">';
		$configuration5['cur_tag_close'] = '</a></li>';
		$configuration5['num_tag_open'] = '<li class="page">';
		$configuration5['num_tag_close'] = '</li>';		
		
		$this->pagination->initialize($configuration5);
		$this->load->view('include/header');
		$this->load->view('manager/manager_employees_show', $data5);
		$this->load->view('include/footer');	
	}
	
	public function getEmployees(){				
		$this->load->library('Pagination');
		$this->load->model('model_manager');
		$total_rows = $this->model_manager->getCountEmployees();
				
		$configuration = array();
		$configuration['base_url'] = base_url() . 'manager/getEmployees/';		
		$configuration['per_page'] = 10;
		
		$configuration['total_rows'] = $total_rows;
		$fetch6 = $this->model_manager->fetchEmployees($configuration['per_page'],$this->uri->segment(3));
		$data6['Employees'] = $fetch6;
		$data6['Active'] = 4;
		
		$configuration['full_tag_open'] = '<ul class="pagination">';
  		$configuration['full_tag_close'] = '</ul></div><!--pagination-->';
		$configuration['first_link'] = '&laquo;';
		$configuration['first_tag_open'] = '<li class="prev page">';
		$configuration['first_tag_close'] = '</li>';
		$configuration['last_link'] = '&raquo;';
		$configuration['last_tag_open'] = '<li class="next page">';
		$configuration['last_tag_close'] = '</li>';
		$configuration['next_link'] = '&rarr;';
		$configuration['next_tag_open'] = '<li class="next page">';
		$configuration['next_tag_close'] = '</li>';
		$configuration['prev_link'] = '&larr;';
		$configuration['prev_tag_open'] = '<li class="prev page">';
		$configuration['prev_tag_close'] = '</li>';
		$configuration['cur_tag_open'] = '<li><a href="" class="active">';
		$configuration['cur_tag_close'] = '</a></li>';
		$configuration['num_tag_open'] = '<li class="page">';
		$configuration['num_tag_close'] = '</li>';		
		
		$this->pagination->initialize($configuration);
		$this->load->view('include/header');
		$this->load->view('manager/manager_employees_show', $data6);
		$this->load->view('include/footer');		
	}
	
	public function redirectNewEmployee(){
		$this->load->model('model_employee');
		$data['oldEmployees'] = $this->model_employee->getInfoForCheckNewEmployee();
		$this->load->view('include/header');
		$this->load->view('manager/manager_employee_new', $data);
		$this->load->view('include/footer');	
	}
	
	public function searchAllEmployees($mode){
		
		$this->load->model('model_manager');
		$searchStr = $this->input->post('employee_search');
		
		if(isset($searchStr) AND !empty($searchStr)){
			$data['Employees'] = $this->model_manager->searchEmployee($searchStr, $mode);
			$data['Active'] = $mode;
			$this->redirectAfterSearch($data);			
		} else {
			$this->redirectResetSearch($data);							
		}
	}	
	
	
	public function redirectAfterSearch($data){
		$this->load->view('include/header');
		$this->load->view('manager/manager_employees_show', $data);
		$this->load->view('include/footer');
	}
	
	public function redirectResetSearch($data){
		switch($data['Active']){
				case 0: redirect(base_url('manager/getAllEmployees')); break;
				case 1: redirect(base_url('manager/getManagers')); break;
				case 2: redirect(base_url('manager/getLeadEmployees')); break;
				case 3: redirect(base_url('manager/getDrivers')); break;
				case 4: redirect(base_url('manager/getEmployees')); break;				
			}	
	}
	
	
	public function createEmployee(){
		$this->load->helper(array('form', 'url'));
		$this->load->library('form_validation');
		
		$this->form_validation->set_rules('newEmployeeFirst', 'Meno', 'required');
		$this->form_validation->set_rules('newEmployeeLast', 'Priezvisko', 'required');
		$this->form_validation->set_rules('newEmail', 'Email', 'required|valid_email|trim|xss_clean');
		$this->form_validation->set_rules('newEmployeeBirth', 'Rodné číslo', 'required');	
		$this->form_validation->set_rules('newEmployeeType', 'Typ zamestnanca', 'callback_chosen_type');
		
		if ($this->form_validation->run()==FALSE){
			$this->load->view('include/header');
			$this->load->view('manager/manager_employee_new');
			$this->load->view('include/footer');	
		} else {
			$this->load->model('model_manager');

			$this->model_manager->createEmployee($this->input->post('newEmployeeFirst'),$this->input->post('newEmployeeLast'),$this->input->post('newEmail'),$this->input->post('newEmployeeBirth'),$this->input->post('newEmployeeType'), date("Y-m-d"));
			
			$this->load->library('encrypt');
			$generatedPassword = rand(000000, 999999);
			$hashedPassword=md5($generatedPassword);

			
			$configuration = Array (
					'protocol' => 'smtp',
					'smtp_host' => 'smtp.webglobe.sk',
					'smtp_port' =>	2525,
					'smtp_user' => 'no-reply@martinbendik.studenthosting.sk',
					'smtp_pass' => 'w81H9Ppl'
				);
			
			
			$this->load->library('email', $configuration);			
			$this->email->set_newline("\r\n");
			
			$this->email->from('no-reply@martinbendik.studenthosting.sk', 'no-reply');
			$this->email->to($this->input->post('newEmail'));
			$this->email->subject('Prvé prihlásenie');
			$this->email->message('
Dobrý deň,
			
Vítajte v informačnom systéme.

Prihlásiť sa môžete na adrese www.martinbendik.studenthosting.sk.

Vaše prihlasovacie údaje sú Váš e-mail ( '. $this->input->post('newEmail') .' ) a Vaše heslo je: '. $generatedPassword . '
						
Prosím v systéme v sekcii profilu si prosím toto vygenerované heslo zmeňte.

Taktiež Vás prosíme o vyplnenie vášho profilu.

Ďakujeme.');
			
			if($this->email->send()) {
				$this->load->model('model_employee');
				$this->model_employee->setPassword($hashedPassword, $this->input->post('newEmail'));
				redirect(base_url() . 'manager/getAllEmployees');
			} else {
				show_error($this->email->print_debugger());
			}						
	}	
	}
	
	
	public function chosen_type(){
		if ($this->input->post('newEmployeeType')==99){
				$this->form_validation->set_message('chosen_type', 'Vyberte prosím typ zamestnanca.');
				return false;	
			} else {
				return true;
			}
	}
	public function redirectEditEmployee($id_emp){
		$this->load->model('model_employee');
		$data['Employee'] = $this->model_employee->getEmployeeInfoEdit($id_emp);
		
		$this->load->view('include/header');
		$this->load->view('manager/manager_employee_edit', $data);
		$this->load->view('include/footer');
	}
	
	public function updateEmployee($id_emp){
		$this->load->helper(array('form', 'url'));
		$this->load->library('form_validation');
		
		$this->form_validation->set_rules('editEmployeeFirst', 'Meno', 'required');
		$this->form_validation->set_rules('editEmployeeLast', 'Priezvisko', 'required');
		$this->form_validation->set_rules('editEmployeeEmail', 'Email', 'required|valid_email|trim|xss_clean');
		$this->form_validation->set_rules('editEmployeeBirth', 'Rodné číslo', 'required');	
		$this->form_validation->set_rules('editEmployeeType', 'Typ zamestnanca', 'callback_chosen_type');
		
		$this->load->model('model_employee');
		if ($this->form_validation->run()==FALSE){
			$data['Employee'] = $this->model_employee->getEmployeeInfoEdit($id_emp);
			$this->load->view('include/header');
			$this->load->view('manager/manager_employee_edit',$data);
			$this->load->view('include/footer');	
		} else {	
			$this->model_employee->updateEmployeeInfo($id_emp, $this->input->post('editEmployeeFirst'),$this->input->post('editEmployeeLast'),$this->input->post('editEmployeeEmail'),$this->input->post('editEmployeeBirth'),$this->input->post('editEmployeeType'),$this->input->post('editEmployeeStatus'));			
			redirect(base_url('manager/getAllEmployees'));
		}	
	}
	
	public function redirectDetailEmployee($modeInv, $modeDet, $id_emp, $modeSta, $year){
		$this->load->model('model_employee');
		$data['modeDet']=$modeDet;
		$data['modeInv']=$modeInv;
		$data['id_emp']=$id_emp;
		$data['modeSta']=$modeSta;
		$data['year']=$year;
		$type_emp = $this->model_employee->getEmployeeType($id_emp);
		$data['type_emp']=$type_emp;
		$limit=5;

		switch($modeDet){
			case 1: 
				$data['employee']=$this->model_employee->getGeneralEmployeeInfo($id_emp);
			break;
			case 2: 
				switch($type_emp){
					case 1: 
						$data['inventories'] = FALSE;
					break;
					case 2:
						$data['inventories'] = $this->model_employee->getLastInventoriesLeadEmployee($id_emp, $limit);
					break;
					case 3:
						$data['inventories'] = $this->model_employee->getLastInventoriesDriver($id_emp, $limit);
					break;
					case 4:
						$data['inventories'] = $this->model_employee->getLastInventoriesEmployee($id_emp, $limit);
					break;
				}
			break;
			case 3: 
				switch($type_emp){
					case 1: 
						$data['inventories'] = FALSE;
					break;
					case 2:
						$data['inventories'] = $this->model_employee->getLastInventoriesLeadEmployee($id_emp, $limit);
					break;
					case 3:
						$data['inventories'] = $this->model_employee->getLastInventoriesDriver($id_emp, $limit);
					break;
					case 4:
						$data['inventories'] = $this->model_employee->getLastInventoriesEmployee($id_emp, $limit);
					break;
				}
			break;
			case 4: 
				$data['amercements'] = $this->model_employee->getAmercements($id_emp, $limit);
			break;
		}		
		
		$this->load->view('include/header');
		$this->load->view('manager/manager_employee_detail',$data);
		$this->load->view('include/footer');
	}
	
	public function redirectStatistics($modeSta,$modeDet,$year){
		$data['modeSta']=$modeSta;
		$data['modeDet']=$modeDet;
		$data['year']=$year;
		
		$this->load->view('include/header');
		$this->load->view('manager/manager_statistics',$data);
		$this->load->view('include/footer');
	}
	
	public function redirectSettings($mode,$year,$month){
		$data['mode']=$mode;
		if($month<1){
			$data['month']=12;
			$data['year']=($year-1);	
		}else if($month>12){
			$data['month']=1;
			$data['year']=($year+1);	
		}else{
			$data['month']=$month;
			$data['year']=$year;
		}
		
		
		
		$this->load->model('model_manager');
		$data['settings']=$this->model_manager->getOldSettings();
		
		$this->load->view('include/header');
		$this->load->view('manager/manager_settings',$data);
		$this->load->view('include/footer');
	}
	
	public function saveNewSettings(){
		$this->load->model('model_manager');
		$date = new DateTime();
		$data['settings']=$this->model_manager->saveNewSettings($date->format('Y-m-d H:i:s'),$this->input->post('newSalaryLead'),$this->input->post('newSalaryDriver'),$this->input->post('newSalaryEmployee'),str_replace(',', '.', $this->input->post('newSalaryKm')));
			
		redirect(base_url('manager/redirectSettings/3/'.date('Y',time())."/".date('m',time())));
	}
	
	public function redirectPosts(){
		$this->load->library('Pagination');
		$this->load->model('model_manager');
		$total_rows = $this->model_manager->getCountPosts();
				
		$configuration = array();
		$configuration['base_url'] = base_url() . 'manager/redirectPosts/';		
		$configuration['per_page'] = 8;
		
		$configuration['total_rows'] = $total_rows;
		$fetch = $this->model_manager->fetchPosts($configuration['per_page'],$this->uri->segment(3));
		$data['posts'] = $fetch;
		
		$configuration['full_tag_open'] = '<ul class="pagination">';
  		$configuration['full_tag_close'] = '</ul></div><!--pagination-->';
		$configuration['first_link'] = '&laquo;';
		$configuration['first_tag_open'] = '<li class="prev page">';
		$configuration['first_tag_close'] = '</li>';
		$configuration['last_link'] = '&raquo;';
		$configuration['last_tag_open'] = '<li class="next page">';
		$configuration['last_tag_close'] = '</li>';
		$configuration['next_link'] = '&rarr;';
		$configuration['next_tag_open'] = '<li class="next page">';
		$configuration['next_tag_close'] = '</li>';
		$configuration['prev_link'] = '&larr;';
		$configuration['prev_tag_open'] = '<li class="prev page">';
		$configuration['prev_tag_close'] = '</li>';
		$configuration['cur_tag_open'] = '<li><a href="" class="active">';
		$configuration['cur_tag_close'] = '</a></li>';
		$configuration['num_tag_open'] = '<li class="page">';
		$configuration['num_tag_close'] = '</li>';		
		
		$this->pagination->initialize($configuration);
		$this->load->view('include/header');
		$this->load->view('manager/manager_posts', $data);
		$this->load->view('include/footer');	 
	}
	
	public function redirectPostDetail($id_post){
		$this->load->model('model_manager');
		$data['post'] = $this->model_manager->getPostDetail($id_post);
		$this->load->view('include/header');
		$this->load->view('manager/manager_post_detail', $data);
		$this->load->view('include/footer');
	}
	
	public function setPostAsDone($id_post){
		$this->load->model('model_manager');
		$data['post'] = $this->model_manager->setPostAsDone($id_post, date("Y-m-d G:i:s"),$this->session->userdata['id_zamestnanca']);		
		redirect(base_url('manager/redirectPostDetail/'.$id_post));
	}
	
	public function penaltyEmployee($id_emp,$id_rep){
		$this->load->model("model_manager");
		$this->model_manager->penaltyEmployee($id_emp,$id_rep);
		redirect(base_url('manager/redirectDetailEmployee/4/4/'.$id_emp.'/1/'.date("Y")));			
	}
	
	public function unPenaltyEmployee($id_emp,$id_rep){
		$this->load->model("model_manager");
		$this->model_manager->unPenaltyEmployee($id_emp,$id_rep);
		redirect(base_url('manager/redirectDetailEmployee/4/4/'.$id_emp.'/1/'.date("Y")));		
	}
	
}	
		
	
	
	
		
		
	
		
		



	


