<script type="text/javascript">

function OnChangeBox (x,y) {		
		if (y==5){
			if (x.checked) {
				$(x).parent().css({"background": "url(http://martinbendik.studenthosting.sk/pictures/sedan_zeleny.png)","background-repeat": "no-repeat","background-position": "0px 30px"});
				var z = parseInt(document.getElementById("pocet_zam").innerText);
				document.getElementById("pocet_zam").innerHTML = z+y-1;
			} 
			else {
			$(x).parent().css({"background": "url(http://martinbendik.studenthosting.sk/pictures/sedan_sivy.png)","background-repeat": "no-repeat","background-position": "0px 30px"});			
				var z = parseInt(document.getElementById("pocet_zam").innerText);
				document.getElementById("pocet_zam").innerHTML = z-y+1;	
			}	 
		} else if (y==7){
			if (x.checked) {
				$(x).parent().css({"background": "url(http://martinbendik.studenthosting.sk/pictures/combi_zeleny.png)","background-repeat": "no-repeat","background-position": "0px 30px"});
				var z = parseInt(document.getElementById("pocet_zam").innerText);
				document.getElementById("pocet_zam").innerHTML = z+y-1;	
			}
			else {
				$(x).parent().css({"background": "url(http://martinbendik.studenthosting.sk/pictures/combi_sivy.png)","background-repeat": "no-repeat","background-position": "0px 30px"});			
				var z = parseInt(document.getElementById("pocet_zam").innerText);
				document.getElementById("pocet_zam").innerHTML = z-y+1;
			}
		} else if (y==9){
			if (x.checked) {
				$(x).parent().css({"background": "url(http://martinbendik.studenthosting.sk/pictures/van_zeleny.png)","background-repeat": "no-repeat","background-position": "0px 28px"});
				var z = parseInt(document.getElementById("pocet_zam").innerText);
				document.getElementById("pocet_zam").innerHTML = z+y-1;	
			}
			else {
				$(x).parent().css({"background": "url(http://martinbendik.studenthosting.sk/pictures/van_sivy.png)","background-repeat": "no-repeat","background-position": "0px 28px"});			
				var z = parseInt(document.getElementById("pocet_zam").innerText);
				document.getElementById("pocet_zam").innerHTML = z-y+1;
			}
		} else {
			if (x.checked) {
				$(x).parent().css({"background": "url(http://martinbendik.studenthosting.sk/pictures/bus_zeleny.png)","background-repeat": "no-repeat","background-position": "0px 28px"});
				var z = parseInt(document.getElementById("pocet_zam").innerText);
				document.getElementById("pocet_zam").innerHTML = z+y-1;	
			}
			else {
				$(x).parent().css({"background": "url(http://martinbendik.studenthosting.sk/pictures/bus_sivy.png)","background-repeat": "no-repeat","background-position": "0px 28px"});			
				var z = parseInt(document.getElementById("pocet_zam").innerText);
				document.getElementById("pocet_zam").innerHTML = z-y+1;
			}
		} 
		
	}


</script>	
		


