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

require "financial_year_calculation.php";
$accountyear    = $financialYearStart."-".$financialYearEnd;

$saleid  = $_GET['id'];
$sql_employee = mysqli_query($conn,"SELECT id,ename FROM employee_master WHERE isdelete='1' order by ename ASC ");
$row_employee = '';

$sql = mysqli_query($conn,"SELECT * FROM  employee_advance_collection WHERE id='$saleid' ");
 
$row=mysqli_fetch_array($sql,MYSQLI_ASSOC);

$advance_no  = $row['advance_no'];
$advance_date   = $row['advance_date'];
$employee_id        = $row['employee_id'];
$employeename      = $row['employeename'];
$advance_amount=$row['advance_amount'];
$advance_collection_amount=$row['advance_collection_amount'];
$remarks=$row['remarks'];
$paytype=$row['paytype'];



date_default_timezone_set('Asia/Kolkata');
$currentTime = date( 'h:i:s A', time () );


?>

<!DOCTYPE html>
<html>
<head>
    <title>Advance Add</title>
    <?php require 'header.php' ?>
    <style>
    
    .table-grid{
        display: grid;
        width:95%;
        max-width: 95vw;
        margin:0px auto;
        height:100px;
        background-color: sandybrown;
        grid-template-columns: 200px repeat(8, auto) 90px;
    }
    .each-section{
        background-color: aqua;
        display:grid;
        grid-template-rows: 50% 50%;
    }
    .each-section div{
        background-color: white;
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 0px 10px;
        border: 1px solid #ccc;
    }
    .section-label{
        font-weight:700;
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        font-size:14px;
       
    }
    .section-input{
        background-color: #eee !important;
    }
    
    @media screen and (max-width:720px){
        .table-grid{
            display: flex;
            flex-direction: column;
            height:auto;
        }
        .each-section{
            grid-template-rows: 100%;
            grid-template-columns: 40% 60%;
            padding: 0px 0px;
        }
        .each-section div{
            padding: 10px;
        }
        .section-input input[type=button]{
            width:80%;
        }
    }
</style>


    
</head>
<body>
    <?php require 'menu.php' ?>
<div class="container-fluid">
<form class="form-horizontal" action="Advance_collection_update.php" method="post" onSubmit="return checkForm(this);" autocomplete="off">

<h3 align="center" >Employee Advance Collection</h3>

<div class="form-group">
      <label class="control-label col-sm-3" for="email">Cash No</label>
      <div class="col-sm-5">
     <input class="form-control input-lg" type="text" name="advance_no" value="<?php echo $advance_no; ?>" readonly>
      </div>

    </div>
    
    <div class="form-group">
      <label class="control-label col-sm-3" for="email">Date</label>
      <div class="col-sm-5">
    <input class="form-control input-lg "  type="date" name="advance_date" autocomplete="off" required value="<?php echo $advance_date; ?>">
      </div>

    </div>
    
    <div class="form-group">
      <label class="control-label col-sm-3" for="email">Emp.Name</label>
      <div class="col-sm-5">
    <select class="form-control input-lg " name="employee_id" id="employee_id" required>
         <option value="<?php echo $employee_id; ?>"><?php echo $employeename ?> </option>
        </select>
      </div>

    </div>

 <div class="form-group">
      <label class="control-label col-sm-3" for="email">Total&nbsp;Advance&nbsp;Amount</label>
      <div class="col-sm-5">
    <input class="form-control input-lg "  type="text" name="advance_amount" id="advance_amount" autocomplete="off" required readonly value="<?php echo $advance_amount; ?>">
      </div>

    </div>
    
    <div class="form-group">
      <label class="control-label col-sm-3" for="email">Collecting&nbsp;Amount</label>
      <div class="col-sm-5">
    <input class="form-control input-lg "  type="number" name="advance_collection_amount" autocomplete="off" required value="<?php echo $advance_collection_amount; ?>">
      </div>

    </div>
    
     <div class="form-group">
      <label class="control-label col-sm-3" for="email">Payment Mode</label>
      <div class="col-sm-5">
    <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>
    
    <div class="form-group">
      <label class="control-label col-sm-3" for="email">Remark</label>
      <div class="col-sm-5">
    <textarea class="form-control input-lg "  name="remarks" autocomplete="off"><?php echo $remarks; ?></textarea>
      </div>

    </div>


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

</form>
</div>
    <?php require 'footer.php' ?>
    <script type="text/javascript">var sql_product = "<?= $sql_product ?>";</script>
    <script type="text/javascript">var base_url = "<?= $base_url ?>";</script>
   
    <!-- Include jQuery -->
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>

<!-- Include Date Range Picker -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.1/js/bootstrap-datepicker.min.js"></script>
<script>

  var checkForm = function(form) {

    //
    // validate form fields
    //

    form.myButton.disabled = true;
    return true;
  };


</script>

    

<script>
	 $('#employee_id').change(function(){  
	  var queryx=$(this).val();
	   //alert(queryx);
                $.ajax({  
                     url:"pickadvance.php",   
                     method:"POST",  
                     data:{query:queryx},
                     success:function(data1)  
                     {
						 var data0 = data1.split("||");
                          $('#advance_amount').val("");  
                          $('#advance_amount').val(data0[0]); 
						  
						  //alert(data0[0] ); 
                          
							
					 }
				});
		});
	
	
	
	</script>
 
    

</body>
</html>