<?php 

function getBadgeStock($stock, $showNumber = true) {
    $stockValue = intval($stock);
    $displayText = $showNumber ? $stock : '';
    
    if ($stockValue >= 25) {
        return '<span class="badge bg-success" title="Stock: '.$stock.'">'.$displayText.'</span>';
    } 
    elseif ($stockValue >= 15) {
        return '<span class="badge bg-warning" title="Stock: '.$stock.'">'.$displayText.'</span>';
    }
    else {
        return '<span class="badge-danger-blink" title="Stock: '.$stock.'">'.$displayText.'</span>';
    }
}


?>


    <form id="form_detail" autocomplete="off">
      <div class="modal-header">
        <h1 class="modal-title fs-4"><?= $title ?></h1>
        <!-- <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> -->
      </div>
      <div class="modal-body">

          <div class="table-responsive text-nowrap">
              <table class="table table-striped">
                  <tr>
                    <td style="width: 10%;">Nama</td>
                    <td>: <?= $row->name ?></td>
                  </tr>
                  <tr>
                    <td>Kategori</td>
                    <td>: <?= $row->category_name ?></td>
                  </tr>
                  <tr>
                    <td>Satuan</td>
                    <td>: <?= $row->unit_name ?></td>
                  </tr>
                  <tr>
                    <td>Stok</td>
                    <td>: <?= getBadgeStock($row->stock) ?></td>
                  </tr>
                  <tr>
                    <td>Harga Beli</td>
                    <td>: <span class="text-danger fw-semibold">Rp. <?= number_format($row->price_buy, 0, ',', '.') ?></span></td>
                  </tr>
                  <tr>
                    <td>Harga Jual</td>
                    <td>: <span class="text-success fw-semibold"> Rp. <?= number_format($row->price_sale, 0, ',', '.') ?></span></td>
                  </tr>
                  <tr>
                    <td>Diskon</td>
                    <td>: <?= empty($row->discount) ? ' -' : $row->discount ?></td>
                  </tr>
                  <tr>
                    <td>Keterangan</td>
                    <td>: <?= $row->description ?></td>
                  </tr>
                  <tr>
                    <td class="px-0 position-relative" style="height: 100px;"> <!-- Tambahkan height sesuai kebutuhan -->
                      <div class="position-absolute top-0 start-0 pt-2" style="margin-left: 20px;">Gambar</div>
                    </td>
                    <td> <img src="<?= base_url() .'uploads/goods/'.$row->image ?>" style="width: 140px;"></td>
                  </tr>
                </tbody>
              </table>
          </div>

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Tutup</button>
      </div>
    </form>

    