Rev 35252 | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
$(function() {$(document).on('click', ".create-scheme", function() {loadScheme("main-content");});$(document).on('click', ".scheme-details", function() {var schemeId = $(this).attr('data');console.log("schemeId = " + schemeId);loadSchemeDetails(schemeId, "scheme-details-container");});$(document).on('click', ".active-scheme", function() {var schemeId = $(this).attr('data');console.log("active-scheme id : " + schemeId);var start = $("#schemes-paginated .start").text();// var end = $( "#schemes-paginated .end" ).text();var offset = start - 1;if (confirm("Are you sure you want to Active Scheme!")) {activeScheme(schemeId, offset, "schemes-table");}});$(document).on('click', ".scheme-imei-history", function() {loadImeiWiseScheme("main-content");});$(document).on('click', ".expire-scheme", function() {var schemeId = $(this).attr('data');var expireDate = getDatesFromPicker('input[name="expireSchemeById"]').endDate;if (confirm("Are you sure you want to Expire Scheme!")) {expireScheme(schemeId, expireDate, "schemes-table");}});$(document).on('click', "#extendDatetime-button",function() {console.log("extendAll button click");var extendDatetime = getDatesFromPicker('input[name="extendDatetime"]').endDate;console.log("extendDatetime : " + extendDatetime);if (extendDatetime) {if (confirm("Are you sure you want to Extend expireDateTime for All Scheme!")) {extendAllScheme(extendDatetime);}} else {alert("feild can't be blank");}});$(document).on('click', "#extendScheme-button",function() {console.log("extend button click");var extendDatetime = getDatesFromPicker('input[name="extendSchemeById"]').endDate;var schemeId = $('#schemeId').val()console.log("extendDatetime : " + extendDatetime);console.log(schemeId);if (extendDatetime) {if (confirm("Are you sure you want to Extend expireDateTime for Scheme!") == true) {extendSchemeById(extendDatetime, schemeId);}} else {alert("field can't be blank");}});$(document).on('click', ".monthy-investment",function() {console.log("hello evaluateActualInvestmentPayout");window.location.href = context + "/evaluateActualInvestmentPayout";});$(document).on('click', ".process-investment", function() {if (confirm("Are you sure you want to Process Investment")) {processInvestment();}});$(document).on('click', ".processInvestmentDryRun",function() {console.log("processInvestmentDryRun");window.location.href = context + "/processInvestmentDryRun";});$(document).on('click', ".brand-wise-income",function() {var brand = $(this).data('brand');var status = $(this).data('status');var month = $(this).data('month');brandWiseIncome(brand, month, status);});$(document).on('click', ".imei_wise_income",function() {var catalogItemId = $(this).data('catalogitemid');var month = $(this).data('month');console.log(catalogItemId);imeiWiseIncome(catalogItemId, month);});$(document).on('change', "#month-wise-income", function() {var month = $(this).val();monthWiseIncome(month, "main-content");});$(document).on('click', ".schemes", function() {schemes("main-content");console.log("Active Schemes Button Clicked...")/*bootbox.confirm({message: "<div class = 'disclosurehindata'> <img src='resources/images/disclosure.png' style='width:100%'> </div>",buttons: {confirm: {label: 'I agree',className: 'btn-success'},cancel: {label: 'I disagree',className: 'btn-danger'}},callback: function (result) {if (result == true) {}}});*/});$(document).on('click', ".margin-calculator", function() {console.log("Active Schemes Button Clicked...")marginCalculator("main-content");});$(document).on('click', ".schemes-download-page", function() {console.log("Schemes Download Clicked...")loadSchemesDownloadPage("main-content");});$(document).on('click', ".schemes-update", function() {loadSchemeUpdatePage("main-content");});$(document).on('click', ".add-item", function() {var schemeIds = $("#schemeids").val();// Read from modal model multi-select if available, else fall back to text inputvar selectedModels = $(".modalCatalogItems").val();var catalogIds;if (selectedModels && selectedModels.length > 0) {catalogIds = selectedModels.join(",");} else {catalogIds = $("#catalogids").val();}if (!schemeIds || !catalogIds || catalogIds.trim().length === 0) {alert("Scheme ID and at least one Model are required");return;}// Filter out catalogs that already exist in the schemevar existingCatalogs = [];$('#scheme-details-container tr[data-catalogid]').each(function() {existingCatalogs.push(String($(this).data('catalogid')));});var requestedIds = catalogIds.split(",");var duplicates = requestedIds.filter(function(id) { return existingCatalogs.indexOf(id.trim()) >= 0; });var newIds = requestedIds.filter(function(id) { return existingCatalogs.indexOf(id.trim()) < 0; });if (newIds.length === 0) {alert("All selected models already exist in this scheme");return;}if (duplicates.length > 0) {alert("Skipping already existing catalog IDs: " + duplicates.join(", "));}catalogIds = newIds.join(",");if (confirm("Add " + newIds.length + " model(s) to Scheme?")) {updateSingleScheme(schemeIds, catalogIds);}});$(document).on('click', ".add-schemes", function() {let schemeIds = $("#schemeids").val();let catalogIds = $("#catalogids").val();if (confirm("Are you sure you want to Add Item to Scheme!") == true) {if (catalogIds.trim().length === 0 || schemeIds.trim().length === 0) {alert("fields shouldn't be blank");return;}updateSchemes(schemeIds, catalogIds);}});$(document).on('click', ".process-sellIn", function() {let purchaseInvoiceNumber=$("#invoiceNumbers1").val();if (confirm("Are you sure you want to Process SellIn") == true) {if (purchaseInvoiceNumber.trim().length === 0) {alert("fields shouldn't be blank");return;}processSellin(purchaseInvoiceNumber);}});$(document).on('click', ".process-sellOut", function() {let fofoOrderInvoiceNumber=$("#invoiceNumbers2").val();if (confirm("Are you sure you want to Process SellOut") == true) {if (fofoOrderInvoiceNumber.trim().length === 0) {alert("fields shouldn't be blank");return;}processSellout(fofoOrderInvoiceNumber);}});$(document).on('click', ".delete-schemes", function() {if (confirm("Delete model from Scheme?") == true) {schemeId = $(this).data('schemeid');catalogId = $(this).data('catalogid');deleteScheme(schemeId, catalogId);}});$(document).on('click', "#scheme-search-button",function() {var searchText = $("#scheme-search-text").val();if (typeof (searchText) == "undefined" || !searchText) {searchText = "";}doGetAjaxRequestHandler(context + "/getSchemes?searchScheme="+ searchText, function(response) {$('#' + "main-content").html(response);});});$(document).on("keyup", "#scheme-search-text", function(e) {var keyCode = e.keyCode || e.which;if (keyCode == 13) {$("#scheme-search-button").click();}});$(document).on('click', "#scheme-item-search-button", function() {var searchText = $("#scheme-item-search-text").val();var date = $(".schemes-date").val();if (typeof (searchText) == "undefined" || !searchText) {searchText = "";alert("please select item");return;}if (typeof currentItem != "undefined") {console.log(currentItem);loadSchemeItemSearchInfo(currentItem, date);} else {console.log("reeffff")alert("Data No Found")}});$(document).on('click', "#scheme-imei-search-button", function() {var searchText = $("#scheme-imei-search-text").val();var date = $(".schemes-date").val();if (typeof (searchText) == "undefined" || !searchText) {searchText = "";alert("please select imei");return;}if (typeof imei != "undefined") {console.log(imei);loadSchemeImeiSearchInfo(imei, date);} else {console.log("reeffff")alert("Data No Found")}});$(document).on('click', "#scheme-imei-wise-search-button", function() {var searchText = $("#scheme-imei-wise-search-text").val();var date = $(".schemes-date").val();if (typeof (searchText) === "undefined" || !searchText) {searchText = "";alert("please select imei");return;}if (typeof imei !== "undefined") {console.log(imei);var searchText = $("#scheme-imei-wise-search-text").val();if ((searchText)) {doGetAjaxRequestHandler(`${context}/getSchemesByImei?searchImei=${searchText}`, function(response) {$('#' + "main-content").html(response);$('#scheme-imei-search-text').val(searchText);});}} else {console.log("reeffff");alert("Data No Found");}});$(document).on('click', ".categoryWiseSchemeHistory",function() {var category = $('#partner-category').val();console.log(category);doGetAjaxRequestHandler(context + "/getSchemes?partnerType="+ category, function(response) {$('#' + "main-content").html(response);$('#partner-category').val(category);window.dispatchEvent(new Event('resize'));});});$(document).on("keyup", "#scheme-item-search-text", function(e) {var keyCode = e.keyCode || e.which;if (keyCode == 13) {$("#scheme-item-search-button").click();}});});function configureTagListingItemsDescriptionDropDown() {$('.catalogItemsDescription').multiselect({includeSelectAllOption: true,maxHeight: 200,buttonWidth: '180px',numberDisplayed: 1,nonSelectedText: 'Models',nSelectedText: ' - Models Selected',allSelectedText: 'All Models Selected',enableFiltering: true,enableCaseInsensitiveFiltering: true});}function schemesDownload() {let pickerData = getDatesFromPicker('input[name="startEndDateTime"]')doAjaxGetDownload(context + "/schemes/download?" +"startDateTime=" + pickerData.startDate+ "&endDateTime=" + pickerData.endDate,"SchemesReport.xlsx");}function selectedbrand(categoryId) {var brands = $('#tag-listing-brands').val();if (brands) {loadCatalogDescriptionByBrands("tag-listing-items-description-container", categoryId, brands);}}function categoryChanged() {let categoryId = $('#category-list').val();if (categoryId) {loadBrandsByCategory("brand-list", categoryId);}}function loadSchemeDetails(schemeId, domId) {doGetAjaxRequestHandler(context + "/getSchemeById?schemeId=" + schemeId,function(response) {$('#' + domId).html(response);window.dispatchEvent(new Event('resize'));});}function activeScheme(schemeId, offset, domId) {doPutAjaxRequestHandler(context + "/activeSchemeById?schemeId=" + schemeId+ "&offset=" + offset, function(response) {$('#' + domId).html(response);$('#scheme-details-container').html('');});}function expireScheme(schemeId, expireDate, domId) {doPutAjaxRequestHandler(context + "/expireSchemeById?schemeId=" + schemeId+ "&expireTimestamp=" + expireDate, function(response) {alert("Scheme - " + schemeId + " marked for expiry successfully!");$('#' + domId).html(response);$('#scheme-details-container').html('');});}function extendAllScheme(extendDate) {doPostAjaxRequestWithJsonHandler(context + "/extendAllSchemes", JSON.stringify(extendDate), function(response) {if (response == 'true') {alert("Scheme All Extended successfully");schemes("main-content");} else {alert("No scheme Activated Currently");schemes("main-content");}});}function extendSchemeById(extendDate, schemeId) {doPostAjaxRequestWithJsonHandler(context + "/extendSchemeById?schemeId="+ schemeId, JSON.stringify(extendDate), function(response) {if (response == 'true') {alert("Scheme extended successfully");schemes("main-content");} else {alert("Scheme already Expired");schemes("main-content");}});}function processInvestment() {doPostAjaxRequestWithJsonHandler(context + "/payMonthlyInvestment", function(response) {alert("InvestmentPayout processed successfully");});}function loadScheme(domId) {doGetAjaxRequestHandler(context + "/createScheme", function(response) {$('#' + domId).html(response);createSchemeOnReady();categoryChanged();$('input[name="dateRange"]').daterangepicker(getRangedDatePicker());});}function loadImeiWiseScheme(domId) {doGetAjaxRequestHandler(context + "/getSchemesByImei",function(response) {$('#' + domId).html(response);});}function loadCatalogDescriptionByBrands(domId, categoryId, brands) {let brandsString = brands.join(",")doGetAjaxRequestHandler(`${context}/getCatalogDescriptionByBrands?categoryId=${categoryId}&brands=${brandsString}`,function(response) {$('#' + domId).html(response);configureTagListingItemsDescriptionDropDown();});}function loadBrandsByCategory(domId, categoryId) {doGetAjaxRequestHandler(`${context}/getBrandsByCategory?categoryId=${categoryId}`,function(response) {$('#' + domId).html(response);configureBrandsDropDown();});}function schemes(domId) {doGetAjaxRequestHandler(context + "/getSchemes", function(response) {$('#' + domId).html(response);});}function marginCalculator(domId) {doGetAjaxRequestHandler(context + "/getMarginCalculator", function(response) {$('#' + domId).html(response);});}function loadSchemesDownloadPage(domId) {doGetAjaxRequestHandler(context + "/schemes/downloadPage", function(response) {$('#' + domId).html(response);});}function loadSchemeUpdatePage(domId) {doGetAjaxRequestHandler(context + "/schemes/update-schemes-page", function(response) {$('#' + domId).html(response);});}function brandWiseIncome(brand, month, status) {console.log(brand);console.log(month);doGetAjaxRequestHandler(`${context}/brandWiseIncome?brand=${brand}&month=${month}`, function (response) {$('.imei-wise-income-container').html('');$('.brand-wise-income-container').html(response);});}function monthWiseIncome(month, domId) {console.log(month);doGetAjaxRequestHandler(context + "/monthWisePartnerIncome/" + month, function(response) {console.log(response);$('#' + domId).html(response);})}function imeiWiseIncome(catalogItemId, month) {console.log(catalogItemId);console.log(month);doGetAjaxRequestHandler(context + "/getLastMonthImeiWiseIncome?catalogItemId=" + catalogItemId + "&month=" + month, function(response) {$('.imei-wise-income-container').html(response);});}function toIsoDateTime(ddmmyyyy, endOfDay) {var parts = ddmmyyyy.split('/');if (parts.length !== 3) return ddmmyyyy;var isoDate = parts[2] + '-' + parts[1] + '-' + parts[0];return isoDate + (endOfDay ? 'T23:59:59' : 'T00:00:00');}function updateSingleScheme(schemeIds, catalogIds) {var payload = {"catalogIds": catalogIds.split(",").map(Number),"schemeIds": schemeIds.split(",").map(Number)};var startDate = $('#addItemStartDate').val();var endDate = $('#addItemEndDate').val();if (startDate) payload.startDate = toIsoDateTime(startDate, false);if (endDate) payload.endDate = toIsoDateTime(endDate, true);doPostAjaxRequestWithJsonHandler(context + '/addItemToScheme', JSON.stringify(payload), function(response) {$('#newItemToSchemeModal').modal('hide');alert("Item Added to scheme successfully");loadSchemeDetails(schemeIds, "scheme-details-container");});}function updateSchemes(schemeIds, catalogIds) {doPostAjaxRequestWithJsonHandler(context + '/schemes/update', JSON.stringify({"catalogIds": catalogIds.split(",").map(Number),"schemeIds": schemeIds.split(",").map(Number)}), function(response) {if (response == 'true') {alert("Item Added to scheme successfully");// $('#newItemToSchemeModal').modal('hide');loadSchemeUpdatePage("main-content");}});}function processSellin(purchaseInvoiceNumber) {doPostAjaxRequestWithJsonHandler(context + "/schemes/process-sellin",JSON.stringify(purchaseInvoiceNumber.split(",").map(x=>x.trim())), function(response) {if (response) {alert("Invoices Processed Successfully");loadSchemeUpdatePage("main-content");}});}function processSellout(fofoOrderInvoiceNumber) {doPostAjaxRequestWithJsonHandler(context + "/schemes/process-sellout",JSON.stringify(fofoOrderInvoiceNumber.split(",").map(x=>x.trim())), function(response) {if (response) {alert("Invoices Processed Successfully");loadSchemeUpdatePage("main-content");}});}function deleteScheme(schemeId, catalogId) {doDeleteAjaxRequestHandler(context + "/schemes/delete?schemeId=" + schemeId+ "&catalogId=" + catalogId, function(response) {if (response == 'true') {alert("Model Deleted successfully from Scheme");loadSchemeDetails(schemeId, "scheme-details-container");}});}function loadSearchItemScheme(domId, selectedModel, date) {var searchText = $("#scheme-item-search-text").val();var category = $('#partner-category').val();if (typeof (searchText) == "undefined" || !searchText) {searchText = "";}if (typeof (category) == "undefined" || !category) {category = "";}if (searchText && category) {doGetAjaxRequestHandler(`${context}/getSchemes?searchModel=${selectedModel}&partnerType=${category}&date=${date}`, function(response) {$('#' + domId).html(response);$('#partner-category').val(category);});} else if (searchText) {doGetAjaxRequestHandler(`${context}/getSchemes?searchModel=${selectedModel}&date=${date}`, function(response) {$('#' + domId).html(response);$('#partner-category').val(category);});}}function loadSearchImeiScheme(domId, selected_imei, date) {var category = $('#partner-category').val();var searchText = $("#scheme-imei-search-text").val();var category = $('#partner-category').val();console.log(category)if (typeof (searchText) == "undefined" || !searchText) {searchText = "";}if (typeof (category) == "undefined" || !category) {category = "";}if ((searchText) && (category)) {doGetAjaxRequestHandler(context + "/getSchemes?searchImei="+ selected_imei + "&partnerType=" + category, function(response) {$('#' + domId).html(response);$('#partner-category').val(category);$('#scheme-imei-search-text').val(selected_imei);});} else if ((searchText)) {doGetAjaxRequestHandler(`${context}/getSchemes?searchImei=${selected_imei}&date=${date}`, function(response) {$('#' + domId).html(response);$('#scheme-imei-search-text').val(selected_imei);});}}function loadSchemeItemSearchInfo(selectedModel, date) {loadSearchItemScheme("main-content", selectedModel, date);}function loadSchemeImeiSearchInfo(selectedImei, date) {loadSearchImeiScheme("main-content", selectedImei, date);}$(document).on('click', ".mark-active", function() {let activeScheme=$("#activeSchemes").val();if (activeScheme.trim().length === 0) {alert("fields shouldn't be blank");return;}if (confirm("Are you sure you want to Active schemes?")) {console.log("activeScheme",activeScheme);doPutAjaxRequestHandler(context + "/activeSchemeByIds?schemeId=" + activeScheme, function(response) {if (response){$("#activeSchemes").val("");alert("schemes activated")}});}});$(document).on('click', ".mark-expire", function () {let expireSchemes = $("#expireSchemes").val();if (expireSchemes.trim().length === 0) {alert("fields shouldn't be blank");return;}if (confirm("Are you sure you want to expire schemes?")) {console.log("expireSchemes", expireSchemes);doPutAjaxRequestHandler(context + "/expireSchemeByIds?schemeId=" + expireSchemes, function (response) {if (response) {$("#expireSchemes").val("");alert("schemes expired")}});}});