upgrade matrice with files
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
include('include/headscript.php');
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$id = isset($_POST['id']) ? (int)$_POST['id'] : 0;
|
||||
$qty = isset($_POST['qty']) ? (float)$_POST['qty'] : null;
|
||||
|
||||
if ($id <= 0 || $qty === null) {
|
||||
echo json_encode(['success' => false, 'message' => 'Invalid input']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($qty < 0) {
|
||||
echo json_encode(['success' => false, 'message' => 'Quantity cannot be negative']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$db = DBHandlerSelect::getInstance();
|
||||
$pdo = $db->getConnection();
|
||||
|
||||
try {
|
||||
$stmt = $pdo->prepare("UPDATE mescole_supplier_lots SET qty = ? WHERE id = ?");
|
||||
$stmt->execute([$qty, $id]);
|
||||
|
||||
if ($stmt->rowCount() === 0) {
|
||||
echo json_encode(['success' => false, 'message' => 'No rows updated (id not found?)']);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
Reference in New Issue
Block a user