Subversion Repositories SmartDukaan

Rev

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