
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
<h1>Sample Template</h1>
<form method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr class="row1">
	<td class="tabledata1"><strong>Branch</strong></td>
	<td><select name="site" id="site" style="width:150px;" onchange="ShowDiv(this.value,'hid_lstemp','EmpCodePrefix.php')">
	<option value="0">Select</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 ($_REQUEST['site']==$site_row['loccode']?'selected':'')?>><?php echo $site_row['locationname'];?></option>
	<?php }?>
	</select></td>
	<td class="tabledata1"><strong>Employee</strong></td>
	<td><div id='hid_lstemp'>
	<select name="employee_code" id="employee_code"  style="width:150px;">
		<option value="">Select</option>
	<?php
	$query="Select  * from empmaster where emp_site='".$_REQUEST['site']."' order by emp_name ";	
	$sql_emp=DB_query($query,$db);
	 while($rowEmp=DB_fetch_array($sql_emp)){?>
	<option value="<?php echo $rowEmp['id'] ?>" <?php echo ($_REQUEST['employee_code']==$rowEmp['id']?'selected':'') ?>><?php echo $rowEmp['emp_name'] ?></option>
	 <?php }?>
	</select>
 	</div></td>
	<td class="tabledata1"><strong>From</strong></td>
	<td><input type="text" name="from_date" id="from_date" value="<?php echo $_REQUEST['from_date']; ?>" class="datepicker"  /></td>
	<td class="tabledata1"><strong>To</strong></td>
	<td><input type="text" name="to_date" id="to_date" value="<?php echo $_REQUEST['to_date']; ?>" class="datepicker"  /></td>
	<td class="tabledata1"><input type="submit" name="GO" value="GO" class="search" /></td>
</tr>
</table>
</form>

<?php 
if($_REQUEST['GO'])
{
	if($_REQUEST['site']!='')
	{
		$filter[]="emp_site='".$_REQUEST['site']."'";
	}
	if($_REQUEST['employee_code']!='')
	{
		$filter[]="id='".$_REQUEST['employee_code']."'";
	}
	//if($_REQUEST['from_date']!='' && $_REQUEST['to_date']!='')
	//{
	//	$filter[]="id='".$_REQUEST['employee_code']."'";
	//}
	if($filter!='')
	{
		$filter1=implode(" and ",$filter);
		$sql="select * from empmaster where $filter1";
	}
$DBEmp=DB_query($sql,$db);
$EMPDetails=DB_fetch_array($DBEmp);
$Ondaysal=$EMPDetails['allow_tot']/30;
$otamt=round($Ondaysal/8,2);
}
$fromdate=FormatDateForSQL($_REQUEST['from_date']);
$todate=FormatDateForSQL($_REQUEST['to_date']);
$startdate=date('Y-m-d',strtotime($fromdate));
$enddate=date('Y-m-d',strtotime($todate));
?>


<table width="100%" border="1" cellspacing="0" cellpadding="3">
<tr class="row1">
	<td class="tabledata1"><strong>Name of Worker</strong></th>
    <td><?php echo $EMPDetails['emp_name'];?></td>
    <td class="tabledata1"><strong>Period Ended</strong></th>
    <td><?php echo $_REQUEST['to_date']; ?></td>
</tr>
<tr class="row1">
	<td class="tabledata1"><strong>Normal Worked Day Rate</strong></th>
    <td><?php echo round($Ondaysal,2); ?></td>
   <td class="tabledata1"><strong>Overtime Worked Hour Rate:</strong></th>
    <td><?php echo $otamt; ?></td>
</tr>
<tr class="row1">
    <td class="tabledata1"><strong>Payment Date</strong></th>
    <td colspan="3">&nbsp;</td>
</tr>
</table>
<br />
<br />



<form name="form1" action="" method="post" >
<table width="100%" border="1" cellspacing="0" cellpadding="2">
  <tr>
    <th width="10%" align="left" valign="top">Date</th>
    <th width="10%" align="left" valign="top">Day</th>
    <th width="15%" align="left" valign="top" style="padding:0px; margin:0px;" colspan="2"><table width="100%" border="1" cellspacing="0" cellpadding="3" style="border:none;">
<tr>
    <td colspan="2" align="center" style="text-align:center;"><strong>Time</strong></td>
    </tr>
  <tr>
    <td width="50%" align="left"><strong>From</strong></td>
    <td align="center"><strong>To</strong></td>
