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