sigd/resources/views/modules/form/table.blade.php

78 lines
4.0 KiB
PHP

<form action="{{ route('modules.form.save', ['sector' => $form->sector, 'code' => $form->code]) }}" method="POST">
@csrf
<input type="hidden" name="inventoryYear" value="{{ $inventoryYear }}">
<input type="hidden" name="instansi" value="{{ $instansi }}">
<div class="table-responsive mt-3" style="overflow-x: auto;">
<table class="table table-bordered table-detail">
<thead class="table-info text-white">
<tr>
<th style="width: 50px;">No.</th>
<th style="width: 100px;">Tahun</th>
@foreach ($formDetails as $detail)
@php
$unitCode = $detail->unit_code;
$unitCategory = $unitsMap[$unitCode]->category ?? null;
@endphp
<th style="min-width: 150px;">
{{ $detail->activity ? $detail->activity->name : 'N/A' }}
<br /><br />
@if ($unitCategory)
<select name="unit_code[{{ $detail->activity_code }}]" class="form-control unit-code"
data-activity-code="{{ $detail->activity_code }}"
data-current-unit="{{ $unitCode }}">
@foreach ($unitsByCategory[$unitCategory] as $unit)
<option value="{{ $unit->code }}"
{{ $unit->code == $unitCode ? 'selected' : '' }}>
{{ $unit->code }}
</option>
@endforeach
</select>
@else
{{ $unitCode }}
@endif
</th>
@endforeach
</tr>
</thead>
<tbody>
@php
$counter = 1;
$years = activityYearRange($inventoryYear);
@endphp
@foreach ($years as $year)
<tr>
<td>{{ $counter }}</td>
<td>{{ $year }}</td>
@foreach ($formDetails as $detail)
@php
$activity_value = isset($activityFormDetails[$year])
? $activityFormDetails[$year]
->where('activity_code', $detail->activity_code)
->where('activity_unit_code', $detail->unit_code)
->first()->activity_value ?? ''
: '';
@endphp
<td>
<input type="text"
name="data[{{ $year }}][{{ $detail->activity_code }}-{{ $detail->unit_code }}]"
value="{{ getFormattedValue($activity_value) ?? '' }}"
class="form-control text-right" oninput="numberFormat(this)"
style="min-width: 80px;" {{ $isLocked || $instansi === 'all' || $limitInternal ? 'readonly' : '' }}>
{{-- <input type="hidden"
name="data[{{ $year }}][{{ $detail->activity_code }}-{{ $detail->unit_code }}]"
value="{{ $activity_value }}"> --}}
</td>
@endforeach
</tr>
@php
$counter++;
@endphp
@endforeach
</tbody>
</table>
</div>
<br />
<button type="submit" class="btn btn-primary" {{ $isLocked || $instansi === 'all' || $limitInternal ? 'disabled' : '' }}>Simpan</button>
</form>