<?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;">';
			echo '<a href="'. base_url() . 'manager/redirectNewVehicle" class="button">Vytvoriť nové vozidlo</a>';
			echo '</div>';
			echo '<div class="button-group" style="margin-left:50px;margin-top:10px;">';						
			if($active==1){
				echo '<a href="'. base_url() . 'manager/showVehicles/1" class="button active">Všetky vozidlá</a>';
				echo '<a href="'. base_url() . 'manager/showVehicles/2" class="button">Aktívne vozidlá</a>';
				echo '<a href="'. base_url() . 'manager/showVehicles/3" class="button">Neaktívne vozidlá</a>';
				echo "</div>";
				if (count($Vehicles)==0){
				echo "<table class='vehicle_table'>"; 
					echo "<h3>Ľutujeme, ale v súčasnej dobe nie je k dispozícii žiadne aktívne vozidlo.</h3>";
				echo "</table>";			
				} else {
					echo "<div class='vehicle_div'>";
					echo "</br>";
					echo "</div>";
					foreach($Vehicles as $Vehicle){ 
						echo "<div class='vehicle_div' align='center'>";						
						echo "<table class='vehicle_table' style='margin-left:50px; padding-top:15px;margin-top:0px; margin-bottom:10px;'>";
							echo "<tr class='vehicle_tr'>";
								echo "<td width='60px'>";
									if ($Vehicle->Status_vozidla==1){
										echo "<img src='http://martinbendik.studenthosting.sk/pictures/green_diod.png' height='20px'>";	
									} else {
										echo "<img src='http://martinbendik.studenthosting.sk/pictures/red_diod.png' height='20px'>";
									}									
								echo "</td>";
								echo "<td>"; 
									if ($Vehicle->Pocet_miest==5){																		
										echo "<img src='http://martinbendik.studenthosting.sk/pictures/sedan_sivy.png' height='80%'>";
									} elseif ($Vehicle->Pocet_miest==7){									
										echo "<img src='http://martinbendik.studenthosting.sk/pictures/combi_sivy.png'height='80%'>";
									} elseif ($Vehicle->Pocet_miest==9){									
										echo "<img src='http://martinbendik.studenthosting.sk/pictures/van_sivy.png'height='80%'>";								
									} else {									
										echo "<img src='http://martinbendik.studenthosting.sk/pictures/bus_sivy.png'height='80%'>";
									}
								echo "</td>";
								echo "<td width='150px' style='text-align: center'>";
									echo "<b>ID vozidla:</b>";
									echo "</br>";
									echo "</br>";
									if (strlen($Vehicle->ID_VOZ)==1) {
										echo "000";
										echo $Vehicle->ID_VOZ;
									} elseif (strlen($Vehicle->ID_VOZ)==2) {
										echo "00";
										echo $Vehicle->ID_VOZ;
									} elseif (strlen($Vehicle->ID_VOZ)==3) {
										echo "0";
										echo $Vehicle->ID_VOZ;
									} else {
										echo $Vehicle->ID_VOZ;
									}								
								echo "</td>";
								echo "<td width='160px' style='text-align: center'>";
									echo "<b>Názov vozidla:</b>";
									echo "</br>";
									echo "</br>";
									echo $Vehicle->Nazov;
								echo "</td>";
								echo "<td width='160px' style='text-align: center'>";
									echo "<b>ŠPZ vozidla:</b>";
									echo "</br>";
									echo "</br>";
									echo $Vehicle->SPZ;
								echo "</td>";
								echo "<td width='160px' style='text-align: center'>";
									echo "<b>Pocet miest:</b>";
									echo "</br>";
									echo "</br>";
									echo $Vehicle->Pocet_miest;
								echo "</td>";
								echo "<td width='220px' style='text-align: center'>";								
									echo '<div class="button-group" style="margin-left:0px;margin-top:0px">';
										echo '<a href="'. base_url() . 'manager/redirectEditVehicle/' . $Vehicle->ID_VOZ . '" class="button danger">Upraviť</a>';
										echo '<a href="'. base_url() . 'manager/showDetailVehicleActive/'.$active.'/1/'.$Vehicle->ID_VOZ.'/0" class="button">Detial</a>';			
									echo '</div>';		
								echo "</td>";
							echo "</tr>";	
						echo "</table>";
						echo "</div>";	
					}
				}					
			} elseif ($active==2){
				echo '<a href="'. base_url() . 'manager/showVehicles/1" class="button">Všetky vozidlá</a>';
				echo '<a href="'. base_url() . 'manager/showVehicles/2" class="button active">Aktívne vozidlá</a>';
				echo '<a href="'. base_url() . 'manager/showVehicles/3" class="button">Neaktívne vozidlá</a>';
				echo "</div>";
				if (count($Vehicles)==0){
				echo "<table class='vehicle_table'>";
					echo "<h3>Ľutujeme, ale v súčasnej dobe nie je k dispozícii žiadne aktívne vozidlo.</h3>";
				echo "</table>";			
				} else {
					echo "<div class='vehicle_div'>";
					echo "</br>";
					echo "</div>";
					foreach($Vehicles as $Vehicle){
						echo "<div class='vehicle_div' align='center'>";						
						echo "<table class='vehicle_table' style='margin-left:50px; padding-top:15px;margin-top:0px; margin-bottom:10px;'>";
							echo "<tr class='vehicle_tr'>";
								echo "<td width='60px'>";
									echo "<img src='http://martinbendik.studenthosting.sk/pictures/green_diod.png' height='20px'>";		
								echo "</td>";
								echo "<td>"; 
									if ($Vehicle->Pocet_miest==5){																		
										echo "<img src='http://martinbendik.studenthosting.sk/pictures/sedan_sivy.png' height='80%'>";
									} elseif ($Vehicle->Pocet_miest==7){									
										echo "<img src='http://martinbendik.studenthosting.sk/pictures/combi_sivy.png'height='80%'>";
									} elseif ($Vehicle->Pocet_miest==9){									
										echo "<img src='http://martinbendik.studenthosting.sk/pictures/van_sivy.png'height='80%'>";								
									} else {									
										echo "<img src='http://martinbendik.studenthosting.sk/pictures/bus_sivy.png'height='80%'>";
									}
								echo "</td>";
								echo "<td width='150px' style='text-align: center'>";
									echo "<b>ID vozidla:</b>";
									echo "</br>";
									echo "</br>";
									if (strlen($Vehicle->ID_VOZ)==1) {
										echo "000";
										echo $Vehicle->ID_VOZ;
									} elseif (strlen($Vehicle->ID_VOZ)==2) {
										echo "00";
										echo $Vehicle->ID_VOZ;
									} elseif (strlen($Vehicle->ID_VOZ)==3) {
										echo "0";
										echo $Vehicle->ID_VOZ;
									} else {
										echo $Vehicle->ID_VOZ;
									}								
								echo "</td>";
								echo "<td width='160px' style='text-align: center'>";
									echo "<b>Názov vozidla:</b>";
									echo "</br>";
									echo "</br>";
									echo $Vehicle->Nazov;
								echo "</td>";
								echo "<td width='160px' style='text-align: center'>";
									echo "<b>ŠPZ vozidla:</b>";
									echo "</br>";
									echo "</br>";
									echo $Vehicle->SPZ;
								echo "</td>";
								echo "<td width='160px' style='text-align: center'>";
									echo "<b>Pocet miest:</b>";
									echo "</br>";
									echo "</br>";
									echo $Vehicle->Pocet_miest;
								echo "</td>";
								echo "<td width='220px' style='text-align: center'>";								
									echo '<div class="button-group" style="margin-left:0px;margin-top:0px">';
										echo '<a href="'. base_url() . 'manager/redirectEditVehicle/' . $Vehicle->ID_VOZ . '" class="button danger">Upraviť</a>';
										echo '<a href="'. base_url() . 'manager/showDetailVehicleActive/'.$active.'/1/'. $Vehicle->ID_VOZ . '/0" class="button">Detial</a>';			
									echo '</div>';		
								echo "</td>";
							echo "</tr>";	
						echo "</table>";
						echo "</div>";	
					}
				}	
			} else {
				echo '<a href="'. base_url() . 'manager/showVehicles/1" class="button">Všetky vozidlá</a>';
				echo '<a href="'. base_url() . 'manager/showVehicles/2" class="button">Aktívne vozidlá</a>';
				echo '<a href="'. base_url() . 'manager/showVehicles/3" class="button active">Neaktívne vozidlá</a>';
				echo "</div>";
				if (count($Vehicles)==0){
				echo "<table class='vehicle_table'>";
					echo "<h3>Ľutujeme, ale v súčasnej dobe nie je k dispozícii žiadne neaktívne vozidlo.</h3>";
				echo "</table>";			
				} else {
					echo "<div class='vehicle_div'>";
					echo "</br>";
					echo "</div>";
					foreach($Vehicles as $Vehicle){
						echo "<div class='vehicle_div' align='center'>";						
						echo "<table class='vehicle_table' style='margin-left:50px; padding-top:15px;margin-top:0px; margin-bottom:10px;'>";
							echo "<tr class='vehicle_tr'>";
								echo "<td width='60px'>";
									echo "<img src='http://martinbendik.studenthosting.sk/pictures/red_diod.png' height='20px'>";		
								echo "</td>";
								echo "<td>"; 
									if ($Vehicle->Pocet_miest==5){																		
										echo "<img src='http://martinbendik.studenthosting.sk/pictures/sedan_sivy.png' height='80%'>";
									} elseif ($Vehicle->Pocet_miest==7){									
										echo "<img src='http://martinbendik.studenthosting.sk/pictures/combi_sivy.png'height='80%'>";
									} elseif ($Vehicle->Pocet_miest==9){									
										echo "<img src='http://martinbendik.studenthosting.sk/pictures/van_sivy.png'height='80%'>";								
									} else {									
										echo "<img src='http://martinbendik.studenthosting.sk/pictures/bus_sivy.png'height='80%'>";
									}
								echo "</td>";
								echo "<td width='150px' style='text-align: center'>";
									echo "<b>ID vozidla:</b>";
									echo "</br>";
									echo "</br>";
									if (strlen($Vehicle->ID_VOZ)==1) {
										echo "000";
										echo $Vehicle->ID_VOZ;
									} elseif (strlen($Vehicle->ID_VOZ)==2) {
										echo "00";
										echo $Vehicle->ID_VOZ;
									} elseif (strlen($Vehicle->ID_VOZ)==3) {
										echo "0";
										echo $Vehicle->ID_VOZ;
									} else {
										echo $Vehicle->ID_VOZ;
									}								
								echo "</td>";
								echo "<td width='160px' style='text-align: center'>";
									echo "<b>Názov vozidla:</b>";
									echo "</br>";
									echo "</br>";
									echo $Vehicle->Nazov;
								echo "</td>";
								echo "<td width='160px' style='text-align: center'>";
									echo "<b>ŠPZ vozidla:</b>";
									echo "</br>";
									echo "</br>";
									echo $Vehicle->SPZ;
								echo "</td>";
								echo "<td width='160px' style='text-align: center'>";
									echo "<b>Pocet miest:</b>";
									echo "</br>";
									echo "</br>";
									echo $Vehicle->Pocet_miest;
								echo "</td>";
								echo "<td width='220px' style='text-align: center'>";								
									echo '<div class="button-group" style="margin-left:0px;margin-top:0px">';
										echo '<a href="'. base_url() . 'manager/redirectEditVehicle/' . $Vehicle->ID_VOZ . '" class="button danger">Upraviť</a>';
										echo '<a href="'. base_url() . 'manager/showDetailVehicleActive/'.$active.'/1/'. $Vehicle->ID_VOZ . '/0" class="button">Detial</a>';			
									echo '</div>';		
								echo "</td>";
							echo "</tr>";	
						echo "</table>";
						echo "</div>";	
					}
				}			
				}				
		echo "</div>";		
		echo $this->pagination->create_links();
	} else {
		redirect(base_url('main/restricted'));
	}	
?>
	


