Commit aa2c0374 by Hannah Zahra

Final Update

parent a3cb80f0
<title>Maklumat Tuntutan</title>
@extends('ui::layouts.app')
@section('content')
<style>
body {
background-color: #f0f2f5;
}
.ui.container {
max-width: 70% !important;
margin-top: 2rem;
}
.ui.segment {
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
border-radius: 10px;
background-color: #fff;
padding: 2rem;
}
table.ui.definition.table td:first-child {
width: 40%;
font-weight: 600;
background-color: #f9fafb;
}
.totals-row td {
font-weight: 700;
background: #f7f7f8;
}
.small-muted { font-size: .9rem; color: #666; }
</style>
<div class="ui container">
<h2 class="ui header">Maklumat Tuntutan</h2>
<div class="ui segment">
<table class="ui definition table">
<tr>
<td>Tarikh Tuntutan</td>
<td>{{ \Carbon\Carbon::parse($claim->claim_date)->format('d/m/Y') }}</td>
</tr>
<tr>
<td>Jenis Kenderaan</td>
<td>{{ $claim->jenisKenderaan->keterangan ?? $claim->jenisKenderaan->name ?? '-' }}</td>
</tr>
<tr>
<td>Nama Projek</td>
<td>{{ $claim->project->p_project_description ?? 'Tanpa Projek' }}</td>
</tr>
<tr>
<td>Butiran Tuntutan</td>
<td>{{ $claim->description ?? '-' }}</td>
</tr>
<tr>
<td>Jarak Dari</td>
<td>{{ $claim->distance_from ?? '-' }}</td>
</tr>
<tr>
<td>Jarak Ke</td>
<td>{{ $claim->distance_to ?? '-' }}</td>
</tr>
<tr>
<td>Jumlah Perbatuan (KM)</td>
<td>{{ number_format($claim->total_mileage ?? 0, 2) }} km</td>
</tr>
{{-- Claimable mileage (deduct 40km rule) --}}
<tr>
<td>Jumlah Perbatuan Layak Dituntut</td>
<td>
@php
$totalMileage = floatval($claim->total_mileage ?? 0);
$claimable = $claim->claimable_mileage ?? max(0, $totalMileage - 40);
@endphp
{{ number_format($claimable, 2) }} km
</td>
</tr>
{{-- Show per-km rate and mileage multiplication --}}
<tr>
<td>Kiraan (Perbatuan × Kadar)</td>
<td>
@php
// Determine rate by vehicle
$jenisId = $claim->jenis_kenderaan_id ?? ($claim->jenisKenderaan->id ?? null);
if ($jenisId == 1) {
$rate = ($claimable <= 500) ? 0.55 : 0.50; // Car
} else {
$rate = 0.30; // Motorcycle
}
$mileageAmount = round($claimable * $rate, 2);
@endphp
<span class="small-muted">{{ number_format($claimable, 2) }} km × RM {{ number_format($rate, 2) }}</span>
&nbsp;=&nbsp;
<strong>RM {{ number_format($mileageAmount, 2) }}</strong>
</td>
</tr>
{{-- Toll amount --}}
<tr>
<td>Tol (RM)</td>
<td>RM {{ number_format(floatval($claim->toll_amount ?? 0), 2) }}</td>
</tr>
{{-- Others amount --}}
<tr>
<td>Lain-lain (RM)</td>
<td>RM {{ number_format(floatval($claim->others_amount ?? 0), 2) }}</td>
</tr>
{{-- Butiran Lain-lain (always shown) --}}
<tr>
<td>Butiran Lain-lain</td>
<td>{{ $claim->others_description ?: 'Tiada Nilai Lain-lain' }}</td>
</tr>
{{-- Subtotal: mileageAmount + toll + others --}}
<tr>
<td>Jumlah Tuntutan (Perjalanan + Tol + Lain-lain)</td>
<td>
@php
$toll = floatval($claim->toll_amount ?? 0);
$others = floatval($claim->others_amount ?? 0);
$subtotal = round($mileageAmount + $toll + $others, 2);
@endphp
RM {{ number_format($subtotal, 2) }}
</td>
</tr>
<tr class="totals-row">
<td>Jumlah Akhir (RM)</td>
<td>
@php
$final = $claim->total_claim_amount ?? round($subtotal - ($displayPenalty ?? 0), 2);
@endphp
<strong>RM {{ number_format(floatval($final), 2) }}</strong>
</td>
</tr>
</table>
</div>
<a href="{{ route('mileage::BOD.index') }}" class="ui button">
<i class="arrow left icon"></i> Kembali
</a>
</div>
@endsection
......@@ -97,7 +97,7 @@
<td>{{ $claim->claim_date }}</td>
<td>{{ $claim->description ?? '-' }}</td>
<td>{{ max(0, $claim->total_mileage - 40) }} km</td>
<td>RM {{ number_format($claim->calculated_amount, 2) }}</td>
<td>RM {{ number_format($claim->total_claim_amount, 2) }}</td>
<td>{{ $claim->status }}</td>
<td style = "white-space: nowrap; width: 1%;">
<a href="{{ route('mileage::HOD.show', $claim->id) }}" class="ui blue button tiny">
......
<title>Maklumat Tuntutan</title>
@extends('ui::layouts.app')
@section('content')
<style>
body {
background-color: #f0f2f5;
}
.ui.container {
max-width: 70% !important;
margin-top: 2rem;
}
.ui.segment {
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
border-radius: 10px;
background-color: #fff;
padding: 2rem;
}
table.ui.definition.table td:first-child {
width: 40%;
font-weight: 600;
background-color: #f9fafb;
}
.totals-row td {
font-weight: 700;
background: #f7f7f8;
}
.small-muted { font-size: .9rem; color: #666; }
</style>
<div class="ui container">
<h2 class="ui header">Maklumat Tuntutan</h2>
<div class="ui segment">
<table class="ui definition table">
<tr>
<td>Tarikh Tuntutan</td>
<td>{{ \Carbon\Carbon::parse($claim->claim_date)->format('d/m/Y') }}</td>
</tr>
<tr>
<td>Jenis Kenderaan</td>
<td>{{ $claim->jenisKenderaan->keterangan ?? $claim->jenisKenderaan->name ?? '-' }}</td>
</tr>
<tr>
<td>Nama Projek</td>
<td>{{ $claim->project->p_project_description ?? 'Tanpa Projek' }}</td>
</tr>
<tr>
<td>Butiran Tuntutan</td>
<td>{{ $claim->description ?? '-' }}</td>
</tr>
<tr>
<td>Jarak Dari</td>
<td>{{ $claim->distance_from ?? '-' }}</td>
</tr>
<tr>
<td>Jarak Ke</td>
<td>{{ $claim->distance_to ?? '-' }}</td>
</tr>
<tr>
<td>Jumlah Perbatuan (KM)</td>
<td>{{ number_format($claim->total_mileage ?? 0, 2) }} km</td>
</tr>
{{-- Claimable mileage (deduct 40km rule) --}}
<tr>
<td>Jumlah Perbatuan Layak Dituntut</td>
<td>
@php
$totalMileage = floatval($claim->total_mileage ?? 0);
$claimable = $claim->claimable_mileage ?? max(0, $totalMileage - 40);
@endphp
{{ number_format($claimable, 2) }} km
</td>
</tr>
{{-- Show per-km rate and mileage multiplication --}}
<tr>
<td>Kiraan (Perbatuan × Kadar)</td>
<td>
@php
// Determine rate by vehicle
$jenisId = $claim->jenis_kenderaan_id ?? ($claim->jenisKenderaan->id ?? null);
if ($jenisId == 1) {
$rate = ($claimable <= 500) ? 0.55 : 0.50; // Car
} else {
$rate = 0.30; // Motorcycle
}
$mileageAmount = round($claimable * $rate, 2);
@endphp
<span class="small-muted">{{ number_format($claimable, 2) }} km × RM {{ number_format($rate, 2) }}</span>
&nbsp;=&nbsp;
<strong>RM {{ number_format($mileageAmount, 2) }}</strong>
</td>
</tr>
{{-- Toll amount --}}
<tr>
<td>Tol (RM)</td>
<td>RM {{ number_format(floatval($claim->toll_amount ?? 0), 2) }}</td>
</tr>
{{-- Others amount --}}
<tr>
<td>Lain-lain (RM)</td>
<td>RM {{ number_format(floatval($claim->others_amount ?? 0), 2) }}</td>
</tr>
{{-- Butiran Lain-lain (always shown) --}}
<tr>
<td>Butiran Lain-lain</td>
<td>{{ $claim->others_description ?: 'Tiada Nilai Lain-lain' }}</td>
</tr>
{{-- Subtotal: mileageAmount + toll + others --}}
<tr>
<td>Jumlah Tuntutan (Perjalanan + Tol + Lain-lain)</td>
<td>
@php
$toll = floatval($claim->toll_amount ?? 0);
$others = floatval($claim->others_amount ?? 0);
$subtotal = round($mileageAmount + $toll + $others, 2);
@endphp
RM {{ number_format($subtotal, 2) }}
</td>
</tr>
<tr class="totals-row">
<td>Jumlah Akhir (RM)</td>
<td>
@php
$final = $claim->total_claim_amount ?? round($subtotal - ($displayPenalty ?? 0), 2);
@endphp
<strong>RM {{ number_format(floatval($final), 2) }}</strong>
</td>
</tr>
</table>
</div>
<a href="{{ route('mileage::HOD.index') }}" class="ui button">
<i class="arrow left icon"></i> Kembali
</a>
</div>
@endsection
......@@ -71,7 +71,7 @@
@foreach($claims as $c)
@php
$total += $c->total_claim;
$total += $c->total_claim_amount;
$totalMileage += $c->total_mileage ?? 0;
$totalToll += $c->toll_amount ?? 0;
$totalOthers += $c->others_amount ?? 0;
......
......@@ -226,6 +226,25 @@
<script>
$(document).ready(function() {
// Show / hide "Butiran Lain-lain" based on input
function toggleOthersDescription() {
const val = parseFloat($('#others_amount').val()) || 0;
if (val > 0) {
$('#others_description_wrapper').slideDown();
$('#others_description').attr('required', true);
} else {
$('#others_description_wrapper').slideUp();
$('#others_description').removeAttr('required').val('');
}
}
// Run when user types
$('#others_amount').on('input', toggleOthersDescription);
// Run on page load in case editing
toggleOthersDescription();
// === Auto Calculation for Ringkasan Pengiraan ===
function updateSummary() {
const totalMileage = parseFloat($('#total_mileage').val()) || 0;
......@@ -320,4 +339,4 @@ function updateSummary() {
});
</script>
@endpush
@endpush
\ No newline at end of file
......@@ -212,6 +212,24 @@
<script>
$(document).ready(function() {
// Show / hide "Butiran Lain-lain" based on input
function toggleOthersDescription() {
const val = parseFloat($('#others_amount').val()) || 0;
if (val > 0) {
$('#others_description_wrapper').slideDown();
$('#others_description').attr('required', true);
} else {
$('#others_description_wrapper').slideUp();
$('#others_description').removeAttr('required').val('');
}
}
// Run when user types
$('#others_amount').on('input', toggleOthersDescription);
// Run on page load in case editing
toggleOthersDescription();
// === Auto Calculation for Ringkasan Pengiraan ===
function updateSummary() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment