<style type="text/css">
ul.pagination {
	font-family: "Arial", "Helvetica", sans-serif;
	font-size: 13px;
	height: 100%;
	list-style-type: none;
	margin: 20px 0;
	overflow: hidden;
	padding: 0;
}
ul.pagination li.details {
	background-color: white;
	border-color: #C8D5E0;
	border-image: none;
	border-style: solid;
	border-width: 1px 1px 2px;
	color: #1E598E;
	font-weight: bold;
	padding: 8px 10px;
	text-decoration: none;
}
ul.pagination li.dot {
	padding: 3px 0;
}
ul.pagination li {
	float: left;
	list-style-type: none;
	margin: 0 3px 0 0;
}
ul.pagination li:first-child {
	margin-left: 0;
}
ul.pagination li a {
	color: black;
	display: block;
	padding: 7px 10px;
	text-decoration: none;
}
ul.pagination li a img {
	border: medium none;
}
ul.pagination li a.current {
	background-color: white;
	border-radius: 0 0 0 0;
	color: #333333;
}
ul.pagination li a.current:hover {
	background-color: white;
}
ul.pagination li a:hover {
	background-color: #C8D5E0;
}
ul.pagination li a {
	background-color: #F6F6F6;
	border-color: #C8D5E0;
	border-image: none;
	border-style: solid;
	border-width: 1px 1px 2px;
	color: #1E598E;
	display: block;
	font-weight: bold;
	padding: 8px 10px;
	text-decoration: none;
}
</style>
<link rel="stylesheet" type="text/css" href="css/table_frize_1.css">
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
<?php 
//unset($_SESSION['employee_code']);
//error_reporting(0);
include('./includes/fun-php.php');
include('./includes/fun-HRClass.php');
$modid=$_REQUEST['modid'];
$frmid=$_REQUEST['frmid'];
$target_rurl="index.php?route=HRModule/forgot_punch_reports&modid=".$modid."&frmid=".$frmid."";
$rurl_view="index.php?route=forgot_punch&action=View&modid=".$modid."&frmid=".$frmid."";

?>

<?php

/* 
function floor_dec($number,$precision,$separator)
{
    $numberpart=explode($separator,$number);
    $numberpart[1]=substr_replace($numberpart[1],$separator,$precision,0);
    if($numberpart[0]>=0)
    {$numberpart[1]=floor($numberpart[1]);}
    else
    {$numberpart[1]=ceil($numberpart[1]);}

     $ceil_number= $numberpart[1];
    return $ceil_number;
}
function floor_dec1($number,$precision,$separator)
{
    $numberpart=explode($separator,$number);
    $numberpart[1]=substr_replace($numberpart[1],$separator,$precision,0);
    if($numberpart[0]>=0)
    {$numberpart[1]=floor($numberpart[1]);}
    else
    {$numberpart[1]=ceil($numberpart[1]);}

     $ceil_number= $numberpart[0];
    return $ceil_number;
} */


