@extends('layouts.app')

@section('content')
{{--*/ usort($tableGrid, "SiteHelpers::_sort") /*--}}
<div class="page-titles">
  <h2> {{ $pageTitle }} <small> {{ $pageNote }} </small></h2>
</div>
<div  class="card">
	<div class="card-body">
		<div class="toolbar-nav">
			<div class="row">
				<div class="col-md-6">
					<div class="btn-group">
						<button type="button" class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-bars"></i> Bulk Action </button>
				        <ul class="dropdown-menu">
				         @if($access['is_excel'] ==1)
							<li class="nav-item"><a href="{{ url( $pageModule .'/export?do=excel&return='.$return) }}" class="nav-link"> Export CSV </a></li>	
						@endif
				        </ul>
				    </div>	
				</div>    
			</div>
		<div >

	


		 {!! Form::open(array('url'=>'takdesrekapafdeling/delete/', 'class'=>'form-horizontal' ,'id' =>'SximoTable' )) !!}
		 <div class="table-responsive" style="min-height:300px; max-height: 500px; overflow-y: auto;">
	    <table class="table table-hover table-striped table-bordered">
	        <thead class="thead-dark" style="background-color: #000; color: #fff; position: sticky; top: 0; z-index: 10;">
				<tr>
					<th class="number" style="background-color: #000; color: #fff; border-color: #000; position: sticky; top: 0;"> No </th>			
					@foreach ($tableGrid as $t)
						@if($t['view'] =='1')
							<th style="background-color: #000; color: #fff; border-color: #000; position: sticky; top: 0;">{{ $t['label'] }}</th>
						@endif
					@endforeach
				  </tr>
	        </thead>

	        <tbody>
							
	            @foreach ($rowData as $row)
	                <?php 
	                    $hasTotal = false;
	                    foreach ($tableGrid as $field) {
	                        if($field['view'] == '1') {
	                            $fieldValue = $row->{$field['field']};
	                            if (stripos($fieldValue, 'TOTAL') !== false) {
	                                $hasTotal = true;
	                                break;
	                            }
	                        }
	                    }
	                ?>
	                <tr @if($hasTotal) style="background-color: rgba(0,0,0,0.1); font-weight: bold;" @endif>
						<td width="30" @if($hasTotal) style="background-color: rgba(0,0,0,0.1); font-weight: bold;" @endif> {{ ++$i }} </td>	
					<?php $colIndex = 1; ?>
					@foreach ($tableGrid as $field)
						 @if($field['view'] =='1')
						 	<?php $limited = isset($field['limited']) ? $field['limited'] :''; ?>
						 	@if(SiteHelpers::filterColumn($limited ))
							 <td @if($hasTotal) style="background-color: rgba(0,0,0,0.1); font-weight: bold; @if($colIndex == 9 || ($colIndex >= 10 && $colIndex <= 19)) text-align: right; @endif" @else @if($colIndex == 9 || ($colIndex >= 10 && $colIndex <= 19)) style="text-align: right;" @endif @endif>					 
							 	@if($colIndex == 9 && is_numeric($row->{$field['field']}))
							 		{{ number_format($row->{$field['field']}, 3, '.', ',') }}
							 	@elseif($colIndex >= 10 && $colIndex <= 19 && is_numeric($row->{$field['field']}))
							 		{{ number_format($row->{$field['field']}, 2, '.', ',') }}
							 	@else
							 		{!! SiteHelpers::formatRows($row->{$field['field']},$field ,$row ) !!}
							 	@endif						 
							 </td>
							 <?php $colIndex++; ?>
							@endif	
						 @endif					 
					 @endforeach				 
					
	                </tr>
					
	            @endforeach
	              
	        </tbody>
	      
	    </table>
		<input type="hidden" name="md" value="" />
		</div>
		{!! Form::close() !!}
		
		
		@include('footer')
	</div>  
</div>
@stop