Lot, Serial, ExpiryDate

This commit is contained in:
Thanakorn S
2026-04-25 14:37:00 +07:00
parent 92d116fd21
commit 3cc5baba3f
35 changed files with 3518 additions and 1890 deletions
+46 -2
View File
@@ -45,11 +45,15 @@
</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" required>
<input type="number" class="form-control" id="min_stock" placeholder="0" min="0" required>
<div class="invalid-feedback" id="min_stock_error"></div>
<small class="text-muted" id="min_stock_hint">Safety floor</small>
</div>
<div class="col-md-3 mb-3">
<label for="reorder_point" class="form-label">Reorder Point</label>
<input type="number" class="form-control" id="reorder_point" placeholder="0" required>
<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>
</div>
</div>
@@ -203,6 +207,46 @@
console.log(e);
}
});
function validate_stock_thresholds() {
var min_stock = parseFloat($('#min_stock').val() || 0);
var reorder_point = parseFloat($('#reorder_point').val() || 0);
// Reset both fields to clean state
$('#min_stock, #reorder_point').removeClass('is-invalid');
$('#min_stock_error, #reorder_point_error').text('');
$('#min_stock_hint, #reorder_point_hint').show();
// Helper: mark a field invalid and hide its hint
function flag(field, msg) {
$('#' + field).addClass('is-invalid');
$('#' + field + '_error').text(msg);
$('#' + field + '_hint').hide();
}
if (min_stock < 0) {
flag('min_stock', 'Cannot be negative.');
return false;
}
if (reorder_point < 0) {
flag('reorder_point', 'Cannot be negative.');
return false;
}
if (min_stock >= reorder_point) {
flag('reorder_point', 'Must be greater than min stock (' + min_stock + ').');
return false;
}
return true;
}
// Live feedback as the user types
$('#min_stock, #reorder_point').on('input', validate_stock_thresholds);
</script>