92 lines
3.2 KiB
PHP
92 lines
3.2 KiB
PHP
<?php
|
|
include '../template/template1.php';
|
|
include '../template/header.php';
|
|
include '../template/sidebar.php';
|
|
|
|
$id = $_GET['id'];
|
|
$query = mysqli_query($conn, "SELECT * FROM pemasok WHERE id_pemasok='$id'");
|
|
$data = mysqli_fetch_assoc($query);
|
|
|
|
if (isset($_POST['submit'])) {
|
|
$nama_pemasok = $_POST['nama_pemasok'];
|
|
$no_hp = $_POST['no_hp'];
|
|
$harga_beli = $_POST['harga_beli'];
|
|
$berat = $_POST['berat'];
|
|
$jumlah = $_POST['jumlah'];
|
|
|
|
$update = "UPDATE pemasok SET
|
|
nama_pemasok='$nama_pemasok',
|
|
no_hp='$no_hp',
|
|
harga_beli='$harga_beli',
|
|
berat='$berat',
|
|
jumlah='$jumlah'
|
|
WHERE id_pemasok='$id'";
|
|
|
|
if (mysqli_query($conn, $update)) {
|
|
echo "<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
Swal.fire({
|
|
icon: 'success',
|
|
title: 'Berhasil',
|
|
text: 'Pemasok berhasil diperbarui',
|
|
confirmButtonText: 'OK'
|
|
}).then(function() {
|
|
window.location = 'index.php';
|
|
});
|
|
});
|
|
</script>";
|
|
}
|
|
|
|
}
|
|
?>
|
|
|
|
<main id="main" class="main">
|
|
<div class="pagetitle">
|
|
<h1>Edit Pemasok</h1>
|
|
<nav>
|
|
<ol class="breadcrumb">
|
|
<li class="breadcrumb-item"><a href="../index.php">Home</a></li>
|
|
<li class="breadcrumb-item"><a href="index.php">Pemasok</a></li>
|
|
<li class="breadcrumb-item active">Edit Pemasok</li>
|
|
</ol>
|
|
</nav>
|
|
</div>
|
|
|
|
<div class="card mt-2">
|
|
<div class="card-body">
|
|
<form method="POST">
|
|
<div class="mb-3">
|
|
<label class="form-label">Nama Pemasok</label>
|
|
<input type="text" name="nama_pemasok" value="<?= $data['nama_pemasok']; ?>" required class="form-control">
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">No HP</label>
|
|
<input type="text" name="no_hp" value="<?= $data['no_hp']; ?>" required class="form-control">
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Harga Beli</label>
|
|
<input type="number" name="harga_beli" value="<?= $data['harga_beli']; ?>" required class="form-control">
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Berat (kg)</label>
|
|
<input type="number" name="berat" value="<?= number_format($data['berat'], 2, '.', ''); ?>" required class="form-control" step="0.01">
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Jumlah</label>
|
|
<input type="number" name="jumlah" value="<?= $data['jumlah']; ?>" required class="form-control">
|
|
</div>
|
|
|
|
<button type="submit" name="submit" class="btn btn-success">Simpan Perubahan</button>
|
|
<a href="index.php" class="btn btn-secondary">Batal</a>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<?php include '../template/footer.php'; ?>
|
|
<?php include '../template/template2.php'; ?>
|