if($_REQUEST['Search'])
{
	$_SESSION['Mstemp_paysal']=array();			 
	$_SESSION['Mstemp']=array();
	$paystatus=true;  
	$_SESSION['payyear']=$_REQUEST['payyear'];
	$_SESSION['paymonth']=$_REQUEST['paymonth'];
	$_SESSION['employee_code']=$_REQUEST['employee_code'];
	$_SESSION['emptype']=$_REQUEST['emptype'];
	$_SESSION['emp_salprocess_site']=$_REQUEST['site'];
	$years=$_SESSION['payyear'];
	$month=$_SESSION['paymonth'];	   
	$employee_code=$_SESSION['employee_code'];
	$emptype=$_SESSION['emptype'];
	$emp_salprocess_site=$_SESSION['emp_salprocess_site'];
}	 
/* 
if($_REQUEST['Reset'])
{
	unset($_SESSION['Mstemp_paysal']);			 
	unset($_SESSION['Mstemp']);
	unset($_SESSION['payyear']);
	unset($_SESSION['paymonth']);
	unset($_SESSION['employee_code']);
	unset($_SESSION['emptype']);
	unset($_SESSION['emp_salprocess_site']);
	unset($_SESSION['payyear']);
	unset($_SESSION['paymonth']);	   
	unset($_SESSION['emptype']);
	unset($_SESSION['emp_salprocess_site']);
	$s->PageLocation($target_rurl);
} */	
?>
<form action="" method="post">
<h1><strong>Forgot Punch Report</strong></h1>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr class="row1">
    <td align="right"><strong>Site :</strong></td>
    <td ><select name="site" id="site" style="width:98%;">
			<option value="">---ALL---</option>
			<?php $site_sql=DB_query("Select loccode, locationname from locations  where CompanyId='".$_SESSION['ACGCompanyId']."' and loccode in('".$_SESSION['AssignedBranch']."')",$db);
			while($site_row=DB_fetch_array($site_sql)){?>
			<option value="<?php echo $site_row['loccode'];?>"<?php echo ($_SESSION['emp_salprocess_site']==$site_row['loccode']?'selected':'');?>><?php echo $site_row['locationname'];?></option>
			<?php } ?>
		</select>
	</td>
    <td align="right"><strong>Type :</strong></td>
    <td>
		<select name="type" id="type" style="width:98%;"> 
			<option value="" >---</option>
			<option value="fp">Forgot Punch</option>
			<option value="lc">Late Coming</option>
			<option value="ed">Early departure</option>
		</select>
	</td>
	<td align="right"><strong>Status :</strong></td>
    <td>
		<select name="status" id="status" style="width:98%;"> 
			<option value="" >---</option>
			<option value="0">Request</option>
			<option value="1">Approve</option>
			<option value="2">Decline</option>
		</select>
	</td>
	<td style="text-align:right;"><strong>From date:</strong></td>		
	<td >
	<input name="from_date" type="text" id="from_date" class='datepicker' readonly value="<?php if($_REQUEST['from_date']!=''){ echo $_REQUEST['from_date']; } else { echo ConvertSQLDate($_SESSION['financialYrStart']); } ?>" />
	</td>
	<td style="text-align:right;"><strong>To date:</strong></td>		
	<td >
	<input name="to_date" type="text" id="to_date" class='datepicker' readonly value="<?php if($_REQUEST['to_date']!='') { echo $_REQUEST['to_date']; } else { echo ConvertSQLDate($_SESSION['financialYrEnd']); } ?>"  />
	</td>
  </tr>
  
  <tr class="row1">
    <td colspan="10" align="center">
		<input type="submit" name="Search" class="search" value="Search" /> <input type="submit" name="Reset" class="search" value="Reset"/>
	</td>
  </tr>
</table>

</form>
<?php //print_r($_REQUEST); ?>

	
<?php 

