Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
31762 tejbeer 1
$(function() {
2
	$(document).on('click', ".create-scheme", function() {
23343 ashik.ali 3
		loadScheme("main-content");
4
	});
31762 tejbeer 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
	});
31762 tejbeer 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
 
31762 tejbeer 21
 
22
	$(document).on('click', ".scheme-imei-history", function() {
23
		loadImeiWiseScheme("main-content");
24
	});
25
 
26
	$(document).on('click', ".expire-scheme", function() {
23343 ashik.ali 27
		var schemeId = $(this).attr('data');
30599 amit.gupta 28
		var expireDate = getDatesFromPicker('input[name="expireSchemeById"]').endDate;
30122 amit.gupta 29
		if (confirm("Are you sure you want to Expire Scheme!")) {
30599 amit.gupta 30
			expireScheme(schemeId, expireDate, "schemes-table");
23343 ashik.ali 31
		}
32
	});
27755 amit.gupta 33
	$(document).on('click', "#extendDatetime-button",
31762 tejbeer 34
		function() {
28134 tejbeer 35
			console.log("extendAll button click");
30599 amit.gupta 36
			var extendDatetime = getDatesFromPicker('input[name="extendDatetime"]')
37
				.endDate;
28134 tejbeer 38
			console.log("extendDatetime : " + extendDatetime);
39
			if (extendDatetime) {
30122 amit.gupta 40
				if (confirm("Are you sure you want to Extend expireDateTime for All Scheme!")) {
30599 amit.gupta 41
					extendAllScheme(extendDatetime);
28134 tejbeer 42
				}
43
			} else {
44
				alert("feild can't be blank");
45
			}
46
		});
27755 amit.gupta 47
	$(document).on('click', "#extendScheme-button",
31762 tejbeer 48
		function() {
28134 tejbeer 49
			console.log("extend button click");
30599 amit.gupta 50
			var extendDatetime = getDatesFromPicker('input[name="extendSchemeById"]').endDate;
28134 tejbeer 51
			var schemeId = $('#schemeId').val()
52
			console.log("extendDatetime : " + extendDatetime);
53
			console.log(schemeId);
54
			if (extendDatetime) {
55
				if (confirm("Are you sure you want to Extend expireDateTime for Scheme!") == true) {
30599 amit.gupta 56
					extendSchemeById(extendDatetime, schemeId);
28134 tejbeer 57
				}
58
			} else {
30054 manish 59
				alert("field can't be blank");
30122 amit.gupta 60
			}
28134 tejbeer 61
		});
30122 amit.gupta 62
 
63
 
29586 manish 64
	$(document).on('click', ".monthy-investment",
31762 tejbeer 65
		function() {
30122 amit.gupta 66
			console.log("hello evaluateActualInvestmentPayout");
67
			window.location.href = context + "/evaluateActualInvestmentPayout";
68
 
69
		});
70
 
31762 tejbeer 71
	$(document).on('click', ".process-investment", function() {
29759 amit.gupta 72
		if (confirm("Are you sure you want to Process Investment")) {
29761 amit.gupta 73
			processInvestment();
29759 amit.gupta 74
		}
75
	});
76
 
30122 amit.gupta 77
 
29586 manish 78
	$(document).on('click', ".processInvestmentDryRun",
31762 tejbeer 79
		function() {
30122 amit.gupta 80
			console.log("processInvestmentDryRun");
81
			window.location.href = context + "/processInvestmentDryRun";
82
 
83
		});
84
 
30054 manish 85
	$(document).on('click', ".brand-wise-income",
31762 tejbeer 86
		function() {
30122 amit.gupta 87
			var brand = $(this).data('brand');
88
 
89
			var status = $(this).data('status');
90
			var month = $(this).data('month');
91
 
92
			brandWiseIncome(brand, month, status);
93
 
94
		});
95
 
30054 manish 96
	$(document).on('click', ".imei_wise_income",
31762 tejbeer 97
		function() {
23752 govind 98
 
30122 amit.gupta 99
 
100
			var catalogItemId = $(this).data('catalogitemid');
101
			var month = $(this).data('month');
102
 
103
			console.log(catalogItemId);
104
			imeiWiseIncome(catalogItemId, month);
105
 
106
		});
107
 
