| Line 148... |
Line 148... |
| 148 |
$(".scheme-imei-history-view").hide();
|
148 |
$(".scheme-imei-history-view").hide();
|
| 149 |
$(".fofo-summry-view").show();
|
149 |
$(".fofo-summry-view").show();
|
| 150 |
});
|
150 |
});
|
| 151 |
|
151 |
|
| 152 |
|
152 |
|
| - |
|
153 |
// Variables for modal search
|
| - |
|
154 |
var modalCurrentItem = null;
|
| - |
|
155 |
var modalFofoId = null;
|
| - |
|
156 |
|
| 153 |
// IMEI Margin (Scheme IMEI History) handlers
|
157 |
// IMEI Margin (Scheme IMEI History) handlers
|
| 154 |
$(document).on('click', '.scheme-imei-history-btn', function () {
|
158 |
$(document).on('click', '.scheme-imei-history-btn', function () {
|
| 155 |
let fofoId = $(this).data("fofoid");
|
159 |
modalFofoId = $(this).data("fofoid");
|
| 156 |
|
160 |
|
| 157 |
// Load the scheme-imei-history view (empty initially, user will search)
|
161 |
// Load the scheme-imei-history view (empty initially, user will search)
|
| 158 |
doGetAjaxRequestHandler(`${context}/getSchemesByImei?searchImei=&modal=true`, function (response) {
|
162 |
doGetAjaxRequestHandler(`${context}/getImeiMarginModal?searchImei=&fofoId=${modalFofoId}`, function (response) {
|
| 159 |
$(".today-fofo-offer-view").hide();
|
163 |
$(".today-fofo-offer-view").hide();
|
| 160 |
$(".fofo-summry-view").hide();
|
164 |
$(".fofo-summry-view").hide();
|
| 161 |
$(".scheme-imei-history-view").show();
|
165 |
$(".scheme-imei-history-view").show();
|
| 162 |
$('.scheme-imei-history-view').html(response);
|
166 |
$('.scheme-imei-history-view').html(response);
|
| 163 |
|
167 |
|
| 164 |
// Initialize IMEI autocomplete if available
|
168 |
// Initialize IMEI autocomplete if available
|
| 165 |
if (typeof getAllImeiAheadOptions === 'function') {
|
169 |
if (typeof getAllImeiAheadOptions === 'function') {
|
| 166 |
getAllImeiAheadOptions($("#scheme-imei-wise-search-text"), function (inventoryItem) {
|
170 |
getImeiAheadOptions($("#modal-imei-search-text"), modalFofoId, function (inventoryItem) {
|
| 167 |
// Trigger search when item selected from autocomplete
|
171 |
// Trigger search when item selected from autocomplete
|
| 168 |
});
|
172 |
});
|
| 169 |
}
|
173 |
}
|
| - |
|
174 |
|
| - |
|
175 |
// Initialize model autocomplete for modal
|
| - |
|
176 |
initModalModelAutocomplete();
|
| 170 |
});
|
177 |
});
|
| 171 |
});
|
178 |
});
|
| 172 |
|
179 |
|
| - |
|
180 |
// Initialize model autocomplete in modal
|
| - |
|
181 |
function initModalModelAutocomplete() {
|
| - |
|
182 |
modalCurrentItem = null;
|
| - |
|
183 |
if (typeof getEntityAheadOptions === 'function') {
|
| - |
|
184 |
getEntityAheadOptions($("#modal-model-search-text"), function (selectedItem) {
|
| - |
|
185 |
modalCurrentItem = selectedItem.catalogId_i;
|
| - |
|
186 |
});
|
| - |
|
187 |
}
|
| - |
|
188 |
}
|
| - |
|
189 |
|
| 173 |
// Search IMEI margin on button click within modal
|
190 |
// Search IMEI margin on button click within modal
|
| 174 |
$(document).on('click', '#scheme-imei-wise-search-button', function () {
|
191 |
$(document).on('click', '#modal-imei-search-button', function () {
|
| 175 |
let imei = $("#scheme-imei-wise-search-text").val().trim();
|
192 |
let imei = $("#modal-imei-search-text").val().trim();
|
| 176 |
if (imei) {
|
193 |
if (imei) {
|
| 177 |
searchImeiMarginInModal(imei);
|
194 |
searchImeiMarginInModal(imei);
|
| 178 |
} else {
|
195 |
} else {
|
| 179 |
alert("Please enter IMEI number");
|
196 |
alert("Please enter IMEI number");
|
| 180 |
}
|
197 |
}
|
| 181 |
});
|
198 |
});
|
| 182 |
|
199 |
|
| - |
|
200 |
// Search Model margin on button click within modal
|
| - |
|
201 |
$(document).on('click', '#modal-model-search-button', function () {
|
| - |
|
202 |
let searchText = $("#modal-model-search-text").val().trim();
|
| - |
|
203 |
let date = $(".modal-schemes-date").val();
|
| - |
|
204 |
|
| - |
|
205 |
if (!searchText) {
|
| - |
|
206 |
alert("Please select a model");
|
| - |
|
207 |
return;
|
| - |
|
208 |
}
|
| - |
|
209 |
|
| - |
|
210 |
if (modalCurrentItem) {
|
| - |
|
211 |
searchModelMarginInModal(modalCurrentItem, date);
|
| - |
|
212 |
} else {
|
| - |
|
213 |
alert("Please select a valid model from suggestions");
|
| - |
|
214 |
}
|
| - |
|
215 |
});
|
| - |
|
216 |
|
| - |
|
217 |
// Function to search and load model-wise margin details in modal
|
| - |
|
218 |
function searchModelMarginInModal(catalogId, date) {
|
| - |
|
219 |
const loaderHtml = `
|
| - |
|
220 |
<center><div class="loader-wrapper" style="padding: 50px;">
|
| - |
|
221 |
<i class="fa fa-spinner fa-spin fa-3x"></i>
|
| - |
|
222 |
<p style="margin-top: 15px;">Loading model margin details...</p>
|
| - |
|
223 |
</div></center>`;
|
| - |
|
224 |
|
| - |
|
225 |
// Hide IMEI results, show Model results container
|
| - |
|
226 |
$('.modal-imei-margin-container').hide();
|
| - |
|
227 |
$('.modal-model-margin-container').show().html(loaderHtml);
|
| - |
|
228 |
|
| - |
|
229 |
// Use new endpoint with fofoId
|
| - |
|
230 |
doGetAjaxRequestHandler(`${context}/getModelMarginModal?searchModel=${catalogId}&date=${date}&fofoId=${modalFofoId}`, function (response) {
|
| - |
|
231 |
$('.modal-model-margin-container').html(response);
|
| - |
|
232 |
});
|
| - |
|
233 |
}
|
| - |
|
234 |
|
| 183 |
// Function to search and load IMEI margin details in modal
|
235 |
// Function to search and load IMEI margin details in modal
|
| 184 |
function searchImeiMarginInModal(imei) {
|
236 |
function searchImeiMarginInModal(imei) {
|
| 185 |
const loaderHtml = `
|
237 |
const loaderHtml = `
|
| 186 |
<center><div class="loader-wrapper" style="padding: 50px;">
|
238 |
<center><div class="loader-wrapper" style="padding: 50px;">
|
| 187 |
<i class="fa fa-spinner fa-spin fa-3x"></i>
|
239 |
<i class="fa fa-spinner fa-spin fa-3x"></i>
|
| 188 |
<p style="margin-top: 15px;">Loading margin details for ${imei}...</p>
|
240 |
<p style="margin-top: 15px;">Loading margin details for ${imei}...</p>
|
| 189 |
</div></center>`;
|
241 |
</div></center>`;
|
| 190 |
|
242 |
|
| 191 |
$('.scheme-imei-history-view').html(loaderHtml);
|
243 |
// Hide Model results, show IMEI results container
|
| 192 |
|
- |
|
| 193 |
doGetAjaxRequestHandler(`${context}/getSchemesByImei?searchImei=${imei}&modal=true`, function (response) {
|
244 |
$('.modal-model-margin-container').hide();
|
| 194 |
$('.scheme-imei-history-view').html(response);
|
245 |
$('.modal-imei-margin-container').show().html(loaderHtml);
|
| 195 |
|
246 |
|
| 196 |
// Re-initialize IMEI autocomplete after content reload
|
- |
|
| 197 |
if (typeof getAllImeiAheadOptions === 'function') {
|
247 |
// Use new endpoint with fofoId
|
| 198 |
getAllImeiAheadOptions($("#scheme-imei-wise-search-text"), function (inventoryItem) {
|
248 |
doGetAjaxRequestHandler(`${context}/getImeiMarginModal?searchImei=${imei}&fofoId=${modalFofoId}`, function (response) {
|
| 199 |
// Trigger search when item selected from autocomplete
|
249 |
$('.modal-imei-margin-container').html(response);
|
| 200 |
});
|
- |
|
| 201 |
}
|
- |
|
| 202 |
});
|
250 |
});
|
| 203 |
}
|
251 |
}
|
| 204 |
|
252 |
|
| 205 |
|
253 |
|
| 206 |
$(document).on('click', ".fofo-brand-tab", function () {
|
254 |
$(document).on('click', ".fofo-brand-tab", function () {
|