@php
$indexedReports = [];
foreach ($ict_reports as $report) {
$termKey = $report['term'] ?? '';
$bidKey = $report['beneficiary_id'] ?? '';
if ($termKey && $bidKey) {
$indexedReports[$termKey][$bidKey] = $report;
}
}
@endphp
| {!! $project_term_report->label($field) !!} |
@foreach ($beneficiaries as $sno => $beneficiary)
@php
$bid = $beneficiary->id;
$report01Value = $indexedReports['REPORT01'][$bid][$field] ?? 0;
$report02Value = $indexedReports['REPORT02'][$bid][$field] ?? 0;
$currentValue = $indexedReports[$term][$bid][$field] ?? 0;
$rowTotal += $currentValue;
$previousTermsTotal = $report01Value + $report02Value;
@endphp
{!! Form::number("reports[$bid][$field]", old("reports.$bid.$field", $currentValue), [
'tabindex' => $sno,
'onchange' => 'updateRowTotalNew(this)',
'data-field-name' => $field,
'data-bid' => $bid,
'data-term' => $term,
'data-report01' => $report01Value,
'data-report02' => $report02Value,
'class' => 'report-input',
]) !!}
@if ($term === 'REPORT03')
@php
$reasonFields = [
'families_visited' => [
'field' => 'families_visited_reason',
'id' => "families_visited_reason_$bid",
'placeholder' => 'Reason for less than 10',
],
'decisions_made' => [
'field' => 'decisions_made_reason',
'id' => "decisions_made_reason_$bid",
'placeholder' => 'Reason for less than 1',
],
'no_of_children_attended_cbc_ten_days' => [
'field' => 'no_of_children_attended_cbc_ten_days_reason',
'id' => "no_of_children_attended_cbc_ten_days_reason_$bid",
'placeholder' => 'Reason for less than 5',
],
'no_of_decision_made_cbc_ten_days' => [
'field' => 'decisions_reason',
'id' => "decisions_reason_$bid",
'placeholder' => 'Reason for less than 5',
],
'no_of_new_life_memebers' => [
'field' => 'new_life_members_reason',
'id' => "new_life_members_reason_$bid",
'placeholder' => 'Reason for less than 5',
],
'new_life_groups_formed_in_this_period' => [
'field' => 'worship_groups_reason',
'id' => "worship_groups_reason_$bid",
'placeholder' => 'Reason for less than 1',
],
'no_of_people_attending_new_life_groups' => [
'field' => 'people_attending_worship_groups_reason',
'id' => "people_attending_worship_groups_reason_$bid",
'placeholder' => 'Reason for less than 1',
],
];
@endphp
@if (array_key_exists($field, $reasonFields))
@php $reasonField = $reasonFields[$field]['field']; @endphp
{!! Form::text("reports[$bid][$reasonField]", old("reports.$bid.$reasonField", $indexedReports[$term][$bid][$reasonField] ?? ''), [
'class' => 'form-control-sm mt-1',
'id' => $reasonFields[$field]['id'],
'placeholder' => $reasonFields[$field]['placeholder'],
'style' => 'display:none;',
]) !!}
@endif
@endif
{{-- Validation Errors --}}
@if (isset($cErrors[$bid]) && $cErrors[$bid]->has($field))
{{ $cErrors[$bid]->first($field) }}
@endif
@if (isset($errors) && $errors->has("reports.$bid.{$field}_reason"))
{{ $errors->first("reports.$bid.{$field}_reason") }}
@endif
|
@endforeach
{!! Form::number(null, $rowTotal, [ 'disabled' => true, 'data-field-name' => $field, 'class' => 'report-input-total']) !!}
|
@endforeach