update lagi tgl 25
This commit is contained in:
parent
02c22275e7
commit
6597e856c0
|
@ -4,6 +4,9 @@
|
|||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\LaporanModel;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Exports\LaporanExport;
|
||||
|
||||
class LaporanController extends Controller
|
||||
{
|
||||
|
@ -18,4 +21,30 @@ public function index()
|
|||
|
||||
return view('Laporan', compact('laporan', 'totalUangMasuk', 'totalUangKeluar', 'totalGaji', 'totalKredit', 'saldo'));
|
||||
}
|
||||
|
||||
public function exportExcel()
|
||||
{
|
||||
return Excel::download(new LaporanExport, 'laporan-keuangan-'.date('Y-m-d').'.xlsx');
|
||||
}
|
||||
|
||||
public function exportPDF()
|
||||
{
|
||||
$laporan = LaporanModel::orderBy('Tanggal', 'desc')->get();
|
||||
$totalUangMasuk = LaporanModel::sum('uang_masuk');
|
||||
$totalUangKeluar = LaporanModel::sum('uang_keluar');
|
||||
$totalGaji = LaporanModel::sum('gaji');
|
||||
$totalKredit = $totalUangKeluar + $totalGaji;
|
||||
$saldo = $totalUangMasuk - $totalKredit;
|
||||
|
||||
$pdf = PDF::loadView('laporan-pdf', compact(
|
||||
'laporan',
|
||||
'totalUangMasuk',
|
||||
'totalUangKeluar',
|
||||
'totalGaji',
|
||||
'totalKredit',
|
||||
'saldo'
|
||||
));
|
||||
|
||||
return $pdf->download('laporan-keuangan-'.date('Y-m-d').'.pdf');
|
||||
}
|
||||
}
|
|
@ -6,10 +6,12 @@
|
|||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.1",
|
||||
"barryvdh/laravel-dompdf": "^3.1",
|
||||
"guzzlehttp/guzzle": "^7.2",
|
||||
"laravel/framework": "^10.10",
|
||||
"laravel/sanctum": "^3.3",
|
||||
"laravel/tinker": "^2.8"
|
||||
"laravel/tinker": "^2.8",
|
||||
"maatwebsite/excel": "^3.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.9.1",
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -170,17 +170,39 @@
|
|||
<!-- Action Buttons -->
|
||||
<div class="flex justify-between items-center mt-4 mb-4">
|
||||
<div class="flex space-x-2">
|
||||
<button class="btn bg-green-500 text-white hover:bg-green-600">
|
||||
<a href="{{ route('laporan.export-excel') }}" class="btn bg-green-500 text-white hover:bg-green-600">
|
||||
<i class="fas fa-file-excel mr-2"></i>Export Excel
|
||||
</button>
|
||||
<button class="btn bg-red-500 text-white hover:bg-red-600">
|
||||
</a>
|
||||
<a href="{{ route('laporan.export-pdf') }}" class="btn bg-red-500 text-white hover:bg-red-600">
|
||||
<i class="fas fa-file-pdf mr-2"></i>Export PDF
|
||||
</button>
|
||||
<button class="btn bg-gray-500 text-white hover:bg-gray-600">
|
||||
</a>
|
||||
<button onclick="window.print()" class="btn bg-gray-500 text-white hover:bg-gray-600">
|
||||
<i class="fas fa-print mr-2"></i>Print
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Style untuk print -->
|
||||
<style>
|
||||
@media print {
|
||||
.btn, header, footer, .no-print {
|
||||
display: none !important;
|
||||
}
|
||||
body {
|
||||
padding: 20px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.print-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
.print-table th,
|
||||
.print-table td {
|
||||
border: 1px solid #000;
|
||||
padding: 8px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- Pagination (same as before) -->
|
||||
<!-- Modal (same as before) -->
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
|
||||
//untuk Laporan
|
||||
Route::get('/Laporan', [LaporanController::class, 'index'])->name('Laporan.index');
|
||||
Route::get('/laporan/export-excel', [LaporanController::class, 'exportExcel'])->name('laporan.export-excel');
|
||||
Route::get('/laporan/export-pdf', [LaporanController::class, 'exportPDF'])->name('laporan.export-pdf');
|
||||
|
||||
//untuk Home
|
||||
Route::get('/home', [HomeController::class, 'index'])->name('home');
|
||||
|
|
Loading…
Reference in New Issue