Subversion Repositories SmartDukaan

Rev

Rev 27359 | Rev 27696 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 27359 Rev 27618
Line 1... Line 1...
1
var logosmapping = {
1
var logosmapping = {
2
	mobile_insurance_providers : {
2
	mobile_insurance_providers: {
3
		"0" : context + '/resources/images/icons/provider-logos/iffco.png',
3
		"0": context + '/resources/images/icons/provider-logos/iffco.png',
4
		"1" : context + '/resources/images/icons/provider-logos/icici.jpg',
4
		"1": context + '/resources/images/icons/provider-logos/icici.jpg',
5
		"2" : context + '/resources/images/icons/provider-logos/tataaig.png',
5
		"2": context + '/resources/images/icons/provider-logos/tataaig.png',
6
		"3" : context + '/resources/images/icons/provider-logos/bharti.jpg'
6
		"3": context + '/resources/images/icons/provider-logos/bharti.jpg'
7
	}
7
	}
8
}
8
}
9
function badRequestAlert(response) {
9
function badRequestAlert(response) {
10
	console.log(response.responseText);
10
	console.log(response.responseText);
11
	var errorObject = JSON.parse(response.responseText);
11
	var errorObject = JSON.parse(response.responseText);
12
	errorObject = errorObject.response;
12
	errorObject = errorObject.response;
13
	bootbox.alert('Bad Request\n' + 'rejectedType : '
13
	bootbox.alert('Bad Request\n' + 'rejectedType : '
14
			+ errorObject.rejectedType + '\n' + 'rejectedValue : '
14
		+ errorObject.rejectedType + '\n' + 'rejectedValue : '
15
			+ errorObject.rejectedValue + '\n' + 'message : '
15
		+ errorObject.rejectedValue + '\n' + 'message : '
16
			+ errorObject.message);
16
		+ errorObject.message);
17
}
17
}
18
 
18
 
19
function internalServerErrorAlert(response) {
19
function internalServerErrorAlert(response) {
20
	console.log(response.responseText);
20
	console.log(response.responseText);
21
	var errorObject = JSON.parse(response.responseText);
21
	var errorObject = JSON.parse(response.responseText);
22
	errorObject = errorObject.response;
22
	errorObject = errorObject.response;
23
	bootbox.alert('Internal Server Error\n' + 'rejectedType : '
23
	bootbox.alert('Internal Server Error\n' + 'rejectedType : '
24
			+ errorObject.rejectedType + '\n' + 'rejectedValue : '
24
		+ errorObject.rejectedType + '\n' + 'rejectedValue : '
25
			+ errorObject.rejectedValue + '\n' + 'message : '
25
		+ errorObject.rejectedValue + '\n' + 'message : '
26
			+ errorObject.message);
26
		+ errorObject.message);
27
}
27
}
28
 
28
 
