@extends('pdf.layouts.app') @section('title', 'General Ledger Report') @section('styles') @endsection @section('content')
@if(isset($data['data']) && is_array($data['data'])) @foreach($data['data'] as $account) @php renderAccountSection($account); @endphp @endforeach @elseif(is_array($data)) @foreach($data as $account) @php renderAccountSection($account); @endphp @endforeach @endif {{-- المجموع النهائي --}}
@endsection @php function renderAccountSection($account) { if (!isset($account['title']) || !isset($account['serial_number'])) return; $serialNumber = $account['serial_number'] ?? ''; $hasChildren = !empty($account['children']); echo '
'; // هيدر الحساب echo '
'; echo ''; echo ''; echo '
'; // الجدول echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; // صف الحساب الرئيسي renderAccountRow($account, 1); // الأطفال if ($hasChildren) { foreach ($account['children'] as $child) { renderAllChildren($child, 2); } } echo ''; // المجموع echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
' . __('Account') . '' . __('Serial Number') . '' . __('Opening Debit') . '' . __('Opening Credit') . '' . __('Period Debit') . '' . __('Period Credit') . '' . __('Final Debit') . '' . __('Final Credit') . '
' . __('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) . '
'; echo '
'; } function renderAllChildren($account, $level) { renderAccountRow($account, $level); if (!empty($account['children'])) { foreach ($account['children'] as $child) { renderAllChildren($child, $level + 1); } } } function renderAccountRow($account, $level) { $indent = ($level - 1) * 20; 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 ''; } @endphp