Subversion Repositories SmartDukaan

Rev

Rev 28795 | Rev 29759 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
23343 ashik.ali 1
$(function() {
27754 amit.gupta 2
	$(document).on('click', ".create-scheme", function() {
23343 ashik.ali 3
		loadScheme("main-content");
4
	});
23752 govind 5
 
27755 amit.gupta 6
	$(document).on('click', "#schemes-paginated .next",
28134 tejbeer 7
		function() {
8
			var category = $('#partner-category').val();
9
			var searchText = $("#scheme-item-search-text").val();
26802 tejbeer 10
 
28134 tejbeer 11
			var category = $('#partner-category').val();
12
			if (typeof (searchText) == "undefined" || !searchText) {
13
				searchText = "";
14
			}
15
			if (typeof (category) == "undefined" || !category) {
16
				category = "";
17
			}
23752 govind 18
 
28134 tejbeer 19
			if ((searchText) && (category)) {
26802 tejbeer 20
 
28134 tejbeer 21
				var params = {};
22
				params['searchItem'] = currentItem.itemId;
23
				params['partnerType'] = category
24
				loadPaginatedNextItems('/getPaginatedSchemes', params,
25
					'schemes-paginated', 'schemes-table',
26
					'scheme-details-container');
26763 tejbeer 27
 
28134 tejbeer 28
			} else if ((searchText)) {
29
				var params = {};
30
				params['searchItem'] = currentItem.itemId;
31
				loadPaginatedNextItems('/getPaginatedSchemes', params,
32
					'schemes-paginated', 'schemes-table',
33
					'scheme-details-container');
26802 tejbeer 34
 
28134 tejbeer 35
			} else {
36
				var params = {};
37
				params['partnerType'] = category
38
				loadPaginatedNextItems('/getPaginatedSchemes', params,
39
					'schemes-paginated', 'schemes-table',
40
					'scheme-details-container');
41
			}
42
			$(this).blur();
43
		});
23752 govind 44
 
27755 amit.gupta 45
	$(document).on('click', "#schemes-paginated .previous",
28134 tejbeer 46
		function() {
47
			var searchText = $("#scheme-item-search-text").val();
48
			var category = $('#partner-category').val();
49
			// var searchTxt=$("#scheme-search-text").val();
50
			console.log(searchText);
51
			if (typeof (searchText) == "undefined" || !searchText) {
52
				searchText = "";
53
			}
54
			if (typeof (category) == "undefined" || !category) {
55
				category = "";
56
			}
23752 govind 57
 
28134 tejbeer 58
			console.log(searchText)
26802 tejbeer 59
 
28134 tejbeer 60
			if ((searchText) && (category)) {
26802 tejbeer 61
 
28134 tejbeer 62
				var params = {};
63
				params['searchItem'] = currentItem.itemId;
64
				params['partnerType'] = category
65
				loadPaginatedPreviousItems('/getPaginatedSchemes', params,
66
					'schemes-paginated', 'schemes-table',
67
					'scheme-details-container');
26763 tejbeer 68
 
28134 tejbeer 69
			} else if ((searchText)) {
70
				var params = {};
71
				params['searchItem'] = currentItem.itemId;
72
				loadPaginatedPreviousItems('/getPaginatedSchemes', params,
73
					'schemes-paginated', 'schemes-table',
74
					'scheme-details-container');
26763 tejbeer 75
 
28134 tejbeer 76
			} else {
77
				var params = {};
78
				params['partnerType'] = category
79
				loadPaginatedPreviousItems('/getPaginatedSchemes', params,
80
					'schemes-paginated', 'schemes-table',
81
					'scheme-details-container');
82
			}
83
			$(this).blur();
84
		});
23752 govind 85
 
27754 amit.gupta 86
	$(document).on('click', ".scheme-details", function() {
23343 ashik.ali 87
		var schemeId = $(this).attr('data');
23752 govind 88
		console.log("schemeId = " + schemeId);
23343 ashik.ali 89
		loadSchemeDetails(schemeId, "scheme-details-container");
90
	});
23752 govind 91
 
27754 amit.gupta 92
	$(document).on('click', ".active-scheme", function() {
23343 ashik.ali 93
		var schemeId = $(this).attr('data');
23752 govind 94
		console.log("active-scheme id : " + schemeId);
95
		var start = $("#schemes-paginated .start").text();
96
		// var end = $( "#schemes-paginated .end" ).text();
23343 ashik.ali 97
		var offset = start - 1;
23752 govind 98
		if (confirm("Are you sure you want to Active Scheme!") == true) {
23343 ashik.ali 99
			activeScheme(schemeId, offset, "schemes-table");
100
		}
101
	});
23752 govind 102
 
27754 amit.gupta 103
	$(document).on('click', ".expire-scheme", function() {
23343 ashik.ali 104
		var schemeId = $(this).attr('data');
25069 amit.gupta 105
		var expireDate = startDate;
23752 govind 106
		var start = $("#schemes-paginated .start").text();
107
		// var end = $( "#schemes-paginated .end" ).text();
23343 ashik.ali 108
		var offset = start - 1;
23752 govind 109
		if (confirm("Are you sure you want to Expire Scheme!") == true) {
25069 amit.gupta 110
			expireScheme(schemeId, expireDate, offset, "schemes-table");
23343 ashik.ali 111
		}
112
	});
27755 amit.gupta 113
	$(document).on('click', "#extendDatetime-button",
28134 tejbeer 114
		function() {
115
			console.log("extendAll button click");
116
			var extendDatetime = $('input[name="extendDatetime"]')
117
				.val();
118
			console.log("extendDatetime : " + extendDatetime);
119
			if (extendDatetime) {
120
				if (confirm("Are you sure you want to Extend expireDateTime for All Scheme!") == true) {
121
					extendAllScheme(extendDatetime, "schemes-table")
122
				}
123
			} else {
124
				alert("feild can't be blank");
125
			}
126
		});
27755 amit.gupta 127
	$(document).on('click', "#extendScheme-button",
28134 tejbeer 128
		function() {
129
			console.log("extend button click");
130
			var extendDatetime = $('input[name="extendScheme"]')
131
				.val();
132
			var schemeId = $('#schemeId').val()
133
			console.log("extendDatetime : " + extendDatetime);
134
			console.log(schemeId);
135
			if (extendDatetime) {
136
				if (confirm("Are you sure you want to Extend expireDateTime for Scheme!") == true) {
137
					extendSchemeById(schemeId)
138
				}
139
			} else {
140
				alert("feild can't be blank");
141
			}
142
		});
29586 manish 143
 
144
 
145
	$(document).on('click', ".monthy-investment",
146
			function() {
147
		console.log("hello evaluateActualInvestmentPayout");
148
		window.location.href = context + "/evaluateActualInvestmentPayout";		
149
 
150
			});
151
 
152
	$(document).on('click', ".process-investment",
153
			function() {
154
		console.log("payMonthlyInvestment");
155
		window.location.href = context + "/payMonthlyInvestment";		
156
 
157
			});
158
 
159
	$(document).on('click', ".processInvestmentDryRun",
160
			function() {
161
		console.log("processInvestmentDryRun");
162
		window.location.href = context + "/processInvestmentDryRun";		
163
 
164
			});
165
 
166
 
167
 
168
 
23752 govind 169
 
27754 amit.gupta 170
	$(document).on('click', ".schemes", function() {
23347 ashik.ali 171
		console.log("Active Schemes Button Clicked...")
28134 tejbeer 172
 
173
		bootbox.confirm({
174
			message: "<div class = 'disclosurehindata'> <img src='resources/images/disclosure.png' style='width:100%'> </div>"
175
			,
176
			buttons: {
177
				confirm: {
178
					label: 'I agree',
179
					className: 'btn-success'
180
				},
181
				cancel: {
182
					label: 'I disagree',
183
					className: 'btn-danger'
184
				}
185
			},
186
			callback: function(result) {
187
				if (result == true) {
188
					schemes("main-content");
189
				}
190
			}
191
		});
192
 
23347 ashik.ali 193
	});
23752 govind 194
 
28134 tejbeer 195
	$(document).on('click', ".margin-calculator", function() {
27648 tejbeer 196
		console.log("Active Schemes Button Clicked...")
28134 tejbeer 197
		marginCalculator("main-content");
27648 tejbeer 198
	});
199
 
27754 amit.gupta 200
	$(document).on('click', ".schemes-download-page", function() {
23347 ashik.ali 201
		console.log("Schemes Download Clicked...")
202
		loadSchemesDownloadPage("main-content");
22860 ashik.ali 203
	});
23752 govind 204
 
27754 amit.gupta 205
	$(document).on('click', ".schemes-update", function() {
23556 amit.gupta 206
		loadSchemeUpdatePage("main-content");
207
	});
23557 amit.gupta 208
 
27754 amit.gupta 209
	$(document).on('click', ".add-item", function() {
23928 govind 210
 
211
		schemeIds = $("#schemeids").val();
212
		itemIds = $("#itemids").val();
213
		console.log(schemeIds);
214
		console.log(itemIds);
215
		if (confirm("Are you sure you want to Add Item to Scheme!") == true) {
26763 tejbeer 216
			if (itemIds.trim().length === 0 || schemeIds.trim().length === 0) {
217
				alert("fields shouldn't be blank");
218
				return;
219
			}
220
			updateSingleScheme(schemeIds, itemIds);
23928 govind 221
		}
222
	});
27754 amit.gupta 223
	$(document).on('click', ".add-schemes", function() {
23752 govind 224
 
23557 amit.gupta 225
		schemeIds = $("#schemeids").val();
226
		itemIds = $("#itemids").val();
23914 govind 227
		console.log(schemeIds);
228
		console.log(itemIds);
229
		if (confirm("Are you sure you want to Add Item to Scheme!") == true) {
26763 tejbeer 230
			if (itemIds.trim().length === 0 || schemeIds.trim().length === 0) {
231
				alert("fields shouldn't be blank");
232
				return;
233
			}
234
			updateSchemes(schemeIds, itemIds);
23557 amit.gupta 235
		}
236
	});
27754 amit.gupta 237
	$(document).on('click', ".delete-schemes", function() {
23819 govind 238
		if (confirm("Are you sure you want to delete Scheme!") == true) {
23914 govind 239
			schemeId = $(this).data('schemeid');
240
			itemId = $(this).data('itemid');
241
			console.log(schemeId);
242
			console.log(itemId);
243
			deleteScheme(schemeId, itemId);
23715 govind 244
		}
23752 govind 245
	});
246
 
27755 amit.gupta 247
	$(document).on('click', "#scheme-search-button",
28134 tejbeer 248
		function() {
249
			var searchText = $("#scheme-search-text").val();
250
			if (typeof (searchText) == "undefined" || !searchText) {
251
				searchText = "";
252
			}
253
			doGetAjaxRequestHandler(context + "/getSchemes?searchTerm="
254
				+ searchText, function(response) {
26802 tejbeer 255
					$('#' + "main-content").html(response);
256
				});
28134 tejbeer 257
		});
26802 tejbeer 258
 
27754 amit.gupta 259
	$(document).on("keyup", "#scheme-search-text", function(e) {
23752 govind 260
		var keyCode = e.keyCode || e.which;
261
		if (keyCode == 13) {
262
			$("#scheme-search-button").click();
263
		}
264
	});
27754 amit.gupta 265
	$(document).on('click', "#scheme-item-search-button", function() {
23752 govind 266
		var searchText = $("#scheme-item-search-text").val();
27875 amit.gupta 267
		var date = $(".schemes-date").val();
23752 govind 268
		if (typeof (searchText) == "undefined" || !searchText) {
269
			searchText = "";
26497 amit.gupta 270
			alert("please select item");
271
			return;
23752 govind 272
		}
27094 tejbeer 273
		if (typeof currentItem != "undefined") {
274
			console.log(currentItem);
27875 amit.gupta 275
			loadSchemeItemSearchInfo(currentItem, date);
27094 tejbeer 276
		} else {
277
			console.log("reeffff")
278
			alert("Data No Found")
279
		}
23752 govind 280
	});
281
 
28795 tejbeer 282
 
283
	$(document).on('click', "#scheme-imei-search-button", function() {
284
		var searchText = $("#scheme-imei-search-text").val();
285
		var date = $(".schemes-date").val();
286
		if (typeof (searchText) == "undefined" || !searchText) {
287
			searchText = "";
288
			alert("please select imei");
289
			return;
290
		}
291
		if (typeof imei != "undefined") {
292
			console.log(imei);
293
			loadSchemeImeiSearchInfo(imei, date);
294
		} else {
295
			console.log("reeffff")
296
			alert("Data No Found")
297
		}
298
	});
27755 amit.gupta 299
	$(document).on('click', ".categoryWiseSchemeHistory",
28134 tejbeer 300
		function() {
301
			var category = $('#partner-category').val();
302
			console.log(category);
26763 tejbeer 303
 
28134 tejbeer 304
			doGetAjaxRequestHandler(context + "/getSchemes?partnerType="
305
				+ category, function(response) {
26802 tejbeer 306
					$('#' + "main-content").html(response);
307
					$('#partner-category').val(category);
308
					window.dispatchEvent(new Event('resize'));
309
				});
26763 tejbeer 310
 
28134 tejbeer 311
		});
26763 tejbeer 312
 
27754 amit.gupta 313
	$(document).on("keyup", "#scheme-item-search-text", function(e) {
23752 govind 314
		var keyCode = e.keyCode || e.which;
315
		if (keyCode == 13) {
316
			$("#scheme-item-search-button").click();
317
		}
318
	});
22860 ashik.ali 319
});
320
 
