@extends('layouts.main') @push('styles') @endpush @section('content')

{{ __('finance.budgets') }}

@include('budgets::budgets.menu') @include('flash::message')
{{-- --}} @php $period_months = getMonthsList(); $second_col = "Account"; $end_col = "Budget Total"; switch ($budget->period) { case 'months': $period = "Months"; $budget_start_date = strtotime($budget->period_start);//y-m-d $budget_end_date = date("Y-m-d", strtotime("+". $budget->period_count - 1 ." month", $budget_start_date)); $period_range = date("M-Y", $budget_start_date) . " to " . date("M-Y", strtotime($budget_end_date)); $interval = DateInterval::createFromDateString('1 month'); $period = new DatePeriod(new DateTime($budget->period_start), $interval, new DateTime(date("Y-m-d", strtotime("+". $budget->period_count ." month", $budget_start_date)))); foreach ($period as $dt) $months_data[] = $dt->format("M-Y"); $column_1 = [$second_col]; $columns = array_merge($column_1, $months_data); array_push($columns, $end_col); $collength = count($columns); break; case 'quarters': $period = "Quarters"; $other_columns =[];$quarter_start_dates =['-01-01', '-04-01', '-07-01', '-10-01']; //m-d $budget_start_date = $budget->period_start;//y-m-d $budget_end_date = date("Y-m-d", strtotime("+". ($budget->period_count-1) * 3 ." month", strtotime('-1 day', strtotime($budget_start_date)))); $quarters_data = get_quarters($budget_start_date, $budget_end_date); for($y =0; $y < count($quarters_data); $y++) $other_columns[] = $quarters_data[$y]->period; $period_range = $other_columns[0] . " to " . $other_columns[count($other_columns)-1]; $column_1 = [$second_col]; $columns = array_merge($column_1, $other_columns); array_push($columns, $end_col); $collength = count($columns); break; case 'years': $period = "Years"; $year=date('Y', strtotime($budget->period_start)); $sec = substr($year, -2); $years_data = [$year.'/'. ++$sec]; for ($i = 1; $i <$budget->period_count; $i++) array_push($years_data, $year + $i .'/'. ++$sec); $period_range = $years_data[0] . " to " . $years_data[count($years_data)-1]; $column_1 = [$second_col]; $columns = array_merge($column_1, $years_data); array_push($columns, $end_col); $collength = count($columns); break; default: break; } @endphp

{{ __('budgets.budget_name') . ": " . $budget->name }}

{{ "Period(" .ucfirst($budget->period) . "): " . $period_range }}

@php for ($i = 0; $i < count($columns); $i++) echo ''; $totals_budgets = $sub_accounts = $totals_budgets_colums = $income_column_totals = $expense_column_totals = $cost_of_goods_column_totals = []; $sub_account_total= 0; @endphp @foreach ($options as $option) {{-- @foreach ($option['sub_accounts'] as $keyid => $sub_account) --}} {{-- --}} {{-- @foreach ($sub_account as $sub_account_entry) @php for ($i =0; $i < $collength; $i++) { $sum=0; for ($j=0; $j < count($sub_account_entry['account_entries']); $j++) $sum +=(int)$sub_account_entry['account_entries'][$j]; if ($i==0) echo '' ; else if ($i==$collength - 1) echo "" ; else echo "" ; } @endphp @endforeach --}} {{-- Sub Account Section column Totals --}} {{-- @php for ($i =0; $i < $collength; $i++) { $sub_account_total_section = $sub_account_columnTotal_section=0; $keys = array_keys($option['sub_accounts']); if ($i==0) echo '' ; else if ($i==$collength - 1){ //Sub account totals for($k=0; $k < $budget->period_count; $k++){ $columnTotal = 0; for ($m = 0; $m < count($option['sub_accounts'][$keyid]); $m++) { $columnTotal +=(int)($option['sub_accounts'][$keyid][$m]['account_entries'][$k]); } $sub_account_total_section += $columnTotal; } echo "" ; } else { for ($b=0; $b < count($option['sub_accounts'][$keyid]); $b++) { $sub_account_columnTotal_section +=(int)($option['sub_accounts'][$keyid][$b]['account_entries'][$i - 1]); } echo "" ; } } @endphp --}} {{-- @endforeach @if (!empty($option['sub_accounts'])) @endif --}} @foreach ($option['entries'] as $entry ) @php for ($i =0; $i < $collength; $i++) { $sum=0; for ($j=0; $j < count($entry['account_entries']); $j++) $sum +=(int)$entry['account_entries'][$j]; $total=ugandan_shillings($sum); if ($i==0) echo '' ; else if ($i==$collength - 1) echo "" ; else echo "" ; } @endphp @endforeach {{-- Other income Section column Totals --}} {{-- @if (!empty($option['sub_accounts'])) @php for ($i =0; $i < $collength; $i++) { $budget_total_section=0; $columnTotal_section=0; if ($i==0) echo '' ; else if ($i==$collength - 1){ //Budget totals for for($k=0; $k < $budget->period_count; $k++){ $columnTotal = 0; for ($m = 0; $m < count($option['entries']); $m++) { $columnTotal +=(int)($option['entries'][$m]['account_entries'][$k]); } $budget_total_section +=$columnTotal; } echo "" ; } else { for ($b=0; $b < count($option['entries']); $b++) { $columnTotal_section +=(int)($option['entries'][$b]['account_entries'][$i - 1]); } echo "" ; } } @endphp @endif --}} {{-- Operating Budget Section Totals --}} @php for ($i =0; $i < $collength; $i++) { $budget_total_section=0; $columnTotal_section=0; if ($i==0) echo '' ; else if ($i==$collength - 1){ //Budget totals for for($k=0; $k < $budget->period_count; $k++){ $columnTotal = 0; for ($m = 0; $m < count($option['entries']); $m++) { $columnTotal +=(int)($option['entries'][$m]['account_entries'][$k]); } $budget_total_section +=$columnTotal; } array_push($totals_budgets, $budget_total_section); echo "" ; } else { for ($b=0; $b < count($option['entries']); $b++) { $columnTotal_section +=(int)($option['entries'][$b]['account_entries'][$i - 1]); } //Push to column total arrays if($entry['type'] == 'Income') array_push($income_column_totals, $columnTotal_section); else if($entry['type'] == 'Expense') array_push($expense_column_totals, $columnTotal_section); else array_push($cost_of_goods_column_totals, $columnTotal_section); echo "" ; } } @endphp @endforeach {{-- Budget Projections --}} @php for ($i =0; $i < $collength; $i++) { if ($i==0) echo '' ; else if ($i==$collength - 1){ //Budget Totals $overall_projection = $totals_budgets[0] - $totals_budgets[1] - $totals_budgets[2]; echo "" ; } else { $columnTotal_projection=$income_column_totals[$i-1] - $expense_column_totals[$i-1] - $cost_of_goods_column_totals[$i-1]; echo "" ; } } @endphp @php for ($i = 0; $i < count($columns); $i++) echo ''; @endphp
Budget Name: {{ ucfirst($budget->name) .' - Period('. ucfirst($budget->period) .'): '.$period_range }}
' .$columns[$i].'
{{ $option['section_header'] }}
{{ get_name($keyid, 'id', 'name','chart_of_accounts') }} -
' .$sub_account_entry['name']. '" . ugandan_shillings($sum) . "" .ugandan_shillings($sub_account_entry['account_entries'][$i - 1]). "
'. get_name($keyid, 'id', 'name','chart_of_accounts') . ' Total" .ugandan_shillings($sub_account_total_section) . "" .ugandan_shillings($sub_account_columnTotal_section). "
{{ 'Other '. $option['section_header'] }} -
' .$entry['name']. '" .$total. "" .ugandan_shillings($entry['account_entries'][$i - 1]). "
Other '.$option['section_header']. ' total" .ugandan_shillings($budget_total_section) . "" .ugandan_shillings($columnTotal_section). "
'.$option['total_header']. '" .ugandan_shillings($budget_total_section) . "" .ugandan_shillings($columnTotal_section). "
Projected Net Income" . ugandan_shillings($overall_projection) . "".ugandan_shillings($columnTotal_projection). "
' .$columns[$i].'
@endsection @push('scripts') @endpush