@php
$direction = $direction ?? 'ltr';
$isRtl = $direction === 'rtl';
$start = $isRtl ? 'right' : 'left';
$end = $isRtl ? 'left' : 'right';
$primaryColor = '#195FBB';
$boxBorder = '#D1D9E6';
$textColor = '#1E293B';
$textMuted = '#64748B';
$bgLight = '#F0F4FA';
$isExchange = (isset($capture_exchange) && in_array(strtolower($capture_exchange ?? ''), ['exchange','payment']))
|| (isset($voucher_type) && (stripos($voucher_type ?? '', 'payment') !== false || stripos($voucher_type ?? '', 'exchange') !== false));
$voucherTitle = $isRtl ? ($isExchange ? 'سند صرف' : 'سند قبض') : ($isExchange ? 'Payment Voucher' : 'Receipt Voucher');
$voucherSubtitle = $isRtl ? ($isExchange ? 'Payment Voucher' : 'Receipt Voucher') : ($isExchange ? 'سند صرف' : 'سند قبض');
$ca = is_object($credit_account ?? null) ? (array)$credit_account : ($credit_account ?? []);
$creditAmount = $ca['credit_amount'] ?? 0;
$currSymbol = $isRtl ? 'ج.م' : 'EGP';
$amountWords = $ca['amount_in_words'] ?? '---';
$accNo = $ca['account_no'] ?? '---';
$accTitle = $ca['account_title'] ?? '---';
$logoImg = data_get($company ?? [], 'invoice_logo') ?: null;
$isHtml = request()->query('view') === 'html';
$logoSrc = null;
if ($logoImg) {
$logoSrc = $isHtml ? asset($logoImg) : public_path($logoImg);
if (!$isHtml && !file_exists($logoSrc)) $logoSrc = null;
}
$companyName = data_get($company ?? [], 'company_name', data_get($company ?? [], 'name_company', 'Azora'));
$companyVat = data_get($company ?? [], 'company_vat', data_get($company ?? [], 'tax_number', '---'));
$voucherNo = $number_doc ?? ($id ?? '---');
$voucherDate = $date ?? (isset($created_at) ? \Carbon\Carbon::parse($created_at)->format('Y-m-d') : date('Y-m-d'));
$exchRate = number_format($currency_transfer_rate ?? 1, 2);
$payMethod = $payment_method ?? ($isRtl ? 'تحويل بنكي' : 'Bank Transfer');
$bankName = $name ?? '---';
// جمع صفوف الجدول
$rows = [];
if (!empty($transfers) && count($transfers) > 0) {
foreach ($transfers as $t) {
$tArr = (array) $t;
$amt = $tArr['creditor'] ?? 0;
if ((float)$amt == 0) continue;
$treeAcc = $tArr['tree_accounting'] ?? $tArr['treeAccounting'] ?? [];
$tAccNo = $treeAcc['account_number'] ?? $treeAcc['code'] ?? $tArr['account_no'] ?? '---';
$tTitle = $treeAcc['title'] ?? null;
if (!$tTitle && !empty($treeAcc['translations']) && is_array($treeAcc['translations'])) {
$tTitle = $treeAcc['translations'][0]['title'] ?? null;
}
$tTitle = $tTitle ?: ($tArr['account_title'] ?? '---');
$rows[] = [
'account_no' => $tAccNo,
'account_title' => $tTitle,
'description' => $tArr['notes'] ?? $tArr['description'] ?? ($description ?? '---'),
'file_no' => $tArr['file_no'] ?? ($file_no ?? '---'),
'ref_no' => $tArr['ref_no'] ?? ($ref_no ?? '---'),
'amount' => $amt,
'symbol' => $currSymbol,
];
}
}
if (empty($rows)) {
$rows[] = [
'account_no' => $accNo,
'account_title' => $accTitle,
'description' => $description ?? '---',
'file_no' => $file_no ?? '---',
'ref_no' => $ref_no ?? '---',
'amount' => $creditAmount,
'symbol' => $currSymbol,
];
}
@endphp
{{-- ───────────────────────────────────────────
1. HEADER
─────────────────────────────────────────── --}}
|
{{ $voucherTitle }}
{{-- فاصل إجباري لحل مشكلة اللزق في mPDF --}}
{{ $isRtl ? 'رقم السند:' : 'Voucher No:' }} {{ $voucherNo }}
{{ $isRtl ? 'التاريخ:' : 'Date:' }} {{ $voucherDate }}
|
{{-- لوجو واسم الشركة --}}
@if($logoSrc)

