Rev 34149 | Blame | Compare with Previous | Last modification | View Log | RSS feed
$(document).on('click', '.mk-brand-commitment-panal', function () {doGetAjaxRequestHandler(`${context}/brand-commitment-panel`, function (response) {$(`#main-content`).html(response);});});$(document).on('change', '#commitBrand', function () {let retailerId = $('#partnerId').val();let brand = $('#commitBrand').val();doGetAjaxRequestHandler(`${context}/partner-brand-commitment?retailerId=${retailerId}&brand=${brand}`, function (response) {console.log("brand commit response ", response);let docStatus = response.docStatus;let partnerBrandCommitmentModel = response.partnerBrandCommitmentModel;$('input[name="commitmentAmount"]').val(partnerBrandCommitmentModel.commitment);$('input[name="nocDocId"]').val(partnerBrandCommitmentModel.noc);$('#CommitmentIsActive').prop('checked', partnerBrandCommitmentModel.active);updateValue();const selectElement = document.getElementById('nocRequired');selectElement.innerHTML = '<option selected disabled>Select Status</option>';docStatus.forEach(status => {const option = document.createElement('option');option.value = status;option.textContent = status;if (status == partnerBrandCommitmentModel.docStatus) {option.selected = true;}selectElement.appendChild(option);});});});$(document).on('input', '#noc-doc-file', function () {if (confirm('Confirm file upload ?')) {var file = this.files[0];uploadDocument(file, function (documentId) {$('#noc-doc-id').val(documentId);});}});$(document).on('click', '#mk-submit-commitment', function () {let retailerId = $('#partnerId').val();let brand = $('#commitBrand').val();let commitment = $('input[name="commitmentAmount"]').val();let nocDoc = $('input[name="nocDocId"]').val();let docStatus = $('#nocRequired').val();let commitIsActive = $('#CommitmentIsActive').val();if (docStatus == "RECEIVED") {if (!nocDoc) {alert("Please upload Document");return;}}if (confirm("Are you sure to submit Commitment")) {doPostAjaxRequestHandler(`${context}/submit-commitment?retailerId=${retailerId}&brand=${brand}&commitment=${commitment}&nocDoc=${nocDoc}&docStatus=${docStatus}&active=${commitIsActive}`, function (response) {if (response) {alert("Commitment submit successfully");getAllCommitments(retailerId, function (commitment) {resetField();$('#brand-commitments-report').empty();$('#brand-commitments-report').html(commitment);});} else {alert("Commitment not submit, Please try again.");}});}});function getAllCommitments(retailerIdOrStoreCode, callback) {doGetAjaxRequestHandler(`${context}/partner-commitments?retailerIdOrStoreCode=${retailerIdOrStoreCode}`, function (commitment) {callback(commitment);});}function resetField() {$('#commitBrand').prop('selectedIndex', 0);$('input[name="commitmentAmount"]').val('');$('#noc-doc-id').val('');$('#noc-doc-file').val('');$('#nocRequired').prop('selectedIndex', 0);$('#CommitmentIsActive').prop('checked', false);}function updateValue() {const checkbox = document.getElementById('CommitmentIsActive');let value = checkbox.checked ? 'True' : 'False';$('#CommitmentIsActive').val(value);}