Subversion Repositories SmartDukaan

Rev

Rev 29759 | Rev 29761 | 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");
29759 amit.gupta 141
			}	
28134 tejbeer 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
 
29759 amit.gupta 152
	$(document).on('click', ".process-investment", function() {
153
		if (confirm("Are you sure you want to Process Investment")) {
154
			processInvestment(schemeId);
155
		}
156
	});
157
 
29586 manish 158
	$(document).on('click', ".processInvestmentDryRun",
159
			function() {
160
		console.log("processInvestmentDryRun");
161
		window.location.href = context + "/processInvestmentDryRun";		
162
 
163
			});
164
 
165
 
166
 
167
 
23752 govind 168
 
27754 amit.gupta 169
	$(document).on('click', ".schemes", function() {
23347 ashik.ali 170
		console.log("Active Schemes Button Clicked...")
28134 tejbeer 171
 
172
		bootbox.confirm({
173
			message: "<div class = 'disclosurehindata'> <img src='resources/images/disclosure.png' style='width:100%'> </div>"
174
			,
175
			buttons: {
176
				confirm: {
177
					label: 'I agree',
178
					className: 'btn-success'
179
				},
180
				cancel: {
181
					label: 'I disagree',
182
					className: 'btn-danger'
183
				}
184
			},
185
			callback: function(result) {
186
				if (result == true) {
187
					schemes("main-content");
188
				}
189
			}
190
		});
191
 
23347 ashik.ali 192
	});
23752 govind 193
 
28134 tejbeer 194
	$(document).on('click', ".margin-calculator", function() {
27648 tejbeer 195
		console.log("Active Schemes Button Clicked...")
28134 tejbeer 196
		marginCalculator("main-content");
27648 tejbeer 197
	});
198
 
27754 amit.gupta 199
	$(document).on('click', ".schemes-download-page", function() {
23347 ashik.ali 200
		console.log("Schemes Download Clicked...")
201
		loadSchemesDownloadPage("main-content");
22860 ashik.ali 202
	});
23752 govind 203
 
27754 amit.gupta 204
	$(document).on('click', ".schemes-update", function() {
23556 amit.gupta 205
		loadSchemeUpdatePage("main-content");
206
	});
23557 amit.gupta 207
 
27754 amit.gupta 208
	$(document).on('click', ".add-item", function() {
23928 govind 209
 
210
		schemeIds = $("#schemeids").val();
211
		itemIds = $("#itemids").val();
212
		console.log(schemeIds);
213
		console.log(itemIds);
214
		if (confirm("Are you sure you want to Add Item to Scheme!") == true) {
26763 tejbeer 215
			if (itemIds.trim().length === 0 || schemeIds.trim().length === 0) {
216
				alert("fields shouldn't be blank");
217
				return;
218
			}
219
			updateSingleScheme(schemeIds, itemIds);
23928 govind 220
		}
221
	});
27754 amit.gupta 222
	$(document).on('click', ".add-schemes", function() {
23752 govind 223
 
23557 amit.gupta 224
		schemeIds = $("#schemeids").val();
225
		itemIds = $("#itemids").val();
23914 govind 226
		console.log(schemeIds);
227
		console.log(itemIds);
228
		if (confirm("Are you sure you want to Add Item to Scheme!") == true) {
26763 tejbeer 229
			if (itemIds.trim().length === 0 || schemeIds.trim().length === 0) {
230
				alert("fields shouldn't be blank");
231
				return;
232
			}
233
			updateSchemes(schemeIds, itemIds);
23557 amit.gupta 234
		}
235
	});
27754 amit.gupta 236
	$(document).on('click', ".delete-schemes", function() {
23819 govind 237
		if (confirm("Are you sure you want to delete Scheme!") == true) {
23914 govind 238
			schemeId = $(this).data('schemeid');
239
			itemId = $(this).data('itemid');
240
			console.log(schemeId);
241
			console.log(itemId);
242
			deleteScheme(schemeId, itemId);
23715 govind 243
		}
23752 govind 244
	});
245
 
27755 amit.gupta 246
	$(document).on('click', "#scheme-search-button",
28134 tejbeer 247
		function() {
248
			var searchText = $("#scheme-search-text").val();
249
			if (typeof (searchText) == "undefined" || !searchText) {
250
				searchText = "";
251
			}
252
			doGetAjaxRequestHandler(context + "/getSchemes?searchTerm="
253
				+ searchText, function(response) {
26802 tejbeer 254
					$('#' + "main-content").html(response);
255
				});
28134 tejbeer 256
		});
26802 tejbeer 257
 
