<? 
include("si_confi.php");

 $empid=$_GET['q'];
 $mnt=$_GET['mnt'];

$expl=explode(",",$empid);
 $emid=$expl[0];
$emname=$expl[1];
	 
	 $daset=date_default_timezone_set('Asia/Kolkata');
	 $mnth=$mnt;
	 $crddate=date('Y-m-d');
	 $year=date('Y');
	 
	 $nmonth = date("m", strtotime("$mnth"));
	 
	 $dd=cal_days_in_month(CAL_GREGORIAN,$nmonth,$year);
	 
	 for($mn=1;$mn<=31;$mn++)
	 {
		 
	 $ckkqu=mysql_query("select * from `emp_attendance` where `empid`='$emid' and  `month`='$mnth' and `year`='$year' and `$mn`='1'  ");
	 $chknum=mysql_num_rows($ckkqu);
	 if($chknum>0)
	 {
		 $lday+=1;
	 }
	 else
	 {
		$wday+=1; 
	 }
	 
	 }
	 
	
	 
	 
	 
	 
$selcmadv=mysql_query("select * from advance where empid='$emid' and code='0' and status='1'");
while($fecg=mysql_fetch_array($selcmadv))
{
$amnt+=$fecg['advance'];
}

$selcmadv33=mysql_query("select * from employee_mng where emp_id='$emid'");
$fecg45=mysql_fetch_array($selcmadv33);
$salary=$fecg45['salary'];


 $perday=round($fecg45['salary']/$dd);

  $mnleave=$perday*$lday;


if($amnt!='')
{
	$payablamnt2=$salary-$amnt;
	$payablamnt=$payablamnt2-$mnleave;
	
?>
<span style="height:70px;">
Salary Amount : Rs.<? echo $salary; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Advance Paid : Rs.<? echo $amnt; ?> <br /><br />
Leave Days : <? echo $lday; ?> (Rs.<? echo $mnleave; ?>) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Payable Amount : Rs.<? echo $payablamnt; ?>
</span>
 
        <input type="hidden" name="salary"  value="<? echo $salary; ?>" >
       
        <input type="hidden" name="advance" value="<? echo $amnt; ?>" >  
         <input type="hidden" name="detection" value="<? echo $mnleave; ?>" >
        
        <input type="hidden" name="payable"  value="<? echo $payablamnt; ?>" >

<?
}
else
{
	$paybale=$salary-$mnleave;
?>
<span style="height:70px;">
Salary Amount : Rs.<? echo $salary; ?>&nbsp;&nbsp;&nbsp;&nbsp;<? if($lday) { ?>Leave Days : <? echo $lday; ?> (Rs.<? echo $mnleave; ?>) &nbsp;&nbsp;&nbsp;&nbsp;Payable Amount : Rs.<? echo $salary-$mnleave; ?><? } ?>
 <input type="hidden" name="salary"  value="<? echo $salary; ?>" >
<input type="hidden" name="payable" value="<? echo $paybale; ?>" >
 <input type="hidden" name="detection" value="<? echo $mnleave; ?>" >

</span>
 <? } ?>