Subversion Repositories SmartDukaan

Rev

Rev 34671 | Rev 35340 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 34671 Rev 35289
Line 1... Line 1...
1
$(function() {
1
$(function () {
2
	$(document).on('click', ".lead", function() {
2
    $(document).on('click', ".trial_users", function () {
3
		loadLead("main-content");
3
        loadPendingTrialForms("main-content");
4
	});
4
    });
5
 
5
 
6
	$(document).on('click', ".team-commitment", function() {
6
    $(document).on('click', ".mk_trial_create", function () {
7
		loadTeamCommitment("main-content");
7
        let trialFormId = $(this.closest('tr')).data('id');
8
	});
8
    });
9
 
9
 
10
 
10
    $(document).on('click', ".mk_trial_cancel", function () {
11
	$(document).on('click', ".partner-health", function() {
11
        let trialFormId = $(this.closest('tr')).data('id');
12
		loadPartnerHealth("main-content");
12
        cancelTrialForm(trialFormId);
13
	});
13
    });
14
 
14
 
15
	$(document).on('click', ".lead-detail", function() {
15
    function loadPendingTrialForms(domId) {
16
		loadLeadDetail("main-content");
16
        doGetAjaxRequestHandler(context + "/trial/pending", function (response) {
17
	});
17
            $('#' + domId).html(response);
18
 
18
        });
19
 
19
    }
20
 
20
 
21
	$(document).on('click', ".submitCommitment",
21
    function trialCreate(trialFormId) {
22
		function() {
22
        doAjaxRequestHandler(`${context}/trial/create/${trialFormId}`, "GET", function (response) {
23
			var startDateTime = getDatesFromPicker('input[name="commitmentDate"]').startDate;
23
            $('#main-content').html(response);
24
			doGetAjaxRequestHandler(context + "/getTeamCommitment?date="
24
        });
25
				+ startDateTime, function(response) {
25
    }
26
					$('.teamcommitmentcontainer').html(response);
26
 
27
 
27
    function cancelTrialForm(trialFormId) {
28
				});
28
        if (confirm("Are you sure you want to cancel this trial?")) {
29
		});
29
            doGetAjaxRequestHandler(`${context}/trial/cancel/${trialFormId}`, function (response) {
30
 
30
                if (response == "true") {
31
 
31
                    loadPendingTrialForms("main-content");
32
 
32
                }
33
 
33
            });
34
 
34
        }
35
 
35
    }
36
	$(document).on('click', ".submitDateWiseLead", function() {
-
 
37
 
-
 
38
 
-
 
39
		var leadDate = $("#dateWiseLead").val();
-
 
40
		var status = $("#statusFilter").val();
-
 
41
		var color = $("#colorFilter").val();
-
 
42
 
-
 
43
		if (color == null) {
-
 
44
			color = "";
-
 
45
		}
-
 
46
 
-
 
47
 
-
 
48
		console.log(leadDate);
-
 
49
 
-
 
50
		doGetAjaxRequestHandler(context + "/getOpenLead?leadStatus=" + status + "&color=" + color + "&leadDate=" + leadDate, function(response) {
-
 
51
			$('#' + 'main-content').html(response);
-
 
52
		});
-
 
53
 
-
 
54
 
-
 
55
	})
-
 
56
	;$(document).on('click', ".downloadDateWiseLead", function () {
-
 
57
 
-
 
58
 
-
 
59
		var leadDate = $("#dateWiseLead").val();
-
 
60
		var status = $("#statusFilter").val();
-
 
61
		var color = $("#colorFilter").val();
-
 
62
 
-
 
63
		if (color == null) {
-
 
64
			color = "";
-
 
65
		}
-
 
66
		// console.log(leadDate);
-
 
67
		// doGetAjaxRequestHandler(context + "/downloadDateWiseLead?leadStatus=" + status + "&color=" + color + "&leadDate=" + leadDate, function(response) {
-
 
68
		// 	$('#' + 'main-content').html(response);
-
 
69
		// });
-
 
70
 
-
 
71
		console.log(leadDate);
-
 
72
		let endPoint = `${context}/downloadDateWiseLead?leadStatus=${status}&color=${color}&leadDate=${leadDate}`;
-
 
73
		window.location.href = endPoint;
-
 
74
 
-
 
75
	});
-
 
76
 
-
 
77
 
-
 
78
	$(document).on('click', ".visit-request-plan", function() {
-
 
79
 
-
 
80
		doGetAjaxRequestHandler(context + "/visitPlan", function(response) {
-
 
81
			$('#' + 'main-content').html(response);
-
 
82
		});
-
 
83
 
-
 
84
	});
-
 
85
 
-
 
86
	$(document).on('click', ".visitPlan", function() {
-
 
87
 
-
 
88
		let dateWisePlan = $("#dateVisitSearch").val();
-
 
89
 
-
 
90
		doGetAjaxRequestHandler(context + "/visit/getVisitPlan?date=" + dateWisePlan, function(response) {
-
 
91
			$('#' + 'main-content').html(response);
-
 
92
		});
-
 
93
 
-
 
94
	});
-
 
95
 
-
 
96
	$(document).on('click', ".lead-close", function() {
-
 
97
		loadClosedLead("main-content");
-
 
98
	});
-
 
99
 
-
 
100
	$(document).on('click', "#lead-close-paginated .next",
-
 
101
		function() {
-
 
102
 
-
 
103
			var searchText = $("#authUser").val();
-
 
104
			// var searchTxt=$("#scheme-search-text").val();
-
 
105
			console.log(searchText);
-
 
106
			if (typeof (searchText) == "undefined" || !searchText) {
-
 
107
				searchText = "";
-
 
108
			}
-
 
109
 
-
 
110
			if ((searchText)) {
-
 
111
				var params = {};
-
 
112
				params['searchTerm'] = searchText;
-
 
113
				loadPaginatedNextItems('/searchLeadPaginated', params,
-
 
114
					'lead-close-paginated', 'close-lead-table',
-
 
115
					'lead-close-container');
-
 
116
			} else {
-
 
117
 
-
 
118
				loadPaginatedNextItems('/getPaginatedClosedLeads', null,
-
 
119
					'lead-close-paginated', 'close-lead-table',
-
 
120
					'lead-close-container');
-
 
121
			}
-
 
122
			$(this).blur();
-
 
123
		});
-
 
124
 
-
 
125
	$(document).on('click', "#lead-close-paginated .previous",
-
 
126
		function() {
-
 
127
			var searchText = $("#authUser").val();
-
 
128
			// var searchTxt=$("#scheme-search-text").val();
-
 
129
			console.log(searchText);
-
 
130
			if (typeof (searchText) == "undefined" || !searchText) {
-
 
131
				searchText = "";
-
 
132
			}
-
 
133
 
-
 
134
			if ((searchText)) {
-
 
135
				var params = {};
-
 
136
				params['searchTerm'] = searchText;
-
 
137
				loadPaginatedPreviousItems('/searchLeadPaginated', params,
-
 
138
					'lead-close-paginated', 'close-lead-table',
-
 
139
					'lead-close-container');
-
 
140
			} else {
-
 
141
				loadPaginatedPreviousItems('/getPaginatedClosedLeads',
-
 
142
					null, 'lead-close-paginated', 'close-lead-table',
-
 
143
					'lead-close-container');
-
 
144
			}
-
 
145
			$(this).blur();
-
 
146
		});
-
 
147
 
-
 
148
	$(document).on('click', "#close-lead-search-button", function() {
-
 
149
		var searchText = $("#authUser").val();
-
 
150
		if (typeof (searchText) == "undefined" || !searchText) {
-
 
151
			searchText = "";
-
 
152
		}
-
 
153
		loadLeadSearchInfo(searchText);
-
 
154
	});
-
 
155
 
-
 
156
	$(document).on("keyup", "#authUser", function(e) {
-
 
157
		var keyCode = e.keyCode || e.which;
-
 
158
		if (keyCode == 13) {
-
 
159
			$("#close-lead-search-button").click();
-
 
160
		}
-
 
161
	});
-
 
162
	$(document).on('click', ".view",
-
 
163
		function() {
-
 
164
			var id = $(this).data('requestid');
-
 
165
			console.log(id);
-
 
166
			doGetAjaxRequestHandler(context + "/getLeadActivity?leadId="
-
 
167
				+ id, function(response) {
-
 
168
 
-
 
169
					console.log(response)
-
 
170
 
-
 
171
					$('#fetchLeadActivityData .modal-content').html(response);
-
 
172
 
-
 
173
				});
-
 
174
		});
-
 
175
 
-
 
176
	$(document).on('click', ".newLead", function() {
-
 
177
		$('#newEntryLeadModal').modal('show');
-
 
178
		$("#scheduleTime").hide();
-
 
179
	});
-
 
180
 
-
 
181
	$(document).on('click', ".show-lead", function() {
-
 
182
		var status = $("#statusFilter").val();
-
 
183
		doGetAjaxRequestHandler(context + "/getOpenLead?leadStatus=" + status, function(response) {
-
 
184
			$('#' + 'main-content').html(response);
-
 
185
		});
-
 
186
	});
-
 
187
 
-
 
188
 
-
 
189
 
-
 
190
 
-
 
191
 
-
 
192
	$(document).on('click', ".show-colowise-lead", function() {
-
 
193
		var status = $("#statusFilter").val();
-
 
194
		var color = $("#colorFilter").val();
-
 
195
		doGetAjaxRequestHandler(context + "/getOpenLead?leadStatus=" + status + "&color=" + color, function(response) {
-
 
196
			$('#' + 'main-content').html(response);
-
 
197
		});
-
 
198
	});
-
 
199
 
-
 
200
	$(document).on('click', "#uploadIvoryLead", function() {
-
 
201
 
-
 
202
		window.location.href = context + "/downloadIvoryLead";
-
 
203
	});
-
 
204
 
-
 
205
	$(document).on('click', ".submitLeadGenerate", function() {
-
 
206
 
-
 
207
		console.log("hello");
-
 
208
		if (confirm('Confirm upload ?')) {
-
 
209
			var fileSelector = $(this)[0];
-
 
210
			if (fileSelector != undefined) {
-
 
211
				var url = `${context}/csvFileAndSetLead`;
-
 
212
				console.log(url);
-
 
213
				var file = $(".fileLeadGenerate")[0].files[0];
-
 
214
				let fileInput = $(this);
-
 
215
				console.log("file" + file);
-
 
216
				console.log("fileInput" + fileInput);
-
 
217
				doAjaxUploadRequestHandler(
-
 
218
					url,
-
 
219
					'POST',
-
 
220
					file, function(response) {
-
 
221
 
-
 
222
						console.log("reponse" + response);
-
 
223
 
-
 
224
						if (response == true) {
-
 
225
							alert("successfully uploaded");
-
 
226
 
-
 
227
 
-
 
228
						}
-
 
229
					});
-
 
230
 
-
 
231
			}
-
 
232
		}
-
 
233
		else {
-
 
234
			// Do nothing!
-
 
235
		}
-
 
236
	});
-
 
237
 
-
 
238
 
-
 
239
	$(document).on('click', ".lead-request",
-
 
240
		function() {
-
 
241
 
-
 
242
			var firstName = $('input[name="firstName"]').val();
-
 
243
			var lastName = $('input[name="lastName"]').val();
-
 
244
			var mobile = $('input[name="mobile"]').val();
-
 
245
			var address = $('input[name="address"]').val();
-
 
246
			var status = $("#status").val();
-
 
247
			var city = $('input[name="city"]').val();
-
 
248
			var state = $("#state").val();
-
 
249
			var remark = $("#createRemark").val();
-
 
250
			var assignTo = $("#createAssignTo").val();
-
 
251
			var source = $("#leadSource").val();
-
 
252
			var communicationType = $("#communicationTye").val();
-
 
253
 
-
 
254
			var conversionprobability = $("#conversionprobabilit").val();
-
 
255
 
-
 
256
 
-
 
257
			var outletName = $('input[name="leadoutletName"]').val();
-
 
258
			var counterSize = $('input[name="leadcounterSize"]').val();
-
 
259
			var table = document.getElementById('brandtable');
-
 
260
			var brandValueJson = [];
-
 
261
			var leadBrands;
-
 
262
 
-
 
263
			console.log(conversionprobability)
-
 
264
 
-
 
265
 
-
 
266
			if (firstName === "" && lastName === "" && mobile === ""
-
 
267
				&& address === "" && status === "" && city === ""
-
 
268
				&& state === "" && remark === "" && source === "") {
-
 
269
				alert("Field can't be empty");
-
 
270
				return;
-
 
271
			}
-
 
272
 
-
 
273
 
-
 
274
			if (firstName === "") {
-
 
275
				alert("First Name is required");
-
 
276
				return;
-
 
277
			}
-
 
278
			if (lastName === "") {
-
 
279
				alert("Last Name is required");
-
 
280
				return;
-
 
281
			}
-
 
282
			if (mobile === "") {
-
 
283
				alert("Mobile is required");
-
 
284
				return;
-
 
285
			}
-
 
286
			if (status === "") {
-
 
287
				alert("Status is required");
-
 
288
				return;
-
 
289
			}
-
 
290
			if (address === "") {
-
 
291
				alert("address is required");
-
 
292
				return;
-
 
293
			}
-
 
294
			if (city === "") {
-
 
295
				alert("city is required");
-
 
296
				return;
-
 
297
			}
-
 
298
 
-
 
299
			if (state === "") {
-
 
300
				alert("state is required");
-
 
301
				return;
-
 
302
			}
-
 
303
			if (source === "") {
-
 
304
				alert("Source is required")
-
 
305
				return;
-
 
306
			}
-
 
307
 
-
 
308
			if (remark === "") {
-
 
309
				alert("Remark is required");
-
 
310
				return;
-
 
311
			}
-
 
312
 
-
 
313
			if (conversionprobability === "") {
-
 
314
				alert("Conversion Probability is required");
-
 
315
				return;
-
 
316
			}
-
 
317
			if (status == "followUp" || status == "pending" || status == "finalized") {
-
 
318
				if (outletName === "") {
-
 
319
					alert("Outlet Name is required");
-
 
320
					return;
-
 
321
				}
-
 
322
 
-
 
323
				if (counterSize === "") {
-
 
324
					alert("Counter Size is required");
-
 
325
					return;
-
 
326
				}
-
 
327
 
-
 
328
				if (localStorage.getItem("frontph") == "undefined" && localStorage.getItem("frontph") == null) {
-
 
329
					alert("Front Document is required");
-
 
330
					return;
-
 
331
				}
-
 
332
 
-
 
333
				if (localStorage.getItem("internalMarketh") == "undefined" || localStorage.getItem("internalMarketh") == null) {
-
 
334
					alert("Front With Market Document is required");
-
 
335
					return;
-
 
336
				}
-
 
337
 
-
 
338
				if (localStorage.getItem("leftShoth") == "undefined" || localStorage.getItem("leftShoth") == null) {
-
 
339
					alert("Internal Left Shot Document is required");
-
 
340
					return;
-
 
341
				}
-
 
342
 
-
 
343
				if (localStorage.getItem("leftWallh") == "undefined" || localStorage.getItem("leftWallh") == null) {
-
 
344
					alert("Internal Left Wall Document is required");
-
 
345
					return;
-
 
346
				}
-
 
347
 
-
 
348
 
-
 
349
				if (localStorage.getItem("rightWallh") == "undefined" || localStorage.getItem("rightWallh") == null) {
-
 
350
					alert("Internal Right Wall Document is required");
-
 
351
					return;
-
 
352
				}
-
 
353
 
-
 
354
 
-
 
355
				for (i = 1; i < table.rows.length; i++) {
-
 
356
 
-
 
357
					var objCells = table.rows[i].cells;
-
 
358
 
-
 
359
					leadBrands = {
-
 
360
						brand: objCells[0].innerText,
-
 
361
						value: objCells[1].getElementsByTagName('input')[0].value
-
 
362
					}
-
 
363
					brandValueJson.push(leadBrands);
-
 
364
				}
-
 
365
 
-
 
366
 
-
 
367
			}
-
 
368
 
-
 
369
 
-
 
370
			var leaddetailData = {}
-
 
371
			leaddetailData['firstName'] = firstName;
-
 
372
			leaddetailData['lastName'] = lastName
-
 
373
			leaddetailData['mobile'] = mobile
-
 
374
			leaddetailData['address'] = address
-
 
375
			leaddetailData['city'] = city
-
 
376
			leaddetailData['state'] = state
-
 
377
			leaddetailData['status'] = status
-
 
378
			leaddetailData['remark'] = remark
-
 
379
			leaddetailData['assignTo'] = assignTo
-
 
380
			leaddetailData['source'] = source
-
 
381
			leaddetailData['colorCheck'] = conversionprobability
-
 
382
 
-
 
383
 
-
 
384
 
-
 
385
			if (status == "followUp") {
-
 
386
				leaddetailData['schelduleTimestamp'] = getDatesFromPicker('#scheduleTime').startDate;
-
 
387
 
-
 
388
				leaddetailData['communicationType'] = communicationType
-
 
389
			}
-
 
390
 
-
 
391
 
-
 
392
 
-
 
393
 
-
 
394
			leaddetailData['outletName'] = outletName;
-
 
395
 
-
 
396
			leaddetailData['counterSize'] = counterSize;
-
 
397
 
-
 
398
 
-
 
399
			leaddetailData['leadBrands'] = brandValueJson;
-
 
400
 
-
 
401
			console.log(localStorage.getItem("frontp"));
-
 
402
 
-
 
403
 
-
 
404
			leaddetailData['frontp'] = localStorage
-
 
405
				.getItem("frontph");
-
 
406
 
-
 
407
 
-
 
408
			leaddetailData['frontWithMarket'] = localStorage
-
 
409
				.getItem("internalMarketh");
-
 
410
 
-
 
411
 
-
 
412
			leaddetailData['internalLongShot'] = localStorage
-
 
413
				.getItem("leftShoth");
-
 
414
 
-
 
415
 
-
 
416
			leaddetailData['internalLeftWall'] = localStorage
-
 
417
				.getItem("leftWallh");
-
 
418
 
-
 
419
 
-
 
420
			leaddetailData['internalRightWall'] = localStorage
-
 
421
				.getItem("rightWallh");
-
 
422
 
-
 
423
			console.log(leaddetailData);
-
 
424
 
-
 
425
			if (confirm("Are you sure you want to add lead!") == true) {
-
 
426
				doPostAjaxRequestWithJsonHandler(context + "/createLead",
-
 
427
					JSON.stringify(leaddetailData), function(response) {
-
 
428
						if (response == 'true') {
-
 
429
							alert("successfully Add");
-
 
430
							$('#newEntryLeadModal').modal('hide');
-
 
431
							$('.modal-backdrop').remove();
-
 
432
							loadLead("main-content");
-
 
433
						} else {
-
 
434
							alert(response);
-
 
435
						}
-
 
436
					});
-
 
437
 
-
 
438
				return false;
-
 
439
			}
-
 
440
		});
-
 
441
	var leadId = null;
-
 
442
	var row = null;
-
 
443
	$(document).on('click', ".editLead", function() {
-
 
444
		$('#editLeadData').modal('show');
-
 
445
 
-
 
446
		$('input[name="remark"]').val("")
-
 
447
		$("#assignTo").val("")
-
 
448
		$("#editStatus").val("");
-
 
449
		$("#reason").val("");
-
 
450
		$("#statusFilter").val("");
-
 
451
 
-
 
452
		localStorage.removeItem("frontph");
-
 
453
		localStorage.removeItem("leftShoth");
-
 
454
		localStorage.removeItem("rightWallh");
-
 
455
		localStorage.removeItem("leftWallh");
-
 
456
		localStorage.removeItem("internalMarketh");
-
 
457
 
-
 
458
 
-
 
459
		row = $(this).closest("tr");
-
 
460
		$("#editScheduleTime").hide();
-
 
461
		leadId = $(this).data('leadid');
-
 
462
		console.log(leadId)
-
 
463
		$('#lead-detail-view').show();
-
 
464
		doAjaxRequestHandler(context + "/getLeadDetailByLeadId?leadId=" + leadId, "GET",
-
 
465
			function(response) {
-
 
466
				console.log(response)
-
 
467
 
-
 
468
				console.log(response.response)
-
 
469
 
-
 
470
				var data = response.response;
-
 
471
 
-
 
472
				if (data != null) {
-
 
473
 
-
 
474
					$('#lead-detail-view').hide();
-
 
475
					$('input[name="outletName"]').val(data.outletName);
-
 
476
					$('input[name="counterSize"]').val(data.counterSize);
-
 
477
				}
-
 
478
 
-
 
479
			});
-
 
480
 
-
 
481
 
-
 
482
	});
-
 
483
 
-
 
484
	$(document).on('click', ".lead-edit-request",
-
 
485
		function() {
-
 
486
 
-
 
487
 
-
 
488
			console.log(row);
-
 
489
			var rowIndex = $(this).closest('tr').prevAll().length;
-
 
490
			var remark = $('input[name="remark"]').val();
-
 
491
			var assignTo = $("#assignTo").val();
-
 
492
			var editStatus = $("#editStatus").val();
-
 
493
			var reason = $("#reason").val();
-
 
494
 
-
 
495
			var leadDate = $("#dateWiseLead").val();
-
 
496
			var leadStatus = $("#statusFilter").val();
-
 
497
			var color = $("#colorFilter").val();
-
 
498
			var communicationType = $("#communicationType").val();
-
 
499
 
-
 
500
			var conversionprobability = $("#conversionprobability").val();
-
 
501
 
-
 
502
			console.log(conversionprobability)
-
 
503
 
-
 
504
 
-
 
505
			console.log(leadDate)
-
 
506
			console.log(leadStatus)
-
 
507
 
-
 
508
			console.log(color)
-
 
509
			console.log(reason)
-
 
510
 
-
 
511
			if (remark === "" && assignTo === "" && editStatus === "") {
-
 
512
				alert("All fields is required");
-
 
513
				return;
-
 
514
			}
-
 
515
 
-
 
516
			if (assignTo === "") {
-
 
517
				alert("assignTo is required");
-
 
518
				return;
-
 
519
			}
-
 
520
 
-
 
521
			if (remark === "") {
-
 
522
				alert("Remark is required");
-
 
523
				return;
-
 
524
			}
-
 
525
 
-
 
526
 
-
 
527
			if (editStatus === "") {
-
 
528
				alert("status is required");
-
 
529
				return;
-
 
530
			}
-
 
531
 
-
 
532
			if (editStatus === "notInterested") {
-
 
533
				if (reason == null) {
-
 
534
					alert("Reason  is required");
-
 
535
					return;
-
 
536
				}
-
 
537
			}
-
 
538
			var leadActivityData = {}
-
 
539
			leadActivityData['id'] = leadId;
-
 
540
			leadActivityData['remark'] = remark;
-
 
541
			leadActivityData['assignTo'] = assignTo
-
 
542
			leadActivityData['status'] = editStatus
-
 
543
			leadActivityData['reason'] = reason
-
 
544
			leadActivityData['colorCheck'] = conversionprobability
-
 
545
 
-
 
546
 
-
 
547
			if (editStatus == "followUp") {
-
 
548
				leadActivityData['scheldule'] = getDatesFromPicker('input[name="editScheduleTime"]').startDate
-
 
549
				leadActivityData['communicationType'] = communicationType
-
 
550
 
-
 
551
			}
-
 
552
 
-
 
553
			console.log(leadActivityData);
-
 
554
			if (confirm("Are you sure you want to add lead!") == true) {
-
 
555
				doPostAjaxRequestWithJsonHandler(context + "/editLead", JSON.stringify(leadActivityData), function(response) {
-
 
556
					console.log(response);
-
 
557
					$('#editLeadData').modal('hide');
-
 
558
					$('.modal-backdrop').remove();
-
 
559
					row.html(response);
-
 
560
				});
-
 
561
			}
-
 
562
 
-
 
563
		});
-
 
564
 
-
 
565
 
-
 
566
 
-
 
567
	$(document).on('click', ".show-partner-health",
-
 
568
		function() {
-
 
569
 
-
 
570
			var email = $("#authUserFilter").val();
-
 
571
 
-
 
572
			console.log(email)
-
 
573
			doGetAjaxRequestHandler(context + "/partnerHealth?email="
-
 
574
				+ email, function(response) {
-
 
575
					console.log(response)
-
 
576
					$('#' + 'main-content').html(response);
-
 
577
 
-
 
578
				});
-
 
579
		});
-
 
580
 
-
 
581
 
-
 
582
	$(document).on('click', ".lead-detail-entry",
-
 
583
		function() {
-
 
584
 
-
 
585
			console.log("hello");
-
 
586
			var outletName = $('input[name="outletName"]').val();
-
 
587
			var counterSize = $('input[name="counterSize"]').val();
-
 
588
			var table = document.getElementById('editbrandtable');
-
 
589
			var brandValueJson = [];
-
 
590
			var leadBrands;
-
 
591
 
-
 
592
			if (outletName === "") {
-
 
593
				alert("Outlet Name is required");
-
 
594
				return;
-
 
595
			}
-
 
596
 
-
 
597
			if (counterSize === "") {
-
 
598
				alert("Counter Size is required");
-
 
599
				return;
-
 
600
			}
-
 
601
 
-
 
602
			if (localStorage.getItem("frontph") == "undefined" && localStorage.getItem("frontph") == null) {
-
 
603
				alert("Front Document is required");
-
 
604
				return;
-
 
605
			}
-
 
606
 
-
 
607
			if (localStorage.getItem("internalMarketh") == "undefined" || localStorage.getItem("internalMarketh") == null) {
-
 
608
				alert("Front With Market Document is required");
-
 
609
				return;
-
 
610
			}
-
 
611
 
-
 
612
			if (localStorage.getItem("leftShoth") == "undefined" || localStorage.getItem("leftShoth") == null) {
-
 
613
				alert("Internal Left Shot Document is required");
-
 
614
				return;
-
 
615
			}
-
 
616
 
-
 
617
			if (localStorage.getItem("leftWallh") == "undefined" || localStorage.getItem("leftWallh") == null) {
-
 
618
				alert("Internal Left Wall Document is required");
-
 
619
				return;
-
 
620
			}
-
 
621
 
-
 
622
 
-
 
623
			if (localStorage.getItem("rightWallh") == "undefined" || localStorage.getItem("rightWallh") == null) {
-
 
624
				alert("Internal Right Wall Document is required");
-
 
625
				return;
-
 
626
			}
-
 
627
 
-
 
628
 
-
 
629
			for (i = 1; i < table.rows.length; i++) {
-
 
630
 
-
 
631
				var objCells = table.rows[i].cells;
-
 
632
 
-
 
633
				leadBrands = {
-
 
634
					brand: objCells[0].innerText,
-
 
635
					value: objCells[1].getElementsByTagName('input')[0].value
-
 
636
				}
-
 
637
				brandValueJson.push(leadBrands);
-
 
638
			}
-
 
639
 
-
 
640
 
-
 
641
			var leadDetailObject = {};
-
 
642
 
-
 
643
			leadDetailObject['leadId'] = leadId;
-
 
644
 
-
 
645
 
-
 
646
			leadDetailObject['outletName'] = outletName;
-
 
647
 
-
 
648
			leadDetailObject['counterSize'] = counterSize;
-
 
649
 
-
 
650
 
-
 
651
			leadDetailObject['leadBrands'] = brandValueJson;
-
 
652
 
-
 
653
			console.log(localStorage.getItem("frontp"));
-
 
654
 
-
 
655
 
-
 
656
			leadDetailObject['frontp'] = localStorage
-
 
657
				.getItem("frontph");
-
 
658
 
-
 
659
 
-
 
660
			leadDetailObject['frontWithMarket'] = localStorage
-
 
661
				.getItem("internalMarketh");
-
 
662
 
-
 
663
 
-
 
664
			leadDetailObject['internalLongShot'] = localStorage
-
 
665
				.getItem("leftShoth");
-
 
666
 
-
 
667
 
-
 
668
			leadDetailObject['internalLeftWall'] = localStorage
-
 
669
				.getItem("leftWallh");
-
 
670
 
-
 
671
 
-
 
672
			leadDetailObject['internalRightWall'] = localStorage
-
 
673
				.getItem("rightWallh");
-
 
674
 
-
 
675
			console.log(leadDetailObject);
-
 
676
 
-
 
677
			if (confirm("Are you sure you want to add lead detail!") == true) {
-
 
678
				doPostAjaxRequestWithJsonHandler(context + "/leadDetail", JSON.stringify(leadDetailObject), function(response) {
-
 
679
					console.log(response);
-
 
680
					if (response == 'true') {
-
 
681
						alert("Submit Successfully");
-
 
682
					}
-
 
683
 
-
 
684
				});
-
 
685
			}
-
 
686
 
-
 
687
		});
-
 
688
 
-
 
689
 
-
 
690
	$(document).on('change', '.frontp',
-
 
691
		function() {
-
 
692
 
-
 
693
			if (confirm('Document has been selected, Do you want to upload ?')) {
-
 
694
 
-
 
695
				var documentId = uploadImage(this, "frontph");
-
 
696
 
-
 
697
 
-
 
698
 
-
 
699
 
-
 
700
 
-
 
701
			} else {
-
 
702
 
-
 
703
			}
-
 
704
		});
-
 
705
 
-
 
706
	$(document).on('change', '.internalMarket',
-
 
707
		function() {
-
 
708
 
-
 
709
			if (confirm('Document has been selected, Do you want to upload ?')) {
-
 
710
 
-
 
711
				var documentId = uploadImage(this, "internalMarketh");
-
 
712
 
-
 
713
			} else {
-
 
714
 
-
 
715
			}
-
 
716
		});
-
 
717
 
-
 
718
	$(document).on('change', '.leftShot',
-
 
719
 
-
 
720
		function() {
-
 
721
			if (confirm('Document has been selected, Do you want to upload ?')) {
-
 
722
				var documentId = uploadImage(this, "leftShoth");
-
 
723
			} else {
-
 
724
 
-
 
725
			}
-
 
726
		});
-
 
727
 
-
 
728
	$(document).on('change', '.leftWall',
-
 
729
		function() {
-
 
730
			if (confirm('Document has been selected, Do you want to upload ?')) {
-
 
731
				var documentId = uploadImage(this, "leftWallh");
-
 
732
			} else {
-
 
733
 
-
 
734
			}
-
 
735
		});
-
 
736
 
-
 
737
	$(document).on('change', '.rightWall',
-
 
738
		function() {
-
 
739
			if (confirm('Document has been selected, Do you want to upload ?')) {
-
 
740
				var documentId = uploadImage(this, "rightWallh");
-
 
741
			} else {
-
 
742
			}
-
 
743
		});
-
 
744
 
-
 
745
 
-
 
746
 
-
 
747
 
-
 
748
});
36
});
749
 
