@extends('layouts/acc_layout') @if ($operation == 'view') @section('title', '| View Budget') @else @section('title', '| Edit Budget') @endif @section('content')
@if ($operation == 'view')
@endif @php if($operation == 'edit'){ $title = "Edit Budget"; } else{ $title = "Budget Details"; } @endphp

{{ $title }}

{{ 'Project' . $budget->project }}
{{ 'Project Type' . $budget->projectType }}
{{ 'Branch' . $budget->branch }}
{{ 'Fiscal Year' . $budget->fiscalYear }}
{!! Form::open(['role' => 'form', 'class' => 'form-horizontal form-groups', 'id' => 'budgetForm']) !!} {!! Form::hidden('id', encrypt($budget->id)) !!} @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['budgetDetails'] = $budgetDetails; // 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] = 'debit'; $GLOBALS['natureRules']['receipt'][9] = 'credit'; $GLOBALS['natureRules']['receipt'][12] = 'credit'; $GLOBALS['natureRules']['payment'][1] = 'debit'; $GLOBALS['natureRules']['payment'][6] = 'credit'; $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 = []; $totalValue = 0; 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 = $GLOBALS['operation'] == 'view' ? 'readonly' : ''; if ($GLOBALS['operation'] == 'edit') { $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') . ");'"; } } $value = (float) @$GLOBALS['budgetDetails'][$nature][$month][$ledger->id]; $totalValue += $value; $trString .= ""; } $trString .= ""; echo $trString; $childrens = $ledgers->where('parentId', $ledger->id); foreach ($childrens as $child) { print_ledger($ledgers, $child, $type, $ledger->id, $parentAccountTypeId); } } @endphp @foreach ($receiptTyepLedgers as $receiptTyepLedger) @php print_ledger($ledgers, $receiptTyepLedger, $type = 'receipt', '', $receiptTyepLedger->accountTypeId); @endphp @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 Monthly Budget Total
{{ $month }}
$ledger->name[$ledger->code]$totalValue
Receipt
Payment
Difference
@if ($operation == 'edit')
{!! Form::label('', '', ['class' => 'control-label col-sm-12']) !!}
{!! Form::button('Update', ['id' => 'budgetSubmit', 'class' => 'btn btn-primary btn-md', 'style' => 'font-size:14px']) !!}
{!! Form::close() !!} @endif
@if ($GLOBALS['operation'] == 'edit') @endif @endsection