88 lines
4.1 KiB
PHP
88 lines
4.1 KiB
PHP
@extends('layouts.master')
|
|
|
|
@section('title', 'Unit Conversion Matrix')
|
|
|
|
@section('content')
|
|
<div class="card shadow-sm">
|
|
<div class="card-header d-flex justify-content-between align-items-center">
|
|
<h5 class="mb-0 font-weight-bold">
|
|
Unit Conversion Matrix ({{ $selectedCategory }})
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row mb-3">
|
|
<div class="col-md-3">
|
|
<form method="GET" action="{{ route($route.'.index') }}">
|
|
<div class="form-group">
|
|
<label for="category">Pilih Kategori:</label>
|
|
<select id="category" name="category" class="form-control" onchange="this.form.submit()">
|
|
@foreach ($categories as $category)
|
|
<option value="{{ $category }}"
|
|
{{ $category == $selectedCategory ? 'selected' : '' }}>
|
|
{{ $category }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<form method="POST" action="{{ route($route.'.store') }}">
|
|
@csrf
|
|
<input type="hidden" name="category" value="{{ $selectedCategory }}">
|
|
<div class="table-responsive" style="overflow-x: auto;">
|
|
<table class="table table-bordered table-detail">
|
|
<thead class="table-info text-white">
|
|
<tr>
|
|
<th width="20%">
|
|
<span class="text-left">From</span>
|
|
<span class="float-right">To</span>
|
|
</th>
|
|
@foreach ($units as $unit)
|
|
<th class="text-center">{{ $unit->code }}</th>
|
|
@endforeach
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach ($units as $fromUnit)
|
|
<tr>
|
|
<td class="text-left" colspan="1">{{ $fromUnit->name }} ({{ $fromUnit->code }})
|
|
</td>
|
|
@foreach ($units as $toUnit)
|
|
@php
|
|
$convertValue = $conversions[$fromUnit->code][$toUnit->code]->value ?? '';
|
|
@endphp
|
|
<td>
|
|
@if ($fromUnit->code == $toUnit->code)
|
|
<input type="text" class="form-control text-right" value="1"
|
|
readonly style="background-color: #fff; border-color: #bec4ca;">
|
|
@else
|
|
<input type="text" class="form-control text-right"
|
|
name="conversions[{{ $fromUnit->code }}][{{ $toUnit->code }}]"
|
|
value="{{ getFormattedValue($convertValue) ?? '' }}"
|
|
oninput="numberFormat(this)">
|
|
@endif
|
|
</td>
|
|
@endforeach
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">Simpan</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
@endsection
|
|
|
|
@section('js')
|
|
<script>
|
|
$(document).ready(function() {
|
|
$('#category').select2({
|
|
placeholder: 'Pilih Kategori',
|
|
});
|
|
});
|
|
</script>
|
|
@endsection
|