@extends('layouts.app')

@section('content')
{{--*/ usort($tableGrid, "SiteHelpers::_sort") /*--}}
<div class="page-titles mb-4 text-center">
	<h2 class="h4 font-weight-bold text-success mb-1">{{ $pageTitle }}</h2>
	<p class="text-muted">{{ $pageNote }}</p>
</div>
<div class="card shadow-sm border-0">
	<div class="card-body">
		<div class="d-flex justify-content-between align-items-center mb-3">
			<div>
				<div class="btn-group btn-group-sm">
					<button type="button" class="btn btn-outline-success dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
						<i class="fa fa-tasks"></i> Bulk Action
					</button>
					<ul class="dropdown-menu">
						@if($access['is_excel'] ==1)
							<li>
								<a href="{{ url( $pageModule .'/export?do=excel&return='.$return) }}" class="dropdown-item">
									<i class="fa fa-file-excel me-2 text-success"></i>Export Excel
								</a>
							</li>
							<li>
								<a href="{{ url( $pageModule .'/download-excel?return='.$return) }}" class="dropdown-item">
									<i class="fa fa-download me-2 text-success"></i>Download Excel
								</a>
							</li>
						@endif
					</ul>
				</div>
			</div>
		</div>

		{!! Form::open(['url'=>'mutubersihpta/delete/', 'class'=>'form-horizontal', 'id' =>'SximoTable']) !!}
		<div class="table-responsive" style="min-height:300px; max-height:500px; overflow-y:auto; overflow-x:auto;">
			<table class="table table-hover align-middle table-bordered table-striped" id="freeze-header-table" style="min-width:1200px;">
				<thead class="table-success" style="position: sticky; top: 0; z-index: 10; background: #d1e7dd;">
					<tr>
						<th class="number text-center" style="position: sticky; left: 0; top: 0; background: #d1e7dd; z-index: 11;">No</th>
						@php $colIndex = 1; @endphp
						@foreach ($tableGrid as $t)
							@if($t['view'] =='1')
								<th 
									@if($colIndex < 6)
										style="position: sticky; left: {{ $colIndex * 120 }}px; top: 0; background: #d1e7dd; z-index: 11;"
									@else
										style="position: sticky; top: 0; background: #d1e7dd; z-index: 10;"
									@endif
								>
									{{ $t['label'] }}
								</th>
								@php $colIndex++; @endphp
							@endif
						@endforeach
					</tr>
				</thead>
				<tbody>
					@foreach ($rowData as $row)
						<tr>
							<td class="text-center" style="position: sticky; left: 0; background: #fff; z-index: 2;">{{ ++$i }}</td>
							@php $colIndex = 1; @endphp
							@foreach ($tableGrid as $field)
								@if($field['view'] =='1')
									<?php 
										$limited = isset($field['limited']) ? $field['limited'] :''; 
										$isNumber = isset($field['type']) && in_array($field['type'], ['int','float','double','decimal','number']);
									?>
									@if(SiteHelpers::filterColumn($limited ))
										<td class="{{ $isNumber ? 'text-end' : '' }}"
											@if($colIndex < 6)
												style="position: sticky; left: {{ $colIndex * 120 }}px; background: #fff; z-index: 2;"
											@endif
										>
											@if($isNumber)
												{{ number_format($row->{$field['field']}) }}
											@else
												{!! SiteHelpers::formatRows($row->{$field['field']},$field ,$row ) !!}
											@endif
										</td>
										@php $colIndex++; @endphp
									@endif
								@endif
							@endforeach
						</tr>
					@endforeach
				</tbody>
			</table>
			<input type="hidden" name="md" value="" />
		</div>
		{!! Form::close() !!}
		@include('footer')
	</div>
</div>
@stop
