<?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'));
		
		$poradie = 0;
		$this->load->helper('employee_inventory_helper');
		$this->load->helper('lead_employee_helper');
			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('driver/DetailOfInventory/'.$modeType.'/'.$mode.'/1/'.$id_inv).'" class="button active">Všeobecné informácie</a>';
							echo '<a href="'.base_url('driver/DetailOfInventory/'.$modeType.'/'.$mode.'/2/'.$id_inv).'" class="button">Zoznam zamestnancov</a>';
							echo '</div>';
							echo "<div class='div_curve'>";	
								echo '<div class="divForMap">';
								echo $map['html'];
							echo '</div>';
							echo '<table class="detailTable"';
							echo '<tr>';
								echo '<td id="td200">';
									echo '<b>Identifikačné číslo:</b>';
								echo '</td>';
								echo '<td>';
									if (strlen($inventoryInfo->ID_INV)==1) {
								echo "0000";
								echo $inventoryInfo->ID_INV;
							} elseif (strlen($inventoryInfo->ID_INV)==2) {
								echo "000";
								echo $inventoryInfo->ID_INV;
							} elseif (strlen($inventoryInfo->ID_INV)==3) {
								echo "00";
								echo $inventoryInfo->ID_INV;
							} elseif (strlen($inventoryInfo->ID_INV)==4) {
								echo "0";
								echo $inventoryInfo->ID_INV;
							} else {
								echo $inventoryInfo->ID_INV;
							}
								echo '</td>';	
							echo '</tr>';							
							echo '<tr>';
								echo '<td>';
									echo '<b>Názov spoločnosti:</b>';
								echo '</td>';
								echo '<td>';
									echo $inventoryInfo->Nazov_spolocnosti;
								echo '</td>';									
							echo '</tr>';
							echo '<tr>';
								echo '<td>';
									echo '<b>Typ spolocnosti:</b>';
								echo '</td>';
								echo '<td>';
									echo $inventoryInfo->Nazov_typ_obchodu;
								echo '</td>';																	
							echo '</tr>';
							echo '<tr>';
								echo '<td>';
									echo '<b>Rozloha spolocnosti:</b>';
								echo '</td>';
								echo '<td>';
									echo $inventoryInfo->Nazov_rozloha;
								echo '</td>';									
							echo '</tr>';
							echo '<tr>';
								echo '<td>';
								echo '&nbsp';
								echo '</td>';
							echo '</tr>';
							echo '<tr>';
								echo '<td>';
									echo '<b>Kontaktná adresa:</b>';
								echo '</td>';
								echo '<td>';
									echo $inventoryInfo->Ulica." ".$inventoryInfo->Cislo;
								echo '</td>';									
							echo '</tr>';	
							echo '<tr>';
								echo '<td>';
									echo '&nbsp';
								echo '</td>';
								echo '<td>';
									echo $inventoryInfo->PSC.", ".$inventoryInfo->Mesto;
								echo '</td>';	
							echo '</tr>';
							echo '<tr>';
								echo '<td>';
								echo '&nbsp';
								echo '</td>';
							echo '</tr>';
							echo '<tr>';
							echo '<td>';
									echo '<b>Uzávierka prihlasovania:</b>';
								echo '</td>';
								echo '<td>';
									echo date('d.m.Y G:i',strtotime($inventoryInfo->Datum_prihlasovania));
								echo '</td>';								
							echo '</tr>';
							echo '<tr>';
								echo '<td>';
									echo '<b>Dátum a čas začiatku:</b>';
								echo '</td>';
								echo '<td>';
									echo date('d.m.Y G:i',strtotime($inventoryInfo->Datum_zaciatku));
								echo '</td>';	
							echo '</tr>';
							echo '<tr>';
								echo '<td>';
									echo '<b>Dátum a čas konca:</b>';
								echo '</td>';
								echo '<td>';
									echo date('d.m.Y G:i',strtotime($inventoryInfo->Datum_konca));
								echo '</td>';
							echo '</tr>';
							echo '<tr>';
							echo '<tr>';
								echo '<td>';
								echo '&nbsp';
								echo '</td>';
							echo '</tr>';
							echo '<td>';
									echo '<b>Čas cesty:</b>';
								echo '</td>';
								echo '<td>';
									echo date('G:i',strtotime($inventoryInfo->Cas_cesty));
								echo '</td>';
							echo '</tr>';
							echo '<tr>';
							echo '<td>';
									echo '<b>Vzdialenost:</b>';
								echo '</td>';
								echo '<td>';
									echo $inventoryInfo->Vzdialenost." Km";
								echo '</td>';
							echo '</tr>';							
						echo '</table>';			
					echo "</div>";
					echo '<div class="button-group" style="margin-left:50px;margin-top:10px">';
						echo '<a href="'.base_url('driver/showAllInventories/'.$modeType.'/'.$mode).'" class="button">Späť</a>';
					echo '</div>';	 
						break;
						case 2:  
							echo '<a href="'.base_url('driver/DetailOfInventory/'.$modeType.'/'.$mode.'/1/'.$id_inv).'" class="button">Všeobecné informácie</a>';
							echo '<a href="'.base_url('driver/DetailOfInventory/'.$modeType.'/'.$mode.'/2/'.$id_inv).'" class="button  active">Zoznam zamestnancov</a>';
							echo '</div>';
							
					$printLeadEmployee = true;
					$allEmployeesCount = 0;
					
					foreach($inventoryInfo as $reservation){
						echo "<div class='div_curve' style='margin-top:15px'>";
						$vehicle = getCarInfo($reservation->ID_VOZ);
						echo '<table class="detailTable"';
							echo '<tr>';
								echo '<td width="250px">';
									switch ($vehicle->Typ_vozidla){
										case 1:
											echo "<img src='".base_url('pictures/sedan_sivy.png')."'>";
										break;
										case 2:
											echo "<img src='".base_url('pictures/combi_sivy.png')."'>";
										break;
										case 3:
											echo "<img src='".base_url('pictures/van_sivy.png')."'>";
										break;
										case 4:
											echo "<img src='".base_url('pictures/bus_sivy.png')."'>";
										break;
									}										
								echo '</td>';
								echo '<td>';
									echo '<b><p style="float:left;display: inline-block; margin-left:0px">Názov vozidla:<br>ŠPZ vozidla:<br>Počet miest:</p></b>';
									echo '<p style="float:left;display: inline-block;">';
										echo $vehicle->Nazov;
										 	echo "</br>";
										echo $vehicle->SPZ;
										 	echo "</br>";
										echo $vehicle->Pocet_miest;	
									echo '</p>';
								echo '</td>';
							echo '</tr>';
							echo '</table>';
//hlavicka
							echo '<table class="detailTableEmployees"';
							echo '<tr>';
								echo '<th class="ID" style="width:60px">';
									echo 'Por. č.';
								echo '</th>';
								echo '<th class="ID" style="width:150px">';
									echo 'Typ';
								echo '</th>';
								echo '<th class="ID">';
									echo 'ID';
								echo '</th>';
								echo '<th class="nameTD">';
									echo 'Priezvisko';
								echo '</th>';
								echo '<th class="nameTD">';
									echo 'Meno';
								echo '</th>';
								echo '<th class="nameTD">';
									echo 'Tel. číslo';
								echo '</th>';
								echo '<th class="emailTD">';
									echo 'Email';
								echo '</th>';
							echo '</tr>';
//vypis vodica			
							if($reservation->ID_SOF==NULL){
								$driver = new stdClass();
								$driver->Nazov = "Šofér";
								$driver->ID_ZAM= "-";
								$driver->Priezvisko="-";
								$driver->Meno="-";
								$driver->Tel_cislo_zamestnanca="-";
								$driver->Email="-";								
							} elseif($reservation->ID_SOF==0){
								$driver = new stdClass();
								$driver->Nazov = "Šofér";
								$driver->ID_ZAM= "-";
								$driver->Priezvisko="Šofér";
								$driver->Meno="Externý";
								$driver->Tel_cislo_zamestnanca="-";
								$driver->Email="-";	
							} else {
								$driver = getEmployeeInfo($reservation->ID_SOF);	
							}
							
							$allEmployeesCount++;
							echo '<tr>';
								echo '<td>';
									echo $allEmployeesCount.".";
								echo '</td>';
								echo '<td>';
									echo $driver->Nazov;
								echo '</td>';
								echo '<td>';
									if ($driver->ID_ZAM=="-"){
										echo "-";
									} else {
										echo returnStringId($driver->ID_ZAM);
									}								
								echo '</td>';
								echo '<td>';
									echo $driver->Priezvisko;	
								echo '</td>';
								echo '<td>';
									echo $driver->Meno;
								echo '</td>';
								echo '<td>';
									if($driver->Tel_cislo_zamestnanca=="-"){
										echo "-";	
									} elseif ($driver->Tel_cislo_zamestnanca==0){										
										echo "-nevyplnené-";	
									} else {
										echo "0".$driver->Tel_cislo_zamestnanca;		
									}									
								echo '</td>';
								echo '<td>';
									echo $driver->Email;
								echo '</td>';
							echo '</tr>';							
//Vypis zamestnancov
						$employees=getReservationEmployees($reservation->ID_REZ);						
							foreach($employees as $employee){
								if($employee->ID_ZAM==NULL){
									$employeeInfo = new stdClass();
									$employeeInfo->Nazov = "Vedúci";
									$employeeInfo->ID_ZAM= "-";
									$employeeInfo->Priezvisko="-";
									$employeeInfo->Meno="-";
									$employeeInfo->Tel_cislo_zamestnanca="-";
									$employeeInfo->Email="-";								
								} else {
									$employeeInfo = getEmployeeInfo($employee->ID_ZAM);	
								}
									$allEmployeesCount++;
							echo '<tr>';
								echo '<td>';
									echo $allEmployeesCount.".";
								echo '</td>';
								echo '<td>';
									if ($employeeInfo->Nazov=="Šofér"){
										echo "Zamestnanec";	
									} else {
										echo $employeeInfo->Nazov;	
									}									
								echo '</td>';
								echo '<td>';
									if ($employeeInfo->ID_ZAM=="-"){
										echo "-";
									} else {
										echo returnStringId	($employeeInfo->ID_ZAM);	
									}
								echo '</td>';
								echo '<td>';
									echo $employeeInfo->Priezvisko;	
								echo '</td>';
								echo '<td>';
									echo $employeeInfo->Meno;
								echo '</td>';
								echo '<td>';
									if($employeeInfo->Tel_cislo_zamestnanca=="-"){
										echo "-";	
									}elseif($employeeInfo->Tel_cislo_zamestnanca==0){
										echo "-nevyplnené-";
									} else {
										echo "0".$employeeInfo->Tel_cislo_zamestnanca;		
									}									
								echo '</td>';
								echo '<td>';
									echo $employeeInfo->Email;
								echo '</td>';
							echo '</tr>';	
						}		
									
							
				
			
						echo '</table>';
					echo "</div>";		
					}									
			
					echo '<div class="button-group" style="margin-left:50px;margin-top:10px">';
						echo '<a href="'.base_url('driver/showAllInventories/'.$modeType.'/'.$mode).'" class="button">Späť</a>';
					echo '</div>';
				
						break;
					}
				
		
		
		
		
		

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

	
	
	


