@extends('layouts.dashboard')

@section('page_title')
	Accounts
@endsection

@section('page_header_title')
	Manage Accounts
@endsection

<!-- LIST OF BREADCRUMB  -->
@php($breadcrumb = ['head_id' => $head->id, 'head_name' => $head->name])
<!-- END -->

@section('page_body')

	<div class="row row-cards row-deck">
              <div class="col-12">
                <div class="card">
                	  <div class="card-header">
                    @if(Auth::user()->hasAnyPermission(['All','Add Subhead']))    

					     <button  class="float-right btn btn-sm btn-outline-primary" data-toggle="modal" data-target="#md_add_subhead"><i class="fa fa-plus"></i></button> &nbsp;&nbsp;
               @endif

					     <h3 class="card-title">Add Subhead</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>Code</th>
                          <th>Name</th>
                          <th>Type</th>
                          <th>Date Created</th>
                          <th></th>
                        </tr>
                      </thead>
                      <tbody>
            
                        @isset($subhead)
                          @php($pass_data = [])
                          @foreach($subhead as $rows)

                            @php(
                              $pass_data = array(
                                  'subhead_id'  => Crypt::encrypt($rows->id),
                                  'name'        => $rows->name,
                                  'code'        => $rows->code,
                                  'type'        => $rows->type,
                               
                                )
                            )
                        <tr>
                          <td>{{$loop->iteration}}</td>
                          <td>{{$rows->code}}</td>
                          <td>{{$rows->name}}</td>                          
                          <td>{{$rows->type}}</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 Subhead']))
                                          @if(true)
                                          <a onclick="update(event,'{{json_encode($pass_data)}}','form_update_subhead','md_update_subhead')" 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>
                                          @endif
                                      @endif
                                      
                                      @if(Auth::user()->hasAnyPermission(['All','Remove Subhead']))
                                          @if($rows->flag == "0" && ($rows->countLedgerByAccount($rows->id)) == 0)
                                          <a href="{{route('subhead.trash',['id' => Crypt::encrypt($rows->id)])}}" class="dropdown-item cls_delete" content="remove subhead"><i class="dropdown-icon fa fa-trash"></i> Remove</a>
                                          @endif
                                      @endif
                                      @if(Auth::user()->hasAnyPermission(['All','View Ledger']))
                                        <a href="{{route('subhead.viewledger',['id'=>Crypt::encrypt($rows->id)])}}" class="dropdown-item " ><i class="dropdown-icon fa fa-eye"></i> View Ledger</a>
                                        @endif
                                    </div>
                                  </div>
                               </td>
                        </tr>
                      	@endforeach
                        @endisset
                        
                      </tbody>
                    </table>
                  </div>
                </div>
              </div>
          </div>

@endsection

@section('page_modal')

@if(Auth::user()->hasAnyPermission(['All','Add Subhead']))    
  @include('accounts.modals.add_subhead')
@endif

@if(Auth::user()->hasAnyPermission(['All','Update Subhead']))    
  @include('accounts.modals.update_subhead')
@endif

@if(Auth::user()->hasAnyPermission(['All','Add Bank']))
  @include('bank.modals.add_bank')
@endif

@endsection

@section('page_script')
	@include('scripts.subhead')
  @include('scripts.bank')

@endsection

  