29
$(document).ajaxError(function(event, jqxhr, settings, thrownError) {
29
$(document).ajaxError(function(event, jqxhr, settings, thrownError) {
30
	if (typeof loaderDialogObj != "undefined") {
30
	if (typeof loaderDialogObj != "undefined") {
31
		loaderDialogObj.modal('hide');
31
		loaderDialogObj.modal('hide');
Line 47... Line 47...
47
});
47
});
48
function ajaxStartHandler() {
48
function ajaxStartHandler() {
49
	if (typeof loaderDialogObj != "undefined")
49
	if (typeof loaderDialogObj != "undefined")
50
		loaderDialogObj.modal('show');
50
		loaderDialogObj.modal('show');
51
	if (typeof isInvestmentOk != "undefined" && !isInvestmentOk
51
	if (typeof isInvestmentOk != "undefined" && !isInvestmentOk
52
			&& $('#order-details').length == 0) {
52
		&& $('#order-details').length == 0) {
53
		var investmentDialog = bootbox
53
		var investmentDialog = bootbox
54
				.dialog({
54
			.dialog({
55
					title : '<h3	class="text-danger">ATTENTION!! ORDERING THROUGH APP MAY BE BLOCKED DUE TO LOW INVESTMENTS!</h3>',
55
				title: '<h3	class="text-danger">ATTENTION!! ORDERING THROUGH APP MAY BE BLOCKED DUE TO LOW INVESTMENTS!</h3>',
56
					message : "<h3>Dear Partner, your investments are low by "
56
				message: "<h3>Dear Partner, your investments are low by "
57
							+ shortPercentage
57
					+ shortPercentage
58
							+ "%</h3>"
58
					+ "%</h3>"
59
							+ "<dl>"
59
					+ "<dl>"
60
							+ "<dt>Investment Should be</dt><dd>- "
60
					+ "<dt>Investment Should be</dt><dd>- "
61
							+ minimumInvestmentAmount
61
					+ minimumInvestmentAmount
62
							+ "</dd>"
62
					+ "</dd>"
63
							+ "<dt>Total Invested Amount</dt><dd>-"
63
					+ "<dt>Total Invested Amount</dt><dd>-"
64
							+ totalInvestedAmount
64
					+ totalInvestedAmount
65
							+ "</dd>"
65
					+ "</dd>"
66
							+ '<dt>Investment Amount Short By</dt><dd class="text-danger lead">-  '
66
					+ '<dt>Investment Amount Short By</dt><dd class="text-danger lead">-  '
67
							+ shortAmount
67
					+ shortAmount
68
							+ '</dd></dl>'
68
					+ '</dd></dl>'
69
							+ '<pre class="text-danger" style="font-size:18px;"><strong>To unblock your Billing, please \nadd Rs.'
69
					+ '<pre class="text-danger" style="font-size:18px;"><strong>To unblock your Billing, please \nadd Rs.'
70
							+ minAmountToBeAdded
70
					+ minAmountToBeAdded
71
							+ ' to wallet immediately.</strong></pre>',
71
					+ ' to wallet immediately.</strong></pre>',
72
					buttons : {
72
				buttons: {
73
						cancel : {
73
					cancel: {
74
							label : "OK",
74
						label: "OK",
75
							className : 'btn-primary'
75
						className: 'btn-primary'
76
						}
-
 
77
					}
76
					}
-
 
77
				}
78
				});
78
			});
79
		investmentDialog.on('shown.bs.modal', function() {
79
		investmentDialog.on('shown.bs.modal', function() {
80
			var dialogEl = investmentDialog.find('.modal-content')[0];
80
			var dialogEl = investmentDialog.find('.modal-content')[0];
81
			var dialogRect = dialogEl.getBoundingClientRect();
81
			var dialogRect = dialogEl.getBoundingClientRect();
82
			var height = window.innerHeight - dialogRect.height;
82
			var height = window.innerHeight - dialogRect.height;
83
			var width = window.innerWidth - dialogRect.width;
83
			var width = window.innerWidth - dialogRect.width;
Line 88... Line 88...
88
	}
88
	}
89
}
89
}
90
$(document).ajaxStart(ajaxStartHandler);
90
$(document).ajaxStart(ajaxStartHandler);
91
 
91
 
92
function doAjaxRequestWithParamsHandler(urlString, httpType, params,
92
function doAjaxRequestWithParamsHandler(urlString, httpType, params,
93
		callback_function) {
93
	callback_function) {
94
	$.ajax({
94
	$.ajax({
95
		url : urlString,
95
		url: urlString,
96
		async : true,
96
		async: true,
97
		cache : false,
97
		cache: false,
98
		data : params,
98
		data: params,
99
		// dataType:'json',
99
		// dataType:'json',
100
		type : httpType,
100
		type: httpType,
101
		success : function(response) {
101
		success: function(response) {
102
			callback_function(response);
102
			callback_function(response);
103
			$('.currency').each(function(index, ele) {
103
			$('.currency').each(function(index, ele) {
104
				if (!isNaN(parseInt($(ele).html()))) {
104
				if (!isNaN(parseInt($(ele).html()))) {
105
					$(ele).html(numberToComma($(ele).html()));
105
					$(ele).html(numberToComma($(ele).html()));
106
				}
106
				}
Line 112... Line 112...
112
function doGetAjaxRequestWithParamsHandler(urlString, params, callback_function) {
112
function doGetAjaxRequestWithParamsHandler(urlString, params, callback_function) {
113
	doAjaxRequestWithParamsHandler(urlString, "GET", params, callback_function);
113
	doAjaxRequestWithParamsHandler(urlString, "GET", params, callback_function);
114
}
114
}
115
 
115
 
116
function doPostAjaxRequestWithParamsHandler(urlString, params,
116
function doPostAjaxRequestWithParamsHandler(urlString, params,
117
		callback_function) {
117
	callback_function) {
118
	doAjaxRequestWithParamsHandler(urlString, "POST", params, callback_function);
118
	doAjaxRequestWithParamsHandler(urlString, "POST", params, callback_function);
119
}
119
}
120
 
120
 
121
function doAjaxRequestWithJsonHandler(urlString, httpType, json,
121
function doAjaxRequestWithJsonHandler(urlString, httpType, json,
122
		callback_function) {
122
	callback_function) {
123
	$.ajax({
123
	$.ajax({
124
		url : urlString,
124
		url: urlString,
125
		async : true,
125
		async: true,
126
		cache : false,
126
		cache: false,
127
		processData : false,
127
		processData: false,
128
		data : json,
128
		data: json,
129
		contentType : 'application/json',
129
		contentType: 'application/json',
130
		type : httpType,
130
		type: httpType,
131
		success : function(response) {
131
		success: function(response) {
132
			// console.log("response"+JSON.stringify(data));
132
			// console.log("response"+JSON.stringify(data));
133
			callback_function(response);
133
			callback_function(response);
134
			$('.currency').each(function(index, ele) {
134
			$('.currency').each(function(index, ele) {
135
				if (!isNaN(parseInt($(ele).html()))) {
135
				if (!isNaN(parseInt($(ele).html()))) {
136
					$(ele).html(numberToComma($(ele).html()));
136
					$(ele).html(numberToComma($(ele).html()));
Line 148... Line 148...
148
	doAjaxRequestWithJsonHandler(urlString, "PUT", json, callback_function);
148
	doAjaxRequestWithJsonHandler(urlString, "PUT", json, callback_function);
149
}
149
}
150
 
150
 
151
function doAjaxRequestHandler(urlString, httpType, callback_function) {
151
function doAjaxRequestHandler(urlString, httpType, callback_function) {
152
	$.ajax({
152
	$.ajax({
153
		url : urlString,
153
		url: urlString,
154
		async : true,
154
		async: true,
155
		cache : false,
155
		cache: false,
156
		type : httpType,
156
		type: httpType,
157
		success : function(response) {
157
		success: function(response) {
158
			callback_function(response);
158
			callback_function(response);
159
			$('.currency').each(function(index, ele) {
159
			$('.currency').each(function(index, ele) {
160
				if (!isNaN(parseInt($(ele).html()))) {
160
				if (!isNaN(parseInt($(ele).html()))) {
161
					$(ele).html(numberToComma($(ele).html()));
161
					$(ele).html(numberToComma($(ele).html()));
162
				}
162
				}
Line 182... Line 182...
182
}
182
}
183
 
183
 
184
function doAjaxUploadRequest(urlString, httpType, file) {
184
function doAjaxUploadRequest(urlString, httpType, file) {
185
	var response;
185
	var response;
186
	doAjaxUploadRequestHandler(urlString, httpType, file,
186
	doAjaxUploadRequestHandler(urlString, httpType, file,
187
			function(ajaxResponse) {
187
		function(ajaxResponse) {
188
				response = ajaxResponse;
188
			response = ajaxResponse;
189
			});
189
		});
190
	return response;
190
	return response;
191
}
191
}
192
 
192
 
193
function doAjaxUploadRequestHandler(urlString, httpType, file,
193
function doAjaxUploadRequestHandler(urlString, httpType, file,
194
		callback_function) {
194
	callback_function) {
195
	var formData = new FormData();
195
	var formData = new FormData();
196
	formData.append("file", file);
196
	formData.append("file", file);
197
	$.ajax({
197
	$.ajax({
198
		url : urlString,
198
		url: urlString,
199
		type : httpType,
199
		type: httpType,
200
		data : formData,
200
		data: formData,
201
		dataType : 'json',
201
		dataType: 'json',
202
		async : true,
202
		async: true,
203
		cache : false,
203
		cache: false,
204
		contentType : false,
204
		contentType: false,
205
		enctype : 'multipart/form-data',
205
		enctype: 'multipart/form-data',
206
		processData : false,
206
		processData: false,
207
		success : function(response) {
207
		success: function(response) {
208
			// console.log("response"+JSON.stringify(data));
208
			// console.log("response"+JSON.stringify(data));
209
			callback_function(response);
209
			callback_function(response);
210
		}
210
		}
211
	});
211
	});
212
}
212
}
213
function doAjaxUploadRequestJsonHandler(urlString, httpType, file, json,
213
function doAjaxUploadRequestJsonHandler(urlString, httpType, file, json,
214
		callback_function) {
214
	callback_function) {
215
	var formData = new FormData();
215
	var formData = new FormData();
216
	formData.append("file", file);
216
	formData.append("file", file);
217
	formData.append('json', new Blob([ json ]));
217
	formData.append('json', new Blob([json]));
218
	$.ajax({
218
	$.ajax({
219
		url : urlString,
219
		url: urlString,
220
		type : httpType,
220
		type: httpType,
221
		data : formData,
221
		data: formData,
222
		enctype : 'multipart/form-data',
222
		enctype: 'multipart/form-data',
223
		contentType : false,
223
		contentType: false,
224
		processData : false,
224
		processData: false,
225
		success : function(response) {
225
		success: function(response) {
226
			// console.log("response"+JSON.stringify(data));
226
			// console.log("response"+JSON.stringify(data));
227
			callback_function(response);
227
			callback_function(response);
228
		}
228
		}
229
	});
229
	});
230
}
230
}
Line 294... Line 294...
294
	}
294
	}
295
	// You should set responseType as blob for binary responses
295
	// You should set responseType as blob for binary responses
296
	// xhttp.responseType = 'blob';
296
	// xhttp.responseType = 'blob';
297
	xhttp.send(data);
297
	xhttp.send(data);
298
}
298
}
-
 
299
function loadPaginatedCatalogNextItems(url, params, paginatedIdentifier,
-
 
300
	tableIdentifier, detailsContainerIdentifier) {
-
 
301
	var start = $("#" + paginatedIdentifier + " .start").text();
-
 
302
 
-
 
303
	var end = $("#" + paginatedIdentifier + " .end").text();
-
 
304
 
-
 
305
	url = context + url + "?offset=" + end;
-
 
306
 
-
 
307
	if (params != null) {
-
 
308
		for (var key in params) {
-
 
309
			if (params.hasOwnProperty(key)) {
-
 
310
				//console.log(key + " -> " + params[key]);
-
 
311
				url = url + "&" + key + "=" + params[key];
-
 
312
			}
-
 
313
		}
-
 
314
	}
-
 
315
 
-
 
316
	doGetAjaxRequestHandler(url, function(response) {
-
 
317
		var size = $("#" + paginatedIdentifier + " .size").text();
-
 
318
		if ((parseInt(end) + 20) > parseInt(size)) {
-
 
319
			// console.log("(end + 10) > size == true");
-
 
320
			$("#" + paginatedIdentifier + " .end").text(size);
-
 
321
		} else {
-
 
322
			// console.log("(end + 10) > size == false");
-
 
323
			$("#" + paginatedIdentifier + " .end").text(+end + +20);
-
 
324
		}
-
 
325
		$("#" + paginatedIdentifier + " .start").text(+start + +20);
-
 
326
		var last = $("#" + paginatedIdentifier + " .end").text();
-
 
327
		var temp = $("#" + paginatedIdentifier + " .size").text();
-
 
328
		console.log("last" + last);
-
 
329
		if (parseInt(last) >= parseInt(temp)) {
-
 
330
			$("#" + paginatedIdentifier + " .next").prop('disabled', true);
-
 
331
			// $( "#good-inventory-paginated .end" ).text(temp);
-
 
332
		}
-
 
333
		$('#' + tableIdentifier).html(response);
-
 
334
		if (detailsContainerIdentifier != null) {
-
 
335
			$('#' + detailsContainerIdentifier).html('');
-
 
336
		}
-
 
337
		$("#" + paginatedIdentifier + " .previous").prop('disabled', false);
-
 
338
	});
-
 
339
 
-
 
340
}
-
 
341
function loadPaginatedCatalogPreviousItem(url, params, paginatedIdentifier,
-
 
342
	tableIdentifier, detailsContainerIdentifier) {
-
 
343
	var start = $("#" + paginatedIdentifier + " .start").text();
-
 
344
	console.log("start" + start);
-
 
345
	var end = $("#" + paginatedIdentifier + " .end").text();
-
 
346
	console.log("Startend" + end);
-
 
347
	var size = $("#" + paginatedIdentifier + " .size").text();
-
 
348
	console.log("size" + size);
-
 
349
	if (parseInt(end) == parseInt(size) && parseInt(end) % 20 != 0) {
-
 
350
		var mod = parseInt(end) % 20;
-
 
351
		end = parseInt(end) + (20 - mod);
-
 
352
	}
-
 
353
	var pre = end - 20;
-
 
354
	var lat = pre - 20;
-
 
355
	//console.log("preCatalog" +pre);
-
 
356
 
-
 
357
	url = context + url + "?offset=" + pre;
-
 
358
 
-
 
359
	if (params != null) {
-
 
360
		for (var key in params) {
-
 
361
			if (params.hasOwnProperty(key)) {
-
 
362
				url = url + "&" + key + "=" + params[key];
-
 
363
			}
-
 
364
		}
-
 
365
	}
-
 
366
 
-
 
367
	doGetAjaxRequestHandler(url, function(response) {
-
 
368
		$("#" + paginatedIdentifier + " .end").text(+end - +20);
-
 
369
		$("#" + paginatedIdentifier + " .start").text(+start - +20);
-
 
370
		$('#' + tableIdentifier).html(response);
-
 
371
		if (detailsContainerIdentifier != null) {
-
 
372
			$('#' + detailsContainerIdentifier).html('');
-
 
373
		}
-
 
374
		$("#" + paginatedIdentifier + " .next").prop('disabled', false);
-
 
375
		if (parseInt(lat) == 0) {
-
 
376
			$("#" + paginatedIdentifier + " .previous").prop('disabled', true);
-
 
377
		}
-
 
378
	});
-
 
379
 
-
 
380
}
299
 
381
 
300
function loadPaginatedNextItems(url, params, paginatedIdentifier,
382
function loadPaginatedNextItems(url, params, paginatedIdentifier,
301
		tableIdentifier, detailsContainerIdentifier) {
383
	tableIdentifier, detailsContainerIdentifier) {
302
	var start = $("#" + paginatedIdentifier + " .start").text();
384
	var start = $("#" + paginatedIdentifier + " .start").text();
303
	var end = $("#" + paginatedIdentifier + " .end").text();
385
	var end = $("#" + paginatedIdentifier + " .end").text();
304
	url = context + url + "?offset=" + end;
386
	url = context + url + "?offset=" + end;
305
 
387
 
306
	if (params != null) {
388
	if (params != null) {
307
		for ( var key in params) {
389
		for (var key in params) {
308
			if (params.hasOwnProperty(key)) {
390
			if (params.hasOwnProperty(key)) {
309
				// console.log(key + " -> " + p[key]);
391
				// console.log(key + " -> " + p[key]);
310
				url = url + "&" + key + "=" + params[key];
392
				url = url + "&" + key + "=" + params[key];
311
			}
393
			}
312
		}
394
		}
Line 336... Line 418...
336
	});
418
	});
337
 
419
 
338
}
420
}
339
 
421
 
340
function loadPaginatedPreviousItems(url, params, paginatedIdentifier,
422
function loadPaginatedPreviousItems(url, params, paginatedIdentifier,
341
		tableIdentifier, detailsContainerIdentifier) {
423
	tableIdentifier, detailsContainerIdentifier) {
342
	var start = $("#" + paginatedIdentifier + " .start").text();
424
	var start = $("#" + paginatedIdentifier + " .start").text();
343
	var end = $("#" + paginatedIdentifier + " .end").text();
425
	var end = $("#" + paginatedIdentifier + " .end").text();
344
	var size = $("#" + paginatedIdentifier + " .size").text();
426
	var size = $("#" + paginatedIdentifier + " .size").text();
345
	if (parseInt(end) == parseInt(size) && parseInt(end) % 10 != 0) {
427
	if (parseInt(end) == parseInt(size) && parseInt(end) % 10 != 0) {
346
		var mod = parseInt(end) % 10;
428
		var mod = parseInt(end) % 10;
347
		end = parseInt(end) + (10 - mod);
429
		end = parseInt(end) + (10 - mod);
348
	}
430
	}
349
	var pre = end - 20;
431
	var pre = end - 10;
350
 
432
 
351
	url = context + url + "?offset=" + pre;
433
	url = context + url + "?offset=" + pre;
352
 
434
 
353
	if (params != null) {
435
	if (params != null) {
354
		for ( var key in params) {
436
		for (var key in params) {
355
			if (params.hasOwnProperty(key)) {
437
			if (params.hasOwnProperty(key)) {
356
				url = url + "&" + key + "=" + params[key];
438
				url = url + "&" + key + "=" + params[key];
357
			}
439
			}
358
		}
440
		}
359
	}
441
	}
Line 386... Line 468...
386
	} else {
468
	} else {
387
		if (otherNumbers != '')
469
		if (otherNumbers != '')
388
			lastThree = ',' + lastThree;
470
			lastThree = ',' + lastThree;
389
	}
471
	}
390
	return otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g, ",") + (lastThree)
472
	return otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g, ",") + (lastThree)
391
			+ x2;
473
		+ x2;
392
 
474
 
393
}
475
}
394
 
476
 
395
function reporticoDRCallback(start, end) {
477
function reporticoDRCallback(start, end) {
396
	startMoment = start;
478
	startMoment = start;
Line 406... Line 488...
406
	endDate = end.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
488
	endDate = end.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
407
}
489
}
408
 
490
 
409
function getSingleDatePicker() {
491
function getSingleDatePicker() {
410
	var singleDatePicker = {
492
	var singleDatePicker = {
411
		"todayHighlight" : true,
493
		"todayHighlight": true,
412
		"startDate" : startMoment || moment(),
494
		"startDate": startMoment || moment(),
413
		"autoclose" : true,
495
		"autoclose": true,
414
		"autoUpdateInput" : true,
496
		"autoUpdateInput": true,
415
		"singleDatePicker" : true,
497
		"singleDatePicker": true,
416
		"locale" : {
498
		"locale": {
417
			'format' : 'DD/MM/YYYY'
499
			'format': 'DD/MM/YYYY'
418
		}
500
		}
419
	};
501
	};
420
	return singleDatePicker;
502
	return singleDatePicker;
421
}
503
}
422
 
504
 
423
function getRangedDatePicker(showRanges) {
505
function getRangedDatePicker(showRanges) {
424
	if (typeof showRanges == "undefined") {
506
	if (typeof showRanges == "undefined") {
425
		showRanges = false;
507
		showRanges = false;
426
	}
508
	}
427
	var rangedDatePicker = {
509
	var rangedDatePicker = {
428
		"todayHighlight" : true,
510
		"todayHighlight": true,
429
		"opens" : "right",
511
		"opens": "right",
430
		"startDate" : startMoment || moment(),
512
		"startDate": startMoment || moment(),
431
		"endDate" : endMoment || moment(),
513
		"endDate": endMoment || moment(),
432
		"autoclose" : true,
514
		"autoclose": true,
433
		"alwaysShowCalendars" : false,
515
		"alwaysShowCalendars": false,
434
		"autoUpdateInput" : true,
516
		"autoUpdateInput": true,
435
		"locale" : {
517
		"locale": {
436
			'format' : 'DD/MM/YYYY'
518
			'format': 'DD/MM/YYYY'
437
		}
519
		}
438
	};
520
	};
439
	if (showRanges) {
521
	if (showRanges) {
440
		rangedDatePicker['ranges'] = {
522
		rangedDatePicker['ranges'] = {
441
			'Today' : [ moment(), moment() ],
523
			'Today': [moment(), moment()],
442
			'Yesterday' : [ moment().subtract(1, 'days'),
524
			'Yesterday': [moment().subtract(1, 'days'),
443
					moment().subtract(1, 'days') ],
525
			moment().subtract(1, 'days')],
444
			'Last 7 Days' : [ moment().subtract(6, 'days'), moment() ],
526
			'Last 7 Days': [moment().subtract(6, 'days'), moment()],
445
			'Last 30 Days' : [ moment().subtract(29, 'days'), moment() ],
527
			'Last 30 Days': [moment().subtract(29, 'days'), moment()],
446
			'This Month' : [ moment().startOf('month'), moment().endOf('month') ],
528
			'This Month': [moment().startOf('month'), moment().endOf('month')],
447
			'Last Month' : [ moment().subtract(1, 'month').startOf('month'),
529
			'Last Month': [moment().subtract(1, 'month').startOf('month'),
448
					moment() ],
530
			moment()],
449
			'Last 3 Months' : [ moment().subtract(3, 'month').startOf('month'),
531
			'Last 3 Months': [moment().subtract(3, 'month').startOf('month'),
450
					moment() ],
532
			moment()],
451
			'Last 6 Months' : [ moment().subtract(6, 'month').startOf('month'),
533
			'Last 6 Months': [moment().subtract(6, 'month').startOf('month'),
452
					moment() ]
534
			moment()]
453
		}
535
		}
454
	}
536
	}
455
	return rangedDatePicker;
537
	return rangedDatePicker;
456
}
538
}
457
function showPosition(position) {
539
function showPosition(position) {
458
	if (typeof latitude == "undefined") {
540
	if (typeof latitude == "undefined") {
459
		var coords = {
541
		var coords = {
460
			latitude : position.coords.latitude,
542
			latitude: position.coords.latitude,
461
			longitude : position.coords.longitude
543
			longitude: position.coords.longitude
462
		}
544
		}
463
		doAjaxRequestWithJsonHandler('partner/location', 'PUT', JSON
545
		doAjaxRequestWithJsonHandler('partner/location', 'PUT', JSON
464
				.stringify(coords), function() {
546
			.stringify(coords), function() {
465
			latitude = position.coords.latitude;
547
				latitude = position.coords.latitude;
466
			longitude = position.coords.longitude;
548
				longitude = position.coords.longitude;
467
		});
549
			});
468
	}
550
	}
469
	// distance = getDistance(latitude, longitude, position.coords.latitude,
551
	// distance = getDistance(latitude, longitude, position.coords.latitude,
470
	// position.coords.longitude);
552
	// position.coords.longitude);
471
}
553
}
472
 
554
 
473
function getAuthorisedWarehouses(callback) {
555
function getAuthorisedWarehouses(callback) {
474
	bootBoxObj = {
556
	bootBoxObj = {
475
		size : "small",
557
		size: "small",
476
		title : "Choose Warehouse",
558
		title: "Choose Warehouse",
477
		callback : callback,
559
		callback: callback,
478
		inputType : 'select',
560
		inputType: 'select',
479
		inputOptions : typeof inputOptions == "undefined" ? undefined
561
		inputOptions: typeof inputOptions == "undefined" ? undefined
480
				: inputOptions
562
			: inputOptions
481
	}
563
	}
482
	if (typeof inputOptions == "undefined") {
564
	if (typeof inputOptions == "undefined") {
483
		doGetAjaxRequestHandler(context + "/authorisedWarehouses", function(
565
		doGetAjaxRequestHandler(context + "/authorisedWarehouses", function(
484
				response) {
566
			response) {
485
			response = JSON.parse(response);
567
			response = JSON.parse(response);
486
			inputOptions = [];
568
			inputOptions = [];
487
			response.forEach(function(warehouse) {
569
			response.forEach(function(warehouse) {
488
				inputOptions.push({
570
				inputOptions.push({
489
					text : warehouse.name,
571
					text: warehouse.name,
490
					value : warehouse.id,
572
					value: warehouse.id,
491
				});
573
				});
492
			});
574
			});
493
			bootBoxObj['inputOptions'] = inputOptions;
575
			bootBoxObj['inputOptions'] = inputOptions;
494
			bootbox.prompt(bootBoxObj);
576
			bootbox.prompt(bootBoxObj);
495
		});
577
		});
Line 500... Line 582...
500
	}
582
	}
501
 
583
 
502
}
584
}
503
function getColorsForItems(catalogId, itemId, description, callback) {
585
function getColorsForItems(catalogId, itemId, description, callback) {
504
	bootBoxObj = {
586
	bootBoxObj = {
505
		size : "small",
587
		size: "small",
506
		className : "item-wrapper",
588
		className: "item-wrapper",
507
		title : description,
589
		title: description,
508
		callback : callback,
590
		callback: callback,
509
		inputType : 'checkbox',
591
		inputType: 'checkbox',
510
	}
592
	}
511
	doGetAjaxRequestHandler(context + "/itemsByCatalogId?catalogId="
593
	doGetAjaxRequestHandler(context + "/itemsByCatalogId?catalogId="
512
			+ catalogId + "&itemId=" + itemId, function(response) {
594
		+ catalogId + "&itemId=" + itemId, function(response) {
513
		coloredItems = JSON.parse(response);
595
			coloredItems = JSON.parse(response);
514
		inputOptions = [ {
596
			inputOptions = [{
515
			text : "All",
597
				text: "All",
516
			value : "0",
598
				value: "0",
517
			onclick : "toggleAll('itemIds')"
599
				onclick: "toggleAll('itemIds')"
518
		} ];
600
			}];
519
		coloredItems.forEach(function(item) {
601
			coloredItems.forEach(function(item) {
520
			inputOptions.push({
602
				inputOptions.push({
521
				text : item.color,
603
					text: item.color,
522
				value : item.id,
604
					value: item.id,
523
				selected : item.active
605
					selected: item.active
-
 
606
				});
524
			});
607
			});
525
		});
-
 
526
		bootBoxObj['inputOptions'] = inputOptions;
608
			bootBoxObj['inputOptions'] = inputOptions;
527
		promptObj = bootbox.prompt(bootBoxObj);
609
			promptObj = bootbox.prompt(bootBoxObj);
528
		promptObj.modal('show')
610
			promptObj.modal('show')
529
		$('.item-wrapper').find("input[type='checkbox']").slice(1).each(
611
			$('.item-wrapper').find("input[type='checkbox']").slice(1).each(
530
				function(index, checkbox) {
612
				function(index, checkbox) {
531
					checkbox.checked = coloredItems[index].active;
613
					checkbox.checked = coloredItems[index].active;
532
				});
614
				});
533
	});
615
		});
534
}
616
}
535
$(".item-wrapper").find("input[type='checkbox']:first").live(
617
$(".item-wrapper").find("input[type='checkbox']:first").live(
536
		'change',
618
	'change',
537
		function() {
619
	function() {
538
			if (this.value == "0") {
620
		if (this.value == "0") {
539
				$(this).closest('.item-wrapper').find("input[type='checkbox']")
621
			$(this).closest('.item-wrapper').find("input[type='checkbox']")
540
						.slice(1).prop('checked', $(this).prop('checked'));
622
				.slice(1).prop('checked', $(this).prop('checked'));
541
			}
623
		}
542
		});
624
	});
543
function getItemAheadOptions(jqElement, callback) {
625
function getItemAheadOptions(jqElement, anyColor, callback) {
-
 
626
	console.log(anyColor)
544
	jqElement.typeahead('destroy').typeahead({
627
	jqElement.typeahead('destroy').typeahead({
545
		source : function(q, process) {
628
		source: function(q, process) {
546
			if (q.length >= 3) {
629
			if (q.length >= 3) {
547
				return $.ajax(context + "/item", {
630
				return $.ajax(context + "/item?anyColor=" + anyColor, {
548
					global : false,
631
					global: false,
549
					data : {
632
					data: {
550
						query : q
633
						query: q
551
					},
634
					},
552
					success : function(data) {
635
					success: function(data) {
553
						queryData = JSON.parse(data);
636
						queryData = JSON.parse(data);
554
						process(queryData);
637
						process(queryData);
555
					},
638
					},
556
				});
639
				});
557
			}
640
			}
558
		},
641
		},
559
		delay : 300,
642
		delay: 300,
560
		items : 20,
643
		items: 20,
561
		displayText : function(item) {
644
		displayText: function(item) {
562
			return item.itemDescription;
645
			return item.itemDescription;
563
		},
646
		},
564
		autoSelect : true,
647
		autoSelect: true,
565
		afterSelect : callback
648
		afterSelect: callback
566
	});
649
	});
567
}
650
}
568
function getEntityAheadOptions(jqElement, callback) {
651
function getEntityAheadOptions(jqElement, callback) {
569
	jqElement.typeahead('destroy').typeahead({
652
	jqElement.typeahead('destroy').typeahead({
570
		source : function(q, process) {
653
		source: function(q, process) {
571
			if (q.length >= 3) {
654
			if (q.length >= 3) {
572
				return $.ajax(context + "/entity", {
655
				return $.ajax(context + "/entity", {
573
					global : false,
656
					global: false,
574
					data : {
657
					data: {
575
						query : q
658
						query: q
576
					},
659
					},
577
					success : function(data) {
660
					success: function(data) {
578
						queryData = JSON.parse(data);
661
						queryData = JSON.parse(data);
579
						process(queryData);
662
						process(queryData);
580
					},
663
					},
581
				});
664
				});
582
			}
665
			}
583
		},
666
		},
584
		delay : 300,
667
		delay: 300,
585
		items : 20,
668
		items: 20,
586
		displayText : function(entity) {
669
		displayText: function(entity) {
587
			return entity.title_s + "(" + entity.catalogId_i + ")";
670
			return entity.title_s + "(" + entity.catalogId_i + ")";
588
		},
671
		},
589
		autoSelect : true,
672
		autoSelect: true,
590
		afterSelect : callback
673
		afterSelect: callback
591
	});
674
	});
592
}
675
}
593
function getPartnerAheadOptions(jqElement, callback) {
676
function getPartnerAheadOptions(jqElement, callback) {
594
	jqElement.typeahead('destroy').typeahead({
677
	jqElement.typeahead('destroy').typeahead({
595
		source : function(q, process) {
678
		source: function(q, process) {
596
			if (q.length >= 3) {
679
			if (q.length >= 3) {
597
				return $.ajax(context + "/partners", {
680
				return $.ajax(context + "/partners", {
598
					global : false,
681
					global: false,
599
					data : {
682
					data: {
600
						query : q
683
						query: q
601
					},
684
					},
602
					success : function(data) {
685
					success: function(data) {
603
						queryData = JSON.parse(data);
686
						queryData = JSON.parse(data);
604
						process(queryData);
687
						process(queryData);
605
					},
688
					},
606
				});
689
				});
607
			}
690
			}
608
		},
691
		},
609
		delay : 300,
692
		delay: 300,
610
		items : 20,
693
		items: 20,
611
		displayText : function(partner) {
694
		displayText: function(partner) {
612
			return partner.displayName;
695
			return partner.displayName;
613
		},
696
		},
614
		autoSelect : true,
697
		autoSelect: true,
615
		afterSelect : callback
698
		afterSelect: callback
616
	});
699
	});
617
}
700
}
618
 
701
 
619
function loadPriceDrop(domId) {
702
function loadPriceDrop(domId) {
620
	doGetAjaxRequestHandler(context + "/getItemDescription",
703
	doGetAjaxRequestHandler(context + "/getItemDescription",
621
			function(response) {
704
		function(response) {
622
				$('#' + domId).html(response);
705
			$('#' + domId).html(response);
623
			});
706
		});
624
}
707
}
625
$(".price_drop").live('click', function() {
708
$(".price_drop").live('click', function() {
626
	loadPriceDrop("main-content");
709
	loadPriceDrop("main-content");
627
});
710
});
628
 
711
 
-
 
712
 
629
function notifyTypeChange(messageType) {
713
function notifyTypeChange(messageType) {
630
	var messageQueryString = "?messageType=" + messageType;
714
	var messageQueryString = "?messageType=" + messageType;
631
	if (messageType == null) {
715
	if (messageType == null) {
632
		messageQueryString = "";
716
		messageQueryString = "";
633
	}
717
	}
634
	doGetAjaxRequestHandler(context + "/notifications" + messageQueryString,
718
	doGetAjaxRequestHandler(context + "/notifications" + messageQueryString,
635
			function(response) {
719
		function(response) {
636
				$('.notification-container').html(response);
720
			$('.notification-container').html(response);
637
			});
721
		});
638
}
722
}
639
 
723
 
640
function downloadNotifyDocument(documentId, cid, documentName) {
724
function downloadNotifyDocument(documentId, cid, documentName) {
641
	doAjaxGetDownload(context + "/notifyDocument/download?cid=" + cid,
725
	doAjaxGetDownload(context + "/notifyDocument/download?cid=" + cid,
642
			documentName);
726
		documentName);
643
}
727
}