<?php include('common/header.php'); ?>
  <!-- Main Sidebar Container -->
<?php include('common/sidenav.php'); ?>
<style>
    .box{
       
        display: none;
       
    }
    .Cheque{ background: #fff; color:#000; }
  
</style>

<?php
 include_once ('includes/config.php');
   
// Check connection
    if ($con->connect_error) {
    die("Connection failed: " . $con->connect_error);
    } 

if(isset($_POST['submit']))
{
 
$sess= $_SESSION['sess_user'];


   
//insert.php
$id = $_GET['id'];
$vendorid =$_POST['vendor_id'];
$date = $_POST['date'];
$bill_no =$_POST['bill_no'];
$chtype =$_POST['type'];
$chequeno = $_POST['cheque_no'];
$bill_amount =$_POST['bill_amount'];
$generate_amount =$_POST['generate_amount'];
$new_balance =$_POST['new_balance'];





 // Check connection
    if ($con->connect_error) {
    die("Connection failed: " . $conn->connect_error);
    } 
  else

 

    
    $id = $_GET['id'];
    $query="Update payment_generate Set `bill_no`='".$bill_no."' where pay_id='$id' ";
    $res = mysqli_query($con, $query);
    
    
    
?>
  <script>
        alert('Record has Been Updated Successfully.');
        window.location.href='payment.php';
    </script>
<?php



$con->close();
}
 ?>
 
  <?php
//vendor
include('includes/config.php');
$v = '';

$query = "SELECT * FROM `vendors` ORDER BY company_name ASC";
$result = mysqli_query($con, $query);
while($row = mysqli_fetch_array($result))
{
 $v .= '<option value="'.$row["v_id"].'">'.$row["company_name"].' </option>';
}
?>


  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
  

    <!-- Content Header (Page header) -->
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1>Add Payment</h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item">  <a  href="payment.php" ><i class="fa fa-link">Payment List</i></a></li>
             
            <!--  <li class="breadcrumb-item active"><a href="#">Dashboard</a></li>-->
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>

    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-12">


            <div class="card">
              <div class="card-header">
   
                <h3 class="card-title">Edit Info</h3>
              </div>
        
              <!-- /.card-header -->
              <div class="card-body">

                           <!-- add driver -->
    
      	<form  method="post">
          		<?php
                     // check total bill amount
    include('includes/config.php');
               
     $id = $_GET['id'];
      $resultbill = mysqli_query($con, "SELECT * FROM `payment_generate` as p JOIN vendors as v On p.vendor_id= v.v_id where p.pay_id='$id'");
       while($rowbill = mysqli_fetch_assoc($resultbill)) {
    
  ?>
          	    <div class="row">
          	        <div class="col-md-4">
                       <div class="form-group">
                              <label>Bill No</label>
                                <input type="text" placeholder="Bill No"  class="form-control" name="bill_no" value="<?php echo $rowbill['bill_no'] ?>">
                      </div>       
                        
                    </div>
                    
          	       
          	      
          	      
                     
          	    </div>
          	  
          	    <?php } ?>
          	    
                       
                <div class="row">
                  <div class="col-md-6">
                      <div class="form-group">
                           
                      <div class="form-example-int mg-t-15">
                            <button name="submit" class="btn btn-danger notika-btn-success">Submit</button>
                        </div>
                     
                  </div>
                </div>
                </div>
           </form>
              

    <!-- end add driver -->
                
                
                
                
                
              </div>
              <!-- /.card-body -->
            </div>
            <!-- /.card -->
          </div>
          <!-- /.col -->
        </div>
        <!-- /.row -->
      </div>
      <!-- /.container-fluid -->
    </section>
    <!-- /.content -->





<Script>
function minus()
{
    d = Number(document.getElementById('total_bill').value);
	e = Number(document.getElementById('generate_amount').value);
	f= d - e;
	 
	document.getElementById('new_balance').value = f;

   	
  /* 	a = Number(document.getElementById('payable').value);
	b = Number(document.getElementById('g_amount').value);
	c= a + b;

   	document.getElementById('add_payable').value = c;*/
   	
}
</script>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></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>

  </div>
  <!-- /.content-wrapper -->


<?php include('common/footer.php'); ?>