Commit ef9c054f by Siti Aisah

tambah datatable dan filter periode saku

parent 6f38d6b7
......@@ -5,21 +5,67 @@
use App\Http\Controllers\Controller;
use App\Models\Admin\Vsaku;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Session;
class LaporanController extends Controller
{
public function index() {
public function index(Request $request) {
$data['rs'] = Vsaku::get();
$filter_periode = DB::table('ms_periode')->orderBy('periode','asc')->get();
Session::put('periode', $request->periode);
if(empty(Session::get('periode'))) {
$rs = DB::table('v_saku_new')
->select('nama', 'nip', 'unit', DB::raw('COUNT(id_pengajuan) as jumlah'))
->groupBy('nama', 'nip', 'unit')
->get();
} else {
$periode = DB::table('ms_periode')->where('periode', Session::get('periode'))->first();
$rs = DB::table('v_saku_new')
->select('nama', 'nip', 'unit', DB::raw('COUNT(id_pengajuan) as jumlah'))
->whereBetween('tanggal_keputusan', [$periode->tanggal_awal, $periode->tanggal_akhir])
->groupBy('nama', 'nip', 'unit')
->get();
}
$data = [
'rs' => $rs,
'periode' => $filter_periode
];
return view('laporan.index', $data);
}
public function download(Request $request) {
$data['nama_file'] = 'Laporan Reviewer Sipeka '.date('Y-m-d');
$data['rs'] = Vsaku::get();
if(empty(Session::get('periode'))) {
$data['rs'] = DB::table('v_saku_new')
->select('nama', 'nip', 'unit', DB::raw('COUNT(id_pengajuan) as jumlah'))
->groupBy('nama', 'nip', 'unit')
->get();
$data['nama_file'] = 'Laporan Reviewer Sipeka Semua Periode';
} else {
$periode = DB::table('ms_periode')->where('periode', Session::get('periode'))->first();
$data['rs'] = DB::table('v_saku_new')
->select('nama', 'nip', 'unit', DB::raw('COUNT(id_pengajuan) as jumlah'))
->whereBetween('tanggal_keputusan', [$periode->tanggal_awal, $periode->tanggal_akhir])
->groupBy('nama', 'nip', 'unit')
->get();
$data['nama_file'] = 'Laporan Reviewer Sipeka Periode '. $periode->periode;
}
return view('laporan.excel', $data);
}
......
......@@ -5,15 +5,32 @@
<div class="card">
<div class="card-header">
<h4 class="card-title">SAKU Reviewer</h4>
<form action="{{ route('laporan.download') }}" method="POST">
@csrf
<button type="submit" class="btn btn-success pull-lefts">Download Excel</button>
</form>
</div>
<div class="card-body">
<div class="card-text">
<div class="row">
<div class="panel panel-info">
<div class="panel-body">
<form action="{{ route('laporan.download') }}" method="POST">
@csrf
<button type="submit" class="btn btn-success pull-lefts">Download Excel</button>
<form action="{{ route('laporan.index') }}" method="GET">
<div class="row">
<div class="col-md-3">
<label>Periode</label>
<select name="periode" class="form-control">
<option value="">Semua</option>
@foreach($periode as $p)
<option value={{ $p->periode }} @if( Session::get('periode') == $p->periode) selected="selected" @endif>{{ $p->periode }}</option>
@endforeach
</select>
</div>
<div class="col-md-2">
<br>
<button class="btn btn-info pull-lefts">Cari</button>
</div>
</div>
</form>
</div>
</div>
......
......@@ -59,6 +59,7 @@
<link rel="stylesheet" type="text/css" href="{{ url('theme/css/plugins/forms/pickers/form-pickadate.css') }}">
<link rel="stylesheet" type="text/css" href="{{ url('theme/css/pages/app-invoiceE.css') }}">
<link rel="stylesheet" href="https://cdn.datatables.net/1.12.1/css/jquery.dataTables.min.css">
<!-- BEGIN: Custom CSS-->
<link rel="stylesheet" type="text/css" href="{{ url('theme/assets/css/style.css') }}">
......
......@@ -26,7 +26,7 @@
</div>
<div class="table-responsive mb-4">
<table id="zero-config" class="table table-hover" style="width:100%">
<table id="datatable" class="table data-table table-hover" style="width:100%">
<thead>
<tr>
<th>No</th>
......@@ -92,5 +92,16 @@
</div>
</div>
@push('js')
<!-- Include DataTable JS -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons"></script>
<script>
$(document).ready(function() {
$('#datatable').DataTable();
});
feather.replace();
</script>
@endpush
@stop
......@@ -57,7 +57,7 @@
</div>
<div class="table-responsive mb-4">
<table id="zero-config" class="table table-hover" style="width:100%">
<table id="datatable" class="table data-table table-hover" style="width:100%">
<thead>
<tr>
@php
......@@ -182,5 +182,16 @@
</div>
</div>
@push('js')
<!-- Include DataTable JS -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons"></script>
<script>
$(document).ready(function() {
$('#datatable').DataTable();
});
feather.replace();
</script>
@endpush
@stop
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment