<?php include("connection.php");
error_reporting(E_ERROR | E_PARSE); 
 $pagename = basename($_SERVER['PHP_SELF']);

 $bill_no=$_REQUEST["bill_no"];


 $bill=mysqli_query($con,"select * from onshop where `bill_no`='".$bill_no."' and `status`='active' and `bill_status`='pending' "); $billr=mysqli_fetch_array($bill,MYSQLI_ASSOC);
  $billn=mysqli_num_rows($bill);

?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- /Added by HTTrack --><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--
<link type="text/css" rel="stylesheet" href="javax.faces.resource/themeab55.css?ln=primefaces-aristo" />
<link type="text/css" rel="stylesheet" href="javax.faces.resource/dist-butterfaces-bootstrap.min4e5d.css?ln=butterfaces-dist-css" />
-->
<link type="text/css" rel="stylesheet" href="javax.faces.resource/css/default.css" />
<link type="text/css" rel="stylesheet" href="javax.faces.resource/css/cssLayout.css" />
<link type="text/css" rel="stylesheet" href="javax.faces.resource/css/bootstrap.css" />
<link type="text/css" rel="stylesheet" href="javax.faces.resource/css/bootstrap.min.css" />
<link type="text/css" rel="stylesheet" href="javax.faces.resource/css/popup.css" />
<link type="text/css" rel="stylesheet" href="javax.faces.resource/css/menu.css" />
<!--
<script type="text/javascript" src="javax.faces.resource/butterfaces-all-with-jquery-and-bootstrap-bundle.min686a.js?ln=butterfaces-dist-bundle-js"></script>
<script type="text/javascript" src="javax.faces.resource/js/jquery-3.4.0.min.js"></script>
<script type="text/javascript" src="javax.faces.resource/js/bootstrap.js"></script>
<script type="text/javascript" src="javax.faces.resource/js/jquery-1.11.2.js"></script>
<script type="text/javascript" src="javax.faces.resource/js/jssor.slider-27.5.0.min.js"></script>
<script type="text/javascript" src="javax.faces.resource/jquery8490.js?ln=js"></script>
<script type="text/javascript" src="javax.faces.resource/menu8490.js?ln=js"></script>
<script type="text/javascript" src="javax.faces.resource/js/canvasjs.min.js"></script>
        
  -->     
        <script type="text/javascript">
            $(function() {
                $('ul.nav li.dropdown').hover(function() {
                    $(this).find('.dropdown-menu').stop(true, true).delay(100).fadeIn(500);
                }, function() {
                    $(this).find('.dropdown-menu').stop(true, true).delay(100).fadeOut(500);
                });
            });
        </script>
        <script type="text/javascript">
            $(function() {
                $("#notice").fadeIn("slow").append('');
                $(".dismis").click(function() {
                    $("#notice").fadeOut("slow");
                });
            });
        </script>
		
<script>
function lfn_SelectSection(p_Class)
    {
        document.getElementById('cusname').disabled=false;
		
  
        $.ajax({
		
                    type: "GET",
                    url: "ajax_location.html?classID=" + p_Class,
                    success: function(state) {
                    document.getElementById('cusname').innerHTML=state;    
					
                    }
        });
		
	 
		
		
    }

</script>
<style> 
        input.largerCheckbox { 
            width: 20px; 
            height: 20px; 
			
        } 
    </style> 
        <title>The Star Salon</title></head><body>

        <div id="top">


                    <div class="container-fluid text-center" style="margin-left: 5px"> 
                        <div class="row">
                            <div class="col-sm-1">
							<!-- Logo -->
							
							
                            </div>                           
                                       
                           
                        </div>
                    </div>

                    <!-- Menu start  -->

                    <nav class="navbar navbar-expand-lg header-m" role="navigation">
                        <div class="container-fluid">
                            <div class="navbar-header">
                                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                                    <span class="sr-only">Toggle navigation</span>
                                    <span class="icon-bar" style="background-color: #fff;"></span>
                                    <span class="icon-bar" style="background-color: #fff;"></span>
                                    <span class="icon-bar" style="background-color: #fff;"></span>
                                </button>
                                <a class="navbar-brand" href="#"></a>
                            </div>

                            <!-- Collect the nav links, forms, and other content for toggling -->
                            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                                <?php include("include/header.php"); ?>
                            </div>

                            <!-- /.navbar-collapse -->
                        </div>
                        <!-- /.container-fluid -->
                    </nav>

        </div>

        <div id="content" class="center_content ">

                    <div class="container-fluid text-center">    
                        <div class="row">
                            <div class="col-sm-2" style="padding-right: 0px;">
							
							
							
							
							
                                <?php include("include/left.php"); ?>

                                </div>

                            </div>

                            <div class="col-sm-8" style="padding-right: 2px; padding-left:2px;">

                                <div class="row" >
                                    <div class="col-sm-12" >

                                        <div class="panel panel-primary" style="background-color: rgb(186,233,254);border: 1px solid #000; margin-bottom: 0px; ">
                                            <div class="panel-heading" style="font-size: 20px; font-family: serif; background-color: #007de8; color:#CCFF00"> <b>Employee Salary / Advance</b>  </div>
                                            <div class="panel-body" style="text-align: justify;padding-bottom: 0px; padding-top: 6px;"><p style="font-family: Cambria;"><strong>
					 
					 