27754 amit.gupta 258
	$(document).on("keyup", "#scheme-search-text", function(e) {
23752 govind 259
		var keyCode = e.keyCode || e.which;
260
		if (keyCode == 13) {
261
			$("#scheme-search-button").click();
262
		}
263
	});
27754 amit.gupta 264
	$(document).on('click', "#scheme-item-search-button", function() {
23752 govind 265
		var searchText = $("#scheme-item-search-text").val();
27875 amit.gupta 266
		var date = $(".schemes-date").val();
23752 govind 267
		if (typeof (searchText) == "undefined" || !searchText) {
268
			searchText = "";
26497 amit.gupta 269
			alert("please select item");
270
			return;
23752 govind 271
		}
27094 tejbeer 272
		if (typeof currentItem != "undefined") {
273
			console.log(currentItem);
27875 amit.gupta 274
			loadSchemeItemSearchInfo(currentItem, date);
27094 tejbeer 275
		} else {
276
			console.log("reeffff")
277
			alert("Data No Found")
278
		}
23752 govind 279
	});
280
 
28795 tejbeer 281
 
282
	$(document).on('click', "#scheme-imei-search-button", function() {
283
		var searchText = $("#scheme-imei-search-text").val();
284
		var date = $(".schemes-date").val();
285
		if (typeof (searchText) == "undefined" || !searchText) {
286
			searchText = "";
287
			alert("please select imei");
288
			return;
289
		}
290
		if (typeof imei != "undefined") {
291
			console.log(imei);
292
			loadSchemeImeiSearchInfo(imei, date);
293
		} else {
294
			console.log("reeffff")
295
			alert("Data No Found")
296
		}
297
	});
27755 amit.gupta 298
	$(document).on('click', ".categoryWiseSchemeHistory",
28134 tejbeer 299
		function() {
300
			var category = $('#partner-category').val();
301
			console.log(category);
26763 tejbeer 302
 
28134 tejbeer 303
			doGetAjaxRequestHandler(context + "/getSchemes?partnerType="
304
				+ category, function(response) {
26802 tejbeer 305
					$('#' + "main-content").html(response);
306
					$('#partner-category').val(category);
307
					window.dispatchEvent(new Event('resize'));
308
				});
26763 tejbeer 309
 
28134 tejbeer 310
		});
26763 tejbeer 311
 
27754 amit.gupta 312
	$(document).on("keyup", "#scheme-item-search-text", function(e) {
23752 govind 313
		var keyCode = e.keyCode || e.which;
314
		if (keyCode == 13) {
315
			$("#scheme-item-search-button").click();
316
		}
317
	});
22860 ashik.ali 318
});
319
 
23752 govind 320
function configureTagListingItemsDescriptionDropDown() {
28134 tejbeer 321
	$('.tagListingItemsDescription').multiselect({
322
		includeSelectAllOption: true,
323
		maxHeight: 200,
324
		buttonWidth: '180px',
325
		numberDisplayed: 1,
326
		nonSelectedText: 'Items',
327
		nSelectedText: ' - Items Selected',
328
		allSelectedText: 'All Items Selected',
329
		enableFiltering: true,
330
		enableCaseInsensitiveFiltering: true
23752 govind 331
	});
23343 ashik.ali 332
}
333
 
23752 govind 334
function schemesDownload() {
23343 ashik.ali 335
	console.log("downloadItemLedgerReport Button clicked")
23914 govind 336
	var startDateTime = $('input[name="startDateTime"]').val();
337
	console.log("startDateTime : " + startDateTime);
338
	var endDateTime = $('input[name="endDateTime"]').val();
339
	console.log("endDateTime : " + endDateTime);
23752 govind 340
	doAjaxGetDownload(context + "/schemes/download?startDateTime="
28134 tejbeer 341
		+ startDateTime + "&endDateTime=" + endDateTime,
342
		"SchemesReport.xlsx");
23343 ashik.ali 343
}
23914 govind 344
function selectedbrand() {
345
	var brands = $('#tag-listing-brands').val();
346
	console.log(brands);
347
	if (brands) {
348
		loadTagListingItemsDescriptionByBrand(
28134 tejbeer 349
			"tag-listing-items-description-container", brands);
23914 govind 350
	}
351
}
23752 govind 352
function loadSchemeDetails(schemeId, domId) {
353
	doGetAjaxRequestHandler(context + "/getSchemeById?schemeId=" + schemeId,
28134 tejbeer 354
		function(response) {
355
			$('#' + domId).html(response);
356
			window.dispatchEvent(new Event('resize'));
357
		});
23343 ashik.ali 358
}
359
 
