93 lines
4.0 KiB
PHP
93 lines
4.0 KiB
PHP
@extends('layouts.dashboard')
|
|
|
|
@section('content')
|
|
<div class="container mx-auto px-4 py-8">
|
|
<div class="max-w-2xl mx-auto bg-white rounded-lg shadow-md p-6">
|
|
<h2 class="text-2xl font-bold mb-6">Edit Pesanan</h2>
|
|
|
|
@if(session('error'))
|
|
<div class="bg-red-100 border-l-4 border-red-500 text-red-700 p-4 mb-6 rounded">
|
|
{{ session('error') }}
|
|
</div>
|
|
@endif
|
|
|
|
<div class="mb-6">
|
|
<h3 class="text-lg font-semibold mb-2">Detail Barang:</h3>
|
|
<div class="bg-gray-50 p-4 rounded">
|
|
<div class="flex items-center space-x-4">
|
|
<div class="w-20 h-20 rounded-lg overflow-hidden flex-shrink-0">
|
|
@if($pesanan->barang->gambar)
|
|
<img src="{{ Storage::url($pesanan->barang->gambar) }}"
|
|
alt="{{ $pesanan->barang->nama }}"
|
|
class="w-full h-full object-cover">
|
|
@else
|
|
<div class="w-full h-full bg-gray-200 flex items-center justify-center">
|
|
<i class="fas fa-box text-gray-400 text-2xl"></i>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
<div>
|
|
<p class="font-medium text-lg mb-1">{{ $pesanan->barang->nama }}</p>
|
|
<p class="text-gray-600 mb-2">Rp {{ number_format($pesanan->barang->harga, 0, ',', '.') }} / unit</p>
|
|
<p class="text-sm text-gray-500">Stok Tersedia: {{ $pesanan->barang->stok + $pesanan->jumlah }}</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<form action="{{ route('pesanan.update', $pesanan) }}" method="POST" class="space-y-4">
|
|
@csrf
|
|
@method('PUT')
|
|
|
|
<div>
|
|
<label for="jumlah" class="block text-sm font-medium text-gray-700 mb-1">Jumlah</label>
|
|
<input type="number" name="jumlah" id="jumlah"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-[#2C7A7B]"
|
|
min="1" max="{{ $pesanan->barang->stok + $pesanan->jumlah }}"
|
|
value="{{ old('jumlah', $pesanan->jumlah) }}" required>
|
|
@error('jumlah')
|
|
<p class="text-red-500 text-sm mt-1">{{ $message }}</p>
|
|
@enderror
|
|
</div>
|
|
|
|
<div class="border-t pt-4 mt-6">
|
|
<div class="flex justify-between items-center">
|
|
<p class="text-gray-600">Total Pembayaran:</p>
|
|
<p class="text-xl font-bold text-[#2C7A7B]" id="total-harga">
|
|
Rp {{ number_format($pesanan->total_harga, 0, ',', '.') }}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex justify-between items-center mt-6">
|
|
<a href="{{ route('pesanan.index') }}"
|
|
class="px-4 py-2 bg-gray-500 text-white rounded-md hover:bg-gray-600 transition-colors duration-200">
|
|
Kembali
|
|
</a>
|
|
<button type="submit"
|
|
class="px-4 py-2 bg-[#2C7A7B] text-white rounded-md hover:bg-[#1C6B6B] transition-colors duration-200">
|
|
Simpan Perubahan
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
@push('scripts')
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const hargaBarang = "{{ $pesanan->barang->harga }}";
|
|
const inputJumlah = document.getElementById('jumlah');
|
|
const totalHarga = document.getElementById('total-harga');
|
|
|
|
function updateTotal() {
|
|
const total = parseInt(hargaBarang) * parseInt(inputJumlah.value);
|
|
totalHarga.textContent = 'Rp ' + total.toLocaleString('id-ID');
|
|
}
|
|
|
|
inputJumlah.addEventListener('change', updateTotal);
|
|
inputJumlah.addEventListener('input', updateTotal);
|
|
});
|
|
</script>
|
|
@endpush
|
|
@endsection |