<?php $__env->startSection('page_title'); ?>
Manage Stocks
<?php $__env->stopSection(); ?>
<?php $__env->startSection('page_header_title'); ?>
Manage Stock
<?php $__env->stopSection(); ?>
<?php ($label_list = EF::getWhiteLabel()); ?>

<?php $__env->startSection('page_body'); ?>
<?php echo e(Breadcrumbs::render('payable.view')); ?>


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



					     <h3 class="card-title">Payables</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>GRN No.</th>
                          <th>PO No.</th>
                          <th>Item</th>
                          <th>Total Amount</th>
                          <th>Received Amount</th>
													<th>Project</th>
                          <th>Status</th>
                           <th style="text-align: center;"><i class="dropdown-icon fa fa-cogs"></i></th>

                        </tr>
                      </thead>
                     <tbody>
                      <?php if(isset($payable_list)): ?>
                      <?php $__currentLoopData = $payable_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $rows): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <?php (

                            $id = array(
                            'payable'            => Crypt::encrypt($rows->id),
                            'total_amount'       => $rows->total_amount,
                            'received_amount'    => $rows->received_amount,
                            'payable_amount'     => $rows->total_amount - $rows->received_amount,
                            'amount_in_words'    => EF::numberToWords($rows->total_amount - $rows->received_amount),
                            )
                        ); ?>
                      <tr>
                        <td><?php echo e($loop->iteration); ?></td>
                        <td><?php echo e($rows->grn->grn_number); ?></td>
                        <td><?php echo e($rows->purchaseOrder->p_number); ?></td>
                        <td><?php echo e($rows->purchaseOrder->boqitem->item->name); ?></td>
                        <td><?php echo e(EF::numberFormat($rows->total_amount)); ?></td>
                        <td><?php echo e(EF::numberFormat($rows->received_amount)); ?></td>
                        <td><?php echo e($rows->purchaseOrder->boq->branch->name); ?></td>
                        
                        <td>
                          <?php if($rows->status == "Approved"): ?>
                            <span class="badge badge-success"><?php echo e($rows->status); ?></span>
                          <?php elseif($rows->status == "Pending"): ?>
                            <span class="badge badge-primary"><?php echo e($rows->status); ?></span>
                          <?php else: ?>
                            <span class="badge badge-warning"> <?php echo e($rows->status); ?></span>
                          <?php endif; ?>

                        </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">
                              <a href="javascript:void(0)" class="dropdown-item"><i class="dropdown-icon fa fa-cogs"></i> Action</a>
    
                              <?php if(Auth::user()->hasAnyPermission(['All','Pay Inventory Payable']) && $rows->status == 'Pending'): ?>
                               <div class="dropdown-divider"></div>

                                <a href="#" id="pay" class="dropdown-item" onclick="showPayPaymentModel(event,'<?php echo e(Crypt::encrypt(EF::getGenericTableIndex()['Inventory Payable'])); ?>','<?php echo e(Crypt::encrypt($rows->id)); ?>')"><i class="dropdown-icon fa fa-check"   ></i> Pay </a>
                               
                            

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

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

<?php $__env->startSection('page_modal'); ?>
   <?php echo $__env->make('inventory_module.payable.modals.pay_payable', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
   <div id="modal_add_payment"> </div>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('page_script'); ?>

<?php echo $__env->make('scripts.payment', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

<script>
  function checkPayableAmount(event,obj)
  {
    var payable_amount = $(obj).val();

   var total_amount =  $('.total_amount').val();
   var received_amount =  $('.received_amount').val();

   var pending_amount = isDefaulter(total_amount)-isDefaulter(received_amount);


  if(payable_amount > pending_amount)
  {

  field_unsuccess($('#amount'),'Invalid  Payable Amount');


            return false;
  }
  if(payable_amount <= 0)
  {

     field_unsuccess($('#amount'),'Invalid  Payable Amount');


            return false;

  }

   field_refersh($('#amount'));


  }

  </script>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.dashboard', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/ubuntu/rebmgisplus/skylite/resources/views/inventory_module/payable/managePayable.blade.php ENDPATH**/ ?>