Ilości ujemne w zamówieniu (Ilość)
This commit is contained in:
@@ -42,7 +42,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|||||||
$message = "<div class='alert alert-danger'>Nie udało się zapisać zamówienia.</div>";
|
$message = "<div class='alert alert-danger'>Nie udało się zapisać zamówienia.</div>";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$message = "<div class='alert alert-warning'>Wypełnij nazwę produktu i ilość.</div>";
|
$message = "<div class='alert alert-warning'>Wypełnij nazwę produktu i podaj ilość większą od zera.</div>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ try {
|
|||||||
|
|
||||||
$price = (float)str_replace(',', '.', $data['price_per_unit'] ?? 0);
|
$price = (float)str_replace(',', '.', $data['price_per_unit'] ?? 0);
|
||||||
$qty = (int)($data['quantity'] ?? 1);
|
$qty = (int)($data['quantity'] ?? 1);
|
||||||
|
if ($qty < 1) {
|
||||||
|
die(json_encode(['success' => false, 'error' => 'Ilość musi być większa od zera.']));
|
||||||
|
}
|
||||||
|
|
||||||
$stmt->execute([
|
$stmt->execute([
|
||||||
trim($data['product_name']),
|
trim($data['product_name']),
|
||||||
|
|||||||
@@ -45,6 +45,13 @@ try {
|
|||||||
$old_val = $stmt->fetchColumn();
|
$old_val = $stmt->fetchColumn();
|
||||||
|
|
||||||
if ((string)$old_val !== (string)$value) {
|
if ((string)$old_val !== (string)$value) {
|
||||||
|
if ($field === 'quantity') {
|
||||||
|
$value = (int)$value;
|
||||||
|
if ($value < 1) {
|
||||||
|
die(json_encode(['success' => false, 'error' => 'Ilość musi być większa od zera.']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($field === 'price_per_unit') {
|
if ($field === 'price_per_unit') {
|
||||||
$value = (float)str_replace(',', '.', $value);
|
$value = (float)str_replace(',', '.', $value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && !isset($_POST['archive_action']) &&
|
|||||||
$delivery_address = trim($_POST['delivery_address'] ?? '');
|
$delivery_address = trim($_POST['delivery_address'] ?? '');
|
||||||
$company = trim($_POST['company'] ?? '');
|
$company = trim($_POST['company'] ?? '');
|
||||||
|
|
||||||
|
if ($quantity < 1) {
|
||||||
|
$message = "<div class='alert alert-warning'>Ilość musi być większa od zera.</div>";
|
||||||
|
} else {
|
||||||
$changes = [];
|
$changes = [];
|
||||||
if (($order['company'] ?? '') !== $company) $changes[] = "Firma: [{$order['company']}] ➔ [$company]";
|
if (($order['company'] ?? '') !== $company) $changes[] = "Firma: [{$order['company']}] ➔ [$company]";
|
||||||
if (($order['product_name'] ?? '') !== $product_name) $changes[] = "Produkt: [{$order['product_name']}] ➔ [$product_name]";
|
if (($order['product_name'] ?? '') !== $product_name) $changes[] = "Produkt: [{$order['product_name']}] ➔ [$product_name]";
|
||||||
@@ -102,6 +105,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && !isset($_POST['archive_action']) &&
|
|||||||
$message = "<div class='alert alert-danger'>Błąd bazy: " . $e->getMessage() . "</div>";
|
$message = "<div class='alert alert-danger'>Błąd bazy: " . $e->getMessage() . "</div>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// POBIERANIE HISTORII
|
// POBIERANIE HISTORII
|
||||||
|
|||||||
+5
-2
@@ -501,7 +501,9 @@ function getStatusClass($status) {
|
|||||||
</select>`;
|
</select>`;
|
||||||
} else if (fieldName === 'delivery_date') {
|
} else if (fieldName === 'delivery_date') {
|
||||||
inputHTML = `<input type="date" class="inline-input" value="${currentText}">`;
|
inputHTML = `<input type="date" class="inline-input" value="${currentText}">`;
|
||||||
} else if (fieldName === 'quantity' || fieldName === 'price_per_unit') {
|
} else if (fieldName === 'quantity') {
|
||||||
|
inputHTML = `<input type="number" min="1" step="1" class="inline-input" style="width: 70px;" value="${currentText}">`;
|
||||||
|
} else if (fieldName === 'price_per_unit') {
|
||||||
inputHTML = `<input type="number" step="0.01" class="inline-input" style="width: 70px;" value="${currentText}">`;
|
inputHTML = `<input type="number" step="0.01" class="inline-input" style="width: 70px;" value="${currentText}">`;
|
||||||
} else {
|
} else {
|
||||||
inputHTML = `<input type="text" class="inline-input" value="${currentText}">`;
|
inputHTML = `<input type="text" class="inline-input" value="${currentText}">`;
|
||||||
@@ -558,7 +560,7 @@ function getStatusClass($status) {
|
|||||||
<td></td>
|
<td></td>
|
||||||
<td class="text-muted"><span class="badge bg-info text-dark">Nowe</span></td>
|
<td class="text-muted"><span class="badge bg-info text-dark">Nowe</span></td>
|
||||||
<td><input type="text" class="form-control form-control-sm border-primary" id="add-prod" placeholder="Nazwa produktu..."></td>
|
<td><input type="text" class="form-control form-control-sm border-primary" id="add-prod" placeholder="Nazwa produktu..."></td>
|
||||||
<td><input type="number" class="form-control form-control-sm border-primary" id="add-qty" value="1" style="width: 60px;"></td>
|
<td><input type="number" class="form-control form-control-sm border-primary" id="add-qty" value="1" min="1" step="1" style="width: 60px;"></td>
|
||||||
<td><input type="text" class="form-control form-control-sm border-primary" id="add-place" placeholder="Sklep..."></td>
|
<td><input type="text" class="form-control form-control-sm border-primary" id="add-place" placeholder="Sklep..."></td>
|
||||||
<td><input type="text" class="form-control form-control-sm border-primary" id="add-price" placeholder="0.00" style="width: 80px;"></td>
|
<td><input type="text" class="form-control form-control-sm border-primary" id="add-price" placeholder="0.00" style="width: 80px;"></td>
|
||||||
<td class="text-muted small">Brak</td>
|
<td class="text-muted small">Brak</td>
|
||||||
@@ -581,6 +583,7 @@ function getStatusClass($status) {
|
|||||||
const price = document.getElementById('add-price').value;
|
const price = document.getElementById('add-price').value;
|
||||||
|
|
||||||
if(!prod) { alert("Nazwa produktu jest obowiązkowa!"); document.getElementById('add-prod').focus(); return; }
|
if(!prod) { alert("Nazwa produktu jest obowiązkowa!"); document.getElementById('add-prod').focus(); return; }
|
||||||
|
if(!qty || Number(qty) < 1) { alert("Ilość musi być większa od zera!"); document.getElementById('add-qty').focus(); return; }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let response = await fetch('ajax_add_row.php', {
|
let response = await fetch('ajax_add_row.php', {
|
||||||
|
|||||||
Reference in New Issue
Block a user