<div class="col-lg-12">
    <div class="card m-b-30">
        <div class="card-body">

            <h4 class="mt-0 header-title">Kalkulator Economic Order Quantity (EOQ)</h4>
            <p class="text-muted m-b-30 font-14">Masukkan nilai untuk menghitung EOQ secara langsung.</p>

            <div class="alert alert-success alert-dismissible fade show mb-0" role="alert" id="alert-simpan-berhasil" style="display:none;">
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
                <strong>Berhasil !</strong> Perhitungan Selesai
            </div>

            <form class="" action="<?= site_url('lap/eoq/calculator') ?>" id="frm_eoq_calculator" method="POST">
                <div class="form-group">
                    <label for="demand">Permintaan Barang (D) per Tahun</label>
                    <input type="number" required name="demand" class="form-control" placeholder="Masukkan jumlah permintaan per tahun" value="<?= isset($result['demand']) ? $result['demand'] : '' ?>">
                </div>
                <div class="form-group">
                    <label for="biaya_pesan">Biaya Pesan (S) per Pesanan</label>
                    <input type="number" required name="biaya_pesan" class="form-control" placeholder="Masukkan biaya pesan per pesanan" value="<?= isset($result['biaya_pesan']) ? $result['biaya_pesan'] : '' ?>">
                </div>
                <div class="form-group">
                    <label for="biaya_simpan">Biaya Simpan (H) per Unit per Tahun</label>
                    <input type="number" required name="biaya_simpan" class="form-control" placeholder="Masukkan biaya simpan per unit per tahun" value="<?= isset($result['biaya_simpan']) ? $result['biaya_simpan'] : '' ?>">
                </div>

                <div class="form-group text-right">
                    <button type="submit" class="btn btn-primary waves-effect waves-light">
                        <span id="txt-proses">Hitung EOQ</span>
                    </button>
                    <button type="reset" class="btn btn-secondary waves-effect m-l-5">
                        Reset
                    </button>
                </div>
            </form>

            <?php if(isset($result)): ?>
            <div class="mt-4">
                <h5>Hasil Perhitungan EOQ</h5>
                <table class="table table-bordered">
                    <tr>
                        <th>Parameter</th>
                        <th>Nilai</th>
                    </tr>
                    <tr>
                        <td>Permintaan Barang (D)</td>
                        <td><?= $result['demand'] ?> unit/tahun</td>
                    </tr>
                    <tr>
                        <td>Biaya Pesan (S)</td>
                        <td>Rp <?= number_format($result['biaya_pesan']) ?> per pesanan</td>
                    </tr>
                    <tr>
                        <td>Biaya Simpan (H)</td>
                        <td>Rp <?= number_format($result['biaya_simpan']) ?> per unit/tahun</td>
                    </tr>
                    <tr>
                        <td><strong>Economic Order Quantity (EOQ)</strong></td>
                        <td><strong><?= $result['eoq'] ?> unit</strong></td>
                    </tr>
                </table>
                <p class="text-muted">Rumus: EOQ = √(2 × D × S / H)</p>
                <p class="text-muted">Proses: EOQ = √(2 × <?= $result['demand'] ?> × <?= $result['biaya_pesan'] ?> / <?= $result['biaya_simpan'] ?>) = √(<?= 2 * $result['demand'] * $result['biaya_pesan'] / $result['biaya_simpan'] ?>) = <?= $result['eoq'] ?> unit</p>
            </div>
            <?php endif; ?>

        </div>
    </div>
</div> <!-- end col -->