<b><font color="red">Select Employee : </font></b><select name="" id="cat" style="width:200px; height:25px; background-color:#99FF66" onChange="show_p();">
<option  value="0">Select Employee </option>
<?php $c=mysqli_query($con,"select * from user where `type`!='admin' and `status`='active'"); while($cr=mysqli_fetch_array($c,MYSQLI_ASSOC)) 
{  $ct=$cr["id"]; ?>
<option  <?php if($_REQUEST["id"]==$ct) { ?> selected="selected" <?php } else {} ?> value="<?php echo $cr["id"]; ?>"><?php echo $cr["name"]; ?></option>

<?php } ?>
</select>
 &nbsp; <a href="?types=history"><img src="transaction.png" width="17"> <font color="green">Salary & Part Payment History</font></a>
<script>
function show_p() {
 var v=document.getElementById("cat").value;
 window.location.href="?id="+v;
}
</script>
<?php if($_REQUEST["id"]!="" AND $_REQUEST["id"]>=0 OR $_REQUEST["page"]=="home" ) { } else { ?>
<hr>
<form method="post"> Employee
 <select style="width:20%; height:30px;" id="s_e">
										        <option value="0">Show All Employee</option>
<?php $e=mysqli_query($con,"select * from user where `type`!='admin' and `status`='active' ");  while($er=mysqli_fetch_array($e,MYSQLI_ASSOC)) { ?>									        
										        <option value="<?php echo $er["id"]; ?>" <?php if($_REQUEST["emp"]==$er["id"]) { ?> selected <?php } else {} ?> ><?php echo $er["name"]; ?></option>
										        
										        <?php } ?>
										    </select>     
<b><font color="red">From Date : </font></b>
<input type="date" name="fd" id="cat1" style="width:20%; height:25px; background-color:#99FF66" value="<?php echo $_REQUEST['fd']; ?>">&nbsp;&nbsp;&nbsp;
To : &nbsp;&nbsp;&nbsp;<input type="date" name="td" id="cat2" style="width:20%; height:25px; background-color:#99FF66" onChange="show_pp()" value="<?php echo $_REQUEST['td']; ?>"> 

</form>
<script>
function show_pp() {
 var v=document.getElementById("cat1").value;
 var vv=document.getElementById("cat2").value;
  var vvv=document.getElementById("s_e").value;
 window.location.href="?fd="+v+"&td="+vv+"&types=history&emp="+vvv;
}
</script>	
<br>
<?php 
 $from_date=$_REQUEST["fd"];
	 $to_date=$_REQUEST["td"];
?>


<?php $i=1; $fs=0; $sr=0; $t=0; $ars=0; $d=0; 

$q=mysqli_query($con,"select * from salary where  `type`='1' and `date` BETWEEN '".$from_date."' AND '".$to_date."'"); while($qr=mysqli_fetch_array($q,MYSQLI_ASSOC)) { 
$emp_id=$qr["emp_id"];
$a=mysqli_query($con,"select * from user where `id`='".$emp_id."'");
$ar=mysqli_fetch_array($a,MYSQLI_ASSOC);

?>
<tr height="20" style="background-color:#FFFF99"><td align="center"><?php echo $i; ?></td>
<td align="left">&nbsp;<?php echo $ar["name"]; ?> </td>
<td align="left">&nbsp;<?php echo $qr["full_salary"]; $fs=$fs+$qr["full_salary"]; ?> /-</td>
<td align="center"><?php echo $qr["month"]; ?> -<?php echo $qr["year"]; ?>  </td><td align="center">
    <?php $temp_date=date_create($qr["date"]); echo date_format($temp_date,"d/m/y"); ?>
</td>
</tr>
<?php $i++; }?>
<tr style="height:25px; background-color:#9900FF"><td colspan="2" align="right"><font color="white">Total Salary Paid &nbsp</font></td>
<td><font color="white">&nbsp;<?php echo $fs; ?></font></td>

</tr>



</table>

<?php $i=1; $fs=0; $sr=0; $t=0; $ars=0; $q=mysqli_query($con,"select * from salary where  `type`='0' and `mode`='pay' and `date` BETWEEN '".$from_date."' AND '".$to_date."'"); while($qr=mysqli_fetch_array($q,MYSQLI_ASSOC)) { 
$emp_id=$qr["emp_id"];
$a=mysqli_query($con,"select * from user where `id`='".$emp_id."'");
$ar=mysqli_fetch_array($a,MYSQLI_ASSOC);

?>
<tr height="20" style="background-color:#FFFF99"><td align="center"><?php echo $i; ?></td>
<td align="left">&nbsp;<?php echo $ar["name"]; ?> </td><td align="left">&nbsp;<?php echo $qr["advance"]; $fs=$fs+$qr["advance"]; ?> /-</td><td align="center"><?php $temp_date=date_create($qr["date"]); echo date_format($temp_date,"d/m/y"); ?>

</td>
</tr>
<?php $i++; }?>
<tr style="height:25px; background-color:#9900FF"><td colspan="2" align="right"><font color="white">Total Payment &nbsp</font></td><td><font color="white"><?php echo $fs; ?></font></td>

</tr>


</table>

<p>&nbsp;</p>
Payment From Wallet : 
<table width="100%" border="1">
<tr height="30" style="background-color:#9900FF"><td align="center"><font color="#FFFFFF">SI No.</font></td>
<td align="center"><font color="#FFFFFF">Emp. Name</font></td>
<td align="center"><font color="#FFFFFF">Amount</font></td>
<td align="center"><font color="#FFFFFF">Type</font></td>
<td align="center"><font color="#FFFFFF">Balance</font></td>
<td align="center"><font color="#FFFFFF">Date</font></td>
</tr>

<?php $i=1; $fs=0; $sr=0; $t=0; $ars=0; $q=mysqli_query($con,"select * from salary where  `type`='0' and `mode`!='pay' and `date` BETWEEN '".$from_date."' AND '".$to_date."'"); while($qr=mysqli_fetch_array($q,MYSQLI_ASSOC)) { 
$emp_id=$qr["emp_id"];
$a=mysqli_query($con,"select * from user where `id`='".$emp_id."'");
$ar=mysqli_fetch_array($a,MYSQLI_ASSOC);

?>
<tr height="20" style="background-color:#FFFF99"><td align="center"><?php echo $i; ?></td>
<td align="left">&nbsp;<?php echo $ar["name"]; ?> </td><td align="left">&nbsp;<?php echo $qr["advance"]; $fs=$fs+$qr["advance"]; ?> /-</td>
<td ><?php if($qr["mode"]=="dfw") {?>From Wallet <?php  } else {?> For Leave <?php } ?></td>
<td ><?php echo $qr["balance"]; ?> /-</td>
<td align="center"><?php $temp_date=date_create($qr["date"]); echo date_format($temp_date,"d/m/y"); ?>

</tr>
<?php $i++; }?>
<tr style="height:25px; background-color:#9900FF"><td colspan="2" align="right"><font color="white">Total Payment &nbsp</font></td><td><font color="white"><?php echo $fs; ?></font></td>

</tr>


</table>

<?php 
$from_date=$_REQUEST["fd"];
	 $to_date=$_REQUEST["td"];
	 $emp=$_REQUEST["emp"]; 
	 $a=0;
?>
Part Payment History : 
<table width="100%" border="1">
<tr height="30" style="background-color:#9900FF"><td align="center"><font color="#FFFFFF">SI No.</font></td>
<td align="center"><font color="#FFFFFF">Date</font></td>

<td align="center"><font color="#FFFFFF">Payment</font></td>
<td align="center"><font color="#FFFFFF">Wallet</font></td>
</tr> <?
if($emp!="0") {  $emp=$_REQUEST["emp"];  $u=mysqli_query($con,"select * from user where `status`='active' and `id`='".$emp."' "); } else {   $u=mysqli_query($con,"select * from user where `status`='active' and `type` !='admin'"); }  
   
    while($ur=mysqli_fetch_array($u,MYSQLI_ASSOC)) 
    {
        $ii=1;
        $emp=$ur["id"];
         $q=mysqli_query($con,"select * from salary where `mode`='dfw' and `emp_id`='".$emp."' and `type`='0' and   `date` BETWEEN '".$from_date."' AND '".$to_date."'"); 
         $qn=mysqli_num_rows($q);
          if($qn>0) { ?> <tr style="background-color:#FFFFCC"><td colspan="4"><?php echo $emp=$ur["name"]; ?></td></tr><?php   } else {}
         while($qr=mysqli_fetch_array($q,MYSQLI_ASSOC)) 
         { $ii;  ?>
                             <tr height="20" ><td align="center"><?php echo $ii; ?></td>
                    <td align="center"><font ><?php $temp_date=date_create($qr["date"]); echo date_format($temp_date,"d/m/y");?></font></td>
                    
                    <td ><font ><?php echo $qr["advance"]; $a=$a+$qr["advance"]; ?></font></td>
                    <td ><font ><?php echo $qr["balance"];?></font></td>
                    </tr>	 
                             <?php $ii++;
        }
        if($qn>0) { ?>  <tr style="background-color:#FFCCFF"><td colspan="2" align="right">Total : </td><td><?php echo $a; ?></td></tr><?php $qn=0; $a=0; } else {}
        
    }  ?> </table>
 <p>&nbsp;</p>
 Leave History : 
<table width="100%" border="1">
<tr height="30" style="background-color:#9900FF"><td align="center"><font color="#FFFFFF">SI No.</font></td>
<td align="center"><font color="#FFFFFF">Date</font></td>

<td align="center"><font color="#FFFFFF">Payment</font></td>
<td align="center"><font color="#FFFFFF">Wallet</font></td>
</tr> <?
    if($emp!="0") {  $emp=$_REQUEST["emp"];  $u=mysqli_query($con,"select * from user where `status`='active' and `id`='".$emp."' "); } else {   $u=mysqli_query($con,"select * from user where `status`='active'"); }  

    while($ur=mysqli_fetch_array($u,MYSQLI_ASSOC)) 
    {
        $ii=1;
        $emp=$ur["id"];
         $q=mysqli_query($con,"select * from salary where `mode`='dfl' and `emp_id`='".$emp."' and `type`='0' and   `date` BETWEEN '".$from_date."' AND '".$to_date."'"); 
         $qn=mysqli_num_rows($q);
          if($qn>0) { ?> <tr style="background-color:#FFFFCC"><td colspan="4"><?php echo $emp=$ur["name"]; ?></td></tr><?php   } else {}
         while($qr=mysqli_fetch_array($q,MYSQLI_ASSOC)) 
         { $ii;  ?>
                             <tr height="20" ><td align="center"><?php echo $ii; ?></td>
                    <td align="center"><font ><?php $temp_date=date_create($qr["date"]); echo date_format($temp_date,"d/m/y");?></font></td>
                    
                    <td ><font ><?php echo $qr["advance"]; $a=$a+$qr["advance"]; ?></font></td>
                    <td ><font ><?php echo $qr["balance"];?></font></td>
                    </tr>	 
                             <?php $ii++;
        }
        if($qn>0) { ?>  <tr style="background-color:#FFCCFF"><td colspan="2" align="right">Total : </td><td><?php echo $a; ?></td></tr><?php $qn=0; $a=0; } else {}
        
    }  ?> </table>
  <p>&nbsp;</p>
  Advance Salary History : 
<table width="100%" border="1">
<tr height="30" style="background-color:#9900FF"><td align="center"><font color="#FFFFFF">SI No.</font></td>
<td align="center"><font color="#FFFFFF">Date</font></td>

<td align="center"><font color="#FFFFFF">Payment</font></td>
<td align="center"><font color="#FFFFFF">Wallet</font></td>
</tr> <?
    
   if($emp!="0") {  $emp=$_REQUEST["emp"];  $u=mysqli_query($con,"select * from user where `status`='active' and `id`='".$emp."' "); } else {   $u=mysqli_query($con,"select * from user where `status`='active'"); }  

    while($ur=mysqli_fetch_array($u,MYSQLI_ASSOC)) 
    {
        $ii=1;
        $emp=$ur["id"];
         $q=mysqli_query($con,"select * from salary where `balance`<0 and `type`='0' and `emp_id`='".$emp."' and  `date` BETWEEN '".$from_date."' AND '".$to_date."'");

         $qn=mysqli_num_rows($q);
          if($qn>0) { ?> <tr style="background-color:#FFFFCC"><td colspan="4"><?php echo $emp=$ur["name"]; ?></td></tr><?php   } else {}
         while($qr=mysqli_fetch_array($q,MYSQLI_ASSOC)) 
         { $ii;  ?>
                             <tr height="20" ><td align="center"><?php echo $ii; ?></td>
                    <td align="center"><font ><?php $temp_date=date_create($qr["date"]); echo date_format($temp_date,"d/m/y");?></font></td>
                    
                    <td ><font ><?php echo $qr["advance"]; $a=$a+$qr["advance"]; ?></font></td>
                    <td ><font ><?php echo $qr["balance"];?></font></td>
                    </tr>	 
                             <?php $ii++;
        }
        if($qn>0) { ?>  <tr style="background-color:#FFCCFF"><td colspan="2" align="right">Total : </td><td><?php echo $a; ?></td></tr><?php $qn=0; $a=0; } else {}
        
    }  ?> </table>
    
    



<?php }  ?>
<hr>