if($_REQUEST['Search']){?>
 <p align="right">
	<a href="forgot_punch_print.php?site=<?php echo $_REQUEST['site'];?>&type=<?php echo $_REQUEST['type'];?>&from_date=<?php echo $_REQUEST['from_date'];?>&to_date=<?php echo $_REQUEST['to_date'];?>&status=<?php echo $_REQUEST['status'];?>" target="_blank" class="search">Print</a></p>
<form action="" method="post" name="myform">
<h3><strong>Forgot Punch Report</strong></h3>

	<table width="100%" cellpadding="3" cellspacing="0" border="1" style="border:#808080 1px solid: border-collapse:collapse;">
	<tr>
	     <th width="2%"><strong>Sr. No.</strong></th>
    	 <th width="5%"><strong>Emp. Code</strong></th>
		<th><strong>Emp. Name</strong></th>
		<th width="12%"><strong>Department</strong></th>
		<th width="9%"><strong>Request Date</strong></th>
		<th width="9%"><strong>Approve Date</strong></th>
		<th width="7%"><strong>Type</strong></th>
        <th width="10%"><strong>Date</strong></th>
		<th width="10%"><strong>Punch(IN/OUT)</strong></th>
		<th width="7%"><strong>Time</strong></th>
		<th width="7%"><strong>Reason</strong></th>
		<th width="7%"><strong>Remarks</strong></th>
		<th>Status</th>    
    </tr>
    <?php 
	
	$whr = 1;
	 if(isset($_POST['Search'])){
		$site		= $_POST['site'];
		$from_date	= $_POST['from_date'];
		$to_date	= $_POST['to_date'];
		$type		= $_POST['type'];
		$status		= $_POST['status'];
		if($status != ''){
			 $whr .= " AND approve_status = '".$status."' "; 
		 }
	
		 if($site != ''){
			 $whr .= " AND site = '".$site."' "; 
		 }
		 
		 if($from_date != '' && $to_date != ''){
			 $whr .= " AND DATE(punch_date) BETWEEN '".date('Y-m-d', strtotime(strtr($_POST['from_date'],'/','-')))."' AND '".date('Y-m-d', strtotime(strtr($_POST['to_date'],'/','-')))."' "; 
		 } else if($to_date != ''){
			 $whr .= " AND DATE(punch_date) = '".date('Y-m-d', strtotime(strtr($_POST['to_date'],'/','-')))."' "; 
		 } else if($from_date) {
			 $whr .= " AND DATE(punch_date) = '".date('Y-m-d', strtotime(strtr($_POST['from_date'],'/','-')))."' "; 
		 } else {
			 
		 }
		 
		 if($type != ''){
			 $whr .= " AND punchtype = '".$type."' "; 
		 }
		 
	 }
		$GetProcess = "Select * from hr_forgot_punch WHERE $whr";
		
		$ResultProcess_SalData = DB_query($GetProcess,$db);
	   if(DB_num_rows($ResultProcess_SalData)){
	$i=0;
   	   while($RowData = DB_fetch_array($ResultProcess_SalData))
	   {
  ?>
 
				 <tr bgcolor="#fff">
				 <td><?php echo $i+1; ?></td>
		<td>
			<?php  
				$empCode = "Select emp_code from empmaster WHERE id='".$RowData['emp_id']."'";
				$empCodeData = DB_query($empCode,$db);
				$code = DB_fetch_array($empCodeData);
				echo $code['emp_code'];
				
			?>
		</td>
		<td>
			<?php  
				$empName = "Select emp_name from empmaster WHERE id='".$RowData['emp_id']."'";
				$empNameData = DB_query($empName,$db);
				$name = DB_fetch_array($empNameData);
				echo $name['emp_name'];
			
			?>
		</td>
		<td>
			<?php  
				$depName = "Select deptname from deptmaster WHERE id='".$RowData['department']."'";
				$depNameData = DB_query($depName,$db);
				$dep = DB_fetch_array($depNameData);
				echo $dep['deptname'];
			
			?>
		</td>
		<td><?php  echo ConvertSQLDate($RowData['punch_request_date']); ?></td>
		<td><?php  if($RowData['approve_date']!='') { echo ConvertSQLDate($RowData['approve_date']); }  ?></td>
		<td>
			<?php  
				if($RowData['punchtype'] == 'fp'){
					echo 'Forgot Punch';
				} else if($RowData['punchtype'] == 'lc'){
					echo 'Late Coming';
				} else 	if($RowData['punchtype'] == 'ed'){
					echo 'Early departure';
				} else {
					echo '';
				}
			?>
		</td>
        <td><?php  echo ConvertSQLDate($RowData['punch_date']); ?></td>
        <td>
		
			<?php  
				if($RowData['punch_time'] == 'in'){
					echo 'IN';
				} else if($RowData['punch_time'] == 'out'){
					echo 'OUT';
				} else {
					echo '';
				}
			?>
		</td>
		
		<td><?php  echo $RowData['time']  ?></td>	
		<td>
			
			<?php  
				if($RowData['reason'] == 'md'){
					echo 'Machine Down';
				} else if($RowData['reason'] == 'fp'){
					echo 'Forgot Punch';
				} else 	if($RowData['reason'] == 'lc'){
					echo 'Late Coming';
				} else 	if($RowData['reason'] == 'ed'){
					echo 'Early Dep.';
				} else 	if($RowData['reason'] == 'o'){
					echo 'Other';
				} else {
					echo '';
				}
			?>
		</td>	
		<td><?php  echo $RowData['remarks'];  ?></td>	
		<td>
				<?php if($RowData['approve_status'] == 1){  echo "Approved"; } else if($RowData['approve_status'] == 2) { echo "Declined"; } else if($RowData['approve_status'] == 0){ echo "Requested"; } ?>
				
		</td>
			
		<!--td style="text-align:center;"><a href="#" onclick='popup("LoanPaymentDetails.php?id=<?php  //echo $RowData['id'].$rurl?>",600,400)' class="search">Details</a></td-->		
	 </tr>
	<?php $i++;}?>
	
   <?php } else{
		echo "<tr bgcolor='#fff'><td colspan='11' align='center'>No Record Found</td></tr>";
	}   
?>
    </table>
	
</form>
 <?php }
	   
	    ?>

</div>
</div>