</tr>
</table></th>
    <th width="10%" align="left" valign="top">Normal Worked Day</th>
    <th width="10%" align="left" valign="top">Sunday Worked Day</th>
    <th width="10%" align="left" valign="top">Overtime Worked Hour</th>
    <th width="15%" align="left" valign="top">Extra/Penalised Worked Hour</th>
    <th width="12%" align="left" valign="top">Amount (&#36;&#36; )</th>
    <th align="left" valign="top">Remark/Proj</th>
    <th align="left" valign="top">Meal Allowance</th>
  </tr>
 <?php 
 $amtarr='';
 $workhrsarra='';
 $sunworkhrs='';
 $Othrsarr='';
 for($i=$startdate;$i<=$enddate;$i=date ('Y-m-d',strtotime('+1 day',strtotime($i)))){ 
 $empattSQL=DB_query("SELECT * FROM daily_attendance where employee='".$EMPDetails['id']."' and attendance_date='".$i."'",$db);
 $EMPDailyAtt=DB_fetch_array($empattSQL);?>
  <tr>
    <td align="left" valign="top"><?php echo ConvertSQLDate($i)  ?></td>
    <td align="left" valign="top"><?php echo $s->GetFieldValue('shift_master',"id='".$EMPDailyAtt['shift_category']."'",'shift_for').'('.$s->GetFieldValue('shift_master',"id='".$EMPDailyAtt['shift_category']."'",'shift_category').')'; ?></td>
    <td colspan="2" align="left" valign="top" style="padding:0px;">
	<table width="100%" border="1" cellpadding="2">
  <tr>
    <td width="50%"><?php if($EMPDailyAtt['time_in']!=''){echo $EMPDailyAtt['time_in'].' '.$EMPDailyAtt['timein_AMPM'];}else{echo '&nbsp;';}?></td>
    <td><?php if($EMPDailyAtt['time_out']!=''){echo $EMPDailyAtt['time_out'].' '.$EMPDailyAtt['timeout_AMPM'];}else{echo '&nbsp;';}?></td>
  </tr>
</table>

	</td>
	<td><?php echo $EMPDailyAtt['work_hrs'];
	$workhrsarra[]=$EMPDailyAtt['work_hrs'];
	 ?></td>
	<td><?php if($EMPDailyAtt['pres_abs']=='WL'){echo $EMPDailyAtt['ot_hrs'];
	$sunworkhrs[]=$EMPDailyAtt['ot_hrs'];
	
	} ?></td>
	<td><?php echo $EMPDailyAtt['ot_hrs'];
	$Othrsarr[]=$EMPDailyAtt['ot_hrs'];
	 ?></td>
	<td>&nbsp;</td>
	<td><?php 	if($EMPDailyAtt['work_hrs']!='')
				{
				$otalhrs=$EMPDailyAtt['work_hrs'];
				echo $amt=$otalhrs*$otamt;
				}
				else
				{
				echo round($Ondaysal,2);
				}
				
				$amtarr[]=$amt;
	?></td>
	<td>&nbsp;</td>
	<td><?php echo 'No'; ?></td>
    
  </tr>
 <?php }?>
  
  
  <tr>
    <th colspan="4" align="left" valign="top">&nbsp;</th>
    <th align="left" valign="top"><?php echo array_sum($workhrsarra); ?></th>
    <th align="left" valign="top"><?php echo array_sum($sunworkhrs); ?></th>
    <th align="left" valign="top"><?php echo array_sum($Othrsarr); ?></th>
    <th align="left" valign="top">0.00</th>
    <th align="left" valign="top"><?php echo array_sum($amtarr); ?></th>
    <th align="left" valign="top">&nbsp;</th>
    <th align="left" valign="top">0.00</th>
  </tr>
  <tr>
    <td colspan="8" rowspan="6" align="left" valign="top">&nbsp;</td>
    <th align="left" valign="top">Allowance</th>
    <td align="left" valign="top">&nbsp;</td>
    <td rowspan="6" align="left" valign="top">&nbsp;</td>
  </tr>
  
  
  
  
  <tr>
    <th align="left" valign="top">Less Fees</th>
    <td align="left" valign="top">&nbsp;</td>
    </tr>
  <tr>
    <th align="left" valign="top">Less CPF</th>
    <td align="left" valign="top">&nbsp;</td>
    </tr>
  <tr>
    <th align="left" valign="top">Less Tax</th>
    <td align="left" valign="top">&nbsp;</td>
    </tr>
  <tr>
    <th align="left" valign="top">Less Loan</th>
    <td align="left" valign="top">&nbsp;</td>
    </tr>
  <tr>
    <th align="left" valign="top">Grand Total</th>
    <td align="left" valign="top">&#36;<?php echo array_sum($amtarr); ?></td>
    </tr>
</table>

	
</form>