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

require_once("config/configDB.php"); 

$id  =  $_GET['id'];

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

$cashno   = $row['cashno'];
$expensedate   = new DateTime($row['expensedate']);$expensedate   = $expensedate->format('d-m-Y');
$expensetype   = $row['expensetype'];
$expense_des   = $row['expense'];
$expenser   = $row['expenser'];


$amount   = $row['amount'];

$mode  = $row['mode'];
$remark   = $row['remark'];


$sql_expense = mysqli_query($conn,"SELECT id, expense FROM expense_master where flag=1 ");
$row_expense = '';


?>
<!DOCTYPE html>
<html>
<head>
    <title>Expense Entry</title>
    <?php require 'header.php' ?>
    

</head>
<body>
    <?php require 'menu.php' ?>
<div class="container-fluid">
    <form class="form-horizontal" action="expenseEntryUpdate.php" method="post">
    <div class="form-group">
      <label class="control-label col-sm-3" for="email">Cash No</label>
      <div class="col-sm-5">
      <input type="text" class="form-control" name="cashno" value="<?php echo $cashno; ?>" >
      <input type="hidden" value='<?php echo $id; ?>' name="edit_id">
      </div>

    </div>
    <div class="form-group">
      <label class="control-label col-sm-3" for="email">Date</label>
      <div class="col-sm-5">
        <input type="text" class="form-control datepickers" name="expensedate" value="<?php echo $expensedate; ?>" id="date" autocomplete="off">
      </div>
      
    </div>
    <div class="form-group">
      <label class="control-label col-sm-3" for="email">Expense Type</label>
      <div class="col-sm-5">
      <select class="form-control" id="sel1" name="expensetype" >
         <?php
        while($row = mysqli_fetch_array($sql_expense)){
        ?>
        <option value="<?php echo $row['id'] ?>" <?php if( $expensetype == $row['id'] ): ?> selected="selected"<?php endif; ?> > <?php echo $row['expense']; ?> </option>
        <?php
        }
        ?>
        
        </select>
      </div>
    </div>
    
    <div class="form-group">
      <label class="control-label col-sm-3" for="email">Expenser</label>
      <div class="col-sm-5">
      <input type="text" class="form-control"  name="expenser" value="<?php echo $expenser; ?>">
       
      </div>
    </div>
    
    <div class="form-group">
      <label class="control-label col-sm-3" for="email">Expense </label>
      <div class="col-sm-5">
        <input type="text" class="form-control" name="expense" value="<?php echo $expense_des; ?>">
      </div>
    </div>
    
   
    <!-- <div class="form-group">
      <label class="control-label col-sm-3" for="email">Payment Type</label>
      <div class="col-sm-5">
      <select class="form-control" id="sel1" name="paymenttype">
        <option>Select Payment</option>
        
        </select>
      </div>
      
    </div>
    <div class="form-group">
      <label class="control-label col-sm-3" for="email">Silver AQUA</label>
      <div class="col-sm-5">
        <input type="text" class="form-control" name="silverAQUA" value="<?php //echo $silverAQUA; ?>">
      </div>
    </div>
  
    <div class="form-group">
      <label class="control-label col-sm-3" for="email">Available Amount</label>
      <div class="col-sm-5">
        <input type="text" class="form-control" name="availableAmount" value="<?php //echo $availableAmount; ?>">
      </div>
    </div> -->
    
    
    <div class="form-group">
      <label class="control-label col-sm-3" for="email">Expense Mode</label>
      <div class="col-sm-5">
      <select class="form-control" id="mode" name="mode">
        
        <option><?php echo $mode; ?></option>
       <option>Bank</option>
       <option>Gpay</option>
       <option>Phonepe</option>
       <option>Cash</option>
       <option>Cheque</option>
       <option>Other Upi</option>
        
      </select>
      </div>
    </div>
    
    <div class="form-group">
      <label class="control-label col-sm-3" for="email">Amount</label>
      <div class="col-sm-5">
        <input type="text" class="form-control" name="amount" value="<?php echo $amount; ?>">
      </div>
    </div>  
    
    <div class="form-group">
      <label class="control-label col-sm-3" for="email">Remark</label>
      <div class="col-sm-5">
        <input type="text" class="form-control" name="remark" value="<?php echo $remark; ?>">
      </div>
    </div>  
   
    <div class="form-group">        
      <div class="col-sm-offset-2 col-sm-10">
        <button type="submit" class="btn btn-default">Submit</button>
      </div>
    </div>
  </form>   
</div>


    <?php require 'footer.php' ?>

            <!-- 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>
        $(document).ready(function(){
            var date_input=$('input[id="date"]'); 
            var container=$('form >  .datepickers').length>0 ? $('form > .datepickers ').parent() : "body";
            date_input.datepicker({
                format: 'dd-mm-yyyy',
                container: container,
                todayHighlight: true,
                autoclose: true,
            });     
            

        });
    </script>
</body>
</html>