<?php if($_REQUEST["page"]=="home" ) {  ?>
<b>Last Salary Payment at a glance :	</b>
<form method="post">
   
<b><font color="red">From Date : </font></b>
<input type="date" name="fd" id="cat1" style="width:20%; height:26px; background-color:#99FF66" value="<?php echo $_REQUEST['fd']; ?>">&nbsp;&nbsp;&nbsp;
To : &nbsp;&nbsp;&nbsp;<input type="date" name="td" id="cat2" style="width:20%; height:26px; background-color:#99FF66" onChange="show_pp()" value="<?php echo $_REQUEST['td']; ?>"> 
&nbsp; 
</form><br>
<script>
function show_pp() {
 var v=document.getElementById("cat1").value;
 var vv=document.getElementById("cat2").value;
 window.location.href="?fd="+v+"&td="+vv+"&page=home";
}
</script>	


Details Payment From Wallet : 
<?php  if($_REQUEST["td"]!="") { ?>
<table width="100%" border="1">


<?php  $i=1; $fs=0; $sr=0; $t=0; $ars=0; 
	 $a=mysqli_query($con,"select * from user where `status`='active' and `user_id`!='admin'");
	 while($ar=mysqli_fetch_array($a,MYSQLI_ASSOC)) {?>
	 <tr><td colspan="5" style="background-color:green; height:30px; color:white"><?php echo $ar["name"]; ?></td></tr>
	 <tr height="30" style="background-color:#9900FF"><td align="center"><font color="#FFFFFF">SI No.</font></td>

<td align="center"><font color="#FFFFFF">Amount</font></td>
<td align="center"><font color="#FFFFFF">Type</font></td>
<td align="center"><font color="#FFFFFF">Balance</font></td>
<td align="center"><font color="#FFFFFF">Date</font></td>
</tr><?php 
	     $emp_id=$ar["id"];
	     $from_date=$_REQUEST["fd"];
	 $to_date=$_REQUEST["td"];
	     $q=mysqli_query($con,"select * from salary where `emp_id`='".$emp_id."' and  `type`='0' and `mode`!='pay' and `date` BETWEEN '".$from_date."' AND '".$to_date."'"); 
	        while($qr=mysqli_fetch_array($q,MYSQLI_ASSOC)) { 

?>
<tr height="20" style="background-color:#FFFF99"><td align="center"><?php echo $i; ?></td>
<td align="left">&nbsp;<?php echo $qr["advance"]; $z=$z+$qr["advance"]; $fs=$fs+$qr["advance"]; ?> /-</td>
<td ><?php if($qr["mode"]=="dfw") {?>From Wallet <?php  } else {?> For Leave <?php } ?></td>
<td ><?php echo $qr["balance"]; ?> /-</td>
<td align="center"><?php $temp_date=date_create($qr["date"]); echo date_format($temp_date,"d/m/y"); ?>

</tr>
<?php $i++; } ?>
<tr style="height:25px;"><td colspan="1" align="right"><font >Receive &nbsp</font></td><td><font ><?php echo $z; ?></font></td>
</tr><?php

$i=1; $z=0;  }?>
<tr style="height:25px; background-color:#9900FF"><td colspan="2" align="right"><font color="white">Total Payment &nbsp</font></td><td><font color="white"><?php echo $fs; ?></font></td>

</tr>
</table><p>&nbsp;</p>
<?php } else {} ?>




<table width="100%" border="1">
   <tr style="background-color:#66FFFF">
        <td align="center" style="height:35px;background-color:#66FFFF">Sl No.</td>
		<td align="center">Emp. Name</td><td align="center">Payment Month</td>
		<td align="center">Act. Sal.</td>
		<td align="center">Wall. Pay</td>
		<td align="center">Leave Deduc.</td>
		<td align="center">Cur. Outst.</td>
		<td align="center">Cur. Wallets</td>
    </tr>
        <?php $i=1; $cc=0; 
         $from_date=$_REQUEST["fd"];
	 $to_date=$_REQUEST["td"];
        $ux=mysqli_query($con,"select * from user where `type`!='admin' and `status`='active'"); 
while($uxr=mysqli_fetch_array($ux,MYSQLI_ASSOC)) 
{ 
     $emp_id=$uxr["id"]; $s=mysqli_query($con,"select  SUM(advance) as w from salary where `type`=0 and `mode`='dfw' and `emp_id`='".$emp_id."' and `date` BETWEEN '".$from_date."' AND '".$to_date."'  "); $sr=mysqli_fetch_array($s,MYSQLI_ASSOC);
 $ss=mysqli_query($con,"select  SUM(advance) as w from salary where `type`=0 and `mode`='dfl' and `emp_id`='".$emp_id."' and `date` BETWEEN '".$from_date."' AND '".$to_date."'  "); $ssr=mysqli_fetch_array($ss,MYSQLI_ASSOC);
?> <tr>
    <td align="center"><?php echo $i; ?></td><td>&nbsp;<?php echo $uxr["name"];  ?></td>
    <td>&nbsp;<?php echo $uxr["last_sal_month"]; ?> - <?php echo $uxr["last_sal_year"]; ?></td>
	<td>&nbsp;<?php echo $uxr["salary"]; $a=$a+$uxr["salary"]; ?></td>
	<td>&nbsp;<?php echo $sr["w"]; // echo $uxr["sal_receive"]; $b=$b+$uxr["sal_receive"]; ?></td>
	<td>&nbsp;<?php echo $ssr["w"]; ?></td>
	<td>&nbsp;<?php if($uxr["wallet"]<0) { echo $x=$uxr["wallet"]*-1; $cc=$cc+$x;    } else {} ?></td>
	<td>&nbsp;<?php if($uxr["wallet"]>=0) { echo $uxr["wallet"]; $d=$d+$uxr["wallet"];   } else {} ?></td>
</tr>       

 <?php $i++; } ?>  
  <tr style="background-color:#FFFFCC; height:30px;">
    <td align="center" colspan="3">Total Actual Salary </td>
    
	<td><?php echo $a; ?></td>
	<td colspan=""><?php echo $b; ?></td>
		<td colspan=""><?php  ?></td>
	<td><?php echo $cc; ?></td>
	<td><?php echo $d; ?></td>
</tr>         
 </table>
<?php } else {} ?>