-
 
750
function uploadImage(fileSelector, attrName) {
-
 
751
	var documentId;
-
 
752
	if (fileSelector != undefined
-
 
753
		&& fileSelector.files[0] != undefined) {
-
 
754
		var url = context
-
 
755
			+ '/document-upload';
-
 
756
 
-
 
757
		console.log(url);
-
 
758
		var file = fileSelector.files[0];
-
 
759
 
-
 
760
		console.log(file)
-
 
761
		doAjaxUploadRequestHandler(
-
 
762
			url,
-
 
763
			'POST',
-
 
764
			file,
-
 
765
			function(response) {
-
 
766
				console.log(response)
-
 
767
				documentId = response.response.document_id;
-
 
768
				console
-
 
769
					.log("documentId : "
-
 
770
						+ documentId);
-
 
771
 
-
 
772
 
-
 
773
				localStorage
-
 
774
					.setItem(
-
 
775
						attrName,
-
 
776
						documentId);
-
 
777
 
-
 
778
			});
-
 
779
		return documentId;
-
 
780
	}
-
 
781
 
-
 
782
}
-
 
783
 
-
 
784
 
-
 
785
function loadLead(domId) {
-
 
786
	doGetAjaxRequestHandler(context + "/getOpenLead", function(response) {
-
 
787
		$('#' + domId).html(response);
-
 
788
	});
-
 
789
}
-
 
