<?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/redirectNewEmployee" class="button">Vytvoriť nového zamestnanca</a>'; 
		echo '</div>';
		echo '<div class="button-group" style="margin-left:50px;margin-top:10px;">';
			if($Active==0){
				echo '<a href="'. base_url() . 'manager/getAllEmployees" class="button active">Všetci zamestnanci</a>';
				echo '<a href="'. base_url() . 'manager/getManagers" class="button">Manažéri</a>';
				echo '<a href="'. base_url() . 'manager/getLeadEmployees" class="button">Vedúci</a>';
				echo '<a href="'. base_url() . 'manager/getDrivers" class="button">Vodiči</a>';
				echo '<a href="'. base_url() . 'manager/getEmployees" class="button">Zamestnanci</a>';	
				echo '</div>';
				echo '<div class="button-group" style="margin-left:50px;margin-top:10px;">';
		 			echo form_open(base_url() . 'manager/searchAllEmployees/0','onkeypress="return event.keyCode != 13;"');	  			   			
						echo form_submit('submit_search', 'Hľadať', 'class="button"');
						echo form_input('employee_search','','class="search_area" ');			
		 			echo form_close();
	    		echo '</div>';
				echo "<div class='vehicle_div' style='align:center; margin-top:15px; margin-bottom:5px'></div>";
	echo "<table width='100%'>";		
		echo "<thead style='text-align:left'>";
				echo "<th>";
				echo "</td>";
				echo "<th>";
					echo "ID zamest.";
				echo "</th>";
				echo "<th>";
					echo "Meno a priezvisko";
				echo "</th>";
				echo "<th>";
					echo "Mesto";
				echo "</th>";
				echo "<th>";
					echo "Kontakt";
				echo "</th>";
				echo "<th>";
					echo "E-mail";
				echo "</th>";
			echo "</thead>";
			echo "<tbody class='zoznamTable'>";						
				echo "<tr>";
					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($Employees as $Employee){
				echo "<tr>";
				echo "<td width='130px'>";
				echo "</td>";
				echo "<td width='100px'>";
				if (strlen($Employee->ID_ZAM)==1) {
							echo "0000";
							echo $Employee->ID_ZAM;
						} elseif (strlen($Employee->ID_ZAM)==2) {
							echo "000";
							echo $Employee->ID_ZAM;
						} elseif (strlen($Employee->ID_ZAM)==3) {
							echo "00";
							echo $Employee->ID_ZAM;
						} elseif (strlen($Employee->ID_ZAM)==4) {
							echo "0";
							echo $Employee->ID_ZAM;
						} else {
							echo $Employee->ID_ZAM;
						}
					
				echo "</td>";
				echo "<td width='160px'>";
					echo $Employee->Meno.' '.$Employee->Priezvisko;
				echo "</td>";
				echo "<td style='width:120px'>";
					if ($Employee->Mesto_zamestnanca==null){
						echo "<i>-nezadané-</i>";
					} else {
						echo $Employee->Mesto_zamestnanca;
					}					
				echo "</td>";
				echo "<td width='150px'>";
					if ($Employee->Tel_cislo_zamestnanca==null){
						echo "<i>-nezadané-</i>";
					} else {
						echo "+421 ".$Employee->Tel_cislo_zamestnanca;
					}					
				echo "</td>";
				echo "<td class='email_td'>";
					echo $Employee->Email;
				echo "</td>";
				echo "<td>";
					echo '<div class="button-group" style="padding-top:3px">';
						echo '<a href="'. base_url('manager/redirectEditEmployee/' . $Employee->ID_ZAM) . '" class="button danger">Upraviť</a>';
						echo '<a href="'. base_url('manager/redirectDetailEmployee/0/1/' . $Employee->ID_ZAM.'/1/2016') . '" class="button">Detail</a>';										
					echo '</div>';
				echo "</td>";
				echo "<td width='0px'>";
				echo "</td>";
			echo "</tr>";
				
				}
			echo "</tbody>";								
		echo "</table>";
		echo "<div class='vehicle_div' style='align:center; margin-top:10px; margin-bottom:10px'></div>";
		echo '</div>';	
		echo $this->pagination->create_links();	
			} elseif ($Active==1){
				echo '<a href="'. base_url() . 'manager/getAllEmployees" class="button">Všetci zamestnanci</a>';
				echo '<a href="'. base_url() . 'manager/getManagers" class="button active">Manažéri</a>';
				echo '<a href="'. base_url() . 'manager/getLeadEmployees" class="button">Vedúci</a>';
				echo '<a href="'. base_url() . 'manager/getDrivers" class="button">Vodiči</a>';
				echo '<a href="'. base_url() . 'manager/getEmployees" class="button">Zamestnanci</a>';
				echo '</div>';
				echo '<div class="button-group" style="margin-left:50px;margin-top:10px;">';
		 			echo form_open(base_url() . 'manager/searchAllEmployees/1','onkeypress="return event.keyCode != 13;"');	  			   			
						echo form_submit('submit_search', 'Hľadať', 'class="button"');
						echo form_input('employee_search','','class="search_area" ');			
		 			echo form_close();
	    		echo '</div>';
								echo "<div class='vehicle_div' style='align:center; margin-top:15px; margin-bottom:5px'></div>";
		echo "<table width='100%'>";		
		echo "<thead style='text-align:left'>";
				echo "<th>";
				echo "</td>";
				echo "<th>";
					echo "ID zamest.";
				echo "</th>";
				echo "<th>";
					echo "Meno a priezvisko";
				echo "</th>";
				echo "<th>";
					echo "Mesto";
				echo "</th>";
				echo "<th>";
					echo "Kontakt";
				echo "</th>";
				echo "<th>";
					echo "E-mail";
				echo "</th>";
			echo "</thead>";
			echo "<tbody class='zoznamTable'>";						
				echo "<tr>";
					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($Employees as $Employee){
				echo "<tr>";
				echo "<td width='130px'>";
				echo "</td>";
				echo "<td width='100px'>";
				if (strlen($Employee->ID_ZAM)==1) {
							echo "0000";
							echo $Employee->ID_ZAM;
						} elseif (strlen($Employee->ID_ZAM)==2) {
							echo "000";
							echo $Employee->ID_ZAM;
						} elseif (strlen($Employee->ID_ZAM)==3) {
							echo "00";
							echo $Employee->ID_ZAM;
						} elseif (strlen($Employee->ID_ZAM)==4) {
							echo "0";
							echo $Employee->ID_ZAM;
						} else {
							echo $Employee->ID_ZAM;
						}
					
				echo "</td>";
				echo "<td width='160px'>";
					echo $Employee->Meno.' '.$Employee->Priezvisko;
				echo "</td>";
				echo "<td width='120px'>";
					if ($Employee->Mesto_zamestnanca==null){
						echo "<i>-nezadané-</i>";
					} else {
						echo $Employee->Mesto_zamestnanca;
					}					
				echo "</td>";
				echo "<td width='150px'>";
					if ($Employee->Tel_cislo_zamestnanca==null){
						echo "<i>-nezadané-</i>";
					} else {
						echo "+421 ".$Employee->Tel_cislo_zamestnanca;
					}					
				echo "</td>";
				echo "<td class='email_td'>";
					echo $Employee->Email;
				echo "</td>";
				echo "<td>";
					echo '<div class="button-group" style="padding-top:3px">';
						echo '<a href="'. base_url('manager/redirectEditEmployee/' . $Employee->ID_ZAM) . '" class="button danger">Upraviť</a>';
						echo '<a href="'. base_url('manager/redirectDetailEmployee/1/1/' . $Employee->ID_ZAM.'/1/2016') . '" class="button">Detail</a>';										
					echo '</div>';
				echo "</td>";
				echo "<td>";
				echo "</td>";
			echo "</tr>";	
				}
			echo "</tbody>";		
		echo "</table>";
		echo "<div class='vehicle_div' style='align:center; margin-top:15px; margin-bottom:10px'></div>";
		echo '</div>';	
		echo $this->pagination->create_links();	
			} elseif ($Active==2){
				echo '<a href="'. base_url() . 'manager/getAllEmployees" class="button">Všetci zamestnanci</a>';
				echo '<a href="'. base_url() . 'manager/getManagers" class="button">Manažéri</a>';
				echo '<a href="'. base_url() . 'manager/getLeadEmployees" class="button  active">Vedúci</a>';
				echo '<a href="'. base_url() . 'manager/getDrivers" class="button">Vodiči</a>';
				echo '<a href="'. base_url() . 'manager/getEmployees" class="button">Zamestnanci</a>';
				echo '</div>';
				echo '<div class="button-group" style="margin-left:50px;margin-top:10px;">';
		 			echo form_open(base_url() . 'manager/searchAllEmployees/2','onkeypress="return event.keyCode != 13;"');	  			   			
						echo form_submit('submit_search', 'Hľadať', 'class="button"');
						echo form_input('employee_search','','class="search_area" ');			
		 			echo form_close();
	    		echo '</div>';
								echo "<div class='vehicle_div' style='align:center; margin-top:15px; margin-bottom:5px'></div>";
		echo "<table width='100%'>";		
		echo "<thead style='text-align:left'>";
				echo "<th>";
				echo "</td>";
				echo "<th>";
					echo "ID zamest.";
				echo "</th>";
				echo "<th>";
					echo "Meno a priezvisko";
				echo "</th>";
				echo "<th>";
					echo "Mesto";
				echo "</th>";
				echo "<th>";
					echo "Kontakt";
				echo "</th>";
				echo "<th>";
					echo "E-mail";
				echo "</th>";
			echo "</thead>";
			echo "<tbody class='zoznamTable'>";						
				echo "<tr>";
					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($Employees as $Employee){
				echo "<tr>";
				echo "<td width='130px'>";
				echo "</td>";
				echo "<td width='100px'>";
				if (strlen($Employee->ID_ZAM)==1) {
							echo "0000";
							echo $Employee->ID_ZAM;
						} elseif (strlen($Employee->ID_ZAM)==2) {
							echo "000";
							echo $Employee->ID_ZAM;
						} elseif (strlen($Employee->ID_ZAM)==3) {
							echo "00";
							echo $Employee->ID_ZAM;
						} elseif (strlen($Employee->ID_ZAM)==4) {
							echo "0";
							echo $Employee->ID_ZAM;
						} else {
							echo $Employee->ID_ZAM;
						}
					
				echo "</td>";
				echo "<td width='160px'>";
					echo $Employee->Meno.' '.$Employee->Priezvisko;
				echo "</td>";
				echo "<td width='120px'>";
					if ($Employee->Mesto_zamestnanca==null){
						echo "<i>-nezadané-</i>";
					} else {
						echo $Employee->Mesto_zamestnanca;
					}					
				echo "</td>";
				echo "<td width='150px'>";
					if ($Employee->Tel_cislo_zamestnanca==null){
						echo "<i>-nezadané-</i>";
					} else {
						echo "+421 ".$Employee->Tel_cislo_zamestnanca;
					}					
				echo "</td>";
				echo "<td class='email_td'>";
					echo $Employee->Email;
				echo "</td>";
				echo "<td>";
					echo '<div class="button-group" style="padding-top:3px">';
						echo '<a href="'. base_url('manager/redirectEditEmployee/' . $Employee->ID_ZAM) . '" class="button danger">Upraviť</a>';
						echo '<a href="'. base_url('manager/redirectDetailEmployee/2/1/' . $Employee->ID_ZAM.'/1/2016') . '" class="button">Detail</a>';										
					echo '</div>';
				echo "</td>";
				echo "<td>";
				echo "</td>";
			echo "</tr>";	
				}
			echo "</tbody>";		
		echo "</table>";
		echo "<div class='vehicle_div' style='align:center; margin-top:10px; margin-bottom:10px'></div>";
		echo '</div>';	
		echo $this->pagination->create_links();	
			} elseif ($Active==3){
				echo '<a href="'. base_url() . 'manager/getAllEmployees" class="button">Všetci zamestnanci</a>';
				echo '<a href="'. base_url() . 'manager/getManagers" class="button">Manažéri</a>';
				echo '<a href="'. base_url() . 'manager/getLeadEmployees" class="button">Vedúci</a>';
				echo '<a href="'. base_url() . 'manager/getDrivers" class="button active">Vodiči</a>';
				echo '<a href="'. base_url() . 'manager/getEmployees" class="button">Zamestnanci</a>';
				echo '</div>';
				echo '<div class="button-group" style="margin-left:50px;margin-top:10px;">';
		 			echo form_open(base_url() . 'manager/searchAllEmployees/3','onkeypress="return event.keyCode != 13;"');	  			   			
						echo form_submit('submit_search', 'Hľadať', 'class="button"');
						echo form_input('employee_search','','class="search_area" ');			
		 			echo form_close();
	    		echo '</div>';
				echo "<div class='vehicle_div' style='align:center; margin-top:15px; margin-bottom:5px'></div>";
		echo "<table width='100%'>";		
		echo "<thead style='text-align:left'>";
				echo "<th>";
				echo "</td>";
				echo "<th>";
					echo "ID zamest.";
				echo "</th>";
				echo "<th>";
					echo "Meno a priezvisko";
				echo "</th>";
				echo "<th>";
					echo "Mesto";
				echo "</th>";
				echo "<th>";
					echo "Kontakt";
				echo "</th>";
				echo "<th>";
					echo "E-mail";
				echo "</th>";
			echo "</thead>";
			echo "<tbody class='zoznamTable'>";						
				echo "<tr>";
					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($Employees as $Employee){
				echo "<tr>";
				echo "<td width='130px'>";
				echo "</td>";
				echo "<td width='100px'>";
				if (strlen($Employee->ID_ZAM)==1) {
							echo "0000";
							echo $Employee->ID_ZAM;
						} elseif (strlen($Employee->ID_ZAM)==2) {
							echo "000";
							echo $Employee->ID_ZAM;
						} elseif (strlen($Employee->ID_ZAM)==3) {
							echo "00";
							echo $Employee->ID_ZAM;
						} elseif (strlen($Employee->ID_ZAM)==4) {
							echo "0";
							echo $Employee->ID_ZAM;
						} else {
							echo $Employee->ID_ZAM;
						}
					
				echo "</td>";
				echo "<td width='160px'>";
					echo $Employee->Meno.' '.$Employee->Priezvisko;
				echo "</td>";
				echo "<td width='120px'>";
					if ($Employee->Mesto_zamestnanca==null){
						echo "<i>-nezadané-</i>";
					} else {
						echo $Employee->Mesto_zamestnanca;
					}					
				echo "</td>";
				echo "<td width='150px'>";
					if ($Employee->Tel_cislo_zamestnanca==null){
						echo "<i>-nezadané-</i>";
					} else {
						echo "+421 ".$Employee->Tel_cislo_zamestnanca;
					}					
				echo "</td>";
				echo "<td class='email_td'>";
					echo $Employee->Email;
				echo "</td>";
				echo "<td>";
							echo '<div class="button-group" style="margin-top:3px">';
						echo '<a href="'. base_url('manager/redirectEditEmployee/' . $Employee->ID_ZAM) . '" class="button danger">Upraviť</a>';
						echo '<a href="'. base_url('manager/redirectDetailEmployee/3/1/' . $Employee->ID_ZAM.'/1/2016') . '" class="button">Detail</a>';										
					echo '</div>';
				echo "</td>";
				echo "<td>";
				echo "</td>";
			echo "</tr>";	
				}	
			echo "</tbody>";	
		echo "</table>";
		echo "<div class='vehicle_div' style='align:center; margin-top:10px; margin-bottom:10px'></div>";
		echo '</div>';	
		echo $this->pagination->create_links();	
			} elseif ($Active==4){
				echo '<a href="'. base_url() . 'manager/getAllEmployees" class="button">Všetci zamestnanci</a>';
				echo '<a href="'. base_url() . 'manager/getManagers" class="button">Manažéri</a>';
				echo '<a href="'. base_url() . 'manager/getLeadEmployees" class="button">Vedúci</a>';
				echo '<a href="'. base_url() . 'manager/getDrivers" class="button">Vodiči</a>';
				echo '<a href="'. base_url() . 'manager/getEmployees" class="button active">Zamestnanci</a>';
				echo '</div>';
				echo '<div class="button-group" style="margin-left:50px;margin-top:10px;">';
		 			echo form_open(base_url() . 'manager/searchAllEmployees/4','onkeypress="return event.keyCode != 13;"');	  			   			
						echo form_submit('submit_search', 'Hľadať', 'class="button"');
						echo form_input('employee_search','','class="search_area" ');			
		 			echo form_close();
	    		echo '</div>';
				echo "<div class='vehicle_div' style='align:center; margin-top:15px; margin-bottom:5px'></div>";						
		echo "<table width='100%'>";		
		echo "<thead style='text-align:left'>";
				echo "<th>";
				echo "</td>";
				echo "<th>";
					echo "ID zamest.";
				echo "</th>";
				echo "<th>";
					echo "Meno a priezvisko";
				echo "</th>";
				echo "<th>";
					echo "Mesto";
				echo "</th>";
				echo "<th>";
					echo "Kontakt";
				echo "</th>";
				echo "<th>";
					echo "E-mail";
				echo "</th>";
			echo "</thead>";
			echo "<tbody class='zoznamTable'>";						
				echo "<tr>";
					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($Employees as $Employee){
				echo "<tr>";
				echo "<td width='130px'>";
				echo "</td>";
				echo "<td width='100px'>";
				if (strlen($Employee->ID_ZAM)==1) {
							echo "0000";
							echo $Employee->ID_ZAM;
						} elseif (strlen($Employee->ID_ZAM)==2) {
							echo "000";
							echo $Employee->ID_ZAM;
						} elseif (strlen($Employee->ID_ZAM)==3) {
							echo "00";
							echo $Employee->ID_ZAM;
						} elseif (strlen($Employee->ID_ZAM)==4) {
							echo "0";
							echo $Employee->ID_ZAM;
						} else {
							echo $Employee->ID_ZAM;
						}
					
				echo "</td>";
				echo "<td width='160px'>";
					echo $Employee->Meno.' '.$Employee->Priezvisko;
				echo "</td>";
				echo "<td style='width:120px'>";
					if ($Employee->Mesto_zamestnanca==null){
						echo "<i>-nezadané-</i>";
					} else {
						echo $Employee->Mesto_zamestnanca;
					}					
				echo "</td>";
				echo "<td width='150px'>";
					if ($Employee->Tel_cislo_zamestnanca==null){
						echo "<i>-nezadané-</i>";
					} else {
						echo "+421 ".$Employee->Tel_cislo_zamestnanca;
					}					
				echo "</td>";
				echo "<td class='email_td'>";
					echo $Employee->Email;
				echo "</td>";
				echo "<td>";
					echo '<div class="button-group" style="padding-top:3px">';
						echo '<a href="'. base_url('manager/redirectEditEmployee/' . $Employee->ID_ZAM) . '" class="button danger">Upraviť</a>';
						echo '<a href="'. base_url('manager/redirectDetailEmployee/4/1/' . $Employee->ID_ZAM.'/1/2016') . '" class="button">Detail</a>';										
					echo '</div>';
				echo "</td>";
				echo "<td>";
				echo "</td>";
			echo "</tr>";	
				}
			echo "</tbody>";		
		echo "</table>";
		echo "<div class='vehicle_div' style='align:center; margin-top:10px; margin-bottom:10px'></div>";
		echo '</div>';	
		echo $this->pagination->create_links();	
			}
			
			
		
		
	} else {
		redirect(base_url('main/restricted'));
	}	
?>
	


