<script>
	function showLoading(){
		var confBackGr = document.getElementById("confirmBackgr");						
		var dialog = document.getElementById("loadingBox");	
		document.getElementById("loadingBox").innerHTML = "<img src='http://martinbendik.studenthosting.sk/pictures/loading.gif' style='width:150px'><br><span style='width:150px;margin-left:40px'>Nahrávam...</span>";
		confBackGr.style.display = "block";
		dialog.style.display = "block";	
		var width = window.innerWidth;
		var height = window.innerHeight; 
		dialog.style.left = ((width/2)-25)+"px";
		dialog.style.top = "200px";
	}
	
	function destroyDialog(){
		var confBackGr = document.getElementById("confirmBackgr");	
		var dialog = document.getElementById("loadingBox");
		confBackGr.style.display = "none";
		dialog.style.display = "none";
	}

	function showDiv(){
		if(document.getElementById("divForNewSettings").style.visibility=="visible"){
			document.getElementById("divForNewSettings").style.visibility="hidden";
			document.getElementById("newSettingsButton").className="button";	
		}else{
			document.getElementById("divForNewSettings").style.visibility="visible";
			document.getElementById("newSettingsButton").className="button active";
		}
	}
	
	function checkLead(){
		if(document.getElementById("newSalaryLead").value!=""){
			if(document.getElementById("newSalaryLead").value.match(/^[0-9.]+$/)){
				document.getElementById("leadStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/yes.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";	
				document.getElementById("leadChecker").innerHTML="1";	
			}else{
				document.getElementById("leadStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";	
				document.getElementById("leadChecker").innerHTML="0";		
			}	
		}else{
			document.getElementById("leadStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";	
			document.getElementById("leadChecker").innerHTML="0";
		}
	}
	
	function checkLead(){
		if(document.getElementById("newSalaryLead").value!=""){
			if(document.getElementById("newSalaryLead").value.match(/^[0-9.]+$/)){
				document.getElementById("leadStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/yes.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";	
				document.getElementById("leadChecker").innerHTML="1";	
			}else{
				document.getElementById("leadStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";	
				document.getElementById("leadChecker").innerHTML="0";		
			}	
		}else{
			document.getElementById("leadStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";	
			document.getElementById("leadChecker").innerHTML="0";
		}
	}
	
	function checkDriver(){
		if(document.getElementById("newSalaryDriver").value!=""){
			if(document.getElementById("newSalaryDriver").value.match(/^[0-9.]+$/)){
				document.getElementById("driverStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/yes.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";	
				document.getElementById("driverChecker").innerHTML="1";	
			}else{
				document.getElementById("driverStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";	
				document.getElementById("driverChecker").innerHTML="0";		
			}	
		}else{
			document.getElementById("driverStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";	
			document.getElementById("driverChecker").innerHTML="0";
		}
	}
	
	function checkEmployee(){
		if(document.getElementById("newSalaryEmployee").value!=""){
			if(document.getElementById("newSalaryEmployee").value.match(/^[0-9.]+$/)){
				document.getElementById("employeeStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/yes.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";	
				document.getElementById("employeeChecker").innerHTML="1";	
			}else{
				document.getElementById("employeeStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";	
				document.getElementById("employeeChecker").innerHTML="0";		
			}	
		}else{
			document.getElementById("employeeStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";	
			document.getElementById("employeeChecker").innerHTML="0";
		}
	}
	
	function checkKm(){
		if(document.getElementById("newSalaryKm").value!=""){
			if(document.getElementById("newSalaryKm").value.match(/^[0-9.,]+$/)){
				document.getElementById("kmStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/yes.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";	
				document.getElementById("kmChecker").innerHTML="1";	
			}else{
				document.getElementById("kmStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";	
				document.getElementById("kmChecker").innerHTML="0";		
			}	
		}else{
			document.getElementById("kmStatus").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";	
			document.getElementById("kmChecker").innerHTML="0";
		}
	}
	
	document.addEventListener("keyup", function(){
		if(document.getElementById("leadChecker").innerHTML=="1" && document.getElementById("driverChecker").innerHTML=="1" && document.getElementById("employeeChecker").innerHTML=="1" && document.getElementById("kmChecker").innerHTML=="1"){
			document.getElementById("submitSpan").style.visibility = "visible";	
		}else{
			document.getElementById("submitSpan").style.visibility = "hidden";
		}
	});
	
</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('mydatetime_helper');
		echo '<div id="confirmBackgr">';
		echo '</div>';
			echo '<div id="loadingBox" style="border:0px;width:100px;text-align:left">';
			echo '</div>';
		echo '<div id="default_container" style="padding-right: ">';
			echo '<div class="button-group" style="margin-left:50px;margin-top:10px;">';
			switch($mode){
				case 1:
					echo '<a href="'.base_url('manager/redirectSettings/1/'.$year.'/'.$month).'" class="button active">Vyplatné pásky</a>';
					echo '<a href="'.base_url('manager/redirectSettings/2/'.$year.'/'.$month).'" class="button">Mesačné uzávierky</a>';
					echo '<a href="'.base_url('manager/redirectSettings/3/'.$year.'/'.$month).'" class="button">Nastavenie miezd</a>';
						echo '<a href="'.base_url('manager/redirectSettings/'.$mode.'/'.($year-1).'/'.$month).'" class="button" style="margin-right:0px;margin-left:50px">&laquo;</a>';
						echo '<a href="'.base_url('manager/redirectSettings/'.$mode.'/'.$year.'/'.($month-1)).'" class="button" style="margin-right:10px;">&lsaquo;</a>';
						echo '<a href="'.base_url('manager/redirectSettings/'.$mode.'/'.$year.'/'.($month-1)).'" class="button" style="width:100px">'.getNameOfMonth(($month-1),$year).'</a>';
						echo '<a href="" class="button active" style="width:100px">'.getNameOfMonth($month,$year).'</a>';
						echo '<a href="'.base_url('manager/redirectSettings/'.$mode.'/'.($year).'/'.($month+1)).'" class="button" style="margin-right:10px;width:100px">'.getNameOfMonth(($month+1),$year).'</a>';											
						echo '<a href="'.base_url('manager/redirectSettings/'.$mode.'/'.$year.'/'.($month+1)).'" class="button" style="margin-right:0px;">&rsaquo;</a>';					
						echo '<a href="'.base_url('manager/redirectSettings/'.$mode.'/'.($year+1).'/'.$month).'" class="button" style="margin-right:10px;">&raquo;</a>';
					echo '<a href="'.base_url('manager/redirectSettings/'.$mode.'/'.date("Y",time())."/".date("n",time())).'" style="margin-left:10px;" class="button">Vynulovať</a>';
					echo '</div>';
					echo "<div class='vehicle_div' style='align:center; margin-top:15px; margin-bottom:5px'></div>";
						echo '<div class="button-group" style="margin-left:50px;margin-top:15px;">';
						if($year>=date('Y',time()) AND $month>date('n',time())){
							echo "<h11>Nie je možné zobraziť budúci mesiac.</h11>";	
						}else if($year<=2015){
							echo "<h11>V tento čas ešte nebol systém zavedený.</h11>";
						}else{

							if((date('Y',time())."-".date('n',time()))==($year."-".$month)){
								echo "<img src='".base_url("pictures/Exclamation.png")."' style='width:50px; margin-left:0px; margin-bottom:-10px'>";
								echo "<h11 style='margin-left:10px;padding-bottom:5px;padding-top:0px'>Ešte nie je možné vytvoriť vyplatné pásky aktualného mesiaca.</h11>";	
							}else{
								echo '<a href="'.base_url('settings/createPayCheckForMonthPDF/'.$mode."/1/".$year."/".$month).'" class="button" onclick="showLoading()">Zobraziť PDF</a>';
							}	
						}	
						echo '</div>';
					echo "<div class='vehicle_div' style='align:center; margin-top:15px; margin-bottom:5px'></div>";
						echo '<div class="button-group" style="margin-left:50px;margin-top:15px;">';
							echo '<a class="button" href='.base_url('main/manager').'>Zrušiť</a>';
						echo '</div>';
					echo '</div>';	 
				break;
				case 2:
					echo '<a href="'.base_url('manager/redirectSettings/1/'.$year.'/'.$month).'" class="button ">Vyplatné pásky</a>';
					echo '<a href="'.base_url('manager/redirectSettings/2/'.$year.'/'.$month).'" class="button active">Mesačné uzávierky</a>';
					echo '<a href="'.base_url('manager/redirectSettings/3/'.$year.'/'.$month).'" class="button">Nastavenie miezd</a>';					
						echo '<a href="'.base_url('manager/redirectSettings/'.$mode.'/'.($year-1).'/'.$month).'" class="button" style="margin-right:0px;margin-left:50px">&laquo;</a>';
						echo '<a href="'.base_url('manager/redirectSettings/'.$mode.'/'.$year.'/'.($month-1)).'" class="button" style="margin-right:10px;">&lsaquo;</a>';
						echo '<a href="'.base_url('manager/redirectSettings/'.$mode.'/'.$year.'/'.($month-1)).'" class="button" style="width:100px">'.getNameOfMonth(($month-1),$year).'</a>';
						echo '<a href="" class="button active" style="width:100px">'.getNameOfMonth($month,$year).'</a>';
						echo '<a href="'.base_url('manager/redirectSettings/'.$mode.'/'.($year).'/'.($month+1)).'" class="button" style="margin-right:10px;width:100px">'.getNameOfMonth(($month+1),$year).'</a>';											
						echo '<a href="'.base_url('manager/redirectSettings/'.$mode.'/'.$year.'/'.($month+1)).'" class="button" style="margin-right:0px;">&rsaquo;</a>';					
						echo '<a href="'.base_url('manager/redirectSettings/'.$mode.'/'.($year+1).'/'.$month).'" class="button" style="margin-right:10px;">&raquo;</a>';
						echo '<a href="'.base_url('manager/redirectSettings/'.$mode.'/'.date("Y",time())."/".date("n",time())).'" style="margin-left:10px;" class="button">Vynulovať</a>';
					echo '</div>';
					echo "<div class='vehicle_div' style='align:center; margin-top:15px; margin-bottom:5px'></div>";
					echo '<div class="button-group" style="margin-left:50px;margin-top:15px;">';
					if($year>=date('Y',time()) AND $month>date('n',time())){
							echo "<h11>Nie je možné zobraziť budúci mesiac.</h11>";	
					}else if($year<=2015){
							echo "<h11>V tento čas ešte nebol systém zavedený.</h11>";
					}else{

						if((date('Y',time())."-".date('n',time()))==($year."-".$month)){
							echo "<img src='".base_url("pictures/Exclamation.png")."' style='width:50px; margin-left:0px; margin-bottom:-10px'>";
							echo "<h11 style='margin-left:10px;padding-bottom:5px;padding-top:0px'>Ešte nie je možné vytvoriť uzávierku aktualného mesiaca.</h11>";	
						}else{
							echo '<a href="'.base_url('settings/createSummaryPerMonthPDF/'.$mode."/1/".$year."/".$month).'" class="button" onclick="showLoading()">Zobraziť PDF</a>';							
						}
					}
					echo '</div>';
					echo "<div class='vehicle_div' style='align:center; margin-top:15px; margin-bottom:5px'></div>";
						echo '<div class="button-group" style="margin-left:50px;margin-top:15px;">';
							echo '<a class="button" href='.base_url('main/manager').'>Zrušiť</a>';
						echo '</div>';
					echo '</div>';	 
				break;
				case 3:
					echo '<a href="'.base_url('manager/redirectSettings/1/'.$year.'/'.$month).'" class="button">Vyplatné pásky</a>';
					echo '<a href="'.base_url('manager/redirectSettings/2/'.$year.'/'.$month).'" class="button">Mesačné uzávierky</a>'; 
					echo '<a href="'.base_url('manager/redirectSettings/3/'.$year.'/'.$month).'" class="button active">Nastavenie miezd</a>';
					echo '</div>';
					echo '<div class="divForNewSettings" id="divForNewSettings" >';
 			echo form_open(base_url('manager/saveNewSettings'),'onkeypress="return event.keyCode != 13;"');
			echo '<table id="newCustomerInfoTable" style="margin-left:0px; margin-top:0px">';					
				echo "<tr>";
					echo "<td  style='width:200px'>";
						echo "Hod. mzda vedúci inventúry: ";
					echo "</td>";
					echo "<td>";
						echo form_input("newSalaryLead",'' , 'onkeyup="checkLead()" id="newSalaryLead" class="login_textarea"');																 
					echo "</td>";
					echo "<td id='leadStatus'>";
						echo "<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";
					echo "</td>";
					echo "<td id='leadChecker' hidden>";
						echo "0";
					echo "</td>";
				echo "</tr>";
				echo "<tr>";
					echo "<td  style='width:200px'>";
						echo "Hod. mzda šofér: ";
					echo "</td>";
					echo "<td>";
						echo form_input("newSalaryDriver",'' , 'onkeyup="checkDriver()" id="newSalaryDriver" class="login_textarea"');																 
					echo "</td>";
					echo "<td id='driverStatus'>";
						echo "<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";
					echo "</td>";
					echo "<td id='driverChecker' hidden>";
						echo "0";
					echo "</td>";
				echo "</tr>";
				echo "<tr>";
					echo "<td  style='width:200px'>";
						echo "Hod. mzda zamestnanec: ";
					echo "</td>";
					echo "<td>";
						echo form_input("newSalaryEmployee",'' , 'onkeyup="checkEmployee()" id="newSalaryEmployee" class="login_textarea"');																 
					echo "</td>";
					echo "<td id='employeeStatus'>";
						echo "<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";
					echo "</td>";
					echo "<td id='employeeChecker' hidden>";
						echo "0";
					echo "</td>";
				echo "</tr>";
				echo "<tr>";
					echo "<td  style='width:200px'>";
						echo "Mzda za kilometer: ";
					echo "</td>";
					echo "<td>";
						echo form_input("newSalaryKm",'' , 'onkeyup="checkKm()" id="newSalaryKm" class="login_textarea"');																 
					echo "</td>";
					echo "<td id='kmStatus'>";
						echo "<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18'  style='margin-left:10px;margin-top:6px'>";
					echo "</td>";
					echo "<td id='kmChecker' hidden>";
						echo "0";
					echo "</td>";
				echo "</tr>";
			echo "</table>";
		echo '</div>';

			echo '<h3> Aktuálne nastavenie hodinových miezd </h3>';
				echo '<table id="newCustomerInfoTable" style="margin-left:50px; margin-top:10px">';
				echo "<tr>";
					echo "<td style='width:240px'>";
						echo "<b>Dátum nastavenia: </b>";
					echo "</td>";
					echo "<td>";										
						echo date('d.m.Y',strtotime($settings->Datum_nastavenia));
					echo "</td>";
				echo "</tr>";	
				
				echo "<tr>";
					echo "<td>";
						echo "<b>Hodinová mzda vedúci inventúry: </b>";
					echo "</td>";
					echo "<td>";										
						echo $settings->Vyplata_veduci_inventury." € / Hod";
					echo "</td>";
				echo "</tr>";
				
				echo "<tr>";
					echo "<td>";
						echo "<b>Hodinová mzda šofér: </b>";
					echo "</td>";
					echo "<td>";										
						echo $settings->Vyplata_sofer." € / Hod";
					echo "</td>";
				echo "</tr>";
				
				echo "<tr>";
					echo "<td>";
						echo "<b>Hodinová mzda zamestnanec: </b>";
					echo "</td>";
					echo "<td>";										
						echo $settings->Vyplata_zamestnanec." € / Hod";
					echo "</td>";
				echo "</tr>";
				
				echo "<tr>";
					echo "<td>";
						echo "<b>Mzda za odcestovaný kilometer: </b>";
					echo "</td>";
					echo "<td>";										
						echo $settings->Vyplata_kilometer." € / Km";
					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 class="button" href='.base_url('main/manager').'>Zrušiť</a>';
			echo '<span id="editSpan">';
				echo '<a class="button" id="newSettingsButton" href="#" onclick="showDiv()">Vytvoriť nové nastavenie</a>';
			echo '</span>';
			echo '<span id="submitSpan">';
				echo form_submit('input_form_submit' , 'Uložiť' ,'class="button"' );
			echo '</span>';
		echo '</div>';
				break;
			}
						
		echo '</div>';	
	} else {
		redirect(base_url('main/restricted'));
	}	
?>

	
	
	