<?php 
$id=$_REQUEST["id"]; 
if($id!="" AND $id!="0") { 
$u=mysqli_query($con,"select * from user where `id`='".$id."'");
$ur=mysqli_fetch_array($u,MYSQLI_ASSOC); ?>				 
<table width="100%" border="0">
<tr><td width="20%" height="27"><b>Name</b></td>
<td width="30%" height="27"><?php echo $ur["name"]; ?></td>
<td rowspan="5"><img src="<?php echo $ur['photo'];?>" width="100"><br>
<?php if($ur['wallet'] >="0" ) {?><font color="blue">Wallet Value : Rs. <?php echo $ur['wallet'];  ?> /-</font> <?php } else { ?>
<font color="red">Outstanding Amount : Rs. <?php echo $ur['wallet']*(-1);  ?> /-</font> 
<?php } ?>
</td></tr>
<tr><td height="28">Phone</td>
<td><?php echo $ur["phone"]; ?></td></tr>
<tr><td height="28">Date of Joining</td>
<td><?php echo $ur["doj"]; ?></td></tr>
<tr><td height="27">Employee Type</td>
<td><?php echo $ur["emp_type"]; ?></td></tr>
<tr><td height="28">Salary</td>
<td><?php echo $ur["salary"]; ?> /- </td></tr>
<tr><td height="28">Wallet</td>
<td><?php if($ur["wallet"]<0) { ?><font color="red">Outstanding Rs. : <?php echo $ur["wallet"]*-1; ?></font> <?php } else { echo $ur["wallet"]; }  ?> /- </td></tr>

</table>	<hr>
<?php } else { } 
 if($_REQUEST['id'] >0) {?>
<table width="100%" border="0" style="background-color:#C1FF84">
<tr><!--<td width="20%"><img src="advance_payment.png" width="140" ></td>--><td width="20%" align="center"><img src="pay_history.png" width="110"></td><td width="20%" align="center"><img src="salary.png" width="110"></td><td width="20%" align="center"><img src="payment.png" width="110"></td></tr>
<tr><!--<td><a href="?type=advance&id=<?php echo $_REQUEST['id']; ?>"><font color="#6600FF">Advance / Part Payment</font></a></td>--><td align="center"><a href="?type=salary_history&id=<?php echo $_REQUEST['id']; ?>"><font color="#6600FF">Salary History</font></a></td><td width="10%" align="center"><a href="?type=salary&id=<?php echo $_REQUEST['id']; ?>"><font color="#6600FF">Update Salary</font></a></td><td width="10%" align="center"><a href="?type=pay_salary&id=<?php echo $_REQUEST['id']; ?>"><font color="#6600FF">Pay Salary</font></a></td></tr>

</table>

<!-- Part Payment -->

<?php } else { }?>		<hr>






















