<?php
session_start();
include 'koneksi.php';

if (isset($_GET['id'])) {
    $id = mysqli_real_escape_string($koneksi, $_GET['id']);

    // Hapus supplier berdasarkan ID
    $query = mysqli_query($koneksi, "DELETE FROM supplier WHERE id = '$id'");

    if ($query) {
        // Set pesan sukses ke session
        $_SESSION['pesan_sukses'] = "Supplier berhasil dihapus!";
        header("Location: supplier.php");
        exit();
    } else {
        echo "Gagal menghapus: " . mysqli_error($koneksi);
        echo "<br><a href='supplier.php'>Kembali</a>";
    }
} else {
    header("Location: supplier.php");
    exit();
}
?>