Subversion Repositories SmartDukaan

Rev

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