Subversion Repositories SmartDukaan

Rev

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