<script>
function checkFirstName(){
	if(document.getElementById("editEmployeeFirst").value!=""){
		if(!document.getElementById("editEmployeeFirst").value.match(/^[A-Za-záÁéÉíÍĺĹóÓŕŔúÚýÝčČďĎľĽňŇšŠťŤžŽäô]+$/)){
			document.getElementById("firstStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18' style='margin-left:10px;margin-top:6px'>";;	
			document.getElementById("firstError").innerHTML="Iba písmená abecedy!";	
			document.getElementById("firstChecker").innerHTML="0";						
		}else if(document.getElementById("editEmployeeFirst").value.length<3){
			document.getElementById("firstStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18' style='margin-left:10px;margin-top:6px'>";;	
			document.getElementById("firstError").innerHTML="Minimálne tri znaky!";	
			document.getElementById("firstChecker").innerHTML="0";					
		}else{
			document.getElementById("firstStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/yes.png' height='17' width='18' style='margin-left:10px;margin-top:6px'>";;	
			document.getElementById("firstError").innerHTML="";	
			document.getElementById("firstChecker").innerHTML="1";					
		}	
	}else{
		document.getElementById("firstStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18' style='margin-left:10px;margin-top:6px'>";;	
		document.getElementById("firstError").innerHTML="";	
		document.getElementById("firstChecker").innerHTML="0";	
	}	
}

function checkLastName(){
	if(document.getElementById("editEmployeeLast").value!=""){
		if(!document.getElementById("editEmployeeLast").value.match(/^[A-Za-záÁéÉíÍĺĹóÓŕŔúÚýÝčČďĎľĽňŇšŠťŤžŽäô]+$/)){
			document.getElementById("lastStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18' style='margin-left:10px;margin-top:6px'>";;	
			document.getElementById("lastError").innerHTML="Iba písmená abecedy!";	
			document.getElementById("lastChecker").innerHTML="0";						
		}else if(document.getElementById("editEmployeeLast").value.length<3){
			document.getElementById("lastStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18' style='margin-left:10px;margin-top:6px'>";;	
			document.getElementById("lastError").innerHTML="Minimálne tri znaky!";	
			document.getElementById("lastChecker").innerHTML="0";					
		}else{
			document.getElementById("lastStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/yes.png' height='17' width='18' style='margin-left:10px;margin-top:6px'>";;	
			document.getElementById("lastError").innerHTML="";	
			document.getElementById("lastChecker").innerHTML="1";					
		}	
	}else{
		document.getElementById("lastStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18' style='margin-left:10px;margin-top:6px'>";;	
		document.getElementById("lastError").innerHTML="";	
		document.getElementById("lastChecker").innerHTML="0";	
	}	
}

function checkEmail(){
	function isRealEmail(email) {
		var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
		return re.test(email);
	}	
	if(document.getElementById("editEmployeeEmail").value!=""){
		if(!isRealEmail(document.getElementById("editEmployeeEmail").value)){
			document.getElementById("emailStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18' style='margin-left:10px;margin-top:6px'>";;	
			document.getElementById("emailError").innerHTML="Nesprávny formát emailu.";	
			document.getElementById("emailChecker").innerHTML="0";	
		}else{	
			document.getElementById("emailStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/yes.png' height='17' width='18' style='margin-left:10px;margin-top:6px'>";;	
			document.getElementById("emailError").innerHTML="";	
			document.getElementById("emailChecker").innerHTML="1";							
		}		
	}else{
		document.getElementById("emailStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18' style='margin-left:10px;margin-top:6px'>";;	
		document.getElementById("emailError").innerHTML="";	
		document.getElementById("emailChecker").innerHTML="0";	
	};
};

function checkBirthDate(){
	if(document.getElementById("editEmployeeBirth").value!=""){				
		if(!document.getElementById("editEmployeeBirth").value.match(/^[0-9/]+$/)){
			document.getElementById("birthStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18' style='margin-left:10px;margin-top:6px'>";	
			document.getElementById("birthError").innerHTML="Iba číslice a lomka.";	
			document.getElementById("birthChecker").innerHTML="0";
		}else if((document.getElementById("editEmployeeBirth").value.length)!=11){
			document.getElementById("birthStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18' style='margin-left:10px;margin-top:6px'>";;	
			document.getElementById("birthError").innerHTML="Rodné číslo ma 11 znakov.";	
			document.getElementById("birthChecker").innerHTML="0";	
		}else{
			document.getElementById("birthStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/yes.png' height='17' width='18' style='margin-left:10px;margin-top:6px'>";	
			document.getElementById("birthError").innerHTML="";	
			document.getElementById("birthChecker").innerHTML="1";	
		}				
	}else{
		document.getElementById("birthStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18' style='margin-left:10px;margin-top:6px'>";	
		document.getElementById("birthError").innerHTML="";	
		document.getElementById("birthChecker").innerHTML="0";	
	}
}

document.addEventListener("keyup", function(){
	if(document.getElementById("firstChecker").innerHTML=="1" && document.getElementById("lastChecker").innerHTML=="1" && document.getElementById("emailChecker").innerHTML=="1" && document.getElementById("birthChecker").innerHTML=="1" && document.getElementById("typeChecker").innerHTML=="1"){
		document.getElementById("submitSpan").style.visibility = "visible";	
		document.getElementById("finallyCheckerEmployee").innerHTML="<h3 style='padding-top:12px'><img src='http://martinbendik.studenthosting.sk/pictures/yes.png' height='20' width='20' align='middle' style='padding-bottom:12px;padding-right:15px'>Editácia zamestnanca</h3>";					
	}else{
		document.getElementById("submitSpan").style.visibility = "hidden";
		document.getElementById("finallyCheckerEmployee").innerHTML="<h3 style='padding-top:12px'><img src='http://martinbendik.studenthosting.sk/pictures/Exclamation.png' height='20' width='20' align='middle' style='padding-bottom:12px;padding-right:15px'>Editácia zamestnanca</h3>";
	} 
});
</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')); 	
			
  		echo form_open(base_url('manager/updateEmployee/' . $Employee->ID_ZAM),'onkeypress="return event.keyCode != 13;"');			
		echo '<div id="default_container">';
			echo '<span id="finallyCheckerEmployee">';
				echo "<h3 style='padding-top:12px'><img src='http://martinbendik.studenthosting.sk/pictures/yes.png' height='20' width='20' align='middle' style='padding-bottom:12px;padding-right:15px'>Editácia zamestnanca</h3>";
			echo '</span>';
				echo '<div id="errors" >';
					echo validation_errors(); 
				echo "</div>";
			echo '<table id="newCustomerInfoTable" style="margin-left:50px; margin-top:10px">';				
				echo "<tr>";
					echo "<td  style='width:150px'>";
						echo "Meno:";
					echo "</td>";
					echo "<td>";
						echo form_input("editEmployeeFirst",$Employee->Meno , 'onkeyup="checkFirstName()" id="editEmployeeFirst" class="login_textarea"');	
					echo "</td>";
					echo "<td id='firstStatus'>";
						echo "<img src='http://martinbendik.studenthosting.sk/pictures/yes.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";
					echo "</td>";
					echo "<td id='firstError'>";
					echo "</td>";
					echo "<td id='firstChecker' hidden>";
						echo "1";
					echo "</td>";
				echo "</tr>";
				
				echo "<tr>";
					echo "<td>";
						echo "Priezvisko:";
					echo "</td>";
					echo "<td>";
						echo form_input("editEmployeeLast",$Employee->Priezvisko , 'onkeyup="checkLastName()" id="editEmployeeLast"  class="login_textarea"');	
					echo "</td>";
					echo "<td id='lastStatus'>";
						echo "<img src='http://martinbendik.studenthosting.sk/pictures/yes.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";
					echo "</td>";
					echo "<td id='lastError'>";
					echo "</td>";
					echo "<td id='lastChecker' hidden>";
						echo "1";
					echo "</td>";
				echo "</tr>";
				
				echo "<tr>";
					echo "<td>";
						echo "Email:";
					echo "</td>";
					echo "<td>";
						echo form_input("editEmployeeEmail",$Employee->Email , 'onkeyup="checkEmail()" id="editEmployeeEmail" class="login_textarea"');	
					echo "</td>";
					echo "<td id='emailStatus'>";
						echo "<img src='http://martinbendik.studenthosting.sk/pictures/yes.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";
					echo "</td>";
					echo "<td id='emailError'>";
					echo "</td>";
					echo "<td id='emailChecker' hidden>";
						echo "1";
					echo "</td>";
				echo "</tr>";
				
				echo "<tr>";
					echo "<td>";
						echo "Rodné číslo:";
					echo "</td>";
					echo "<td>";
						echo form_input("editEmployeeBirth", $Employee->Rodne_cislo , 'onkeyup="checkBirthDate()" id="editEmployeeBirth" class="login_textarea"');	
					echo "</td>";
					echo "<td id='birthStatus'>";
						echo "<img src='http://martinbendik.studenthosting.sk/pictures/yes.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";
					echo "</td>";
					echo "<td id='birthError'>";
					
					echo "</td>";
					echo "<td id='birthChecker' hidden>";
						echo "1";
					echo "</td>";
				echo "</tr>";
					
				echo "<tr>";
					echo "<td>";
						echo "Typ zamestnanca:";
					echo "</td>";
					echo "<td>";
					if($Employee->ID_TYP_Z>1){
						$options = array(
                  			'2'  => 'Vedúci inventúr',
                  			'3'  => 'Šofér',
                  			'4'  => 'Zamestnanec',														  
               			);	
					}else{
						$options = array(
                  			'1'  => 'Manažér',														  
               			);	
					}
						
						echo form_dropdown('editEmployeeType', $options, $Employee->ID_TYP_Z , 'onclick="checkType()" id="editEmployeeType" class="login_textarea2"' );	
					echo "</td>";
					echo "<td id='typeStatus'>";
						echo "<img src='http://martinbendik.studenthosting.sk/pictures/yes.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";
					echo "</td>";
					echo "<td id='typeError'>";
					echo "</td>";
					echo "<td id='typeChecker' hidden>";
						echo "1";
					echo "</td>";
				echo "</tr>";
				echo "<tr>";
					echo "<td>";
						echo "Status zamestnanca:";
					echo "</td>";
					echo "<td>";
					if($Employee->ID_TYP_Z>1){
						$options2 = array(
                  			'1'  => 'Aktívny',
                  			'2'  => 'Neaktívny',
                  			'3'  => 'Prepustený'														  
               			);	
					}else{
						$options2 = array(
                  			'1'  => 'Aktívny',														  
               			);	
					}					
						echo form_dropdown('editEmployeeStatus', $options2, $Employee->Status , ' class="login_textarea2"' );	
					echo "</td>";
					echo "<td id='typeStatus'>";
						echo "<img src='http://martinbendik.studenthosting.sk/pictures/yes.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";
					echo "</td>";					
				echo "</tr>";
			echo "</table>";
		echo "<div class='vehicle_div' style='align:center; margin-top:15px;'></div>";				
		echo '<div class="button-group" style="margin-left:50px;margin-top:20px;">';
			echo '<a href="javascript:window.history.go(-1);" class="button">Späť</a>';
			echo '<span id="submitSpan" style="visibility:visible">';
				echo form_submit('create_employee_2' , 'Uložiť', 'class="button"');
			echo '</span>';
		echo '</div>';
		
		echo "</div>";
		
		
		
		
			
			
			
			
			
	
	
	
	} else {
		redirect(base_url('main/restricted'));
	}	
?>
	


