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

class Main extends CI_Controller {
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// index	

	public $globalData = array();
	
	public function index()
	{
		$this->login();
	} 
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// presmerovanie na login page	
	public function login () {

		$this->load->view('login');	
	}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// generovanie nového hesla	a poslanie emailu s novým heslom
	public function lostPassword() {
		$this->load->view('lost_password');
	}
	
	public function generateNewPassword() {
		$this->load->library('form_validation');
		$this->form_validation->set_rules('email_generate', 'Email', 'required|valid_email|trim|xss_clean');
		
		if ($this->form_validation->run()) {
			$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('email_generate'));
			$this->email->subject('Zmena hesla');
			$this->email->message('
Dobrý deň,
			
na vašu žiadosť vám bolo vygenerované nové heslo.
			
Vaše nové heslo je: '. $generatedPassword . '
			
Teraz sa môžete prihlásiť a zmeniť heslo v sekcii: Zmena profilu zamestnanca.');
			
			if($this->email->send()) {
				$this->load->model('model_employee');
				$this->model_employee->setPassword($hashedPassword, $this->input->post('email_generate'));
				
				$data ['email_sended'] = $this->input->post('email_generate');
				$this->load->view('password_changed', $data);
			} else {
				show_error($this->email->print_debugger());
			}
			
			
		} else {
			$this->load->view('lost_password');	
		}
	}
	
	
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////LOGIN UZIVATELOV////////////////////////////////////////////////////
public function login_validation() {
	$this->load->library('form_validation');
	$this->load->model('model_users');		
				
	$this->form_validation->set_rules('email', 'Email', 'required|trim|xss_clean|callback_validate_credentials|callback_validate_activity');
	$this->form_validation->set_rules('password', 'Password', 'required|md5|trim');		
	if($this->form_validation->run()) {											
		$this->session->set_userdata(
			array ('email' => $this->input->post('email'), 
					'is_logged_in' => true,
					'permisson' => $this->model_users->what_type(),
					'id_zamestnanca' => $this->model_users->get_employee_number(),
					'meno' => $this->model_users->get_name(),	
					'priezvisko' => $this->model_users->get_last_name())
		);			
		switch($this->session->userdata('permisson')){
			case 1: redirect(base_url('main/manager')); break;
			case 2: redirect(base_url('main/lead_employee')); break;
			case 3: redirect(base_url('main/driver')); break;
			case 4: redirect(base_url('main/employee')); break;
			default: $this->load->view('login'); break;
		}						
	} else {
		
		$this->load->view('login');
	}		
}
	public function validate_credentials() {		
			if ($this->model_users->logIn()) {			
				return true;
			} else {
				$this->form_validation->set_message('validate_credentials', '<p style="color:red">Nesprávne meno alebo heslo!</p>');
				return false;
			}
	}			
	public function validate_activity() {
				
		if ($this->model_users->checkActivity()) {			
			return true;
		} else {
			$this->form_validation->set_message('validate_activity', '<p style="color:red">Ľutujeme, ale už nie ste v evidencii zamestnancov.</p>');
			return false;
		}
	}
	
	
	
	public function logout() {
		$this->session->sess_destroy();
		redirect(base_url() . 'main/login');
	}
	
	public function restricted () {
		$this->session->sess_destroy();
		$this->load->view('restricted');
	}
	
	public function manager() {
		if ($this->session->userdata('is_logged_in')) {
			$this->showView ('manager/manager');
		} else {
			redirect(base_url() . 'main/restricted');
		}		
	}
	
	public function lead_employee() {
		if ($this->session->userdata('is_logged_in')) {
			$this->showView ('lead_employee/lead_employee');
		} else {
			redirect(base_url() . 'main/restricted');
		}		
	}
	
	public function driver() {
		if ($this->session->userdata('is_logged_in')) {
			$this->showView ('driver/driver');
		} else {
			redirect(base_url() . 'main/restricted');
		}		
	}
	
