<?php if(Auth::user()->hasAnyPermission(['All','View Subhead'])): ?>
<div class="table-responsive table-height">
    <table class="table table-hover table-outline table-vcenter text-nowrap card-table ">
      <thead>
        <tr>
          
          <th>#</th>
          <th>Code</th>
          <th>Name</th>
          <th>Type</th>
          <th>Status</th>

          <th>Closing Balance</th>
          <th>Date Created</th>
          <th></th>
        </tr>
      </thead>
      <tbody>

        <?php if(isset($subhead)): ?>
         
          <?php $__currentLoopData = $subhead; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $rows): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

          <?php ($balance = $journal->getClosingBalance(['head_id' => $rows->head_id],['id' => $rows->id])); ?>

           
        <tr>
          <td><?php echo e($loop->iteration); ?></td>
          <td><?php echo e($rows->code); ?></td>
          <td><?php echo e($rows->name); ?></td>                          
          <td><?php echo e($rows->type); ?></td>
          <td>
            <?php if($rows->flag == 1): ?>
              <span style="font-weight: bolder; font-size: 10pt;" class="badge badge-info badge-bolder"><strong>System Generated</strong></span>
            <?php else: ?> 
              <span style="font-weight: bolder; font-size: 10pt;" class="badge badge-success badge-bolder"><strong>Manual</strong></span>
            <?php endif; ?>
          </td>
          <td>

            <?php if($balance < 0 && in_array($rows->head->nature,['Capital / Equity','Long-term Liability','Short-term Liability','Revenue'])): ?>
                (<?php echo e(EF::numberFormat(abs($balance))); ?>)
            <?php else: ?>
                <?php echo e(EF::numberFormat(($balance))); ?>

            <?php endif; ?>

          </td>
          <td><?php echo e(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 if(Auth::user()->hasAnyPermission(['All','Update Subhead'])): ?>
                            <?php if(true): ?>
                                <a onclick="showUpdateSubHeadModel(event,'<?php echo e(Crypt::encrypt($rows->id)); ?>')" href="javascript:void(0)" class="dropdown-item" data-toggle="modal" data-target="#md_update_subhead"><i class="dropdown-icon fa fa-edit"></i> Update</a>
                            <?php endif; ?>
                          <?php endif; ?>
                      
                          <?php if(Auth::user()->hasAnyPermission(['All','Remove Subhead'])): ?>
                            <?php if($rows->flag == "0" && ($rows->countLedgerByAccount($rows->id)) == 0): ?>
                                <a onclick="removeSubhead(event,this);" href="<?php echo e(route('subhead.trash',['id' => Crypt::encrypt($rows->id)])); ?>" class="dropdown-item " content="remove subhead"><i class="dropdown-icon fa fa-trash"></i> Remove</a>
                            <?php endif; ?>
                          <?php endif; ?>

                          <?php if(Auth::user()->hasAnyPermission(['All','View Ledger'])): ?>
                            <a href="<?php echo e(route('subhead.viewledger',['id'=>Crypt::encrypt($rows->id)])); ?>" class="dropdown-item " ><i class="dropdown-icon fa fa-eye"></i> View Ledger</a>
                          <?php endif; ?>
                    </div>
                  </div>
               </td>
          </tr>
      	<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        <?php endif; ?>
        
      </tbody>
    </table>
  </div>
  <?php endif; ?><?php /**PATH /home/ubuntu/rebmgisplus/skylite/resources/views/components/subhead/subhead_table.blade.php ENDPATH**/ ?>