MIF_E31231430/resources/views/admin/penyewaan_edit.blade.php

221 lines
14 KiB
PHP

@extends('layouts.app')
@section('title', 'Edit Pengajuan Sewa')
@section('hide_navbar', true)
@section('content')
@php
$memberLabels = [
'tanpa_member' => 'Tanpa Member',
'bronze' => 'Bronze',
'silver' => 'Silver',
'gold' => 'Gold',
];
$statusLabels = [
'menunggu' => 'Menunggu',
'disetujui' => 'Disetujui',
'ditolak' => 'Ditolak',
'dikembalikan' => 'Dikembalikan',
];
$usesStock = in_array($penyewaan->status, ['menunggu', 'disetujui'], true);
$kameraEditableStock = $penyewaan->kamera ? $penyewaan->kamera->stok + ($usesStock ? $penyewaan->qty : 0) : null;
$lensaEditableStock = $penyewaan->lensa ? $penyewaan->lensa->stok + ($usesStock ? $penyewaan->qty : 0) : null;
$editableStockLimit = match ($penyewaan->jenis_sewa) {
'kamera' => $kameraEditableStock,
'lensa' => $lensaEditableStock,
default => min($kameraEditableStock ?? \App\Models\Kamera::DEFAULT_STOCK, $lensaEditableStock ?? \App\Models\Lensa::DEFAULT_STOCK),
};
@endphp
<div class="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 space-y-6">
<div class="flex items-center justify-between gap-3 flex-wrap">
<div>
<h1 class="text-2xl font-bold text-gray-900">Edit Pengajuan Sewa</h1>
<p class="mt-1 text-sm text-gray-600">Perbarui data pengajuan sewa sebelum diproses atau setelah pengecekan di lokasi selesai.</p>
</div>
<a href="{{ route('dashboard') }}" class="inline-flex items-center rounded-lg border border-gray-200 px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50">
Kembali ke Dashboard
</a>
</div>
@if($errors->any())
<div class="rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700">
{{ $errors->first() }}
</div>
@endif
<section class="surface-card rounded-[1.8rem] p-6">
<div class="grid gap-4 md:grid-cols-3 text-sm">
<div class="rounded-2xl border border-[#dceceb] bg-[#f7fbfa] p-4">
<p class="text-xs uppercase tracking-wide text-gray-400">Jenis Sewa</p>
<p class="mt-1 font-semibold text-gray-900">
{{ $penyewaan->jenis_sewa === 'paket' ? 'Paket Kamera + Lensa' : ($penyewaan->jenis_sewa === 'lensa' ? 'Lensa' : 'Kamera') }}
</p>
</div>
<div class="rounded-2xl border border-[#dceceb] bg-[#f7fbfa] p-4">
<p class="text-xs uppercase tracking-wide text-gray-400">Item</p>
<p class="mt-1 font-semibold text-gray-900">
{{ $penyewaan->kamera->nama ?? '-' }}{{ ($penyewaan->kamera && $penyewaan->lensa) ? ' + ' : '' }}{{ $penyewaan->lensa->nama ?? '' }}
</p>
</div>
<div class="rounded-2xl border border-[#dceceb] bg-[#f7fbfa] p-4">
<p class="text-xs uppercase tracking-wide text-gray-400">Total Saat Ini</p>
<p class="mt-1 font-semibold text-gray-900">Rp {{ number_format($penyewaan->total_harga, 0, ',', '.') }}</p>
</div>
</div>
</section>
<section class="surface-card rounded-[1.8rem] p-6">
<form method="POST" action="{{ route('dashboard.penyewaans.update', $penyewaan) }}" enctype="multipart/form-data" class="space-y-5">
@csrf
@method('PATCH')
<div class="grid gap-4 md:grid-cols-2">
<div>
<label class="block text-sm font-medium text-gray-700">Nama Penyewa</label>
<input name="nama_penyewa" value="{{ old('nama_penyewa', $penyewaan->nama_penyewa) }}" required class="mt-1 w-full rounded-lg border-gray-300 focus:border-[#edc039] focus:ring-[#edc039]">
</div>
<div>
<label class="block text-sm font-medium text-gray-700">Email</label>
<input type="email" name="email" value="{{ old('email', $penyewaan->email) }}" required class="mt-1 w-full rounded-lg border-gray-300 focus:border-[#edc039] focus:ring-[#edc039]">
</div>
</div>
<div class="grid gap-4 md:grid-cols-3">
<div>
<label class="block text-sm font-medium text-gray-700">Telepon</label>
<input name="telepon" value="{{ old('telepon', $penyewaan->telepon) }}" required class="mt-1 w-full rounded-lg border-gray-300 focus:border-[#edc039] focus:ring-[#edc039]">
</div>
<div>
<label class="block text-sm font-medium text-gray-700">No. WA</label>
<input name="no_wa" value="{{ old('no_wa', $penyewaan->no_wa) }}" required class="mt-1 w-full rounded-lg border-gray-300 focus:border-[#edc039] focus:ring-[#edc039]">
</div>
<div>
<label class="block text-sm font-medium text-gray-700">Instagram</label>
<input name="instagram" value="{{ old('instagram', $penyewaan->instagram) }}" class="mt-1 w-full rounded-lg border-gray-300 focus:border-[#edc039] focus:ring-[#edc039]">
</div>
</div>
<div class="grid gap-4 md:grid-cols-2">
<div>
<label class="block text-sm font-medium text-gray-700">Alamat KTP</label>
<textarea name="alamat_ktp" rows="3" required class="mt-1 w-full rounded-lg border-gray-300 focus:border-[#edc039] focus:ring-[#edc039]">{{ old('alamat_ktp', $penyewaan->alamat_ktp) }}</textarea>
</div>
<div>
<label class="block text-sm font-medium text-gray-700">Alamat Tinggal</label>
<textarea name="alamat_tinggal" rows="3" required class="mt-1 w-full rounded-lg border-gray-300 focus:border-[#edc039] focus:ring-[#edc039]">{{ old('alamat_tinggal', $penyewaan->alamat_tinggal) }}</textarea>
</div>
</div>
<div class="grid gap-4 md:grid-cols-2">
<div>
<label class="block text-sm font-medium text-gray-700">Jaminan</label>
<input name="jaminan" value="{{ old('jaminan', $penyewaan->jaminan) }}" required class="mt-1 w-full rounded-lg border-gray-300 focus:border-[#edc039] focus:ring-[#edc039]">
</div>
<div>
<label class="block text-sm font-medium text-gray-700">Member</label>
<select name="member_level" required class="mt-1 w-full rounded-lg border-gray-300 focus:border-[#edc039] focus:ring-[#edc039]">
@foreach($memberLabels as $value => $label)
<option value="{{ $value }}" {{ old('member_level', $penyewaan->member_level) === $value ? 'selected' : '' }}>{{ $label }}</option>
@endforeach
</select>
</div>
</div>
<div class="grid gap-4 md:grid-cols-3">
<div>
<label class="block text-sm font-medium text-gray-700">Jumlah</label>
<input type="number" name="qty" min="1" max="{{ max((int) $editableStockLimit, 1) }}" value="{{ old('qty', $penyewaan->qty) }}" required class="mt-1 w-full rounded-lg border-gray-300 focus:border-[#edc039] focus:ring-[#edc039]">
<p class="mt-1 text-xs text-gray-500">Maksimal jumlah yang bisa disimpan saat ini: {{ $editableStockLimit }} unit.</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-700">Tanggal Mulai</label>
<input type="date" name="tanggal_mulai" value="{{ old('tanggal_mulai', $penyewaan->tanggal_mulai) }}" required class="mt-1 w-full rounded-lg border-gray-300 focus:border-[#edc039] focus:ring-[#edc039]">
</div>
<div>
<label class="block text-sm font-medium text-gray-700">Tanggal Selesai</label>
<input type="date" name="tanggal_selesai" value="{{ old('tanggal_selesai', $penyewaan->tanggal_selesai) }}" required class="mt-1 w-full rounded-lg border-gray-300 focus:border-[#edc039] focus:ring-[#edc039]">
</div>
</div>
<div class="grid gap-4 md:grid-cols-2">
<div>
<label class="block text-sm font-medium text-gray-700">Jam Sewa</label>
<input type="time" name="jam_sewa" value="{{ old('jam_sewa', substr($penyewaan->jam_sewa, 0, 5)) }}" required class="mt-1 w-full rounded-lg border-gray-300 focus:border-[#edc039] focus:ring-[#edc039]">
</div>
<div>
<label class="block text-sm font-medium text-gray-700">Jam Kembali</label>
<input type="time" name="jam_kembali" value="{{ old('jam_kembali', substr($penyewaan->jam_kembali, 0, 5)) }}" required class="mt-1 w-full rounded-lg border-gray-300 focus:border-[#edc039] focus:ring-[#edc039]">
</div>
</div>
<div class="grid gap-4 md:grid-cols-3">
<div>
<label class="block text-sm font-medium text-gray-700">Metode Pembayaran</label>
<select name="metode_pembayaran" required class="mt-1 w-full rounded-lg border-gray-300 focus:border-[#edc039] focus:ring-[#edc039]">
<option value="qris" {{ old('metode_pembayaran', $penyewaan->metode_pembayaran) === 'qris' ? 'selected' : '' }}>QRIS</option>
<option value="transfer_bca" {{ old('metode_pembayaran', $penyewaan->metode_pembayaran) === 'transfer_bca' ? 'selected' : '' }}>Transfer BCA</option>
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700">Status</label>
<select name="status" required class="mt-1 w-full rounded-lg border-gray-300 focus:border-[#edc039] focus:ring-[#edc039]">
@foreach($statusLabels as $value => $label)
<option value="{{ $value }}" {{ old('status', $penyewaan->status) === $value ? 'selected' : '' }}>{{ $label }}</option>
@endforeach
</select>
</div>
<div class="rounded-xl border border-[#dceceb] bg-[#f7fbfa] px-4 py-3 text-sm text-gray-600">
<p class="text-xs uppercase tracking-wide text-gray-400">File Saat Ini</p>
@if($penyewaan->foto_jaminan_path)
<a href="{{ \Illuminate\Support\Facades\Storage::url($penyewaan->foto_jaminan_path) }}" target="_blank" class="mt-1 block text-[#edc039] hover:underline">Lihat Foto Jaminan</a>
@endif
@if($penyewaan->foto_diri_path)
<a href="{{ \Illuminate\Support\Facades\Storage::url($penyewaan->foto_diri_path) }}" target="_blank" class="mt-1 block text-[#edc039] hover:underline">Lihat Foto Diri</a>
@endif
@if($penyewaan->bukti_pembayaran_path)
<a href="{{ \Illuminate\Support\Facades\Storage::url($penyewaan->bukti_pembayaran_path) }}" target="_blank" class="mt-1 block text-[#edc039] hover:underline">Lihat Bukti Pembayaran</a>
@endif
</div>
</div>
<div class="grid gap-4 md:grid-cols-3">
<div>
<label class="block text-sm font-medium text-gray-700">Ganti Foto Jaminan</label>
<input type="file" name="foto_jaminan" accept=".jpg,.jpeg,.png" class="mt-1 w-full rounded-lg border-gray-300 focus:border-[#edc039] focus:ring-[#edc039] file:mr-3 file:rounded-md file:border-0 file:bg-[#e6f5ee] file:px-3 file:py-2 file:text-[#edc039]">
<p class="mt-1 text-xs text-gray-500">Kosongkan jika tidak ingin mengganti file.</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-700">Ganti Foto Diri</label>
<input type="file" name="foto_diri" accept=".jpg,.jpeg,.png" class="mt-1 w-full rounded-lg border-gray-300 focus:border-[#edc039] focus:ring-[#edc039] file:mr-3 file:rounded-md file:border-0 file:bg-[#e6f5ee] file:px-3 file:py-2 file:text-[#edc039]">
<p class="mt-1 text-xs text-gray-500">Kosongkan jika tidak ingin mengganti file.</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-700">Ganti Bukti Pembayaran</label>
<input type="file" name="bukti_pembayaran" accept=".jpg,.jpeg,.png,.pdf" class="mt-1 w-full rounded-lg border-gray-300 focus:border-[#edc039] focus:ring-[#edc039] file:mr-3 file:rounded-md file:border-0 file:bg-[#e6f5ee] file:px-3 file:py-2 file:text-[#edc039]">
<p class="mt-1 text-xs text-gray-500">Kosongkan jika tidak ingin mengganti file.</p>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700">Catatan</label>
<textarea name="catatan" rows="4" class="mt-1 w-full rounded-lg border-gray-300 focus:border-[#edc039] focus:ring-[#edc039]">{{ old('catatan', $penyewaan->catatan) }}</textarea>
</div>
<div>
<label class="block text-sm font-medium text-gray-700">Catatan Admin untuk User</label>
<textarea name="admin_catatan" rows="5" class="mt-1 w-full rounded-lg border-gray-300 focus:border-[#edc039] focus:ring-[#edc039]" placeholder="Tulis catatan untuk user, misalnya foto jaminan tidak sesuai, foto diri kurang jelas, atau pembayaran belum masuk.">{{ old('admin_catatan', $penyewaan->admin_catatan) }}</textarea>
<p class="mt-1 text-xs text-gray-500">Catatan ini akan muncul sebagai notifikasi di akun user setelah login.</p>
</div>
<div class="flex flex-col gap-3 sm:flex-row sm:justify-end">
<a href="{{ route('dashboard') }}" class="inline-flex items-center justify-center rounded-lg border border-gray-200 px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50">
Batal
</a>
<button type="submit" class="btn-dark px-5 py-2.5 text-sm font-semibold">
Simpan Perubahan
</button>
</div>
</form>
</section>
</div>
@endsection