<?php  if($_REQUEST["type"]=="pay_salary") { ?>
<div style="background-color:#FFCCFF"><br>
<form method="post">
&nbsp;	Amount : <input type="text" name="receive_amount" style="height:30px; width:72px;" required > 
<select style="height:30px; width:25%;" onChange="show_b();" id="b" name="receive_type" >
     
    <option value="dfw" ><?php if($ur["wallet"]<0) {?> <font color="red">PAY AS ADVANCE</font> <?php } else { ?> DEDUCT FROM WALLET  <?php } ?> </option>
     <option value="dfl" >DEDUCT FOR LEAVE</option>
     
</select>
<script>
function show_b() {
 var v=document.getElementById("b").value;
 if(v=="dfl" || v=="dfw" ) {
  document.getElementById("apay2").style.display = "inline";
   document.getElementById("apay").style.display = "none";
 }
 else {
  document.getElementById("apay2").style.display = "none";
   document.getElementById("apay").style.display = "inline";
 }
}
</script>
<input type="submit" name="apay" style="height:30px; width:72px;" value="Pay" id="apay"> <input type="submit" name="apay2" style="height:30px; width:72px;display:none" value="Deduct" id="apay2" >

	<input type="text" name="advne" value="<?php echo $ur['remain_advance']; ?>" style="display:none">
		<input type="text" name="wallet" value="<?php echo $ur['wallet']; ?>" style="display:none" >
	<hr width="100%">
	</form>

</div>
<?php } else {} ?>	
<?php  if($_REQUEST["type"]=="salary_history") { ?>
<div style="background-color:#FFCCFF">
    <br>
&nbsp;Salary Paying History : <br> &nbsp;
&nbsp;<table width="100%" border="1">
<tr height="30" style="background-color:#9900FF"><td align="center"><font color="#FFFFFF">SI No.</font></td><td align="center"><font color="#FFFFFF">Total Salary</font></td><td align="center"><font color="#FFFFFF">Payment For</font></td><td align="center"><font color="#FFFFFF">Receive Date</font></td></tr>
<?php $i=1; $t=0; $q=mysqli_query($con,"select * from salary where `emp_id`='".$id."' and `type`='1' order by `id` desc"); while($qr=mysqli_fetch_array($q,MYSQLI_ASSOC)) { ?>
<tr height="20" style="background-color:#FFFF99"><td align="center"><?php echo $i; ?></td><td align="center"><?php echo $qr["full_salary"]; ?> /-</td><td align="center"><?php echo $qr["month"]; ?> -<?php echo $qr["year"]; ?>  </td>
<td align="center">
    <?php $temp_date=date_create($qr["date"]); echo date_format($temp_date,"d/m/y"); ?>
    </td>

    </tr>
<?php $i++; }?>

</table>
<p>&nbsp;</p>
</div>
<?php } else {} ?>				 
	<?php  if($_REQUEST["type"]=="salary") { ?>
	<div style="background-color:#FFCCFF">
	<form method="post">
	Curent Salary : <input type="text" name="salary" style="height:30px; width:72px;" value="<?php echo $ur['salary']; ?>"> <input type="submit" name="update" style="height:30px; width:72px;" value="Update">
	<hr width="40%">
	</form>
	<?php if(isset($_POST["update"]))
        { 
		  $sal= $_POST["salary"];
		  $date=date('Y-m-d');
		  mysqli_query($con,"insert into salary_increment(`emp_id`,`salary`,`date`) values('".$id."','".$sal."','".$date."')");
		  mysqli_query($con,"update user set `salary`='".$sal."' where `id`='".$id."'");?>
		   <script>alert("successfully updated"); window.location.href="?id=<?php echo $id; ?>"</script><?php 
		}
	?>
Salary Increment History : <br> &nbsp;
&nbsp;<table width="100%" border="1">
<tr height="30" style="background-color:#9900FF"><td align="center"><font color="#FFFFFF">SI No.</font></td><td align="center"><font color="#FFFFFF">Salary</font></td><td align="center"><font color="#FFFFFF">Increment Date</font></td></tr>
<?php $i=1; $t=0; $q=mysqli_query($con,"select * from salary_increment where `emp_id`='".$id."' order by `id` desc"); while($qr=mysqli_fetch_array($q,MYSQLI_ASSOC)) { ?>
<tr height="20" style="background-color:#FFFF99"><td align="center"><?php echo $i; ?></td><td align="center"><?php echo $qr["salary"]; ?> /-</td><td align="center">
    <?php $temp_date=date_create($qr["date"]); echo date_format($temp_date,"d/m/y"); ?> </td></tr>
<?php $i++; }?>

</table>
<p>&nbsp;</p>
</div>
<?php } else {} ?>	
<?php  if($_REQUEST["type"]=="pay_salary") { ?>
	<div style="background-color:#FFCC00">
	<form method="post">

	
	<input type="text" value="<?php echo $ur["remain_advance"]; ?>"  style="display:none" name="remain_advance"> <br>
		<input type="text" id="cs" value="<?php echo $ur["salary"]; ?>"  style="display:none" name="full_salary">
	<input type="text"  value="<?php echo $ur["wallet"]; ?>"  style="display:none" name="wallet">
	</font>
	&nbsp;Pay Salary 
	   For <select style="height:30px; width:72px;" name="month">
	<option value="JAN" <?php if(date('M')=="Jan") { ?> selected <?php } else {  } ?>>JAN</option>
	<option value="FEB" <?php if(date('M')=="Feb") { ?> selected <?php } else {  } ?>>FEB</option>
	<option value="MAR" <?php if(date('M')=="Mar") { ?> selected <?php } else {  } ?>>MAR</option>
	<option value="APR" <?php if(date('M')=="Apr") { ?> selected <?php } else {  } ?>>APR</option>
	<option value="MAY" <?php if(date('M')=="May") { ?> selected <?php } else {  } ?>> MAY</option>
	<option value="JUN" <?php if(date('M')=="Jun") { ?> selected <?php } else {  } ?>>JUN</option>
	<option value="JUL" <?php if(date('M')=="Jul") { ?> selected <?php } else {  } ?>>JUL</option>
	<option value="AUG" <?php if(date('M')=="Aug") { ?> selected <?php } else {  } ?>>AUG</option>
	<option value="SEP" <?php if(date('M')=="Sep") { ?> selected <?php } else {  } ?>>SEP</option>
	<option value="OCT" <?php if(date('M')=="Oct") { ?> selected <?php } else {  } ?>>OCT</option>
	<option value="NOV" <?php if(date('M')=="Nov") { ?> selected <?php } else {  } ?> >NOV</option>
	<option value="DEC" <?php if(date('M')=="Dec") { ?> selected <?php } else {  } ?>>DEC</option>
	</select>
	<select style="height:30px; width:72px;" name="year">
	 
	  <option value="2020">2020</option>
	</select>
	<script>
	function fs() {
	 var bn=document.getElementById("sal").value;
	 var bn2=document.getElementById("cs").value;
	 var s=bn2-bn;
	 document.getElementById("da").value=s;
	}
	</script>

	<input type="submit" name="pay_wallet" style="height:30px; width:110px;" value="Pay to Wallet"> 
		
	<hr >
<!-- Part Payment -->	

	
	</form>

</div>
<div>
Part Payment Receive History  : <br> &nbsp;
<table width="100%" border="1">
<tr height="20" style="background-color:#663333"><td align="center"><font color="#FFFFFF">SI No.</font></td><td align="center"><font color="#FFFFFF">Amount</font></td><td align="center"><font color="#FFFFFF">Date of Receive</font></td><td align="center"><font color="#FFFFFF">Deduct Type</font></td></tr>
<?php $i=1; $t=0; $q=mysqli_query($con,"select * from salary where `emp_id`='".$id."' and `type`='0' order by `id` desc"); while($qr=mysqli_fetch_array($q,MYSQLI_ASSOC)) { ?>
<tr height="20" style="background-color:#FFFF99"><td align="center"><?php echo $i; ?></td><td align="center"><?php echo $qr["advance"]; $t=$t+$qr["advance"]; ?> /-</td><td align="center"><?php 
$temp_date=date_create($qr["date"]); echo date_format($temp_date,"d/m/y"); ?></td><td align="center">
    <?php if($qr["mode"]=="dfl") {?> Leave <?php  } else { ?> Payment <?php } ?>
    
</td></tr>
<?php $i++; }?>
<!--
<tr height="30" style="background-color:#CCCCFF"><td colspan="2" align="right">Total Advance Rs. &nbsp;</td><td align="left">&nbsp;<?php echo $t; ?> /-</td></tr> -->
</table><p>&nbsp;</p>

</div>
<?php } else {} ?>	
<?php   
if(isset($_POST["pay_ok"]))
        { 
	$id=$_REQUEST["id"];
	$full_salary=$_POST["full_salary"];	
	$pay_salary=$_POST["salary"];
	$leave=$_POST["leave"];
	$date=date('Y-m-d');
	$curent_advance=$_POST["remain_advance"];
	$deduct_amount=$full_salary-$pay_salary;
	$remain_advance=$_POST["remain_advance"]-$deduct_amount;
	$remain=$rs2+$rs;
	$year=$_POST["year"];
	$month=$_POST["month"];
		$wallet=$_POST["wallet"];
			$w_deduct=$_POST["w_deduct"];
			$w_deduct2=$wallet+$w_deduct;
	 mysqli_query($con,"update user set `last_sal_month`='".$month."',`last_sal_year`='".$year."',`leave`='".$leave."',`sal_receive`='".$pay_salary."',`sal_type`='salary',`wallet`='".$w_deduct2."' where `id`='".$id."'");	
	
	 mysqli_query($con,"insert into  salary (`emp_id`,`full_salary`,`salary_receive`,`deduct`,`date`,`type`,`remain_advance`,`year`,`month`,`leave_day`,`advance_revenue`) values('".$id."','".$full_salary."','".$pay_salary."','".$deduct_amount."','".$date."','1','".$remain_advance."','".$year."','".$month."','".$leave."','".$w_deduct."')");	
		?>
<script>alert("Successfully Salary Paid");
window.location.href="?id=<?php echo $_REQUEST['id']; ?>";
</script><?php 		
		} 
	
	
		if(isset($_POST["pay_wallet"]))
        { 
	$id=$_REQUEST["id"];
	$full_salary=$_POST["full_salary"];	
	$wallet=$_POST["wallet"];	
	$date=date('Y-m-d');
   $current_wallet=$wallet+$full_salary;

	$year=$_POST["year"];
	$month=$_POST["month"];
	// mysqli_query($con,"update user set `remain_advance`='".$remain_advance."' where `id`='".$id."'");
	mysqli_query($con,"update user set `wallet`='".$current_wallet."' ,`last_sal_month`='".$month."',`last_sal_year`='".$year."' where `id`='".$id."'");
	
	 mysqli_query($con,"insert into  salary (`emp_id`,`full_salary`,`date`,`type`,`year`,`month`,`wallet`) values('".$id."','".$full_salary."','".$date."','1','".$year."','".$month."','".$current_wallet."')");	
		?>
<script>alert("Successfully Salary Paid");
window.location.href="?id=<?php echo $_REQUEST['id']; ?>";
</script><?php 		
		} 




