upgrade matrice with files
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
include('include/headscript.php');
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$category = trim($_POST['category'] ?? '');
|
||||
$item_name = trim($_POST['item_name'] ?? '');
|
||||
$item_code = trim($_POST['item_code'] ?? '');
|
||||
|
||||
$allowed = ['PACKAGING_TYPE', 'BOX', 'PALLET', 'OTHER'];
|
||||
if (!in_array($category, $allowed, true) || $item_name === '' || $item_code === '') {
|
||||
echo json_encode(['success' => false, 'message' => 'Invalid input']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$db = DBHandlerSelect::getInstance();
|
||||
$pdo = $db->getConnection();
|
||||
|
||||
try {
|
||||
$stmt = $pdo->prepare("INSERT INTO packaging_items (category, item_name, item_code) VALUES (?,?,?)");
|
||||
$stmt->execute([$category, $item_name, $item_code]);
|
||||
echo json_encode(['success' => true]);
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
Reference in New Issue
Block a user