Commit ef9c054f by Siti Aisah

tambah datatable dan filter periode saku

parent 6f38d6b7
...@@ -5,21 +5,67 @@ ...@@ -5,21 +5,67 @@
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Admin\Vsaku; use App\Models\Admin\Vsaku;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Session;
class LaporanController extends Controller 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); return view('laporan.index', $data);
} }
public function download(Request $request) { public function download(Request $request) {
$data['nama_file'] = 'Laporan Reviewer Sipeka '.date('Y-m-d'); if(empty(Session::get('periode'))) {
$data['rs'] = Vsaku::get();
$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); return view('laporan.excel', $data);
} }
......
...@@ -5,15 +5,32 @@ ...@@ -5,15 +5,32 @@
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<h4 class="card-title">SAKU Reviewer</h4> <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>
<div class="card-body"> <div class="card-body">
<div class="card-text"> <div class="card-text">
<div class="row"> <div class="row">
<div class="panel panel-info"> <div class="panel panel-info">
<div class="panel-body"> <div class="panel-body">
<form action="{{ route('laporan.download') }}" method="POST"> <form action="{{ route('laporan.index') }}" method="GET">
@csrf <div class="row">
<button type="submit" class="btn btn-success pull-lefts">Download Excel</button> <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> </form>
</div> </div>
</div> </div>
......
...@@ -59,6 +59,7 @@ ...@@ -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/plugins/forms/pickers/form-pickadate.css') }}">
<link rel="stylesheet" type="text/css" href="{{ url('theme/css/pages/app-invoiceE.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--> <!-- BEGIN: Custom CSS-->
<link rel="stylesheet" type="text/css" href="{{ url('theme/assets/css/style.css') }}"> <link rel="stylesheet" type="text/css" href="{{ url('theme/assets/css/style.css') }}">
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
</div> </div>
<div class="table-responsive mb-4"> <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> <thead>
<tr> <tr>
<th>No</th> <th>No</th>
...@@ -92,5 +92,16 @@ ...@@ -92,5 +92,16 @@
</div> </div>
</div> </div>
@push('js') @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 @endpush
@stop @stop
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
</div> </div>
<div class="table-responsive mb-4"> <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> <thead>
<tr> <tr>
@php @php
...@@ -182,5 +182,16 @@ ...@@ -182,5 +182,16 @@
</div> </div>
</div> </div>
@push('js') @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 @endpush
@stop @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