23752 govind 360
function activeScheme(schemeId, offset, domId) {
361
	doPutAjaxRequestHandler(context + "/activeSchemeById?schemeId=" + schemeId
28134 tejbeer 362
		+ "&offset=" + offset, function(response) {
363
			$('#' + domId).html(response);
364
			$('#scheme-details-container').html('');
365
		});
23752 govind 366
 
23343 ashik.ali 367
}
368
 
25069 amit.gupta 369
function expireScheme(schemeId, expireDate, offset, domId) {
23752 govind 370
	doPutAjaxRequestHandler(context + "/expireSchemeById?schemeId=" + schemeId
28134 tejbeer 371
		+ "&offset=" + offset + "&expireTimestamp=" + expireDate, function(
26763 tejbeer 372
			response) {
373
		alert("Scheme - " + schemeId + " marked for expiry successfully!");
23343 ashik.ali 374
		$('#' + domId).html(response);
375
		$('#scheme-details-container').html('');
376
	});
377
}
23914 govind 378
function extendAllScheme(domId) {
26763 tejbeer 379
	doPostAjaxRequestWithJsonHandler(context + "/extendAllSchemes", JSON
28134 tejbeer 380
		.stringify(startDate), function(response) {
381
			if (response == 'true') {
382
				alert("Scheme All Extended successfully");
383
				schemes("main-content");
384
			} else {
385
				alert("No scheme Activated Currently");
386
				schemes("main-content");
387
			}
388
		});
23343 ashik.ali 389
 
23914 govind 390
}
391
function extendSchemeById(schemeId) {
26763 tejbeer 392
	doPostAjaxRequestWithJsonHandler(context + "/extendSchemeById?schemeId="
28134 tejbeer 393
		+ schemeId, JSON.stringify(startDate), function(response) {
394
			if (response == 'true') {
395
				alert("Scheme extended successfully");
396
				schemes("main-content");
397
			} else {
398
				alert("Scheme already Expired");
399
				schemes("main-content");
400
			}
401
		});
23914 govind 402
 
403
}
29760 amit.gupta 404
function processInvestment(schemeId) {
29759 amit.gupta 405
	doPostAjaxRequestWithJsonHandler(context + "/processInvestment", function(response) {
406
		alert("InvestmentPayout processed successfully");
407
	});
408
}
23914 govind 409
 
23752 govind 410
function loadScheme(domId) {
411
	doGetAjaxRequestHandler(context + "/createScheme", function(response) {
23343 ashik.ali 412
		$('#' + domId).html(response);
413
	});
23752 govind 414
 
23343 ashik.ali 415
}
416
 
23914 govind 417
function loadTagListingItemsDescriptionByBrand(domId, brands) {
418
	doPostAjaxRequestWithJsonHandler(context + '/getTagListingItemsByBrand',
28134 tejbeer 419
		JSON.stringify(brands), function(response) {
420
			$('#' + domId).html(response);
421
			debugger;
422
			configureTagListingItemsDescriptionDropDown();
423
		});
23752 govind 424
 
23343 ashik.ali 425
}
426
 
23752 govind 427
function schemes(domId) {
428
	doGetAjaxRequestHandler(context + "/getSchemes", function(response) {
23343 ashik.ali 429
		$('#' + domId).html(response);
430
	});
431
}
27648 tejbeer 432
function marginCalculator(domId) {
433
	doGetAjaxRequestHandler(context + "/getMarginCalculator", function(response) {
434
		$('#' + domId).html(response);
435
	});
436
}
23343 ashik.ali 437
 
23752 govind 438
function loadSchemesDownloadPage(domId) {
439
	doGetAjaxRequestHandler(context + "/schemes/downloadPage", function(
28134 tejbeer 440
		response) {
23343 ashik.ali 441
		$('#' + domId).html(response);
442
	});
23556 amit.gupta 443
}
444
 
23752 govind 445
function loadSchemeUpdatePage(domId) {
446
	doGetAjaxRequestHandler(context + "/schemes/update-schemes-page", function(
28134 tejbeer 447
		response) {
23556 amit.gupta 448
		$('#' + domId).html(response);
449
	});
23557 amit.gupta 450
}
451
 