@endif
{{ $companyName }}
{{-- فاصل إجباري لحل مشكلة اللزق في mPDF --}}
{{-- الرقم الضريبي --}}
{{ $isRtl ? 'الرقم الضريبي:' : 'VAT No:' }} {{ $companyVat }}
{{-- فاصل إجباري لحل مشكلة اللزق في mPDF --}}
{{-- Amount Box (مبني كجدول) --}}
|
{{ $isRtl ? 'إجمالي المبلغ' : 'TOTAL AMOUNT' }}
@if($isRtl)
{{ number_format($creditAmount, 2) }} {{ $currSymbol }}
@else
{{ $currSymbol }} {{ number_format($creditAmount, 2) }}
@endif
|
|
{{-- ───────────────────────────────────────────
2. PAID BY / BENEFICIARY (تم التعديل كجداول متداخلة)
─────────────────────────────────────────── --}}
|
{{ $isRtl ? 'استلمنا من' : 'Received From' }}
{{ $created_name ?? '---' }}
|
|
|
|
{{ $isRtl ? 'المستفيد' : 'Beneficiary ' }}
{{ $accTitle }}
|
|
{{-- ───────────────────────────────────────────
3. AMOUNT IN WORDS
─────────────────────────────────────────── --}}
|
{{'A' }}
|
{{ $isRtl ? 'المبلغ بالحروف' : 'AMOUNT IN WORDS' }}
{{ $amountWords }}
|
{{-- ───────────────────────────────────────────
4. BANK / RATE / METHOD (تم التعديل كجداول متداخلة)
─────────────────────────────────────────── --}}
|
{{ $isRtl ? 'البنك / الخزينة' : 'Bank / Safe' }}
{{ $bankName }}
|
|
|
|
{{ $isRtl ? 'سعر الصرف' : 'Exchange Rate' }}
{{ $exchRate }} {{ $currSymbol }}/EGP
|
|
{{-- ───────────────────────────────────────────
5. ACCOUNTS TABLE
─────────────────────────────────────────── --}}
| {{ $isRtl ? 'اسم الحساب' : 'ACCOUNT NAME' }} |
{{ $isRtl ? 'البيان' : 'DESCRIPTION' }} |
{{ $isRtl ? 'ملف الرحلة' : 'FILE' }} |
{{ $isRtl ? 'رقم المرجع' : 'REF' }} |
{{ $isRtl ? 'القيمة' : 'AMOUNT' }} |
@foreach($rows as $row)
| {{ $row['account_title'] }} |
{{ $row['description'] }} |
{{ $row['file_no'] }} |
{{ $row['ref_no'] }} |
{{ number_format($row['amount'],2) }} {{ $row['symbol'] }}
|
@endforeach
{{-- ───────────────────────────────────────────
6. NOTES (تم التعديل كجدول متداخل)
─────────────────────────────────────────── --}}
|
{{ $isRtl ? 'ملاحظات / تعليقات' : 'Notes / Remarks' }}
{{ $notes ?? $description ?? ($isRtl ? 'لا يوجد ملاحظات إضافية.' : 'No additional remarks.') }}
|
{{-- فاصل كبير جداً (140px) لزق التوقيعات لأسفل الصفحة --}}
{{-- ───────────────────────────────────────────
7. SIGNATURES
─────────────────────────────────────────── --}}
@if($isRtl)
|
توقيع المستلم
|
|
اعتماد بواسطة
|
|
المحاسب
|
@else
Accountant
|
|
Approved By
|
|
Receiver Signature
|
@endif
{{-- end .page-content --}}