@extends('layouts.dashboard')

@section('page_title')
	Add Invoice
@endsection

@section('page_style')
<link rel="stylesheet" type="text/css" href="{{asset('plugins/easyautocomplete/easy-autocomplete.min.css')}}">

<link rel="stylesheet" type="text/css" href="{{asset('plugins/easyautocomplete/easy-autocomplete.themes.min.css')}}">

<style type="text/css">
    .easy-autocomplete-container {
    left: 0;
     position: relative; !important; 
    width: 100%;
    z-index: 10 !important;
}
</style>

@endsection

@section('page_header_title')
    Add Invoice
@endsection



@section('page_body')
{{ Breadcrumbs::render('invoice') }}

@php ($uniqid = uniqid())

{{ Form::open(array('route' => 'invoice.store', 'id' => 'form_add_invoice', 'class' => 'cls_from ', 'enctype' => 'multipart/form-data')) }}
<div class="content">
    <div class="container-xl">
        <div class="card">
            <div class="card-header d-print-none">
                <h3 class="card-title">Purchase Invoice</h3>
                <div class="card-options">
                    <!-- <button type="button" class="btn btn-primary" onclick="javascript:window.print();"><i
                        class="si si-printer"></i> Print Invoice
                        </button> -->
                </div>
            </div>
            <div class="card-body">
              <div class="row">

                <!-- LEFT SIDE -->
                <div class="col-lg-12">
                    <div class="row">
                        <div class="col-lg-3">
                            <div class="form-group">
                                <label class="label-color"> Project: <i style = "color:red;">*</i></label>
                                <small class="form-errors pull-right req" value="*"></small>
                                <select name="branch" class="form-control fstdropdown-select form-control-sm cls_required">
                                <option value="{{Crypt::encrypt(0)}}">Select Project</option>
                                    @foreach($branch_list as $branch)
                                        <option value="{{Crypt::encrypt($branch->id)}}">{{$branch->name}} </option>
                                    @endforeach

                                </select>
                            </div>
                        </div>

                        <div class="col-lg-3">
                            <div class="form-group">
                                <label class="label-color"> Vendor: <i style = "color:red;">*</i></label>
                                <small class="form-errors pull-right req" value="*"></small>
                               <select name="user" class="form-control fstdropdown-select form-control-sm cls_required vendor" onChange="getVendor(event,this)">
                                    <option value="{{Crypt::encrypt(0)}}">Select Vendor </option>
                                    @foreach($vendor_list as $vendor)
                                    <option value="{{Crypt::encrypt($vendor->id)}}">{{$vendor->name}} </option>
                                    @endforeach

                                </select>
                            </div>
                        </div>

                        <div class="col-lg-3">
                            <div class="form-group">
                                <label class="form-label">Date<i style = "color:red;">*</i></label>
                                <small class="form-errors pull-right req" value="*"></small>
                                

                                <input type="date" name="date" value="{{date('Y-m-d')}}" class=" form-control ">

                                <input style="display: none;"  type="text" name="invoice_no" class=" form-control  " placeholder="Invoice No">
                            </div>
                        </div>

                        <div class="col-lg-3">
                            <div class="form-group">
                                <label class="form-label"> Due Date<i style = "color:red;">*</i></label>
                                <small class="form-errors pull-right req" value="*"></small>
                                
                                <input required="" type="date" name="due_date" class=" form-control " >
                            </div>
                        </div>


                        <div class="col-lg-12">
                            <label class="form-label name"></label>
                        </div>

                        <div class="col-lg-12">
                            <label class="form-label cnic"></label>
                        </div>

                        <div class="col-lg-12">
                            <label class="form-label contact"></label>
                        </div>

                        <div class="col-lg-12">
                            <label class="form-label address"></label>
                        </div>


                    </div>
                </div>
                <!-- END LEFT SIDE -->

             


              </div>
  
    
              <div class="table-responsive">
                <table class="table">
                  <thead>
                    <tr>
                      <th class="text-center"style="width: 10%;">Item Code <i style = "color:red;">*</i></th>
                      <th class="text-center" style="width: 31%;">Description <i style = "color:red;">*</i></th>
                      <th class="text-center">Unit Price <i style = "color:red;">*</i></th>
                      <th class="text-center">Discount</th>
                      <th class="text-center">Quantity <i style = "color:red;">*</i></th>
                      <th class="text-center">GST%</th>
                      <th class="text-center">GST Value</th>
                      <th class="text-center">Amount</th>
                      <th style="text-align: center;"><i class="dropdown-icon fa fa-cogs"></i></th>

                    </tr>
                  </thead>
                
                <tbody id="invoice_table">
                  <tr>
                    <td><input required="" type="text" name= "item_code[]" class="form-control form-control-sm item_code cls_required " id="item_code_{{$uniqid}}" placeholder="Code"/></td>

                    <td><input required="" class = "form-control form-control-sm cls_alpha_numeric description" id="description_{{$uniqid}}" placeholder="Description" type="text" name="description[]"/></td>
                    
                    <td><input required=""  class = "form-control form-control-sm cls_alpha_numeric" id="unit_price_{{$uniqid}}" placeholder="Unit Price" onkeyup="create_PurchaseItem(event,'{{$uniqid}}')"  type="text" name="unit_price[]"/></td>
                    
                    <td><input  class = "form-control form-control-sm cls_alpha_numeric" id="discount_{{$uniqid}}"  onkeyup="create_PurchaseItem(event,'{{$uniqid}}')" placeholder="Discount" type="text" name="discount[]"/></td>
                    
                    <td><input  required="" class = "form-control form-control-sm cls_alpha_numeric" id="quantity_{{$uniqid}}" placeholder="Quantity"  onkeyup="create_PurchaseItem(event,'{{$uniqid}}')" type="text" name="quantity[]"/></td>
                    
                    <td><input  class = "form-control form-control-sm cls_alpha_numeric" id="gst_percentage_{{$uniqid}}" placeholder="GST %"  onkeyup="create_PurchaseItem(event,'{{$uniqid}}')" type="text" name="gst_percentage[]"/></td>
                    
                    <td><input class = "form-control form-control-sm cls_alpha_numeric" id="gst_value_{{$uniqid}}" placeholder="GST Value"  type="text" name="gst_value[]" readonly/></td>
                    
                    <td><input class = "form-control form-control-sm cls_alpha_numeric" id="amount_{{$uniqid}}" placeholder="Amount"  type="text" name="amount[]" readonly/></td>
                    
                    <td><button class=" btn-success btn-sm" onclick="addInvoiceRowOnetime(event)"><i class="fa fa-plus"></i></button></td>
                  </tr>

                </div>
                </table>
              </div>

            </div>
            <div class="card-footer">
                <button onclick="storeInvoice(event,this)" type="submit" class="btn btn-primary float-right purchase_details" content="">Submit</button>

            </div>
        </div>

    </div>
    {{Form::close()}}



@endsection

@section('page_modal')

@endsection

@section('page_script')
@include('scripts.invoice') 
<script type="text/javascript">

    // showAutoCompleteItemCodes('{{$uniqid}}');
    $(function(){

        showAutoCompleteItemCodes('{{$uniqid}}');
});
</script>
@endsection