if(isset($_POST["apay"]))
        { 
	$id=$_REQUEST["id"];
	$receive_amount=$_POST["receive_amount"];	
	$receive_type=$_POST["receive_type"];
	$date=date('Y-m-d');
	$wallet=$_POST["wallet"];
	$current_wallet=$wallet-$receive_amount;
	mysqli_query($con,"update user set  `advance_date`='".$date."',`wallet`='".$current_wallet."' where `id`='".$id."'");	
	
	mysqli_query($con,"insert into  salary (`emp_id`,`advance`,`type`,`mode`,`date`,`balance`) values('".$id."','".$receive_amount."','0','".$receive_type."','".$date."','".$current_wallet."')");	
		?>
<script>alert("  Successfully Done");
window.location.href="?id=<?php echo $_REQUEST['id']; ?>&type=pay_salary";
</script><?php 		
		} ?>
<?php 		
		if(isset($_POST["apay2"]))
        { 
	$id=$_REQUEST["id"];
	$receive_amount=$_POST["receive_amount"];	
	$receive_type=$_POST["receive_type"];
	$date=date('Y-m-d');
	$wallet=$_POST["wallet"];
	$current_wallet=$wallet-$receive_amount;
	mysqli_query($con,"update user set  `advance_date`='".$date."',`wallet`='".$current_wallet."' where `id`='".$id."'");	
	
	mysqli_query($con,"insert into  salary (`emp_id`,`advance`,`type`,`mode`,`date`,`balance`) values('".$id."','".$receive_amount."','0','".$receive_type."','".$date."','".$current_wallet."')");	
		?>
<script>alert("  Successfully Done");
window.location.href="?id=<?php echo $_REQUEST['id']; ?>&type=pay_salary";
</script><?php 		
		} ?>				
					 
	<!--				 					
											 <select name="class" id="class" class="form-control" onChange="lfn_SelectSection(this.value);">
                                            <option value="">--- Please Select Class ----</option>
                                             <option value="A">A</option>
											 <option value="B">B</option>
											 <option value="C">C</option>
                                             </select>
											Section
											 <select type="text" name="secname" id="secname" class="form-control" >
                                        	<option value="0">------select Section_o------</option>

                                        </select> -->	
										
                                                    </strong></p></div>
                                        </div>



                                    </div>
                                </div>

                            <!--   <div class="well" style="padding: 5px;background-color: rgb(186,233,254); border: 1px solid #000; margin-bottom: 1px;">
                                    <div class="row">
                                        
                                        
                                       
                                        
                                        
                                        
                                    </div> 
                                </div>-->
                                <div class="row">
                                   <!-- <div class="col-sm-2">
                                        <div class="panel panel-primary" style="background-color: antiquewhite;">
                                            <div class="panel-body" style="border: 1px solid #000"><img src="javax.faces.resource/school-educatione0f8.png?ln=img" width="50" />  </div>
                                            <div class="panel-footer" style="padding: 1px 2px; background-color: #007de8; font-size: 13px;"><a href="../e_Pension/AdminLogin.html"> School Education Department Users</a>  </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-2">
                                        <div class="panel panel-primary" style="background-color: #7c5a5e;">
                                            <div class="panel-body" style="border: 1px solid #000"><img src="javax.faces.resource/villagee0f8.png?ln=img" width="50" /></div>
                                            <div class="panel-footer" style="padding: 1px 2px;background-color: #007de8; font-size: 13px;"><a href="../e_Pension/AdminLogin.html">P &amp; R D Department Users</a>  </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-2">
                                        <div class="panel panel-primary" style="background-color: #f6f191;">
                                            <div class="panel-body" style="border: 1px solid #000"><img src="javax.faces.resource/librarye0f8.png?ln=img" width="50" /></div>
                                            <div class="panel-footer" style="padding: 1px 2px;background-color: #007de8; font-size: 13px;"><a href="../e_Pension/AdminLogin.html">UD &amp; MA Department Users</a>  </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-2">
                                        <div class="panel panel-primary" style="background-color: #fff;">
                                            <div class="panel-body" style="border: 1px solid #000"><img src="javax.faces.resource/images6e0f8.png?ln=img" width="50" /></div>
                                            <div class="panel-footer" style="padding: 1px 2px;background-color: #007de8; font-size: 13px;"><a href="../e_Pension/AdminLogin.html"> MEE &amp; LS Department Users</a>  </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-2">
                                        <div class="panel panel-primary" style="background-color: #ffdc6a;">
                                            <div class="panel-body" style="border: 1px solid #000"><img src="javax.faces.resource/treasurye0f8.png?ln=img" width="50" /></div>
                                            <div class="panel-footer" style="padding: 10px 5px;background-color: #007de8; font-size: 13px;"><a href="../e_Pension/AdminLogin.html">Treasury Users</a>  </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-2">
                                        <div class="panel panel-primary" style="background-color: #5cfef2;">
                                            <div class="panel-body" style="border: 1px solid #000"><img src="javax.faces.resource/users-groupe0f8.png?ln=img" width="50" /></div>
                                            <div class="panel-footer" style="padding: 1px 2px;background-color: #007de8; font-size: 12px;"><a href="../e_Pension/AdminLogin.html">Other Departments Users</a>  </div>
                                        </div>
                                    </div>    -->
                                </div>
                            
                               

                            </div>
                            <div class="col-sm-2" style="padding-left:0px;">
                                <?php include("include/right.php"); ?>
                            </div>                     
                        </div>

                    </div>
</form>
        </div>


       <?php include("include/footer.php"); ?>

		
		
		</body>



</html>