	public function employee() {
		if ($this->session->userdata('is_logged_in')) {
			$this->showView('employee/employee');
		} else {
			redirect(base_url() . 'main/restricted');
		}		
	}
	
	public function showView ($name_view) {
		$this->load->view('include/header');
		$this->load->view($name_view);
		$this->load->view('include/footer');
	}
	
	public function redirectNewPost($mode, $id){
		$data['mode']=$mode;
		$data['id']=$id;
		$this->load->model('model_employee');
		switch($mode){
			case 0: 
			break;
		}
		$this->load->view('include/header');
		$this->load->view('employee/employee_post_create', $data);
		$this->load->view('include/footer');
	}
	
	public function saveNewPost(){
		$this->load->model('model_employee');
		$this->model_employee->createNewPost($this->session->userdata('id_zamestnanca'),$this->input->post('newPostSubject'),$this->input->post('newPost'));
		
		switch($this->session->userdata('permisson')){
			case 2: redirect(base_url('main/lead_employee')); 
			break;
			case 3: redirect(base_url('main/driver')); 
			break;
			case 4: redirect(base_url('main/employee')); 
			break;
		}
	}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////SEKTOR ZAMESTNANCI/////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////


public function updateProfile() {
		$this->load->model('model_employee');
		$employeeInfo = $this->model_employee->getGeneralEmployeeInfo($this->session->userdata('id_zamestnanca'));
		$data['employee'] = $employeeInfo;	
		
		if ($employeeInfo->ID_TYP_Z==1){
			$this->load->view('include/header');
			$this->load->view('manager/manager_profile_edit', $data);
			$this->load->view('include/footer');	
		} elseif ($employeeInfo->ID_TYP_Z==2){
			$this->load->view('include/header');
			$this->load->view('lead_employee/lead_employee_profile_edit', $data);
			$this->load->view('include/footer');	
		} elseif ($employeeInfo->ID_TYP_Z==3) {
			$this->load->view('include/header');
			$this->load->view('driver/driver_profile_edit', $data);
			$this->load->view('include/footer');	
		} elseif ($employeeInfo->ID_TYP_Z==4) {
			$this->load->view('include/header');
			$this->load->view('employee/employee_profile_edit', $data);
			$this->load->view('include/footer');	
		}
}

public function finallyUpdateProfile() {
			$this->load->helper(array('form', 'url'));
			$this->load->library('form_validation');
			$this->form_validation->set_rules('Kod_banky', 'Kód banky', 'numeric');
			$this->form_validation->set_rules('Cislo_uctu', 'Číslo účtu', 'numeric');


			if ($this->form_validation->run()==FALSE) {

					$this->load->model('model_employee');
					$employeeInfo = $this->model_employee->getGeneralEmployeeInfo($this->session->userdata('email'));
					$data['employee'] = $employeeInfo;
					
					if ($employeeInfo->ID_TYP_Z==1){
										$this->load->view('include/header');
										$this->load->view('manager/manager_profile_edit', $data);
										$this->load->view('include/footer');	
									} elseif ($employeeInfo->ID_TYP_Z==2){
										$this->load->view('include/header');
										$this->load->view('lead_employee/lead_employee_profile_edit', $data);
										$this->load->view('include/footer');	
									} elseif ($employeeInfo->ID_TYP_Z==3) {
										$this->load->view('include/header');
										$this->load->view('driver/driver_profile_edit', $data);
										$this->load->view('include/footer');	
									} elseif ($employeeInfo->ID_TYP_Z==4) {
										$this->load->view('include/header');
										$this->load->view('employee/employee_profile_edit', $data);
										$this->load->view('include/footer');	
					}
				
			}else{ 
													
						if ($this->input->post('input_form_submit')==FALSE) {
							redirect(base_url() . 'main/restricted');	
						} else {
							$this->load->model('model_employee');
							$this->model_employee->finallyUpdateProfile(
										$this->session->userdata['id_zamestnanca'],
										$this->input->post('Ulica_zamestnanca'),
										$this->input->post('Cislo_domu_zamestnanca'),
										$this->input->post('PSC_zamestnanca'),
										$this->input->post('Mesto_zamestnanca'),
										$this->input->post('Tel_cislo_zamestnanca'),
										$this->input->post('Cislo_uctu'),
										$this->input->post('Kod_banky'),
										$this->input->post('Nazov_poistovne')					
					);					
					$this->load->model('model_employee');
					$employeeInfo = $this->model_employee->getGeneralEmployeeInfo($this->session->userdata('id_zamestnanca'));
					$data['employee'] = $employeeInfo;	
					
					if ($employeeInfo->ID_TYP_Z==1){
										$this->load->view('include/header');
										$this->load->view('manager/manager_profile', $data);
										$this->load->view('include/footer');	
									} elseif ($employeeInfo->ID_TYP_Z==2){
										$this->load->view('include/header');
										$this->load->view('lead_employee/lead_employee_profile', $data);
										$this->load->view('include/footer');	
									} elseif ($employeeInfo->ID_TYP_Z==3) {
										$this->load->view('include/header');
										$this->load->view('driver/driver_profile', $data);
										$this->load->view('include/footer');	
									} elseif ($employeeInfo->ID_TYP_Z==4) {
										$this->load->view('include/header');
										$this->load->view('employee/employee_profile', $data);
										$this->load->view('include/footer');	
					}
			}


	}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//CHANGE PASSWORD

	public function changePassword(){		
		$this->load->view('change_email_password');
	}
	
	public function setPassword() {		
			$this->load->helper(array('form', 'url'));
			$this->load->library('form_validation');
			$this->form_validation->set_rules('email_change', 'Email', 'trim|valid_email|callback_validate_email2');
			$this->form_validation->set_rules('oldpassword_change', 'Staré heslo', 'trim|required|md5');
			$this->form_validation->set_rules('password_change', 'Heslo', 'trim|required|matches[password2_change]|min_length[6]|max_length[20]|md5');
			$this->form_validation->set_rules('password2_change', 'Potvrdenie hesla', 'trim|required|md5');									
			
			if ($this->form_validation->run()==FALSE){
				$this->load->view('change_email_password');
			} else {
				$this->load->model('model_employee');
				$this->model_employee->setPassword($this->input->post('password_change'),$this->input->post('email_change'));
				
				$this->load->model('model_employee');
				$employeeInfo = $this->model_employee->getGeneralEmployeeInfo($this->session->userdata('id_zamestnanca'));
				$data['employee'] = $employeeInfo;
					
				if ($employeeInfo->ID_TYP_Z==1){
										$this->load->view('include/header');
										$this->load->view('manager/manager_profile', $data);
										$this->load->view('include/footer');	
									} elseif ($employeeInfo->ID_TYP_Z==2){
										$this->load->view('include/header');
										$this->load->view('lead_employee/lead_employee_profile', $data);
										$this->load->view('include/footer');	
									} elseif ($employeeInfo->ID_TYP_Z==3) {
										$this->load->view('include/header');
										$this->load->view('driver/driver_profile', $data);
										$this->load->view('include/footer');	
									} elseif ($employeeInfo->ID_TYP_Z==4) {
										$this->load->view('include/header');
										$this->load->view('employee/employee_profile', $data);
										$this->load->view('include/footer');	
					}				
				}
			}
		
		
	public function validate_email2() {
			$this->load->model('model_employee');		
		if (($this->model_employee->existEmailPassword($this->input->post('email_change'),md5($this->input->post('oldpassword_change'))))AND (($this->input->post('email_change'))==($this->session->userdata['email']))) {	
			return true;
		} else {
			$this->form_validation->set_message('validate_email2', 'Neplatný email alebo heslo.');
			return false;		
		}
	
	
	
	
	
	
	/*	$CI =& get_instance();
		$CI->load->model('model_employee');
		$result = $CI->model_employee->existEmail($this->input->post('email'));
		if ($result==TRUE){
			return true ;
		} else {
			return false;
			$this->form_validation->set_message('validate_email', '<p style="color:red">Nesprávne meno alebo heslo!</p>');
		}*/
	}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// ZAMESTNANEC////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	public function getGeneralEmployeeInfo() {
		$this->load->model('model_employee');
		$employeeInfo = $this->model_employee->getGeneralEmployeeInfo($this->session->userdata('id_zamestnanca'));
		$data['employee'] = $employeeInfo;				
			if ($employeeInfo->ID_TYP_Z==1){
				$this->load->view('include/header');
				$this->load->view('manager/manager_profile', $data);
				$this->load->view('include/footer');	
			} elseif ($employeeInfo->ID_TYP_Z==2){
				$this->load->view('include/header');
				$this->load->view('lead_employee/lead_employee_profile', $data);
				$this->load->view('include/footer');	
			} elseif ($employeeInfo->ID_TYP_Z==3) {
				$this->load->view('include/header');
				$this->load->view('driver/driver_profile', $data);
				$this->load->view('include/footer');	
			} elseif ($employeeInfo->ID_TYP_Z==4) {
				$this->load->view('include/header');
				$this->load->view('employee/employee_profile', $data);
				$this->load->view('include/footer');	
			}		
		}
	

	
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// VEDUCI INVENTURY //////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	
	

	
////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
///////////////////////////////////// MANAGER //////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////	


	

	
	
