Commit 519e8625 authored by Mahmoud Aglan's avatar Mahmoud Aglan

Use branding data and receipt settings in all invoice/print views

Wizard inline invoice and the print/invoice view were using hardcoded
colors and no logo/branch info. Now they pull from SettingsService:
logo, primary_color, receipt_footer_text, and branch address/phone.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 4adf1a85
......@@ -706,16 +706,37 @@ class="inline-flex items-center gap-2 px-8 py-3 min-h-16 bg-green-600 text-white
{{-- Printable Invoice --}}
@if($this->invoiceForPrint)
@php $inv = $this->invoiceForPrint; @endphp
<div id="printable-invoice" class="bg-white border border-gray-300 rounded-xl p-6 max-w-2xl mx-auto print:border-0 print:shadow-none print:rounded-none print:p-0 print:max-w-full">
{{-- Invoice Header --}}
@php
$inv = $this->invoiceForPrint;
$branding = app(\App\Domain\Shared\Services\SettingsService::class);
$brandLogo = $branding->get('branding.logo');
$academyName = app('current_academy')->name_ar ?? '';
$branch = \App\Domain\Identity\Models\Branch::where('academy_id', app('current_academy')?->id)->first();
$receiptFooter = $branding->get('branding.receipt_footer_text', '');
@endphp
<div id="printable-invoice" class="bg-white border border-gray-300 rounded-xl p-4 sm:p-6 max-w-2xl mx-auto print:border-0 print:shadow-none print:rounded-none print:p-0 print:max-w-full">
{{-- Invoice Header with Branding --}}
<div class="flex items-start justify-between border-b border-gray-200 pb-4 mb-4">
<div>
<h3 class="text-lg font-bold text-gray-800">{{ __('فاتورة') }}</h3>
<p class="text-sm text-gray-500 mt-1" dir="ltr">#{{ $inv->number }}</p>
<div class="flex items-center gap-3">
@if($brandLogo)
<img src="{{ Storage::disk('public')->url($brandLogo) }}" alt="{{ $academyName }}" class="h-12 sm:h-14 object-contain">
@endif
<div>
<h3 class="text-base sm:text-lg font-bold text-gray-800">{{ $academyName }}</h3>
@if($branch)
<p class="text-xs text-gray-500">{{ $branch->name_ar }}</p>
@if($branch->address)
<p class="text-xs text-gray-400">{{ $branch->address }}</p>
@endif
@if($branch->phone)
<p class="text-xs text-gray-400" dir="ltr">{{ $branch->phone }}</p>
@endif
@endif
</div>
</div>
<div class="text-end text-sm">
<p class="font-semibold text-gray-700">{{ app('current_academy')->name_ar ?? '' }}</p>
<p class="font-bold text-gray-700">{{ __('فاتورة') }}</p>
<p class="text-gray-500 mt-1 font-mono" dir="ltr">#{{ $inv->number }}</p>
<p class="text-gray-500 mt-1">{{ __('التاريخ') }}: {{ $inv->issue_date?->format('Y/m/d') ?? now()->format('Y/m/d') }}</p>
<p class="text-gray-500">{{ __('الاستحقاق') }}: {{ $inv->due_date?->format('Y/m/d') ?? now()->addDays(7)->format('Y/m/d') }}</p>
</div>
......@@ -773,7 +794,7 @@ class="inline-flex items-center gap-2 px-8 py-3 min-h-16 bg-green-600 text-white
@endif
@if($inv->service_fee_amount > 0)
<div class="flex justify-between">
<span class="text-gray-500">{{ __('رسوم الخدمة (3%)') }}</span>
<span class="text-gray-500">{{ __('رسوم الخدمة') }}</span>
<span class="font-medium" dir="ltr">{{ number_format($inv->service_fee_amount / 100, 2) }} {{ __('ج.م') }}</span>
</div>
@endif
......@@ -819,6 +840,13 @@ class="inline-flex items-center gap-2 px-8 py-3 min-h-16 bg-green-600 text-white
</span>
@endif
</div>
{{-- Footer from branding settings --}}
@if($receiptFooter)
<div class="mt-4 pt-3 border-t border-gray-200 text-center text-xs text-gray-500">
{{ $receiptFooter }}
</div>
@endif
</div>
{{-- Actions --}}
......
......@@ -3,19 +3,29 @@
<head>
<meta charset="UTF-8">
<title>{{ __('فاتورة') }} - {{ $invoice->invoice_number }}</title>
@php
$branding = app(\App\Domain\Shared\Services\SettingsService::class);
$brandLogo = $branding->get('branding.logo');
$brandPrimary = $branding->get('branding.primary_color', '#1e40af');
$receiptFooter = $branding->get('branding.receipt_footer_text', __('تم إنشاء هذه الفاتورة إلكترونياً ولا تحتاج إلى توقيع'));
$academyName = app()->bound('current_academy') ? app('current_academy')->name_ar : 'الكابتن';
$branch = \App\Domain\Identity\Models\Branch::where('academy_id', app('current_academy')?->id)->first();
@endphp
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Cairo', 'Noto Sans Arabic', sans-serif; direction: rtl; padding: 30px; font-size: 13px; color: #333; }
.header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 30px; padding-bottom: 20px; border-bottom: 2px solid #1e40af; }
.header h1 { font-size: 24px; color: #1e40af; }
.header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 30px; padding-bottom: 20px; border-bottom: 2px solid {{ $brandPrimary }}; }
.header h1 { font-size: 24px; color: {{ $brandPrimary }}; }
.header .meta { text-align: left; font-size: 12px; color: #666; }
.header .meta p { margin-bottom: 3px; }
.header .brand { display: flex; align-items: center; gap: 12px; }
.header .brand img { height: 50px; object-fit: contain; }
.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-bottom: 25px; }
.party { padding: 15px; background: #f8fafc; border-radius: 8px; }
.party h3 { font-size: 12px; color: #64748b; margin-bottom: 8px; text-transform: uppercase; }
.party p { margin-bottom: 3px; }
table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
th { background: #1e40af; color: white; padding: 10px 12px; text-align: right; font-size: 12px; }
th { background: {{ $brandPrimary }}; color: white; padding: 10px 12px; text-align: right; font-size: 12px; }
td { padding: 10px 12px; border-bottom: 1px solid #e2e8f0; }
.totals { margin-right: auto; width: 280px; }
.totals .row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; }
......@@ -34,13 +44,27 @@
</head>
<body>
<div class="no-print">
<button onclick="window.print()" style="padding: 8px 20px; background: #1e40af; color: white; border: none; border-radius: 6px; cursor: pointer;">{{ __('طباعة') }}</button>
<button onclick="window.print()" style="padding: 8px 20px; background: {{ $brandPrimary }}; color: white; border: none; border-radius: 6px; cursor: pointer;">{{ __('طباعة') }}</button>
</div>
<div class="header">
<div>
<h1>{{ __('فاتورة') }}</h1>
<p style="color: #64748b; margin-top: 4px;">{{ app()->bound('current_academy') ? app('current_academy')->name_ar : 'الكابتن' }}</p>
<div class="brand">
@if($brandLogo)
<img src="{{ Storage::disk('public')->url($brandLogo) }}" alt="{{ $academyName }}">
@endif
<div>
<h1>{{ __('فاتورة') }}</h1>
<p style="color: #64748b; margin-top: 4px;">{{ $academyName }}</p>
@if($branch)
<p style="color: #64748b; font-size: 11px;">{{ $branch->name_ar }}</p>
@if($branch->address)
<p style="color: #94a3b8; font-size: 11px;">{{ $branch->address }}</p>
@endif
@if($branch->phone)
<p style="color: #94a3b8; font-size: 11px;" dir="ltr">{{ $branch->phone }}</p>
@endif
@endif
</div>
</div>
<div class="meta">
<p><strong>{{ __('رقم الفاتورة') }}:</strong> {{ $invoice->invoice_number }}</p>
......@@ -108,6 +132,12 @@
<span dir="ltr" style="color: #dc2626;">-{{ format_money($invoice->discount_amount) }}</span>
</div>
@endif
@if(($invoice->service_fee_amount ?? 0) > 0)
<div class="row">
<span>{{ __('رسوم الخدمة') }}</span>
<span dir="ltr">{{ format_money($invoice->service_fee_amount) }}</span>
</div>
@endif
@if($invoice->tax_amount > 0)
<div class="row">
<span>{{ __('الضريبة') }}</span>
......@@ -157,7 +187,7 @@
@endif
<div class="footer">
{{ __('تم إنشاء هذه الفاتورة إلكترونياً ولا تحتاج إلى توقيع') }}
{{ $receiptFooter }}
</div>
</body>
</html>
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