<script>
	
	function destroyDialog(){
		var confBackGr = document.getElementById("confirmBackgr");	
		var dialog = document.getElementById("confirmBox");
		confBackGr.style.display = "none";
		dialog.style.display = "none";
	}
	
	function showConfirmBoxLogOn(id_inv){
		var confBackGr = document.getElementById("confirmBackgr");						
		var dialog = document.getElementById("confirmBox");
		document.getElementById("confirmBoxHead").innerHTML = "Prihlásenie na inventúru";
		document.getElementById("confirmBoxBody").innerHTML = "Určite sa chcete prihlásiť na inventúru pre zákazníka: <br><b>"+document.getElementById("zak"+id_inv).innerHTML+" ("+document.getElementById("invStart"+id_inv).innerHTML+")";
		document.getElementById("confirmButtons").innerHTML = "<a onclick='destroyDialog()' class='button'>Nie</a><a href='http://martinbendik.studenthosting.sk/lead_employee/joinLeadEmployeeInventory/"+document.getElementById("active").innerHTML+"/"+id_inv+"' class='button'>Áno</a>";
		confBackGr.style.display = "block";
		dialog.style.display = "block";	
		var width = window.innerWidth;
		var height = window.innerHeight; 
		dialog.style.left = ((width/2)-(500/2)+80)+"px";
		dialog.style.top = "200px";
	}
	
	function showConfirmBoxLogOut(id_inv){
		var confBackGr = document.getElementById("confirmBackgr");						
		var dialog = document.getElementById("confirmBox");
		document.getElementById("confirmBoxHead").innerHTML = "Odhlásenie z inventúry";
		document.getElementById("confirmBoxBody").innerHTML = "Určite sa chcete odhlásiť z inventúry pre zákazníka: <br><b>"+document.getElementById("zak"+id_inv).innerHTML+" ("+document.getElementById("invStart"+id_inv).innerHTML+")";
		document.getElementById("confirmButtons").innerHTML = "<a onclick='destroyDialog()' class='button'>Nie</a><a href='http://martinbendik.studenthosting.sk/lead_employee/disjoinLeadEmployeeInventory/"+document.getElementById("active").innerHTML+"/"+id_inv+"' class='button'>Áno</a>";
		confBackGr.style.display = "block";
		dialog.style.display = "block";	
		var width = window.innerWidth;
		var height = window.innerHeight; 
		dialog.style.left = ((width/2)-(500/2)+80)+"px";
		dialog.style.top = "200px";
	}
	
	document.onload = function(){
		destroyDialog();
	}