	/*public function m_detailInventory($id_inv){
		$this->load->model('model_inventory');
		$detailOfInventory = $this->model_inventory->DetailOfInventory($id_inv);
		
		$data['detailOfInventory'] = $detailOfInventory;
		$this->load->view('include/header');
		$this->load->view('manager/manager_inventory_detail', $data);
		$this->load->view('include/footer');			
	}*/

	/*public function createCustomer(){
		$this->load->view('include/header');
		$this->load->view('manager/manager_customer_create');
		$this->load->view('include/footer');
	}*/
	
	/*public function m_createInventory(){
		$this->load->library('Pagination');
		$this->load->model('model_manager');
		$total_rows = $this->model_manager->getCountCustomers();
		$configuration = array();
		
		$configuration['base_url'] = base_url() . 'main/m_createInventory';
		$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 detailCustomer($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_inventory_create_2', $data);
		$this->load->view('include/footer');	
	}*/
		
//presunute do manager	
	/*public function finallyCreateCustomer(){
		$this->load->helper(array('form', 'url'));
		$this->load->library('form_validation');
		
		$this->form_validation->set_rules('newNazovSpolocnosti', 'Názov spoločnosti', 'required');
		$this->form_validation->set_rules('newMestoSpolocnosti', 'Názov spoločnosti', 'required');
		$this->form_validation->set_rules('newUlicaSpolocnosti', 'Názov spoločnosti', 'required');
		$this->form_validation->set_rules('newCisloSpolocnosti', 'Názov spoločnosti', 'required');	
		$this->form_validation->set_rules('newPSCSpolocnosti', 'Názov spoločnosti', 'required|min_length[5]|max_length[5]');
		
		
				
		if ($this->form_validation->run()==FALSE){
			$this->load->view('include/header');
			$this->load->view('manager/manager_customer_create');
			$this->load->view('include/footer');	
		} else {
			$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;
			$data = json_decode(file_get_contents($mapLink));
		    if ($data=='ZERO_RESULTS'){
				$coordinates=null;
			} else {
				$coordinates = $data->results[0]->geometry->location->lat . ',' . $data->results[0]->geometry->location->lng;					
			}			
			$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	
												);
			$data2['Customer'] = $this->model_manager->getNewCustomerInfo($this->input->post('newNazovSpolocnosti'),
												 $this->input->post('newDruhSpolocnosti'),	
												 $this->input->post('newMestoSpolocnosti'),	
												 $this->input->post('newUlicaSpolocnosti'),	
												 $this->input->post('newCisloSpolocnosti'),
												 $this->input->post('newPSCSpolocnosti')	
												);	
			$this->load->view('include/header');
			$this->load->view('manager/manager_inventory_create_2', $data2);
			$this->load->view('include/footer');
		}	
	}*/
	