31762 tejbeer 108
	$(document).on('change', "#month-wise-income", function() {
30122 amit.gupta 109
		var month = $(this).val();
110
 
111
		monthWiseIncome(month, "main-content");
112
	});
113
 
114
 
31762 tejbeer 115
	$(document).on('click', ".schemes", function() {
30122 amit.gupta 116
		schemes("main-content");
23347 ashik.ali 117
		console.log("Active Schemes Button Clicked...")
28134 tejbeer 118
 
30122 amit.gupta 119
		/*bootbox.confirm({
28134 tejbeer 120
			message: "<div class = 'disclosurehindata'> <img src='resources/images/disclosure.png' style='width:100%'> </div>"
121
			,
122
			buttons: {
123
				confirm: {
124
					label: 'I agree',
125
					className: 'btn-success'
126
				},
127
				cancel: {
128
					label: 'I disagree',
129
					className: 'btn-danger'
130
				}
131
			},
30122 amit.gupta 132
			callback: function (result) {
28134 tejbeer 133
				if (result == true) {
134
				}
135
			}
30122 amit.gupta 136
		});*/
28134 tejbeer 137
 
23347 ashik.ali 138
	});
23752 govind 139
 
31762 tejbeer 140
	$(document).on('click', ".margin-calculator", function() {
27648 tejbeer 141
		console.log("Active Schemes Button Clicked...")
28134 tejbeer 142
		marginCalculator("main-content");
27648 tejbeer 143
	});
144
 
31762 tejbeer 145
	$(document).on('click', ".schemes-download-page", function() {
23347 ashik.ali 146
		console.log("Schemes Download Clicked...")
147
		loadSchemesDownloadPage("main-content");
22860 ashik.ali 148
	});
23752 govind 149
 
31762 tejbeer 150
	$(document).on('click', ".schemes-update", function() {
23556 amit.gupta 151
		loadSchemeUpdatePage("main-content");
152
	});
23557 amit.gupta 153
 
31762 tejbeer 154
	$(document).on('click', ".add-item", function() {
23928 govind 155
 
156
		schemeIds = $("#schemeids").val();
30122 amit.gupta 157
		itemIds = $("#catalogids").val();
158
		if (confirm("Are you sure you want to Add Model to Scheme!") == true) {
159
			if (catalogIds.trim().length === 0 || schemeIds.trim().length === 0) {
26763 tejbeer 160
				alert("fields shouldn't be blank");
161
				return;
162
			}
30122 amit.gupta 163
			updateSingleScheme(schemeIds, catalogIds);
23928 govind 164
		}
165
	});
31762 tejbeer 166
	$(document).on('click', ".add-schemes", function() {
23752 govind 167
 
30122 amit.gupta 168
		let schemeIds = $("#schemeids").val();
169
		let catalogIds = $("#catalogids").val();
170
 
23914 govind 171
		if (confirm("Are you sure you want to Add Item to Scheme!") == true) {
30122 amit.gupta 172
			if (catalogIds.trim().length === 0 || schemeIds.trim().length === 0) {
26763 tejbeer 173
				alert("fields shouldn't be blank");
174
				return;
175
			}
30122 amit.gupta 176
			updateSchemes(schemeIds, catalogIds);
23557 amit.gupta 177
		}
178
	});
32299 jai.hind 179
 
180
	$(document).on('click', ".process-sellIn", function() {
181
    let purchaseInvoiceNumber=$("#invoiceNumbers1").val();
182
    if (confirm("Are you sure you want to Process SellIn") == true) {
183
    			if (purchaseInvoiceNumber.trim().length === 0) {
184
    				alert("fields shouldn't be blank");
185
    				return;
186
    			}
187
    			processSellin(purchaseInvoiceNumber);
188
    		}
189
 
190
	});
191
 
192
	$(document).on('click', ".process-sellOut", function() {
193
    let fofoOrderInvoiceNumber=$("#invoiceNumbers2").val();
194
    if (confirm("Are you sure you want to Process SellOut") == true) {
195
        			if (fofoOrderInvoiceNumber.trim().length === 0) {
196
        				alert("fields shouldn't be blank");
197
        				return;
198
        			}
199
        			processSellout(fofoOrderInvoiceNumber);
200
        		}
201
 
202
    });
203
 