23752 govind 321
function configureTagListingItemsDescriptionDropDown() {
28134 tejbeer 322
	$('.tagListingItemsDescription').multiselect({
323
		includeSelectAllOption: true,
324
		maxHeight: 200,
325
		buttonWidth: '180px',
326
		numberDisplayed: 1,
327
		nonSelectedText: 'Items',
328
		nSelectedText: ' - Items Selected',
329
		allSelectedText: 'All Items Selected',
330
		enableFiltering: true,
331
		enableCaseInsensitiveFiltering: true
23752 govind 332
	});
23343 ashik.ali 333
}
334
 
23752 govind 335
function schemesDownload() {
23343 ashik.ali 336
	console.log("downloadItemLedgerReport Button clicked")
23914 govind 337
	var startDateTime = $('input[name="startDateTime"]').val();
338
	console.log("startDateTime : " + startDateTime);
339
	var endDateTime = $('input[name="endDateTime"]').val();
340
	console.log("endDateTime : " + endDateTime);
23752 govind 341
	doAjaxGetDownload(context + "/schemes/download?startDateTime="
28134 tejbeer 342
		+ startDateTime + "&endDateTime=" + endDateTime,
343
		"SchemesReport.xlsx");
23343 ashik.ali 344
}
23914 govind 345
function selectedbrand() {
346
	var brands = $('#tag-listing-brands').val();
347
	console.log(brands);
348
	if (brands) {
349
		loadTagListingItemsDescriptionByBrand(
28134 tejbeer 350
			"tag-listing-items-description-container", brands);
23914 govind 351
	}
352
}
23752 govind 353
function loadSchemeDetails(schemeId, domId) {
354
	doGetAjaxRequestHandler(context + "/getSchemeById?schemeId=" + schemeId,
28134 tejbeer 355
		function(response) {
356
			$('#' + domId).html(response);
357
			window.dispatchEvent(new Event('resize'));
358
		});
23343 ashik.ali 359
}
360
 
