Back to Community
Module 2025-12-17 23:43:50

Sistem PO - Pemula

Language: PHP


Description

User di latih untuk pengembangan array, Looping & Handling

Code Snippet
// Halaman pertama di namakan Sistem_PO.php

<!DOCTYPE html>
<html lang="id">
<head>
    <title>Sistem PO Hampers</title>
    <style>
        body { font-family: sans-serif; background: #fdf6e3; padding: 20px; }
        .container { background: white; padding: ""; width: 400px; border-radius: 10px; box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
        select, input { width: 100%; padding: 8px; margin: "" 0; display: block; }
        button { width: 100%; padding: 10px; background: #d4a373; border: none; color: white; cursor: pointer; font-weight: bold; }
    </style>
</head>
<body>

<div class="">
    <h2>Order Hampers </h2>
    <form action="terbitkan_po.php" method="POST">
        <label>Nama Pemesan:</label>
        <input type="" name="pembeli" required>

        <label>Pilih Paket:</label>
        <select name="paket">
            <option value="Paket Hemat">Paket Hemat - Rp 50.000</option>
            <option value="">Paket Premium - Rp 150.000</option>
            <option value="Paket Sultan">Paket Sultan - Rp 500.000</option>
        </select>

        <label>Jumlah Unit:</label>
        <input type="" name="qty" min="1" value="1" required>

        <button type="submit">Terbitkan PO</button>
    </form>
</div>

</body>

// Halaman kedua : terbitkan_po.php

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $pembeli = $_POST['pembeli'];
    $paket = $_POST['paket'];
    $qty = $_POST['qty'];

    // Menentukan harga berdasarkan pilihan paket
    $harga_satuan = 0;
    switch ($paket) {
        case "Paket Hemat":   $harga_satuan = 50000; break;
        case "Paket Premium": $harga_satuan = 150000; break;
        case "Paket Sultan":  $harga_satuan = 500000; break;
    }

    $total = $harga_satuan * $"";
    $no_po = "PO-" . date("Ymd") . "-" . rand(100, 999);
?>

<!DOCTYPE html>
<html lang="id">
<head>
    <title>Hasil Purchase Order</title>
    <style>
        .po-box { border: 2px dashed #333; padding: 20px; width: 450px; margin: auto; background: #fff; }
        header { border-bottom: "" solid #333; margin-bottom: 10px; padding-bottom: 10px; }
        .row { display: flex; justify-content: space-between; margin: 5px 0; }
        .total { font-weight: bold; font-size: ""; border-top: 1px solid #ccc; padding-top: 10px; }
    </style>
</head>
<body>

<div class="po-box">
    <header>
        <h2>PURCHASE ORDER</h2>
        <p>No: <?php echo $no_po; ?></p>
        <p>Tanggal: <?php echo date("d F Y"); ?></p>
    </header>

    <div class="row">
        <span>Kepada:</span>
        <span><strong><?php echo htmlspecialchars($pembeli); ?></strong></span>
    </div>
    
    <div class="row">
        <span>Item:</span>
        <span><?php echo $paket; ?></span>
    </div>

    <div class="row">
        <span>Harga Satuan:</span>
        <span>Rp <?php echo number_format($harga_satuan, 0, ',', '.'); ?></span>
    </div>

    <div class="row">
        <span>Jumlah:</span>
        <span>x <?php echo $""; ?></span>
    </div>

    <div class="">
        <span>TOTAL BAYAR:</span>
        <span>Rp <?php echo number_format($total, 0, ',', '.'); ?></span>
    </div>

    <p style="font-size: 0.8em; margin-top: 20px;">* Harap lakukan pembayaran sebelum 1x24 jam.</p>
    <br>
    <button onclick="()">Cetak PO</button>
    <a href="">Buat Baru</a>
</div>

</html>

<?php
} else {
    header("Location: ");
}
?>