@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 style="position:relative;">
			<style>
				.table-responsive {
					overflow-y: auto;
					max-height: 400px;
				}
				.table thead th {
					position: sticky;
					top: 0;
					background: #fff;
					z-index: 2;
				}
				/* Freeze columns up to "Kode Kat" */
				.table-responsive {
					position: relative;
				}
				.table th.freeze-col,
				.table td.freeze-col {
					position: sticky;
					background: #fff;
					z-index: 3;
				}
				/* Add more .freeze-col-N for each column to freeze */
				.table th.freeze-col-1, .table td.freeze-col-1 { left: 0; z-index: 4; }
				.table th.freeze-col-2, .table td.freeze-col-2 { left: 60px; z-index: 4; }
				.table th.freeze-col-3, .table td.freeze-col-3 { left: 120px; z-index: 4; }
				.table th.freeze-col-4, .table td.freeze-col-4 { left: 180px; z-index: 4; }
				.table th.freeze-col-5, .table td.freeze-col-5 { left: 240px; z-index: 4; }
			</style>

			{!! Form::open(array('url'=>'reportlkpkebun/delete/', 'class'=>'form-horizontal' ,'id' =>'SximoTable' )) !!}
			<div class="table-responsive" style="min-height:300px; max-height:400px;">
				<table class="table table-hover table-striped">
					<thead>
						<tr>
							<th class="number freeze-col freeze-col-1 freeze-bg"> No </th>			
							@php $freezeCols = 1; @endphp
							@foreach ($tableGrid as $idx => $t)
								@if($t['view'] =='1')
									@php
										$freezeClass = '';
										$bgClass = '';
										if ($freezeCols < 11) { // Sampai kolom ke-10 (Kode Kat)
											$freezeClass = 'freeze-col freeze-col-'.($freezeCols+1);
											$bgClass = 'freeze-bg';
										}
										$freezeCols++;
									@endphp
									<th class="{{ $freezeClass }} {{ $bgClass }}">{{ $t['label'] }}</th>
								@endif
							@endforeach
						</tr>
					</thead>
					<tbody>
						@php $i = 0; @endphp
						@foreach ($rowData as $row)
							<tr>
								@php $colIdx = 1; @endphp
								<td class="freeze-col freeze-col-1" width="30"> {{ ++$i }} </td>
								@foreach ($tableGrid as $field)
									@if($field['view'] =='1')
										<?php $limited = isset($field['limited']) ? $field['limited'] :''; ?>
										@if(SiteHelpers::filterColumn($limited ))
											<td>
												{!! SiteHelpers::formatRows($row->{$field['field']},$field ,$row ) !!}
											</td>
										@endif
									@endif
								@endforeach
							</tr>
						@endforeach
					</tbody>

	        <tbody>
							
	            @foreach ($rowData as $row)
	                <tr>
						<td width="30"> {{ ++$i }} </td>	
					@foreach ($tableGrid as $field)
						 @if($field['view'] =='1')
						 	<?php $limited = isset($field['limited']) ? $field['limited'] :''; ?>
						 	@if(SiteHelpers::filterColumn($limited ))
							 <td>					 
							 	{!! SiteHelpers::formatRows($row->{$field['field']},$field ,$row ) !!}						 
							 </td>
							@endif	
						 @endif					 
					 @endforeach				 
					
	                </tr>
					
	            @endforeach
	              
	        </tbody>
	      
	    </table>
		<input type="hidden" name="md" value="" />
		</div>
		{!! Form::close() !!}
		
		
		@include('footer')
	</div>  
</div>
@stop