Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
26053 amit.gupta 1
$(document).on('click', 'a.list-group-item', function() {
26063 amit.gupta 2
	reportTitle = $(this).find('h4').html();
3
	reportUrl = this.href;
26054 amit.gupta 4
	$reportModal = $('#report-modal');
26063 amit.gupta 5
	$reportModal.find('h4.modal-title').html(reportTitle);
31416 tejbeer 6
	if ($(this).data("paramslist") == undefined) {
26054 amit.gupta 7
		return true;
26053 amit.gupta 8
	} else {
9
		var paramsList = $(this).data("paramslist");
10
		paramsMap = {};
11
		renderInputDialog(paramsList);
12
		$reportModal.modal('show');
13
		return false;
14
	}
15
});
30163 manish 16
 
17
 
18
 
19
$(document).on('click', ".invoice-scheme-out-report", function() {
31416 tejbeer 20
 
30163 manish 21
	doGetAjaxRequestHandler(context + "/invoiceSchemeOutSummaryReport",
22
		function(response) {
23
			$('#' + 'main-content').html(response);
24
		});
25
});
26
 
27
 
28
$(document).on('click', ".price-drop-report", function() {
31416 tejbeer 29
 
30163 manish 30
	doGetAjaxRequestHandler(context + "/priceDropReport",
31
		function(response) {
32
			$('#' + 'main-content').html(response);
33
		});
34
});
35
 
33091 shampa 36
$(document).on('click', ".scheme-payout", function() {
31416 tejbeer 37
 
30163 manish 38
	doGetAjaxRequestHandler(context + "/schemePayoutReport",
39
		function(response) {
40
			$('#' + 'main-content').html(response);
41
		});
42
});
33091 shampa 43
$(document).on('click', ".partner-reports", function() {
33010 shampa 44
console.log('HELLO');
45
	doGetAjaxRequestHandler(context + "/offerPayoutReport",
46
		function(response) {
47
			$('#' + 'main-content').html(response);
48
		});
49
});
30163 manish 50
 
51
$(document).on('click', ".pending-indent", function() {
31416 tejbeer 52
 
30163 manish 53
	doGetAjaxRequestHandler(context + "/pendingIndentReport",
54
		function(response) {
55
			$('#' + 'main-content').html(response);
56
		});
57
});
33067 shampa 58
$(document).on('click', '.pending-indent-fetch-report', function() {
59
	var startDate = $("#startDate-pending-indent-report").val();
30163 manish 60
 
33067 shampa 61
	var endDate = $("#endDate-pending-indent-report").val();
62
 
63
	if (startDate == "" || startDate == undefined) {
64
 
65
		alert("start date is not be empty!!");
66
		return;
67
	}
68
	if (endDate == "" || endDate == undefined) {
69
 
70
		alert("end date is not be empty!!");
71
		return;
72
	}
73
	doGetAjaxRequestHandler(context + "/pendingIndentFetchReportByDate?startDate=" + startDate + "&endDate=" + endDate,
74
		function(response) {
75
			$('#' + 'main-content').html(response);
76
		});
77
});
78
 
79
 
80
 
30163 manish 81
$(document).on('click', ".wallet_statement", function() {
33010 shampa 82
	console.log('HELLO');
30163 manish 83
	doGetAjaxRequestHandler(context + "/walletSummaryReport",
84
		function(response) {
85
			$('#' + 'main-content').html(response);
86
		});
87
});
88
 
89
 
33067 shampa 90
$(document).on('click', ".partner-collection-summary", function() {
33091 shampa 91
 
30163 manish 92
	doGetAjaxRequestHandler(context + "/collectionSummary",
93
		function(response) {
94
			$('#' + 'main-content').html(response);
95
		});
96
});
97
 
98
 
