[test] contact to setting modules

This commit is contained in:
Thanakorn S
2026-05-06 08:58:09 +07:00
parent 414f1cd81d
commit 6501d326ca
43 changed files with 4295 additions and 581 deletions
+2 -2
View File
@@ -15,9 +15,9 @@
exit(json_encode($answer));
}
if ($min_stock >= $reorder_point) {
if ($min_stock > $reorder_point) {
$answer['success'] = 0;
$answer['message'] = "Min stock ({$min_stock}) must be less than reorder point ({$reorder_point}).";
$answer['message'] = "Min stock ({$min_stock}) must be less than or equal to reorder point ({$reorder_point}).";
http_response_code(400);
exit(json_encode($answer));
}
+7 -3
View File
@@ -2,11 +2,15 @@
session_start();
require '../../../assets/utils/db_auth.php';
require '../../../assets/utils/classes/WarehouseManager.php';
require '../../../assets/utils/classes/CompanySettingManager.php';
try {
dbTransaction($pdo2, function($pdo) use ($data, $company_id, $logging) {
$setting = new CompanySettingManager($pdo1, $company_id, $pdo2);
$advanced_location = (int)$setting->get('advanced_location') === 1;
dbTransaction($pdo2, function($pdo) use ($data, $company_id, $logging, $advanced_location) {
$wh = new WarehouseManager($pdo, $company_id);
$wh->saveStorage($data, $logging);
$wh->saveStorage($data, $logging, $advanced_location);
});
$answer['success'] = 1;
@@ -23,4 +27,4 @@
}
exit(json_encode($answer));
?>
?>
+17 -5
View File
@@ -4,17 +4,29 @@
require '../../../assets/utils/classes/WarehouseManager.php';
try {
dbTransaction($pdo2, function($pdo) use ($data, $company_id, $logging) {
$newWarehouseId = null;
dbTransaction($pdo2, function($pdo) use ($data, $company_id, $logging, &$newWarehouseId) {
$wh = new WarehouseManager($pdo, $company_id);
$wh->saveWarehouse($data, $logging);
$newWarehouseId = $wh->saveWarehouse($data, $logging);
});
if (!empty($newWarehouseId)) {
$wh = new WarehouseManager($pdo2, $company_id);
$wh->createStockTableForWarehouse((int)$newWarehouseId);
}
$answer['success'] = 1;
} catch (PDOException $e) {
$answer['success'] = 0;
$answer['message'] = 'Database error, please try again';
http_response_code(500);
if ($e->getCode() === '23000' && strpos($e->getMessage(), 'company_id_warehouse_name') !== false) {
$answer['message'] = 'Warehouse name already exists. Please use a different warehouse name.';
http_response_code(400);
} else {
$answer['message'] = 'Database error, please try again';
http_response_code(500);
}
} catch (Exception $e) {
$answer['success'] = 0;
@@ -23,4 +35,4 @@
}
exit(json_encode($answer));
?>
?>
+24 -4
View File
@@ -39,10 +39,29 @@
</div>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<div class="col-md-4 mb-3">
<label for="price" class="form-label">Price</label>
<input type="number" class="form-control" id="price" placeholder="0.00" step="0.01" required>
</div>
<div class="col-md-2 mb-3">
<label for="uom" class="form-label">UOM</label>
<input type="text" class="form-control" id="uom" placeholder="pcs"
list="uom_suggestions" autocomplete="off" maxlength="20">
<datalist id="uom_suggestions">
<option value="pcs">
<option value="box">
<option value="kg">
<option value="g">
<option value="l">
<option value="ml">
<option value="set">
<option value="roll">
<option value="pair">
<option value="sheet">
<option value="bag">
<option value="bottle">
</datalist>
</div>
<div class="col-md-3 mb-3">
<label for="min_stock" class="form-label">Min Stock</label>
<input type="number" class="form-control" id="min_stock" placeholder="0" min="0" required>
@@ -53,7 +72,7 @@
<label for="reorder_point" class="form-label">Reorder Point</label>
<input type="number" class="form-control" id="reorder_point" placeholder="0" min="0" required>
<div class="invalid-feedback" id="reorder_point_error"></div>
<small class="text-muted" id="reorder_point_hint">Must be greater than min stock</small>
<small class="text-muted" id="reorder_point_hint">Must be greater than or equal to min stock</small>
</div>
</div>
@@ -119,6 +138,7 @@
}
formData.append('keep_files', $('#current_file_label').val())
formData.append('uom', $('#uom').val() || 'pcs')
return ajax_request({
url: "<?php echo $server_url?>inventory/api/engine/manage_product.php",
@@ -236,8 +256,8 @@
return false;
}
if (min_stock >= reorder_point) {
flag('reorder_point', 'Must be greater than min stock (' + min_stock + ').');
if (min_stock > reorder_point) {
flag('reorder_point', 'Must be greater than or equal to min stock (' + min_stock + ').');
return false;
}
+11 -1
View File
@@ -172,6 +172,16 @@
var isNumeric = function(v) { return /^[0-9]+$/.test(v); };
var isAlpha = function(v) { return /^[A-Z]$/.test(v); };
if (!zone) {
alert('Please enter a ' + label_zone + ' value.'); return;
}
if (!aisle_from || !aisle_to) {
alert('Please enter the full ' + label_aisle + ' range.'); return;
}
if (!rack_from || !rack_to) {
alert('Please enter the full ' + label_rack + ' range.'); return;
}
if (aisle_from && aisle_to) {
if (isNumeric(aisle_from) !== isNumeric(aisle_to)) {
alert(label_aisle + ' From and To must both be numbers or both be letters.'); return;
@@ -303,4 +313,4 @@
</body>
</html>
</html>
+12 -3
View File
@@ -197,6 +197,7 @@
<th width="75px"></th>
<th>Product</th>
<th>SKU</th>
<th>UOM</th>
<th style="text-align: right;">Current Stock</th>
<th style="text-align: right;">Min Stock</th>
<th style="text-align: right;">Reorder Point</th>
@@ -344,7 +345,7 @@
if (filtered.length === 0) {
$("table#product > tbody").html(
'<tr><td colspan="8" class="text-center py-5 text-muted">No products match your search.</td></tr>'
'<tr><td colspan="9" class="text-center py-5 text-muted">No products match your search.</td></tr>'
);
return;
}
@@ -355,11 +356,19 @@
$.each(page_data, function(key, item) {
body += `<tr height="50px">
<td class="py-3">
<img src="<?php echo $server_url?>uploads/product/${item['product_image']}" alt="${item['product_name']}" class="img-fluid" style="height: 25px;">
${item['product_image']
? `<img src="<?php echo $server_url?>uploads/product/${item['product_image']}" alt="${item['product_name']}" style="width:40px;height:40px;object-fit:cover;border-radius:4px;">`
: `<div style="width:40px;height:40px;display:flex;align-items:center;justify-content:center;" class="rounded-2 bg-light"><i class="ti ti-photo fs-5 text-muted"></i></div>`}
</td>
<td class="py-3">${item['product_name']}</td>
<td class="py-3">${item['sku']}</td>
<td class="py-3" style="text-align: right;">${format_number(item['product_balance'], 4)}</td>
<td class="py-3"><span class="badge bg-light text-secondary border">${item['uom'] || 'pcs'}</span></td>
<td class="py-3">
<div class="d-flex justify-content-end align-items-baseline gap-1">
<span>${format_number(item['product_balance'], 4)}</span>
<span class="text-muted small" style="min-width:28px;">${item['uom'] || 'pcs'}</span>
</div>
</td>
<td class="py-3" style="text-align: right;">${format_number(item['min_stock'], 2)}</td>
<td class="py-3" style="text-align: right;">${format_number(item['reorder_point'], 2)}</td>
<td class="py-3">