	/*public function finallyCreateInventory($id_cus){
		$this->load->helper(array('form', 'url'));
		$this->load->library('form_validation');		
															
		$this->form_validation->set_rules('newRozlohaSpolocnosti', 'Dátum a čas začiatku', 'callback_choosen_rozloha');
		$this->form_validation->set_rules('newVzdialenostSpolocnosti', 'Dátum a čas začiatku', 'required');
		$this->form_validation->set_rules('newHodinyCesty', 'Dátum a čas začiatku', 'callback_choosen_cas_cesty_hodiny');
		$this->form_validation->set_rules('newMinutyCesty', 'Dátum a čas začiatku', 'callback_choosen_cas_cesty_minuty');
		$this->form_validation->set_rules('newDatumZaciatku', 'Dátum a čas začiatku', 'callback_choosen_datum_zaciatku|callback_is_start_higher_than_today');
		$this->form_validation->set_rules('newHodinyZaciatku', 'Dátum a čas začiatku', 'callback_choosen_hodiny_zaciatku');
		$this->form_validation->set_rules('newMinutyZaciatku', 'Dátum a čas začiatku', 'callback_choosen_minuty_zaciatku');
		$this->form_validation->set_rules('newDatumKonca', 'Dátum a čas začiatku', 'callback_choosen_datum_konca|callback_is_end_higher_than_start');
		$this->form_validation->set_rules('newHodinyKonca', 'Dátum a čas začiatku', 'callback_choosen_hodiny_konca');
		$this->form_validation->set_rules('newMinutyKonca', 'Dátum a čas začiatku', 'callback_choosen_minuty_konca');
		$this->form_validation->set_rules('newDatumPrihlasovania', 'Dátum a čas začiatku', 'callback_choosen_datum_prihlasovania|callback_is_start_higher_than_login');
		$this->form_validation->set_rules('newHodinyPrihlasovania', 'Dátum a čas začiatku', 'callback_choosen_hodiny_prihlasovania');
		$this->form_validation->set_rules('newMinutyPrihlasovania', 'Dátum a čas začiatku', 'callback_choosen_minuty_prihlasovania');
				
		if ($this->form_validation->run()==FALSE){
			$this->load->model('model_manager');
			$data['Customer'] = $this->model_manager->getCustomerInfo($id_cus);
			$this->load->view('include/header');
			$this->load->view('manager/manager_inventory_create_2', $data);
			$this->load->view('include/footer');	
		} else {
			$this->load->model('model_manager');
			$this->model_manager->CreateInventory($id_cus,
												  $this->input->post('newRozlohaSpolocnosti'),
											   	  $this->input->post('newVzdialenostSpolocnosti'),	
												  $this->input->post('newDatumZaciatku').' '.$this->input->post('newHodinyZaciatku').':'.$this->input->post('newMinutyZaciatku').':00',	
												  $this->input->post('newDatumKonca').' '.$this->input->post('newHodinyKonca').':'.$this->input->post('newMinutyKonca').':00',	
												  $this->input->post('newDatumPrihlasovania').' '.$this->input->post('newHodinyPrihlasovania').':'.$this->input->post('newMinutyPrihlasovania').':00',
												  $this->input->post('newHodinyCesty').':'.$this->input->post('newMinutyCesty').':00'												 	
												);
			$data['NewInventory'] = $this->model_manager->getInventoryInfo($id_cus,$this->input->post('newRozlohaSpolocnosti'),$this->input->post('newDatumZaciatku').' '.$this->input->post('newHodinyZaciatku').':'.$this->input->post('newMinutyZaciatku').':00',$this->input->post('newDatumKonca').' '.$this->input->post('newHodinyKonca').':'.$this->input->post('newMinutyKonca').':00',$this->input->post('newDatumPrihlasovania').' '.$this->input->post('newHodinyPrihlasovania').':'.$this->input->post('newMinutyPrihlasovania').':00');
			
			$this->load->view('include/header');
			$this->load->view('manager/manager_inventory_create_3', $data);
			$this->load->view('include/footer');
		}
		
		}*/
		
