@extends('layouts.dashboard')

@section('page_title')
   Payments
@endsection

@section('page_header_title')
   Payments
@endsection



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


  
    <div class="row row-cards row-deck">
              <div class="col-12">
                <div class="card">
                    <div class="card-header">
            
            
               <h3 class="card-title">Payment</h3>
            </div>

        <div style="margin:2%;" id="tableCustomFilters" class="row"></div>


                  <div class="card-status card-status-left bg-pink"></div>
                     <div class="table-responsive ">
    <table id="my-datatable" class="table table-sm table-hover table-outline table-vcenter text-nowrap card-table">
      <thead>
        <tr>

          <th>Sr #</th>
          <th>{{ucwords(str_replace('_',' ',EF::branchWhiteLabel()['module']))}}</th>
          <th>Invoice #</th>
          <th>Vendor</th>

          <th>Amount</th>
          <th>Mode</th>
          <th>Payment Type</th>
          <th>status</th> 
          <th>Date</th>   
         {{--
          <th style="text-align: center;"><i class="dropdown-icon fa fa-cogs"></i></th>  --}}                        
        </tr>
      </thead>
      <tbody>
        @isset($payment_list)
        @foreach($payment_list as $rows)


                      
        
        <tr>
          <td>{{$loop->iteration}}</td>
          <td>{{$rows->branch->name}}</td>

          <td>{{$rows->invoice->invoice_no}}</td>

          <td>{{$rows->user->name}}</td>



          <td>{{EF::numberFormat($rows->amount)}}</td>
          <td>{{$rows->mode}}</td>

          <td>{{$rows->payment_type}}</td>
          <td>
             @if($rows->status == "Approve") 
                <span class="badge badge-success">{{EF::getstatus($rows->status)}}</span>
              @elseif($rows->status == "Unapprove") 
                <span class="badge badge-primary">{{EF::getstatus($rows->status)}}</span>
              @else
                <span class="badge badge-warning"> {{$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">

                  @php($voucher_type = 'receipt')

             @if(Auth::user()->hasAnyPermission(['All','Create Voucher'])) 
                   @if($rows->status == "Unapprove")
                      <a href="#" id="pay" class="dropdown-item" data-target="#md_add_voucher" data-toggle="modal" onclick="showpaymentvoucherModel(event,'{{Crypt::encrypt($rows->id)}}','{{Crypt::encrypt($voucher_type)}}')"><i class="dropdown-icon fa fa-edit"   ></i>Create Voucher  </a>
                      @endif
                      @endif
                    
                  @if(Auth::user()->hasAnyPermission(['All','Update Payment'])) 
                  @if($rows->status == "Unapprove")
                   <a href="#" id="pay" class="dropdown-item" onclick="showUpdatePayPaymentModel(event,'{{Crypt::encrypt($rows->id)}}');" ><i class="dropdown-icon fa fa-edit"   ></i>Update  </a>
                   @endif
                   @endif

                  @if(Auth::user()->hasAnyPermission(['All','Remove Payment']))  
                  @if($rows->status == "Unapprove") 
                   <a href="{{route('payment.trash',['id' => Crypt::encrypt($rows->id)])}}" content ="remove payment" class="dropdown-item  cls_delete"><i class="dropdown-icon  fa fa-trash"></i> Remove </a>
                   @endif
                   @endif
               
                </div>
            </div>
          </td>
          --}}
       </tr>
      
       @endforeach
       @endisset
     </tbody>
   </table>
 </div>  
                </div>
              </div>
  </div>
      
@endsection

@section('page_modal')
  <div id="modal_update_payment"> </div>
  <div id="modal_payment_voucher"> </div>

   

@endsection

@section('page_script')
  @include('scripts.account')
  @include('scripts.payment')

    <script type="text/javascript">
    $(function(){

      $('document').ready(function(){



             $('#my-datatable').DataTable({
              "columnDefs": [
                { "type": "numeric-comma", targets: 0 }
            ],

    initComplete: function () {

       var api = this.api();

  
            createSearchableDropDown('#tableCustomFilters',api,1,'Select Project.','col-sm-3');
            createSearchableDropDown('#tableCustomFilters',api,2,'Select Invoice No.','col-sm-3');
            createSearchableDropDown('#tableCustomFilters',api,3,'Select Vendor','col-sm-3');

            createSearchableDropDown('#tableCustomFilters',api,6,'Select Mode','col-sm-3');
          



            
     
      
      
    }
  });
  // END
      });

    });
  </script>

@endsection

  