Subversion Repositories SmartDukaan

Rev

Rev 30599 | Rev 33010 | 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
});
43
 
44
$(document).on('click', ".pending-indent", function() {
31416 tejbeer 45
 
30163 manish 46
	doGetAjaxRequestHandler(context + "/pendingIndentReport",
47
		function(response) {
48
			$('#' + 'main-content').html(response);
49
		});
50
});
51
 
52
$(document).on('click', ".wallet_statement", function() {
53
	console.log('HELO');
54
	doGetAjaxRequestHandler(context + "/walletSummaryReport",
55
		function(response) {
56
			$('#' + 'main-content').html(response);
57
		});
58
});
59
 
60
 
61
$(document).on('click', ".collection-summary", function() {
62
	console.log('HELO');
63
	doGetAjaxRequestHandler(context + "/collectionSummary",
64
		function(response) {
65
			$('#' + 'main-content').html(response);
66
		});
67
});
68
 
69
 
70
$(document).on('click', '.download-collection-summary', function() {
31416 tejbeer 71
	var startDate = $("#startDate-collection-summary").val();
72
 
73
	var endDate = $("#endDate-collection-summary").val();
74
 
75
	if (startDate == "" || startDate == undefined) {
76
 
30163 manish 77
		alert("start date is not be empty!!");
78
		return;
79
	}
31416 tejbeer 80
	if (endDate == "" || endDate == undefined) {
81
 
82
		alert("end date is not be empty!!");
30163 manish 83
		return;
84
	}
31416 tejbeer 85
	window.location.href = context + "/downloadCollectionSummary?startDate=" + startDate + "&endDate=" + endDate;
86
 
30163 manish 87
});
88
 
89
 
90
$(document).on('click', '.download-price-drop-report', function() {
31416 tejbeer 91
	var startDate = $("#startDate-price-drop-report").val();
92
 
93
	var endDate = $("#endDate-price-drop-report").val();
94
 
95
	if (startDate == "" || startDate == undefined) {
96
 
30163 manish 97
		alert("start date is not be empty!!");
98
		return;
99
	}
31416 tejbeer 100
	if (endDate == "" || endDate == undefined) {
101
 
102
		alert("end date is not be empty!!");
30163 manish 103
		return;
104
	}
31416 tejbeer 105
	window.location.href = context + "/downloadPriceDropReport?startDate=" + startDate + "&endDate=" + endDate;
106
 
30163 manish 107
});
108
 
109
 
110
 
111
 
112
$(document).on('click', ".smartdukaan-billing-statement", function() {
113
	console.log('HELO');
114
	doGetAjaxRequestHandler(context + "/selectPartnerBillingSummaryReport",
115
		function(response) {
116
			$('#' + 'main-content').html(response);
117
		});
118
});
119
 
120
 
121
$(document).on('click', '.download-invoicewise-scheme-out-report', function() {
31416 tejbeer 122
 
30163 manish 123
	window.location.href = context + "/downloadInvoiceSchemeOutSummaryReport";
31416 tejbeer 124
 
30163 manish 125
});
126
 
127
$(document).on('click', ".download-pending-indent-report", function() {
31416 tejbeer 128
 
129
	window.location.href = context + "/pendingIndentReportDownload";
30163 manish 130
});
131
 
132
$(document).on('click', ".download-scheme-payout-report", function() {
31416 tejbeer 133
 
134
	var startDate = $("#startDate-scheme-payout").val();
135
 
136
	var endDate = $("#endDate-scheme-payout").val();
137
 
138
	if (startDate == "" || startDate == undefined) {
139
		alert("start date is not be empty!!");
140
		return;
141
	}
142
	if (endDate == "" || endDate == undefined) {
143
 
144
		alert("end date is not be empty!!");
145
		return;
146
	}
147
 
148
	window.location.href = context + "/schemePayoutReportDownload?startDate=" + startDate + "&endDate=" + endDate;
30163 manish 149
});
150
 
151
$(document).on('click', ".franchisee_sales", function() {
152
	console.log('HELO');
153
	doGetAjaxRequestHandler(context + "/franchiseeSalesReport",
154
		function(response) {
155
			$('#' + 'main-content').html(response);
156
		});
157
});
158
 
159
$(document).on('click', '.download-wallet-summary-report', function() {
31416 tejbeer 160
	var startDate = $("#startDate-wallet-summary-report").val();
161
 
162
	var endDate = $("#endDate-wallet-summary-report").val();
163
 
164
	if (startDate == "" || startDate == undefined) {
165
		alert("start date is not be empty!!");
30163 manish 166
		return;
167
	}
31416 tejbeer 168
	if (endDate == "" || endDate == undefined) {
169
 
30163 manish 170
		alert("end date is not be empty!!");
171
		return;
172
	}
31416 tejbeer 173
	window.location.href = context + "/downloadWalletSummaryReport?startDate=" + startDate + "&endDate=" + endDate;
30163 manish 174
});
175
 
176
 
177
$(document).on('click', '.download-partner-billing-report', function() {
31416 tejbeer 178
	var startDate = $("#startDate-partner-billing-report").val();
179
 
180
	var endDate = $("#endDate-partner-billing-report").val();
181
 
182
	if (startDate == "" || startDate == undefined) {
183
 
30163 manish 184
		alert("start date is not be empty!!");
185
		return;
186
	}
31416 tejbeer 187
	if (endDate == "" || endDate == undefined) {
188
 
30163 manish 189
		alert("end date is not be empty!!");
190
		return;
191
	}
31416 tejbeer 192
	window.location.href = context + "/downloadPartnerBillingSummaryReport?startDate=" + startDate + "&endDate=" + endDate;
30163 manish 193
});
194
 
195
$(document).on('click', '.download-franchisee-sales', function() {
31416 tejbeer 196
	var startDate = $("#startDate-franchisee-sales").val();
197
 
198
	var endDate = $("#endDate-franchisee-sales").val();
199
 
200
	if (startDate == "" || startDate == undefined) {
201
 
30163 manish 202
		alert("start date is not be empty!!");
203
		return;
204
	}
31416 tejbeer 205
	if (endDate == "" || endDate == undefined) {
206
 
30163 manish 207
		alert("end date is not be empty!!");
208
		return;
209
	}
31416 tejbeer 210
	window.location.href = context + "/downloadFranchiseeSales?startDate=" + startDate + "&endDate=" + endDate;
30163 manish 211
});
212
 
213
 
31416 tejbeer 214
$(document).on('click', 'button.download-report', function() {
26054 amit.gupta 215
	var reportParams = {};
26153 amit.gupta 216
	var validated = true;
26134 amit.gupta 217
	$inputContainer.find("input.param,select.param").each(function(idx, inputElement) {
26054 amit.gupta 218
		var inputName = $(inputElement).attr("name");
31416 tejbeer 219
		if (typeof inputName === "undefined" || !(inputName in paramsMap)) {
26089 amit.gupta 220
			console.log(inputName);
221
			return;
222
		}
223
		param = paramsMap[inputName];
31416 tejbeer 224
		if ($(inputElement).val() == "") {
26089 amit.gupta 225
			bootbox.alert(`${param.displayName} is required`);
26153 amit.gupta 226
			validated = false;
26148 amit.gupta 227
			return false;
26054 amit.gupta 228
		}
31416 tejbeer 229
		if (param.type == 'DATE') {
30599 amit.gupta 230
			reportParams[`MANUAL_${inputName}`] = getReporticoDatesFromPicker(inputElement).startDate;
31416 tejbeer 231
		} else if (param.type == 'DATE_RANGE') {
30599 amit.gupta 232
			reportParams[`MANUAL_${inputName}_FROMDATE`] = getReporticoDatesFromPicker(inputElement).startDate;
233
			reportParams[`MANUAL_${inputName}_TODATE`] = getReporticoDatesFromPicker(inputElement).endDate;
26054 amit.gupta 234
		} else {
31416 tejbeer 235
			if (['code', 'warehouseId'].indexOf(param.name) >= 0) {
236
				if (typeof $(inputElement).val() == "string") {
26204 amit.gupta 237
					reportParams[`${inputName}`] = $(inputElement).val();
26167 amit.gupta 238
				} else {
26204 amit.gupta 239
					reportParams[`${inputName}`] = $(inputElement).val().join(",");
26157 amit.gupta 240
				}
26116 amit.gupta 241
 
26089 amit.gupta 242
			} else {
243
				reportParams[`MANUAL_${inputName}`] = $(inputElement).val();
244
			}
26054 amit.gupta 245
		}
246
	});
31416 tejbeer 247
	if (validated) {
26153 amit.gupta 248
		var jsonParams = JSON.stringify(reportParams);
249
		doAjaxPostDownload(reportUrl, jsonParams, `${reportTitle}.csv`);
250
	}
31416 tejbeer 251
 
26054 amit.gupta 252
});
26053 amit.gupta 253
function renderInputDialog(paramsList) {
26054 amit.gupta 254
	$reportModal = $('div#report-modal');
255
	$inputContainer = $reportModal.find('div.modal-body');
256
	//Clear container first
257
	$inputContainer.html('');
26053 amit.gupta 258
	paramsList.forEach(function(value) {
259
		paramsMap[value.name] = value;
260
		renderInput($inputContainer, value);
261
	});
262
}
263
 
