<?php

require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include ('includes/function.php');

$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);
$maindb = "itempart";
$success = false;
if (isset($_REQUEST['code'])) {
    $mcode = $_REQUEST['code'];
    if ($mcode != '') {
        $resperf = mysqli_query($conn, "SELECT `itempart` FROM `itemsize` WHERE `itempart`='$mcode'") or die(mysqli_error($conn));
        $perfet = mysqli_num_rows($resperf);
        if ($perfet > 0) {
            $success = false;
            $row = "ITEM PART AVAILABLE IN ITEM";
        } else {
            $delitempart = mysqli_query($conn, "DELETE FROM `$maindb` WHERE `code` = '$mcode'")or die(mysqli_error($conn));
            $success = true;
            $row = "Record Deleted Successfully";
        }
    } else {
        $success = false;
        $row = "Record Not Deleted";
    }
}

echo json_encode($row);
?>