tambah download pdf

This commit is contained in:
hildaaaevs 2025-05-30 21:06:28 +07:00
parent 1e2f94acf6
commit 04462db32b
10 changed files with 441 additions and 35 deletions

View File

@ -1,18 +0,0 @@
<?php
namespace App\Filament\Pages;
use Filament\Pages\Dashboard as BaseDashboard;
use App\Filament\Widgets\CalendarWidget;
class Dashboard extends BaseDashboard
{
protected static ?string $navigationIcon = 'heroicon-o-home';
protected function getHeaderWidgets(): array
{
return [
CalendarWidget::class,
];
}
}

View File

@ -32,6 +32,8 @@
use Filament\Forms\Components\Grid; use Filament\Forms\Components\Grid;
use Filament\Forms\Components\Radio; use Filament\Forms\Components\Radio;
use Filament\Forms\Components\BelongsToSelect; use Filament\Forms\Components\BelongsToSelect;
use Barryvdh\DomPDF\Facade\Pdf;
use Filament\Forms\Components\Modal;
class ReservasiiResource extends Resource class ReservasiiResource extends Resource
{ {
@ -239,15 +241,36 @@ public static function table(Table $table): Table
EditAction::make(), EditAction::make(),
DeleteAction::make() DeleteAction::make()
]) ])
]); ])
} ->headerActions([
// ->bulkActions([ Tables\Actions\Action::make('downloadPdf')
//Tables\Actions\BulkActionGroup::make([ ->label('Download PDF')
//Tables\Actions\DeleteBulkAction::make(), ->icon('heroicon-o-document-arrow-down')
//]), ->form([
// ]) DatePicker::make('start_date')
//->defaultSort('created_at', 'desc'); ->label('Tanggal Mulai')
->required(),
DatePicker::make('end_date')
->label('Tanggal Selesai')
->required(),
])
->action(function (array $data) {
$reservasis = Reservasii::with(['user', 'detail.paketFoto'])
->whereBetween('tanggal', [$data['start_date'], $data['end_date']])
->get();
$pdf = Pdf::loadView('pdf.reservasi', [
'reservasis' => $reservasis,
'start_date' => $data['start_date'],
'end_date' => $data['end_date']
]);
return response()->streamDownload(function () use ($pdf) {
echo $pdf->output();
}, 'reservasi.pdf');
})
]);
}
public static function getRelations(): array public static function getRelations(): array
{ {

View File

@ -23,6 +23,8 @@
class AdminPanelProvider extends PanelProvider class AdminPanelProvider extends PanelProvider
{ {
protected static ?string $navigationLabel = 'Dashboard';
public function panel(Panel $panel): Panel public function panel(Panel $panel): Panel
{ {
return $panel return $panel

View File

@ -7,6 +7,7 @@
"license": "MIT", "license": "MIT",
"require": { "require": {
"php": "^8.2", "php": "^8.2",
"barryvdh/laravel-dompdf": "^3.1",
"filament/filament": "^3.2", "filament/filament": "^3.2",
"laravel/framework": "^11.31", "laravel/framework": "^11.31",
"laravel/tinker": "^2.9", "laravel/tinker": "^2.9",

299
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "be7f3b11976e7d288f560860af33c3ac", "content-hash": "888cb519a7bf5bc3e0fa714989a74c28",
"packages": [ "packages": [
{ {
"name": "anourvalar/eloquent-serialize", "name": "anourvalar/eloquent-serialize",
@ -72,6 +72,83 @@
}, },
"time": "2025-01-27T15:13:13+00:00" "time": "2025-01-27T15:13:13+00:00"
}, },
{
"name": "barryvdh/laravel-dompdf",
"version": "v3.1.1",
"source": {
"type": "git",
"url": "https://github.com/barryvdh/laravel-dompdf.git",
"reference": "8e71b99fc53bb8eb77f316c3c452dd74ab7cb25d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/barryvdh/laravel-dompdf/zipball/8e71b99fc53bb8eb77f316c3c452dd74ab7cb25d",
"reference": "8e71b99fc53bb8eb77f316c3c452dd74ab7cb25d",
"shasum": ""
},
"require": {
"dompdf/dompdf": "^3.0",
"illuminate/support": "^9|^10|^11|^12",
"php": "^8.1"
},
"require-dev": {
"larastan/larastan": "^2.7|^3.0",
"orchestra/testbench": "^7|^8|^9|^10",
"phpro/grumphp": "^2.5",
"squizlabs/php_codesniffer": "^3.5"
},
"type": "library",
"extra": {
"laravel": {
"aliases": {
"PDF": "Barryvdh\\DomPDF\\Facade\\Pdf",
"Pdf": "Barryvdh\\DomPDF\\Facade\\Pdf"
},
"providers": [
"Barryvdh\\DomPDF\\ServiceProvider"
]
},
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"psr-4": {
"Barryvdh\\DomPDF\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Barry vd. Heuvel",
"email": "barryvdh@gmail.com"
}
],
"description": "A DOMPDF Wrapper for Laravel",
"keywords": [
"dompdf",
"laravel",
"pdf"
],
"support": {
"issues": "https://github.com/barryvdh/laravel-dompdf/issues",
"source": "https://github.com/barryvdh/laravel-dompdf/tree/v3.1.1"
},
"funding": [
{
"url": "https://fruitcake.nl",
"type": "custom"
},
{
"url": "https://github.com/barryvdh",
"type": "github"
}
],
"time": "2025-02-13T15:07:54+00:00"
},
{ {
"name": "blade-ui-kit/blade-heroicons", "name": "blade-ui-kit/blade-heroicons",
"version": "2.6.0", "version": "2.6.0",
@ -850,6 +927,161 @@
], ],
"time": "2024-02-05T11:56:58+00:00" "time": "2024-02-05T11:56:58+00:00"
}, },
{
"name": "dompdf/dompdf",
"version": "v3.1.0",
"source": {
"type": "git",
"url": "https://github.com/dompdf/dompdf.git",
"reference": "a51bd7a063a65499446919286fb18b518177155a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/dompdf/dompdf/zipball/a51bd7a063a65499446919286fb18b518177155a",
"reference": "a51bd7a063a65499446919286fb18b518177155a",
"shasum": ""
},
"require": {
"dompdf/php-font-lib": "^1.0.0",
"dompdf/php-svg-lib": "^1.0.0",
"ext-dom": "*",
"ext-mbstring": "*",
"masterminds/html5": "^2.0",
"php": "^7.1 || ^8.0"
},
"require-dev": {
"ext-gd": "*",
"ext-json": "*",
"ext-zip": "*",
"mockery/mockery": "^1.3",
"phpunit/phpunit": "^7.5 || ^8 || ^9 || ^10 || ^11",
"squizlabs/php_codesniffer": "^3.5",
"symfony/process": "^4.4 || ^5.4 || ^6.2 || ^7.0"
},
"suggest": {
"ext-gd": "Needed to process images",
"ext-gmagick": "Improves image processing performance",
"ext-imagick": "Improves image processing performance",
"ext-zlib": "Needed for pdf stream compression"
},
"type": "library",
"autoload": {
"psr-4": {
"Dompdf\\": "src/"
},
"classmap": [
"lib/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-2.1"
],
"authors": [
{
"name": "The Dompdf Community",
"homepage": "https://github.com/dompdf/dompdf/blob/master/AUTHORS.md"
}
],
"description": "DOMPDF is a CSS 2.1 compliant HTML to PDF converter",
"homepage": "https://github.com/dompdf/dompdf",
"support": {
"issues": "https://github.com/dompdf/dompdf/issues",
"source": "https://github.com/dompdf/dompdf/tree/v3.1.0"
},
"time": "2025-01-15T14:09:04+00:00"
},
{
"name": "dompdf/php-font-lib",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/dompdf/php-font-lib.git",
"reference": "6137b7d4232b7f16c882c75e4ca3991dbcf6fe2d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/dompdf/php-font-lib/zipball/6137b7d4232b7f16c882c75e4ca3991dbcf6fe2d",
"reference": "6137b7d4232b7f16c882c75e4ca3991dbcf6fe2d",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"php": "^7.1 || ^8.0"
},
"require-dev": {
"symfony/phpunit-bridge": "^3 || ^4 || ^5 || ^6"
},
"type": "library",
"autoload": {
"psr-4": {
"FontLib\\": "src/FontLib"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-2.1-or-later"
],
"authors": [
{
"name": "The FontLib Community",
"homepage": "https://github.com/dompdf/php-font-lib/blob/master/AUTHORS.md"
}
],
"description": "A library to read, parse, export and make subsets of different types of font files.",
"homepage": "https://github.com/dompdf/php-font-lib",
"support": {
"issues": "https://github.com/dompdf/php-font-lib/issues",
"source": "https://github.com/dompdf/php-font-lib/tree/1.0.1"
},
"time": "2024-12-02T14:37:59+00:00"
},
{
"name": "dompdf/php-svg-lib",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/dompdf/php-svg-lib.git",
"reference": "eb045e518185298eb6ff8d80d0d0c6b17aecd9af"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/dompdf/php-svg-lib/zipball/eb045e518185298eb6ff8d80d0d0c6b17aecd9af",
"reference": "eb045e518185298eb6ff8d80d0d0c6b17aecd9af",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"php": "^7.1 || ^8.0",
"sabberworm/php-css-parser": "^8.4"
},
"require-dev": {
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Svg\\": "src/Svg"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0-or-later"
],
"authors": [
{
"name": "The SvgLib Community",
"homepage": "https://github.com/dompdf/php-svg-lib/blob/master/AUTHORS.md"
}
],
"description": "A library to read, parse and export to PDF SVG files.",
"homepage": "https://github.com/dompdf/php-svg-lib",
"support": {
"issues": "https://github.com/dompdf/php-svg-lib/issues",
"source": "https://github.com/dompdf/php-svg-lib/tree/1.0.0"
},
"time": "2024-04-29T13:26:35+00:00"
},
{ {
"name": "dragonmantank/cron-expression", "name": "dragonmantank/cron-expression",
"version": "v3.4.0", "version": "v3.4.0",
@ -4716,6 +4948,71 @@
], ],
"time": "2024-02-26T18:08:49+00:00" "time": "2024-02-26T18:08:49+00:00"
}, },
{
"name": "sabberworm/php-css-parser",
"version": "v8.8.0",
"source": {
"type": "git",
"url": "https://github.com/MyIntervals/PHP-CSS-Parser.git",
"reference": "3de493bdddfd1f051249af725c7e0d2c38fed740"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/MyIntervals/PHP-CSS-Parser/zipball/3de493bdddfd1f051249af725c7e0d2c38fed740",
"reference": "3de493bdddfd1f051249af725c7e0d2c38fed740",
"shasum": ""
},
"require": {
"ext-iconv": "*",
"php": "^5.6.20 || ^7.0.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0"
},
"require-dev": {
"phpunit/phpunit": "5.7.27 || 6.5.14 || 7.5.20 || 8.5.41"
},
"suggest": {
"ext-mbstring": "for parsing UTF-8 CSS"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "9.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Sabberworm\\CSS\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Raphael Schweikert"
},
{
"name": "Oliver Klee",
"email": "github@oliverklee.de"
},
{
"name": "Jake Hotson",
"email": "jake.github@qzdesign.co.uk"
}
],
"description": "Parser for CSS Files written in PHP",
"homepage": "https://www.sabberworm.com/blog/2010/6/10/php-css-parser",
"keywords": [
"css",
"parser",
"stylesheet"
],
"support": {
"issues": "https://github.com/MyIntervals/PHP-CSS-Parser/issues",
"source": "https://github.com/MyIntervals/PHP-CSS-Parser/tree/v8.8.0"
},
"time": "2025-03-23T17:59:05+00:00"
},
{ {
"name": "spatie/color", "name": "spatie/color",
"version": "1.8.0", "version": "1.8.0",

View File

@ -20,7 +20,7 @@ public function run(): void
'nama_paket_foto' => 'Paket Pasangan', 'nama_paket_foto' => 'Paket Pasangan',
'harga_paket_foto' => '75000', 'harga_paket_foto' => '75000',
'fasilitas' => '20 menit foto, 1x cetak foto single frame', 'fasilitas' => '20 menit foto, 1x cetak foto single frame',
'gambar' => '01JMC5FASB77HCJQHGNNS56X3P.jpg', 'gambar' => '.jpg',
'status' => true, 'status' => true,
'created_at' => now(), 'created_at' => now(),
'updated_at' => now() 'updated_at' => now()
@ -40,7 +40,7 @@ public function run(): void
'nama_paket_foto' => 'Widebox Couple', 'nama_paket_foto' => 'Widebox Couple',
'harga_paket_foto' => '50000', 'harga_paket_foto' => '50000',
'fasilitas' => '10 menit foto, 1x cetak foto 4R', 'fasilitas' => '10 menit foto, 1x cetak foto 4R',
'gambar' => 'platinum.jpg', 'gambar' => 'pasangan.jpg',
'status' => true, 'status' => true,
'created_at' => now(), 'created_at' => now(),
'updated_at' => now() 'updated_at' => now()

View File

@ -3,6 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="{{ asset('storage/logo.png') }}">
<script defer src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"></script> <script defer src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"></script>
<title>{{ $title ?? 'SiKolaself' }}</title> <title>{{ $title ?? 'SiKolaself' }}</title>

View File

@ -43,7 +43,7 @@
<!-- Submit Button --> <!-- Submit Button -->
<button type="submit" class="w-full py-3 px-4 bg-gray-600 text-white font-semibold rounded-lg hover:bg-gray-700">Login</button> <button type="submit" class="w-full py-3 px-4 bg-gray-600 text-white font-semibold rounded-lg hover:bg-gray-700">Login</button>
<p class="text-sm text-center text-gray-600">Sudah punya akun? <a href="/register" class="text-blue-600 hover:underline">Daftar</a></p> <p class="text-sm text-center text-gray-600">Belum punya akun? <a href="/register" class="text-blue-600 hover:underline">Daftar</a></p>
</form> </form>
</> </>
</div> </div>

View File

@ -1,5 +1,5 @@
<div class="w-full max-w-[85rem] py-10 px-4 sm:px-6 lg:px-8 mx-auto"> <div class="w-full max-w-[85rem] py-10 px-4 sm:px-6 lg:px-8 mx-auto">
<h1 class="text-4xl font-bold text-slate-500">Reservasi</h1> <h1 class="text-4xl font-bold text-slate-500">Histori</h1>
<div class="flex flex-col bg-white p-5 rounded mt-4 shadow-lg"> <div class="flex flex-col bg-white p-5 rounded mt-4 shadow-lg">
<div class="-m-1.5 overflow-x-auto"> <div class="-m-1.5 overflow-x-auto">
<div class="p-1.5 min-w-full inline-block align-middle"> <div class="p-1.5 min-w-full inline-block align-middle">
@ -7,13 +7,13 @@
<table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700"> <table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
<thead> <thead>
<tr> <tr>
<th scope="col" class="px-6 py-3 text-start text-xs font-medium text-gray-500 uppercase">Order</th> <th scope="col" class="px-6 py-3 text-start text-xs font-medium text-gray-500 uppercase">Id</th>
<th scope="col" class="px-6 py-3 text-start text-xs font-medium text-gray-500 uppercase">Tanggal</th> <th scope="col" class="px-6 py-3 text-start text-xs font-medium text-gray-500 uppercase">Tanggal</th>
<th scope="col" class="px-6 py-3 text-start text-xs font-medium text-gray-500 uppercase">Waktu</th> <th scope="col" class="px-6 py-3 text-start text-xs font-medium text-gray-500 uppercase">Waktu</th>
<th scope="col" class="px-6 py-3 text-start text-xs font-medium text-gray-500 uppercase">Paket Foto</th> <th scope="col" class="px-6 py-3 text-start text-xs font-medium text-gray-500 uppercase">Paket Foto</th>
<th scope="col" class="px-6 py-3 text-start text-xs font-medium text-gray-500 uppercase">Status Pembayaran</th> <th scope="col" class="px-6 py-3 text-start text-xs font-medium text-gray-500 uppercase">Tipe Pembayaran</th>
<th scope="col" class="px-6 py-3 text-start text-xs font-medium text-gray-500 uppercase">Total</th> <th scope="col" class="px-6 py-3 text-start text-xs font-medium text-gray-500 uppercase">Total</th>
<th scope="col" class="px-6 py-3 text-end text-xs font-medium text-gray-500 uppercase">Action</th> <th scope="col" class="px-6 py-3 text-end text-xs font-medium text-gray-500 uppercase">Aksi</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>

View File

@ -0,0 +1,100 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Data Reservasi</title>
<style>
body {
font-family: Arial, sans-serif;
font-size: 12px;
}
.header {
text-align: center;
margin-bottom: 20px;
}
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
.total {
text-align: right;
font-weight: bold;
margin-top: 10px;
}
.period {
margin-top: 5px;
font-size: 11px;
color: #666;
}
.summary {
margin-top: 20px;
border-top: 1px solid #ddd;
padding-top: 10px;
}
</style>
</head>
<body>
<div class="header">
<h1>Data Reservasi</h1>
<p>Tanggal Cetak: {{ date('d F Y') }}</p>
<p class="period">Periode: {{ \Carbon\Carbon::parse($start_date)->format('d F Y') }} - {{ \Carbon\Carbon::parse($end_date)->format('d F Y') }}</p>
</div>
<table>
<thead>
<tr>
<th>No</th>
<th>Nama</th>
<th>Tanggal</th>
<th>Waktu</th>
<th>Paket Foto</th>
<th>Total</th>
<th>Tipe Pembayaran</th>
<th>Metode Pembayaran</th>
</tr>
</thead>
<tbody>
@php
$totalHarga = 0;
@endphp
@foreach($reservasis as $index => $reservasi)
<tr>
<td>{{ $index + 1 }}</td>
<td>{{ $reservasi->nama }}</td>
<td>{{ $reservasi->tanggal->format('d F Y') }}</td>
<td>{{ $reservasi->waktu }}</td>
<td>
@foreach($reservasi->detail as $detail)
{{ $detail->paketFoto->nama_paket_foto }}<br>
@endforeach
</td>
<td>Rp {{ number_format($reservasi->total, 0, ',', '.') }}</td>
<td>{{ ucfirst($reservasi->tipe_pembayaran) }}</td>
<td>{{ ucfirst($reservasi->metode_pembayaran) }}</td>
</tr>
@php
$totalHarga += $reservasi->total;
@endphp
@endforeach
</tbody>
</table>
<div class="summary">
<div class="total">
Total Reservasi: {{ $reservasis->count() }}
</div>
<div class="total">
Total Pendapatan: Rp {{ number_format($totalHarga, 0, ',', '.') }}
</div>
</div>
</body>
</html>