@extends('layouts.app')

@section('content')
{{--*/ usort($tableGrid, "SiteHelpers::_sort") /*--}}
<style>
.select2-container{
	border: 2px solid #ffc107 !important;
    border-radius: 8px;
    background: linear-gradient(90deg, #fffbe6 0%, #fff 100%);
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.15);
    font-weight: 500;
}
</style>
<div class="page-titles">
  <h2> {{ $pageTitle }} <small> {{ $pageNote }} </small></h2>
</div>
<div  class="card">
	<div class="card-body">
		<div class="toolbar-nav">
			<form method="GET" action="" class="mb-3">
				<div class="row">
					<div class="col-md-2">
						<input type="date" id="tgl1" name="tgl1" class="form-control" placeholder="Filter table..." value="{{ request('tgl1', date('Y-m-d')) }}">
					</div>
					<div class="col-md-2">
						<input type="date" id="tgl2" name="tgl2" class="form-control" placeholder="Filter table..." value="{{ request('tgl2', date('Y-m-d')) }}">
					</div>
					<div class="col-md-3">

						<select name="filter_cluster" id="filter_cluster" class="form-control border-primary">
 								<option value="">Semua Cluster</option>
                                <option value="SUMATERA 1">SUMATERA 1</option>
                                <option value="SUMATERA 2">SUMATERA 2</option>
                                <option value="JATENG">JATENG</option>
                                <option value="JATIM 1">JATIM 1</option>
                                <option value="JATIM 2">JATIM 2</option>                                
                                <option value="SULAWESI">SULAWESI</option>
						</select>
					</div>
					<div class="col-md-3">

						<select name="filter_kebun" id="filter_kebun" class="form-control border-success">
						
						</select>
					</div>
					
					    
					<div class="col-md-2 text-right">
						<button type="submit" class="btn btn-success">
							<i class="fas fa-filter"></i> Filter
						</button>
					</div>
				</div>
				
			</form>
		<div >

	

		@if(count($results) > 0)
			
		<div style="max-height:600px; overflow:auto;">
			<table class="table table-bordered table-striped">

				<thead class="thead-light" style="position: sticky; top: 0; z-index: 2;">
					<tr>
						<th class="text-center bg-success text-white" style="font-size:14px;">No</th>
						@foreach($results[0] as $key => $value)
							<th class="text-center bg-warning text-dark" style="font-size:14px;">
								{{ ucwords(str_replace('_', ' ', $key)) }}
							</th>
						@endforeach
					</tr>
				</thead>
				<tbody>
					@foreach($results as $no => $row)
						<tr>
							<td>{{ $no+1 }}</td>
							@foreach($row as $value)
								<td>{{ $value }}</td>
							@endforeach
						</tr>
					@endforeach
				</tbody>
			</table>
		</div>
		
		@endif
		
		@include('footer')
	</div>  
</div>
<script>
	                        $("#filter_kebun").jCombo("{!! url('dataprodisconsole/comboselect?filter=master_kebun:nama_kebun:nama_kebun') !!}",
                                    {  initial_text : 'Pilih Kebun', selected_value : "{{ request('filter_kebun') }}" });
		
									@if(request('filter_cluster'))	
									$("#filter_cluster").val("{{ request('filter_cluster') }}");
									@endif

</script>
@stop