<?php 

require_once("config/configDB.php"); 
require "financial_year_calculation.php";
require "userPermission.php";
require "inDieselProFetchData.php";

$accountyear        = $financialYearStart."-".$financialYearEnd;
$sql_InvoiceQuery   = mysqli_query($conn,"SELECT count(*) as invoice FROM internalunfillpro_diesel WHERE accountyear='$accountyear' ");
$rowInvoiceCount    = mysqli_fetch_array($sql_InvoiceQuery,MYSQLI_ASSOC);
$invoice_count1      = $rowInvoiceCount['invoice']+1;

?>
<!DOCTYPE html>
<html>
<head>
    <?php 
      require 'meta.php'; 
      require 'header.php'; 
    ?>
</head>
<body>
  <?php require 'menu.php' ?>
  <div class="container-fluid">
    <h3 class="text-center"><strong>Internal Unfill Diesel Details</strong></h3>
    <form class="form-horizontal" action="inDieselunfillProInsert.php" method="post" id="inDieselProInvoice" onSubmit="return checkForm(this);" autocomplete="off">
    
    <div class=" col-sm-12 row"><br></div>
    
      <div class="col-sm-12 row">
      <div class=" col-sm-2"><label class="control-label">S.No</label></div>
        <div class=" col-sm-3 form-group">
          
          <input class="form-control input-lg" type="text" name="invoice" value="<?php echo $invoice_count1; ?>" readonly >
        </div>
        
        <div class=" col-sm-2"> <label class="control-label">Date</label></div>
        <div class="col-sm-3 form-group">
         
          <input class="form-control input-lg datepicker-internalprodate"  type="text" name="internalprodate" autocomplete="off" readonly>
        </div>
        </div>
         <div class="col-sm-12 row">
          <div class=" col-sm-2"> <label class="control-label">Stock</label></div>
        <div class="col-sm-3 form-group">
          
          <input class="form-control input-lg" type="text" value="<?php echo number_format($AStock,2,'.',''); ?>" readonly>
        </div>
        <div class=" col-sm-2"><label class="control-label">Vehicle No</label></div>
       <div class=" col-sm-3 form-group">
         
          <select class="form-control input-lg selectpicker select-trip-vehicle" data-show-subtext="true" data-live-search="true" name="vehicleno">
            <option disabled selected>Please Select Vehicle</option>
            <?php   echo $sqlVehicleNo;   ?>
          </select> 
        </div>
        
      </div>
      
      <div class="col-sm-12 row">
          
        <div class=" col-sm-2"><label class="control-label">Driver Name</label></div>
       <div class=" col-sm-3 form-group">
         
          <select class="form-control input-lg selectpicker select-trip-vehicle" data-show-subtext="true" data-live-search="true" name="driverid">
            <option disabled selected>Please Select Driver</option>
            <?php   echo $sqldrivername;   ?>
          </select> 
        </div>
        
        <div class=" col-sm-2"> <label class="control-label">Odometer(KM)</label></div>
        <div class="col-sm-3 form-group">
          
         <input class="form-control input-lg odometerkm"  type="text" name="odometerkm" placeholder="Enter odometers" >
        </div>
      </div>
      
      <div class="col-sm-12 row">
          
        <div class=" col-sm-2"><label class="control-label">Odometer(Hours)</label></div>
       <div class=" col-sm-3 form-group">
         
          <input class="form-control input-lg odometerhours" type="text" name="odometerhours" placeholder="Enter odometers" >
        </div>
        
        <div class=" col-sm-2"> <label class="control-label">Litres</label></div>
        <div class="col-sm-3 form-group">
          
         <input class="form-control input-lg" type="text" name="eqty" placeholder="Enter Diesel Quality">
        </div>
      </div>

      <div class=" col-sm-12 row"><br></div>
      
      
      
      <div class=" col-sm-12 row"><br></div>

    <div class="form-group">        
      <div class="col-sm-12 text-center">
        <button type="submit" name="myButton" class="btn btn-default btn-lg">Save</button>
      </div>
    </div>
    </form>   
  </div>
  <?php require 'footer.php' ?>
 
  <script type="text/javascript">var base_url = "<?= $base_url ?>";</script>
  
  <script type="text/javascript" src="inDieselProScript.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[name="internalprodate"]'); //our date input has the name "date"
		var container=$('form >  .datepicker-internalprodate').length>0 ? $('form > .datepicker-internalprodate').parent() : "body";
		date_input.datepicker({
			  format: 'dd-mm-yyyy',
        container: container,
			  todayHighlight: true,
			  autoclose: true,
    });
    $('input[name="internalprodate"]').datepicker( "setDate", new Date());      
    $('#inDieselProInvoice').bootstrapValidator({
        // To use feedback icons, ensure that you use Bootstrap v3.1.0 or later
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
          invoice: {
                message: 'The invoice number is not valid',
                validators: {
                    notEmpty: {
                        message: 'The invoice number is required and cannot be empty'
                    }
                }
            },
            internalprodate: {
                message: 'The invoice date is not valid',
                validators: {
                    notEmpty: {
                        message: 'The invoice date is required and cannot be empty'
                    }
                }
          },  
          vehicleno: {
                message: 'The vehicle number is not valid',
                validators: {
                    notEmpty: {
                        message: 'The vehicle number is required and cannot be empty'
                    }
                }
            },
            eqty: {
                message: 'The litres is not valid',
                validators: {
                    notEmpty: {
                        message: 'The litres is required and cannot be empty'
                    },
                    
                }
            },
           
        }
    });
    

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