23928 govind 452
function updateSingleScheme(shcemeIds, itemIds) {
453
	doPostAjaxRequestWithJsonHandler(context + '/addItemToScheme', JSON
28134 tejbeer 454
		.stringify({
455
			"itemIds": itemIds.split(",").map(Number),
456
			"schemeIds": schemeIds.split(",").map(Number)
457
		}), function(response) {
458
			if (response == 'true') {
459
				alert("Item Added to scheme successfully");
460
				// $('#newItemToSchemeModal').modal('hide');
461
				loadSchemeDetails(shcemeIds, "scheme-details-container");
462
			} else {
463
				alert("Item already present");
464
				loadSchemeDetails(shcemeIds, "scheme-details-container");
465
			}
466
		});
23715 govind 467
}
23928 govind 468
function updateSchemes(shcemeIds, itemIds) {
469
	doPostAjaxRequestWithJsonHandler(context + '/schemes/update', JSON
28134 tejbeer 470
		.stringify({
471
			"itemIds": itemIds.split(",").map(Number),
472
			"schemeIds": schemeIds.split(",").map(Number)
473
		}), function(response) {
474
			if (response == 'true') {
475
				alert("Item Added to scheme successfully");
476
				// $('#newItemToSchemeModal').modal('hide');
477
				loadSchemeUpdatePage("main-content");
478
			}
479
		});
23928 govind 480
}
23914 govind 481
function deleteScheme(shcemeId, itemId) {
482
	doDeleteAjaxRequestHandler(context + "/schemes/delete?schemeId=" + shcemeId
28134 tejbeer 483
		+ "&itemId=" + itemId, function(response) {
484
			if (response == 'true') {
485
				alert("ItemId Deleted successfully from Scheme");
486
				loadSchemeDetails(shcemeId, "scheme-details-container");
487
			}
488
		});
23752 govind 489
}
490
function loadSearchScheme(domId, search_text) {
27875 amit.gupta 491
	doGetAjaxRequestHandler(context + "/searchScheme?searchTerm="
28134 tejbeer 492
		+ search_text, function(response) {
493
			$('#' + domId).html(response);
494
		});
23752 govind 495
}
27875 amit.gupta 496
function loadSearchItemScheme(domId, selected_item, date) {
26802 tejbeer 497
	var category = $('#partner-category').val();
498
	var searchText = $("#scheme-item-search-text").val();
26763 tejbeer 499
 
26802 tejbeer 500
	var category = $('#partner-category').val();
26912 tejbeer 501
 
502
	console.log(category)
503
 
26802 tejbeer 504
	if (typeof (searchText) == "undefined" || !searchText) {
505
		searchText = "";
506
	}
507
	if (typeof (category) == "undefined" || !category) {
508
		category = "";
509
	}
510
	if ((searchText) && (category)) {
27875 amit.gupta 511
		doGetAjaxRequestHandler(context + "/getSchemes?searchItem="
28134 tejbeer 512
			+ selected_item.itemId + "&partnerType=" + category, function(
26802 tejbeer 513
				response) {
514
			$('#' + domId).html(response);
515
			$('#partner-category').val(category);
516
			$('#scheme-item-search-text').val(selected_item.itemDescription);
517
 
518
		});
26912 tejbeer 519
	} else if ((searchText)) {
27875 amit.gupta 520
		doGetAjaxRequestHandler(`${context}/getSchemes?searchItem=${selected_item.itemId}&date=${date}`, function(response) {
26802 tejbeer 521
			$('#' + domId).html(response);
522
			$('#scheme-item-search-text').val(selected_item.itemDescription);
523
 
524
		});
26912 tejbeer 525
 
526
	}
527
 
23752 govind 528
}
28795 tejbeer 529
 
530
function loadSearchImeiScheme(domId, selected_imei, date) {
531
	var category = $('#partner-category').val();
532
	var searchText = $("#scheme-imei-search-text").val();
533
 
534
	var category = $('#partner-category').val();
535
 
536
	console.log(category)
537
 
538
	if (typeof (searchText) == "undefined" || !searchText) {
539
		searchText = "";
540
	}
541
	if (typeof (category) == "undefined" || !category) {
542
		category = "";
543
	}
544
	if ((searchText) && (category)) {
545
		doGetAjaxRequestHandler(context + "/getSchemes?searchImei="
546
			+ selected_imei + "&partnerType=" + category, function(
547
				response) {
548
			$('#' + domId).html(response);
549
 
550
			$('#partner-category').val(category);
551
			$('#scheme-imei-search-text').val(selected_imei);
552
		});
553
	} else if ((searchText)) {
554
		doGetAjaxRequestHandler(`${context}/getSchemes?searchImei=${selected_imei}&date=${date}`, function(response) {
555
			$('#' + domId).html(response);
556
			$('#scheme-imei-search-text').val(selected_imei);
557
 
558
		});
559
 
560
	}
561
 
562
}
23752 govind 563
function loadSchemeSearchInfo(search_text) {
564
	loadSearchScheme("main-content", search_text);
565
}
27875 amit.gupta 566
function loadSchemeItemSearchInfo(selectedItem, date) {
567
	loadSearchItemScheme("main-content", selectedItem, date);
23914 govind 568
}
28795 tejbeer 569
 
570
function loadSchemeImeiSearchInfo(selectedImei, date) {
571
 
572
	loadSearchImeiScheme("main-content", selectedImei, date);
573
}
574