Subversion Repositories SmartDukaan

Rev

Rev 33010 | Rev 33091 | 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
 
36
$(document).on('click', ".scheme-payout-report", function() {
31416 tejbeer 37
 
30163 manish 38
	doGetAjaxRequestHandler(context + "/schemePayoutReport",
39
		function(response) {
40
			$('#' + 'main-content').html(response);
41
		});
42
});
33010 shampa 43
$(document).on('click', ".offer-payout-dump-report", function() {
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() {
30163 manish 91
	console.log('HELO');
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
 
253
	 doGetAjaxRequestHandler(context + "/schemePayoutFetchReportByDate?startDate=" + startDate + "&endDate=" + endDate,
254
     		function(response) {
255
     			$('#' + 'main-content').html(response);
256
     		});
257
});
258
 
259
$(document).on('click', ".download-offer-payout-dump-report", function() {
260
 
261
	var startDate = $("#startDate-offer-payout-dump").val();
262
 
263
	var endDate = $("#endDate-offer-payout-dump").val();
264
 
265
	if (startDate == "" || startDate == undefined) {
266
		alert("start date is not be empty!!");
267
		return;
268
	}
269
	if (endDate == "" || endDate == undefined) {
270
 
271
		alert("end date is not be empty!!");
272
		return;
273
	}
274
	window.location.href = context + "/offerPayoutDumpReportDownload?startDate=" + startDate + "&endDate=" + endDate;
275
 
276
 
277
});
278
$(document).on('click', ".offer-payout-fetch-report", function() {
279
 
280
	var startDate = $("#startDate-offer-payout-dump").val();
281
 
282
	var endDate = $("#endDate-offer-payout-dump").val();
283
 
284
	if (startDate == "" || startDate == undefined) {
285
		alert("start date is not be empty!!");
286
		return;
287
	}
288
	if (endDate == "" || endDate == undefined) {
289
 
290
		alert("end date is not be empty!!");
291
		return;
292
	}
293
 
294
	 doGetAjaxRequestHandler(context + "/offerPayoutFetchReportByDate?startDate=" + startDate + "&endDate=" + endDate,
295
     		function(response) {
296
     			$('#' + 'main-content').html(response);
297
     		});
298
});
299
 
300
 
30163 manish 301
$(document).on('click', ".franchisee_sales", function() {
33010 shampa 302
	console.log('HELLO');
30163 manish 303
	doGetAjaxRequestHandler(context + "/franchiseeSalesReport",
304
		function(response) {
305
			$('#' + 'main-content').html(response);
306
		});
307
});
308
 
309
$(document).on('click', '.download-wallet-summary-report', function() {
31416 tejbeer 310
	var startDate = $("#startDate-wallet-summary-report").val();
311
 
312
	var endDate = $("#endDate-wallet-summary-report").val();
313
 
314
	if (startDate == "" || startDate == undefined) {
315
		alert("start date is not be empty!!");
30163 manish 316
		return;
317
	}
31416 tejbeer 318
	if (endDate == "" || endDate == undefined) {
319
 
30163 manish 320
		alert("end date is not be empty!!");
321
		return;
322
	}
31416 tejbeer 323
	window.location.href = context + "/downloadWalletSummaryReport?startDate=" + startDate + "&endDate=" + endDate;
30163 manish 324
});
33010 shampa 325
$(document).on('click', '.wallet-summary-fetch-report', function() {
326
	var startDate = $("#startDate-wallet-summary-report").val();
30163 manish 327
 
33010 shampa 328
	var endDate = $("#endDate-wallet-summary-report").val();
30163 manish 329
 
33010 shampa 330
	if (startDate == "" || startDate == undefined) {
331
		alert("start date is not be empty!!");
332
		return;
333
	}
334
	if (endDate == "" || endDate == undefined) {
335
 
336
		alert("end date is not be empty!!");
337
		return;
338
	}
33067 shampa 339
	doGetAjaxRequestHandler(context + "/walletSummaryFetchReportByDate?startDate=" + startDate + "&endDate=" + endDate,
33010 shampa 340
    		function(response) {
341
    			$('#' + 'main-content').html(response);
342
    		});
343
});
344
 
345
 
30163 manish 346
$(document).on('click', '.download-partner-billing-report', function() {
31416 tejbeer 347
	var startDate = $("#startDate-partner-billing-report").val();
348
 
349
	var endDate = $("#endDate-partner-billing-report").val();
350
 
351
	if (startDate == "" || startDate == undefined) {
352
 
30163 manish 353
		alert("start date is not be empty!!");
354
		return;
355
	}
31416 tejbeer 356
	if (endDate == "" || endDate == undefined) {
357
 
30163 manish 358
		alert("end date is not be empty!!");
359
		return;
360
	}
31416 tejbeer 361
	window.location.href = context + "/downloadPartnerBillingSummaryReport?startDate=" + startDate + "&endDate=" + endDate;
30163 manish 362
});
33010 shampa 363
$(document).on('click', '.billing-summary-fetch-report', function() {
364
	var startDate = $("#startDate-partner-billing-report").val();
30163 manish 365
 
33010 shampa 366
	var endDate = $("#endDate-partner-billing-report").val();
367
 
368
	if (startDate == "" || startDate == undefined) {
369
 
370
		alert("start date is not be empty!!");
371
		return;
372
	}
373
	if (endDate == "" || endDate == undefined) {
374
 
375
		alert("end date is not be empty!!");
376
		return;
377
	}
378
	doGetAjaxRequestHandler(context + "/selectPartnerBillingSummaryReport",
379
    		function(response) {
380
    			$('#' + 'main-content').html(response);
381
    		});
382
});
383
 
30163 manish 384
$(document).on('click', '.download-franchisee-sales', function() {
31416 tejbeer 385
	var startDate = $("#startDate-franchisee-sales").val();
386
 
387
	var endDate = $("#endDate-franchisee-sales").val();
388
 
389
	if (startDate == "" || startDate == undefined) {
390
 
30163 manish 391
		alert("start date is not be empty!!");
392
		return;
393
	}
31416 tejbeer 394
	if (endDate == "" || endDate == undefined) {
395
 
30163 manish 396
		alert("end date is not be empty!!");
397
		return;
398
	}
31416 tejbeer 399
	window.location.href = context + "/downloadFranchiseeSales?startDate=" + startDate + "&endDate=" + endDate;
30163 manish 400
});
33010 shampa 401
$(document).on('click', '.franchisee-sales-fetch-report', function() {
402
	var startDate = $("#startDate-franchisee-sales").val();
30163 manish 403
 
33010 shampa 404
	var endDate = $("#endDate-franchisee-sales").val();
30163 manish 405
 
33010 shampa 406
	if (startDate == "" || startDate == undefined) {
407
 
408
		alert("start date is not be empty!!");
409
		return;
410
	}
411
	if (endDate == "" || endDate == undefined) {
412
 
413
		alert("end date is not be empty!!");
414
		return;
415
	}
416
	doGetAjaxRequestHandler(context + "/franchiseeSalesFetchReportByDate?startDate=" + startDate + "&endDate=" + endDate,
417
    		function(response) {
418
    			$('#' + 'main-content').html(response);
419
    		});
420
});
421
 
422
 
31416 tejbeer 423
$(document).on('click', 'button.download-report', function() {
26054 amit.gupta 424
	var reportParams = {};
26153 amit.gupta 425
	var validated = true;
26134 amit.gupta 426
	$inputContainer.find("input.param,select.param").each(function(idx, inputElement) {
26054 amit.gupta 427
		var inputName = $(inputElement).attr("name");
31416 tejbeer 428
		if (typeof inputName === "undefined" || !(inputName in paramsMap)) {
26089 amit.gupta 429
			console.log(inputName);
430
			return;
431
		}
432
		param = paramsMap[inputName];
31416 tejbeer 433
		if ($(inputElement).val() == "") {
26089 amit.gupta 434
			bootbox.alert(`${param.displayName} is required`);
26153 amit.gupta 435
			validated = false;
26148 amit.gupta 436
			return false;
26054 amit.gupta 437
		}
31416 tejbeer 438
		if (param.type == 'DATE') {
30599 amit.gupta 439
			reportParams[`MANUAL_${inputName}`] = getReporticoDatesFromPicker(inputElement).startDate;
31416 tejbeer 440
		} else if (param.type == 'DATE_RANGE') {
30599 amit.gupta 441
			reportParams[`MANUAL_${inputName}_FROMDATE`] = getReporticoDatesFromPicker(inputElement).startDate;
442
			reportParams[`MANUAL_${inputName}_TODATE`] = getReporticoDatesFromPicker(inputElement).endDate;
26054 amit.gupta 443
		} else {
31416 tejbeer 444
			if (['code', 'warehouseId'].indexOf(param.name) >= 0) {
445
				if (typeof $(inputElement).val() == "string") {
26204 amit.gupta 446
					reportParams[`${inputName}`] = $(inputElement).val();
26167 amit.gupta 447
				} else {
26204 amit.gupta 448
					reportParams[`${inputName}`] = $(inputElement).val().join(",");
26157 amit.gupta 449
				}
26116 amit.gupta 450
 
26089 amit.gupta 451
			} else {
452
				reportParams[`MANUAL_${inputName}`] = $(inputElement).val();
453
			}
26054 amit.gupta 454
		}
455
	});
31416 tejbeer 456
	if (validated) {
26153 amit.gupta 457
		var jsonParams = JSON.stringify(reportParams);
458
		doAjaxPostDownload(reportUrl, jsonParams, `${reportTitle}.csv`);
459
	}
31416 tejbeer 460
 
26054 amit.gupta 461
});
26053 amit.gupta 462
function renderInputDialog(paramsList) {
26054 amit.gupta 463
	$reportModal = $('div#report-modal');
464
	$inputContainer = $reportModal.find('div.modal-body');
465
	//Clear container first
466
	$inputContainer.html('');
26053 amit.gupta 467
	paramsList.forEach(function(value) {
468
		paramsMap[value.name] = value;
469
		renderInput($inputContainer, value);
470
	});
471
}
472
 
26054 amit.gupta 473
function renderInput($inputContainer, param) {
474
	console.log(param.type);
26053 amit.gupta 475
	switch (param.type) {
476
		case "DATE": {
26054 amit.gupta 477
			$inputContainer.append(`<div class="form-group">
26053 amit.gupta 478
									<label>${param.displayText}</label> 
26146 amit.gupta 479
				   	  				<input name="${param.name}" type="text" value="" class="param form-control input-sm">
26053 amit.gupta 480
								</div>`);
30599 amit.gupta 481
			$inputContainer.find(`input[name="${param.name}"]`).daterangepicker(getSingleDatePicker());
26054 amit.gupta 482
			return;
26053 amit.gupta 483
		}
31416 tejbeer 484
		case "DATE_RANGE": {
26054 amit.gupta 485
			$inputContainer.append(`<div class="form-group">
26053 amit.gupta 486
					<label>${param.displayText}</label> 
26134 amit.gupta 487
					<input name="${param.name}" type="text" value="" class="param form-control input-sm">
26053 amit.gupta 488
			</div>`);
30599 amit.gupta 489
			$inputContainer.find(`input[name="${param.name}"]`).daterangepicker(getRangedDatePicker(true));
26054 amit.gupta 490
			return;
26053 amit.gupta 491
		}
492
		case "STRING": {
31416 tejbeer 493
			if (param.name == "authId") {
26154 amit.gupta 494
				$inputContainer.append(`
495
						<input type="hidden" name="${param.name}" type="text" value="${authId}" class="param form-control input-sm">`);
26155 amit.gupta 496
			} else {
497
				$inputContainer.append(`<div class="form-group">
498
						<label>${param.displayText}</label> 
499
						<input name="${param.name}" type="text" value="" class="param form-control input-sm">
500
					</div>`);
26142 amit.gupta 501
			}
26054 amit.gupta 502
			return;
26053 amit.gupta 503
		}
31416 tejbeer 504
		case "LIST": {
505
			if (param.name == "code") {
26089 amit.gupta 506
				var arr = [];
31416 tejbeer 507
				if (retailers.length == 1) {
26157 amit.gupta 508
					$inputContainer.append(`<input type="hidden" name="${param.name}" type="text" value="${authId}" class="param form-control input-sm">`)
509
				} else {
31416 tejbeer 510
					for (var i in retailers) {
26157 amit.gupta 511
						arr.push(`<option value="${retailers[i].code}">${retailers[i].displayName}-${retailers[i].code}</option>`);
512
					}
513
					var options = arr.join("");
514
					$inputContainer.append(`<div class="col-lg-2 form-group">
515
							<label>${param.displayText}</label> 
516
							<select class="param form-control input-sm" id="code" multiple="multiple" name="${param.name}">
26089 amit.gupta 517
							<option value="" disabled selected>Select Franchisee</option>
518
							${options}
26157 amit.gupta 519
							</select>
520
					</div>`);
31416 tejbeer 521
 
26157 amit.gupta 522
					$('#code').multiselect({
523
						includeSelectAllOption: true,
31416 tejbeer 524
						multiple: true,
26157 amit.gupta 525
						maxHeight: 200,
526
						buttonWidth: '180px',
527
						numberDisplayed: 1,
528
						nonSelectedText: 'Franchisee',
529
						nSelectedText: ' - Franchisees Selected',
530
						allSelectedText: 'All Franchisees',
531
						enableFiltering: true,
31416 tejbeer 532
						enableCaseInsensitiveFiltering: true
26157 amit.gupta 533
					});
534
				}
31416 tejbeer 535
			} else if (param.name == "warehouseId") {
26134 amit.gupta 536
				var arr = [];
31416 tejbeer 537
				for (var i in warehouses) {
26134 amit.gupta 538
					arr.push(`<option value="${i}">${warehouses[i]}</option>`);
539
				}
540
				var options = arr.join("");
541
				$inputContainer.append(`<div class="col-lg-2 form-group">
542
						<label>${param.displayText}</label> 
543
						<select class="param form-control input-sm" id="code" multiple="multiple" name="${param.name}">
544
						<option value="" disabled selected>Select Warehouses</option>
545
						${options}
546
						</select>
547
				</div>`);
31416 tejbeer 548
 
26134 amit.gupta 549
				$('#code').multiselect({
550
					includeSelectAllOption: true,
31416 tejbeer 551
					multiple: true,
26134 amit.gupta 552
					maxHeight: 200,
553
					buttonWidth: '180px',
554
					numberDisplayed: 1,
555
					nonSelectedText: 'Warehouses',
556
					nSelectedText: ' - Warehouse Selected',
557
					allSelectedText: 'All Warehouses',
558
					enableFiltering: true,
31416 tejbeer 559
					enableCaseInsensitiveFiltering: true
26134 amit.gupta 560
				});
561
			} else {
26089 amit.gupta 562
				$inputContainer.append(`<div class="form-group">
563
						<label>${param.displayText}(Comma Separated)</label> 
26134 amit.gupta 564
						<input name="${param.name}" type="text" value="" class="param form-control input-sm">
26089 amit.gupta 565
				</div>`);
566
			}
26054 amit.gupta 567
			return;
26053 amit.gupta 568
		}
569
	}
570
}