daily report done

pull/1/head
Aji Kamaludin 5 years ago
parent 37d4d86c64
commit a5d7562fdd
No known key found for this signature in database
GPG Key ID: 23E2BDC458317AF8

@ -0,0 +1,31 @@
<?php
namespace App\Exports;
use App\Models\Transaksi;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
class LaporanHarianExport implements FromView
{
public function __construct($date, $tanggal)
{
$this->date = $date;
$this->tanggal = $tanggal;
}
public function collection()
{
return Transaksi::orderBy('siswa_id','desc')->whereDate('created_at', $this->date)->get();
}
public function view(): View
{
return view('dashboard.export', [
'transaksi' => $this->collection(),
'date' => $this->date,
'tanggal' => $this->tanggal,
'jumlah' => 0
]);
}
}

@ -5,6 +5,10 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Models\Keuangan;
use App\Models\Tagihan;
use App\Models\Transaksi;
use App\Exports\LaporanHarianExport;
use Maatwebsite\Excel\Facades\Excel;
class HomeController extends Controller
{
@ -14,12 +18,17 @@ class HomeController extends Controller
$total_uang_spp = Keuangan::where('tipe','in')->where('transaksi_id','!=','null')->sum('jumlah') - Keuangan::where('tipe','out')->where('transaksi_id','!=','null')->sum('jumlah');;
$total_uang_masuk = Keuangan::where('tipe','in')->sum('jumlah');
$total_uang_keluar = Keuangan::where('tipe','out')->sum('jumlah');
$transaksi = Transaksi::orderBy('siswa_id','desc')->whereDate('created_at', now()->today())->get();
return view('dashboard.index',[
'total_uang' => $total_uang,
'total_uang_tabungan' => $total_uang_tabungan,
'total_uang_spp' => $total_uang_spp,
'total_uang_masuk' => $total_uang_masuk,
'total_uang_keluar' => $total_uang_keluar,
'transaksi' => $transaksi,
'jumlah' => '0'
]);
}
@ -58,6 +67,15 @@ class HomeController extends Controller
]);
}
//TODO: dump sql all data
//TODO: reset all data
public function cetak(Request $request){
$date = \Carbon\Carbon::create($request->date)->format('Y-m-d');
$transaksi = Transaksi::orderBy('siswa_id','desc')->whereDate('created_at', $date)->get();
return view('dashboard.export', ['transaksi' => $transaksi, 'date' => $request->date, 'jumlah' => 0, 'print' => true]);
}
public function export(Request $request){
$date = \Carbon\Carbon::create($request->date)->format('Y-m-d');
return Excel::download(new LaporanHarianExport($date, $request->date), 'laporan-harian-'.now().'.xlsx');
}
}

@ -22,6 +22,10 @@ class Tagihan extends Model
return $this->hasMany('App\Models\Transaksi','tagihan_id','id');
}
public function transaksiToday(){
return $this->transaksi()->whereDate('created_at', now()->today());
}
public function role(){
return $this->hasMany('App\Models\Role','tagihan_id','id');
}

@ -0,0 +1,49 @@
<h2 style="text-align:center"><b> {{ $sitename }} </b></h2 >
<h3 style="text-align:center">Laporan Harian</h3>
<p><b>Tanggal :</b> {{ $date }} </p>
<table style="border: 1px solid black; width: 100%">
<thead style="border: 1px solid black;">
<tr>
<th>Tanggal</th>
<th>Nama</th>
<th>Pembayaran</th>
<th>Total</th>
</tr>
</thead>
<tbody>
@foreach ($transaksi as $index => $item)
<tr class="{{ ($index%2) ? 'gray' : '' }}">
<td>{{ $item->created_at->format('d-m-Y') }}</td>
<td>{{ $item->siswa->nama." (".$item->siswa->kelas->nama.")" }}</td>
<td>{{ $item->tagihan->nama }}</td>
<td>IDR. {{ format_idr($item->keuangan->jumlah) }}</td>
@php
$jumlah += $item->keuangan->jumlah
@endphp
</tr>
@endforeach
<tr>
<td><b>Total</b></td>
<td></td>
<td></td>
<td>IDR. {{ format_idr($jumlah) }}</td>
</tr>
</tbody>
</table>
@if(isset($print))
<style>
@media print {
tr.gray {
background-color: #ececec !important;
-webkit-print-color-adjust: exact;
}
th {
background-color: #dadada !important;
-webkit-print-color-adjust: exact;
}
}
</style>
<script>
window.print()
</script>
@endif