</script>
<?php
	if ($this->session->userdata('permisson')==2) {
		$CI =& get_instance();
		$CI->load->library('libraryprofile');
		$CI->libraryprofile->showMenuBarLeadEmployee($this->session->userdata('meno'),$this->session->userdata('priezvisko'),$this->session->userdata('id_zamestnanca'));
		$this->load->helper('lead_employee_helper');
		echo "<span id='active' hidden>".$active."</span>";
		echo '<div id="confirmBackgr">';
		echo '</div>';
			echo '<div id="confirmBox">';
				echo '<div id="confirmBoxHead"></div>';
				echo '<div id="confirmBoxBody"></div>';
				echo '<div id="confirmBoxFoot">';
					echo '<div class="button-group" id="confirmButtons">';
						echo '<a href="" class="button">Nie</a>';
						echo '<a href="" class="button">Áno</a>';
					echo '</div>';
				echo '</div>';
			echo '</div>';		
		echo '<div id="default_container">';
			echo '<div class="button-group" style="margin-left:50px;margin-top:10px;">';
				switch ($active){
					case 1: 
						echo '<a href="'. base_url() . 'lead_employee/getInventories/1" class="button active">Ohlásené inventúry</a>';
						echo '<a href="'. base_url() . 'lead_employee/getInventories/2" class="button">Voľné inventúry</a>';
						echo '<a href="'. base_url() . 'lead_employee/getInventories/3" class="button">Prihlásený na inventúry</a>';
						echo '<a href="'. base_url() . 'lead_employee/getInventories/4" class="button">Archív inventúr</a>';
					break;
					case 2: 
						echo '<a href="'. base_url() . 'lead_employee/getInventories/1" class="button">Ohlásené inventúry</a>';
						echo '<a href="'. base_url() . 'lead_employee/getInventories/2" class="button active">Voľné inventúry</a>';
						echo '<a href="'. base_url() . 'lead_employee/getInventories/3" class="button">Prihlásený na inventúry</a>';
						echo '<a href="'. base_url() . 'lead_employee/getInventories/4" class="button">Archív inventúr</a>';
					break;
					case 3: 
						echo '<a href="'. base_url() . 'lead_employee/getInventories/1" class="button">Ohlásené inventúry</a>';
						echo '<a href="'. base_url() . 'lead_employee/getInventories/2" class="button">Voľné inventúry</a>';
						echo '<a href="'. base_url() . 'lead_employee/getInventories/3" class="button active">Prihlásený na inventúry</a>';
						echo '<a href="'. base_url() . 'lead_employee/getInventories/4" class="button">Archív inventúr</a>';
					break;
					case 4: 
						echo '<a href="'. base_url() . 'lead_employee/getInventories/1" class="button">Ohlásené inventúry</a>';
						echo '<a href="'. base_url() . 'lead_employee/getInventories/2" class="button">Voľné inventúry</a>';
						echo '<a href="'. base_url() . 'lead_employee/getInventories/3" class="button">Prihlásený na inventúry</a>';
						echo '<a href="'. base_url() . 'lead_employee/getInventories/4" class="button active">Archív inventúr</a>';
					break;	
				}
				
			echo "</div>";
			echo "<div class='vehicle_div' style='align:center; margin-top:15px'>";
			echo "</div>"; 
			if(count($inventories)>0){
				echo "<div class='vehicle_div2' align='left' style='border-bottom:1px solid #D0D0D0'>";
			echo "<table class='vehicle_table_head' style='margin-left:35px; padding-top:10px;margin-top:0px; margin-bottom:5px;'>";
				echo "<tr>";
					echo "<td width='50px'>";
					echo '</td>';
					echo "<td width='100px' style='text-align: center; margin-left:0px'>";
						echo "<b> ID invent.:";
					echo '</td>';
					echo "<td width='160px' style='text-align: center'>";
						echo "<b> Zakazník:";
					echo '</td>';
					echo "<td width='90px' style='text-align: center'>";
					echo "<b> Poč. zam.:";
					echo '</td>';
					echo "<td width='120px' style='text-align: center'>";
					echo "<b> Vedúci:";
					echo '</td>';
					echo "<td width='160px' style='text-align: center'>";
					echo "<b> Začiatok:";
					echo '</td>';
					echo "<td width='160px' style='text-align: center'>";
					echo "<b> Koniec:";
					echo '</td>';
				echo "</tr>";
			echo "</table>";
			echo "</div>";	
			}
			 			 			
			$countInv=0;
//vypis inventur		
			foreach($inventories as $inventory){
				if ($active==2){
					if($inventory->ID_Veduci==NULL AND !amILoggedElseWhere($this->session->userdata['id_zamestnanca'],$inventory->ID_INV, $inventory->Datum_zaciatku, $inventory->Datum_konca)){
						$countInv++;
						drawInventory($active,$inventory,$this->session->userdata['id_zamestnanca']);		
					}		
				} else {
					$countInv++;
					drawInventory($active,$inventory,$this->session->userdata['id_zamestnanca']);	
				}
			}	
		if ($countInv==0){							
			switch($active){ 
				case 1:
					echo "<h3>V súčastnej dobe nie sú ohlásené žiadne inventúry.</h3>";	
				break;
				case 2:
					echo "<h3>V súčastnej dobe nie sú pre vás dostupné žiadne voľné inventúry.</h3>";	  
				break;
				case 3:
					echo "<h3>V súčastnej dobe nie ste prihlásený na žiadnu inventúru.</h3>"; 
				break;
				case 4: 
					echo "<h3>Ešte ste neabsolvovali žiadnu inventúru.</h3>";
				break;
			}}else{
				
			}	
		echo '</div>';
		echo $this->pagination->create_links();	
	} else {
		redirect(base_url('main/restricted'));
	}	
?>

	
	
	


