<?php
	
 
		
	if ($this->session->userdata('permisson')==4 OR $this->session->userdata('permisson')==3 OR $this->session->userdata('permisson')==2) {
		$CI =& get_instance();
		$CI->load->library('libraryprofile');
		switch($this->session->userdata('permisson')){
			case 4:
				$CI->libraryprofile->showMenuBarEmployee($this->session->userdata('meno'),$this->session->userdata('priezvisko'),$this->session->userdata('id_zamestnanca')); 
			break;
			case 3:
				$CI->libraryprofile->showMenuBarDriver($this->session->userdata('meno'),$this->session->userdata('priezvisko'),$this->session->userdata('id_zamestnanca'));  
			break;
			case 2: 
				$CI->libraryprofile->showMenuBarLeadEmployee($this->session->userdata('meno'),$this->session->userdata('priezvisko'),$this->session->userdata('id_zamestnanca')); 
			break;
		}
		$this->load->helper("employee_helper");
		$this->load->helper("graph_helper");
		
		echo '<div id="default_container" style="padding-right: ">';
			echo "<div style='margin-top:15px'>";
			echo '<h3 style="display:inline;margin-top:10px; border-bottom:0px">Vyplatné pásky</h3>';
				echo '<div class="button-group" style="float:right;margin-right:50px;margin-top:-5px">';
					echo '<a href="'. base_url('employee/redirectPayChecks/'.($year-1)).'" class="button" style="margin-right:10px;">&laquo;</a>';
					echo '<a href="'. base_url('employee/redirectPayChecks/'.($year-2)).'" class="button">'.($year-2).'</a>';
					echo '<a href="'. base_url('employee/redirectPayChecks/'.($year-1)).'" class="button">'.($year-1).'</a>';
					echo '<a href="" class="button active">'.$year.'</a>';
					echo '<a href="'. base_url('employee/redirectPayChecks/'.($year+1)).'" class="button">'.($year+1).'</a>';
					echo '<a href="'. base_url('employee/redirectPayChecks/'.($year+2)).'" class="button">'.($year+2).'</a>';
					echo '<a href="'. base_url('employee/redirectPayChecks/'.($year+1)).'" class="button" style="margin-left:10px;">&raquo;</a>';			
				echo '</div>';
			echo "<div class='vehicle_div' style='align:center; margin-top:15px; margin-bottom:0px'></div>";		
				if(intVal($year)<intVal(date("Y",strtotime($startDate)))){
					echo "<h3>V túto dobu ste ešte neboli zamestnancom.</h3>";
				}elseif(intVal($year)>intVal(date("Y",strtotime($endDate)))){
					echo "<h3>Ešte neboli vytvorené vyplatné pásky.</h3>";	
				}else{
					if(intVal($year)==intVal(date("Y",strtotime($startDate)))){
						$startMonth=intVal(date("m",strtotime($startDate)));
					}else{
						$startMonth=1;	
					}
					if(intVal($year)==intVal(date("Y",strtotime($endDate)))){
						$endMonth=intVal(date("m",strtotime($endDate)));
					}else{
						$endMonth=12;	
					}					
					for($i=$endMonth; $i>=$startMonth;$i--){
						echo "<table class='postTable'>";
							echo "<tr>";
								echo "<td rowspan='2' style='width:160px;'>";
									echo "&nbsp";
								echo '</td>';
								echo "<td rowspan='2' style='width:50px;'>";
									if($year==intVal(date("Y")) AND $i==intVal(date("m"))){
										echo "<img src='http://martinbendik.studenthosting.sk/pictures/Exclamation.png' height='20' width='20' style='margin-top:3px'>";								 										
									}else{
										echo "<img src='http://martinbendik.studenthosting.sk/pictures/yes.png' height='20' width='20' style='margin-top:3px'>";								 																				
									}
								echo '</td>';
								echo "<td style='width:140px'>";								
									echo "Rok a mesiac:";
								echo "</td>";
								echo "<td style='width:160px'>";								
									echo "Počet inventúr:";
								echo "</td>";
								echo "<td style='width:150px'>";								
									echo "Počet pokút:";
								echo "</td>";
								echo "<td style='width:160px'>";								
									echo "Mzda v hrubom:";
								echo "</td>";
								echo "<td rowspan='2' style='font-style: italic; font-size:12px;width:200px'>";
								if($year==intVal(date("Y")) AND $i==intVal(date("m"))){
										echo 'Pre tento mesiac ešte nie je možné zobraziť vyplatné pásky.';
									}else{
										echo '<div class="button-group" style="margin-top:4px">';
											echo '<a class="button" href="'.base_url('employee/createPayCheckPdf/2/'.$year.'/'.$i).'">Zobraziť</a>';
										echo '</div>';
									}
							
						echo "</td>";
						echo "<td rowspan='2' style='width:122px;'>";
							echo "&nbsp";
						echo '</td>';
							echo "</tr>";
							echo "<tr>";
								echo "<td rowspan='2'><b>";
									switch($i){
										case 1: echo "Január - ".$year; break;
										case 2: echo "Február - ".$year; break;
										case 3: echo "Marec - ".$year; break;
										case 4: echo "Apríl - ".$year; break;
										case 5: echo "Máj - ".$year; break;
										case 6: echo "Jún - ".$year; break;
										case 7: echo "Júl - ".$year; break;
										case 8: echo "August - ".$year; break;
										case 9: echo "September - ".$year; break;
										case 10: echo "Október - ".$year; break;
										case 11: echo "November - ".$year; break;
										case 12: echo "December - ".$year; break;
									}
								echo '</td>';
								echo "<td>";	
									if(strlen($i)==1){
										$i="0".$i;
									}							
									echo getCountCompletedInventories($this->session->userdata('id_zamestnanca'), $year, $i);	
								echo "</td>";
								echo "<td>";								
									echo getCountPenaltyEmp($this->session->userdata('id_zamestnanca'), $year, $i);
								echo "</td>";
								echo "<td>";								
									echo getSalaryYearGross($this->session->userdata('id_zamestnanca'), $year, $i)." €";
								echo "</td>";
							echo "</tr>";	
														
						echo "</table>";
					echo "<div class='vehicle_div' style='align:center;'></div>";								
					}	
				}
		
	
			echo '</div>';
		echo '</div>';		
	} else {
		redirect(base_url('main/restricted'));
	}		
?>