790
 
-
 
791
function loadClosedLead(domId, searchTerm) {
-
 
792
	doGetAjaxRequestHandler(context + "/getClosedLead", function(response) {
-
 
793
		$('#' + domId).html(response);
-
 
794
	})
-
 
795
}
-
 
796
 
-
 
797
function statusAction() {
-
 
798
	var val = $('#status').val();
-
 
799
	if (val == "followUp") {
-
 
800
		$("#scheduleTime").show();
-
 
801
	} else {
-
 
802
		$("#scheduleTime").hide();
-
 
803
	}
-
 
804
 
-
 
805
}
-
 
806
 
-
 
807
 
-
 
808
function editStatusAction() {
-
 
809
	var val = $('#editStatus').val();
-
 
810
	if (val == "followUp") {
-
 
811
		$("#editScheduleTime").show();
-
 
812
	} else {
-
 
813
		$("#editScheduleTime").hide();
-
 
814
	}
-
 
815
 
-
 
816
}
-
 
817
 
-
 
818
function loadLeadSearchInfo(search_text) {
-
 
819
	loadSearchLead("main-content", search_text);
-
 
820
}
-
 
821
 
-
 
822
function loadTeamCommitment(domId) {
-
 
823
	doGetAjaxRequestHandler(context + "/teamCommitment",
-
 
824
		function(response) {
-
 
825
			$('#' + domId).html(response);
-
 
826
		});
-
 
827
}
-
 