26054 amit.gupta 264
function renderInput($inputContainer, param) {
265
	console.log(param.type);
26053 amit.gupta 266
	switch (param.type) {
267
		case "DATE": {
26054 amit.gupta 268
			$inputContainer.append(`<div class="form-group">
26053 amit.gupta 269
									<label>${param.displayText}</label> 
26146 amit.gupta 270
				   	  				<input name="${param.name}" type="text" value="" class="param form-control input-sm">
26053 amit.gupta 271
								</div>`);
30599 amit.gupta 272
			$inputContainer.find(`input[name="${param.name}"]`).daterangepicker(getSingleDatePicker());
26054 amit.gupta 273
			return;
26053 amit.gupta 274
		}
31416 tejbeer 275
		case "DATE_RANGE": {
26054 amit.gupta 276
			$inputContainer.append(`<div class="form-group">
26053 amit.gupta 277
					<label>${param.displayText}</label> 
26134 amit.gupta 278
					<input name="${param.name}" type="text" value="" class="param form-control input-sm">
26053 amit.gupta 279
			</div>`);
30599 amit.gupta 280
			$inputContainer.find(`input[name="${param.name}"]`).daterangepicker(getRangedDatePicker(true));
26054 amit.gupta 281
			return;
26053 amit.gupta 282
		}
283
		case "STRING": {
31416 tejbeer 284
			if (param.name == "authId") {
26154 amit.gupta 285
				$inputContainer.append(`
286
						<input type="hidden" name="${param.name}" type="text" value="${authId}" class="param form-control input-sm">`);
26155 amit.gupta 287
			} else {
288
				$inputContainer.append(`<div class="form-group">
289
						<label>${param.displayText}</label> 
290
						<input name="${param.name}" type="text" value="" class="param form-control input-sm">
291
					</div>`);
26142 amit.gupta 292
			}
26054 amit.gupta 293
			return;
26053 amit.gupta 294
		}
31416 tejbeer 295
		case "LIST": {
296
			if (param.name == "code") {
26089 amit.gupta 297
				var arr = [];
31416 tejbeer 298
				if (retailers.length == 1) {
26157 amit.gupta 299
					$inputContainer.append(`<input type="hidden" name="${param.name}" type="text" value="${authId}" class="param form-control input-sm">`)
300
				} else {
31416 tejbeer 301
					for (var i in retailers) {
26157 amit.gupta 302
						arr.push(`<option value="${retailers[i].code}">${retailers[i].displayName}-${retailers[i].code}</option>`);
303
					}
304
					var options = arr.join("");
305
					$inputContainer.append(`<div class="col-lg-2 form-group">
306
							<label>${param.displayText}</label> 
307
							<select class="param form-control input-sm" id="code" multiple="multiple" name="${param.name}">
26089 amit.gupta 308
							<option value="" disabled selected>Select Franchisee</option>
309
							${options}
26157 amit.gupta 310
							</select>
311
					</div>`);
31416 tejbeer 312
 
26157 amit.gupta 313
					$('#code').multiselect({
314
						includeSelectAllOption: true,
31416 tejbeer 315
						multiple: true,
26157 amit.gupta 316
						maxHeight: 200,
317
						buttonWidth: '180px',
318
						numberDisplayed: 1,
319
						nonSelectedText: 'Franchisee',
320
						nSelectedText: ' - Franchisees Selected',
321
						allSelectedText: 'All Franchisees',
322
						enableFiltering: true,
31416 tejbeer 323
						enableCaseInsensitiveFiltering: true
26157 amit.gupta 324
					});
325
				}
31416 tejbeer 326
			} else if (param.name == "warehouseId") {
26134 amit.gupta 327
				var arr = [];
31416 tejbeer 328
				for (var i in warehouses) {
26134 amit.gupta 329
					arr.push(`<option value="${i}">${warehouses[i]}</option>`);
330
				}
331
				var options = arr.join("");
332
				$inputContainer.append(`<div class="col-lg-2 form-group">
333
						<label>${param.displayText}</label> 
334
						<select class="param form-control input-sm" id="code" multiple="multiple" name="${param.name}">
335
						<option value="" disabled selected>Select Warehouses</option>
336
						${options}
337
						</select>
338
				</div>`);
31416 tejbeer 339
 
26134 amit.gupta 340
				$('#code').multiselect({
341
					includeSelectAllOption: true,
31416 tejbeer 342
					multiple: true,
26134 amit.gupta 343
					maxHeight: 200,
344
					buttonWidth: '180px',
345
					numberDisplayed: 1,
346
					nonSelectedText: 'Warehouses',
347
					nSelectedText: ' - Warehouse Selected',
348
					allSelectedText: 'All Warehouses',
349
					enableFiltering: true,
31416 tejbeer 350
					enableCaseInsensitiveFiltering: true
26134 amit.gupta 351
				});
352
			} else {
26089 amit.gupta 353
				$inputContainer.append(`<div class="form-group">
354
						<label>${param.displayText}(Comma Separated)</label> 
26134 amit.gupta 355
						<input name="${param.name}" type="text" value="" class="param form-control input-sm">
26089 amit.gupta 356
				</div>`);
357
			}
26054 amit.gupta 358
			return;
26053 amit.gupta 359
		}
360
	}
361
}