<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="datatable/data.css">
<script src="datatable/data.js" type="text/javascript"></script>
<script src="datatable/table.js" type="text/javascript"></script>
<script src="datatable/datatable.js"></script>
<link rel="stylesheet" href="datatable/data-boot.css">
<link href="javascript/select2.css" rel="stylesheet" >
<script src="javascript/selectt2.js"></script>
<style>
    
    #navbar
    {
        flex:15%;
        height:100%; 
        flex-direction:row;
        overflow:auto;
        
    }
    #content
    {
        flex:90%;
        overflow:auto;
        padding-left:10px;
        padding-right:10px;
    }
    #fullbody
    {
        display:flex;
        
         height:100%;         
    }
    label
    {
      font-size:20px;
    }
    .edit
    {
        font-size:18px;
        color:green;
        cursor:pointer;
    }
    .dele
    {
        font-size:18px;
        color:red;
        cursor:pointer;
    }
    .edit:hover
    {
        font-size:20px;
        
    }
    .dele:hover
    {
        font-size:20px;
        color:red;
        cursor:pointer;
        
    }
    td
    {
      text-align:center;
    }
    th
    {
      text-align:center;
    }
    li a 
    {
      color:black;
    }
    .page-item.active .page-link {
    
    background-color:yellow;
    border-color: #007bff;
}
input[type="date"],input[type="text"]
{
    width:100%;
}
    @media (max-width: 800px) {
        #fullbody
    {
        display:flex;
        flex-wrap: wrap;
    }
        #navbar,#content {
    flex: 100%;
  }
}
</style>
<script>
$(document).ready( function () {
    $('#protable').DataTable();
} );
</script>

</head>
<body>
    
    <div id="fullbody"> 