31762 tejbeer 204
	$(document).on('click', ".delete-schemes", function() {
30122 amit.gupta 205
		if (confirm("Delete model from Scheme?") == true) {
23914 govind 206
			schemeId = $(this).data('schemeid');
30122 amit.gupta 207
			catalogId = $(this).data('catalogid');
208
			deleteScheme(schemeId, catalogId);
23715 govind 209
		}
23752 govind 210
	});
211
 
27755 amit.gupta 212
	$(document).on('click', "#scheme-search-button",
31762 tejbeer 213
		function() {
28134 tejbeer 214
			var searchText = $("#scheme-search-text").val();
215
			if (typeof (searchText) == "undefined" || !searchText) {
216
				searchText = "";
217
			}
30122 amit.gupta 218
			doGetAjaxRequestHandler(context + "/getSchemes?searchScheme="
31762 tejbeer 219
				+ searchText, function(response) {
220
					$('#' + "main-content").html(response);
221
				});
28134 tejbeer 222
		});
26802 tejbeer 223
 
31762 tejbeer 224
	$(document).on("keyup", "#scheme-search-text", function(e) {
23752 govind 225
		var keyCode = e.keyCode || e.which;
226
		if (keyCode == 13) {
227
			$("#scheme-search-button").click();
228
		}
229
	});
31762 tejbeer 230
	$(document).on('click', "#scheme-item-search-button", function() {
23752 govind 231
		var searchText = $("#scheme-item-search-text").val();
27875 amit.gupta 232
		var date = $(".schemes-date").val();
23752 govind 233
		if (typeof (searchText) == "undefined" || !searchText) {
234
			searchText = "";
26497 amit.gupta 235
			alert("please select item");
236
			return;
23752 govind 237
		}
27094 tejbeer 238
		if (typeof currentItem != "undefined") {
239
			console.log(currentItem);
27875 amit.gupta 240
			loadSchemeItemSearchInfo(currentItem, date);
27094 tejbeer 241
		} else {
242
			console.log("reeffff")
243
			alert("Data No Found")
244
		}
23752 govind 245
	});
246
 
31762 tejbeer 247
	$(document).on('click', "#scheme-imei-search-button", function() {
28795 tejbeer 248
		var searchText = $("#scheme-imei-search-text").val();
249
		var date = $(".schemes-date").val();
250
		if (typeof (searchText) == "undefined" || !searchText) {
251
			searchText = "";
252
			alert("please select imei");
253
			return;
254
		}
255
		if (typeof imei != "undefined") {
256
			console.log(imei);
257
			loadSchemeImeiSearchInfo(imei, date);
258
		} else {
259
			console.log("reeffff")
260
			alert("Data No Found")
261
		}
262
	});
31762 tejbeer 263
 
264
	$(document).on('click', "#scheme-imei-wise-search-button", function() {
265
		var searchText = $("#scheme-imei-wise-search-text").val();
266
		var date = $(".schemes-date").val();
32331 amit.gupta 267
		if (typeof (searchText) === "undefined" || !searchText) {
31762 tejbeer 268
			searchText = "";
269
			alert("please select imei");
270
			return;
271
		}
32331 amit.gupta 272
		if (typeof imei !== "undefined") {
31762 tejbeer 273
			console.log(imei);
274
			var searchText = $("#scheme-imei-wise-search-text").val();
275
 
276
			if ((searchText)) {
277
				doGetAjaxRequestHandler(`${context}/getSchemesByImei?searchImei=${searchText}`, function(response) {
278
					$('#' +  "main-content").html(response);
279
					$('#scheme-imei-search-text').val(searchText);
280
 
281
				});
282
			}
283
		} else {
32331 amit.gupta 284
			console.log("reeffff");
285
			alert("Data No Found");
31762 tejbeer 286
		}
287
	});
27755 amit.gupta 288
	$(document).on('click', ".categoryWiseSchemeHistory",
34575 vikas.jang 289
	function() {
290
		var category = $('#partner-category').val();
291
		console.log(category);
26763 tejbeer 292
 
34575 vikas.jang 293
		doGetAjaxRequestHandler(context + "/getSchemes?partnerType="
294
			+ category, function(response) {
295
				$('#' + "main-content").html(response);
296
				$('#partner-category').val(category);
297
				window.dispatchEvent(new Event('resize'));
298
			});
26763 tejbeer 299
 
34575 vikas.jang 300
	});