23752 govind 361
function activeScheme(schemeId, offset, domId) {
362
	doPutAjaxRequestHandler(context + "/activeSchemeById?schemeId=" + schemeId
28134 tejbeer 363
		+ "&offset=" + offset, function(response) {
364
			$('#' + domId).html(response);
365
			$('#scheme-details-container').html('');
366
		});
23752 govind 367
 
23343 ashik.ali 368
}
369
 
25069 amit.gupta 370
function expireScheme(schemeId, expireDate, offset, domId) {
23752 govind 371
	doPutAjaxRequestHandler(context + "/expireSchemeById?schemeId=" + schemeId
28134 tejbeer 372
		+ "&offset=" + offset + "&expireTimestamp=" + expireDate, function(
26763 tejbeer 373
			response) {
374
		alert("Scheme - " + schemeId + " marked for expiry successfully!");
23343 ashik.ali 375
		$('#' + domId).html(response);
376
		$('#scheme-details-container').html('');
377
	});
378
}
23914 govind 379
function extendAllScheme(domId) {
26763 tejbeer 380
	doPostAjaxRequestWithJsonHandler(context + "/extendAllSchemes", JSON
28134 tejbeer 381
		.stringify(startDate), function(response) {
382
			if (response == 'true') {
383
				alert("Scheme All Extended successfully");
384
				schemes("main-content");
385
			} else {
386
				alert("No scheme Activated Currently");
387
				schemes("main-content");
388
			}
389
		});
23343 ashik.ali 390
 
23914 govind 391
}
392
function extendSchemeById(schemeId) {
26763 tejbeer 393
	doPostAjaxRequestWithJsonHandler(context + "/extendSchemeById?schemeId="
28134 tejbeer 394
		+ schemeId, JSON.stringify(startDate), function(response) {
395
			if (response == 'true') {
396
				alert("Scheme extended successfully");
397
				schemes("main-content");
398
			} else {
399
				alert("Scheme already Expired");
400
				schemes("main-content");
401
			}
402
		});
23914 govind 403
 
404
}
405
 
