sigd/resources/views/modules/reports/crf/index.blade.php

90 lines
3.6 KiB
PHP

@extends('layouts.master')
@section('content')
<div class="card shadow-sm">
<div class="card-header d-flex justify-content-between align-items-center">
<h5 class="mb-0 font-weight-bold">{{@$title}}</h5>
</div>
<div class="card-body">
<form id="crfForm" method="GET">
<div class="row">
<div class="col-md-2 pr-1">
<x-inventory-year-select :selected-year="$inventoryYear" />
</div>
<div class="col-lg-2 pr-1">
<x-activity-year-select :selected-year="$activityYear" :inventory-year="$inventoryYear" />
</div>
<div class="col-md-2 pr-1">
<div class="form-group">
<label for="category">Sektor:</label>
<div class="input-group">
<select name="category" id="category" class="form-control">
<option value="">Sektor</option>
@foreach ($categories as $category)
<option value="{{ $category->code }}"
{{ $sectorCode == $category->code ? 'selected' : '' }}>
{{ $category->name }}
</option>
@endforeach
</select>
</div>
</div>
</div>
<div class="col-lg-12 d-flex align-items-end align-items-center pt-1 pr-1 gap-3">
<div class="form-group mt-2 mb-0 mr-2">
<button type="submit" class="btn btn-info">Tampilkan</button>
</div>
<div class="form-group mt-2 mb-0">
<a href="{{ route($route.'.export', [
'inventoryYear' => $inventoryYear,
'activityYear' => $activityYear,
'sectorCode' => $sectorCode,
]) }}"
class="btn btn-success">Ekspor Excel</a>
</div>
</div>
</div>
</form>
<br />
@if ($crfData->isNotEmpty())
@include('modules.reports.crf.table')
@endif
</div>
</div>
@endsection
@section('js')
<script>
$(document).ready(function() {
$('#inventoryYear').select2({
placeholder: 'Pilih Tahun'
});
$('#activityYear').select2({
placeholder: 'Pilih Tahun'
});
$('#category').select2({
placeholder: 'Pilih Sektor'
});
$('#crfForm').on('submit', function(event) {
event.preventDefault();
const actionUrl = updateFormAction();
window.location.href = actionUrl;
});
});
function updateFormAction() {
const inventoryYear = $('#inventoryYear').val();
const activityYear = $('#activityYear').val() || '';
const sectorCode = $('#category').val() || '';
let actionUrl = `{{ url('laporan/crf') }}/${inventoryYear}`;
if (activityYear) actionUrl += `/${activityYear}`;
if (sectorCode) actionUrl += `/${sectorCode}`;
return actionUrl;
}
</script>
@endsection