828
 
-
 
829
function loadLeadDetail(domId) {
-
 
830
	doGetAjaxRequestHandler(context + "/getLeadDetail",
-
 
831
		function(response) {
-
 
832
			$('#' + domId).html(response);
-
 
833
		});
-
 
834
}
-
 
835
 
-
 
836
function loadPartnerHealth(domId) {
-
 
837
	doGetAjaxRequestHandler(context + "/partnerHealth",
-
 
838
		function(response) {
-
 
839
			$('#' + domId).html(response);
-
 
840
		});
-
 
841
}
-
 
842
 
-
 
843
function loadSearchLead(domId, search_text) {
-
 
844
	doGetAjaxRequestHandler(context + "/searchLeads?searchTerm=" + search_text,
-
 
845
		function(response) {
-
 
846
			$('#' + domId).html(response);
-
 
847
		});
-
 
848
}
-
 
849
 
-
 
850
$(document).on('click', ".arr-button-mk",
-
 
851
	function () {
-
 
852
		var startDate = $('.arr-start_date').val();
-
 
853
		doGetAjaxRequestHandler(context + "/rbmTodayArr?startDate=" + startDate, function (response) {
-
 
854
			$('#main-content').html(response);
-
 
855
 
-
 
856
		});
-
 
857
	});
-
 
858
 
-
 
859
$(document).on('click', ".rbm-today-arr",
-
 
860
	function () {
-
 
861
		doGetAjaxRequestHandler(context + "/rbmTodayArr", function (response) {
-
 
862
			$('#main-content').html(response);
-
 
863
 
-
 
864
		});
-
 
865
	});
-