23752 govind 406
function loadScheme(domId) {
407
	doGetAjaxRequestHandler(context + "/createScheme", function(response) {
23343 ashik.ali 408
		$('#' + domId).html(response);
409
	});
23752 govind 410
 
23343 ashik.ali 411
}
412
 
23914 govind 413
function loadTagListingItemsDescriptionByBrand(domId, brands) {
414
	doPostAjaxRequestWithJsonHandler(context + '/getTagListingItemsByBrand',
28134 tejbeer 415
		JSON.stringify(brands), function(response) {
416
			$('#' + domId).html(response);
417
			debugger;
418
			configureTagListingItemsDescriptionDropDown();
419
		});
23752 govind 420
 
23343 ashik.ali 421
}
422
 
23752 govind 423
function schemes(domId) {
424
	doGetAjaxRequestHandler(context + "/getSchemes", function(response) {
23343 ashik.ali 425
		$('#' + domId).html(response);
426
	});
427
}
27648 tejbeer 428
function marginCalculator(domId) {
429
	doGetAjaxRequestHandler(context + "/getMarginCalculator", function(response) {
430
		$('#' + domId).html(response);
431
	});
432
}
23343 ashik.ali 433
 
23752 govind 434
function loadSchemesDownloadPage(domId) {
435
	doGetAjaxRequestHandler(context + "/schemes/downloadPage", function(
28134 tejbeer 436
		response) {
23343 ashik.ali 437
		$('#' + domId).html(response);
438
	});
23556 amit.gupta 439
}
440
 
