<?php 

require_once("config/configDB.php"); 
require "userPermission.php";
require "spareMasterFetchData.php";

$edit_id=$_GET['id'];


$sql_ename=mysqli_query($conn,"select * from employee_payment where id='$edit_id'");
while($row_emp=mysqli_fetch_array($sql_ename))
{
$salary_no   = $row_emp['salary_no'];
$given_date    = $row_emp['given_date'];
$ecode   = $row_emp['ecode'];
$employee_name    = $row_emp['employee_name'];
$fromDate   = $row_emp['fromdate'];
$toDate    = $row_emp['todate'];
$advance   = $row_emp['advance_amount'];
$collected_amt    = $row_emp['collected_amt'];
$remaining_amt   = $row_emp['remaining_amt'];
$total_shift    = $row_emp['total_shift'];
$total_ot   = $row_emp['total_ot'];
$salary_amount    = $row_emp['salary_amount'];
$pending_salary    = $row_emp['pending_salary'];

$total_salary   = $row_emp['total_salary'];
$paidamount    = $row_emp['paidamount'];
$givenby    = $row_emp['givenby'];


$paytype   = $row_emp['paytype'];
$refno    = $row_emp['refno'];
$remarks    = $row_emp['remarks'];

}




?>

<!DOCTYPE html>
<html>
<head>
    <title>Employee Payment</title>
    <?php require 'header.php' ?>

</head>
<body>
    <?php require 'menu.php' ?>
    <div class="container-fluid text-center">
    <div class="row col-sm-12">
      <strong><h3>Employee Payment</h3></strong>
     
      </div>
    </div>
    <br><br>



