 <?php
		if ($this->session->userdata('permisson')==4) {
		$CI =& get_instance();
		$CI->load->library('libraryprofile');
		$CI->libraryprofile->showMenuBarEmployee($this->session->userdata('meno'),$this->session->userdata('priezvisko'),$this->session->userdata('id_zamestnanca'));
		$this->load->helper('employee_helper');
		
		echo '<div id="default_container">';
			echo '<div class="button-group" style="margin-left:50px;margin-top:10px;">';
				switch ($mode){
					case 1:
						echo '<a href="'. base_url('employee/getInventories/1') .'" class="button active">Ohlásené inventúry</a>';		
						echo '<a href="'. base_url('employee/getInventories/2') .'" class="button">Voľné inventúry</a>';
						echo '<a href="'. base_url('employee/getInventories/3') .'" class="button">Moje inventúry</a>';
						echo '<a href="'. base_url('employee/getInventories/4') .'" class="button">Archív</a>';
						echo '</div>';
						
						echo "<div class='vehicle_div' style='align:center; margin-top:15px'></div>";						
						if ($inventories==FALSE){				
							echo "<h3>V súčastnej dobe nie sú ohlásené žiadne inventúry.</h3>";										
						} else {			 				
							foreach($inventories as $inventory){								
								$canILogIn=canILogin($this->session->userdata['id_zamestnanca'], $inventory->Datum_zaciatku, $inventory->Datum_konca);
								$freeSlots=hasFreeSlots($inventory->ID_INV);
								$amILoggedThere=amILoggedThere($inventory->ID_INV, $this->session->userdata['id_zamestnanca']);
									
									echo "<div class='vehicle_div' align='left'>";
										echo "<table class='vehicle_table' style='margin-left:-10px; padding-top:15px;margin-top:0px; margin-bottom:10px;'>";
											echo "<tr>";
												echo "<td width='50px' style='padding-left:25px;'>";
													if ($amILoggedThere==TRUE){
															echo "<img src='".base_url('pictures/red_diod.png')."' width='20px' height='20px'>";
														} elseif ($freeSlots==FALSE) {
															echo "<img src='".base_url('pictures/red_diod.png')."' width='20px' height='20px'>";
														} elseif ($canILogIn==FALSE)	{
															echo "<img src='".base_url('pictures/red_diod.png')."' width='20px' height='20px'>";
														} else {
															echo "<img src='".base_url('pictures/green_diod.png')."' width='20px' height='20px'>";	
														}
												echo "</td>";
										
												echo "<td width='160px' style='text-align: center'>";
													echo "<b>Zákazník</b>";
													echo "</br>";
													echo $inventory->Nazov_spolocnosti.", ".$inventory->Mesto;
												echo "</td>";
										
												echo "<td width='120px' style='text-align:center;'>";
													echo "<b>Voľných miest</b>";
													echo "</br>";
													echo numberOfFreeSlots($inventory->ID_INV);
												echo "</td>";
										
												echo "<td width='160px' style='text-align: center'>";
													echo "<b>Vedúci invenúry</b>";
													echo "</br>";
														if ($inventory->ID_Veduci==NULL){
															echo "-neurčené-";
														} else {
															echo $inventory->Priezvisko." ".$inventory->Meno;	
														}											
												echo "</td>";
										
												echo "<td width='150px' style='text-align: center'>";
													echo "<b>Prihlasovanie do</b>";
													echo "</br>";
													echo date ("d.m.Y G:i",strtotime($inventory->Datum_prihlasovania));												
												echo "</td>";
										
												echo "<td width='150px' style='text-align: center'>";
													echo "<b>Začiatok</b>";
													echo "</br>";
													echo date ("d.m.Y G:i",strtotime($inventory->Datum_zaciatku));																						
												echo "</td>";

												echo "<td width='150px' style='text-align: center'>";
													echo "<b>Koniec</b>";
													echo "</br>";
													echo date ("d.m.Y G:i",strtotime($inventory->Datum_konca));												
												echo "</td>";
												
												echo '<td style="font-style: italic; font-size:12px; padding-right:10px" >';
													echo '<div class="button-group" >';	
														if ($amILoggedThere==TRUE){
															echo "Na túto inventúru ste už prihlásený.";
														} elseif ($freeSlots==FALSE) {
															echo "Táto inventúra je už plná.";
														} elseif ($canILogIn==FALSE)	{
															echo "V túto dobu ste už prihlásený na inú inventúru.";
														} else {
															echo '<a href="'.base_url('employee/LogOnInventory2/'.$mode.'/'.$inventory->ID_INV).'" class="button">Prihlásiť</a>';								
														}																														
													echo '</div>';									 												
												echo '</td>';
											echo '</tr>';
										echo '</table>';
									echo '</div>';							
							}	
						}
						echo '</div>';
						break;
					case 2:
						echo '<a href="'. base_url('employee/getInventories/1') .'" class="button">Ohlásené inventúry</a>';		
						echo '<a href="'. base_url('employee/getInventories/2') .'" class="button active">Voľné inventúry</a>';
						echo '<a href="'. base_url('employee/getInventories/3') .'" class="button">Moje inventúry</a>';
						echo '<a href="'. base_url('employee/getInventories/4') .'" class="button">Archív</a>';
						echo '</div>';
						echo "<div class='vehicle_div' style='align:center; margin-top:15px'></div>";
						$count=0;						
							foreach($inventories as $inventory){
								if(showInventory($this->session->userdata['id_zamestnanca'], $inventory->ID_INV, $inventory->Datum_zaciatku, $inventory->Datum_konca)==TRUE){
									$count++;
									echo "<div class='vehicle_div' align='left'>";
										echo "<table class='vehicle_table' style='margin-left:-10px; padding-top:15px;margin-top:0px; margin-bottom:10px;'>";
											echo "<tr>";
												echo "<td width='50px' style='padding-left:25px;'>";
													echo "<img src='".base_url('pictures/green_diod.png')."' width='20px' height='20px'>";	
												echo "</td>";
												
												echo "<td width='160px' style='text-align: center'>";
													echo "<b>Zákazník</b>";
													echo "</br>";
													echo $inventory->Nazov_spolocnosti.", ".$inventory->Mesto;
												echo "</td>";
												
												echo "<td width='120px' style='text-align: center'>";
													echo "<b>Voľných miest</b>";
													echo "</br>";
													echo numberOfFreeSlots($inventory->ID_INV);
												echo "</td>";
												
												echo "<td width='160px' style='text-align: center'>";
													echo "<b>Vedúci invenúry</b>";
													echo "</br>";
														if ($inventory->ID_Veduci==NULL){
															echo "-neurčené-";
														} else {
															echo $inventory->Priezvisko." ".$inventory->Meno;	
														}											
												echo "</td>";
												
												echo "<td width='150px' style='text-align: center'>";
													echo "<b>Prihlasovanie do</b>";
													echo "</br>";
													echo date ("d.m.Y G:i",strtotime($inventory->Datum_prihlasovania));												
												echo "</td>";
												
												echo "<td width='150px' style='text-align: center'>";
													echo "<b>Začiatok</b>";
													echo "</br>";
													echo date ("d.m.Y G:i",strtotime($inventory->Datum_zaciatku));																						
												echo "</td>";
		
												echo "<td width='150px' style='text-align: center'>";
													echo "<b>Koniec</b>";
													echo "</br>";
													echo date ("d.m.Y G:i",strtotime($inventory->Datum_konca));												
												echo "</td>";
											
												echo '<td>';
													echo '<div class="button-group" >';													
														echo '<a href="'.base_url('employee/LogOnInventory2/'.$mode.'/'.$inventory->ID_INV).'" class="button">Prihlásiť</a>';								
													echo '</div>';																					
												echo '</td>';
											echo '</tr>';
										echo '</table>';
									echo '</div>';							
									}													
								}	
						if ($count==0){							
							echo "<h3>V súčastnej dobe nie sú pre vás dostupné žiadne voľné inventúry.</h3>";																
						}
						
					break;
					case 3:
						echo '<a href="'. base_url('employee/getInventories/1') .'" class="button">Ohlásené inventúry</a>';		
						echo '<a href="'. base_url('employee/getInventories/2') .'" class="button">Voľné inventúry</a>';
						echo '<a href="'. base_url('employee/getInventories/3') .'" class="button active">Moje inventúry</a>';
						echo '<a href="'. base_url('employee/getInventories/4') .'" class="button">Archív</a>';
						echo '</div>';
						echo "<div class='vehicle_div' style='align:center; margin-top:15px'></div>";
						
						if ($inventories==FALSE){							
							echo "<h3>V súčastnej dobe nie ste prihlásený na žiadnu inventúru.</h3>";																
						} else {
							foreach($inventories as $inventory){
								$canILogIn=canILogin($this->session->userdata['id_zamestnanca'], $inventory->Datum_zaciatku, $inventory->Datum_konca);
								echo "<div class='vehicle_div' align='left'>";
									echo "<table class='vehicle_table' style='margin-left:-10px; padding-top:15px;margin-top:0px; margin-bottom:10px;'>";
										echo "<tr>";
											echo "<td width='50px' style='padding-left:25px;'>";
												
											echo "</td>";
											
											echo "<td width='160px' style='text-align: center'>";
												echo "<b>Zákazník</b>";
												echo "</br>";
												echo $inventory->Nazov_spolocnosti.", ".$inventory->Mesto;
											echo "</td>";
											
											echo "<td width='120px' style='text-align: center'>";
												echo "<b>Voľných miest</b>";
												echo "</br>";
												echo numberOfFreeSlots($inventory->ID_INV);
											echo "</td>";
											
											echo "<td width='160px' style='text-align: center'>";
												echo "<b>Vedúci invenúry</b>";
												echo "</br>";
													if ($inventory->ID_Veduci==NULL){
														echo "-neurčené-";
													} else {
														echo $inventory->Priezvisko." ".$inventory->Meno;	
													}											
											echo "</td>";
											
											echo "<td width='150px' style='text-align: center'>";
												echo "<b>Prihlasovanie do</b>";
												echo "</br>";
												echo date ("d.m.Y G:i",strtotime($inventory->Datum_prihlasovania));												
											echo "</td>";
											
											echo "<td width='150px' style='text-align: center'>";
												echo "<b>Začiatok</b>";
												echo "</br>";
												echo date ("d.m.Y G:i",strtotime($inventory->Datum_zaciatku));																						
											echo "</td>";
	
											echo "<td width='150px' style='text-align: center'>";
												echo "<b>Koniec</b>";
												echo "</br>";
												echo date ("d.m.Y G:i",strtotime($inventory->Datum_konca));												
											echo "</td>";
										
											echo '<td>';
												echo '<div class="button-group" >';													
													echo '<a href="'.base_url('employee/LogOutInventory/'.$inventory->ID_INV).'" class="button">Odhlásiť</a>';
													echo '<a href="'.base_url('employee/DetailOfInventory/3/1/'.$inventory->ID_INV).'" class="button">Detail</a>';																																				
												echo '</div>';																					
											echo '</td>';
											
										echo '</tr>';
									echo '</table>';
								echo '</div>';							
								}	
							}
						echo '</div>';
					break;
					case 4:
						echo '<a href="'. base_url('employee/getInventories/1') .'" class="button">Ohlásené inventúry</a>';		
						echo '<a href="'. base_url('employee/getInventories/2') .'" class="button">Voľné inventúry</a>';
						echo '<a href="'. base_url('employee/getInventories/3') .'" class="button">Moje inventúry</a>';
						echo '<a href="'. base_url('employee/getInventories/4') .'" class="button active">Archív</a>';
						echo '</div>';
						echo "<div class='vehicle_div' style='align:center; margin-top:15px'></div>";
						
						if ($inventories==FALSE){													
							echo "<h3>Ešte ste neabsolvovali žiadnu inventúru.</h3>";									
						} else {
							foreach($inventories as $inventory){
								$canILogIn=canILogin($this->session->userdata['id_zamestnanca'], $inventory->Datum_zaciatku, $inventory->Datum_konca);
									echo "<div class='vehicle_div' align='left'>";
										echo "<table class='vehicle_table' style='margin-left:-10px; padding-top:15px;margin-top:0px; margin-bottom:10px;'>";
											echo "<tr>";
												echo "<td width='50px' style='padding-left:25px;'>";
													
												echo "</td>";
										
												echo "<td width='160px' style='text-align: center'>";
													echo "<b>Zákazník</b>";
													echo "</br>";
													echo $inventory->Nazov_spolocnosti.", ".$inventory->Mesto;
												echo "</td>";
										
												echo "<td width='120px' style='text-align: center'>";
													
												echo "</td>";
										
												echo "<td width='160px' style='text-align: center'>";
													echo "<b>Vedúci invenúry</b>";
													echo "</br>";
														if ($inventory->ID_Veduci==NULL){
															echo "-neurčené-";
														} else {
															echo $inventory->Priezvisko." ".$inventory->Meno;	
														}											
												echo "</td>";
										
												echo "<td width='150px' style='text-align: center'>";
													echo "<b>Prihlasovanie do</b>";
													echo "</br>";
													echo date ("d.m.Y G:i",strtotime($inventory->Datum_prihlasovania));												
												echo "</td>";
										
												echo "<td width='150px' style='text-align: center'>";
													echo "<b>Začiatok</b>";
													echo "</br>";
													echo date ("d.m.Y G:i",strtotime($inventory->Datum_zaciatku));																						
												echo "</td>";

												echo "<td width='150px' style='text-align: center'>";
													echo "<b>Koniec</b>";
													echo "</br>";
													echo date ("d.m.Y G:i",strtotime($inventory->Datum_konca));												
												echo "</td>";
									
												echo '<td>';
													echo '<div class="button-group" >';												
														echo '<a href="'.base_url('employee/DetailOfInventory/4/1/'.$inventory->ID_INV).'" class="button">Detail</a>';												 													
													echo '</div>';																					
												echo '</td>';
											echo '</tr>';
										echo '</table>';
									echo '</div>';							
									}	
								}
							echo '</div>';	
					break;	
				}
									
			
				
			
	
		

		
		
			

	


		

	


	






		
	} else {
		redirect(base_url('main/restricted'));
	}	
	
?>