99
$(document).on('click', '.download-collection-summary', function() {
31416 tejbeer 100
	var startDate = $("#startDate-collection-summary").val();
101
 
102
	var endDate = $("#endDate-collection-summary").val();
103
 
104
	if (startDate == "" || startDate == undefined) {
105
 
30163 manish 106
		alert("start date is not be empty!!");
107
		return;
108
	}
31416 tejbeer 109
	if (endDate == "" || endDate == undefined) {
110
 
111
		alert("end date is not be empty!!");
30163 manish 112
		return;
113
	}
31416 tejbeer 114
	window.location.href = context + "/downloadCollectionSummary?startDate=" + startDate + "&endDate=" + endDate;
115
 
30163 manish 116
});
33010 shampa 117
$(document).on('click', ".collection-summary-fetch-report", function() {
30163 manish 118
 
33010 shampa 119
	var startDate = $("#startDate-collection-summary").val();
30163 manish 120
 
33010 shampa 121
	var endDate = $("#endDate-collection-summary").val();
122
 
123
	if (startDate == "" || startDate == undefined) {
124
		alert("start date is not be empty!!");
125
		return;
126
	}
127
	if (endDate == "" || endDate == undefined) {
128
 
129
		alert("end date is not be empty!!");
130
		return;
131
	}
132
 
33067 shampa 133
	 doGetAjaxRequestHandler(context + "/collectionSummaryFetchReportByDate?startDate=" + startDate + "&endDate=" + endDate,
33010 shampa 134
     		function(response) {
135
     			$('#' + 'main-content').html(response);
136
     		});
137
});
138
 
139
 
30163 manish 140
$(document).on('click', '.download-price-drop-report', function() {
31416 tejbeer 141
	var startDate = $("#startDate-price-drop-report").val();
142
 
143
	var endDate = $("#endDate-price-drop-report").val();
144
 
145
	if (startDate == "" || startDate == undefined) {
146
 
30163 manish 147
		alert("start date is not be empty!!");
148
		return;
149
	}
31416 tejbeer 150
	if (endDate == "" || endDate == undefined) {
151
 
152
		alert("end date is not be empty!!");
30163 manish 153
		return;
154
	}
31416 tejbeer 155
	window.location.href = context + "/downloadPriceDropReport?startDate=" + startDate + "&endDate=" + endDate;
156
 
30163 manish 157
});
33010 shampa 158
$(document).on('click', '.price-drop-fetch-report', function() {
159
	var startDate = $("#startDate-price-drop-report").val();
30163 manish 160
 
33010 shampa 161
	var endDate = $("#endDate-price-drop-report").val();
30163 manish 162
 
33010 shampa 163
	if (startDate == "" || startDate == undefined) {
30163 manish 164
 
33010 shampa 165
		alert("start date is not be empty!!");
166
		return;
167
	}
168
	if (endDate == "" || endDate == undefined) {
30163 manish 169
 
33010 shampa 170
		alert("end date is not be empty!!");
171
		return;
172
	}
33067 shampa 173
	doGetAjaxRequestHandler(context + "/priceDropFetchReportByDate?startDate=" + startDate + "&endDate=" + endDate,
33010 shampa 174
    		function(response) {
175
    			$('#' + 'main-content').html(response);
176
    		});
177
 
178
});
179
 
180
 
181
 
182
 
30163 manish 183
$(document).on('click', ".smartdukaan-billing-statement", function() {
184
	console.log('HELO');
185
	doGetAjaxRequestHandler(context + "/selectPartnerBillingSummaryReport",
186
		function(response) {
187
			$('#' + 'main-content').html(response);
188
		});
189
});
190
 
191
 
192
$(document).on('click', '.download-invoicewise-scheme-out-report', function() {
31416 tejbeer 193
 
30163 manish 194
	window.location.href = context + "/downloadInvoiceSchemeOutSummaryReport";
31416 tejbeer 195
 
30163 manish 196
});
197
 
198
$(document).on('click', ".download-pending-indent-report", function() {
33067 shampa 199
	var startDate = $("#startDate-pending-indent-report").val();
31416 tejbeer 200
 
33067 shampa 201
	var endDate = $("#endDate-pending-indent-report").val();
30163 manish 202
 
33067 shampa 203
	if (startDate == "" || startDate == undefined) {
204
		alert("start date is not be empty!!");
205
		return;
206
	}
207
	if (endDate == "" || endDate == undefined) {
33010 shampa 208
 
33067 shampa 209
		alert("end date is not be empty!!");
210
		return;
211
	}
33010 shampa 212
 
33067 shampa 213
	window.location.href = context + "/pendingIndentReportDownload";
33010 shampa 214
});
215
 