26763 tejbeer 301
 
31762 tejbeer 302
	$(document).on("keyup", "#scheme-item-search-text", function(e) {
23752 govind 303
		var keyCode = e.keyCode || e.which;
304
		if (keyCode == 13) {
305
			$("#scheme-item-search-button").click();
306
		}
307
	});
22860 ashik.ali 308
});
309
 
23752 govind 310
function configureTagListingItemsDescriptionDropDown() {
30148 amit.gupta 311
	$('.catalogItemsDescription').multiselect({
28134 tejbeer 312
		includeSelectAllOption: true,
313
		maxHeight: 200,
314
		buttonWidth: '180px',
315
		numberDisplayed: 1,
30148 amit.gupta 316
		nonSelectedText: 'Models',
317
		nSelectedText: ' - Models Selected',
318
		allSelectedText: 'All Models Selected',
28134 tejbeer 319
		enableFiltering: true,
320
		enableCaseInsensitiveFiltering: true
23752 govind 321
	});
23343 ashik.ali 322
}
323
 
23752 govind 324
function schemesDownload() {
30599 amit.gupta 325
	let pickerData = getDatesFromPicker('input[name="startEndDateTime"]')
326
	doAjaxGetDownload(context + "/schemes/download?" +
327
		"startDateTime=" + pickerData.startDate
328
		+ "&endDateTime=" + pickerData.endDate,
28134 tejbeer 329
		"SchemesReport.xlsx");
23343 ashik.ali 330
}
30122 amit.gupta 331
 
30501 amit.gupta 332
function selectedbrand(categoryId) {
23914 govind 333
	var brands = $('#tag-listing-brands').val();
334
	if (brands) {
30148 amit.gupta 335
		loadCatalogDescriptionByBrands(
30501 amit.gupta 336
			"tag-listing-items-description-container", categoryId, brands);
23914 govind 337
	}
338
}
30122 amit.gupta 339
 
30492 amit.gupta 340
function categoryChanged() {
341
	let categoryId = $('#category-list').val();
342
	if (categoryId) {
343
		loadBrandsByCategory(
344
			"brand-list", categoryId);
345
	}
346
}
347
 
23752 govind 348
function loadSchemeDetails(schemeId, domId) {
349
	doGetAjaxRequestHandler(context + "/getSchemeById?schemeId=" + schemeId,
31762 tejbeer 350
		function(response) {
28134 tejbeer 351
			$('#' + domId).html(response);
352
			window.dispatchEvent(new Event('resize'));
353
		});
23343 ashik.ali 354
}
355
 
23752 govind 356
function activeScheme(schemeId, offset, domId) {
357
	doPutAjaxRequestHandler(context + "/activeSchemeById?schemeId=" + schemeId
34575 vikas.jang 358
	+ "&offset=" + offset, function(response) {
359
		$('#' + domId).html(response);
360
		$('#scheme-details-container').html('');
361
	});
23343 ashik.ali 362
}
363
 
30599 amit.gupta 364
function expireScheme(schemeId, expireDate, domId) {
23752 govind 365
	doPutAjaxRequestHandler(context + "/expireSchemeById?schemeId=" + schemeId
31762 tejbeer 366
		+ "&expireTimestamp=" + expireDate, function(
367
			response) {
26763 tejbeer 368
		alert("Scheme - " + schemeId + " marked for expiry successfully!");
23343 ashik.ali 369
		$('#' + domId).html(response);
370
		$('#scheme-details-container').html('');
371
	});
372
}
30122 amit.gupta 373
 
30599 amit.gupta 374
function extendAllScheme(extendDate) {
26763 tejbeer 375
	doPostAjaxRequestWithJsonHandler(context + "/extendAllSchemes", JSON
31762 tejbeer 376
		.stringify(extendDate), function(response) {
377
			if (response == 'true') {
378
				alert("Scheme All Extended successfully");
379
				schemes("main-content");
380
			} else {
381
				alert("No scheme Activated Currently");
382
				schemes("main-content");
383
			}
384
		});
23343 ashik.ali 385
 
23914 govind 386
}
30122 amit.gupta 387
 
