
@extends('layouts.master')
@section('title','Register Form')
@section('content')

       <div class="content-wrapper">
      <!-- Content Header (Page header) -->
      <section class="content-header">
        <div class="container-fluid">
          <div class="row mb-2">
            <div class="col-sm-6">
              <h1>Sale</h1>
            </div>
            <div class="col-sm-6">
              <ol class="breadcrumb float-sm-right">
                <li class="breadcrumb-item"><a href="#">Home123</a></li>
                <li class="breadcrumb-item active">Add Sale</li>
              </ol>
            </div>
          </div>
        </div><!-- /.container-fluid -->
      </section>

      <!-- Main content -->
      <section class="content">
        <div class="container-fluid">
          <div class="card card-primary">
                   @if(session()->has('success'))
            <div class="alert alert-success">
                {{ session()->get('success') }}
            </div>
        @endif
            <form action="{{route('admin.store')}}" method="post" enctype="multipart/form-data">
              @csrf
              <div class="card-body row">
                <div class="col-md-4">
                <div class="form-group">
                            <label>Supplied by</label>
                            <!-- <select class="form-control select2bs4" style="width: 100%;"> if live search needed -->
                            <select class="form-control" style="width: 100%;" id="supplied_by" name="supplied_by" onchange="get_litr_show(this.value)">
                              <option value="SRK DIESEL TRADING L.L.C" >SRK DIESEL TRADING L.L.C</option>
                              <option value="THREE STAR FUEL TRADING L.L.C">THREE STAR FUEL TRADING L.L.C</option>
                            </select>
                             @if ($errors->has('supplied_by'))
                            <span class="text-danger">{{ $errors->first('supplied_by') }}</span>
                            @endif
                          </div>

                </div>
                 <div class="col-md-4">
                <div class="form-group">
                            <label>Transaction Date</label>
                           <input type="date" class="form-control" name="date" id="date"  value="@php echo date('Y-m-d'); @endphp" autocomplete="off">
                            @if ($errors->has('date'))
                            <span class="text-danger">{{ $errors->first('date') }}</span>
                            @endif
                          </div>

                </div>
                     <div class="col-md-4">
                <div class="form-group">
                            <label>Transaction Time</label>
                           <input type="time" class="form-control" name="transaction_time" id="transaction_time"   autocomplete="off">
                            @if ($errors->has('transaction_time'))
                            <span class="text-danger">{{ $errors->first('transaction_time') }}</span>
                            @endif
                          </div>

                </div>
                <div class="col-md-4">
                <div class="form-group">
                            <label>Ledger</label>
                            <!-- <select class="form-control select2bs4" style="width: 100%;"> if live search needed -->
                            <select class="form-control" style="width: 100%;" name="ledger" onchange="getDoNumber(this.value)">
                             <option value="CashMemo">Cash Memo</option>
                              <option value="DoNo">D.O No.</option>
                            </select>
                            @if ($errors->has('ledger'))
                            <span class="text-danger">{{ $errors->first('ledger') }}</span>
                            @endif
                          </div>

                </div>
                <div class="col-md-4 enterdonno">
                  <div class="form-group">
                    <label for="exampleInputEmail1">Do Number</label>
                   <input type="number" class="form-control" min="1" id="ledger_value" name="ledger_value" step="any" value="{{ old('ledger_value')}}" placeholder="Enter DO number" autocomplete="off" required="">
                    @if ($errors->has('ledger_value'))
                      <span class="text-danger">{{ $errors->first('ledger_value') }}</span>
                      @endif
                  </div>

                </div>
                <div class="col-md-4">
                <div class="form-group">
                            <label>Customer Name</label>
                           <select class="form-control select2bs4" style="width: 100%;" name="customer_id" onchange="vehicle_by_customer(this.value);getPrice(this.value);" required="">
                             <option value="">Select </option>
                             @foreach($customer_data as $customer)
                              <option value="{{$customer->id}}">{{$customer->company_name}}</option>
                              @endforeach
                            </select>
                           
                          </div>

                </div>
                   <div class="col-md-4">
                  <div class="form-group">
                    <label for="exampleInputEmail1">Vehicle Number</label>
                  <select class="form-control select2bs4" style="width: 100%;" name="vehicle_number" id="vehicle_number" onchange="vehicle_change(this.value);">
                 </select>
                  </div>

                </div>
                <div class="col-md-4">
                  <div class="form-group">
                    <label for="exampleInputEmail1">Driver Name</label>
              <!--       <input type="text" class="form-control" name="driver_name" id="driver_name" placeholder="Enter Driver Name" value="{{ old('driver_name')}}" autocomplete="off">
                     @if ($errors->has('driver_name'))
                      <span class="text-danger">{{ $errors->first('driver_name') }}</span> -->
                      <!-- @endif -->
                 <select class="form-control select2bs4" style="width: 100%;" name="driver_name" id="driver_name" >
                 </select>
                  </div>

                </div>
             
                <div class="col-md-4">
                  <div class="form-group">
                    <label for="exampleInputEmail1">QTY - Gallon</label>
                    <input type="number" class="form-control" min="1" id="quantity" name="quantity" step="any" value="{{ old('quantity')}}" placeholder="Enter QTY - Gallon" autocomplete="off" onchange="qtyavailable(this.value)">
                    @if ($errors->has('quantity'))
                      <span class="text-danger">{{ $errors->first('quantity') }}</span>
                      @endif
                  </div>

                </div>
                  <div class="col-md-4">
                  <div class="form-group">
                    <label for="exampleInputEmail1">Return -QTY</label>
                    <input type="number" class="form-control" min="1" id="return_qty" name="return_qty" step="any" value="{{ old('return_qty')}}" placeholder="Enter RETURN QTY" autocomplete="off" >
                    @if ($errors->has('return_qty'))
                      <span class="text-danger">{{ $errors->first('return_qty') }}</span>
                      @endif
                  </div>

                </div>
                <input type="hidden" id="stock_value" value="{{$stock->stock}}">
                <div class="col-md-4 hide1">
                  <div class="form-group">
                    <label for="exampleInputEmail1">QTY - ltr </label>
                    <input type="text" class="form-control" id="quantity_ltr" name="quantity_ltr" value="4.5" readonly >
                  </div>
                </div>
                <input type="hidden" name="hide_value" id="hide_value">
                <div class="col-md-4">
                  <div class="form-group">
                    <label for="exampleInputEmail1">Unit / Gallon Price</label>
                    <input type="number" class="form-control" id="unit_price" value="{{ old('unit_price')}}" step="any" name="unit_price" autocomplete="off" min="1" >
                    @if ($errors->has('unit_price'))
                      <span class="text-danger">{{ $errors->first('unit_price') }}</span>
                      @endif
                  </div>

                </div>
                <div class="col-md-4 hide2">
                  <div class="form-group">
                    <label for="exampleInputEmail1">Unit / Liter Price (gallon unit x Price)</label>
                    <input type="text" class="form-control" id="unit_ltr_price" name="unit_ltr_price" value="0" readonly onclick="hide2()">
                  </div>
                </div>
                <div class="col-md-4">
                  <div class="form-group">
                    <label for="exampleInputEmail1">Gallon Price (Gallon x Gallon price)</label>
                    <input type="text" class="form-control" id="gallon_price" name="gallon_price"  readonly>
                  </div>
                </div>
                <div class="col-md-4">
                  <div class="form-group">
                    <label for="exampleInputEmail1">Tax VAT %</label>
                    <input type="number" class="form-control" id="tax" name="tax" value="5"  >
                  </div>
                </div>
                <div class="col-md-4">
                  <div class="form-group">
                    <label for="exampleInputEmail1">Total</label>
                    <input type="text" class="form-control" id="total" name="total"  readonly>
                  </div>
                </div>
                <div class="col-md-4">
                  <div class="form-group">
                    <label for="exampleInputEmail1">Kilometer NOW(KMs)</label>
                    <input type="number" class="form-control" id="kilometer" step="any" value="{{ old('kilometer')}}" name="kilometer" placeholder="Enter Kilometer NOW(KMs)">
                    @if ($errors->has('kilometer'))
                      <span class="text-danger">{{ $errors->first('kilometer') }}</span>
                      @endif
                  </div>

                </div>

                    <div class="col-md-4">
                <div class="form-group">
                            <label>Payment Mode</label>
                            <!-- <select class="form-control select2bs4" style="width: 100%;"> if live search needed -->
                            <select class="form-control" style="width: 100%;" name="payment_mode" required="">
                             <option value="cash">Cash </option>
                              <option value="credit">Credit</option>
                            </select>
                            @if ($errors->has('payment_mode'))
                            <span class="text-danger">{{ $errors->first('payment_mode') }}</span>
                            @endif
                          </div>

                </div>


              </div>
              <div class="card-footer pt-0 mb-5">
                <button class="btn btn-primary save" type="submit">Submit</button>
                <a href="{{route('admin.index')}}" class="btn btn-danger" >Back</a>
                <!--<input  class="btn btn-primary" type="button" onclick="hide1();" value="Remove Litr" id="btn-id">-->
              </div>
            </form>
          </div>
        </div>
        <!-- /.container-fluid -->
      </section>
      <!-- /.content -->


    </div>
      <!-- /.content -->
@endsection
@section('script')
<script src="{{ asset('js/form.js') }}"></script>
<script>
    $(document).ready(function() {
      $("#sale").addClass('menu-open');
      $("#add-sale").addClass('active');
    });
  </script>
@endsection