216
 
33067 shampa 217
 
30163 manish 218
$(document).on('click', ".download-scheme-payout-report", function() {
31416 tejbeer 219
 
220
	var startDate = $("#startDate-scheme-payout").val();
221
 
222
	var endDate = $("#endDate-scheme-payout").val();
223
 
224
	if (startDate == "" || startDate == undefined) {
225
		alert("start date is not be empty!!");
226
		return;
227
	}
228
	if (endDate == "" || endDate == undefined) {
229
 
230
		alert("end date is not be empty!!");
231
		return;
232
	}
233
 
234
	window.location.href = context + "/schemePayoutReportDownload?startDate=" + startDate + "&endDate=" + endDate;
30163 manish 235
});
236
 
33010 shampa 237
$(document).on('click', ".scheme-payout-fetch-report", function() {
238
 
239
	var startDate = $("#startDate-scheme-payout").val();
240
 
241
	var endDate = $("#endDate-scheme-payout").val();
242
 
243
	if (startDate == "" || startDate == undefined) {
244
		alert("start date is not be empty!!");
245
		return;
246
	}
247
	if (endDate == "" || endDate == undefined) {
248
 
249
		alert("end date is not be empty!!");
250
		return;
251
	}
252
 
33091 shampa 253
	let endPoint = `${context}/schemePayoutFetchReportByDate?startDate=${startDate}&endDate=${endDate}`;
254
	   if (typeof partnerId != "undefined") {
255
		        endPoint = `${endPoint}&fofoId=${partnerId}`;
256
		   }
257
 
258
		    doGetAjaxRequestHandler(endPoint,
259
			        function (response) {
260
				            $('#' + 'main-content').html(response);
261
				       });
33010 shampa 262
});
263
 
264
$(document).on('click', ".download-offer-payout-dump-report", function() {
265
 
266
	var startDate = $("#startDate-offer-payout-dump").val();
267
 
268
	var endDate = $("#endDate-offer-payout-dump").val();
269
 
270
	if (startDate == "" || startDate == undefined) {
271
		alert("start date is not be empty!!");
272
		return;
273
	}
274
	if (endDate == "" || endDate == undefined) {
275
 
276
		alert("end date is not be empty!!");
277
		return;
278
	}
279
	window.location.href = context + "/offerPayoutDumpReportDownload?startDate=" + startDate + "&endDate=" + endDate;
280
 
281
 
282
});
283
$(document).on('click', ".offer-payout-fetch-report", function() {
284
 
285
	var startDate = $("#startDate-offer-payout-dump").val();
286
 
287
	var endDate = $("#endDate-offer-payout-dump").val();
288
 
289
	if (startDate == "" || startDate == undefined) {
290
		alert("start date is not be empty!!");
291
		return;
292
	}
293
	if (endDate == "" || endDate == undefined) {
294
 
295
		alert("end date is not be empty!!");
296
		return;
297
	}
33091 shampa 298
	let endPoint = `${context}/offerPayoutFetchReportByDate?startDate=${startDate}&endDate=${endDate}`;
299
	if (typeof partnerId != "undefined") {
300
		endPoint = `${endPoint}&fofoId=${partnerId}`;
301
	}
33010 shampa 302
 
33091 shampa 303
	doGetAjaxRequestHandler(endPoint,
304
		function (response) {
305
			$('#' + 'main-content').html(response);
306
		});
33010 shampa 307
});
308
 
309
 
30163 manish 310
$(document).on('click', ".franchisee_sales", function() {
33010 shampa 311
	console.log('HELLO');
30163 manish 312
	doGetAjaxRequestHandler(context + "/franchiseeSalesReport",
313
		function(response) {
314
			$('#' + 'main-content').html(response);
315
		});
316
});
317
 
