<?php
		if ($this->session->userdata('permisson')==3) {
		$CI =& get_instance();
		$CI->load->library('libraryprofile');
		$CI->libraryprofile->showMenuBarDriver($this->session->userdata('meno'),$this->session->userdata('priezvisko'),$this->session->userdata('id_zamestnanca'));
		
		$this->load->helper('driver_helper');
		
		echo '<div id="default_container">';
			echo '<div class="button-group" style="margin-left:50px;margin-top:10px;">';
			switch($modeType){
				case 1:
					echo '<a href="'.base_url('driver/showAllInventories/1/'.$mode).'" class="button active">Vodič</a>'; 
					echo '<a href="'.base_url('driver/showAllInventories/2/'.$mode).'" class="button">Zamestnanec</a>'; 
				break;
				case 2:
					echo '<a href="'.base_url('driver/showAllInventories/1/'.$mode).'" class="button">Vodič</a>'; 
					echo '<a href="'.base_url('driver/showAllInventories/2/'.$mode).'" class="button  active">Zamestnanec</a>'; 
				break;
			}			
			echo '</div>';
			
			echo '<div class="button-group" style="margin-left:50px;margin-top:10px;">';			
			switch($mode){
				case 1:
					echo '<a href="'.base_url('driver/showAllInventories/'.$modeType).'/1" class="button active">Ohlásené inventúry</a>'; 
					echo '<a href="'.base_url('driver/showAllInventories/'.$modeType).'/2" class="button">Voľné inventúry</a>';
					echo '<a href="'.base_url('driver/showAllInventories/'.$modeType).'/3" class="button">Moje inventúry</a>';
					echo '<a href="'.base_url('driver/showAllInventories/'.$modeType).'/4" class="button">Archív inventúr</a>'; 
				break;
				case 2:
					echo '<a href="'.base_url('driver/showAllInventories/'.$modeType).'/1" class="button">Ohlásené inventúry</a>'; 
					echo '<a href="'.base_url('driver/showAllInventories/'.$modeType).'/2" class="button active">Voľné inventúry</a>';
					echo '<a href="'.base_url('driver/showAllInventories/'.$modeType).'/3" class="button">Moje inventúry</a>';
					echo '<a href="'.base_url('driver/showAllInventories/'.$modeType).'/4" class="button">Archív inventúr</a>';
				break;
				case 3: 
					echo '<a href="'.base_url('driver/showAllInventories/'.$modeType).'/1" class="button">Ohlásené inventúry</a>'; 
					echo '<a href="'.base_url('driver/showAllInventories/'.$modeType).'/2" class="button">Voľné inventúry</a>';
					echo '<a href="'.base_url('driver/showAllInventories/'.$modeType).'/3" class="button active">Moje inventúry</a>';
					echo '<a href="'.base_url('driver/showAllInventories/'.$modeType).'/4" class="button">Archív inventúr</a>';
				break;
				case 4:
					echo '<a href="'.base_url('driver/showAllInventories/'.$modeType).'/1" class="button">Ohlásené inventúry</a>'; 
					echo '<a href="'.base_url('driver/showAllInventories/'.$modeType).'/2" class="button">Voľné inventúry</a>';
					echo '<a href="'.base_url('driver/showAllInventories/'.$modeType).'/3" class="button">Moje inventúry</a>';
					echo '<a href="'.base_url('driver/showAllInventories/'.$modeType).'/4" class="button active">Archív inventúr</a>'; 
				break;
			}			
			echo '</div>';
			echo "<div class='vehicle_div' style='align:center; margin-top:15px;'>";
			echo "</div>";
			
			switch($modeType){
				case 1:
					switch($mode){
						case 1:
							if (count($inventories)==0){
								echo "<h3>V súčastnej dobe nie sú vypísané žiadne inventúry.</h3>";
							} else {
								foreach($inventories as $inventory){
									drawInventoryFalseDriver($modeType, $mode, $this->session->userdata['id_zamestnanca'],$inventory);													
								}	
							}												 
						break;
						case 2:
							$countTrueInventories=0;
							foreach($inventories as $inventory){								
								if ((isFreeReservation($inventory->ID_INV)==TRUE) AND
								(haveIFreeTimeInventory($this->session->userdata['id_zamestnanca'], $inventory->Datum_zaciatku,$inventory->Datum_konca)==TRUE) AND
								(haveIFreeTimeReservation($this->session->userdata['id_zamestnanca'], $inventory->Datum_zaciatku,$inventory->Datum_konca)==TRUE) AND
								(amILoggedAsEmployee($inventory->ID_INV, $this->session->userdata['id_zamestnanca'])==FALSE) AND
								(amILoggedAsDriver($inventory->ID_INV, $this->session->userdata['id_zamestnanca'])==FALSE)){
									drawInventoryTrueDriver($modeType, $mode, $this->session->userdata['id_zamestnanca'],$inventory);
									$countTrueInventories++;	
								}																			
							}
							if ($countTrueInventories==0){
								echo "<h3>V súčastnej pre vás nie je žiadna voľná inventúra, na ktorú sa môžete prihlásiť ako vodič.</h3>";
							} 
						break;
						case 3: 
							if (count($inventories)==0){
								echo "<h3>V súčastnej dobe nie ste prihlásený ako šofér na žiadnu inventúru.</h3>";		
							} else {
								foreach($inventories as $inventory){
									drawInventoryTrueLogOutDriver($modeType, $mode, $this->session->userdata['id_zamestnanca'],$inventory);
								} 	
							}
						break;
						case 4:
							if (count($inventories)==0){
								echo "<h3>Ešte ste ako vodič neabsolvovali žiadnu inventúru.</h3>";		
							} else {
								foreach($inventories as $inventory){
									drawInventoryTrueArchive($modeType, $mode, $this->session->userdata['id_zamestnanca'],$inventory);
								} 	
							} 
						break;
					} 
				break;
				case 2: 
					switch($mode){
						case 1:
							if (count($inventories)==0){
								echo "<h3>V súčastnej dobe nie sú vypísané žiadne inventúry.</h3>";
							} else {
								foreach($inventories as $inventory){
									drawInventoryFalseEmployee($modeType, $mode, $this->session->userdata['id_zamestnanca'],$inventory);													
								}	
							}									 
						break;
						case 2:  
							$countTrueInventories=0;
							foreach($inventories as $inventory){								
								if ((isFreeInventory($inventory->ID_INV,$inventory->Pocet_zamestnancov)==TRUE) AND
								(haveIFreeTimeInventory($this->session->userdata['id_zamestnanca'], $inventory->Datum_zaciatku,$inventory->Datum_konca)==TRUE) AND
								(haveIFreeTimeReservation($this->session->userdata['id_zamestnanca'], $inventory->Datum_zaciatku,$inventory->Datum_konca)==TRUE) AND
								(amILoggedAsEmployee($inventory->ID_INV, $this->session->userdata['id_zamestnanca'])==FALSE) AND
								(amILoggedAsDriver($inventory->ID_INV, $this->session->userdata['id_zamestnanca'])==FALSE)){
									drawInventoryTrueEmployee($modeType, $mode, $this->session->userdata['id_zamestnanca'],$inventory);
									$countTrueInventories++;	
								}																			
							}
							if ($countTrueInventories==0){
								echo "<h3>V súčastnej pre vás nie je žiadna voľná inventúra, na ktorú sa môžete prihlásiť ako zamestnanec.</h3>";
							}
						break;
						case 3:
							if (count($inventories)==0){
								echo "<h3>V súčastnej dobe nie ste prihlásený ako zamestnanec na žiadnu inventúru.</h3>";		
							} else {
								foreach($inventories as $inventory){
									drawInventoryTrueLogOutEmployee($modeType, $mode, $this->session->userdata['id_zamestnanca'],$inventory);
								} 	
							}						
						break;
						case 4:
							if (count($inventories)==0){
								echo "<h3>Ešte ste ako zamestnanec neabsolvovali žiadnu inventúru.</h3>";		
							} else {
								foreach($inventories as $inventory){
									drawInventoryTrueArchive($modeType, $mode, $this->session->userdata['id_zamestnanca'],$inventory);
								} 	
							} 
						break;
					}
				break;
			}		
		echo '</div>';		
	} else {
		redirect(base_url('main/restricted'));
	}	
?>

	
	
	


