<?php if(Auth::user()->hasAnyPermission(['All','View Side Payment'])): ?>
<div class = "col-md-12 col-sm-12">
  <div class= "card card-collapsed">
    <div class="card-status bg-red">
    </div>
    <div class="card-header">

    <?php if(Auth::user()->hasAnyPermission(['All','Add Side Payment'])): ?>
     <button  class="float-right btn btn-sm btn-outline-primary" data-toggle="modal" data-target="#md_add_commission"><i class="fa fa-plus"></i></button> &nbsp;&nbsp;
     <?php endif; ?>


     <h3 class="card-title">Manage Side Payments</h3>

     <div class="card-options">
       <a onclick="cardCollapseOnce(event,this);" href="#" class="card-options-collapse btn btn-sm btn-outline-primary" >View <i class="fe fe-chevron-up"></i></a>

     </div>


   </div>
   <div class="alert alert-primary card-alert mb-0">
     Commissions / Document & Miscellaneous Charges
   </div>

   <div class=" table-responsive booking-table-height">
    <table class="table table-hover  table-outline table-vcenter scrollbar-primary text-nowrap card-table">
      <thead>
        <tr>

          <th>Sr #</th>
          <th>Name</th>
          <th>Description</th>
          <th>Amount</th>
          <th>Received</th>
          <th>Balance</th>


          <th>Status</th>
          <th style="text-align: center;"><i class="dropdown-icon fa fa-cogs"></i></th>
        </tr>
      </thead>
      <tbody>
        <?php if(isset($commission_list)): ?>
        <?php $__currentLoopData = $commission_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $rows): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

        <?php ($pass_data = []); ?>

        <?php ($charges_data = []); ?>



        <?php (
        $pass_data = array(
        'id'                  => Crypt::encrypt($rows->id),
        'percentage'          => $rows->percentage,
        'updateamount'        => $rows->amount,
        'amount_in_words'     => EF::numberToWords($rows->amount),
        'description'         => trim($rows->description),
         'name'               => $rows->user->name,
         'user_type'          => $rows->role->name,
        )
        ); ?>

        <?php (
         $charges_data = array(
        'id'                  => Crypt::encrypt($rows->id),
        'charges_type'        => $rows->payment_type,
        'chargesamount'       => $rows->amount,
        'amount_in_words'     => EF::numberToWords($rows->amount),
        'description'         => trim($rows->description),

        )
        ); ?>


        


                         <?php ($payment = array(

                            'installment'      => Crypt::encrypt('0'),
                            'commission'       => Crypt::encrypt($rows->id),
                            'amount'           => ($rows->amount - $rows->received_amount),
                            'amount_in_words'  => EF::numberToWords($rows->amount - $rows->received_amount),
                            'description'      => $rows->description,
                            'user'             => Crypt::encrypt($rows->user_id),
                            'booking'          => Crypt::encrypt($booking->id),
                            'user_type'        => $rows->role->name,
                            'user_name'        => $rows->user->name,
                            EF::branchWhiteLabel()['module'] => $booking->branch->name,




                            'booking_detail'   => $booking->ms.' ('.$plot->plot_id.' '.$plot->category.')',

                            'payment_type'     => $rows->payment_type,

                         )); ?>


        <tr>
          <td><?php echo e($loop->iteration); ?></td>
          <td><?php echo e(ucfirst($rows->user->name)); ?> (<?php echo e($rows->role->name); ?>)</td>

          <td style ="word-wrap: break-word;"><?php echo e($rows->payment_type); ?></td>
          <td><?php echo e(EF::numberformat($rows->amount)); ?></td>
          <td><?php echo e(EF::numberformat($rows->received_amount)); ?></td>
          <td><?php echo e(EF::numberformat($rows->amount - $rows->received_amount)); ?></td>


          <td><?php if($rows->status === "Paid"): ?>
                <?php if($rows->payment_type === "Commission"): ?> Paid <?php else: ?> Received <?php endif; ?>
                <?php else: ?>
                <?php echo e($rows->status); ?>

               <?php endif; ?>
            </td>
          <?php if(Auth::user()->hasAnyPermission(['All','Add Payment','Update Side Payment','Remove Side Payment'])): ?>
          <td class="text-center">
            <?php if($rows->status == 'Unpaid'): ?>
            <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 if(Auth::user()->hasAnyPermission(['All','Add Payment']) && $rows->amount > 0): ?>
               <a href="#" id="pay" class="dropdown-item" onclick="showPayPaymentModel(event,'<?php echo e(Crypt::encrypt(EF::getGenericTableIndex()['Commission'])); ?>','<?php echo e(Crypt::encrypt($rows->id)); ?>')"><i class="dropdown-icon fa fa-money"   ></i> Pay </a>
               <?php endif; ?>
                  <?php if(Auth::user()->hasAnyPermission(['All','Update Side Payment'])): ?>
             <?php if($rows->payment_type == 'Commission'): ?>
               <a onclick="update(event,'<?php echo e(json_encode($pass_data)); ?>','form_update_commission','md_update_commission','form_update_charges')" href="#" class="dropdown-item"><i class="dropdown-icon fa fa-edit"></i> Update </a>

               <?php else: ?>
                  <a value = "<?php echo e($rows->payment_type); ?>" onclick="updateCharges(event,'<?php echo e(json_encode($charges_data)); ?>','md_update_commission')" href="#" class="dropdown-item"><i class="dropdown-icon fa fa-edit"></i> Update </a>
               <?php endif; ?>
               <?php endif; ?>

               <?php if(Auth::user()->hasAnyPermission(['All','Remove Side Payment'])): ?>
                  <a href="<?php echo e(route('commission.trash',['id' => Crypt::encrypt($rows->id)])); ?>" content ="remove charges" class="dropdown-item  cls_delete"><i class="dropdown-icon  fa fa-trash"></i> Remove </a>
              <?php endif; ?>

             </div>
           </div>
           <?php endif; ?>
         </td>
        <?php endif; ?>
       </tr>

       <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
       <?php endif; ?>
     </tbody>
   </table>
 </div>


</div>
</div>
<?php endif; ?>
<?php /**PATH /var/www/skylite/resources/views/commission/manage_commission.blade.php ENDPATH**/ ?>