<?php include 'inc_classes.php';?>
<?php include "admin_authentication.php";?>
<?php include "../classes/thumbnail_images.class.php";?>
<?php
if($_REQUEST['record_id'])
{
    $record_id=$_REQUEST['record_id'];
    $sql_record= "SELECT * FROM emp_performance_report where id='".$record_id."'";
    if(mysql_num_rows($db->query($sql_record)))
        $row_record=$db->fetch_array($db->query($sql_record));
    else
		$record_id=0;
}
$edit_access='';
$sel_acc="select * from edit_previleges where admin_id='".$_SESSION['admin_id']."' and privilege_id='349'";
$ptr_access=mysql_query($sel_acc);
if(mysql_num_rows($ptr_access))
{
	$edit_access='yes';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Manage Employee Performance</title>
<?php include "include/headHeader.php";?>
<?php include "include/functions.php"; ?>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css"/>
	<!-- <script type='text/javascript' src='js/jquery-1.6.2.min.js'></script>-->
    <script src="js/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript">
	jQuery(document).ready( function() 
	{
		// binds form submission and fields to the validation engine
		jQuery("#jqueryForm").validationEngine('attach', {promptPosition : "topLeft"});
		
	});
    </script>
    
	<!-- <script src="../js/jquery.custom/development-bundle/jquery-1.4.2.js"></script>-->
    <link rel="stylesheet" href="js/development-bundle/demos/demos.css"/>
     <link rel="stylesheet" href="js/chosen.css" />
    <script src="js/development-bundle/ui/jquery.ui.core.js"></script>
    <script src="js/development-bundle/ui/jquery.ui.widget.js"></script>
    <script src="js/development-bundle/ui/jquery.ui.datepicker.js"></script>
    <script src="js/chosen.jquery.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(document).ready(function()
	{            
		$('.datepicker').datepicker({ changeMonth: true,changeYear: true, showButtonPanel: true, closeText: 'Clear'});
		$.datepicker._generateHTML_Old = $.datepicker._generateHTML; $.datepicker._generateHTML = function(inst)
		{
			res = this._generateHTML_Old(inst); res = res.replace("_hideDatepicker()","_clearDate('#"+date.id+"')"); return res;
			//$("#date" ).datepicker({defaultDate: -1,maxDate:"-1D"});
			$("#date").datepicker("setDate", "-1");
		}
		
		$("#staff_id").chosen({allow_single_deselect:true});
		$("#staff_id_s").chosen({allow_single_deselect:true});
		<?php 
		if($_SESSION['type']=="S" || $_SESSION['type']=='Z' || $_SESSION['type']=='LD')
		{
			?>
			$("#branch_name").chosen({allow_single_deselect:true});
			$("#staff_type").chosen({allow_single_deselect:true});
			<?php
		}
		?>		
	});
	function show_records(value)
{
	table=value.split("-");
	// alert(table[0]);
	if(table[0]=="non_tech")
	{
		document.getElementById("tbl1").style.display = 'block';
        document.getElementById("tbl2").style.display = 'none';
	}
	else if(table[0]=="faculty")
	{
		document.getElementById("tbl1").style.display = 'none';
        document.getElementById("tbl2").style.display = 'block';
	}
}
    </script>
</head>
<?php
					if($_REQUEST['deleteRecord'] && $_REQUEST['record_id'])
					{
						$del_record_id=$_REQUEST['record_id'];    
						$date=$_GET['date'];  
						'<br/>'.$del_kpi="delete from pm_daily_keypoint_performance where 1 and employee_id='".$del_record_id."' and date='".$date."'";
						$ptr_del=mysql_query($del_kpi);
		
					   '<br/>'. $del_tot_per="delete from pm_total_keypoint_performancee where 1 and employee_id='".$del_record_id."' and date='".$date."'";
						$ptr_tot_per=mysql_query($del_tot_per);              
						// $delete_query="delete from pm_insentive_percentage where pi_id='".$del_record_id."'";
						// $db->query($delete_query);      
						?>
						<div id="statusChangesDiv" title="Record Deleted"><center><br><p>Selected record deleted successfully</p></center></div>
						<script type="text/javascript">
							// $("#statusChangesDiv").dialog();
							$(document).ready(function() {
								$( "#statusChangesDiv" ).dialog({
									modal: true,
									buttons: {
												Ok: function() { $( this ).dialog( "close" ); }
												}
									});
								});
								setTimeout('document.location.href="emp_kpi_report.php";',500);
						</script>
						<?php
					}