<div id="navbar" class="bg-info"><?php include "navbar.php"?></div>
<div id="content">
<br>
<h3>Edit Credit</h3>
<br>
<!-- entry for edit  -->
<?php 
$code = $_GET['code'];
$crcedit=mysqli_query($connect,"select *,(select name from customerdetails where customerdetails.code=creditdetails.customer && status!='deleted')as customername from creditdetails where code='$code'&& status!='deleted'");
while($crc_dis = mysqli_fetch_array($crcedit))
{
?>
<form action="update_credit.php" method="post" autocomplete="off">
            <!--  -->
    <!-- entry for edit  -->    
    <div class="row">
                  <div class="col-sm-1"></div>
                  <div class="col-sm-2"><label>Code</label></div>
                  <div class="col-sm-3"><input type="text" class="required" name="code" value="<?php echo $code ?>" placeholder="Enter Code" readonly></div>
              </div><br>
              <div class="row">
                  <div class="col-sm-1"></div>
                  <div class="col-sm-2"><label>Date</label></div>
                  <div class="col-sm-3"><input type="date" class="required" placeholder="Enter Date" name="date" value="<?php echo $crc_dis['date']?>"><input type="hidden" class="required" placeholder="Enter Date" name="time" value="<?php echo $crc_dis['time']?>"></div>
                  <div class="col-sm-2"><label>Customer</label></div>
                  <div class="col-sm-3"><select class="form-control selectpro required" id="customerAdd" name="customer" required><br>
              <option value="<?php echo $crc_dis['customer']?>"><?php echo $crc_dis['customername']?></option>
              <?php 
              $customer = $crc_dis['customer'];
$cus=mysqli_query($connect,"select * from customerdetails where status !='deleted' && code !='$customer'");
while($cusshow = mysqli_fetch_array($cus))
{
?>
<option value="<?php echo $cusshow['code'] ?>"><?php  echo $cusshow['name'] ?></option>
        <?php }?>          
  
              </select>
</div>
              </div><br>
              <input type="hidden" value="<?php echo $crc_dis['sales_code'];?>" id="prior_sales_value"> 
              <div class="row">
                <div class="col-sm-1"></div>
                <div class="col-sm-2"><label>Invoice</label></div>
                 <div class="col-sm-3"><select class="form-control selectpro required" id="invoiceAdd" name="invoice" required><br>
              <option value="">--Select Bill--</option>
              
<!-- <option value="<?php echo $cusshow['code'] ?>"><?php  echo $cusshow['name'] ?></option> -->
  
              </select>
</div>
              </div><br>
              <div class="row">
                  <div class="col-sm-1"></div>
                  <div class="col-sm-2"><label>Total Amount</label></div>
                  <div class="col-sm-3"><input type="text" class="required" placeholder="Enter Total" name="totalamount" id="totalAmount" readonly></div>
                  <div class="col-sm-2"><label>Pending Amount</label></div>
                  <div class="col-sm-3"><input type="text" class="required" placeholder="Enter pending" name="pendingamount" id="pendingAmount" readonly></div>
              </div><br>
              <div class="row">
                  <div class="col-sm-1"></div>
                  <div class="col-sm-2"><label>Payment Method</label></div>
                  <div class="col-sm-3"><select class="form-control required" name="paymentmethod" id="paymentMethod">
                  <?php 
                   if($crc_dis['paymentmethod']=="cash"){
                   echo'
                      <option value="cash">Cash</option>
                      <option value="bank">Bank</option>
                      <option value="all">All</option>';}
                      if($crc_dis['paymentmethod']=="bank"){
                        echo'
                        <option value="bank">Bank</option>
                           <option value="cash">Cash</option>
                           <option value="all">All</option>';}
                           if($crc_dis['paymentmethod']=="all"){
                            echo'
                            <option value="all">All</option>
                               <option value="cash">Cash</option>
                               <option value="bank">Bank</option>';}
                      ?> 
                  </select></div>
                  <div class="col-sm-2"><label>Cash</label></div>
                  <div class="col-sm-3"><input type="text" class="required" placeholder="Enter Cash" name="cash" id="cashEntry"value="<?php echo $crc_dis['amount']?>"></div>
                  
              </div><br>
              <div class="row">
                  <div class="col-sm-1"></div>
                  <div class="col-sm-2"><label>Bank Amount</label></div>
                  <div class="col-sm-3"><input type="text" class="required" placeholder="Enter payment" name="othercash" id="bankEntry" value="<?php echo $crc_dis['otheramount']?>"></div> <div class="col-sm-2"><label>Cheque/Reference</label></div>
                  <div class="col-sm-3"><input type="text" class="required" placeholder="Enter Cheque No" name="cheque" id="chequeNo" value="<?php echo $crc_dis['cheque']?>"></div>
                 
              </div><br>
             <div class="row">
                  <div class="col-sm-1"></div>
                 <div class="col-sm-2"><label>UPI/Mobile.no</label></div>
                  <div class="col-sm-3"><input  name="upi_number" value="<?php echo $crc_dis['upi_number']?>"></div>
                  <div class="col-sm-2"><label>Remark</label></div>
                  <div class="col-sm-3"><input type="text" class="required" placeholder="Enter Remarks" name="remark"value="<?php echo $crc_dis['remark']?>"><input type="hidden" class="required" placeholder="Enter Remarks" name="financialyear"value="<?php echo $crc_dis['financialyear']?>"></div>
              </div><br>       
              <input type="button"  class="btn btn-success" id="ValidationButton" value="Submit" >
          <input type="hidden" id="submitButton"  class="btn btn-success" data-toggle="modal" data-target="#addpro" value="Add" >
        </div>
<!-- entry for edit -->
        </div>
        
        <!-- Modal footer -->
      
         
       
        
<div class="modal fade" id="addpro">
    <div class="modal-dialog modal-sm">
      <div class="modal-content" style="background-color:rgba(77, 219, 106,0.9)">
      
        <!-- Modal Header -->
        
        
        <!-- Modal body -->
        <div class="modal-body">
          <span style="color:white"><i class="fas fa-check" style="font-size:24px"></i> Credit Have Been Updated Successfully</span>
        </div>
        
        <!-- Modal footer -->
        <div class="modal-footer">
          <button type="submit" type="button" class="btn btn-warning editsubmit" ><span class="spinner-border spinner-border-sm subspin2" data-dismiss="modal"></span>Ok</button>
        </div>
        
      </div>
    </div>
  </div>
  
<!-- modal for add -->
                  </form>
  <?php 
}
?>
<!-- modal for edit -->
</div>
  <!-- alert -->

<button type="button" class="btn btn-primary" id="alertPending" data-toggle="modal" data-target="#pendingLimit" style="display:none">
      </button>

  <!-- The Modal -->
  <div class="modal fade" id="pendingLimit">
    <div class="modal-dialog modal-lg">
     <div class="alert alert-danger alert-dismissible fade show">
    <button type="button" class="close"  data-dismiss="alert">&times;</button>
    <strong>Amount Exceeds</strong>
  </div>
  </div>
  </div>
        
<!-- alert -->

<script> 
    $('.selectpro').select2({ width: '100%',height:'420px;' });
    
</script>
<script>
  $(document).ready(function(){
    //$("#showcredit").hide();
    $(".subspin").hide();
    $(".subspin2").hide();
$(".addsubmit").click(function(){
$(".subspin").show();
});
$(".editsubmit").click(function(){
$(".subspin2").show();
//$(".subspin2").hide();
});
  });
</script>

<script src="js/editcredit.js"></script>
<script src="restriction/credit.js"></script>
</body>
</html>