@extends('layouts.app')

@section('title', 'Edit Harga Harian')

@section('content')

<div class="container-fluid">

    <div class="card card-modern border-0 shadow-sm">

        <div class="card-header bg-white py-3">

            <div class="d-flex justify-content-between align-items-center">

                <div>

                    <h4 class="mb-1">
                        ✏️ Edit Harga Harian
                    </h4>

                    <small class="text-muted">
                        Tanggal:
                        {{ \Carbon\Carbon::parse($date)->translatedFormat('d F Y') }}
                    </small>

                </div>

                <a href="/prices" class="btn btn-light">
                    <i class="bi bi-arrow-left"></i>
                    Kembali
                </a>

            </div>

        </div>

        <div class="card-body">

            <form action="/prices/{{ $date }}/update-daily" method="POST">

                @csrf
                @method('PUT')

                <div class="row">

                    @foreach($prices as $price)

                    <div class="col-md-6 mb-3">

                        <div class="card h-100 border">

                            <div class="card-body">

                                <input
                                    type="hidden"
                                    name="ids[]"
                                    value="{{ $price->id }}">

                                <div class="mb-2">

                                    <strong>
                                        {{ $price->product->name }}
                                    </strong>

                                </div>

                                <small class="text-muted d-block mb-2">

                                    Harga sebelumnya:

                                    Rp {{ number_format($price->price, 0, ',', '.') }}

                                </small>

                                <div class="input-group">

                                    <span class="input-group-text">
                                        Rp
                                    </span>

                                    <input
                                        type="number"
                                        class="form-control"
                                        name="prices[]"
                                        value="{{ $price->price }}"
                                        min="0"
                                        required>

                                </div>

                            </div>

                        </div>

                    </div>

                    @endforeach

                </div>

                <div class="text-end mt-4">

                    <button class="btn btn-warning px-4">

                        <i class="bi bi-save"></i>

                        Simpan Semua

                    </button>

                </div>

            </form>

        </div>

    </div>

</div>

@endsection