{!! Form::open(['role' => 'form', 'class' => 'form-horizontal form-groups', 'id' => 'budgetForm']) !!} @foreach ($months as $key => $month) @endforeach @php $GLOBALS['operation'] = $operation; $GLOBALS['maxLevel'] = $ledgers->max('level'); $GLOBALS['months'] = $months; $GLOBALS['childLedgerIds'] = $budgetConfig->pluck('child')->toArray(); $GLOBALS['parentLedgerIds'] = $budgetConfig->pluck('parent')->toArray(); $GLOBALS['budgetConfig'] = $budgetConfig; $GLOBALS['actualBudgetValues'] = $actualBudgetValues; $GLOBALS['skipedLedgerIds'] = $skipedLedgerIds; // if $type = receipt nature would be // Asset -> Credit // Liability -> Debit // Capital Fund -> Credit // Income -> Credit // if $type = payment nature would be // Asset -> Debit // Liability -> Credit // Capital Fund -> Debit // Expenses -> Debit // account type 1= Asset, 6 = Liability, 9= Capital Fund, 12 = Income and 13 = Expenses $GLOBALS['natureRules']['receipt'][1] = 'credit'; $GLOBALS['natureRules']['receipt'][6] = 'credit'; $GLOBALS['natureRules']['receipt'][9] = 'credit'; $GLOBALS['natureRules']['receipt'][12] = 'credit'; $GLOBALS['natureRules']['payment'][1] = 'debit'; $GLOBALS['natureRules']['payment'][6] = 'debit'; $GLOBALS['natureRules']['payment'][9] = 'debit'; $GLOBALS['natureRules']['payment'][13] = 'debit'; function print_ledger($ledgers, $ledger, $type, $parentLedgerId = '', $parentAccountTypeId) { $childrens = []; $nature = @$GLOBALS['natureRules'][$type][$parentAccountTypeId]; $config = null; $config = $GLOBALS['budgetConfig'] ->where('parentNature', $nature) ->where('parent', $ledger->id) ->first(); // this ledger may be child of different parents by this nature $configAsChild = $GLOBALS['budgetConfig'] ->where('childNature', $nature) ->where('child', $ledger->id) ->first(); // according to the config determine whether it will affect the childrens if (in_array($ledger->id, $GLOBALS['parentLedgerIds'])) { // if config is found according to this nature then it will effect the value of childrens if ($config != null) { $childrens = $GLOBALS['budgetConfig']->where('id', $config->id); } } $trString = '' . "".""; $childParentConfigs = []; foreach ($GLOBALS['months'] as $key => $month) { $monthWithoutComa = str_replace(', ', '', $month); foreach ($childrens as $key => $child) { $parentConfigs = $GLOBALS['budgetConfig']->where('child', $child->child)->where('childNature', $child->childNature); $childParentConfigs[$key] = $parentConfigs; $childrens[$key]->month = $monthWithoutComa; } $style = 'style="width:80px;text-align: right;'; $readonly = 'readonly'; $function = ''; if ($ledger->isGroupHead) { $style .= 'background-color: #cbd5d6;"'; } elseif (in_array($ledger->id, $GLOBALS['childLedgerIds']) && $configAsChild != null && $configAsChild->childNature == $nature) { $style .= 'background-color: #bab5b5;"'; } else { $style .= '"'; $readonly = ''; // $function = "onInput='changeChildren(" . htmlspecialchars(json_encode($childrens, true), ENT_QUOTES, 'UTF-8') . ', this.value, ' . htmlspecialchars(json_encode($month), ENT_QUOTES, 'UTF-8') . ");'"; $function = "onInput='changeChildren(" . htmlspecialchars(json_encode($childrens, true), ENT_QUOTES, 'UTF-8') . ', this, ' . htmlspecialchars(json_encode($monthWithoutComa), ENT_QUOTES, 'UTF-8') . ',' . htmlspecialchars(json_encode($childParentConfigs), ENT_QUOTES, 'UTF-8') . ");'"; } $trString .= ""; } $trString .= ""; echo $trString; $childrens = $ledgers->where('parentId', $ledger->id)->whereNotIn('accountTypeId',['4','5'])->whereNotIn('id', $GLOBALS['skipedLedgerIds']); foreach ($childrens as $child) { print_ledger($ledgers, $child, $type, $ledger->id, $parentAccountTypeId); } } @endphp @foreach ($months as $month) @endforeach @foreach ($receiptTyepLedgers as $receiptTyepLedger) @php print_ledger($ledgers, $receiptTyepLedger, $type = 'receipt', '', $receiptTyepLedger->accountTypeId); @endphp @endforeach @foreach ($months as $month) @endforeach @foreach ($paymentTyepLedgers as $paymentTyepLedger) @php print_ledger($ledgers, $paymentTyepLedger, $type = 'payment', '', $paymentTyepLedger->accountTypeId); @endphp @endforeach @foreach ($months as $key => $month) @php $monthWithoutComa = str_replace(', ', '', $month); @endphp @endforeach
Transaction Heads Actual FY {{$fiscalYearName}} Projected Total
{{$previousFy->name}} {{$lastFymonthShort}} FY{{ $month }}
$ledger->name[$ledger->code]".number_format(abs($GLOBALS['actualBudgetValues'][$type][$ledger->id]))."
Opening Balance {{number_format($openingBalance['openingBalance'],2)}}
Cash {{number_format($openingBalance['cashOpeningBalance'],2)}}
Bank {{number_format($openingBalance['bankOpeningBalance'],2)}}
Receipt
Payment Payment
Closing Balance {{number_format($closingBalance['total'],2)}}
CASH IN HAND {{number_format($closingBalance['cash'],2)}}
CASH AT BANK {{number_format($closingBalance['bank'],2)}}
Difference
{!! Form::label('', '', ['class' => 'control-label col-sm-12']) !!}
{!! Form::submit('Save', ['id' => 'budgetSubmit', 'class' => 'btn btn-primary btn-md', 'style' => 'font-size:14px']) !!}
{!! Form::close() !!}