Mr.Combet Webshell
Your IP :
216.73.216.136
Server IP :
103.233.58.157
Server :
Windows NT WIN-4PGF72KEHKB 10.0 build 17763 (Windows Server 2016) AMD64
Server Software :
Microsoft-IIS/10.0
PHP Version :
7.3.25
Add File :
Submit
Add Directory :
Submit
Dir :
C:
/
inetpub
/
wwwroot
/
map
/
Scripts
/
app
/
View File Name :
select.js
jQuery.fn.getSelectedItem = function () { var listItem = $(this[0]); return listItem.find("option:selected"); }; jQuery.fn.getSelectedValue = function () { return $(this[0]).getSelectedItem().val(); }; jQuery.fn.getSelectedText = function () { return $(this[0]).getSelectedItem().text(); }; jQuery.fn.setSelectedText = function (text) { var target = $(this).find("option").filter(function () { return this.text === text; }); target.prop('selected', true); }; function displayFieldBinder(el, url, notNull, filters, callback) { function request() { function getRequest() { return window.getAjaxRequest(url); } function postRequest() { var data = JSON.stringify(filters); return window.getAjaxRequest(url, "POST", data); } if (!filters) { return getRequest(); } return postRequest(); }; var ajax = request(); ajax.done(function (response) { var options = ""; if (!notNull) { options += "<option value> Select</option>"; } $.each(response, function (i) { var option = "<option value='{key}' {selected}>{value}</option>"; option = option.replace("{key}", this.Key); option = option.replace("{value}", this.Value); if (notNull && i === 0) { option = option.replace("{selected}", "selected='selected'"); } else { option = option.replace("{selected}", ""); } options += option; }); el.html(options); //setTimeout(function () { // el.trigger("change").trigger("blur"); //}); if (typeof (callback) === "function") { callback(); } }); } function initializeSelectApis(callback) { const candidates = $("select[data-api]"); candidates.each(function () { var el = $(this); const apiUrl = el.attr("data-api"); const valueField = el.attr("data-api-value-field") || "Value"; const keyField = el.attr("data-api-key-field") || "Key"; const isArray = el.attr("data-is-array") || false; const removePlaceholder = el.attr("data-remove-placeholder") === "true" || false; window.ajaxDataBind(apiUrl, el, null, keyField, valueField, null, function () { var selectedValue = el.attr("data-api-selected-value"); var selectedValues = el.attr("data-api-selected-values"); if (selectedValue) { el.val(selectedValue.toString()); } if (selectedValues) { const values = selectedValues.split(","); el.val(values); } if (selectedValue || selectedValues) { setTimeout(function () { el.trigger("change"); }, 500); } }, isArray, removePlaceholder); }); } function initializeSelectApis3(callback) { const candidates = $("select[data-api]"); candidates.each(function () { var el = $(this); const apiUrl = el.attr("data-api"); const valueField = el.attr("data-api-value-field") || "Value"; const keyField = el.attr("data-api-key-field") || "Key"; const isArray = el.attr("data-is-array") || false; const removePlaceholder = el.attr("data-remove-placeholder") === "true" || false; window.ajaxDataBind3(apiUrl, el, null, keyField, valueField, null, function () { var selectedValue = el.attr("data-api-selected-value"); var selectedValues = el.attr("data-api-selected-values"); if (selectedValue) { el.val(selectedValue.toString()); } if (selectedValues) { const values = selectedValues.split(","); el.val(values); } if (selectedValue || selectedValues) { setTimeout(function () { el.trigger("change"); }, 500); } }, isArray, removePlaceholder); }); } function initializeCascadeLocation() { $("#ProvinceId").off("change").on("change", function () { const provinceId = $(this).val(); const districtId = $("#DistrictId").val(); debugger const municipalityId = $("#MunicipalityId").val(); if (provinceId) { $("#DistrictId").val(''); $("#DistrictId").prop("disabled", false); if (districtId) { $("#MunicipalityId").val(''); $("#MunicipalityId").prop("disabled", false); } } else { $("#DistrictId").val(""); $("#DistrictId").prop("disabled", "disabled"); $("#MunicipalityId").val(''); $("#MunicipalityId").prop("disabled", "disabled"); }; displayFieldBinder($("#DistrictId"), "/districts/select?provinceId=" + provinceId, null, null, function () { const selectedValue = $("#ProvinceId").attr("data-api-selected-value"); if (selectedValue !== provinceId) { $("#DistrictId").attr("data-api-selected-value", ""); } if (selectedValue === provinceId) { $("#DistrictId").val(districtId.toString()); } $("#DistrictId").trigger("change"); }); displayFieldBinder($("#MunicipalityId"), "/municipality/select?provinceId=" + provinceId + "&districtId=" + districtId, null, null, function () { const selectedValue = $("#MunicipalityId").attr("data-api-selected-value"); if (selectedValue) { $("#MunicipalityId").val(selectedValue.toString()); } }); }); $("#DistrictId").off("change").on("change", function () { const provinceId = $("#ProvinceId").val(); const districtId = $(this).val(); const municipalityId = $("#MunicipalityId").attr("data-api-selected-value"); if (districtId) { $("#MunicipalityId").val(''); $("#MunicipalityId").prop("disabled", false); } else { $("#MunicipalityId").val(''); $("#MunicipalityId").prop("disabled", "disabled"); }; displayFieldBinder($("#MunicipalityId"), "/municipality/select?provinceId=" + provinceId + "&districtId=" + districtId, null, null, function () { const selectedValue = $("#DistrictId").attr("data-api-selected-value"); if (selectedValue !== districtId) { $("#MunicipalityId").attr("data-api-selected-value", ""); } if (selectedValue === districtId) { $("#MunicipalityId").val(municipalityId); } }); }); $("#ClassId").off("change").on("change", function () { const classId = $(this).val(); debugger const bankId = $("#BankNameId").attr("data-api-selected-value"); if (classId) { $("#BankNameId").val(''); $("#BankNameId").prop("disabled", false); } else { $("#BankNameId").val(''); $("#BankNameId").prop("disabled", "disabled"); }; displayFieldBinder($("#BankNameId"), "/banks-name-by-type/select?id=" + classId, null, null, function () { const selectedValue = $("#ClassId").attr("data-api-selected-value"); if (selectedValue !== classId) { $("#BankNameId").attr("data-api-selected-value", ""); } if (selectedValue === classId) { $("#BankNameId").val(bankId); } }); }); $("#BfTypeId").off("change").on("change", function () { const classId = $(this).val(); debugger const bankId = $("#BankId").attr("data-api-selected-value"); if (classId) { $("#BankId").val(''); $("#BankId").prop("disabled", false); } else { $("#BankId").val(''); $("#BankId").prop("disabled", "disabled"); }; displayFieldBinder($("#BankId"), "/banks-name-by-type/select?id=" + classId, null, null, function () { const selectedValue = $("#BfTypeId").attr("data-api-selected-value"); if (selectedValue !== classId) { $("#BankId").attr("data-api-selected-value", ""); } if (selectedValue === classId) { $("#BankId").val(bankId); } }); }); } function initializeCascadeLocationForTraining() { $("#TProvinceId").off("change").on("change", function () { const provinceId = $(this).val(); const districtId = $("#TDistrictId").val(); const municipalityId = $("#TMunicipalityId").val(); if (provinceId) { $("#TDistrictId").val(''); $("#TDistrictId").prop("disabled", false); if (districtId) { $("#TMunicipalityId").val(''); $("#TMunicipalityId").prop("disabled", false); } } else { $("#TDistrictId").val(""); $("#TDistrictId").prop("disabled", "disabled"); $("#TMunicipalityId").val(''); $("#TMunicipalityId").prop("disabled", "disabled"); }; displayFieldBinder($("#TDistrictId"), "/districts/select?provinceId=" + provinceId, null, null, function () { const selectedValue = $("#TProvinceId").attr("data-api-selected-value"); if (selectedValue !== provinceId) { $("#TDistrictId").attr("data-api-selected-value", ""); } if (selectedValue === provinceId) { $("#TDistrictId").val(districtId.toString()); } $("#TDistrictId").trigger("change"); }); displayFieldBinder($("#TMunicipalityId"), "/municipality/select?provinceId=" + provinceId + "&districtId=" + districtId, null, null, function () { const selectedValue = $("#TMunicipalityId").attr("data-api-selected-value"); if (selectedValue) { $("#TMunicipalityId").val(selectedValue.toString()); } }); }); $("#TDistrictId").off("change").on("change", function () { const provinceId = $("#TProvinceId").val(); const districtId = $(this).val(); const municipalityId = $("#TMunicipalityId").attr("data-api-selected-value"); if (districtId) { $("#TMunicipalityId").val(''); $("#TMunicipalityId").prop("disabled", false); } else { $("#TMunicipalityId").val(''); $("#TMunicipalityId").prop("disabled", "disabled"); }; displayFieldBinder($("#TMunicipalityId"), "/municipality/select?provinceId=" + provinceId + "&districtId=" + districtId, null, null, function () { const selectedValue = $("#TDistrictId").attr("data-api-selected-value"); if (selectedValue !== districtId) { $("#TMunicipalityId").attr("data-api-selected-value", ""); } if (selectedValue === districtId) { $("#TMunicipalityId").val(municipalityId); } }); }); } function initializeCascadeLocationForOther() { $("#ProvinceIdOther").off("change").on("change", function () { const provinceId = $(this).val(); const districtId = $("#DistrictIdOther").val(); const municipalityId = $("#MunicipalityIdOther").val(); if (provinceId) { $("#DistrictIdOther").val(''); $("#DistrictIdOther").prop("disabled", false); if (districtId) { $("#MunicipalityIdOther").val(''); $("#MunicipalityIdOther").prop("disabled", false); } } else { $("#DistrictIdOther").val(""); $("#DistrictIdOther").prop("disabled", "disabled"); $("#MunicipalityIdOther").val(''); $("#MunicipalityIdOther").prop("disabled", "disabled"); }; displayFieldBinder($("#DistrictIdOther"), "/districts/select?provinceId=" + provinceId, null, null, function () { const selectedValue = $("#ProvinceIdOther").attr("data-api-selected-value"); if (selectedValue !== provinceId) { $("#DistrictIdOther").attr("data-api-selected-value", ""); } if (selectedValue === provinceId) { $("#DistrictIdOther").val(districtId.toString()); } $("#DistrictIdOther").trigger("change"); }); displayFieldBinder($("#MunicipalityIdOther"), "/municipality/select?provinceId=" + provinceId + "&districtId=" + districtId, null, null, function () { const selectedValue = $("#MunicipalityId").attr("data-api-selected-value"); if (selectedValue) { $("#MunicipalityIdOther").val(selectedValue.toString()); } }); }); $("#DistrictIdOther").off("change").on("change", function () { const provinceId = $("#ProvinceIdOther").val(); const districtId = $(this).val(); const municipalityId = $("#MunicipalityIdOther").attr("data-api-selected-value"); if (districtId) { $("#MunicipalityIdOther").val(''); $("#MunicipalityIdOther").prop("disabled", false); } else { $("#MunicipalityIdOther").val(''); $("#MunicipalityIdOther").prop("disabled", "disabled"); }; displayFieldBinder($("#MunicipalityIdOther"), "/municipality/select?provinceId=" + provinceId + "&districtId=" + districtId, null, null, function () { const selectedValue = $("#DistrictIdOther").attr("data-api-selected-value"); if (selectedValue !== districtId) { $("#MunicipalityIdOther").attr("data-api-selected-value", ""); } if (selectedValue === districtId) { $("#MunicipalityIdOther").val(municipalityId); } }); }); } function initializeCascadeGroupWithLocation2() { $("#ProvinceId").off("change").on("change", function () { var provinceId = $("#HiddenProvince").val(); const pId = $("#HiddenProvince").val(); var districtId = $("#DistrictId").attr("data-api-selected-value"); var municipalityId = $("#MunicipalityId").attr("data-api-selected-value"); if (provinceId) { $("#MunicipalityId").val(''); $("#DistrictId").val(''); $("#DistrictId").prop("disabled", false); $("#MunicipalityId").prop("disabled", false); } else { municipalityId = ''; districtId = ''; $("#DistrictId").prop("disabled", "disabled"); $("#MunicipalityId").prop("disabled", "disabled"); }; displayFieldBinder2($("#DistrictId"), "/districts/select?provinceId=" + provinceId, null, null, function () { const selectedValue = $("#ProvinceId").attr("data-api-selected-value"); if (selectedValue !== provinceId) { $("#DistrictId").attr("data-api-selected-value", ""); } if (selectedValue === provinceId) { $("#DistrictId").val(districtId.toString()); } $("#DistrictId").trigger("change"); }); displayFieldBinder2($("#MunicipalityId"), "/municipality/select?provinceId=" + provinceId + "&districtId=" + districtId, null, null, function () { const selectedValue = $("#MunicipalityId").attr("data-api-selected-value"); if (selectedValue) { $("#MunicipalityId").val(selectedValue.toString()); } }); }); $("#DistrictId").off("change").on("change", function () { var provinceId = $("#ProvinceId").val(); var districtId = $(this).val(); var municipalityId = $("#MunicipalityId").attr("data-api-selected-value"); var commodityId = $("#CommodityId").val(); if (districtId) { $("#MunicipalityId").val(''); $("#MunicipalityId").prop("disabled", false); } else { municipalityId = ''; $("#MunicipalityId").val(''); $("#MunicipalityId").prop("disabled", "disabled"); }; displayFieldBinder2($("#MunicipalityId"), "/municipality/select?provinceId=" + provinceId + "&districtId=" + districtId, null, null, function () { const selectedValue = $("#DistrictId").attr("data-api-selected-value"); if (selectedValue !== districtId) { $("#MunicipalityId").attr("data-api-selected-value", ""); } if (selectedValue === districtId) { $("#MunicipalityId").val(municipalityId); } }); displayFieldBinder2($("#GroupId"), "/approved/female_group/select?districtId=" + districtId + "&municipalityId=" + municipalityId + "&commodityId=" + commodityId, null, null, function () { const selectedValue = $("#GroupId").attr("data-api-selected-value"); if (selectedValue) { $("#GroupId").val(selectedValue.toString()); } }); }); $("#MunicipalityId").off("change").on("change", function () { var provinceId = $("#ProvinceId").val(); var districtId = $("#DistrictId").val(); var municipalityId = $(this).val(); var commodityId = $("#CommodityId").val(); displayFieldBinder2($("#GroupId"), "/approved/female_group/select?districtId=" + districtId + "&municipalityId=" + municipalityId + "&commodityId=" + commodityId, null, null, function () { const selectedValue = $("#GroupId").attr("data-api-selected-value"); if (selectedValue) { $("#GroupId").val(selectedValue.toString()); } }); }); $("#CommodityId").off("change").on("change", function () { var provinceId = $("#ProvinceId").val(); var districtId = $("#DistrictId").val(); var municipalityId = $("#MunicipalityId").val(); var commodityId = $(this).val(); displayFieldBinder2($("#GroupId"), "/approved/female_group/select?districtId=" + districtId + "&municipalityId=" + municipalityId + "&commodityId=" + commodityId, null, null, function () { const selectedValue = $("#GroupId").attr("data-api-selected-value"); if (selectedValue) { $("#GroupId").val(selectedValue.toString()); } }); }); } function initializeCascadeGroup() { $("#ProvinceId").off("change").on("change", function () { const provinceId = $(this).val(); var districtId = $("#DistrictId").val(); var municipalityId = $("#MunicipalityId").val(); const groupId = $("#GroupId").val(); if (provinceId) { //When Province has a value then set district and municipality to 0 index and then open disabled from district and disable municipality $("#DistrictId").val(''); $("#DistrictId").prop("disabled", false); municipalityId = 0; districtId = 0; $("#MunicipalityId").val(''); $("#MunicipalityId").prop("disabled", true); $("#GroupId").val(''); $("#GroupId").prop("disabled", false); } else { $("#DistrictId").val(""); $("#DistrictId").prop("disabled", "disabled"); $("#MunicipalityId").val(''); $("#MunicipalityId").prop("disabled", "disabled"); }; displayFieldBinder($("#DistrictId"), "/districts/select?provinceId=" + provinceId, null, null, function () { //province is already selected above and set to value property and data-api-selected-value already has that const selectedValue = $("#ProvinceId").attr("data-api-selected-value"); if (selectedValue !== provinceId) { $("#DistrictId").attr("data-api-selected-value", ""); } //so , selectedValue is already equal to current ProvinceId if (selectedValue === provinceId) { $("#DistrictId").val(districtId.toString()); } // $("#DistrictId").trigger("change"); }); displayFieldBinder($("#MunicipalityId"), "/municipality/select?provinceId=" + provinceId + "&districtId=" + districtId, null, null, function () { const selectedValue = $("#MunicipalityId").attr("data-api-selected-value"); if (selectedValue) { $("#MunicipalityId").val(selectedValue.toString()); } }); displayFieldBinder($("#GroupId"), "/groups/select?provinceId=" + provinceId + "&districtId=" + districtId + "&municipalityId=" + municipalityId, null, null, function () { const selectedValue = $("#GroupId").attr("data-api-selected-value"); if (selectedValue) { $("#GroupId").val(selectedValue.toString()); } }); }); $("#DistrictId").off("change").on("change", function () { const provinceId = $("#ProvinceId").val(); const districtId = $(this).val(); var municipalityId = $("#MunicipalityId").val(); const groupId = $("#GroupId").attr("data-api-selected-value"); if (districtId) { $("#MunicipalityId").val(''); municipalityId = ''; $("#MunicipalityId").prop("disabled", false); $("#GroupId").val(''); $("#GroupId").prop("disabled", false); } else { $("#MunicipalityId").val(""); municipalityId = ''; $("#MunicipalityId").prop("disabled", "disabled"); $("#GroupId").val(''); $("#GroupId").prop("disabled", "disabled"); }; displayFieldBinder($("#MunicipalityId"), "/municipality/select?provinceId=" + provinceId + "&districtId=" + districtId, null, null, function () { const selectedValue = $("#DistrictId").attr("data-api-selected-value"); if (selectedValue !== districtId) { $("#MunicipalityId").attr("data-api-selected-value", ""); } if (selectedValue === districtId) { $("#MunicipalityId").val(municipalityId); } }); displayFieldBinder($("#GroupId"), "/groups/select?provinceId=" + provinceId + "&districtId=" + districtId + "&municipalityId=" + municipalityId, null, null, function () { const selectedValue = $("#DistrictId").attr("data-api-selected-value"); if (selectedValue === districtId) { $("#GroupId").val(groupId); } }); // $("#MunicipalityId").trigger("change"); }); $("#MunicipalityId").off("change").on("change", function () { var provinceId = $("#ProvinceId").val(); var districtId = $("#DistrictId").val(); var municipalityId = $(this).val(); var commodityId = $("#CommodityId").val(); displayFieldBinder($("#GroupId"), "/groups/select?provinceId=" + provinceId + "&districtId=" + districtId + "&municipalityId=" + municipalityId, null, null, function () { const selectedValue = $("#DistrictId").attr("data-api-selected-value"); if (selectedValue === districtId) { $("#GroupId").val(groupId); } }); }); } function initializeCascadeGroupBasedOnProvinceDistrictAndCommodity() { $("#ProvinceId").off("change").on("change", function () { const provinceId = $(this).val(); const districtId = $("#DistrictId").val(); const commodityIds = $("#SelectedCommodityIds").val(); const groupId = $("#GroupId").val(); if (provinceId) { $("#DistrictId").val(''); $("#DistrictId").prop("disabled", false); } else { $("#DistrictId").val(""); $("#DistrictId").prop("disabled", "disabled"); }; displayFieldBinder($("#DistrictId"), "/districts/select?provinceId=" + provinceId, null, null, function () { const selectedValue = $("#ProvinceId").attr("data-api-selected-value"); if (selectedValue !== provinceId) { $("#DistrictId").attr("data-api-selected-value", ""); } if (selectedValue === provinceId) { $("#DistrictId").val(districtId.toString()); } $("#DistrictId").trigger("change"); }); displayFieldBinder($("#GroupId"), "/groupss/select?provinceId=" + provinceId + "&districtId=" + districtId + "&commodityIds=" + commodityIds, null, null, function () { const selectedValue = $("#GroupId").attr("data-api-selected-value"); if (selectedValue) { $("#GroupId").val(selectedValue.toString()); } else { } }); }); $("#DistrictId").off("change").on("change", function () { const provinceId = $("#ProvinceId").val(); const districtId = $(this).val(); const commodityIds = $("#SelectedCommodityIds").val(); const groupId = $("#GroupId").attr("data-api-selected-value"); displayFieldBinder($("#GroupId"), "/groupss/select?provinceId=" + provinceId + "&districtId=" + districtId + "&commodityIds=" + commodityIds, null, null, function () { const selectedValue = $("#DistrictId").attr("data-api-selected-value"); if (selectedValue !== districtId) { $("#GroupId").attr("data-api-selected-value", ""); } if (selectedValue === districtId) { $("#GroupId").val(groupId); } }); }); $("#CommodityId").off("change").on("change", function () { const provinceId = $("#ProvinceId").val(); const commodityIds = $(this).val(); const districtId = $("#DistrictId").val(); const groupId = $("#GroupId").attr("data-api-selected-value"); if (SelectedCommodityIds) { $("#GroupId").val(''); $("#GroupId").prop("disabled", false); } else { $("#GroupId").val(''); $("#GroupId").prop("disabled", "disabled"); }; displayFieldBinder($("#GroupId"), "/groupss/select?provinceId=" + provinceId + "&districtId=" + districtId + "&commodityIds=" + commodityIds, null, null, function () { const selectedValue = $("#CommodityId").attr("data-api-selected-value"); if (selectedValue !== SelectedCommodityIds) { $("#GroupId").attr("data-api-selected-value", ""); } if (selectedValue === SelectedCommodityIds) { $("#GroupId").val(groupId); } }); }); } function initializeCommodityWiseCommoditySubTypeForExpense() { $("#CommodityExpense").off("change").on("change", function () { var categoryId = $('#CategoryExpense').val(); var expenseId = $("#ExpenseHead").val(); var commodityId = $('#CommodityExpense option:selected').val(); if (commodityId === '') { commodityId = 0; } $.ajax({ type: 'GET', url: '/commodity_subtype/select?commodityId=' + commodityId, success: function (result) { var s = '<option value="">Select</option>'; for (var i = 0; i < result.length; i++) { s += '<option' + (result[i].Key === categoryId ? ' selected' : '') + ' value="' + result[i].Key + '">' + result[i].Value + '</option>'; } $('#CategoryExpense').html(s); } }); $.ajax({ type: 'GET', url: '/commodity_wise_expense_head/select?commodityId=' + commodityId + '&isBaseline=' + 1, success: function (result) { console.clear(); console.log(result); var s = '<option value="">Select</option>'; for (var i = 0; i < result.length; i++) { s += '<option' + (result[i].Key === expenseId ? ' selected' : '') + ' value="' + result[i].Key + '">' + result[i].Value + '</option>'; } $('#ExpenseHead').html(s); } }) //$("#CategoryExpense").prop("disabled", false); //displayFieldBinder($("#CategoryExpense"), "/commodity_subtype/select?commodityId=" + commodityExpenseId , null, null, function () { // const selectedValue = $("#CommodityExpense").attr("data-api-selected-value"); // if (selectedValue !== commodityExpenseId) { // $("#CategoryExpense").attr("data-api-selected-value", ""); // } // if (selectedValue === commodityExpenseId) { // $("#CategoryExpense").val(categoryExpenseId); // } //}); //displayFieldBinder($("#ExpenseHead"), "/commodity_wise_expense_head/select?commodityId=" + commodityExpenseId + "&isBaseline=" + isBaseline, null, null, function () { // const selectedValue = $("#CommodityExpense").attr("data-api-selected-value"); // if (selectedValue !== commodityExpenseId) { // $("#ExpenseHead").attr("data-api-selected-value", ""); // } // if (selectedValue === commodityExpenseId) { // $("#ExpenseHead").val(expenseHead); // } //}); //displayFieldBinder($("#CommodityWiseUnit"), "/unit/commodity/select?commodityId=" + commodityExpenseId, null, null, function () { // const selectedValue = $("#CommodityExpense").attr("data-api-selected-value"); // if (selectedValue !== commodityExpenseId) { // $("#CommodityWiseUnit").attr("data-api-selected-value", ""); // } // if (selectedValue === commodityExpenseId) { // $("#CommodityWiseUnit").val(commodityWiseUnit); // } //}); }); } function initializeCommodityWiseCommoditySubTypeForExpensesFarmerDiary() { $("#CommodityExpense").off("change").on("change", function () { const commodityExpenseId = $(this).val(); const isBaseline = $("#IsBaseline").val(); const expenseHead = $("#ExpenseHead").attr("data-api-selected-value"); const categoryExpenseId = $("#CategoryExpense").attr("data-api-selected-value"); const commodityWiseUnit = $("#CommodityWiseUnit").attr("data-api-selected-value"); if (commodityExpenseId) { $("#CategoryExpense").val(''); $("#CategoryExpense").prop("disabled", false); $("#ExpenseHead").val(''); $("#ExpenseHead").prop("disabled", false); } else { $("#CategoryExpense").val(''); $("#CategoryExpense").prop("disabled", "disabled"); $("#ExpenseHead").val(''); $("#ExpenseHead").prop("disabled", "disabled"); }; $("#CategoryExpense").prop("disabled", false); displayFieldBinder($("#CategoryExpense"), "/commodity_subtype/select?commodityId=" + commodityExpenseId, null, null, function () { const selectedValue = $("#CommodityExpense").attr("data-api-selected-value"); if (selectedValue !== commodityExpenseId) { $("#CategoryExpense").attr("data-api-selected-value", ""); } if (selectedValue === commodityExpenseId) { $("#CategoryExpense").val(categoryExpenseId); } }); displayFieldBinder($("#ExpenseHead"), "/commodity_wise_expense_head/select?commodityId=" + commodityExpenseId + "&isBaseline=" + isBaseline, null, null, function () { const selectedValue = $("#CommodityExpense").attr("data-api-selected-value"); if (selectedValue !== commodityExpenseId) { $("#ExpenseHead").attr("data-api-selected-value", ""); } if (selectedValue === commodityExpenseId) { $("#ExpenseHead").val(expenseHead); } }); displayFieldBinder($("#CommodityWiseUnit"), "/unit/commodity/select?commodityId=" + commodityExpenseId, null, null, function () { const selectedValue = $("#CommodityExpense").attr("data-api-selected-value"); if (selectedValue !== commodityExpenseId) { $("#CommodityWiseUnit").attr("data-api-selected-value", ""); } if (selectedValue === commodityExpenseId) { $("#CommodityWiseUnit").val(commodityWiseUnit); } }); }); } function initializeCommodityWiseCommoditySubTypeForIncome() { $('#CommodityIncome').on('change', function () { var catId = $('#CategoryIdIncome').val(); var Id = $('#CommodityIncome option:selected').val(); var quantityUnit = $('#IncomeUnit').val(); if (Id === '') { Id = 0; } $.ajax({ type: 'GET', url: '/commodity_subtype/select?commodityId=' + Id, success: function (result) { var s = '<option value="">Select</option>'; for (var i = 0; i < result.length; i++) { s += '<option' + (result[i].Key === catId ? ' selected' : '') + ' value="' + result[i].Key + '">' + result[i].Value + '</option>'; } $('#CategoryIdIncome').html(s); } }) $.ajax({ type: 'GET', url: '/commodity_wise_unit/select/' + Id, success: function (result) { console.log("called"); console.log(result); console.log(quantityUnit); var s = '<option value="">Select</option>'; for (var i = 0; i < result.length; i++) { s += '<option' + (result[i].Key === quantityUnit ? ' selected' : '') + ' value="' + result[i].UnitId + '">' + result[i].UnitName + '</option>'; } $('#IncomeUnit').html(s); } }) }); } function initializeCommodityWiseCommoditySubTypeForProductionTab() { $("#CommodityForProductionTab").off("change").on("change", function () { const commodityIncomeId = $(this).val(); const categoryIncomeId = $("#CategoryForProductionTab").attr("data-api-selected-value"); var quantityUnit = $('#ProductionQuantityUnit').val(); if (commodityIncomeId) { $("#CategoryForProductionTab").val(''); $("#CategoryForProductionTab").prop("disabled", false); } else { $("#CategoryForProductionTab").val(''); $("#CategoryForProductionTab").prop("disabled", "disabled"); }; $("#CategoryForProductionTab").prop("disabled", false); displayFieldBinder($("#CategoryForProductionTab"), "/commodity_subtype/select?commodityId=" + commodityIncomeId, null, null, function () { const selectedValue = $("#CommodityForProductionTab").attr("data-api-selected-value"); if (selectedValue !== commodityIncomeId) { $("#CategoryForProductionTab").attr("data-api-selected-value", ""); } if (selectedValue === commodityIncomeId) { $("#CategoryForProductionTab").val(categoryIncomeId); } }); $.ajax({ type: 'GET', url: '/commodity_wise_unit/select/' + commodityIncomeId, success: function (result) { console.log(result); var s = '<option value="">Select</option>'; for (var i = 0; i < result.length; i++) { s += '<option' + (result[i].Key === quantityUnit ? ' selected' : '') + ' value="' + result[i].UnitId + '">' + result[i].UnitName + '</option>'; } $('#ProductionQuantityUnit').html(s); } }) }); } function initializeCasecadeAssetsWiseUnits() { $("#AssetTypeId").off("change").on("change", function () { const assetTypeId = $(this).val(); const unitIds = $("#UnitId").val(); var assetUnitId = $("#AssetUnitId").val(); if (assetTypeId) { console.log(assetTypeId) $("#UnitId").prop("disabled", false); } else { console.log(assetTypeId) $("#UnitId").val(''); $("#UnitId").prop("disabled", "disabled"); } $.ajax({ type: 'GET', url: '/unit/asset?assetsId=' + assetTypeId, success: function (result) { console.clear(); console.log(result); var s = '<option value="">Select</option>'; for (var i = 0; i < result.length; i++) { s += '<option' + (result[i].Key === assetUnitId ? ' selected' : '') + ' value="' + result[i].Key + '">' + result[i].Value + '</option>'; } $('#UnitId').html(s); } }) }); } function initializeMoneyFieldCascade() { $("#TypeId").off("change").on("change", function () { const typeId = $(this).val(); const moneyFieldId = $("#MoneyFieldId").attr("data-api-selected-value"); if (typeId) { $("#MoneyFieldId").val(''); $("#MoneyFieldId").prop("disabled", false); } else { $("#MoneyFieldId").val(''); $("#MoneyFieldId").prop("disabled", "disabled"); } displayFieldBinder($("#MoneyFieldId"), "/money_field/select?typeId=" + typeId, null, null, function () { const selectedValue = $("#TypeId").attr("data-api-selected-value"); if (selectedValue !== typeId) { $("#MoneyFieldId").attr("data-api-selected-value", ""); } if (selectedValue === typeId) { $("#MoneyFieldId").val(moneyFieldId); } }); }); } function initializeCasecadeMembers() { $("#PId").off("change").on("change", function () { const provinceId = $(this).val(); const districtId = $("#DId").val(); const commodityId = $("#CId").val(); if (provinceId) { $("#DId").val(''); $("#DId").prop("disabled", false); $("#CId").prop("disabled", false); if (districtId) { $("#CId").val(''); $("#CId").prop("disabled", false); } } else { $("#DId").val(""); $("#DId").prop("disabled", "disabled"); $("#CId").val(''); $("#CId").prop("disabled", "disabled"); } displayFieldBinder($("#DId"), "/districts/select?provinceId=" + provinceId, null, null, function () { const selectedValue = $("#PId").attr("data-api-selected-value"); if (selectedValue !== provinceId) { $("#DId").attr("data-api-selected-value", ""); } if (selectedValue === provinceId) { $("#DId").val(districtId.toString()); } $("#DId").trigger("change"); $("#CId").trigger("change"); }); displayFieldBinder($("#GId"), "/groups/commodity/select?provinceId=" + provinceId + "&districtId=" + districtId + "&commodityId=" + commodityId, null, null, function () { const selectedValue = $("#GId").attr("data-api-selected-value"); if (selectedValue) { $("#GId").val(selectedValue.toString()); } }); }); $("#DId").off("change").on("change", function () { $("#CId").trigger("change"); }); $("#CId").off("change").on("change", function () { const provinceId = $("#PId").val(); const districtId = $("#DId").val(); const commodityId = $(this).val(); const groupId = $("#GId").attr("data-api-selected-value"); if (districtId) { $("#GId").val(''); $("#GId").prop("disabled", false); } else { $("#GId").val(''); $("#GId").prop("disabled", "disabled"); } displayFieldBinder($("#GId"), "/groups/commodity/select?provinceId=" + provinceId + "&districtId=" + districtId + "&commodityId=" + commodityId, null, null, function () { const selectedValue = $("#CId").attr("data-api-selected-value"); if (selectedValue !== commodityId) { $("#GId").attr("data-api-selected-value", ""); } if (selectedValue === commodityId) { $("#GId").val(groupId); } }); }); $("#GId").off("change").on("change", function () { const groupId = $(this).val(); const memberId = $("#MemberId").attr("data-api-selected-value"); if (groupId) { $("#MemberId").val(''); $("#MemberId").prop("disabled", false); } else { $("#MemberId").val(''); $("#MemberId").prop("disabled", "disabled"); } displayFieldBinder($("#MemberId"), "/groups/members/select?groupId=" + groupId, null, null, function () { const selectedValue = $("#GId").attr("data-api-selected-value"); if (selectedValue !== groupId) { $("#MemberId").attr("data-api-selected-value", ""); } if (selectedValue === groupId) { $("#MemberId").val(memberId); } }); }); } function initializeCascadeLocation2() { $("#ProvinceId").off("change").on("change", function () { const provinceId = $(this).val(); const districtId = $("#DistrictId").val(); const municipalityId = $("#MunicipalityId").val(); if (provinceId) { $("#DistrictId").val(''); $("#DistrictId").prop("disabled", false); if (districtId) { $("#MunicipalityId").val(''); $("#MunicipalityId").prop("disabled", false); } } else { $("#DistrictId").val(""); $("#DistrictId").prop("disabled", "disabled"); $("#MunicipalityId").val(''); $("#MunicipalityId").prop("disabled", "disabled"); }; displayFieldBinder2($("#DistrictId"), "/districts/select?provinceId=" + provinceId, null, null, function () { const selectedValue = $("#ProvinceId").attr("data-api-selected-value"); if (selectedValue !== provinceId) { $("#DistrictId").attr("data-api-selected-value", ""); } if (selectedValue === provinceId) { $("#DistrictId").val(districtId.toString()); } $("#DistrictId").trigger("change"); }); displayFieldBinder2($("#MunicipalityId"), "/municipality/select?provinceId=" + provinceId + "&districtId=" + districtId, null, null, function () { const selectedValue = $("#MunicipalityId").attr("data-api-selected-value"); if (selectedValue) { $("#MunicipalityId").val(selectedValue.toString()); } }); }); $("#DistrictId").off("change").on("change", function () { const provinceId = $("#ProvinceId").val(); const districtId = $(this).val(); const municipalityId = $("#MunicipalityId").attr("data-api-selected-value"); if (districtId) { $("#MunicipalityId").val(''); $("#MunicipalityId").prop("disabled", false); } else { $("#MunicipalityId").val(''); $("#MunicipalityId").prop("disabled", "disabled"); }; displayFieldBinder2($("#MunicipalityId"), "/municipality/select?provinceId=" + provinceId + "&districtId=" + districtId, null, null, function () { const selectedValue = $("#DistrictId").attr("data-api-selected-value"); if (selectedValue !== districtId) { $("#MunicipalityId").attr("data-api-selected-value", ""); } if (selectedValue === districtId) { $("#MunicipalityId").val(municipalityId); } }); }); } function initializeCascadeGroupOrCommodity() { $("#ProvinceId").off("change").on("change", function () { const provinceId = $(this).val(); const districtId = $("#DistrictId").val(); const commodityId = $("#CommodityId").val(); const groupId = $("#GroupId").attr("data-api-selected-value"); if (provinceId) { $("#DistrictId").val(''); $("#DistrictId").prop("disabled", false); if (districtId) { //$("#GroupId").val(''); //$("#GroupId").prop("disabled", false); } } else { $("#DistrictId").val(""); $("#DistrictId").prop("disabled", "disabled"); //$("#GroupId").val(''); //$("#GroupId").prop("disabled", "disabled"); }; displayFieldBinder2($("#DistrictId"), "/districts/select?provinceId=" + provinceId, null, null, function () { const selectedValue = $("#ProvinceId").attr("data-api-selected-value"); if (selectedValue !== provinceId) { $("#DistrictId").attr("data-api-selected-value", ""); } if (selectedValue === provinceId) { $("#DistrictId").val(districtId.toString()); } $("#DistrictId").trigger("change"); }); displayFieldBinder2($("#GroupId"), "/groupss/select?provinceId=" + provinceId + "&districtId=" + districtId + "&commodityId=" + commodityId, null, null, function () { const selectedValue = $("#CommodityId").attr("data-api-selected-value"); if (selectedValue) { $("#GroupId").val(selectedValue.toString()); } }); }); $("#DistrictId").off("change").on("change", function () { const provinceId = $("#ProvinceId").val(); const districtId = $(this).val(); const commodityId = $("#CommodityId").val(); const groupId = $("#GroupId").attr("data-api-selected-value"); console.log(commodityId); //if (districtId) { // $("#GroupId").val(''); // $("#GroupId").prop("disabled", false); //} else { // $("#GroupId").val(''); // $("#GroupId").prop("disabled", "disabled"); //}; displayFieldBinder2($("#GroupId"), "/groupss/select?provinceId=" + provinceId + "&districtId=" + districtId + "&commodityId=" + commodityId, null, null, function () { const selectedValue = $("#CommodityId").attr("data-api-selected-value"); if (selectedValue !== districtId) { $("#GroupId").attr("data-api-selected-value", ""); } if (selectedValue === districtId) { $("#GroupId").val(groupId); } }); }); $("#CommodityId").off("change").on("change", function () { debugger const provinceId = $("#ProvinceId").val(); const districtId = $("#DistrictId").val(); const commodityId = $(this).val(); const groupId = $("#GroupId").attr("data-api-selected-value"); // alert(commodityId); if (districtId) { $("#GroupId").val(''); $("#GroupId").prop("disabled", false); } else { $("#GroupId").val(''); $("#GroupId").prop("disabled", "disabled"); }; displayFieldBinder2($("#GroupId"), "/groupss/select?provinceId=" + provinceId + "&districtId=" + districtId + "&commodityId=" + commodityId, null, null, function () { const selectedValue = $("#CommodityId").attr("data-api-selected-value"); if (selectedValue !== districtId) { $("#GroupId").attr("data-api-selected-value", ""); } if (selectedValue === districtId) { $("#GroupId").val(groupId); } }); }); } function initializeCascadeLocation3() { $("#ProvinceId").off("change").on("change", function () { const provinceId = $(this).val(); const districtId = $("#DistrictId").val(); const municipalityId = $("#MunicipalityId").val(); $("#ProvinceId").prop("disabled", true); if (provinceId) { $("#DistrictId").val(''); $("#DistrictId").prop("disabled", true); if (districtId) { $("#MunicipalityId").val(''); $("#MunicipalityId").prop("disabled", false); } } else { $("#DistrictId").val(""); $("#DistrictId").prop("disabled", "disabled"); $("#MunicipalityId").val(''); $("#MunicipalityId").prop("disabled", "disabled"); }; displayFieldBinder($("#DistrictId"), "/districts/select?provinceId=" + provinceId, null, null, function () { const selectedValue = $("#ProvinceId").attr("data-api-selected-value"); if (selectedValue !== provinceId) { $("#DistrictId").attr("data-api-selected-value", ""); } if (selectedValue === provinceId) { $("#DistrictId").val(districtId.toString()); } $("#DistrictId").trigger("change"); }); displayFieldBinder($("#MunicipalityId"), "/municipality/select?provinceId=" + provinceId + "&districtId=" + districtId, null, null, function () { const selectedValue = $("#MunicipalityId").attr("data-api-selected-value"); if (selectedValue) { $("#MunicipalityId").val(selectedValue.toString()); } }); }); } function displayFieldBinder2(el, url, notNull, filters, callback) { function request() { function getRequest() { return window.getAjaxRequest(url); } function postRequest() { var data = JSON.stringify(filters); return window.getAjaxRequest(url, "POST", data); } if (!filters) { return getRequest(); } return postRequest(); }; var ajax = request(); ajax.done(function (response) { var options = ""; if (!notNull) { options += "<option value>Select All</option>"; } $.each(response, function (i) { var option = "<option value='{key}' {selected}>{value}</option>"; option = option.replace("{key}", this.Key); option = option.replace("{value}", this.Value); if (notNull && i === 0) { option = option.replace("{selected}", "selected='selected'"); } else { option = option.replace("{selected}", ""); } options += option; }); el.html(options); //setTimeout(function () { // el.trigger("change").trigger("blur"); //}); if (typeof (callback) === "function") { callback(); } }); } function initializeSelectApis2(callback) { const candidates = $("select[data-api]"); //$("#ProvinceId option[value='']").text("Change Value"); candidates.each(function () { var el = $(this); const apiUrl = el.attr("data-api"); const valueField = el.attr("data-api-value-field") || "Value"; const keyField = el.attr("data-api-key-field") || "Key"; const isArray = el.attr("data-is-array") || false; const removePlaceholder = el.attr("data-remove-placeholder") === "true" || false; window.ajaxDataBind2(apiUrl, el, null, keyField, valueField, null, function () { var selectedValue = el.attr("data-api-selected-value"); var selectedValues = el.attr("data-api-selected-values"); if (selectedValue) { el.val(selectedValue.toString()); } if (selectedValues) { const values = selectedValues.split(","); el.val(values); } if (selectedValue || selectedValues) { setTimeout(function () { el.trigger("change"); }, 500); } }, isArray, removePlaceholder); }); } function initializeCascadeComponent() { $("#ComponentId").off("change").on("change", function () { const componentId = $(this).val(); const subComponentId = $("#SubComponentId").attr("data-api-selected-value"); const activityCategoryId = $("#ActivityCategoryId").attr("data-api-selected-value"); if (componentId) { $("#SubComponentId").val(''); $("#SubComponentId").prop("disabled", false); if (subComponentId) { //$("#ActivityCategoryId").val(''); //$("#ActivityCategoryId").prop("disabled", false); } } else { $("#SubComponentId").val(""); $("#SubComponentId").prop("disabled", "disabled"); $("#ActivityCategoryId").val(''); $("#ActivityCategoryId").prop("disabled", "disabled"); } displayFieldBinder($("#SubComponentId"), "/sub-component/select?componentId=" + componentId, null, null, function () { const selectedValue = $("#ComponentId").attr("data-api-selected-value"); if (selectedValue !== componentId) { $("#SubComponentId").attr("data-api-selected-value", ""); } if (selectedValue === componentId) { $("#SubComponentId").val(subComponentId); } $("#SubComponentId").trigger("change"); }); //displayFieldBinder($("#ActivityCategoryId"), "/activity-category/select?subComponentId=" + subComponentId, null, null, function () { // const selectedValue = $("#ActivityCategoryId").attr("data-api-selected-value"); // if (selectedValue) { // $("#ActivityCategoryId").val(selectedValue.toString()); // } //}); }); $("#SubComponentId").off("change").on("change", function () { const component = $("#ComponentId").val(); const subComponent = $(this).val(); //const activityCategory = $("#ActivityCategoryId").attr("data-api-selected-value"); const activity = $("#ActivityId").attr("data-api-selected-value"); if (subComponent) { $("#ActivityId").val(''); $("#ActivityId").prop("disabled", false); } else { $("#ActivityId").val(''); $("#ActivityId").prop("disabled", "disabled"); } //displayFieldBinder($("#ActivityCategoryId"), "/activity-category/select?subComponentId=" + subComponent , null, null, function () { // const selectedValue = $("#SubComponentId").attr("data-api-selected-value"); // if (selectedValue !== subComponent) { // $("#ActivityCategoryId").attr("data-api-selected-value", ""); // } // if (selectedValue === subComponent) { // $("#ActivityCategoryId").val(activityCategory); // } //}); displayFieldBinder($("#ActivityId"), "/activity-by-category/select?subComponentId=" + subComponent, null, null, function () { const selectedValue = $("#SubComponentId").attr("data-api-selected-value"); if (selectedValue !== subComponent) { $("#ActivityId").attr("data-api-selected-value", ""); } if (selectedValue === subComponent) { $("#ActivityId").val(activity); } }); }); //$("#ActivityCategoryId").off("change").on("change", function () { // const activityCategory = $(this).val(); // const activity = $("#ActivityId").attr("data-api-selected-value"); // if (activityCategory) { // $("#ActivityId").val(''); // $("#ActivityId").prop("disabled", false); // } else { // $("#ActivityId").val(''); // $("#ActivityId").prop("disabled", "disabled"); // } // displayFieldBinder($("#ActivityId"), "/activity-by-category/select?activityCategoryId=" + activityCategory, null, null, function () { // const selectedValue = $("#ActivityCategoryId").attr("data-api-selected-value"); // if (selectedValue !== activityCategory) { // $("#ActivityId").attr("data-api-selected-value", ""); // } // if (selectedValue === activityCategory) { // $("#ActivityId").val(activity); // } // }); //}); } function initializeCasecadeMembersForStoryCase() { $("#CommodityId").off("change").on("change", function () { const commodityId = $(this).val(); const groupId = $("#GroupId").attr("data-api-selected-value"); //if (commodityId) { // $("#GroupId").val(''); // $("#GroupId").prop("disabled", false); //} else { // $("#GroupId").val(''); // $("#GroupId").prop("disabled", "disabled"); //} displayFieldBinder($("#GroupId"), "/groups/commodity?commodityId=" + commodityId, null, null, function () { const selectedValue = $("#CommodityId").attr("data-api-selected-value"); if (selectedValue !== commodityId) { $("#GroupId").attr("data-api-selected-value", ""); } if (selectedValue === commodityId) { $("#GroupId").val(groupId); } $("#GroupId").trigger("change"); }); }); $("#GroupId").off("change").on("change", function () { const groupId = $(this).val(); const memberId = ($("#MemberIds").val()).split(","); //if (groupId) { // $("#MemberId").val(''); // $("#MemberId").prop("disabled", false); //} else { // $("#MemberId").val(''); // $("#MemberId").prop("disabled", "disabled"); //} displayFieldBinder($("#MemberId"), "/groups/members/kms-select?groupId=" + groupId, null, null, function () { const selectedValue = $("#GroupId").attr("data-api-selected-value"); if (selectedValue === groupId) { $("#MemberId").val(memberId); } }); }); }