30599 amit.gupta 388
function extendSchemeById(extendDate, schemeId) {
26763 tejbeer 389
	doPostAjaxRequestWithJsonHandler(context + "/extendSchemeById?schemeId="
31762 tejbeer 390
		+ schemeId, JSON.stringify(extendDate), function(response) {
391
			if (response == 'true') {
392
				alert("Scheme extended successfully");
393
				schemes("main-content");
394
			} else {
395
				alert("Scheme already Expired");
396
				schemes("main-content");
397
			}
398
		});
23914 govind 399
}
30122 amit.gupta 400
 
29761 amit.gupta 401
function processInvestment() {
31762 tejbeer 402
	doPostAjaxRequestWithJsonHandler(context + "/payMonthlyInvestment", function(response) {
29759 amit.gupta 403
		alert("InvestmentPayout processed successfully");
404
	});
405
}
23914 govind 406
 
23752 govind 407
function loadScheme(domId) {
31762 tejbeer 408
	doGetAjaxRequestHandler(context + "/createScheme", function(response) {
23343 ashik.ali 409
		$('#' + domId).html(response);
30492 amit.gupta 410
		createSchemeOnReady();
411
		categoryChanged();
30599 amit.gupta 412
		$('input[name="dateRange"]').daterangepicker(getRangedDatePicker());
23343 ashik.ali 413
	});
23752 govind 414
 
23343 ashik.ali 415
}
416
 
31762 tejbeer 417
function loadImeiWiseScheme(domId) {
418
	doGetAjaxRequestHandler(context + "/getSchemesByImei",
419
		function(response) {
420
			$('#' + domId).html(response);
421
 
422
		});
423
}
424
 
30501 amit.gupta 425
function loadCatalogDescriptionByBrands(domId, categoryId, brands) {
426
	let brandsString = brands.join(",")
427
	doGetAjaxRequestHandler(`${context}/getCatalogDescriptionByBrands?categoryId=${categoryId}&brands=${brandsString}`,
31762 tejbeer 428
		function(response) {
28134 tejbeer 429
			$('#' + domId).html(response);
430
			configureTagListingItemsDescriptionDropDown();
431
		});
23752 govind 432
 
23343 ashik.ali 433
}
434
 
30492 amit.gupta 435
function loadBrandsByCategory(domId, categoryId) {
436
	doGetAjaxRequestHandler(`${context}/getBrandsByCategory?categoryId=${categoryId}`,
31762 tejbeer 437
		function(response) {
30492 amit.gupta 438
			$('#' + domId).html(response);
439
			configureBrandsDropDown();
440
		});
441
}
442
 
23752 govind 443
function schemes(domId) {
31762 tejbeer 444
	doGetAjaxRequestHandler(context + "/getSchemes", function(response) {
23343 ashik.ali 445
		$('#' + domId).html(response);
446
	});
447
}
30122 amit.gupta 448
 
27648 tejbeer 449
function marginCalculator(domId) {
31762 tejbeer 450
	doGetAjaxRequestHandler(context + "/getMarginCalculator", function(response) {
27648 tejbeer 451
		$('#' + domId).html(response);
452
	});
453
}
23343 ashik.ali 454
 
23752 govind 455
function loadSchemesDownloadPage(domId) {
31762 tejbeer 456
	doGetAjaxRequestHandler(context + "/schemes/downloadPage", function(
28134 tejbeer 457
		response) {
23343 ashik.ali 458
		$('#' + domId).html(response);
459
	});
23556 amit.gupta 460
}
461
 
23752 govind 462
function loadSchemeUpdatePage(domId) {
32299 jai.hind 463
doGetAjaxRequestHandler(context + "/schemes/update-schemes-page", function(
28134 tejbeer 464
		response) {
23556 amit.gupta 465
		$('#' + domId).html(response);
466
	});
23557 amit.gupta 467
}
468
 
30122 amit.gupta 469
function brandWiseIncome(brand, month, status) {
30054 manish 470
	console.log(brand);
471
	console.log(month);
30122 amit.gupta 472
 
32331 amit.gupta 473
	doGetAjaxRequestHandler(`${context}/brandWiseIncome?brand=${brand}&month=${month}`, function (
30054 manish 474
		response) {
475
		$('.imei-wise-income-container').html('');
30122 amit.gupta 476
		$('.brand-wise-income-container').html(response);
30054 manish 477
	});
478
}
479
 
