| 27797 |
tejbeer |
1 |
$(function() {
|
| 24125 |
govind |
2 |
|
| 27797 |
tejbeer |
3 |
$(document).on('click', "#retailer-details-search-button", function() {
|
|
|
4 |
searchContent = $("#retailer-details-search-text").val();
|
|
|
5 |
if (typeof (searchContent) == "undefined" || !searchContent) {
|
|
|
6 |
searchContent = "";
|
|
|
7 |
}
|
|
|
8 |
getRetailerDetailsByEmailIdOrMobileNumber(
|
|
|
9 |
"retailer-details-container", searchContent);
|
|
|
10 |
});
|
| 31860 |
tejbeer |
11 |
|
| 28711 |
amit.gupta |
12 |
$(document).on('click', ".activate-store-temporary", function() {
|
|
|
13 |
var row = $(this).closest("tr");
|
|
|
14 |
var fofoId = $(this).data("fofoid");
|
| 31860 |
tejbeer |
15 |
|
| 28711 |
amit.gupta |
16 |
var ActiveDays = $(row).find("td:eq(4) input[type='text']").val();
|
|
|
17 |
console.log("ActiveDays" + ActiveDays);
|
|
|
18 |
console.log("fofoId" + fofoId);
|
|
|
19 |
var days = parseInt(ActiveDays);
|
| 28713 |
amit.gupta |
20 |
if (confirm("Are you sure you want to activate this store!") == true) {
|
| 31860 |
tejbeer |
21 |
doPostAjaxRequestHandler(context + "/activateStoreTemporary?fofoId=" + fofoId + "&days=" + days,
|
| 28711 |
amit.gupta |
22 |
function(response) {
|
|
|
23 |
if (response == "true") {
|
|
|
24 |
alert("successfully activated!");
|
|
|
25 |
inactiveStoreInfo("main-content");
|
|
|
26 |
}
|
| 24159 |
tejbeer |
27 |
|
| 28711 |
amit.gupta |
28 |
});
|
| 31860 |
tejbeer |
29 |
|
| 28713 |
amit.gupta |
30 |
}
|
| 28711 |
amit.gupta |
31 |
|
| 31860 |
tejbeer |
32 |
|
| 28711 |
amit.gupta |
33 |
});
|
| 31860 |
tejbeer |
34 |
|
| 29268 |
manish |
35 |
$(document).on('click', ".partner-info", function() {
|
| 31860 |
tejbeer |
36 |
var userIds = {};
|
|
|
37 |
userIds['userIds'] = $('#fofo-users').val();
|
|
|
38 |
console.log(userIds)
|
|
|
39 |
doPostAjaxRequestWithJsonHandler(context + "/getPartnerinfo", JSON.stringify(userIds), function(response) {
|
|
|
40 |
|
| 29268 |
manish |
41 |
$('.storePartnerInfo').html(response);
|
|
|
42 |
});
|
| 31860 |
tejbeer |
43 |
|
| 29268 |
manish |
44 |
});
|
| 27797 |
tejbeer |
45 |
$(document).on('click', ".active-store", function() {
|
| 29268 |
manish |
46 |
store("main-content");
|
|
|
47 |
});
|
|
|
48 |
$(document).on('click', ".allStoreInfo", function() {
|
| 27797 |
tejbeer |
49 |
storeInfo("main-content");
|
|
|
50 |
});
|
| 31860 |
tejbeer |
51 |
|
|
|
52 |
|
| 27797 |
tejbeer |
53 |
$(document).on('click', ".inactive-store", function() {
|
|
|
54 |
inactiveStoreInfo("main-content");
|
|
|
55 |
});
|
|
|
56 |
$(document).on('click', ".retailer-info", function() {
|
|
|
57 |
retailerInfo("main-content");
|
|
|
58 |
});
|
| 24125 |
govind |
59 |
|
| 27231 |
tejbeer |
60 |
|
| 27797 |
tejbeer |
61 |
$(document).on('click', ".partner-readonly-info", function() {
|
|
|
62 |
partnerInfo("main-content")
|
| 27171 |
tejbeer |
63 |
|
|
|
64 |
|
| 27797 |
tejbeer |
65 |
});
|
| 28071 |
tejbeer |
66 |
$(document).on('click', ".block-brand-mapping", function() {
|
|
|
67 |
blockBrandMapping("main-content")
|
| 27171 |
tejbeer |
68 |
|
| 24125 |
govind |
69 |
|
| 28071 |
tejbeer |
70 |
});
|
| 31860 |
tejbeer |
71 |
|
| 28272 |
tejbeer |
72 |
$(document).on('click', ".brands-limit", function() {
|
|
|
73 |
brandsLimit("main-content")
|
| 28071 |
tejbeer |
74 |
|
|
|
75 |
|
| 28272 |
tejbeer |
76 |
});
|
| 31860 |
tejbeer |
77 |
|
|
|
78 |
$(document).on('click', ".add-partner-pincode", function() {
|
| 28381 |
tejbeer |
79 |
allPartnerPincode("main-content")
|
| 28272 |
tejbeer |
80 |
|
|
|
81 |
|
| 28381 |
tejbeer |
82 |
});
|
| 28272 |
tejbeer |
83 |
|
| 28381 |
tejbeer |
84 |
|
| 27797 |
tejbeer |
85 |
$(document).on('click', ".partnerInfoReadOnly",
|
|
|
86 |
function() {
|
| 24125 |
govind |
87 |
|
| 27797 |
tejbeer |
88 |
var fofoId = $('#fofo-users').val();
|
|
|
89 |
loginAsPartnerReadonly(fofoId);
|
|
|
90 |
});
|
|
|
91 |
$(document).on('change', "#retailerAddressPinCode",
|
|
|
92 |
function() {
|
| 27171 |
tejbeer |
93 |
|
| 27797 |
tejbeer |
94 |
var pincode = $('#retailerAddressPinCode').val();
|
| 24125 |
govind |
95 |
|
| 27797 |
tejbeer |
96 |
if (undefined != pincode) {
|
|
|
97 |
doGetAjaxRequestHandler(context + "/postOffice?pinCode="
|
|
|
98 |
+ pincode,
|
|
|
99 |
function(response) {
|
|
|
100 |
console.log(response.response.state);
|
|
|
101 |
$('#retailerAddressCity').find('option').not(':first').remove();
|
|
|
102 |
$('#retailerAddressState').val("");
|
|
|
103 |
$('#retailerAddressState').val(
|
|
|
104 |
response.response.state);
|
|
|
105 |
loadDistrictNames(response.response.state);
|
| 33124 |
ranu |
106 |
loadASTDetail(response.response.state);
|
| 27797 |
tejbeer |
107 |
for (let city of response.response.cities) {
|
|
|
108 |
var opt = $("<option>").val(city).text(city);
|
|
|
109 |
$('#retailerAddressCity').append(opt);
|
| 24349 |
amit.gupta |
110 |
|
| 27797 |
tejbeer |
111 |
}
|
| 24159 |
tejbeer |
112 |
|
| 27797 |
tejbeer |
113 |
});
|
|
|
114 |
}
|
|
|
115 |
});
|
| 24159 |
tejbeer |
116 |
|
| 27797 |
tejbeer |
117 |
$(document).on("keyup", "#retailer-details-search-text", function(e) {
|
|
|
118 |
var keyCode = e.keyCode || e.which;
|
|
|
119 |
if (keyCode == 13) {
|
|
|
120 |
$("#retailer-details-search-button").click();
|
|
|
121 |
}
|
|
|
122 |
});
|
| 24159 |
tejbeer |
123 |
|
| 27797 |
tejbeer |
124 |
$(document).on('click', ".deactivate-store", function() {
|
|
|
125 |
var fofoId = $(this).data("fofoid");
|
|
|
126 |
console.log(fofoId);
|
|
|
127 |
if (confirm("Are you sure you want to deactivate store!") == true) {
|
|
|
128 |
deactivateStore("main-content", fofoId);
|
|
|
129 |
}
|
| 27171 |
tejbeer |
130 |
|
| 27797 |
tejbeer |
131 |
});
|
| 28711 |
amit.gupta |
132 |
$(document).on('click', ".activate-store-forever", function() {
|
|
|
133 |
var fofoId = $(this).data("fofoid");
|
|
|
134 |
console.log(fofoId);
|
|
|
135 |
if (confirm("Are you sure you want to activate this store!") == true) {
|
|
|
136 |
activateStoreForever("main-content", fofoId);
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
});
|
| 31860 |
tejbeer |
140 |
|
| 27797 |
tejbeer |
141 |
$(document).on('click', ".login_as", function() {
|
|
|
142 |
var fofoId = $('#partnerId').val();
|
|
|
143 |
loginAsPartner(fofoId);
|
| 24159 |
tejbeer |
144 |
|
| 27797 |
tejbeer |
145 |
});
|
| 24159 |
tejbeer |
146 |
|
| 31860 |
tejbeer |
147 |
|
| 31892 |
tejbeer |
148 |
$('#partnerSecondary').on('click', '.brandFocusedStock', function() {
|
| 34087 |
ranu |
149 |
|
| 31892 |
tejbeer |
150 |
var fofoId = $(this).data('fofoid');
|
|
|
151 |
var brand = $(this).data('brand');
|
|
|
152 |
|
| 31895 |
tejbeer |
153 |
doGetAjaxRequestHandler(
|
|
|
154 |
"https://partners.smartdukaan.com" + "/getPartnerShortageStock?brand=" + brand + "&fofoId="
|
| 31892 |
tejbeer |
155 |
+ fofoId, function(response) {
|
|
|
156 |
|
|
|
157 |
$('#itemWiseBrandStock .modal-content').html(response);
|
|
|
158 |
|
|
|
159 |
});
|
|
|
160 |
});
|
|
|
161 |
|
|
|
162 |
|
|
|
163 |
|
| 34087 |
ranu |
164 |
|
|
|
165 |
|
|
|
166 |
|
|
|
167 |
|
| 31932 |
tejbeer |
168 |
$(document).on('click', ".agingDataAfterNintyDays", function() {
|
|
|
169 |
var fofoId = $(this).data('fofoid');
|
|
|
170 |
console.log(fofoId)
|
|
|
171 |
|
|
|
172 |
doPostAjaxRequestWithJsonHandler(
|
|
|
173 |
"https://partners.smartdukaan.com" + "/getInventoryItemAgingByFofoId?fofoId="
|
|
|
174 |
+ fofoId, JSON.stringify([90]),
|
|
|
175 |
function(response) {
|
|
|
176 |
$('#agingItemWiseBrandStock .modal-content').html(response);
|
|
|
177 |
});
|
|
|
178 |
});
|
|
|
179 |
|
|
|
180 |
|
|
|
181 |
|
| 27797 |
tejbeer |
182 |
$(document).on('click', ".extend-billing", function() {
|
|
|
183 |
var fofoId = $(this).data("fofoid");
|
|
|
184 |
console.log(fofoId);
|
|
|
185 |
if (confirm("Are you sure you want to extend Billing?")) {
|
|
|
186 |
extendBilling($(this).parent(), fofoId);
|
|
|
187 |
}
|
| 24159 |
tejbeer |
188 |
|
| 27797 |
tejbeer |
189 |
});
|
| 24159 |
tejbeer |
190 |
|
| 31860 |
tejbeer |
191 |
/*
|
|
|
192 |
* $(document).on('change', '#retailerAddressState', function() { var stateName =
|
|
|
193 |
* $(this).find('option:selected').text();
|
|
|
194 |
*
|
|
|
195 |
* loadDistrictNames(stateName); });
|
|
|
196 |
*/
|
| 24159 |
tejbeer |
197 |
|
|
|
198 |
|
| 27797 |
tejbeer |
199 |
$(document).on('click', "#location", function() {
|
|
|
200 |
if ($(this).is(":checked")) {
|
| 27516 |
amit.gupta |
201 |
|
| 27797 |
tejbeer |
202 |
$("#divLocation").show();
|
| 27516 |
amit.gupta |
203 |
|
| 27797 |
tejbeer |
204 |
} else {
|
|
|
205 |
$("#divLocation").hide();
|
|
|
206 |
}
|
|
|
207 |
});
|
| 27516 |
amit.gupta |
208 |
|
|
|
209 |
|
| 27797 |
tejbeer |
210 |
$(document).on('click', ".changePartnerCategory", function() {
|
|
|
211 |
$clickedElement = $(this);
|
|
|
212 |
var fofoId = $clickedElement.data("id");
|
|
|
213 |
$tdElement = $(this).closest('td');
|
|
|
214 |
doGetAjaxRequestHandler(context + "/getPartnerCategory?fofoId=" + fofoId, function(response) {
|
| 27516 |
amit.gupta |
215 |
|
| 27797 |
tejbeer |
216 |
$tdElement.html(response);
|
|
|
217 |
$tdElement.find('.partnerCategory').multiselect({
|
|
|
218 |
includeSelectAllOption: true,
|
|
|
219 |
multiple: true,
|
|
|
220 |
maxHeight: 200,
|
|
|
221 |
buttonWidth: '180px',
|
|
|
222 |
numberDisplayed: 1,
|
|
|
223 |
nonSelectedText: 'Category',
|
|
|
224 |
nSelectedText: ' - Category Selected',
|
|
|
225 |
allSelectedText: 'All Category Selected',
|
|
|
226 |
enableFiltering: true,
|
|
|
227 |
enableCaseInsensitiveFiltering: true
|
|
|
228 |
});
|
|
|
229 |
});
|
|
|
230 |
});
|
| 27516 |
amit.gupta |
231 |
|
|
|
232 |
|
| 27797 |
tejbeer |
233 |
$(document).on('click', ".update-category",
|
|
|
234 |
function() {
|
|
|
235 |
var fofoId = $(this).data('fofoid');
|
|
|
236 |
var partnerType = $('#partnerCategory').val();
|
| 27516 |
amit.gupta |
237 |
|
| 27797 |
tejbeer |
238 |
if (confirm("Are you sure you want to update the partners!") == true) {
|
|
|
239 |
doPostAjaxRequestHandler(context
|
|
|
240 |
+ "/updatePartnerCategory?fofoId="
|
|
|
241 |
+ fofoId + "&partnerType=" + partnerType, function(
|
|
|
242 |
response) {
|
|
|
243 |
if (response == "true") {
|
|
|
244 |
alert("Update successfully");
|
|
|
245 |
storeInfo("main-content");
|
|
|
246 |
}
|
|
|
247 |
});
|
|
|
248 |
}
|
| 27516 |
amit.gupta |
249 |
|
| 27797 |
tejbeer |
250 |
});
|
|
|
251 |
|
|
|
252 |
|
| 31860 |
tejbeer |
253 |
|
|
|
254 |
|
| 27797 |
tejbeer |
255 |
$(document).on('click', ".addlocationbutton",
|
|
|
256 |
function() {
|
|
|
257 |
var userId = $('#retailerId').text();
|
|
|
258 |
var name = $('#personName').val();
|
|
|
259 |
var line1 = $('#line1').val();
|
|
|
260 |
var line2 = $('#line2').val();
|
|
|
261 |
var city = $('#city').val();
|
|
|
262 |
var state = $('#state').val();
|
|
|
263 |
var pin = $('#pinCode').val();
|
|
|
264 |
|
|
|
265 |
if (name === "" && line1 === "" && city === "" && pin === "") {
|
|
|
266 |
alert("Field can't be empty");
|
|
|
267 |
return;
|
|
|
268 |
}
|
|
|
269 |
if (name === "") {
|
|
|
270 |
alert("name is required");
|
|
|
271 |
return;
|
|
|
272 |
}
|
|
|
273 |
if (line1 === "") {
|
|
|
274 |
alert("line1 is required");
|
|
|
275 |
return;
|
|
|
276 |
}
|
|
|
277 |
if (city === "") {
|
|
|
278 |
alert("city is required");
|
|
|
279 |
return;
|
|
|
280 |
}
|
|
|
281 |
if (pin === "") {
|
|
|
282 |
alert("pin is required");
|
|
|
283 |
return;
|
|
|
284 |
}
|
|
|
285 |
|
|
|
286 |
var locationData = {};
|
|
|
287 |
locationData['userId'] = $('#retailerId').text();
|
|
|
288 |
locationData['name'] = $('#personName').val();
|
|
|
289 |
locationData['line1'] = $('#line1').val();
|
|
|
290 |
locationData['line2'] = $('#line2').val();
|
|
|
291 |
locationData['city'] = $('#city').val();
|
|
|
292 |
locationData['state'] = $('#state').val();
|
|
|
293 |
locationData['pin'] = $('#pinCode').val();
|
|
|
294 |
|
|
|
295 |
if (confirm("Are you sure you want to add location!") == true) {
|
|
|
296 |
doPostAjaxRequestWithJsonHandler(context + "/addLocation",
|
|
|
297 |
JSON.stringify(locationData), function(response) {
|
|
|
298 |
if (response == 'true') {
|
|
|
299 |
alert("successfully Add");
|
|
|
300 |
$("#addLocationModal").modal('hide');
|
|
|
301 |
|
|
|
302 |
}
|
|
|
303 |
});
|
|
|
304 |
|
|
|
305 |
return false;
|
|
|
306 |
}
|
|
|
307 |
});
|
|
|
308 |
|
| 32044 |
tejbeer |
309 |
|
|
|
310 |
|
|
|
311 |
//Performance
|
|
|
312 |
$(document).on('click', ".partner-performance-access", function() {
|
|
|
313 |
doGetAjaxRequestHandler(context + "/getPartnersForPerformance", function(response) {
|
|
|
314 |
$('#' + "main-content").html(response);
|
|
|
315 |
});
|
|
|
316 |
});
|
|
|
317 |
|
|
|
318 |
$(document).on('click', ".partnerPerformance", function() {
|
|
|
319 |
var fofoId = $('#fofo-users').val();
|
|
|
320 |
var url = context + "/partnerPerformance?fofoId=" + fofoId;
|
|
|
321 |
//$('.partner-performance-container').html(`<iframe class="wrapper" src="${url}" style="width:100%;height:100vh"> </iframe>`);
|
|
|
322 |
doGetAjaxRequestHandler(context + "/partnerPerformance?fofoId=" + fofoId, function(response) {
|
|
|
323 |
$('.partner-performance-container').html(response);
|
|
|
324 |
});
|
|
|
325 |
});
|
|
|
326 |
|
|
|
327 |
$(document).on('click', ".retailer-filter", function() {
|
|
|
328 |
doGetAjaxRequestHandler(context + "/getFilters", function(response) {
|
|
|
329 |
$('#' + "main-content").html(response);
|
|
|
330 |
});
|
|
|
331 |
});
|
|
|
332 |
|
|
|
333 |
|
|
|
334 |
$(document).on('click', ".filters", function() {
|
|
|
335 |
|
|
|
336 |
var credit = $('#credit').is(':checked');
|
|
|
337 |
var billing = $('#billing').is(':checked');
|
|
|
338 |
var investment = $('#investment').is(':checked');
|
|
|
339 |
var secondary = $('#secondary').is(':checked');
|
|
|
340 |
var tertiary = $('#tertiary').is(':checked');
|
|
|
341 |
var mtds = $('#mtds').is(':checked');
|
|
|
342 |
var mtdt = $('#mtdt').is(':checked');
|
|
|
343 |
|
|
|
344 |
var investmentPct = $('#investmentvalue').val();
|
|
|
345 |
var secondaryDays = $('#secondaryvalue').val();
|
|
|
346 |
var tertiaryDays = $('#tertiaryvalue').val();
|
|
|
347 |
var mtdsPct = $('#mtdsvalue').val();
|
|
|
348 |
var mtdtPct = $('#mtdtvalue').val();
|
|
|
349 |
|
|
|
350 |
console.log(investmentPct)
|
|
|
351 |
|
|
|
352 |
|
|
|
353 |
|
|
|
354 |
var retailerFilters = {};
|
|
|
355 |
retailerFilters['credit'] = credit;
|
|
|
356 |
retailerFilters['billing'] = billing
|
|
|
357 |
if (investment) {
|
|
|
358 |
retailerFilters['investmentPct'] = investmentPct
|
|
|
359 |
}
|
|
|
360 |
if (secondary) {
|
|
|
361 |
retailerFilters['secondaryDays'] = secondaryDays
|
|
|
362 |
}
|
|
|
363 |
if (tertiary) {
|
|
|
364 |
retailerFilters['tertiaryDays'] = tertiaryDays
|
|
|
365 |
}
|
|
|
366 |
|
|
|
367 |
if (mtds) {
|
|
|
368 |
retailerFilters['mtdsPct'] = mtdsPct
|
|
|
369 |
}
|
|
|
370 |
|
|
|
371 |
if (mtdt) {
|
|
|
372 |
retailerFilters['mtdtPct'] = mtdtPct
|
|
|
373 |
}
|
|
|
374 |
|
| 32089 |
tejbeer |
375 |
console.log(JSON.stringify(retailerFilters));
|
|
|
376 |
|
| 32044 |
tejbeer |
377 |
doAjaxRequestWithJsonHandler(context + "/getFilteredRetailers", 'POST', JSON.stringify(retailerFilters), function(response) {
|
|
|
378 |
$('.filtered-partner-performance-container').html(response);
|
|
|
379 |
|
|
|
380 |
});
|
|
|
381 |
});
|
|
|
382 |
|
|
|
383 |
|
|
|
384 |
|
|
|
385 |
$(document).on('click', ".default-email-val", function() {
|
|
|
386 |
|
|
|
387 |
var credit = $('#credit').is(':checked');
|
|
|
388 |
var billing = $('#billing').is(':checked');
|
|
|
389 |
var investment = $('#investment').is(':checked');
|
|
|
390 |
var secondary = $('#secondary').is(':checked');
|
|
|
391 |
var tertiary = $('#tertiary').is(':checked');
|
|
|
392 |
var mtds = $('#mtds').is(':checked');
|
|
|
393 |
var mtdt = $('#mtdt').is(':checked');
|
|
|
394 |
|
|
|
395 |
var investmentPct = $('#investmentvalue').val();
|
|
|
396 |
var secondaryDays = $('#secondaryvalue').val();
|
|
|
397 |
var tertiaryDays = $('#tertiaryvalue').val();
|
|
|
398 |
var mtdsPct = $('#mtdsvalue').val();
|
|
|
399 |
var mtdtPct = $('#mtdtvalue').val();
|
|
|
400 |
|
|
|
401 |
console.log(investmentPct)
|
|
|
402 |
|
|
|
403 |
|
|
|
404 |
|
|
|
405 |
var retailerFilters = {};
|
|
|
406 |
retailerFilters['credit'] = credit;
|
|
|
407 |
retailerFilters['billing'] = billing
|
|
|
408 |
retailerFilters['investmentPct'] = investmentPct
|
|
|
409 |
retailerFilters['secondaryDays'] = secondaryDays
|
|
|
410 |
retailerFilters['tertiaryDays'] = tertiaryDays
|
|
|
411 |
retailerFilters['mtdsPct'] = mtdsPct
|
|
|
412 |
retailerFilters['mtdtPct'] = mtdtPct
|
|
|
413 |
|
|
|
414 |
|
|
|
415 |
|
|
|
416 |
|
|
|
417 |
doAjaxRequestWithJsonHandler(context + "/defaultFilterSetForEmail", 'POST', JSON.stringify(retailerFilters), function(response) {
|
|
|
418 |
if (response == "true") {
|
|
|
419 |
alert("Successfully Done")
|
|
|
420 |
}
|
|
|
421 |
});
|
|
|
422 |
});
|
|
|
423 |
|
|
|
424 |
|
| 23347 |
ashik.ali |
425 |
});
|
|
|
426 |
|
| 23837 |
ashik.ali |
427 |
function getDistance(lat1, lon1, lat2, lon2) {
|
| 27797 |
tejbeer |
428 |
var deg2rad = 0.017453292519943295; // === Math.PI / 180
|
|
|
429 |
var cos = Math.cos;
|
|
|
430 |
lat1 *= deg2rad;
|
|
|
431 |
lon1 *= deg2rad;
|
|
|
432 |
lat2 *= deg2rad;
|
|
|
433 |
lon2 *= deg2rad;
|
|
|
434 |
var diam = 12742; // Diameter of the earth in km (2 * 6371)
|
|
|
435 |
var dLat = lat2 - lat1;
|
|
|
436 |
var dLon = lon2 - lon1;
|
|
|
437 |
var a = ((1 - cos(dLat)) + (1 - cos(dLon)) * cos(lat1) * cos(lat2)) / 2;
|
| 23837 |
ashik.ali |
438 |
|
| 27797 |
tejbeer |
439 |
return parseFloat(diam * Math.asin(Math.sqrt(a))).toFixed(2);
|
| 24125 |
govind |
440 |
}
|
| 23837 |
ashik.ali |
441 |
|
| 24125 |
govind |
442 |
function getRetailerDetailsByEmailIdOrMobileNumber(domId, emailIdOrMobileNumber) {
|
| 27797 |
tejbeer |
443 |
doGetAjaxRequestHandler(context + "/retailerDetails?emailIdOrMobileNumber="
|
|
|
444 |
+ emailIdOrMobileNumber, function(response) {
|
|
|
445 |
$('#' + domId).html(response);
|
|
|
446 |
if ($("#location").is(":checked")) {
|
| 27171 |
tejbeer |
447 |
|
| 27797 |
tejbeer |
448 |
$("#divLocation").show();
|
|
|
449 |
}
|
|
|
450 |
});
|
| 23347 |
ashik.ali |
451 |
}
|
|
|
452 |
|
| 24125 |
govind |
453 |
function updateRetailerDocument() {
|
| 27797 |
tejbeer |
454 |
// $("#updateRetailerShopDocument0").click( function() {
|
|
|
455 |
console.log("Update Retailer Document Clicked");
|
|
|
456 |
// console.log(ownerId);
|
|
|
457 |
var emailIdOrMobileNumber = $('#retailer-details-search-text').val();
|
|
|
458 |
console.log("emailIdOrMobileNumber: " + emailIdOrMobileNumber);
|
|
|
459 |
var file = $('#retailerDocument')[0].files[0];
|
|
|
460 |
console.log("file : " + file.name);
|
|
|
461 |
uploadRetailerDocument("retailer-details-container", file,
|
|
|
462 |
emailIdOrMobileNumber);
|
| 23347 |
ashik.ali |
463 |
}
|
|
|
464 |
|
| 24125 |
govind |
465 |
function updateRetailerShopDocument(ownerId) {
|
| 27797 |
tejbeer |
466 |
// $("#updateRetailerShopDocument0").click( function() {
|
|
|
467 |
console.log("Update Retailer Shop Document Clicked");
|
|
|
468 |
console.log(ownerId);
|
|
|
469 |
var shopSize = parseInt($("#shopDetailsSize").attr('size'));
|
|
|
470 |
console.log("size : " + shopSize);
|
|
|
471 |
for (var index = 0; index < shopSize; index++) {
|
|
|
472 |
if ("updateRetailerShopDocument" + index == ownerId) {
|
|
|
473 |
var emailIdOrMobileNumber = $('#retailer-details-search-text')
|
|
|
474 |
.val();
|
|
|
475 |
console.log("emailIdOrMobileNumber: " + emailIdOrMobileNumber);
|
|
|
476 |
var shopId = $('#retailerShopDocument' + index).attr("shopId");
|
|
|
477 |
console.log("shopId : " + shopId);
|
|
|
478 |
var file = $('#retailerShopDocument' + index)[0].files[0];
|
|
|
479 |
console.log("file : " + file.name);
|
|
|
480 |
uploadRetailerShopDocument("retailer-details-container", file,
|
|
|
481 |
emailIdOrMobileNumber, shopId);
|
|
|
482 |
}
|
|
|
483 |
}
|
| 23347 |
ashik.ali |
484 |
}
|
|
|
485 |
|
| 24125 |
govind |
486 |
function loadDistrictNames(stateName) {
|
| 27797 |
tejbeer |
487 |
if (undefined != $("#districtName")) {
|
|
|
488 |
doGetAjaxRequestHandler(
|
|
|
489 |
context + "/district/all/stateName?stateName=" + stateName,
|
|
|
490 |
function(response) {
|
|
|
491 |
console.log(response);
|
|
|
492 |
var districtMasters = response.response;
|
|
|
493 |
// districtMasters = districtMasters.response;
|
|
|
494 |
var districtNameElements = '<option value="" disabled selected>District Name</option>';
|
|
|
495 |
for (index = 0; index < districtMasters.length; index++) {
|
|
|
496 |
districtNameElements = districtNameElements
|
|
|
497 |
+ '<option value="'
|
|
|
498 |
+ districtMasters[index].name + '">'
|
|
|
499 |
+ districtMasters[index].name + '</option>';
|
|
|
500 |
}
|
|
|
501 |
$('#districtName').html(districtNameElements);
|
|
|
502 |
});
|
|
|
503 |
}
|
| 23347 |
ashik.ali |
504 |
}
|
|
|
505 |
|
| 33124 |
ranu |
506 |
function loadASTDetail(stateName) {
|
|
|
507 |
doGetAjaxRequestHandler(
|
|
|
508 |
context + "/astDetail?stateName=" + stateName,
|
| 33128 |
amit.gupta |
509 |
function (asts) {
|
| 33124 |
ranu |
510 |
$('#retailerAstId').find('option').not(':first').remove();
|
| 33128 |
amit.gupta |
511 |
for (let ast of asts) {
|
|
|
512 |
var opt = $("<option>").val(ast.id).text(ast.area + "(" + ast.areaDescription + ")" + " - " + ast.territory + "(" + ast.territoryDescription + ")");
|
| 33124 |
ranu |
513 |
$('#retailerAstId').append(opt);
|
|
|
514 |
}
|
|
|
515 |
}
|
|
|
516 |
);
|
|
|
517 |
}
|
|
|
518 |
|
| 24125 |
govind |
519 |
function retailerInfo(domId) {
|
| 27797 |
tejbeer |
520 |
doGetAjaxRequestHandler(context + "/retailerInfo", function(response) {
|
|
|
521 |
$('#' + domId).html(response);
|
| 24159 |
tejbeer |
522 |
|
| 27797 |
tejbeer |
523 |
});
|
| 24159 |
tejbeer |
524 |
|
| 24125 |
govind |
525 |
}
|
| 27231 |
tejbeer |
526 |
|
| 27516 |
amit.gupta |
527 |
function partnerInfo(domId) {
|
| 27797 |
tejbeer |
528 |
doGetAjaxRequestHandler(context + "/getPartnerReadonlyInfo", function(response) {
|
|
|
529 |
$('#' + domId).html(response);
|
| 27516 |
amit.gupta |
530 |
|
| 27797 |
tejbeer |
531 |
});
|
| 27231 |
tejbeer |
532 |
}
|
| 28071 |
tejbeer |
533 |
function blockBrandMapping(domId) {
|
|
|
534 |
doGetAjaxRequestHandler(context + "/getBlockBrandMapping", function(response) {
|
|
|
535 |
$('#' + domId).html(response);
|
| 27516 |
amit.gupta |
536 |
|
| 28071 |
tejbeer |
537 |
});
|
|
|
538 |
}
|
| 28272 |
tejbeer |
539 |
function brandsLimit(domId) {
|
|
|
540 |
doGetAjaxRequestHandler(context + "/getBrandslimit", function(response) {
|
|
|
541 |
$('#' + domId).html(response);
|
| 28071 |
tejbeer |
542 |
|
| 28272 |
tejbeer |
543 |
});
|
|
|
544 |
}
|
| 24125 |
govind |
545 |
function storeInfo(domId) {
|
| 27797 |
tejbeer |
546 |
doGetAjaxRequestHandler(context + "/getAllStores", function(response) {
|
|
|
547 |
$('#' + domId).html(response);
|
|
|
548 |
});
|
| 24125 |
govind |
549 |
}
|
| 27516 |
amit.gupta |
550 |
|
| 29268 |
manish |
551 |
function store(domId) {
|
|
|
552 |
doGetAjaxRequestHandler(context + "/getstore", function(response) {
|
|
|
553 |
$('#' + domId).html(response);
|
|
|
554 |
});
|
|
|
555 |
}
|
| 24680 |
govind |
556 |
function inactiveStoreInfo(domId) {
|
| 27797 |
tejbeer |
557 |
doGetAjaxRequestHandler(context + "/getAllInactiveStores", function(
|
|
|
558 |
response) {
|
|
|
559 |
$('#' + domId).html(response);
|
|
|
560 |
});
|
| 24680 |
govind |
561 |
}
|
| 27516 |
amit.gupta |
562 |
|
| 28381 |
tejbeer |
563 |
function allPartnerPincode(domId) {
|
|
|
564 |
doGetAjaxRequestHandler(context + "/getAllPartnerPincode", function(
|
|
|
565 |
response) {
|
|
|
566 |
$('#' + domId).html(response);
|
|
|
567 |
});
|
|
|
568 |
}
|
|
|
569 |
|
| 24125 |
govind |
570 |
function deactivateStore(domId, fofoId) {
|
| 27797 |
tejbeer |
571 |
doPostAjaxRequestHandler(context + "/deactivateStore?fofoId=" + fofoId,
|
|
|
572 |
function(response) {
|
|
|
573 |
if (response == "true") {
|
|
|
574 |
alert("successfully deactivated!");
|
|
|
575 |
storeInfo(domId);
|
|
|
576 |
}
|
| 24159 |
tejbeer |
577 |
|
| 27797 |
tejbeer |
578 |
});
|
| 24125 |
govind |
579 |
}
|
| 28711 |
amit.gupta |
580 |
function activateStoreForever(domId, fofoId) {
|
|
|
581 |
doPostAjaxRequestHandler(context + "/activateStoreForever?fofoId=" + fofoId,
|
|
|
582 |
function(response) {
|
|
|
583 |
if (response == "true") {
|
|
|
584 |
alert("successfully activated!");
|
|
|
585 |
inactiveStoreInfo(domId);
|
|
|
586 |
}
|
| 27516 |
amit.gupta |
587 |
|
| 28711 |
amit.gupta |
588 |
});
|
|
|
589 |
}
|
|
|
590 |
|
| 24976 |
amit.gupta |
591 |
function loginAsPartner(fofoId) {
|
| 27797 |
tejbeer |
592 |
doGetAjaxRequestHandler(context + "/login-as-partner?fofoId=" + fofoId,
|
|
|
593 |
function(response) {
|
|
|
594 |
window.create({
|
|
|
595 |
"url": "/dashboard",
|
|
|
596 |
"incognito": true
|
|
|
597 |
});
|
| 31860 |
tejbeer |
598 |
|
| 27797 |
tejbeer |
599 |
});
|
| 24976 |
amit.gupta |
600 |
}
|
| 27231 |
tejbeer |
601 |
|
|
|
602 |
function loginAsPartnerReadonly(fofoId) {
|
| 27797 |
tejbeer |
603 |
doGetAjaxRequestHandler(context + "/login-as-partner-readonly?fofoId=" + fofoId,
|
|
|
604 |
function(response) {
|
|
|
605 |
window.create({
|
|
|
606 |
"url": "/dashboard",
|
|
|
607 |
"incognito": true
|
|
|
608 |
});
|
|
|
609 |
});
|
| 27231 |
tejbeer |
610 |
}
|
| 27516 |
amit.gupta |
611 |
|
| 24349 |
amit.gupta |
612 |
function extendBilling(container, fofoId) {
|
| 27797 |
tejbeer |
613 |
doPostAjaxRequestHandler(context + "/extendBilling?fofoId=" + fofoId,
|
|
|
614 |
function(response) {
|
|
|
615 |
if (isFinite(response)) {
|
|
|
616 |
alert("successfully deactivated!");
|
|
|
617 |
container.html("Billing extended upto "
|
|
|
618 |
+ moment().add(1, 'day').format("DD-MM-YY")
|
|
|
619 |
+ " Grace count(" + response + ")");
|
|
|
620 |
}
|
|
|
621 |
});
|
| 24349 |
amit.gupta |
622 |
}
|
| 24159 |
tejbeer |
623 |
|
|
|
624 |
function updateLocationButton(id) {
|
|
|
625 |
|
| 27797 |
tejbeer |
626 |
var userId = id;
|
|
|
627 |
var name = $('#personName').val();
|
|
|
628 |
var line1 = $('#line1').val();
|
|
|
629 |
var line2 = $('#line2').val();
|
|
|
630 |
var city = $('#city').val();
|
|
|
631 |
var state = $('#state').val();
|
|
|
632 |
var pin = $('#pinCode').val();
|
|
|
633 |
console.log(id);
|
|
|
634 |
if (name === "" && line1 === "" && city === "" && pin === "") {
|
|
|
635 |
alert("Field can't be empty");
|
|
|
636 |
return;
|
|
|
637 |
}
|
|
|
638 |
if (name === "") {
|
|
|
639 |
alert("name is required");
|
|
|
640 |
return;
|
|
|
641 |
}
|
|
|
642 |
if (line1 === "") {
|
|
|
643 |
alert("line1 is required");
|
|
|
644 |
return;
|
|
|
645 |
}
|
|
|
646 |
if (city === "") {
|
|
|
647 |
alert("city is required");
|
|
|
648 |
return;
|
|
|
649 |
}
|
|
|
650 |
if (pin === "") {
|
|
|
651 |
alert("pin is required");
|
|
|
652 |
return;
|
|
|
653 |
}
|
| 24159 |
tejbeer |
654 |
|
| 27797 |
tejbeer |
655 |
var changeLocationData = {};
|
| 24159 |
tejbeer |
656 |
|
| 27797 |
tejbeer |
657 |
changeLocationData['userId'] = id;
|
|
|
658 |
changeLocationData['name'] = $('#personName').val();
|
|
|
659 |
changeLocationData['line1'] = $('#line1').val();
|
|
|
660 |
changeLocationData['line2'] = $('#line2').val();
|
|
|
661 |
changeLocationData['city'] = $('#city').val();
|
|
|
662 |
changeLocationData['state'] = $('#state').val();
|
|
|
663 |
changeLocationData['pin'] = $('#pinCode').val();
|
| 24159 |
tejbeer |
664 |
|
| 27797 |
tejbeer |
665 |
console.log(changeLocationData);
|
| 24159 |
tejbeer |
666 |
|
| 27797 |
tejbeer |
667 |
if (confirm("Are you sure you want to add location!") == true) {
|
|
|
668 |
doPostAjaxRequestWithJsonHandler(context + "/updateLocation", JSON
|
|
|
669 |
.stringify(changeLocationData), function(response) {
|
|
|
670 |
if (response == 'true') {
|
|
|
671 |
alert("successfully Update");
|
| 24159 |
tejbeer |
672 |
|
| 27797 |
tejbeer |
673 |
$("#addLocationModal").modal('hide');
|
| 24159 |
tejbeer |
674 |
|
| 27797 |
tejbeer |
675 |
}
|
|
|
676 |
});
|
| 24159 |
tejbeer |
677 |
|
| 27797 |
tejbeer |
678 |
return false;
|
|
|
679 |
}
|
| 24159 |
tejbeer |
680 |
|
| 33814 |
ranu |
681 |
}
|
|
|
682 |
|
|
|
683 |
$(document).on('click', ".retailer_contacts", function () {
|
|
|
684 |
doGetAjaxRequestHandler(context + "/alternateRetailerContacts",
|
|
|
685 |
function (response) {
|
|
|
686 |
$('#' + 'main-content').html(response);
|
|
|
687 |
});
|
|
|
688 |
});
|
|
|
689 |
|
|
|
690 |
$(document).on('click', '.get-retailer-contacts', function () {
|
|
|
691 |
|
|
|
692 |
if (typeof partnerId != "undefined") {
|
|
|
693 |
doGetAjaxRequestHandler(context + "/retailer-contact-list?fofoId=" + partnerId,
|
|
|
694 |
function (response) {
|
|
|
695 |
$('.retailer-contacts-container').html(response);
|
|
|
696 |
});
|
|
|
697 |
}
|
|
|
698 |
|
|
|
699 |
});
|
|
|
700 |
|
|
|
701 |
$(document).on('click', '.retailer-contact-submit', function () {
|
|
|
702 |
var contactName = $('#retailer-contact-name').val();
|
|
|
703 |
var contactNumber = $('#retailer-contact-number').val();
|
|
|
704 |
|
|
|
705 |
if (typeof partnerId != "undefined") {
|
|
|
706 |
doGetAjaxRequestHandler(context + "/add-retailer-contact-list?contactName=" + contactName + "&contactNumber=" + contactNumber + "&fofoId=" + partnerId,
|
|
|
707 |
function (response) {
|
|
|
708 |
$('#update-retailer-contact-modal').modal('toggle');
|
|
|
709 |
$('.retailer-contacts-container').html(response);
|
|
|
710 |
});
|
|
|
711 |
}
|
|
|
712 |
|
|
|
713 |
});
|
|
|
714 |
|
|
|
715 |
$(document).on('click', '.update-contact-status', function () {
|
|
|
716 |
var contactId = $(this).data('contactid');
|
|
|
717 |
var active = $(this).data('status');
|
|
|
718 |
|
|
|
719 |
if (typeof partnerId != "undefined") {
|
|
|
720 |
doGetAjaxRequestHandler(context + "/update-contact-status?contactId=" + contactId + "&fofoId=" + partnerId + "&active=" + active,
|
|
|
721 |
function (response) {
|
|
|
722 |
$('.retailer-contacts-container').html(response);
|
|
|
723 |
});
|
|
|
724 |
}
|
|
|
725 |
|
| 34425 |
ranu |
726 |
});
|
|
|
727 |
|
|
|
728 |
// analysis dasboard js for retailer
|
|
|
729 |
|
|
|
730 |
$(document).on('click', '.dashboard-view', function () {
|
|
|
731 |
var fofoId = $(this).data('fofoid');
|
|
|
732 |
|
|
|
733 |
window.open(context + "/analysisDashboard?fofoId=" + fofoId, '_blank');
|
|
|
734 |
});
|
| 34813 |
aman |
735 |
|
|
|
736 |
$('#partnerTasks').modal({
|
| 34971 |
aman |
737 |
backdrop: 'static',
|
|
|
738 |
keyboard: false
|
| 34813 |
aman |
739 |
});
|
|
|
740 |
|
|
|
741 |
const emailId = getCookie('emailId');
|
|
|
742 |
console.log("Email ID:", emailId);
|
|
|
743 |
|
| 34818 |
aman |
744 |
function showModal() {
|
| 34971 |
aman |
745 |
if (emailId && emailId.endsWith('@smartdukaan.com')) {
|
|
|
746 |
console.log('SmartDukaan user - modal not shown');
|
|
|
747 |
return;
|
|
|
748 |
}
|
| 34818 |
aman |
749 |
$('#partnerTasks').removeAttr('aria-hidden');
|
| 34813 |
aman |
750 |
|
|
|
751 |
if (!emailId || !emailId.endsWith('@smartdukaan.com')) {
|
|
|
752 |
$('#chartData').html('<div class="loader text-center " style=" height: 30px;\n' +
|
|
|
753 |
' display: flex;\n' +
|
|
|
754 |
' justify-content: center;\n' +
|
|
|
755 |
' align-items: center;\n' +
|
|
|
756 |
' font-size: 1.5rem;\n' +
|
|
|
757 |
' font-weight: 200;\n' +
|
|
|
758 |
' color: #555;" >Loading...</div>');
|
|
|
759 |
|
| 34968 |
ranu |
760 |
doGetAjaxRequestHandler(context + "/dashboardModal", function (response, status, xhr) {
|
|
|
761 |
if (xhr.status === 500) {
|
|
|
762 |
// Do nothing or show optional toast
|
|
|
763 |
return;
|
|
|
764 |
}
|
| 34813 |
aman |
765 |
$('#chartData').html(response);
|
| 34818 |
aman |
766 |
$('#partnerTasks').css('zoom', '125%').modal('show');
|
| 34813 |
aman |
767 |
});
|
|
|
768 |
} else {
|
|
|
769 |
$('#chartData').html('<p>No data to load</p>');
|
| 34818 |
aman |
770 |
$('#partnerTasks').css('zoom', '125%').modal('show');
|
| 34813 |
aman |
771 |
}
|
| 34818 |
aman |
772 |
}
|
|
|
773 |
|
|
|
774 |
$(document).ready(function () {
|
| 34987 |
aman |
775 |
const isAdmin = emailId && emailId.endsWith('@smartdukaan.com');
|
|
|
776 |
console.log("user is admin?" + isAdmin)
|
|
|
777 |
console.log("user email id?" + emailId)
|
|
|
778 |
if (isAdmin) {
|
|
|
779 |
console.log('Admin user - modal logic completely skipped');
|
| 34971 |
aman |
780 |
return;
|
|
|
781 |
}
|
| 34987 |
aman |
782 |
|
| 34818 |
aman |
783 |
const today = new Date().toDateString();
|
|
|
784 |
const currentHour = new Date().getHours();
|
|
|
785 |
const stored = JSON.parse(localStorage.getItem('modalData') || '{}');
|
|
|
786 |
|
|
|
787 |
if (stored.date !== today) {
|
|
|
788 |
localStorage.setItem('modalData', JSON.stringify({date: today, count: 1}));
|
|
|
789 |
console.log('First login of day - showing modal');
|
|
|
790 |
showModal();
|
|
|
791 |
} else if (stored.count === 1 && currentHour >= 17) {
|
|
|
792 |
localStorage.setItem('modalData', JSON.stringify({date: today, count: 2}));
|
|
|
793 |
console.log('5 PM show - showing modal');
|
|
|
794 |
showModal();
|
|
|
795 |
} else {
|
|
|
796 |
console.log('Modal conditions not met - not showing');
|
|
|
797 |
$('#partnerTasks').modal('hide');
|
| 34825 |
aman |
798 |
$('.modal-backdrop').remove();
|
| 34818 |
aman |
799 |
}
|
| 34813 |
aman |
800 |
});
|
| 34818 |
aman |
801 |
|
| 34813 |
aman |
802 |
$(document).on('click', '.partner-tasks-btn', function () {
|
| 34971 |
aman |
803 |
if (emailId && emailId.endsWith('@smartdukaan.com')) {
|
|
|
804 |
console.log('SmartDukaan user - button click blocked');
|
|
|
805 |
return;
|
|
|
806 |
}
|
| 34813 |
aman |
807 |
doGetAjaxRequestHandler(context + "/dashboardModal", function (response) {
|
|
|
808 |
$('#chartData').html(response);
|
| 34818 |
aman |
809 |
$('#partnerTasks').css('zoom', '125%').modal('show');
|
| 34813 |
aman |
810 |
$('#partnerTasks').modal('show');
|
|
|
811 |
});
|
|
|
812 |
});
|
|
|
813 |
|
|
|
814 |
$('#partnerTasks').on('hidden.bs.modal', function () {
|
|
|
815 |
$(this).data('modal', null);
|
|
|
816 |
$('.modal-backdrop').remove();
|
|
|
817 |
const bootstrapCss = document.getElementById('modal-bootstrap-css');
|
|
|
818 |
if (bootstrapCss) {
|
|
|
819 |
bootstrapCss.remove();
|
|
|
820 |
}
|
| 34818 |
aman |
821 |
});
|