318
$(document).on('click', '.download-wallet-summary-report', function() {
31416 tejbeer 319
	var startDate = $("#startDate-wallet-summary-report").val();
320
 
321
	var endDate = $("#endDate-wallet-summary-report").val();
322
 
323
	if (startDate == "" || startDate == undefined) {
324
		alert("start date is not be empty!!");
30163 manish 325
		return;
326
	}
31416 tejbeer 327
	if (endDate == "" || endDate == undefined) {
328
 
30163 manish 329
		alert("end date is not be empty!!");
330
		return;
331
	}
31416 tejbeer 332
	window.location.href = context + "/downloadWalletSummaryReport?startDate=" + startDate + "&endDate=" + endDate;
30163 manish 333
});
33010 shampa 334
$(document).on('click', '.wallet-summary-fetch-report', function() {
335
	var startDate = $("#startDate-wallet-summary-report").val();
30163 manish 336
 
33010 shampa 337
	var endDate = $("#endDate-wallet-summary-report").val();
30163 manish 338
 
33010 shampa 339
	if (startDate == "" || startDate == undefined) {
340
		alert("start date is not be empty!!");
341
		return;
342
	}
343
	if (endDate == "" || endDate == undefined) {
344
 
345
		alert("end date is not be empty!!");
346
		return;
347
	}
33067 shampa 348
	doGetAjaxRequestHandler(context + "/walletSummaryFetchReportByDate?startDate=" + startDate + "&endDate=" + endDate,
33010 shampa 349
    		function(response) {
350
    			$('#' + 'main-content').html(response);
351
    		});
352
});
353
 
354
 
30163 manish 355
$(document).on('click', '.download-partner-billing-report', function() {
31416 tejbeer 356
	var startDate = $("#startDate-partner-billing-report").val();
357
 
358
	var endDate = $("#endDate-partner-billing-report").val();
359
 
360
	if (startDate == "" || startDate == undefined) {
361
 
30163 manish 362
		alert("start date is not be empty!!");
363
		return;
364
	}
31416 tejbeer 365
	if (endDate == "" || endDate == undefined) {
366
 
30163 manish 367
		alert("end date is not be empty!!");
368
		return;
369
	}
31416 tejbeer 370
	window.location.href = context + "/downloadPartnerBillingSummaryReport?startDate=" + startDate + "&endDate=" + endDate;
30163 manish 371
});
33010 shampa 372
$(document).on('click', '.billing-summary-fetch-report', function() {
373
	var startDate = $("#startDate-partner-billing-report").val();
30163 manish 374
 
33010 shampa 375
	var endDate = $("#endDate-partner-billing-report").val();
376
 
377
	if (startDate == "" || startDate == undefined) {
378
 
379
		alert("start date is not be empty!!");
380
		return;
381
	}
382
	if (endDate == "" || endDate == undefined) {
383
 
384
		alert("end date is not be empty!!");
385
		return;
386
	}
387
	doGetAjaxRequestHandler(context + "/selectPartnerBillingSummaryReport",
388
    		function(response) {
389
    			$('#' + 'main-content').html(response);
390
    		});
391
});
392
 
30163 manish 393
$(document).on('click', '.download-franchisee-sales', function() {
31416 tejbeer 394
	var startDate = $("#startDate-franchisee-sales").val();
395
 
396
	var endDate = $("#endDate-franchisee-sales").val();
397
 
398
	if (startDate == "" || startDate == undefined) {
399
 
30163 manish 400
		alert("start date is not be empty!!");
401
		return;
402
	}
31416 tejbeer 403
	if (endDate == "" || endDate == undefined) {
404
 
30163 manish 405
		alert("end date is not be empty!!");
406
		return;
407
	}
31416 tejbeer 408
	window.location.href = context + "/downloadFranchiseeSales?startDate=" + startDate + "&endDate=" + endDate;
30163 manish 409
});
33010 shampa 410
$(document).on('click', '.franchisee-sales-fetch-report', function() {
411
	var startDate = $("#startDate-franchisee-sales").val();
30163 manish 412
 
33010 shampa 413
	var endDate = $("#endDate-franchisee-sales").val();
30163 manish 414
 
33010 shampa 415
	if (startDate == "" || startDate == undefined) {
416
 
417
		alert("start date is not be empty!!");
418
		return;
419
	}
420
	if (endDate == "" || endDate == undefined) {
421
 
422
		alert("end date is not be empty!!");
423
		return;
424
	}
425
	doGetAjaxRequestHandler(context + "/franchiseeSalesFetchReportByDate?startDate=" + startDate + "&endDate=" + endDate,
426
    		function(response) {
427
    			$('#' + 'main-content').html(response);
428
    		});
429
});
430
 