30122 amit.gupta 480
function monthWiseIncome(month, domId) {
30054 manish 481
	console.log(month);
31762 tejbeer 482
	doGetAjaxRequestHandler(context + "/monthWisePartnerIncome/" + month, function(response) {
30122 amit.gupta 483
		console.log(response);
484
		$('#' + domId).html(response);
485
	})
30054 manish 486
}
30122 amit.gupta 487
 
488
function imeiWiseIncome(catalogItemId, month) {
30054 manish 489
	console.log(catalogItemId);
490
	console.log(month);
30122 amit.gupta 491
 
31762 tejbeer 492
	doGetAjaxRequestHandler(context + "/getLastMonthImeiWiseIncome?catalogItemId=" + catalogItemId + "&month=" + month, function(
30054 manish 493
		response) {
30122 amit.gupta 494
		$('.imei-wise-income-container').html(response);
30054 manish 495
	});
496
}
497
 
30122 amit.gupta 498
function updateSingleScheme(shcemeIds, catalogIds) {
23928 govind 499
	doPostAjaxRequestWithJsonHandler(context + '/addItemToScheme', JSON
28134 tejbeer 500
		.stringify({
30122 amit.gupta 501
			"catalogIds": catalogIds.split(",").map(Number),
28134 tejbeer 502
			"schemeIds": schemeIds.split(",").map(Number)
31762 tejbeer 503
		}), function(response) {
504
			if (response == 'true') {
505
				alert("Item Added to scheme successfully");
506
				// $('#newItemToSchemeModal').modal('hide');
507
				loadSchemeDetails(shcemeIds, "scheme-details-container");
508
			} else {
509
				alert("Item already present");
510
				loadSchemeDetails(shcemeIds, "scheme-details-container");
511
			}
512
		});
23715 govind 513
}
30122 amit.gupta 514
 
515
function updateSchemes(schemeIds, catalogIds) {
23928 govind 516
	doPostAjaxRequestWithJsonHandler(context + '/schemes/update', JSON
28134 tejbeer 517
		.stringify({
30122 amit.gupta 518
			"catalogIds": catalogIds.split(",").map(Number),
28134 tejbeer 519
			"schemeIds": schemeIds.split(",").map(Number)
31762 tejbeer 520
		}), function(response) {
521
			if (response == 'true') {
522
				alert("Item Added to scheme successfully");
523
				// $('#newItemToSchemeModal').modal('hide');
524
				loadSchemeUpdatePage("main-content");
525
			}
526
		});
23928 govind 527
}
30122 amit.gupta 528
 
32299 jai.hind 529
function processSellin(purchaseInvoiceNumber) {
530
	doPostAjaxRequestWithJsonHandler(context + "/schemes/process-sellin",
531
	JSON.stringify(purchaseInvoiceNumber.split(",").map(x=>x.trim())), function(response) {
532
			if (response) {
533
				alert("Invoices Processed Successfully");
534
				loadSchemeUpdatePage("main-content");
535
			}
536
		});
537
}
538
 
539
function processSellout(fofoOrderInvoiceNumber) {
540
	doPostAjaxRequestWithJsonHandler(context + "/schemes/process-sellout",
541
	JSON.stringify(fofoOrderInvoiceNumber.split(",").map(x=>x.trim())), function(response) {
542
			if (response) {
543
				alert("Invoices Processed Successfully");
544
				loadSchemeUpdatePage("main-content");
545
			}
546
		});
547
}
548
 
549
 
30122 amit.gupta 550
function deleteScheme(schemeId, catalogId) {
551
	doDeleteAjaxRequestHandler(context + "/schemes/delete?schemeId=" + schemeId
31762 tejbeer 552
		+ "&catalogId=" + catalogId, function(response) {
553
			if (response == 'true') {
554
				alert("Model Deleted successfully from Scheme");
555
				loadSchemeDetails(schemeId, "scheme-details-container");
556
			}
557
		});
23752 govind 558
}
30122 amit.gupta 559
 
560
 