@ -54,13 +54,42 @@
<div class="card-header">
<h3 class="card-title">Laporan Harian : {{ now()->format('d-m-Y') }}</h3>
<div class="card-options">
<input class="form-control mr-2" type="text" name="dates" style="max-width: 200px" data-toggle="datepicker" autocomplete="off" value="{{ now()->format('d-m-Y') }}">
<input class="form-control mr-2" type="text" name="dates" style="max-width: 200px" data-toggle="datepicker" autocomplete="off" value="{{ now()->format('d-m-Y') }}" id="date">
<button id="btn-cetak-spp" class="btn btn-primary mr-1" value="#">Cetak</button>
<a href="#!" target="_blank" class="btn btn-primary">Export</a>
<button id="btn-export-spp" class="btn btn-primary">Export</button>
</div>
</div>
<div class="card-body">
report harian
<table class="table card-table table-hover table-vcenter text-nowrap title" id="print">
<thead>
<tr>
<th>Tanggal</th>
<th>Nama</th>
<th>Pembayaran</th>
<th>Total</th>
</tr>
</thead>
<tbody>
@foreach ($transaksi as $item)
<tr>
<td>{{ $item->created_at->format('d-m-Y') }}</td>
<td>{{ $item->siswa->nama }}</td>
<td>{{ $item->tagihan->nama }}</td>
<td>IDR. {{ format_idr($item->keuangan->jumlah) }}</td>
@php
$jumlah += $item->keuangan->jumlah
@endphp
</tr>
@endforeach
<tr>
<td><b>Total</b></td>
<td></td>
<td></td>
<td>IDR. {{ format_idr($jumlah) }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
@ -73,6 +102,46 @@
$('[data-toggle="datepicker"]').datepicker({
format: 'dd-MM-yyyy'
});
$('#btn-cetak-spp').on('click', function(){
var form = document.createElement("form");
form.setAttribute("style", "display: none");
form.setAttribute("method", "post");
form.setAttribute("action", "{{route('laporan-harian.cetak')}}");
form.setAttribute("target", "_blank");
var token = document.createElement("input");
token.setAttribute("name", "_token");
token.setAttribute("value", "{{csrf_token()}}");
var dateForm = document.createElement("input");
dateForm.setAttribute("name", "date");
dateForm.setAttribute("value", $('#date').val());
form.appendChild(token);
form.appendChild(dateForm);
document.body.appendChild(form);
form.submit();
})
$('#btn-export-spp').on('click', function(){
var form = document.createElement("form");
form.setAttribute("style", "display: none");
form.setAttribute("method", "post");
form.setAttribute("action", "{{route('laporan-harian.export')}}");
form.setAttribute("target", "_blank");
var token = document.createElement("input");
token.setAttribute("name", "_token");
token.setAttribute("value", "{{csrf_token()}}");
var dateForm = document.createElement("input");
dateForm.setAttribute("name", "date");
dateForm.setAttribute("value", $('#date').val());
form.appendChild(token);
form.appendChild(dateForm);
document.body.appendChild(form);
form.submit();
})
});
});
</script>

@ -32,8 +32,8 @@
<p>Logo : </p>
<img src="{{ asset("img/logo.jpg") }}" alt="Logo Sistem" height="250px">
<div class="mt-8">
<button class="btn btn-primary btn-sm">Backup Data</button>
<button class="btn btn-danger btn-sm">Reset Data</button>
{{-- <button class="btn btn-primary btn-sm">Backup Data</button>
<button class="btn btn-danger btn-sm">Reset Data</button> --}}
</div>
</div>
</div>

@ -17,6 +17,8 @@ Route::middleware(['auth:web'])->group(function(){
Route::get('pengaturan','HomeController@pengaturan')->name('pengaturan.index');
Route::get('ubah-pengaturan','HomeController@editPengaturan')->name('pengaturan.edit');
Route::post('ubah-pengaturan','HomeController@storePengaturan')->name('pengaturan.store');
Route::Post('cetak-laporan-harian','HomeController@cetak')->name('laporan-harian.cetak');
Route::post('export-laporan-harian','HomeController@export')->name('laporan-harian.export');
//Siswa
Route::get('siswa','SiswaController@index')->name('siswa.index');

Loading…
Cancel
Save