<div class="container-fluid">
    <form class="form-horizontal" action="employeePaymentUpdate.php" method="post" onSubmit="return validateForm()" name="myForm">
    
    
    <div class="col-sm-12 row">
      <div class=" col-sm-2"><label class="control-label">Sal.No</label></div>
        <div class=" col-sm-2 form-group">
          
         <input type="text" class="form-control"  name="salary_no"  value="<?php echo $salary_no;?>" readonly>
          <input type="hidden" class="form-control"  name="edit_id"  value="<?php echo $edit_id;?>" readonly>
        </div>
        
        <div class=" col-sm-2"> <label class="control-label">Sal.Date</label></div>
        <div class="col-sm-2 form-group">
         
          <input type="text" class="form-control given_date"  name="given_date" value="<?php echo $given_date;?>">
        </div>
        
        <div class=" col-sm-2"> <label class="control-label">Emp.Name</label></div>
        <div class="col-sm-2 form-group">
         
         <input type="text" class="form-control"  name="employee_name"  value="<?php echo $employee_name;?>" readonly>
      <input type="hidden" class="form-control"  name="ecode"  value="<?php echo $ecode;?>" readonly>
        </div>
        </div>
    
    
    
     <div class="col-sm-12 row">
      <div class=" col-sm-2"><label class="control-label">From Date</label></div>
        <div class=" col-sm-2 form-group">
          
         <input type="text" class="form-control given_date"  name="fromDate" value="<?php echo $fromDate;?>" readonly>
        </div>
        
        <div class=" col-sm-2"> <label class="control-label">To Date</label></div>
        <div class="col-sm-2 form-group">
         
           <input type="text" class="form-control given_date"  name="toDate" value="<?php echo $toDate;?>" readonly>
        </div>
        
        <div class=" col-sm-2"> <label class="control-label">Total&nbsp;Advance</label></div>
        <div class="col-sm-2 form-group">
         <input type="text" class="form-control "  name="advance" value="<?php echo $advance;?>" readonly>
        </div>
        </div>
    
    
    <div class="col-sm-12 row">
      <div class=" col-sm-2"><label class="control-label">Collected&nbsp;Amount</label></div>
        <div class=" col-sm-2 form-group">
          
        <input type="text" class="form-control given_date"  name="collected_amt" value="<?php echo $collected_amt;?>" readonly>
        </div>
        
        <div class=" col-sm-2"> <label class="control-label"> Remaining&nbsp;Amount</label></div>
        <div class="col-sm-2 form-group">
         
          <input type="text" class="form-control" placeholder="" name="remaining_amt" value="<?php echo number_format($remaining_amt,2,'.','');?>" required readonly>
        </div>
        
        <div class=" col-sm-2"> <label class="control-label">Total&nbsp;Shift</label></div>
        <div class="col-sm-2 form-group">
         <input type="text" class="form-control "  name="total_shift" value="<?php echo number_format($total_shift,2,'.','');?>" readonly>
        </div>
        </div>
        
         <div class="col-sm-12 row">
          <div class=" col-sm-2"> <label class="control-label">Total&nbsp;Extra.Hrs</label></div>
        <div class="col-sm-2 form-group">
         <input type="text" class="form-control "  name="total_ot" value="<?php echo number_format($total_ot,2,'.','');?>" readonly>
        </div>
        
        <div class=" col-sm-2"> <label class="control-label">Salary Amount</label></div>
        <div class="col-sm-2 form-group">
         <input type="text" class="form-control"  name="salary_amount" value="<?php echo $salary_amount ; ?>" required readonly>
        </div>
        
         <div class=" col-sm-2"> <label class="control-label">Pending&nbsp;Salary</label></div>
        <div class="col-sm-2 form-group">
         <input type="text" class="form-control"  name="pending_salary"  required value="<?php echo number_format($pending_salary,2,'.','');?>" readonly="readonly">
        </div>
         
         </div>
         
         
         
         <div class="col-sm-12 row">
          <div class=" col-sm-2"> <label class="control-label">Total&nbsp;Salary&nbsp;Amt</label></div>
        <div class="col-sm-2 form-group">
         <input type="text" class="form-control "  name="total_salary" value="<?php echo $total_salary ; ?>" readonly >
        </div>
        
       
        
         <div class=" col-sm-2"> <label class="control-label">Paid Amount</label></div>
        <div class="col-sm-2 form-group">
         <input type="text" class="form-control"  name="paidamount"  required value="<?php echo $paidamount;?>" >
        </div>
        
         <div class=" col-sm-2"> <label class="control-label">Given By</label></div>
       <div class="col-sm-2 form-group">
    <?php $sql1 = mysqli_query($conn,"select ename from employee_master ");?>
        <select  class="form-control input-lg  select-trip-drivername selectpicker"  name="givenby" id="givenby">
        <option><?php  echo $givenby;?></option>
        <?php while($row1=mysqli_fetch_array($sql1)){?>
        <option><?php echo $row1['ename'];}?></option>
		</select> 
        </div>
         
         </div>
         
    
	<div class="col-sm-12 row">
     
        
        
        <div class=" col-sm-2"> <label class="control-label">Payment&nbsp;Type</label></div>
         <div class="col-sm-2 form-group">
   
        <select  class="form-control"  name="paytype" id="paytype" required>
		<option><?php  echo $paytype;?></option>
            <option >Cash</option>
            <option >Cheque</option>
            <option >Online</option>
		</select>
        </div>
        
        <div class=" col-sm-2"> <label class="control-label">Refno</label></div>
   <div class="col-sm-2 form-group"> <input type="text" class="form-control "  name="refno" value="<?php  echo $refno;?>" >
       
        </div>
        
         <div class=" col-sm-2"> <label class="control-label">Remarks</label></div>
   <div class="col-sm-2 form-group"> <input type="text" class="form-control "  name="remarks" value="<?php  echo $remarks;?>" >
       
        </div>
    
    </div>
    
    

	<div class="form-group">        
      <div class="col-sm-12 text-center">
        <button type="submit" name="myButton" class="btn btn-default btn-lg">Save</button>
      </div>
    </div>
	
	
    
  </form>   
</div>


    <?php require 'footer.php' ?>
	
	<script>
$(document).ready(function(){
  
  var date_input=$('input[name="given_date"]'); //our date input has the name "date"
	var container=$('form >  .datepicker-given_date').length>0 ? $('form > .datepicker-given_date').parent() : "body";
	date_input.datepicker({ format: 'yyyy-mm-dd',container: container,todayHighlight: true,autoclose: true  });
    
  //$('input[name="given_date"]').datepicker( "setDate", new Date()); 

});
</script>
<script>$(document).ready(function(){
    $("select").change(function(){
        $(this).find("option:selected").each(function(){
            var optionValue = $(this).attr("value");
            if(optionValue){
                $(".box").not("." + optionValue).hide();
                $("." + optionValue).show();
            } else{
                $(".box").hide();
            }
        });
    }).change();
});
</script>

</body>
</html>