561
function loadSearchItemScheme(domId, selectedModel, date) {
26802 tejbeer 562
	var searchText = $("#scheme-item-search-text").val();
563
	var category = $('#partner-category').val();
26912 tejbeer 564
 
26802 tejbeer 565
	if (typeof (searchText) == "undefined" || !searchText) {
566
		searchText = "";
567
	}
568
	if (typeof (category) == "undefined" || !category) {
569
		category = "";
570
	}
30122 amit.gupta 571
	if (searchText && category) {
31762 tejbeer 572
		doGetAjaxRequestHandler(`${context}/getSchemes?searchModel=${selectedModel}&partnerType=${category}&date=${date}`, function(response) {
26802 tejbeer 573
			$('#' + domId).html(response);
574
			$('#partner-category').val(category);
575
		});
30122 amit.gupta 576
	} else if (searchText) {
31762 tejbeer 577
		doGetAjaxRequestHandler(`${context}/getSchemes?searchModel=${selectedModel}&date=${date}`, function(response) {
26802 tejbeer 578
			$('#' + domId).html(response);
30253 amit.gupta 579
			$('#partner-category').val(category);
26802 tejbeer 580
		});
26912 tejbeer 581
 
582
	}
583
 
23752 govind 584
}
28795 tejbeer 585
 
586
function loadSearchImeiScheme(domId, selected_imei, date) {
587
	var category = $('#partner-category').val();
588
	var searchText = $("#scheme-imei-search-text").val();
589
 
590
	var category = $('#partner-category').val();
591
 
592
	console.log(category)
593
 
594
	if (typeof (searchText) == "undefined" || !searchText) {
595
		searchText = "";
596
	}
597
	if (typeof (category) == "undefined" || !category) {
598
		category = "";
599
	}
600
	if ((searchText) && (category)) {
601
		doGetAjaxRequestHandler(context + "/getSchemes?searchImei="
31762 tejbeer 602
			+ selected_imei + "&partnerType=" + category, function(
603
				response) {
28795 tejbeer 604
			$('#' + domId).html(response);
605
 
606
			$('#partner-category').val(category);
607
			$('#scheme-imei-search-text').val(selected_imei);
608
		});
609
	} else if ((searchText)) {
31762 tejbeer 610
		doGetAjaxRequestHandler(`${context}/getSchemes?searchImei=${selected_imei}&date=${date}`, function(response) {
28795 tejbeer 611
			$('#' + domId).html(response);
612
			$('#scheme-imei-search-text').val(selected_imei);
613
 
614
		});
615
	}
616
 
617
}
30122 amit.gupta 618
 
619
function loadSchemeItemSearchInfo(selectedModel, date) {
620
	loadSearchItemScheme("main-content", selectedModel, date);
23752 govind 621
}
28795 tejbeer 622
 
623
function loadSchemeImeiSearchInfo(selectedImei, date) {
624
 
625
	loadSearchImeiScheme("main-content", selectedImei, date);
626
}
627
 
34575 vikas.jang 628
$(document).on('click', ".mark-active", function() {
629
	let activeScheme=$("#activeSchemes").val();
34587 vikas.jang 630
	if (activeScheme.trim().length === 0) {
631
		alert("fields shouldn't be blank");
632
		return;
633
	}
34575 vikas.jang 634
	if (confirm("Are you sure you want to Active schemes?")) {
635
		console.log("activeScheme",activeScheme);
636
		doPutAjaxRequestHandler(context + "/activeSchemeByIds?schemeId=" + activeScheme, function(response) {
637
			if (response){
34587 vikas.jang 638
				$("#activeSchemes").val("");
34575 vikas.jang 639
				alert("schemes activated")
640
			}
641
		});
642
	}
35252 aman 643
});
644
$(document).on('click', ".mark-expire", function () {
645
	let expireSchemes = $("#expireSchemes").val();
646
	if (expireSchemes.trim().length === 0) {
647
		alert("fields shouldn't be blank");
648
		return;
649
	}
650
	if (confirm("Are you sure you want to expire schemes?")) {
651
		console.log("expireSchemes", expireSchemes);
652
		doPutAjaxRequestHandler(context + "/expireSchemeByIds?schemeId=" + expireSchemes, function (response) {
653
			if (response) {
654
				$("#expireSchemes").val("");
655
				alert("schemes expired")
656
			}
657
		});
658
	}
34575 vikas.jang 659
});