<?php 

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

?>
<!DOCTYPE html>
<html>
<head>
    <?php 
      require 'meta.php'; 
      require 'header.php';
	  
    ?>
    <script>
    function my()
    {
    var eqty=parseFloat(document.getElementById("eqty").value);
	var rate=parseFloat(document.getElementById("rate").value);
	
	document.getElementById("amount").value=parseFloat(eqty*rate).toFixed(2);
    
    
    
    }
	</script>
    
    <script>

function validateForm() {
  var sname = document.forms["myForm"]["sname"].value;
  
  
  
  if (sname == "a") {
    alert("Please Select Supplier");
    return false;
  }
  
  
  
  
}
</script>
</head>
<body>
  <?php require 'menu.php' ?>
  <div class="container-fluid">
    <h3 class="text-center"><strong>External Diesel Unfilling Details</strong></h3>
    <form class="form-horizontal" action="exDieselProInsert.php" method="post" id="inDieselProInvoice" onSubmit="return checkForm(this);" autocomplete="off">
      <div class="col-sm-12 row">
      <div class=" col-sm-1"></div>
        <div class=" col-sm-3 form-group">
          <label class="control-label">S.No</label>
          <input class="form-control input-lg" type="text" name="invoice" value="<?php echo $invoice_count; ?>" readonly >
        </div>
        
        <div class="col-sm-3 form-group">
          <label class="control-label">Date</label>
          <input class="form-control input-lg datepicker-internalprodate"  type="text" name="internalprodate" autocomplete="off" readonly>
        </div>
        
       <div class=" col-sm-3 form-group">
          <label class="control-label">Supplier</label>
          <select class="form-control input-lg selectpicker select-trip-vehicle" data-show-subtext="true" data-live-search="true" name="sname" id="sname" required>
           <option disabled selected value="">Please Select Supplier</option>
            <?php   echo $sqlsupplier;   ?>
          </select> 
        </div>
        
        <div class=" col-sm-3 form-group">
          <label class="control-label">Vehicle No</label>
          <select class="form-control input-lg selectpicker select-trip-vehicle" data-show-subtext="true" data-live-search="true" name="vhid" required>
           <option  >Please Select Vehicle</option>
            <?php   echo $sqlVehicleNo;   ?>
          </select> 
        </div>
        
      </div>

      <div class=" col-sm-12 row"><br></div>
      <div class=" col-sm-12 row">
        <div class=" col-sm-1"></div>
        
         <div class="col-sm-2 form-group">
          <label class="control-label">Driver Name</label>
           <select class="form-control input-lg selectpicker select-trip-vehicle" data-show-subtext="true" data-live-search="true" name="driverid" required>
            <option disabled selected>Please Select Driver</option>
            <?php   echo $sqldrivername;   ?>
          </select> 
        </div>
        
        
        <div class="col-sm-2 form-group">
          <label class="control-label">Odometer(KM)</label>
          <input class="form-control input-lg odometerkm"  type="text" name="odometerkm" placeholder="Enter odometers" required>
        </div>
        <div class="col-sm-2 form-group">
          <label class="control-label">Odometer(Hours)</label>
          <input class="form-control input-lg odometerhours" type="text" name="odometerhours" placeholder="Enter odometers" required >
        </div>
        <div class="col-sm-2 form-group">
          <label class="control-label">Litres</label>
          <input class="form-control input-lg" type="text" name="eqty" id="eqty" placeholder="Enter Diesel Quality"  required  onblur="my()">
        </div>
        
        <div class="col-sm-2 form-group">
          <label class="control-label">Rate</label>
          <input class="form-control input-lg" type="text" name="rate" id="rate" placeholder="Enter Rate"  required onBlur="my()">
        </div>
       
       <div class="col-sm-2 form-group">
          <label class="control-label">Amount</label>
          <input class="form-control input-lg" type="text" name="amount" id="amount" placeholder="Enter Bill Amount"  required>
        </div>
       
      </div>
      <div class=" col-sm-12 row">
        <div class=" col-sm-1"></div>

        
        <div class="form-group col-sm-3">
          
          <label class="control-label">Payment </label>
            <select class="form-control input-lg " name="payment" required>
        <option value="">Please Select the Option </option>
       <option value="Cash And Carry">Cash And Carry</option>
       <option value="Accounts">Accounts</option>
       
        </select>
          
        </div>
        
        <div class="form-group col-sm-3">
          <label class="control-label">Paid&nbsp;Amt</label>
          <input class="form-control input-lg" type="text" name="received_amt"  >
        </div>
        
        <div class="form-group col-sm-3">
          <label class="control-label">Payment&nbsp;Mode</label>
          <select class="form-control input-lg selectpicker select-payment-type" data-live-search="true" name="paymenttype" id="supplierdetails">
            <option disabled selected>Select your Option</option>
            <option value="cash">Cash</option>
            <option value="cheque">Cheque</option>
            <option value="NEFT">NEFT</option>
          
          </select>     
        </div>
        
      </div>
      
      <div class=" col-sm-12 row">
        <div class=" col-sm-1"></div>

        
        <div class="form-group col-sm-9">
          
          <label class="control-label">Remarks</label>
            <textarea class="form-control input-lg " name="remark" ></textarea>
       
          
        </div>
        
        
      </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'
                    },
                    
                }
            },
            odometer: {
                message: 'The odometer is not valid',
                validators: {
                    regexp: {
                        regexp: /^[0-9]+$/,
                        message: 'The supplier invoice amount can only consist of number'
                    }
                }
            }
        }
    });
    

	});
</script>
</body>
</html><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
</body>
</html>