23752 govind 441
function loadSchemeUpdatePage(domId) {
442
	doGetAjaxRequestHandler(context + "/schemes/update-schemes-page", function(
28134 tejbeer 443
		response) {
23556 amit.gupta 444
		$('#' + domId).html(response);
445
	});
23557 amit.gupta 446
}
447
 
23928 govind 448
function updateSingleScheme(shcemeIds, itemIds) {
449
	doPostAjaxRequestWithJsonHandler(context + '/addItemToScheme', JSON
28134 tejbeer 450
		.stringify({
451
			"itemIds": itemIds.split(",").map(Number),
452
			"schemeIds": schemeIds.split(",").map(Number)
453
		}), function(response) {
454
			if (response == 'true') {
455
				alert("Item Added to scheme successfully");
456
				// $('#newItemToSchemeModal').modal('hide');
457
				loadSchemeDetails(shcemeIds, "scheme-details-container");
458
			} else {
459
				alert("Item already present");
460
				loadSchemeDetails(shcemeIds, "scheme-details-container");
461
			}
462
		});
23715 govind 463
}
23928 govind 464
function updateSchemes(shcemeIds, itemIds) {
465
	doPostAjaxRequestWithJsonHandler(context + '/schemes/update', JSON
28134 tejbeer 466
		.stringify({
467
			"itemIds": itemIds.split(",").map(Number),
468
			"schemeIds": schemeIds.split(",").map(Number)
469
		}), function(response) {
470
			if (response == 'true') {
471
				alert("Item Added to scheme successfully");
472
				// $('#newItemToSchemeModal').modal('hide');
473
				loadSchemeUpdatePage("main-content");
474
			}
475
		});
23928 govind 476
}
23914 govind 477
function deleteScheme(shcemeId, itemId) {
478
	doDeleteAjaxRequestHandler(context + "/schemes/delete?schemeId=" + shcemeId
28134 tejbeer 479
		+ "&itemId=" + itemId, function(response) {
480
			if (response == 'true') {
481
				alert("ItemId Deleted successfully from Scheme");
482
				loadSchemeDetails(shcemeId, "scheme-details-container");
483
			}
484
		});
23752 govind 485
}
486
function loadSearchScheme(domId, search_text) {
27875 amit.gupta 487
	doGetAjaxRequestHandler(context + "/searchScheme?searchTerm="
28134 tejbeer 488
		+ search_text, function(response) {
489
			$('#' + domId).html(response);
490
		});
23752 govind 491
}
27875 amit.gupta 492
function loadSearchItemScheme(domId, selected_item, date) {
26802 tejbeer 493
	var category = $('#partner-category').val();
494
	var searchText = $("#scheme-item-search-text").val();
26763 tejbeer 495
 
26802 tejbeer 496
	var category = $('#partner-category').val();
26912 tejbeer 497
 
498
	console.log(category)
499
 
26802 tejbeer 500
	if (typeof (searchText) == "undefined" || !searchText) {
501
		searchText = "";
502
	}
503
	if (typeof (category) == "undefined" || !category) {
504
		category = "";
505
	}
506
	if ((searchText) && (category)) {
27875 amit.gupta 507
		doGetAjaxRequestHandler(context + "/getSchemes?searchItem="
28134 tejbeer 508
			+ selected_item.itemId + "&partnerType=" + category, function(
26802 tejbeer 509
				response) {
510
			$('#' + domId).html(response);
511
			$('#partner-category').val(category);
512
			$('#scheme-item-search-text').val(selected_item.itemDescription);
513
 
514
		});
26912 tejbeer 515
	} else if ((searchText)) {
27875 amit.gupta 516
		doGetAjaxRequestHandler(`${context}/getSchemes?searchItem=${selected_item.itemId}&date=${date}`, function(response) {
26802 tejbeer 517
			$('#' + domId).html(response);
518
			$('#scheme-item-search-text').val(selected_item.itemDescription);
519
 
520
		});
26912 tejbeer 521
 
522
	}
523
 
23752 govind 524
}
28795 tejbeer 525
 
