feat: testing print

This commit is contained in:
Yoga Pangestu 2024-12-18 22:03:17 +07:00
parent 69806263cf
commit 9dd4e63f4b
3 changed files with 149 additions and 0 deletions

View File

@ -73,6 +73,13 @@
@if (in_array(auth()->user()->role_id, [1, 3, 4]))
<td>
<ul class="action">
<li class="show">
<a href="{{ route('print.page') }}" data-bs-toggle="tooltip"
data-bs-placement="left" data-bs-title="Print"
target="_blank">
<i data-feather="printer"></i>
</a>
</li>
<li class="edit">
<a href="{{ route('manage.transaction.edit', encryptId($transaction->id)) }}"
data-bs-toggle="tooltip" data-bs-placement="left"

View File

@ -0,0 +1,134 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Invoice</title>
<style>
@page {
size: 80mm auto;
/* Sesuaikan dengan lebar printer thermal */
margin: 0;
}
body {
margin: 0;
padding: 0;
width: 80mm;
font-family: Arial, sans-serif;
font-size: 12px;
line-height: 1.5;
}
.invoice-header {
text-align: center;
margin-bottom: 10px;
}
.invoice-header h1 {
font-size: 16px;
margin: 0;
}
.invoice-header p {
font-size: 12px;
margin: 0;
}
.invoice-details,
.invoice-footer {
margin: 10px 0;
}
.invoice-details table {
width: 100%;
border-collapse: collapse;
}
.invoice-details th,
.invoice-details td {
text-align: left;
padding: 5px;
}
.invoice-details th {
font-weight: bold;
}
.invoice-footer {
text-align: center;
font-size: 12px;
}
.divider {
border-top: 1px dashed #000;
margin: 10px 0;
}
</style>
</head>
<body>
<div class="invoice-header">
<h1>Barbershop Name</h1>
<p>Alamat Barbershop</p>
<p>Telepon: 123-456-789</p>
</div>
<div class="divider"></div>
<div class="invoice-details">
<table>
<tr>
<th>Tanggal:</th>
<td>{{ date('Y-m-d H:i') }}</td>
</tr>
<tr>
<th>Invoice:</th>
<td>#{{ $transaction->id }}</td>
</tr>
<tr>
<th>Pelanggan:</th>
<td>{{ $transaction->customer->name }}</td>
</tr>
</table>
</div>
<div class="divider"></div>
<div class="invoice-items">
<table>
<tr>
<th>Layanan</th>
<th>Harga</th>
</tr>
<tr>
<td>{{ $transaction->service->name }}</td>
<td>{{ number_format($transaction->price, 2) }}</td>
</tr>
<tr>
<td>Diskon</td>
<td>{{ number_format($transaction->discount, 2) }}</td>
</tr>
<tr>
<td>Total</td>
<td>{{ number_format($transaction->total, 2) }}</td>
</tr>
</table>
</div>
<div class="divider"></div>
<div class="invoice-footer">
<p>Metode Pembayaran:
{{ $transaction->payment_method == '1' ? 'Cash' : ($transaction->payment_method == '2' ? 'Qris' : 'Other') }}
</p>
<p>Terima kasih atas kunjungan Anda!</p>
</div>
<script>
window.print();
</script>
</body>
</html>

View File

@ -17,7 +17,9 @@
use App\Http\Controllers\Admin\Setting\AccountController;
use App\Http\Controllers\Admin\Setting\ApplicationController;
use App\Http\Controllers\Client\HomepageController;
use App\Models\Transaction;
use Illuminate\Support\Facades\Route;
use Psy\Readline\Transient;
Route::prefix('auth')->group(function () {
Route::get('login', [LoginController::class, 'index'])->name('login');
@ -176,3 +178,9 @@
});
Route::get('/', [HomepageController::class, 'index'])->name('homepage');
Route::get('/print-page', function () {
return view('print-page', [
'transaction' => Transaction::first()
]); // Ganti dengan nama view halaman cetak Anda
})->name('print.page');