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


$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 = '';


$sqlInvoiceCount = mysqli_query($conn,"SELECT count(*) as invoice FROM cash_expense_entry where status=''");
 
$rowInvoiceCount=mysqli_fetch_array($sqlInvoiceCount,MYSQLI_ASSOC);

$invoice   = $rowInvoiceCount['invoice']+1;


?>
<!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="expenseEntryInsert.php" method="post" onSubmit="return checkForm(this);" autocomplete="off">
    <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="CSHE-<?php echo $invoice; ?>" readonly>
      </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" id="date" required>
      </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>
        <option value="">Select Expense Type</option>
        <?php
        while($row = mysqli_fetch_array($sql_expense)){
        ?>
        <option value="<?php echo $row['id'] ?>" > <?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 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" 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="number" class="form-control" name="amount" required>
      </div>
    </div>  
    
     <div class="form-group">
      <label class="control-label col-sm-3" for="email">Rermark</label>
      <div class="col-sm-5">
        <input type="text" class="form-control" name="english_remark">
      </div>
    </div>
    
    
    
   
    <div class="form-group">        
      <div class="col-sm-offset-2 col-sm-10">
        <button type="submit" class="btn btn-default" name="myButton">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>

  var checkForm = function(form) {

    //
    // validate form fields
    //

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

</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>