<?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')); 
							
		$this->load->helper('vehicles_helper');
		$allFreeVehicles = getFreeVehicles($NewInventory->Datum_zaciatku,$NewInventory->Datum_konca);
		$typesOfVehicles = getTypesOfVehicles();
		 
		$PocetZamestnancov = 0;
		
		echo '<div id="default_container">';
			echo '<h3>Nová inventúra, 3.krok: Rezervácie</h3>';
			echo "<table class='profile_table'>";
				echo '<tr>';
					echo '<td>';
						echo '<b>Názov spoločnosti: </b>';
					echo '</td>';
					echo '<td>';
						echo $NewInventory->Nazov_spolocnosti;
					echo '</td>';
					echo '<td>';
						echo '<b>Počet zamestnancov: </b>';
					echo '</td>';
					echo '<td id="pocet_zam">';
						echo'0';				
					echo '</td>';
				echo '</tr>';
				
				echo '<tr>';
					echo '<td>';
						echo '<b>Typ spoločnosti: </b>';
					echo '</td>';
					echo '<td>';
						echo $NewInventory->Nazov_typ_obchodu;
					echo '</td>';
					echo '<td>';
						echo '<b>Vzdialenosť: </b>';
					echo '</td>';
					echo '<td>';
						echo $NewInventory->Vzdialenost . " km";
					echo '</td>';
				echo '</tr>';
				
				echo '<tr>';
					echo '<td>';
						echo '<b>Mesto: </b>';
					echo '</td>';
					echo '<td>';
						echo $NewInventory->Mesto;
					echo '</td>';
					echo '<td>';
						echo '<b>Čas cesty: </b>';
					echo '</td>';
					echo '<td>';
						echo $NewInventory->Cas_cesty;
					echo '</td>';
				echo '</tr>';
				
				echo '<tr>';
					echo '<td>';
						echo '<b>Ulica: </b>';
					echo '</td>';
					echo '<td>';
						echo $NewInventory->Ulica . ' ' . $NewInventory->Cislo;
					echo '</td>';
					echo '<td>';
						echo '<b>Dátum a čas začiatku: </b>';
					echo '</td>';
					echo '<td>';
						echo $NewInventory->Datum_zaciatku;
					echo '</td>';
				echo '</tr>';
				
				echo '<tr>';
					echo '<td>';
						echo '<b>PSČ: </b>';
					echo '</td>';
					echo '<td>';
						echo $NewInventory->PSC;
					echo '</td>';
					echo '<td>';
						echo '<b>Dátum a čas konca: </b>';
					echo '</td>';
					echo '<td>';
						echo $NewInventory->Datum_konca;
					echo '</td>';
				echo '</tr>';				
			echo '</table>'	;
			
			echo form_open(base_url('main/createReservations/' . $NewInventory->ID_INV),'onkeypress="return event.keyCode != 13;"');
			echo '<h3>Dostupné vozidlá: </h3>';
			if ($allFreeVehicles==FALSE){
				echo '<h4>Ľutujeme ale na tento dátum nie je voľné žiadne vozidlo.</h4>';
			} else {
				foreach ($allFreeVehicles as $freeVehicle){ 
				if ($freeVehicle->Typ_vozidla==1){
					echo '<nav id="box_sedan" onchange="myFunction()">';						
						echo "Počet miest: " . $freeVehicle->Pocet_miest;
						echo "</br>";
						echo "</br>";
						echo "</br>";
						echo "</br>";
						echo "</br>";						
						echo' <input type="checkbox" onclick="OnChangeBox (this,'.$freeVehicle->Pocet_miest.')"  name="vehicle[]" class="vehicle5" value="' . $freeVehicle->ID_VOZ . '" >';
					echo '</nav>';	
				} else if ($freeVehicle->Typ_vozidla==2){	
					echo '<nav id="box_combi">';						
						echo "Počet miest: " . $freeVehicle->Pocet_miest;
						echo "</br>";
						echo "</br>";
						echo "</br>";
						echo "</br>";
						echo "</br>";						
						echo' <input type="checkbox" onclick="OnChangeBox (this,'.$freeVehicle->Pocet_miest.')" name="vehicle[]" class="vehicle7" value="' . $freeVehicle->ID_VOZ . '">';
					echo '</nav>';	
				} else if ($freeVehicle->Typ_vozidla==3){
					echo '<nav id="box_van">';						
						echo "Počet miest: " . $freeVehicle->Pocet_miest;
						echo "</br>";
						echo "</br>";
						echo "</br>";
						echo "</br>";
						echo "</br>";						
						echo' <input type="checkbox" onclick="OnChangeBox (this,'.$freeVehicle->Pocet_miest.')" name="vehicle[]" class="vehicle9" value="' . $freeVehicle->ID_VOZ . '">';
					echo '</nav>';	
				} else {
					echo '<nav id="box_bus">';						
						echo "Počet miest: " . $freeVehicle->Pocet_miest;
						echo "</br>";
						echo "</br>";
						echo "</br>";
						echo "</br>";
						echo "</br>";						
						echo' <input type="checkbox" onclick="OnChangeBox (this,'.$freeVehicle->Pocet_miest.')" name="vehicle[]" class="bus" value="' . $freeVehicle->ID_VOZ . '" >';
					echo '</nav>';	
				}	 
			}	
			}
			echo '</br>';
			echo '<div class="button-group" style="margin-left:50px;margin-top:20px">';
			echo '<a href="#" class="button danger">Preskočiť na detail</a>';
			echo '<a href="#" class="button danger">Upraviť dátum a čas</a>';
			echo '<input type="submit" value="Vytvoriť rezervácie" class="button">';
			echo '</div>';
			echo form_close();			
		echo '</div>';
	} else {
		redirect(base_url('main/restricted'));
	}	
?>