		/*public function is_start_higher_than_today(){
			$dt = new DateTime();
			if ((strtotime($this->input->post('newDatumZaciatku').' '.$this->input->post('newHodinyZaciatku').':'.$this->input->post('newMinutyZaciatku').':00'))>(strtotime($dt->format('Y-m-d H:i:s')))){
			return true;
		} else {
			$this->form_validation->set_message('is_start_higher_than_today', 'Dátum začiatku inventúry musí byť väčší ako dnešný dátum.');
			return false;
		}
		}
		
		public function is_end_higher_than_start(){
			if ((strtotime($this->input->post('newDatumZaciatku').' '.$this->input->post('newHodinyZaciatku').':'.$this->input->post('newMinutyZaciatku').':00'))<(strtotime($this->input->post('newDatumKonca').' '.$this->input->post('newHodinyKonca').':'.$this->input->post('newMinutyKonca').':00'))){
			return true;
		} else {
			$this->form_validation->set_message('is_end_higher_than_start', 'Dátum ukončenia inventúry musí byť väčší ako dátum začiatku inventúry.');
			return false;
		}	
		}
		
		public function is_start_higher_than_login(){
			if ((strtotime($this->input->post('newDatumPrihlasovania').' '.$this->input->post('newHodinyPrihlasovania').':'.$this->input->post('newMinutyPrihlasovania').':00'))<(strtotime($this->input->post('newDatumZaciatku').' '.$this->input->post('newHodinyZaciatku').':'.$this->input->post('newMinutyZaciatku').':00'))){
			return true;
		} else {
			$this->form_validation->set_message('is_start_higher_than_login', 'Dátum ukončenia prihlasovania musí byť menší ako dátum začiatku inventúry.');
			return false;
		}	
		}
		
		public function choosen_rozloha(){
			if ($this->input->post('newRozlohaSpolocnosti')==99){
				$this->form_validation->set_message('choosen_rozloha', 'Nevybrali ste rozlohu.');
				return false;	
			} else {
				return true;
			}
		}
		
		public function choosen_cas_cesty_hodiny(){
			if ($this->input->post('newHodinyCesty')==99){
				$this->form_validation->set_message('choosen_cas_cesty_hodiny', 'Zvoľte prosím hodiny v čase cesty.');
				return false;	
			} else {
				return true;
			}
		}
		
		public function choosen_cas_cesty_minuty(){
			if ($this->input->post('newHodinyCesty')==99){
				$this->form_validation->set_message('choosen_cas_cesty_minuty', 'Zvoľte prosím minúty v čase cesty.');
				return false;	
			} else {
				return true;
			}
		}
		
		public function choosen_datum_zaciatku(){
			if ($this->input->post('newDatumZaciatku')=="Dátum"){
				$this->form_validation->set_message('choosen_datum_zaciatku', 'Zvoľte prosím dátum začiatku inventúry.');
				return false;	
			} else {
				return true;
			}
		}
		
		public function choosen_hodiny_zaciatku(){
			if ($this->input->post('newHodinyZaciatku')==99){
				$this->form_validation->set_message('choosen_hodiny_zaciatku', 'Zvoľte prosím hodiny začiatku inventúry.');
				return false;	
			} else {
				return true;
			}
		}
		
		public function choosen_minuty_zaciatku(){
			if ($this->input->post('newMinutyZaciatku')==99){
				$this->form_validation->set_message('choosen_minuty_zaciatku', 'Zvoľte prosím minúty začiatku inventúry.');
				return false;	
			} else {
				return true;
			}
		}
		
		public function choosen_datum_konca(){
			if ($this->input->post('newDatumKonca')=="Dátum"){
				$this->form_validation->set_message('choosen_datum_konca', 'Zvoľte prosím dátum ukončenia inventúry.');
				return false;	
			} else {
				return true;
			}
		}
		
		public function choosen_hodiny_konca(){
			if ($this->input->post('newHodinyKonca')==99){
				$this->form_validation->set_message('choosen_hodiny_konca', 'Zvoľte prosím hodiny ukončenia inventúry.');
				return false;	
			} else {
				return true;
			}
		}
		
		public function choosen_minuty_konca(){
			if ($this->input->post('newMinutyKonca')==99){
				$this->form_validation->set_message('choosen_minuty_konca', 'Zvoľte prosím minúty ukončenia inventúry.');
				return false;	
			} else {
				return true;
			}
		}
		
		public function choosen_datum_prihlasovania(){
			if ($this->input->post('newDatumPrihlasovania')=="Dátum"){
				$this->form_validation->set_message('choosen_datum_prihlasovania', 'Zvoľte prosím dátum  prihlasovania na inventúru.');
				return false;	
			} else {
				return true;
			}
		}
		
		public function choosen_hodiny_prihlasovania(){
			if ($this->input->post('newHodinyPrihlasovania')==99){
				$this->form_validation->set_message('choosen_hodiny_prihlasovania', 'Zvoľte prosím hodiny  prihlasovania na inventúru.');
				return false;	
			} else {
				return true;
			}
		}
		
		public function choosen_minuty_prihlasovania(){
			if ($this->input->post('newMinutyPrihlasovania')==99){
				$this->form_validation->set_message('choosen_minuty_prihlasovania', 'Zvoľte prosím minúty prihlasovania na inventúru.');
				return false;	
			} else {
				return true;
			}
		}*/
				
