<?php
	if ($this->session->userdata('permisson')==1) {		
		$CI =& get_instance();
		$CI->load->library('libraryprofile');		
		$CI->libraryprofile->showMenuBarManager($this->session->userdata('meno'),$this->session->userdata('priezvisko')); 			 					
		echo '<div id="default_container">';
			echo '<div class="button-group" style="margin-left:50px;margin-top:10px;">';
				switch ($modeDet){
					case 1: 
						echo '<a href="'. base_url() . 'manager/showDetailVehicleActive/'.$active.'/1/'.$id_voz.'/'.$dateRes.'" class="button active">Všeobecné informácie</a>';
						echo '<a href="'. base_url() . 'manager/showDetailVehicleActive/'.$active.'/2/'.$id_voz.'/'.$dateRes.'" class="button">Aktívne inventúry vozidla</a>';
						echo '<a href="'. base_url() . 'manager/showDetailVehicleActive/'.$active.'/3/'.$id_voz.'/'.$dateRes.'" class="button">Archív inventúr vozidla</a>';						
						echo "</div>";
						echo "<div class='vehicle_div' style='align:center; margin-top:15px; margin-bottom:5px'></div>";
						if ($vehicle->Pocet_miest==5){	
					if($vehicle->Nazov=="Toyota Avensis"){
						echo "<div style='position:absolute; margin-left:370px; margin-top:0px'>";
						echo "<img src='".base_url('pictures/avensis.png')."' height='238px'>";	
					}elseif ($vehicle->Nazov=="Toyota Auris"){
						echo "<div style='position:absolute; margin-left:370px; margin-top:-30px'>";
						echo "<img src='".base_url('pictures/auris.png')."' height='300px'>";		
					}else{
						echo "<div style='position:absolute; margin-left:370px; margin-top:105px'>";
						echo "<img src='".base_url('pictures/sedan_sivy.png')."' height='100px'>";	
					}																	
					
				} elseif ($vehicle->Pocet_miest==7){
					if($vehicle->Nazov=="Toyota Prius"){
						echo "<div style='position:absolute; margin-left:370px; margin-top:-85px'>";
						echo "<img src='".base_url('pictures/prius.png')."' height='380px'>";	
					}else{
						echo "<div style='position:absolute; margin-left:370px; margin-top:105px'>";
						echo "<img src='".base_url('pictures/combi_sivy.png')."' height='100px'>";	
					}										
				} elseif ($vehicle->Pocet_miest==9){
					if($vehicle->Nazov=="Opel Vivaro"){
						echo "<div style='position:absolute; margin-left:370px; margin-top:-65px'>";
						echo "<img src='".base_url('pictures/vivaro.png')."' height='350px'>";	
					}else{
						echo "<div style='position:absolute; margin-left:370px; margin-top:105px'>";
						echo "<img src='".base_url('pictures/van_sivy.png')."' height='100px'>";	
					}																	
				} else {
					echo "<div style='position:absolute; margin-left:370px; margin-top:105px'>";									
					echo "<img src='".base_url('pictures/bus_sivy.png')."' height='100px'>";
				}
			echo "</div>";
				echo '<table id="newCustomerInfoTable" style="margin-left:50px; margin-top:10px">';
					echo "<tr>";
						echo "<td style='width:160px'>";
							echo "&nbsp"; 
						echo "</td>";													
					echo "</tr>";
					
					echo "<tr>";
						echo "<td  style='width:160px'>";
							echo "<b>ID vozidla: </b>";
						echo "</td>";
						echo "<td>";										
							if (strlen($vehicle->ID_VOZ)==1) {
								echo "0000";
								echo $vehicle->ID_VOZ;
							} elseif (strlen($vehicle->ID_VOZ)==2) {
								echo "000";
								echo $vehicle->ID_VOZ;
							} elseif (strlen($vehicle->ID_VOZ)==3) {
								echo "00";
								echo $vehicle->ID_VOZ;
							} elseif (strlen($vehicle->ID_VOZ)==4) {
								echo "0";
								echo $vehicle->ID_VOZ;
							} else {
								echo $vehicle->ID_VOZ;
							}
						echo "</td>";																														
					echo "</tr>";
					echo "<tr>";
						echo "<td  style='width:160px'>";
							echo "<b>Názov vozidla: </b>";
						echo "</td>";
						echo "<td>";																	
							echo $vehicle->Nazov;							
						echo "</td>";																														
					echo "</tr>";
					echo "<tr>";
						echo "<td  style='width:160px'>";
							echo "<b>ŠPZ vozidla: </b>";
						echo "</td>";
						echo "<td>";																	
							echo $vehicle->SPZ;							
						echo "</td>";																														
					echo "</tr>";
					echo "<tr>";
						echo "<td style='width:160px'>";
							echo "&nbsp"; 
						echo "</td>";													
					echo "</tr>";
					echo "<tr>";
						echo "<td  style='width:160px'>";
							echo "<b>Počet miest: </b>";
						echo "</td>";
						echo "<td>";																	
							echo $vehicle->Pocet_miest;							
						echo "</td>";																														
					echo "</tr>";
					echo "<tr>";
						echo "<td  style='width:160px'>";
							echo "<b>Typ vozidla: </b>";
						echo "</td>";
						echo "<td>";																	
							switch($vehicle->Typ_vozidla){
								case 1: echo "Sedan"; break;
								case 2: echo "Combi"; break;
								case 3: echo "Van"; break;
								case 4: echo "Autobus"; break;
							}							
						echo "</td>";																														
					echo "</tr>";
					echo "<tr>";
						echo "<td style='width:160px'>";
							echo "&nbsp"; 
						echo "</td>";													
					echo "</tr>";
					echo "<tr>";
						echo "<td  style='width:160px'>";
							echo "<b>Status vozidla: </b>";
						echo "</td>";
						
						echo "<td>";																	
							switch($vehicle->Status_vozidla){
								case 1: echo "Aktívne"; break;
								case 0: echo "Neaktívne"; break;
							}							
						echo "</td>";																														
					echo "</tr>";
					echo "<tr>";
						echo "<td style='width:160px'>";
							echo "&nbsp"; 
						echo "</td>";													
					echo "</tr>";
				echo "</table>";
			echo "<div class='vehicle_div' style='align:center; margin-top:15px; margin-bottom:0px'></div>";
			echo '<div class="button-group" style="margin-left:50px;margin-top:15px;">';	 			
							switch ($active){
								case 1:									
									echo '<a href="'. base_url('manager/showVehicles/1').'" class="button"  >Späť</a>'; 
								break;
								case 2: 
									echo '<a href="'. base_url('manager/showVehicles/2').'" class="button"  >Späť</a>';
								break;
								case 3: 
									echo '<a href="'. base_url('manager/showVehicles/3').'" class="button"  >Späť</a>';	
								break;
								case 4:
									echo '<a href="'. base_url('manager/getReservations/'.$dateRes).'" class="button"  >Späť</a>';	 
								break;
							}	
						echo '</div>';
					echo "</div>";			
					break;						
					case 2: 
						echo '<a href="'. base_url() . 'manager/showDetailVehicleActive/'.$active.'/1/'.$id_voz.'/'.$dateRes.'" class="button">Všeobecné informácie</a>';
						echo '<a href="'. base_url() . 'manager/showDetailVehicleActive/'.$active.'/2/'.$id_voz.'/'.$dateRes.'" class="button active">Aktívne inventúry vozidla</a>';
						echo '<a href="'. base_url() . 'manager/showDetailVehicleActive/'.$active.'/3/'.$id_voz.'/'.$dateRes.'" class="button">Archív inventúr vozidla</a>';	
						echo "</div>";
						echo "<div class='vehicle_div' style='align:center; margin-top:15px; margin-bottom:5px'></div>";
						if(count($inventories)==0 OR $inventories==Array()){
							echo "<h3 style='margin-bottom:30px;padding-bottom:30px'>Vozidlo nie je aktuálne prihlásené na žiadnu inventúru.</h3>";
						}else{
							echo "<table style='width:100%;margin-rignt:0px'>";
							echo "<thead style='text-align:left'>";
								echo "<th>";
								echo "</td>";
								echo "<th>";
									echo "ID inventúry";
								echo "</th>";
								echo "<th>";
									echo "Zákazník";
								echo "</th>";
								echo "<th>";
									echo "Mesto";
								echo "</th>";
								echo "<th>";
									echo "Typ";
								echo "</th>";
								echo "<th>";
									echo "Dátum a čas začiatku";
								echo "</th>";
								echo "<th>";
									echo "Vedúci inventúry";
								echo "</th>";
							echo "</thead>";
							echo "<tbody class='zoznamTable'>";	
							echo "<tr class='nothing'>";
								echo "<td colspan='8' class='nothing'>";
								echo "<div class='vehicle_div' style='align:center; margin-top:5px; margin-bottom:5px'></div>";
								echo "</td>";
							echo "</tr>";
							foreach ($inventories as $inventory) {				
								echo "<tr>";
									echo "<td width='50px'>";
									echo "</td>";				
									echo "<td width='100px'>";
										if (strlen($inventory->ID_INV)==1) {
												echo "0000";
												echo $inventory->ID_INV;
											} elseif (strlen($inventory->ID_INV)==2) {
												echo "000";
												echo $inventory->ID_INV;
											} elseif (strlen($inventory->ID_INV)==3) {
												echo "00";
												echo $inventory->ID_INV;
											} elseif (strlen($inventory->ID_INV)==4) {
												echo "0";
												echo $inventory->ID_INV;
											} else {
												echo $inventory->ID_INV;
											}
									echo "</td>";
									echo "<td width='150px' id='zak".$inventory->ID_INV."'>";
										echo $inventory->Nazov_spolocnosti;
									echo "</td>";
									echo "<td  width='160px' id='mesto".$inventory->ID_INV."'>";
										echo $inventory->Mesto;
									echo "</td>";
									echo "<td  width='100px'>";
										if($inventory->ID_TYP_R<4){
											echo "Predajňa";
										}else{
											echo "Sklad"; 	
										}
									echo "</td>";					
									echo "<td  width='180px' id='invStart".$inventory->ID_INV."'>";
										echo date ("d.m.Y G:i",strtotime($inventory->Datum_zaciatku));
									echo "</td>";
									echo "<td  width='160px'>";
										if(($inventory->Meno==NULL) OR ($inventory->Priezvisko==NULL)){
											echo "neurčené";
										} else {
											echo $inventory->Meno . ' ' .$inventory->Priezvisko;	
										}
										
									echo "</td>";
									echo "<td>";
									echo '<div class="button-group" style="margin-top:3px">';
										echo '<a href="'. base_url('manager/redirectInventoryDetail/'.($id_voz+200).'/1/'.$inventory->ID_INV).'" class="button"  >Detail inventúry</a>';										 
									echo '</div>';
									echo "</td>";										
								echo "</tr>";						
						}	
						echo "</table>";
						echo "<div class='vehicle_div' style='align:center; margin-top:5px; margin-bottom:0px'></div>";											
						}		
						echo '<div class="button-group" style="margin-left:50px;margin-top:15px;">';	 			
							switch ($active){
								case 1:									
									echo '<a href="'. base_url('manager/showVehicles/1').'" class="button"  >Späť</a>'; 
								break;
								case 2: 
									echo '<a href="'. base_url('manager/showVehicles/2').'" class="button"  >Späť</a>';
								break;
								case 3: 
									echo '<a href="'. base_url('manager/showVehicles/3').'" class="button"  >Späť</a>';	
								break;
								case 4:
									echo '<a href="'. base_url('manager/getReservations/'.$dateRes).'" class="button"  >Späť</a>';	 
								break;
							}	
						echo '</div>';
					echo "</div>";				
						echo $this->pagination->create_links();
					break;
					case 3: 
						echo '<a href="'. base_url() . 'manager/showDetailVehicleActive/'.$active.'/1/'.$id_voz.'/'.$dateRes.'" class="button">Všeobecné informácie</a>';
						echo '<a href="'. base_url() . 'manager/showDetailVehicleActive/'.$active.'/2/'.$id_voz.'/'.$dateRes.'" class="button">Aktívne inventúry vozidla</a>';
						echo '<a href="'. base_url() . 'manager/showDetailVehicleActive/'.$active.'/3/'.$id_voz.'/'.$dateRes.'" class="button active">Archív inventúr vozidla</a>';	
						echo "</div>";
						echo "<div class='vehicle_div' style='align:center; margin-top:15px; margin-bottom:5px'></div>";
						if(count($inventories)==0 OR $inventories==Array()){
							echo "<h3 style='margin-bottom:30px;padding-bottom:30px'>Vozidlo nie je aktuálne prihlásené na žiadnu inventúru.</h3>";
						}else{
							echo "<table style='width:100%;margin-rignt:0px'>";
							echo "<thead style='text-align:left'>";
								echo "<th>";
								echo "</td>";
								echo "<th>";
									echo "ID inventúry";
								echo "</th>";
								echo "<th>";
									echo "Zákazník";
								echo "</th>";
								echo "<th>";
									echo "Mesto";
								echo "</th>";
								echo "<th>";
									echo "Typ";
								echo "</th>";
								echo "<th>";
									echo "Dátum a čas začiatku";
								echo "</th>";
								echo "<th>";
									echo "Vedúci inventúry";
								echo "</th>";
							echo "</thead>";
							echo "<tbody class='zoznamTable'>";	
							echo "<tr class='nothing'>";
								echo "<td colspan='8' class='nothing'>";
								echo "<div class='vehicle_div' style='align:center; margin-top:5px; margin-bottom:5px'></div>";
								echo "</td>";
							echo "</tr>";
							foreach ($inventories as $inventory) {				
								echo "<tr>";
									echo "<td width='50px'>";
									echo "</td>";				
									echo "<td width='100px'>";
										if (strlen($inventory->ID_INV)==1) {
												echo "0000";
												echo $inventory->ID_INV;
											} elseif (strlen($inventory->ID_INV)==2) {
												echo "000";
												echo $inventory->ID_INV;
											} elseif (strlen($inventory->ID_INV)==3) {
												echo "00";
												echo $inventory->ID_INV;
											} elseif (strlen($inventory->ID_INV)==4) {
												echo "0";
												echo $inventory->ID_INV;
											} else {
												echo $inventory->ID_INV;
											}
									echo "</td>";
									echo "<td width='150px' id='zak".$inventory->ID_INV."'>";
										echo $inventory->Nazov_spolocnosti;
									echo "</td>";
									echo "<td  width='160px' id='mesto".$inventory->ID_INV."'>";
										echo $inventory->Mesto;
									echo "</td>";
									echo "<td  width='100px'>";
										if($inventory->ID_TYP_R<4){
											echo "Predajňa";
										}else{
											echo "Sklad"; 	
										}
									echo "</td>";					
									echo "<td  width='180px' id='invStart".$inventory->ID_INV."'>";
										echo date ("d.m.Y G:i",strtotime($inventory->Datum_zaciatku));
									echo "</td>";
									echo "<td  width='160px'>";
										if(($inventory->Meno==NULL) OR ($inventory->Priezvisko==NULL)){
											echo "neurčené";
										} else {
											echo $inventory->Meno . ' ' .$inventory->Priezvisko;	
										}
										
									echo "</td>";
									echo "<td>";
									echo '<div class="button-group" style="margin-top:3px">';
										echo '<a href="'. base_url('manager/redirectInventoryDetail/'.($id_voz+300).'/1/'.$inventory->ID_INV).'" class="button"  >Detail inventúry</a>';										 
									echo '</div>';
									echo "</td>";										
								echo "</tr>";						
						}	
						echo "</table>";
						echo "<div class='vehicle_div' style='align:center; margin-top:5px; margin-bottom:0px'></div>";	
						echo '<div class="button-group" style="margin-left:50px;margin-top:15px;">';	 			
							switch ($active){
								case 1:									
									echo '<a href="'. base_url('manager/showVehicles/1').'" class="button"  >Späť</a>'; 
								break;
								case 2: 
									echo '<a href="'. base_url('manager/showVehicles/2').'" class="button"  >Späť</a>';
								break;
								case 3: 
									echo '<a href="'. base_url('manager/showVehicles/3').'" class="button"  >Späť</a>';	
								break;
								case 4:
									echo '<a href="'. base_url('manager/getReservations/'.$dateRes).'" class="button"  >Späť</a>';	 
								break;
							}	
						echo '</div>';
					echo "</div>";					
						}												
						echo $this->pagination->create_links();
					break;
				}
						
			
					
	} else {
		redirect(base_url('main/restricted'));
	}	
?>
	


