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

require_once("config/configDB.php"); 

$id  =  $_GET['id'];

$sql = mysqli_query($conn,"SELECT * FROM cash_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'];
$empname   = $row['empname'];
$expenser   = $row['expenser'];
$expense_details=$row['expense_details'];


$amount   = $row['amount'];


$remark   = $row['remark'];



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

$sql_employee = mysqli_query($conn,"SELECT id,ename FROM employee_master WHERE isdelete='1' order by ename ASC ");
$row_employee = '';
?>
<!DOCTYPE html>
<html>
<head>
    <title>Expense Entry</title>
    <?php require 'header.php' ?>
     <style>
	
	@font-face
	{
	font-family:Bamini;
	src:url(fonts/Bamini.TTF);
	
	}
	.tamil
	{
	font-family:Bamini;
	
	}
	
	
	</style>

</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; ?>" readonly >
      <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 input-lg selectpicker" data-live-search="true" id="sel1" name="expensetype" required >
         <?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">
     
       
        <select class="form-control input-lg selectpicker" data-live-search="true" name="expenser" required>
        <option value="">Please Select the Employee </option>
        <?php
        while($row4 = mysqli_fetch_array($sql_employee)){
        ?>
        <option value="<?php echo $row4['id'] ?>" <?php if( $expenser == $row4['id'] ): ?> selected="selected"<?php endif; ?> > <?php echo $row4['ename']; ?> </option>
        <?php
        //echo "<option value='".$row['id']."'>".$row['cname']."</option>";
        }
        ?>
        </select>
     
      </div>
    </div>
    
    <div class="form-group">
      <label class="control-label col-sm-3" for="email">Expense Details </label>
      <div class="col-sm-5">
        <input type="text" class="form-control" name="expense_details" value="<?php echo $expense_details; ?>" required>
      </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; ?>" required>
      </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>
    
    <SCRIPT language=JavaScript src="js/utf.js"></SCRIPT>
		<SCRIPT language=JavaScript src="js/tamil.js"></SCRIPT>
		
		<script>
			$(document).ready(function(){
				$('input,textarea').on('keydown',function(event){
					if(event.which==121){
						$(this).toggleClass('tamil');
						return false;
					}
					if($(this).hasClass('tamil')){
						toggleKBMode(event);
					}else{
						return true;
					}
				});
				$('input,textarea').on('keypress',function(event){
					if($(this).hasClass('tamil')){
						convertThis(event);
					}
				});
			});
		</script>
</body>
</html>