Subversion Repositories SmartDukaan

Rev

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

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