@extends('layouts.dashboard')

@section('page_title')
Voucher
@endsection

@section('page_header_title')
Manage Voucher
@endsection



@section('page_body')
{{ Breadcrumbs::render('voucher') }}
<div class="row ">
          
          <div class="col-sm-12 col-md-3 col-lg-3">
            <strong>From <small style="color: red;">*</small></strong>
              <input type="date" name="date" class="form-control form-control-sm" id="from">
          </div>

            <div class="col-sm-12 col-md-3 col-lg-3">
              <strong>To <small style="color: red;">*</small></strong>
              <input type="date" name="date" placeholder="" class="form-control form-control-sm" id="to">
          </div>



          <div class="col-sm-12 col-md-5 col-lg-5">
            <strong>Project</strong>
              <select class="form-control form-control-sm " id="filter_project"  name="project">
                <option value="{{Crypt::encrypt(0)}}">Select Project</option>
                @foreach($branch as $rows)
                  <option @if(isset($project)) selected @endif value="{{Crypt::encrypt($rows->id)}}">{{$rows->name}}</option>
                @endforeach
              </select>
          </div>

          <div class="col-sm-12 col-md-1 col-lg-1">
              <button onclick="voucherFilters(event)"  class="btn btn-sm btn-primary mt-5">Search</button>
          </div>
        </div>
<div class="row row-cards row-deck mt-4">

  <div class="col-12">
    <div class="card">
         {!! Form::open(array('route' =>    'approve.multiple.vouchers')) !!}

      <div class="card-header">


       @if(Auth::user()->hasAnyPermission(['All','Create Voucher']))

       <button  onclick="event.preventDefault();" class="float-right btn btn-sm btn-outline-primary" data-toggle="modal" data-target="#md_add_voucher"><i class="fa fa-plus"></i></button> &nbsp;&nbsp;
       @endif

       <h3 class="card-title">Create Voucher</h3> &nbsp; &nbsp;

       <button  class="float-right btn btn-sm btn-outline-primary approve_button" type="submit" disabled><i class="fa fa-save"></i> Approve Selected Vouchers</button> &nbsp;&nbsp;
     </div>


     <div class="card-status card-status-left bg-blue"></div>
     <div class="table-responsive table-height">
      <table class="table table-hover table-sm table-outline table-vcenter text-nowrap card-table cls_datatable">
        <thead>
          <tr>
            <th>#</th>
            <td>Option</td>
            <th>Date</th>
            <th>Clearance Date</th>
            <th>Approve / Reject</th>

            <th>Temp Voucher#</th>
            <th>{{ucwords(str_replace('_',' ',EF::branchWhiteLabel()['module']))}}</th>
            <th>Type</th>
            <th>Status</th>
            <th>Payment Detail</th>
            <th>debit</th>
            <th>credit</th>
            <th>Action</th>
          </tr>
        </thead>
        <tbody id="show_vouchers">
            {!! $view_voucher !!}
       </tbody>
     </table>
   </div>
     {!! Form::close() !!}

 </div>
</div>
</div>
@endsection

@section('page_modal')
@include('voucher.modals.approve_voucher')

@endsection

@section('page_script')
@include('scripts.voucher')

@include('scripts.account')
@include('voucher.modals.add_voucher')
@include('voucher.modals.update_voucher')
{{-- <script type="text/javascript">
  function loadVouchers()
 {
     var element = $('#voucher_table');
     $('#tableCustomFilters').html('');

     element.DataTable().clear();
     element.DataTable().destroy();

     element.DataTable( {

            "search": "^[4-8]", 
            "regex": true ,

             // searching": false,

             
             columnDefs: [
                       { "type": "numeric-comma", targets: 0 }
                   ],
               cache:true,
               responsive: true,
               bProcessing: true,
               bServerSide: true,
               deferRender: true,
               select: true,
               stateSave: true,
               pageLength:50,
               colReorder : true,
                "ajax": {
                 "url": "{{route('loadvouchers')}}",
                 "type": "GET",
                 'data':{id:"{{ $id }}"},
              },
               "columns": [
            
             {
               name: 'transactions.id',
               data: 'count'
             },
             {
               name: 'option',
               data: 'option'
             },
             {
               name: 'clearence_date',
               data: 'clearence_date'
             },
             {
               name: 'approve_reject',
               data: 'approve_reject'
             },
             {
               name: 'transactions.created_at',
               data: 'created_at'
             },

             {
               name: 'transactions.id',
               data: 'temp_no'
             },

             {
               name: 'transactions.voucher_type',
               data: 'voucher_type'
             },
             {
               name: 'u.name',
               data: 'name'
             },
           
             {
               name: 'transactions.total_amount',
               data: 'total_amount'
             },
             {
                 name:'b.form_number',
                 data:'form_number',
             },
             {
                 name:'j.narration',
                 data:'narration',
             },

             {
               name: 'rf.form_number',
               data: 'action'
             },
             
             

             ],
             
       
           });
 }


  $(document).ready(function() {
    loadVouchers();
  });
</script> --}}
@endsection

