<?php
include 'db.php';
include 'auth.php';
require_right('Add Supplier');

$name = $_POST['name'];
$contact = $_POST['contact_number'];
$email = $_POST['email'];
$address = $_POST['address'];
$is_active = isset($_POST['is_active']) ? (int)$_POST['is_active'] : 1;

$stmt = $conn->prepare("INSERT INTO vendors (name, contact_number, email, address, is_active, created_at) VALUES (?, ?, ?, ?, ?, NOW())");
$stmt->bind_param("ssssi", $name, $contact, $email, $address, $is_active);
$stmt->execute();

header("Location: supplier-list.php?success=1");
exit;
?>