526
function loadSearchImeiScheme(domId, selected_imei, date) {
527
	var category = $('#partner-category').val();
528
	var searchText = $("#scheme-imei-search-text").val();
529
 
530
	var category = $('#partner-category').val();
531
 
532
	console.log(category)
533
 
534
	if (typeof (searchText) == "undefined" || !searchText) {
535
		searchText = "";
536
	}
537
	if (typeof (category) == "undefined" || !category) {
538
		category = "";
539
	}
540
	if ((searchText) && (category)) {
541
		doGetAjaxRequestHandler(context + "/getSchemes?searchImei="
542
			+ selected_imei + "&partnerType=" + category, function(
543
				response) {
544
			$('#' + domId).html(response);
545
 
546
			$('#partner-category').val(category);
547
			$('#scheme-imei-search-text').val(selected_imei);
548
		});
549
	} else if ((searchText)) {
550
		doGetAjaxRequestHandler(`${context}/getSchemes?searchImei=${selected_imei}&date=${date}`, function(response) {
551
			$('#' + domId).html(response);
552
			$('#scheme-imei-search-text').val(selected_imei);
553
 
554
		});
555
 
556
	}
557
 
558
}
23752 govind 559
function loadSchemeSearchInfo(search_text) {
560
	loadSearchScheme("main-content", search_text);
561
}
27875 amit.gupta 562
function loadSchemeItemSearchInfo(selectedItem, date) {
563
	loadSearchItemScheme("main-content", selectedItem, date);
23914 govind 564
}
28795 tejbeer 565
 
566
function loadSchemeImeiSearchInfo(selectedImei, date) {
567
 
568
	loadSearchImeiScheme("main-content", selectedImei, date);
569
}
570