| Line 89... |
Line 89... |
| 89 |
} else {
|
89 |
} else {
|
| 90 |
jsonData[key] = value;
|
90 |
jsonData[key] = value;
|
| 91 |
}
|
91 |
}
|
| 92 |
});
|
92 |
});
|
| 93 |
|
93 |
|
| 94 |
// Handle internalWarehouseId separately (may be disabled so not in FormData)
|
94 |
// 0 = not internal; a ticked box must name the physical warehouse the supplier stands for.
|
| 95 |
const internalWarehouseSelect = form.find('#internalWarehouseId');
|
95 |
const internalWarehouseValue = form.find('#internalWarehouseId').val();
|
| 96 |
const internalWarehouseValue = internalWarehouseSelect.val();
|
96 |
if (form.find('#warehouseCheckbox').is(':checked')) {
|
| 97 |
if (internalWarehouseValue && internalWarehouseValue !== '') {
|
97 |
if (!internalWarehouseValue) {
|
| - |
|
98 |
alert("Select the internal warehouse, or untick Internal Warehouse");
|
| - |
|
99 |
return;
|
| - |
|
100 |
}
|
| 98 |
jsonData['internalWarehouseId'] = parseInt(internalWarehouseValue);
|
101 |
jsonData['internalWarehouseId'] = parseInt(internalWarehouseValue);
|
| 99 |
} else {
|
102 |
} else {
|
| 100 |
jsonData['internalWarehouseId'] = null;
|
103 |
jsonData['internalWarehouseId'] = 0;
|
| 101 |
}
|
104 |
}
|
| 102 |
|
105 |
|
| 103 |
doPostAjaxRequestWithJsonHandler(
|
106 |
doPostAjaxRequestWithJsonHandler(
|
| 104 |
`${context}/supplier/update/${supplierId}`,
|
107 |
`${context}/supplier/update/${supplierId}`,
|
| 105 |
JSON.stringify(jsonData),
|
108 |
JSON.stringify(jsonData),
|
| Line 359... |
Line 362... |
| 359 |
|
362 |
|
| 360 |
});
|
363 |
});
|
| 361 |
|
364 |
|
| 362 |
|
365 |
|
| 363 |
$(document).on('change', '#warehouseCheckbox', function () {
|
366 |
$(document).on('change', '#warehouseCheckbox', function () {
|
| 364 |
let warehouseContainer = document.getElementById("warehouseId");
|
367 |
let warehouseContainer = document.getElementById("internalWarehouseId");
|
| 365 |
warehouseContainer.disabled = !this.checked;
|
368 |
warehouseContainer.disabled = !this.checked;
|
| 366 |
});
|
369 |
});
|
| 367 |
$(document).on('click', ".create-supplier-submit", function () {
|
370 |
$(document).on('click', ".create-supplier-submit", function () {
|
| 368 |
console.log("hello");
|
371 |
console.log("hello");
|
| 369 |
var name = $("form#new-supplier-create-form input[name=inputName]").val();
|
372 |
var name = $("form#new-supplier-create-form input[name=inputName]").val();
|
| Line 426... |
Line 429... |
| 426 |
var warehouseId = $("#warehouseLocation").val();
|
429 |
var warehouseId = $("#warehouseLocation").val();
|
| 427 |
if (warehouseId === "") {
|
430 |
if (warehouseId === "") {
|
| 428 |
alert("Warehouse Location is required");
|
431 |
alert("Warehouse Location is required");
|
| 429 |
return false;
|
432 |
return false;
|
| 430 |
}
|
433 |
}
|
| 431 |
var warehouseName = $("#warehouseId").val();
|
- |
|
| 432 |
if (warehouseName === "") {
|
- |
|
| 433 |
alert("warehouseName is required");
|
- |
|
| 434 |
return false;
|
- |
|
| 435 |
}
|
- |
|
| 436 |
|
434 |
|
| 437 |
var state = $("#stateId").val();
|
435 |
var state = $("#stateId").val();
|
| 438 |
if (state === "") {
|
436 |
if (state === "") {
|
| 439 |
alert("state is required");
|
437 |
alert("state is required");
|
| 440 |
return false;
|
438 |
return false;
|
| Line 447... |
Line 445... |
| 447 |
var termConditions = $("form#new-supplier-create-form input[name=inputTermConditions]").val();
|
445 |
var termConditions = $("form#new-supplier-create-form input[name=inputTermConditions]").val();
|
| 448 |
if (termConditions === "") {
|
446 |
if (termConditions === "") {
|
| 449 |
alert("termConditions is required");
|
447 |
alert("termConditions is required");
|
| 450 |
return false;
|
448 |
return false;
|
| 451 |
}
|
449 |
}
|
| 452 |
var internalWarehouse = $("#internalWarehouseId").val();
|
450 |
if ($("#warehouseCheckbox").is(':checked') && !$("#internalWarehouseId").val()) {
|
| 453 |
if (internalWarehouse === "") {
|
- |
|
| 454 |
alert("internalWarehouse is required");
|
451 |
alert("Select the internal warehouse, or untick Internal Warehouse");
|
| 455 |
return false;
|
452 |
return false;
|
| 456 |
}
|
453 |
}
|
| 457 |
|
454 |
|
| 458 |
var json = newSupplierCreateObjectJson();
|
455 |
var json = newSupplierCreateObjectJson();
|
| 459 |
|
456 |
|
| Line 489... |
Line 486... |
| 489 |
newSupplierCreateObject['contactFax'] = $("form#new-supplier-create-form input[name=inputContactFax]").val();
|
486 |
newSupplierCreateObject['contactFax'] = $("form#new-supplier-create-form input[name=inputContactFax]").val();
|
| 490 |
newSupplierCreateObject['registeredAddress'] = $("form#new-supplier-create-form input[name=inputRegisteredAddress]").val();
|
487 |
newSupplierCreateObject['registeredAddress'] = $("form#new-supplier-create-form input[name=inputRegisteredAddress]").val();
|
| 491 |
newSupplierCreateObject['communicationAddress'] = $("form#new-supplier-create-form input[name=inputCommunicationAddress]").val();
|
488 |
newSupplierCreateObject['communicationAddress'] = $("form#new-supplier-create-form input[name=inputCommunicationAddress]").val();
|
| 492 |
newSupplierCreateObject['termConditions'] = $("form#new-supplier-create-form input[name=inputTermConditions]").val();
|
489 |
newSupplierCreateObject['termConditions'] = $("form#new-supplier-create-form input[name=inputTermConditions]").val();
|
| 493 |
newSupplierCreateObject['warehouseId'] = $("#warehouseLocation").val();
|
490 |
newSupplierCreateObject['warehouseId'] = $("#warehouseLocation").val();
|
| 494 |
newSupplierCreateObject['internalWarehouseId'] = $("#internalWarehouse").val();
|
491 |
newSupplierCreateObject['internalWarehouseId'] = $("#warehouseCheckbox").is(':checked')
|
| - |
|
492 |
? parseInt($("#internalWarehouseId").val()) : 0;
|
| 495 |
newSupplierCreateObject['state'] = $("#stateId").val();
|
493 |
newSupplierCreateObject['state'] = $("#stateId").val();
|
| 496 |
newSupplierCreateObject['pOValidityLimit'] = $("form#new-supplier-create-form input[name=inputPOValidityLimit]").val();
|
494 |
newSupplierCreateObject['pOValidityLimit'] = $("form#new-supplier-create-form input[name=inputPOValidityLimit]").val();
|
| 497 |
|
495 |
|
| 498 |
|
496 |
|
| 499 |
return JSON.stringify(newSupplierCreateObject);
|
497 |
return JSON.stringify(newSupplierCreateObject);
|