94 lines
3.2 KiB
PHP
94 lines
3.2 KiB
PHP
<?php
|
|
include '../template/template1.php';
|
|
include '../template/header.php';
|
|
include '../template/sidebar.php';
|
|
|
|
if (isset($_POST['submit'])) {
|
|
$nama_pemasok = $_POST['nama_pemasok'];
|
|
$no_hp = $_POST['no_hp'];
|
|
$harga_beli = $_POST['harga_beli'];
|
|
$berat = isset($_POST['berat']) ? floatval($_POST['berat']) : 0.00;
|
|
$jumlah = $_POST['jumlah'];
|
|
|
|
$query = "INSERT INTO pemasok (nama_pemasok, no_hp, harga_beli, berat, jumlah) VALUES
|
|
('$nama_pemasok', '$no_hp', '$harga_beli', '$berat', '$jumlah')";
|
|
|
|
if (mysqli_query($conn, $query)) {
|
|
echo "<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
Swal.fire({
|
|
icon: 'success',
|
|
title: 'Berhasil',
|
|
text: 'Pemasok berhasil ditambahkan',
|
|
confirmButtonText: 'OK'
|
|
}).then(function() {
|
|
window.location = 'index.php';
|
|
});
|
|
});
|
|
</script>";
|
|
} else {
|
|
echo "<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Gagal',
|
|
text: 'Terjadi kesalahan saat menyimpan data',
|
|
confirmButtonText: 'OK'
|
|
});
|
|
});
|
|
</script>";
|
|
}
|
|
}
|
|
|
|
?>
|
|
|
|
<main id="main" class="main">
|
|
<div class="pagetitle">
|
|
<h1>Tambah 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">Tambah</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" required class="form-control">
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">No HP</label>
|
|
<input type="text" name="no_hp" required class="form-control">
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Harga Beli</label>
|
|
<input type="number" name="harga_beli" required class="form-control">
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Berat (kg)</label>
|
|
<input type="number" name="berat" step="0.01" min="0" required class="form-control">
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Jumlah</label>
|
|
<input type="number" name="jumlah" required class="form-control">
|
|
</div>
|
|
|
|
<button type="submit" name="submit" class="btn btn-success">Simpan</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'; ?>
|