		/*public function createReservations($id_inv){			
			$this->load->model('model_vehicles');
			$pocetZamestnancov = 0;
			$chosenVehicles = $this->input->post('vehicle');
			$status=TRUE;
			foreach ($chosenVehicles as $choseVehicle){				
				$pocetZamestnancov = $pocetZamestnancov + $this->model_vehicles->getNumberOfSeats($choseVehicle) -1;
				$id_rep=$this->model_vehicles->createReservation($id_inv,$choseVehicle);
				if ($status==TRUE){
					$this->model_vehicles->createReservationForLeadEmployee($id_rep);
					$status=FALSE;
				}	
			}
			$pocetZamestnancov=$pocetZamestnancov-1;
			$this->model_vehicles->updateNumberOfEmployees($id_inv,$pocetZamestnancov);
			redirect(base_url().'main/m_showInventories/1');
		}
	*/
////////////////////////////////////////////////////////////////////////////////////////////////////
//REDIRECTS
	


//ZAMESTNANCI			
		
	
		
	
	
	
	
	
	
		
	
	
	
	


/////////////////CUSTOMERS/////////////////////////////////////////////////////////////////////	
	
	


//MENU BAR ZAKAZNICI VSETKO POTREBNE!////////////////////////////////////////////////////////////	
	
	/*public function m_detailCustomer($id_cus){
		$this->load->model('model_manager');
		$data['Customer'] = $this->model_manager->getCustomerDetail($id_cus);
		
		$this->load->library('googlemaps');
		$config = array();
		$config['center'] = $data['Customer']->GPS;
		
		$marker = array();
		$marker['position'] = $data['Customer']->GPS;
		
		$this->googlemaps->add_marker($marker);
		$this->googlemaps->initialize($config);
		$data['map'] = $this->googlemaps->create_map();
	
		$this->load->view('include/header2', $data);
		$this->load->view('manager/manager_customer_detail', $data);
		$this->load->view('include/footer');	
	}*/
	
	

////////////REZERVACIE////////////////////////////////////////////////////////////////////////

	
	
	
	
	
	
		
		
		
					

		
		
			
	}		
		
	
	
	
		
		
	
		
		



	


