| Line 229... |
Line 229... |
| 229 |
if (!brandFeesCollected) missingFields.push('Brand Fees Collected');
|
229 |
if (!brandFeesCollected) missingFields.push('Brand Fees Collected');
|
| 230 |
if (brandFeesCollected > brandFee) missingFields.push('The collected brand fee must not exceed the agreed brand fees.');
|
230 |
if (brandFeesCollected > brandFee) missingFields.push('The collected brand fee must not exceed the agreed brand fees.');
|
| 231 |
if (!paymentMode) missingFields.push('Payment Mode');
|
231 |
if (!paymentMode) missingFields.push('Payment Mode');
|
| 232 |
if (!paymentReferenceNo) missingFields.push('Payment Reference No');
|
232 |
if (!paymentReferenceNo) missingFields.push('Payment Reference No');
|
| 233 |
if (!feeCollectingDate) missingFields.push('Fee Collecting Date');
|
233 |
if (!feeCollectingDate) missingFields.push('Fee Collecting Date');
|
| - |
|
234 |
if (!paymentAttachment) {
|
| - |
|
235 |
var screenshotInput = $('#payment-sc-doc')[0];
|
| - |
|
236 |
if (paymentScreenshotUploading) {
|
| - |
|
237 |
missingFields.push('Payment screenshot (still uploading - wait for "Attached: ..." under the field)');
|
| - |
|
238 |
} else if (screenshotInput && screenshotInput.files && screenshotInput.files.length > 0) {
|
| - |
|
239 |
missingFields.push('Payment screenshot (the file was picked but the upload did not complete - select it again)');
|
| - |
|
240 |
} else {
|
| 234 |
if (!paymentAttachment) missingFields.push('Payment screenshot ');
|
241 |
missingFields.push('Payment screenshot');
|
| - |
|
242 |
}
|
| - |
|
243 |
}
|
| 235 |
if (missingFields.length > 0) {
|
244 |
if (missingFields.length > 0) {
|
| 236 |
alert('The following fields are required: ' + missingFields.join(', '));
|
245 |
alert('The following fields are required: ' + missingFields.join(', '));
|
| 237 |
return;
|
246 |
return;
|
| 238 |
}
|
247 |
}
|
| 239 |
const loiFormData = {
|
248 |
const loiFormData = {
|
| Line 365... |
Line 374... |
| 365 |
$(document).on('click', "#addBrandFeePayment", function () {
|
374 |
$(document).on('click', "#addBrandFeePayment", function () {
|
| 366 |
var $btn = $(this);
|
375 |
var $btn = $(this);
|
| 367 |
if ($btn.prop('disabled')) return false;
|
376 |
if ($btn.prop('disabled')) return false;
|
| 368 |
let formData = objectifyForm($("form[name='brandFeeCollectionForm']").serializeArray());
|
377 |
let formData = objectifyForm($("form[name='brandFeeCollectionForm']").serializeArray());
|
| 369 |
let loiId = $btn.val();
|
378 |
let loiId = $btn.val();
|
| - |
|
379 |
// paymentAttachment is a hidden field filled by the screenshot upload, so name it
|
| - |
|
380 |
// the way the operator sees it rather than echoing the raw form key.
|
| - |
|
381 |
const brandFeeFieldLabels = {
|
| - |
|
382 |
collectedAmount: 'Amount',
|
| - |
|
383 |
paymentMode: 'Payment Mode',
|
| - |
|
384 |
paymentReferenceNo: 'Reference No',
|
| - |
|
385 |
paymentAttachment: 'Attachment (pick the screenshot again - the upload did not complete)',
|
| - |
|
386 |
feeCollectingTimeStamp: 'Collecting Date'
|
| - |
|
387 |
};
|
| 370 |
for (var key in formData) {
|
388 |
for (var key in formData) {
|
| 371 |
if (formData.hasOwnProperty(key) && formData[key].trim() === '') {
|
389 |
if (formData.hasOwnProperty(key) && formData[key].trim() === '') {
|
| 372 |
alert("The (" + key + ") value is blank please fill this field !");
|
390 |
alert("The (" + (brandFeeFieldLabels[key] || key) + ") value is blank please fill this field !");
|
| 373 |
return false;
|
391 |
return false;
|
| 374 |
}
|
392 |
}
|
| 375 |
}
|
393 |
}
|
| 376 |
let jsonData = JSON.stringify(formData);
|
394 |
let jsonData = JSON.stringify(formData);
|
| 377 |
if (confirm("Are you sure to add payment ?")) {
|
395 |
if (confirm("Are you sure to add payment ?")) {
|
| Line 538... |
Line 556... |
| 538 |
doGetAjaxRequestHandler(`${context}/uploadDocumentForm?loiId=${loiId}`,
|
556 |
doGetAjaxRequestHandler(`${context}/uploadDocumentForm?loiId=${loiId}`,
|
| 539 |
function (response) {
|
557 |
function (response) {
|
| 540 |
$('#' + 'main-content').html(response);
|
558 |
$('#' + 'main-content').html(response);
|
| 541 |
});
|
559 |
});
|
| 542 |
});
|
560 |
});
|
| - |
|
561 |
// A file input keeps showing the chosen filename no matter what happens next, so the
|
| - |
|
562 |
// operator reads "attached" from the widget while the validator reads the hidden
|
| 543 |
$(document).on('input', 'table#OnboardingDocumentTable input[type=file],table#mk_brand-fee-collection-details input[type=file]', function () {
|
563 |
// documentId that the upload was supposed to fill. Every path below keeps those two in
|
| - |
|
564 |
// step: if the id does not land, the file input is cleared so the form stops claiming a
|
| 544 |
if (confirm('Confirm file upload ?')) {
|
565 |
// file is attached. (The old confirm() gate is gone - picking a file in the OS dialog is
|
| - |
|
566 |
// already an explicit action, and Chrome's "prevent additional dialogs" checkbox made
|
| 545 |
var fileSelector = $(this)[0];
|
567 |
// confirm() silently return false, which skipped the upload with no trace.)
|
| 546 |
if (fileSelector != undefined
|
568 |
var paymentScreenshotUploading = false;
|
| - |
|
569 |
|
| 547 |
&& fileSelector.files[0] != undefined) {
|
570 |
function setPaymentScreenshotStatus(text, cssClass) {
|
| - |
|
571 |
$('#payment-sc-status').text(text).attr('class', 'help-block ' + (cssClass || ''));
|
| - |
|
572 |
}
|
| - |
|
573 |
|
| - |
|
574 |
$(document).on('change', 'table#OnboardingDocumentTable input[type=file],table#mk_brand-fee-collection-details input[type=file]', function () {
|
| 548 |
var file = this.files[0];
|
575 |
var input = this;
|
| 549 |
let fileInput = $(this);
|
576 |
var fileInput = $(input);
|
| 550 |
uploadDocument(file, function (documentId) {
|
577 |
var file = input.files && input.files[0];
|
| 551 |
fileInput.closest('td').find(".documentId").val(documentId);
|
578 |
fileInput.closest('td').find(".documentId").val('');
|
| 552 |
});
|
579 |
if (!file) {
|
| 553 |
}
|
580 |
return;
|
| 554 |
}
|
581 |
}
|
| - |
|
582 |
uploadDocument(file, function (documentId) {
|
| - |
|
583 |
fileInput.closest('td').find(".documentId").val(documentId);
|
| - |
|
584 |
}, function (message) {
|
| - |
|
585 |
input.value = '';
|
| - |
|
586 |
alert(message);
|
| - |
|
587 |
});
|
| 555 |
});
|
588 |
});
|
| 556 |
|
589 |
|
| 557 |
$(document).on('input', '#payment-sc-doc', function () {
|
590 |
$(document).on('change', '#payment-sc-doc', function () {
|
| 558 |
if (confirm('Confirm file upload ?')) {
|
591 |
var input = this;
|
| 559 |
var file = this.files[0];
|
592 |
var file = input.files && input.files[0];
|
| 560 |
uploadDocument(file, function (documentId) {
|
593 |
// A fresh pick invalidates whatever was uploaded before it.
|
| 561 |
$('#payment-sc-docId').val(documentId);
|
594 |
$('#payment-sc-docId').val('');
|
| - |
|
595 |
if (!file) {
|
| - |
|
596 |
paymentScreenshotUploading = false;
|
| - |
|
597 |
setPaymentScreenshotStatus('', '');
|
| 562 |
});
|
598 |
return;
|
| 563 |
}
|
599 |
}
|
| - |
|
600 |
paymentScreenshotUploading = true;
|
| - |
|
601 |
setPaymentScreenshotStatus('Uploading ' + file.name + ' ...', '');
|
| - |
|
602 |
uploadDocument(file, function (documentId) {
|
| - |
|
603 |
paymentScreenshotUploading = false;
|
| - |
|
604 |
$('#payment-sc-docId').val(documentId);
|
| - |
|
605 |
setPaymentScreenshotStatus('Attached: ' + file.name, 'text-success');
|
| - |
|
606 |
}, function (message) {
|
| - |
|
607 |
paymentScreenshotUploading = false;
|
| - |
|
608 |
input.value = '';
|
| - |
|
609 |
setPaymentScreenshotStatus('Not attached - please select the file again', 'text-danger');
|
| - |
|
610 |
alert(message);
|
| - |
|
611 |
});
|
| 564 |
});
|
612 |
});
|
| 565 |
|
613 |
|
| 566 |
|
614 |
|
| 567 |
$(document).on('click', ".mk_docApproval", function () {
|
615 |
$(document).on('click', ".mk_docApproval", function () {
|
| 568 |
let loiId = $(this).data('form_id');
|
616 |
let loiId = $(this).data('form_id');
|