@extends('layouts.dashboard')

@section('page_title')
Voucher
@endsection

@section('page_header_title')
Manage Voucher
@endsection



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

<div class="row row-cards row-deck">
  <div class="col-12">
    <div class="card">
      <div class="card-header">


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

       <button  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>
     </div>

     <div class="card-status card-status-left bg-blue"></div>
     <div class="table-responsive table-height">
      <table class="table table-hover table-outline table-vcenter text-nowrap card-table cls_datatable">
        <thead>
          <tr>

            <th>#</th>
            <th>{{ucwords(str_replace('_',' ',EF::branchWhiteLabel()['module']))}}</th>
            <th>Temp Voucher#</th>
            
            <th>Type</th>
            <th>Amount</th>
            <th>Status</th>
            <th>Date</th>
            <th></th>
          </tr>
        </thead>
        <tbody>

          @isset($trasnaction)
          @foreach($trasnaction as $rows)


          <tr>
            <td>{{$loop->iteration}}</td>
            <td>{{$rows->getBranch($rows->id)}}</td>
            <td>VR/{{sprintf('%04d', $rows->id)}}</td>
            <td>{{$rows->compound_type}}</td>                          
            <td>{{EF::numberFormat($rows->total_amount)}}</td>
            <td>
             @if($rows->status == "Unapprove") 
                <span class="badge badge-danger">{{EF::getstatus($rows->status)}}</span>
                @endif

              </td>
            <td>{{EF::dateFormat($rows->created_at)}}</td>
            <td class="text-center">

              <div class="item-action dropdown">
                <a href="javascript:void(0)" data-toggle="dropdown" class="icon"><i class="fa fa-list-ul"></i></a>
                <div class="dropdown-menu dropdown-menu-right">
               
                 @if(Auth::user()->hasAnyPermission(['All','Update Voucher']))
                 <a onclick="showVoucher(event,this)"  href="{{route('voucher.show',['id' => Crypt::encrypt($rows->id) ])}}" class="dropdown-item"><i class="dropdown-icon fa fa-edit"></i> Update</a>
                 @endif
                 @if(Auth::user()->hasAnyPermission(['All','Approve Voucher','Reject Voucher']))
                 <a href="" id="{{Crypt::encrypt($rows->id)}}" class="dropdown-item " content="approve voucher" data-toggle="modal" data-target="#md_approve_voucher" onclick="getJorunalById(this);"><i class="dropdown-icon fa fa-check"></i> Approve/Reject</a>
                 @endif
                 @if(Auth::user()->hasAnyPermission(['All','Preview Voucher']))
                 <a target="_blank" href="{{route('document.voucherpreview',['id' => Crypt::encrypt($rows->id)])}}" class="dropdown-item " content="print voucher"><i class="dropdown-icon fa fa-file"></i> Preview Voucher</a>
                 @endif

               </div>
             </div>
           </td>
         </tr>
         @endforeach
         @endisset

       </tbody>
     </table>
   </div>
 </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')

@endsection