431
 
31416 tejbeer 432
$(document).on('click', 'button.download-report', function() {
26054 amit.gupta 433
	var reportParams = {};
26153 amit.gupta 434
	var validated = true;
26134 amit.gupta 435
	$inputContainer.find("input.param,select.param").each(function(idx, inputElement) {
26054 amit.gupta 436
		var inputName = $(inputElement).attr("name");
31416 tejbeer 437
		if (typeof inputName === "undefined" || !(inputName in paramsMap)) {
26089 amit.gupta 438
			console.log(inputName);
439
			return;
440
		}
441
		param = paramsMap[inputName];
31416 tejbeer 442
		if ($(inputElement).val() == "") {
26089 amit.gupta 443
			bootbox.alert(`${param.displayName} is required`);
26153 amit.gupta 444
			validated = false;
26148 amit.gupta 445
			return false;
26054 amit.gupta 446
		}
31416 tejbeer 447
		if (param.type == 'DATE') {
30599 amit.gupta 448
			reportParams[`MANUAL_${inputName}`] = getReporticoDatesFromPicker(inputElement).startDate;
31416 tejbeer 449
		} else if (param.type == 'DATE_RANGE') {
30599 amit.gupta 450
			reportParams[`MANUAL_${inputName}_FROMDATE`] = getReporticoDatesFromPicker(inputElement).startDate;
451
			reportParams[`MANUAL_${inputName}_TODATE`] = getReporticoDatesFromPicker(inputElement).endDate;
26054 amit.gupta 452
		} else {
31416 tejbeer 453
			if (['code', 'warehouseId'].indexOf(param.name) >= 0) {
454
				if (typeof $(inputElement).val() == "string") {
26204 amit.gupta 455
					reportParams[`${inputName}`] = $(inputElement).val();
26167 amit.gupta 456
				} else {
26204 amit.gupta 457
					reportParams[`${inputName}`] = $(inputElement).val().join(",");
26157 amit.gupta 458
				}
26116 amit.gupta 459
 
26089 amit.gupta 460
			} else {
461
				reportParams[`MANUAL_${inputName}`] = $(inputElement).val();
462
			}
26054 amit.gupta 463
		}
464
	});
31416 tejbeer 465
	if (validated) {
26153 amit.gupta 466
		var jsonParams = JSON.stringify(reportParams);
467
		doAjaxPostDownload(reportUrl, jsonParams, `${reportTitle}.csv`);
468
	}
31416 tejbeer 469
 
26054 amit.gupta 470
});
26053 amit.gupta 471
function renderInputDialog(paramsList) {
26054 amit.gupta 472
	$reportModal = $('div#report-modal');
473
	$inputContainer = $reportModal.find('div.modal-body');
474
	//Clear container first
475
	$inputContainer.html('');
26053 amit.gupta 476
	paramsList.forEach(function(value) {
477
		paramsMap[value.name] = value;
478
		renderInput($inputContainer, value);
479
	});
480
}
481
 