?>
<body>
<?php include "include/header.php";?>
<!--info start-->
<div id="info">
<!--left start-->
<?php include "include/menuLeft.php"; ?>
<!--left end-->
<!--right start-->
<div id="right_info">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
  <tr>
    <td class="top_left"></td>
    <td class="top_mid" valign="bottom"><?php include "include/payroll_menu.php"; ?></td>
    <td class="top_right"></td>
  </tr>
  <tr>
    <td class="mid_left"></td>
    <td class="mid_mid">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
        	<?php
            $errors=array(); $i=0;			
            $success=0;
				?>
            	<tr><td>
   				<form method="GET" id="jqueryForm" name="jqueryForm" enctype="multipart/form-data" >
				<table border="0" cellspacing="15" cellpadding="0" width="100%">
              	<tr>
                <td colspan="3" class="orange_font">* Mandatory Fields</td>
                </tr>
				<tr>
                    <td width="20%">Select Date<span class="orange_font">*</span></td>
                    <td><input type="text"  style="width: 300px;"  name="date" class="input_text datepicker" placeholder="Date" id="date" title="Date" value="<?php if($_REQUEST['date']) echo $_REQUEST['date']; else echo date('d/m/Y') ?>">
                    </td>
                </tr>
                <tr>
                <td width="20%"> Branch Name<span class="orange_font">*</span></td>
				<?php 
                if($_SESSION['type']=='S' || $_SESSION['type']=='Z' || $_SESSION['type']=='LD')
                {
                    ?>
                    <td>
                        <select name="branch_name" id="branch_name" class="input_select_login" style="width: 300px;" onchange="getstaffDetails(this.value)">
                        <option value="">Select Branch </option>
                        <?php 
                        $sel_branch="select branch_id,branch_name from branch where status='Active'";
                        $ptr_sel=mysql_query($sel_branch);
                        while($data_branch=mysql_fetch_array($ptr_sel))
                        {
                            $sel='';
                            if($data_branch['branch_name']==$_GET['branch_name'])
                            {
                                $sel='selected="selected"';
                            }
                            elseif($data_branch['branch_name']=='Pune')
                            {
                                $sel='selected="selected"';
                            }
                            echo '<option '.$sel.' value="'.$data_branch['branch_name'].'" > '.$data_branch['branch_name'].'</option>';
                        }
                        ?>
                        </select>
                    </td>
                    <?php
                }
                else 
                {
                    ?>
                    <td colspan="2" align="left">
                    <input type="hidden" name="branch_name" id="branch_name" value="<?php echo $_SESSION['branch_name']; ?>" />
                    </td>
                    <?php 
                }
				?>
				</tr>
				
				<tr>
                    <td  colspan="2"><input style="margin-left: 350px;" type="submit" onclick="return validme()" name="save_changes"  value="Check Record"  /></td>
                </tr>
				<?php
						 if($_REQUEST['date'])
						 {
							$frm_date=explode("/",$_REQUEST['date']);
							$frm_dates=$frm_date[2]."-".$frm_date[1]."-".$frm_date[0];
							$start_date=$frm_dates;
						 }
						 else{
							$start_date=date("Y-m-d");
						 }
						 if($_REQUEST['branch_name']!='')
                            {
                            	$branch_name=$_REQUEST['branch_name'];
                                $select_cm_id="select cm_id from site_setting where branch_name='".$branch_name."' and type='A'";
                            	$ptr_cm_id=mysql_query($select_cm_id);
                                $data_cm_id=mysql_fetch_array($ptr_cm_id);
                                $search_cm_id="and cm_id='".$data_cm_id['cm_id']."'";
                            }
                        else
                            {
                                $search_cm_id="and cm_id='2'";
                            }
						 ?>
					<tr>
						<td>
							<select name="staff_type" id="staff_type" class="input_select_login" style="width: 150px;" onChange="show_records(this.value)">
								<!-- <option value="">Select </option> -->
								<option value="non_tech">Non Technical</option>  <?php //if ($_GET['staff_type'] == "non_tech") echo "selected='selected'";?>
								<option value="faculty" >Faculty</option> <?php //if ($_GET['staff_type'] == "faculty") echo "selected='selected'";?>
							</select>
						</td>
					</tr>
            <tr>
                <table border="0" cellspacing="15" cellpadding="0" width="100%" id='tbl1' class="table" >
					<tr>
					<td width="100%" colspan="11" align="center"><h2>Not Technical Staff ( <?php if($_REQUEST['branch_name']!='') echo ucfirst($_GET['branch_name']) ; else echo 'Pune' ;?>)  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue"><?php echo date('d-m-Y',strtotime($start_date)) ; ?></span></h2> </td>
					</tr>
                        <tr class="grey_td" style="text-align:center">
                            <td width="4%" align="center"><strong>Sr. No.</strong></td>
                            <td width="7%" align="center"><strong>Staff Name</strong></td>
                            <td width="7%" colspan="" align="center"><strong>Time Sheet Sent</strong></td>
							<td width="7%" colspan="" align="center"><strong>Well Groomed</strong></td>
                            <td width="7%" colspan="" align="center"><strong>Phone Submitted</strong></td>
                            <td width="7%" colspan="" align="center"><strong>On Time Reporting</strong></td>
                            <td width="7%" colspan="" align="center"><strong>Not Early Checkout without Info</strong></td>
                            <td width="7%" colspan="" align="center"><strong>NO Misconduct With Staff and Student</strong></td>
							<td width="7%" colspan="" align="center"><strong>Total Point Get</strong></td>
							<td width="7%" colspan="" align="center"><strong>Total Percentage</strong></td>
							<td width="7%" colspan="" align="center"><strong>Action</strong></td>
                        </tr>
                        <?php
						 $bgColorCounter=1;
						
                    $sel_staff="select admin_id,name,type from site_setting where 1 and system_status='Enabled' and type!='F'  ". $search_cm_id." order by name asc";
                     $ptr_staff=mysql_query( $sel_staff);
                     $i=1;
                    while($data_staff=mysql_fetch_array( $ptr_staff))
                    {
							if($bgColorCounter%2==0){
                                $bgcolor='class="grey_td"';
							}
                            else{
                                $bgcolor="";    
							}            
                                $listed_record_id=$data_staff['admin_id']; 
								$sel_com="select comment,total_point,status,employee_id,total_percentage FROM `pm_total_keypoint_performancee` WHERE 1 and employee_id='".$data_staff['admin_id']."' and DATE(date)='".$start_date."' ". $search_cm_id."";
									$ptr_comm=mysql_query($sel_com);
									$data=mysql_num_rows($ptr_comm);
									$data_comm=mysql_fetch_array($ptr_comm);
									?>
                        <tr <?php echo $bgcolor ?> style="text-align:center">
							   <td width="4%" align="center"><?php echo $i++;?></td>
							   <td width="7%" align="center"><?php echo ucwords($data_staff['name']);?></td>
								<?php
							if($data_comm['status']=='present')
							{
								'<br/>'. $sel_kpi="select *  from pm_daily_keypoint_performance p, pm_key_performance_point k where 1 and p.key_point_id=k.key_id and DATE(p.date)='".$start_date."'and p.employee_id='".$data_staff['admin_id']."'  ". $search_cm_id." order by key_point_id ASC"; //".$data_staff['admin_id']."
									$ptr_kpi=mysql_query( $sel_kpi);
									$record=mysql_num_rows($ptr_kpi);
								while($data_kpi=mysql_fetch_array($ptr_kpi))
								{
									?>
									<td>
										<table border="0" cellspacing="" cellpadding="0" width="99%">
											<tr>
												<td width="7%" align="center"><?php echo ucwords($data_kpi['points']);?></td>
											</tr>
										</table>
									</td>
									<?php
                               	}
							}
							else if($data_comm['status']=='absent')
							{
								?>
								<td  align="center" colspan="6"><span style="color:red"><b><?php echo 'Absent';?></b></span></td>
								<?php
							}
							if($data)
							{
								?>
								<td width="7%" align="center"><strong><?php echo $data_comm['total_point'];?></strong></td>
								<td width="7%" align="center"><strong><?php echo $data_comm['total_percentage'];?> %</strong></td>
								<?php
							}
							if($data_comm['employee_id']==$data_staff['admin_id'])
							{
                              
								 echo '<td align="center">';
								 if($data_comm['status']=='present'){
								 echo '<a href="emp_edit_kpi.php?record_id='.$listed_record_id.'&date='.$start_date.'&type='.$data_staff['type'].'" ><img src="images/edit_icon.png" title="Edit Record" class="example-fade"/></a>&nbsp;&nbsp';
								 }
                                  echo '<a onclick="return validationToDelete(\''.$_SERVER['PHP_SELF'].'\');" href="'.$_SERVER['PHP_SELF'].'?deleteRecord=1&record_id='.$listed_record_id.'&date='.$start_date.'&page='.$_REQUEST['page'].$query_string1.'"><img src="images/delete_icon.png" title="Delete Record" class="example-fade" /></a>&nbsp;&nbsp;';
                                echo '</td>';
								?>
								<!-- <td align="center"><a href="emp_edit_kpi.php?record_id='<?php echo $listed_record_id ?>'&date='<?php echo $start_date?>'" ><img src="images/edit_icon.png" title="Edit Record" class="example-fade"/></a>&nbsp;&nbsp;
								<a onclick="return validationToDelete(\''.$_SERVER['PHP_SELF'].'\')"; href=" <?php echo $_SERVER['PHP_SELF'] ?>?deleteRecord=1&record_id='<?php  echo $listed_record_id ?>'&page=' <?php  echo $_REQUEST['page'].$query_string1 ?>'"><img src="images/delete_icon.png" title="Delete Record" class="example-fade" /></a>&nbsp;&nbsp;
								</td> -->
								<?php
							}
								?>
						</tr>
						<tr style="color:blue">
							<?php 
							if($data)
								{
									?>
									<td colspan="3" align="right"> <b>Comment : </b></td>
									<td colspan="8" align="left"><?php echo ucwords($data_comm['comment']); ?></td>
									<?php 
								}
								?>
						</tr>
                        <?php
							$bgColorCounter++;
                    }
                    ?>
            	</table>
            </tr>
			<tr>
            	<table border="0" cellspacing="15" cellpadding="0" width="100%" style="display:none" id='tbl2' class="table" >
					<tr>
					<td width="100%" colspan="17" align="center"><h2> Faculty Staff ( <?php if($_REQUEST['branch_name']!='') echo ucfirst($_GET['branch_name']) ; else echo 'Pune' ;?>) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue"><?php echo date('d-m-Y',strtotime($start_date)) ; ?></span></h2></td>
					</tr>
					<tr class="grey_td" style="text-align:center">
                            <td width="4%" align="center"><strong>Sr. No.</strong></td>
                            <td width="7%" align="center"><strong>Staff Name</strong></td>
                            <td width="7%" colspan="" align="center"><strong>Time Sheet Sent</strong></td>
                            <td width="7%" colspan="" align="center"><strong>phone Submitted</strong></td>
                            <td width="7%" colspan="" align="center"><strong>On Time Reporting</strong></td>
                            <td width="7%" colspan="" align="center"><strong>Not Early Checkout without Info</strong></td>
                            <td width="7%" colspan="" align="center"><strong>NO Misconduct With Staff and Student</strong></td>
							<td width="7%" colspan="" align="center"><strong>Class Started On Time	</strong></td>
                            <td width="7%" colspan="" align="center"><strong>Class Concluded On Time</strong></td>
                            <td width="7%" colspan="" align="center"><strong>Faculty grooming</strong></td>
                            <td width="7%" colspan="" align="center"><strong>Logsheet Send</strong></td>
                            <td width="7%" colspan="" align="center"><strong>Mobile Not Used During Class</strong></td>
							<td width="7%" colspan="" align="center"><strong>Timetable Followed</strong></td>
							<td width="7%" colspan="" align="center"><strong>Student Decoram Maintain</strong></td>
							<td width="7%" colspan="" align="center"><strong>Total Point Get</strong></td>
							<td width="7%" colspan="" align="center"><strong>Total Percentage</strong></td>
							<td width="7%" colspan="" align="center"><strong>Action</strong></td>
                    </tr>
                        <?php
						 $bgColorCounter1=1;
                            $sel_staff="select admin_id,name,type from site_setting where 1 and system_status='Enabled' and type='F' ". $search_cm_id."order by admin_id asc";
                            $ptr_staff=mysql_query( $sel_staff);
                            $i=1;
                           while($data_staff=mysql_fetch_array( $ptr_staff))
                           {
							if($bgColorCounter%2==0){
                                $bgcolor='class="grey_td"';
							}
                            else{
                                $bgcolor="";    
							}    
							$listed_record_id1=$data_staff['admin_id']; 
							$sel_com="select comment,total_point,status,employee_id ,total_percentage FROM `pm_total_keypoint_performancee` WHERE 1 and employee_id='".$data_staff['admin_id']."' and DATE(date)='".$start_date."' ". $search_cm_id."";
							$ptr_comm=mysql_query($sel_com);
							$data=mysql_num_rows($ptr_comm);
							$data_comm=mysql_fetch_array($ptr_comm);
							
								?>
                               <tr <?php echo $bgcolor ?> style="text-align:center">
							   <td width="4%" align="center"><?php echo $i++;?></td>
							   <td width="7%" align="center"><?php echo ucwords($data_staff['name']);?></td>
                       		 <?php
							 if($data_comm['status']=='present')
							 {
                             '<br/>'. $sel_kpi="select *  from pm_daily_keypoint_performance p, pm_key_performance_point k where 1 and p.key_point_id=k.key_id and DATE(p.date)='".$start_date."'and p.employee_id='".$data_staff['admin_id']."'  ". $search_cm_id." order by kpi_id ASC"; //".$data_staff['admin_id']."
                                $ptr_kpi=mysql_query( $sel_kpi);
								$record=mysql_num_rows($ptr_kpi);
                                while($data_kpi=mysql_fetch_array($ptr_kpi))
								{
									?>
									<td>
										<table border="0" cellspacing="0" cellpadding="0" width="99%">
											</tr>
											<td width="7%" align="center"><?php echo ucwords($data_kpi['points']);?></td>
											</tr>
										</table>
									</td>
									<?php
                                }
							}
								else if($data_comm['status']=='absent')
								{
									?>
									<td  align="center" colspan="12"><span style="color:red"><b><?php echo 'Absent';?></b></span></td>
									<?php
								}
								if($data)
								{
										?>
										<td width="7%" align="center"><strong><?php echo $data_comm['total_point'];?></strong></td>
										<td width="7%" align="center"><strong><?php echo $data_comm['total_percentage'];?> %</strong></td>
										<?php
								}
								if($data_comm['employee_id']==$data_staff['admin_id'])
								{
									echo '<td align="center">';
									if($data_comm['status']=='present'){
									echo '<a href="emp_edit_kpi.php?record_id='.$listed_record_id1.'&type='.$data_staff['type'].'&date='.$start_date.'" ><img src="images/edit_icon.png" title="Edit Record" class="example-fade"/></a>&nbsp;&nbsp';
									}
									echo '<a onclick="return validationToDelete(\''.$_SERVER['PHP_SELF'].'\');" href="'.$_SERVER['PHP_SELF'].'?deleteRecord=1&record_id='.$listed_record_id1.'&date='.$start_date.'&page='.$_REQUEST['page'].$query_string1.'"><img src="images/delete_icon.png" title="Delete Record" class="example-fade" /></a>&nbsp;&nbsp;';
							  echo '</td>';
                                    ?>
										<!-- <td align="center"><a href="pm_insentive_percentage.php?record_id='<?php  echo $listed_record_id ?>'" ><img src="images/edit_icon.png" title="Edit Record" class="example-fade"/></a>&nbsp;&nbsp;
										<a onclick="return validationToDelete(\''.$_SERVER['PHP_SELF'].'\')"; href=" <?php echo $_SERVER['PHP_SELF'] ?>?deleteRecord=1&record_id='<?php  echo $listed_record_id ?>'&page=' <?php  echo $_REQUEST['page'].$query_string1 ?>'"><img src="images/delete_icon.png" title="Delete Record" class="example-fade" /></a>&nbsp;&nbsp;
										</td> -->
									<?php
								}
									?>
								</tr>
								<tr>
									<?php 
									if($data)
									{
										?>
										<td colspan="3" align="right"> <b>Comment : </b></td>
										<td colspan="14" align="left"><?php echo ucwords($data_comm['comment']); ?></td>
										<?php 
									}
									?>
								</tr>
                                 <?php
								   $bgColorCounter1++;
                           }
                        ?>
						 </tr>
                    </table>
                </tr>
        	</table>
        	</form>
        	</td></tr>  
        </table></td>
    <td class="mid_right"></td>
  </tr>
  <tr>
    <td class="bottom_left"></td>
    <td class="bottom_mid"></td>
    <td class="bottom_right"></td>
  </tr>
</table>
</div>
<!--right end-->

</div>
<!--info end-->
<div class="clearit"></div>
<!--footer start-->
<div id="footer"><? require("include/footer.php");?></div>
<!--footer end-->
</body>
</html>
<?php $db->close();?>