<?php 
include("../connection.php");
include("../user.php");
$user = $_SESSION['user'];
$cur_date = date('Y-m-d H:i:s');
?>
<link rel="stylesheet" href="../css/sweet-alert.css" />
<?php
$cat = $_REQUEST['category'];
$pfx = $_REQUEST['prefix'];
$brand = $_REQUEST['brand'];
$category_id = $_REQUEST['category_id'];
$availability = $_REQUEST['availability'];
$price = $_REQUEST['price'];
$tol_amount = $_REQUEST['tol_amount'];
$measurement = $_REQUEST['measurement_type'];
$dept = $_REQUEST['dept'];
// Prepare the SQL query
$query = "INSERT INTO `category_master`(`category_id`,`category_type`,`category_brand`,`department`, `category_description`,`measurement`, `availability`,`amount`,`total_amount`, `status`, `created_on`, `created_by`) 
          VALUES ('$category_id','$cat','$brand','$dept', '$pfx', '$measurement', '$availability','$price','$tol_amount', '0', '$cur_date', '$user')";
$catg = mysqli_query($con, $query);
if($catg) {
?>
<script>
    setTimeout(function() {
        swal({
            title: "Successfully",
            text: "Category Created!",
            type: "success"
        }, function() {
            window.location = "category_master.php";
        });
    }, 100);
</script>  
<?php
} else {
?>
<script>
    setTimeout(function() {
        swal({
            title: "Not",
            text: "Category Created!",
            type: "error"
        }, function() {
            window.location = "category_master.php";
        });
    }, 100);
</script>  
<?php
}
?>
<script src="../js/sweet-alert.js"></script>