26054 amit.gupta 482
function renderInput($inputContainer, param) {
483
	console.log(param.type);
26053 amit.gupta 484
	switch (param.type) {
485
		case "DATE": {
26054 amit.gupta 486
			$inputContainer.append(`<div class="form-group">
26053 amit.gupta 487
									<label>${param.displayText}</label> 
26146 amit.gupta 488
				   	  				<input name="${param.name}" type="text" value="" class="param form-control input-sm">
26053 amit.gupta 489
								</div>`);
30599 amit.gupta 490
			$inputContainer.find(`input[name="${param.name}"]`).daterangepicker(getSingleDatePicker());
26054 amit.gupta 491
			return;
26053 amit.gupta 492
		}
31416 tejbeer 493
		case "DATE_RANGE": {
26054 amit.gupta 494
			$inputContainer.append(`<div class="form-group">
26053 amit.gupta 495
					<label>${param.displayText}</label> 
26134 amit.gupta 496
					<input name="${param.name}" type="text" value="" class="param form-control input-sm">
26053 amit.gupta 497
			</div>`);
30599 amit.gupta 498
			$inputContainer.find(`input[name="${param.name}"]`).daterangepicker(getRangedDatePicker(true));
26054 amit.gupta 499
			return;
26053 amit.gupta 500
		}
501
		case "STRING": {
31416 tejbeer 502
			if (param.name == "authId") {
26154 amit.gupta 503
				$inputContainer.append(`
504
						<input type="hidden" name="${param.name}" type="text" value="${authId}" class="param form-control input-sm">`);
26155 amit.gupta 505
			} else {
506
				$inputContainer.append(`<div class="form-group">
507
						<label>${param.displayText}</label> 
508
						<input name="${param.name}" type="text" value="" class="param form-control input-sm">
509
					</div>`);
26142 amit.gupta 510
			}
26054 amit.gupta 511
			return;
26053 amit.gupta 512
		}
31416 tejbeer 513
		case "LIST": {
514
			if (param.name == "code") {
26089 amit.gupta 515
				var arr = [];
31416 tejbeer 516
				if (retailers.length == 1) {
26157 amit.gupta 517
					$inputContainer.append(`<input type="hidden" name="${param.name}" type="text" value="${authId}" class="param form-control input-sm">`)
518
				} else {
31416 tejbeer 519
					for (var i in retailers) {
26157 amit.gupta 520
						arr.push(`<option value="${retailers[i].code}">${retailers[i].displayName}-${retailers[i].code}</option>`);
521
					}
522
					var options = arr.join("");
523
					$inputContainer.append(`<div class="col-lg-2 form-group">
524
							<label>${param.displayText}</label> 
525
							<select class="param form-control input-sm" id="code" multiple="multiple" name="${param.name}">
26089 amit.gupta 526
							<option value="" disabled selected>Select Franchisee</option>
527
							${options}
26157 amit.gupta 528
							</select>
529
					</div>`);
31416 tejbeer 530
 
26157 amit.gupta 531
					$('#code').multiselect({
532
						includeSelectAllOption: true,
31416 tejbeer 533
						multiple: true,
26157 amit.gupta 534
						maxHeight: 200,
535
						buttonWidth: '180px',
536
						numberDisplayed: 1,
537
						nonSelectedText: 'Franchisee',
538
						nSelectedText: ' - Franchisees Selected',
539
						allSelectedText: 'All Franchisees',
540
						enableFiltering: true,
31416 tejbeer 541
						enableCaseInsensitiveFiltering: true
26157 amit.gupta 542
					});
543
				}
31416 tejbeer 544
			} else if (param.name == "warehouseId") {
26134 amit.gupta 545
				var arr = [];
31416 tejbeer 546
				for (var i in warehouses) {
26134 amit.gupta 547
					arr.push(`<option value="${i}">${warehouses[i]}</option>`);
548
				}
549
				var options = arr.join("");
550
				$inputContainer.append(`<div class="col-lg-2 form-group">
551
						<label>${param.displayText}</label> 
552
						<select class="param form-control input-sm" id="code" multiple="multiple" name="${param.name}">
553
						<option value="" disabled selected>Select Warehouses</option>
554
						${options}
555
						</select>
556
				</div>`);
31416 tejbeer 557
 
26134 amit.gupta 558
				$('#code').multiselect({
559
					includeSelectAllOption: true,
31416 tejbeer 560
					multiple: true,
26134 amit.gupta 561
					maxHeight: 200,
562
					buttonWidth: '180px',
563
					numberDisplayed: 1,
564
					nonSelectedText: 'Warehouses',
565
					nSelectedText: ' - Warehouse Selected',
566
					allSelectedText: 'All Warehouses',
567
					enableFiltering: true,
31416 tejbeer 568
					enableCaseInsensitiveFiltering: true
26134 amit.gupta 569
				});
570
			} else {
26089 amit.gupta 571
				$inputContainer.append(`<div class="form-group">
572
						<label>${param.displayText}(Comma Separated)</label> 
26134 amit.gupta 573
						<input name="${param.name}" type="text" value="" class="param form-control input-sm">
26089 amit.gupta 574
				</div>`);
575
			}
26054 amit.gupta 576
			return;
26053 amit.gupta 577
		}
578
	}
579
}