@extends('pdf.layouts.app') @section('title', 'General Ledger Report') @section('styles') @endsection @section('content') @php $isRtl = ($direction ?? 'rtl') === 'rtl'; // Translation helper $t = [ 'total' => $isRtl ? 'الإجمالي' : 'Total', 'difference' => $isRtl ? 'الفرق' : 'Difference', 'description' => $isRtl ? 'البيان' : 'Description', 'serial_number' => $isRtl ? 'الرقم التسلسلي' : 'Serial Number', 'account' => $isRtl ? 'الحساب' : 'Account', 'opening_debit' => $isRtl ? 'مدين افتتاحي' : 'Opening Debit', 'opening_credit' => $isRtl ? 'دائن افتتاحي' : 'Opening Credit', 'period_debit' => $isRtl ? 'مدين الفترة' : 'Period Debit', 'period_credit' => $isRtl ? 'دائن الفترة' : 'Period Credit', 'total_debit_col' => $isRtl ? 'إجمالي مدين' : 'Total Debit', 'total_credit_col' => $isRtl ? 'إجمالي دائن' : 'Total Credit', 'final_debit' => $isRtl ? 'رصيد مدين' : 'Closing Debit', 'final_credit' => $isRtl ? 'رصيد دائن' : 'Closing Credit', 'no_data' => $isRtl ? 'لا توجد بيانات للعرض' : 'No data available to display', ]; @endphp
@if(isset($data['data']) && is_array($data['data'])) @foreach($data['data'] as $account) @php renderAccountSection($account, $t, $isRtl); @endphp @endforeach @elseif(is_array($data)) @foreach($data as $account) @php renderAccountSection($account, $t, $isRtl); @endphp @endforeach @endif {{-- Grand total section --}}
@endsection @php function renderAccountSection($account, $t, $isRtl) { if (!isset($account['title']) || !isset($account['serial_number'])) return; $serialNumber = $account['serial_number'] ?? ''; $hasChildren = !empty($account['children']); echo '
'; // Account header echo '
'; echo ''; echo ''; echo '
'; // Table echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; // Main account row renderAccountRow_TB($account, 1, $isRtl); // Children if ($hasChildren) { foreach ($account['children'] as $child) { renderAllChildren_TB($child, 2, $isRtl); } } echo ''; // Total row echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
' . e($t['account']) . '' . e($t['serial_number']) . '' . e($t['opening_debit']) . '' . e($t['opening_credit']) . '' . e($t['period_debit']) . '' . e($t['period_credit']) . '' . e($t['total_debit_col']) . '' . e($t['total_credit_col']) . '' . e($t['final_debit']) . '' . e($t['final_credit']) . '
' . e($t['total']) . '' . number_format($account['total_debit_initial'] ?? 0, 2) . '' . number_format($account['total_creditor_initial'] ?? 0, 2) . '' . number_format($account['total_debit_within'] ?? 0, 2) . '' . number_format($account['total_creditor_within'] ?? 0, 2) . '' . number_format($account['total_debit'] ?? 0, 2) . '' . number_format($account['total_creditor'] ?? 0, 2) . '' . number_format($account['closing_debit'] ?? 0, 2) . '' . number_format($account['closing_creditor'] ?? 0, 2) . '
'; echo '
'; } function renderAllChildren_TB($account, $level, $isRtl) { renderAccountRow_TB($account, $level, $isRtl); if (!empty($account['children'])) { foreach ($account['children'] as $child) { renderAllChildren_TB($child, $level + 1, $isRtl); } } } function renderAccountRow_TB($account, $level, $isRtl) { $indent = ($level - 1) * 18; $levelClass = 'level-' . min($level, 6); $padStyle = $isRtl ? 'padding-right:' . $indent . 'px;' : 'padding-left:' . $indent . 'px;'; echo ''; echo '' . e($account['title']) . ''; echo '' . ($account['serial_number'] ?? '') . ''; echo '' . number_format($account['total_debit_initial'] ?? 0, 2) . ''; echo '' . number_format($account['total_creditor_initial'] ?? 0, 2) . ''; echo '' . number_format($account['total_debit_within'] ?? 0, 2) . ''; echo '' . number_format($account['total_creditor_within'] ?? 0, 2) . ''; echo '' . number_format($account['total_debit'] ?? 0, 2) . ''; echo '' . number_format($account['total_creditor'] ?? 0, 2) . ''; echo '' . number_format($account['closing_debit'] ?? 0, 2) . ''; echo '' . number_format($account['closing_creditor'] ?? 0, 2) . ''; echo ''; } @endphp