@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
{{-- المجموع النهائي --}}
| {{ __('Description') }} |
{{ __('Opening Debit') }} |
{{ __('Opening Credit') }} |
{{ __('Period Debit') }} |
{{ __('Period Credit') }} |
{{ __('Final Debit') }} |
{{ __('Final Credit') }} |
| {{ __('Total') }} |
{{ number_format($totals['total_debit_initial'] ?? 0, 2) }} |
{{ number_format($totals['total_creditor_initial'] ?? 0, 2) }} |
{{ number_format($totals['total_debit_within'] ?? 0, 2) }} |
{{ number_format($totals['total_creditor_within'] ?? 0, 2) }} |
{{ number_format($totals['total_debit'] ?? 0, 2) }} |
{{ number_format($totals['total_creditor'] ?? 0, 2) }} |
| {{ __('Difference') }} |
{{ number_format(($totals['total_debit_initial'] ?? 0) - ($totals['total_creditor_initial'] ?? 0), 2) }} |
{{ number_format(($totals['total_debit_within'] ?? 0) - ($totals['total_creditor_within'] ?? 0), 2) }} |
{{ number_format(($totals['total_debit'] ?? 0) - ($totals['total_creditor'] ?? 0), 2) }} |
@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 '| ' . __('Account') . ' | ';
echo '' . __('Serial Number') . ' | ';
echo '' . __('Opening Debit') . ' | ';
echo '' . __('Opening Credit') . ' | ';
echo '' . __('Period Debit') . ' | ';
echo '' . __('Period Credit') . ' | ';
echo '' . __('Final Debit') . ' | ';
echo '' . __('Final Credit') . ' | ';
echo '
';
echo '';
// صف الحساب الرئيسي
renderAccountRow($account, 1);
// الأطفال
if ($hasChildren) {
foreach ($account['children'] as $child) {
renderAllChildren($child, 2);
}
}
echo '';
// المجموع
echo '';
echo '| ' . __('Total') . ' | ';
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 '
';
echo '
';
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