Subversion Repositories SmartDukaan

Rev

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

Rev 30414 Rev 30587
Line 26... Line 26...
26
		+ errorObject.rejectedType + '\n' + 'rejectedValue : '
26
		+ errorObject.rejectedType + '\n' + 'rejectedValue : '
27
		+ errorObject.rejectedValue + '\n' + 'message : '
27
		+ errorObject.rejectedValue + '\n' + 'message : '
28
		+ errorObject.message);
28
		+ errorObject.message);
29
}
29
}
30
 
30
 
31
$(document).ajaxError(function (event, jqxhr, settings, thrownError) {
31
$(document).ajaxError(function(event, jqxhr, settings, thrownError) {
32
	if (typeof loaderDialogObj != "undefined") {
32
	if (typeof loaderDialogObj != "undefined") {
33
		loaderDialogObj.modal('hide');
33
		loaderDialogObj.modal('hide');
34
		// $('div.modal-backdrop.fade').remove();
34
		// $('div.modal-backdrop.fade').remove();
35
	}
35
	}
36
	if (jqxhr.status == 400) {
36
	if (jqxhr.status == 400) {
Line 39... Line 39...
39
	} else {
39
	} else {
40
		internalServerErrorAlert(jqxhr);
40
		internalServerErrorAlert(jqxhr);
41
	}
41
	}
42
});
42
});
43
 
43
 
44
$(document).ajaxComplete(function () {
44
$(document).ajaxComplete(function() {
45
	if (typeof loaderDialogObj != "undefined") {
45
	if (typeof loaderDialogObj != "undefined") {
46
		loaderDialogObj.modal('hide');
46
		loaderDialogObj.modal('hide');
47
		// $('div.modal-backdrop.fade').remove();
47
		// $('div.modal-backdrop.fade').remove();
48
	}
48
	}
49
});
49
});
Line 54... Line 54...
54
}
54
}
55
 
55
 
56
$(document).ajaxStart(ajaxStartHandler);
56
$(document).ajaxStart(ajaxStartHandler);
57
 
57
 
58
function doAjaxRequestWithParamsHandler(urlString, httpType, params,
58
function doAjaxRequestWithParamsHandler(urlString, httpType, params,
59
										callback_function) {
59
	callback_function) {
60
	$.ajax({
60
	$.ajax({
61
		url: urlString,
61
		url: urlString,
62
		async: true,
62
		async: true,
63
		cache: false,
63
		cache: false,
64
		data: params,
64
		data: params,
65
		// dataType:'json',
65
		// dataType:'json',
66
		type: httpType,
66
		type: httpType,
67
		success: function (response) {
67
		success: function(response) {
68
			callback_function(response);
68
			callback_function(response);
69
			$('.currency').each(function (index, ele) {
69
			$('.currency').each(function(index, ele) {
70
				if (!isNaN(parseInt($(ele).html()))) {
70
				if (!isNaN(parseInt($(ele).html()))) {
71
					$(ele).html(numberToComma($(ele).html()));
71
					$(ele).html(numberToComma($(ele).html()));
72
				}
72
				}
73
			});
73
			});
74
		}
74
		}
Line 78... Line 78...
78
function doGetAjaxRequestWithParamsHandler(urlString, params, callback_function) {
78
function doGetAjaxRequestWithParamsHandler(urlString, params, callback_function) {
79
	doAjaxRequestWithParamsHandler(urlString, "GET", params, callback_function);
79
	doAjaxRequestWithParamsHandler(urlString, "GET", params, callback_function);
80
}
80
}
81
 
81
 
82
function doPostAjaxRequestWithParamsHandler(urlString, params,
82
function doPostAjaxRequestWithParamsHandler(urlString, params,
83
											callback_function) {
83
	callback_function) {
84
	doAjaxRequestWithParamsHandler(urlString, "POST", params, callback_function);
84
	doAjaxRequestWithParamsHandler(urlString, "POST", params, callback_function);
85
}
85
}
86
 
86
 
87
function doAjaxRequestWithJsonHandler(urlString, httpType, json,
87
function doAjaxRequestWithJsonHandler(urlString, httpType, json,
88
									  callback_function) {
88
	callback_function) {
89
	$.ajax({
89
	$.ajax({
90
		url: urlString,
90
		url: urlString,
91
		async: true,
91
		async: true,
92
		cache: false,
92
		cache: false,
93
		processData: false,
93
		processData: false,
94
		data: json,
94
		data: json,
95
		contentType: 'application/json',
95
		contentType: 'application/json',
96
		type: httpType,
96
		type: httpType,
97
		success: function (response) {
97
		success: function(response) {
98
			// console.log("response"+JSON.stringify(data));
98
			// console.log("response"+JSON.stringify(data));
99
			callback_function(response);
99
			callback_function(response);
100
			$('.currency').each(function (index, ele) {
100
			$('.currency').each(function(index, ele) {
101
				if (!isNaN(parseInt($(ele).html()))) {
101
				if (!isNaN(parseInt($(ele).html()))) {
102
					$(ele).html(numberToComma($(ele).html()));
102
					$(ele).html(numberToComma($(ele).html()));
103
				}
103
				}
104
			});
104
			});
105
		}
105
		}
Line 118... Line 118...
118
	$.ajax({
118
	$.ajax({
119
		url: urlString,
119
		url: urlString,
120
		async: true,
120
		async: true,
121
		cache: false,
121
		cache: false,
122
		type: httpType,
122
		type: httpType,
123
		success: function (response) {
123
		success: function(response) {
124
			callback_function(response);
124
			callback_function(response);
125
			$('.currency').each(function (index, ele) {
125
			$('.currency').each(function(index, ele) {
126
				if (!isNaN(parseInt($(ele).html()))) {
126
				if (!isNaN(parseInt($(ele).html()))) {
127
					$(ele).html(numberToComma($(ele).html()));
127
					$(ele).html(numberToComma($(ele).html()));
128
				}
128
				}
129
			});
129
			});
130
		}
130
		}
Line 148... Line 148...
148
}
148
}
149
 
149
 
150
function doAjaxUploadRequest(urlString, httpType, file) {
150
function doAjaxUploadRequest(urlString, httpType, file) {
151
	var response;
151
	var response;
152
	doAjaxUploadRequestHandler(urlString, httpType, file,
152
	doAjaxUploadRequestHandler(urlString, httpType, file,
153
		function (ajaxResponse) {
153
		function(ajaxResponse) {
154
			response = ajaxResponse;
154
			response = ajaxResponse;
155
		});
155
		});
156
	return response;
156
	return response;
157
}
157
}
158
 
158
 
159
function doAjaxUploadRequestHandler(urlString, httpType, file,
159
function doAjaxUploadRequestHandler(urlString, httpType, file,
160
									callback_function) {
160
	callback_function) {
161
	var formData = new FormData();
161
	var formData = new FormData();
162
	formData.append("file", file);
162
	formData.append("file", file);
163
	$.ajax({
163
	$.ajax({
164
		url: urlString,
164
		url: urlString,
165
		type: httpType,
165
		type: httpType,
Line 168... Line 168...
168
		async: true,
168
		async: true,
169
		cache: false,
169
		cache: false,
170
		contentType: false,
170
		contentType: false,
171
		enctype: 'multipart/form-data',
171
		enctype: 'multipart/form-data',
172
		processData: false,
172
		processData: false,
173
		success: function (response) {
173
		success: function(response) {
174
			// console.log("response"+JSON.stringify(data));
174
			// console.log("response"+JSON.stringify(data));
175
			callback_function(response);
175
			callback_function(response);
176
		}
176
		}
177
	});
177
	});
178
}
178
}
179
 
179
 
180
function doAjaxUploadRequestJsonHandler(urlString, httpType, file, json,
180
function doAjaxUploadRequestJsonHandler(urlString, httpType, file, json,
181
										callback_function) {
181
	callback_function) {
182
	var formData = new FormData();
182
	var formData = new FormData();
183
	formData.append("file", file);
183
	formData.append("file", file);
184
	formData.append('json', new Blob([json]));
184
	formData.append('json', new Blob([json]));
185
	$.ajax({
185
	$.ajax({
186
		url: urlString,
186
		url: urlString,
187
		type: httpType,
187
		type: httpType,
188
		data: formData,
188
		data: formData,
189
		enctype: 'multipart/form-data',
189
		enctype: 'multipart/form-data',
190
		contentType: false,
190
		contentType: false,
191
		processData: false,
191
		processData: false,
192
		success: function (response) {
192
		success: function(response) {
193
			// console.log("response"+JSON.stringify(data));
193
			// console.log("response"+JSON.stringify(data));
194
			callback_function(response);
194
			callback_function(response);
195
		}
195
		}
196
	});
196
	});
197
}
197
}
198
 
198
 
199
function uploadDocument(file) {
199
function uploadDocument(file) {
200
	var url = context + '/document-upload';
200
	var url = context + '/document-upload';
201
	doAjaxUploadRequestHandler(url, 'POST', file, function (response) {
201
	doAjaxUploadRequestHandler(url, 'POST', file, function(response) {
202
		var documentId = response.response.document_id;
202
		var documentId = response.response.document_id;
203
		console.log("documentId : " + documentId);
203
		console.log("documentId : " + documentId);
204
		return documentId;
204
		return documentId;
205
	});
205
	});
206
}
206
}
Line 216... Line 216...
216
 
216
 
217
function doAjaxDownload(urlString, httpType, data, fileName) {
217
function doAjaxDownload(urlString, httpType, data, fileName) {
218
	xhttp = new XMLHttpRequest();
218
	xhttp = new XMLHttpRequest();
219
	if (typeof loaderDialogObj != "undefined")
219
	if (typeof loaderDialogObj != "undefined")
220
		loaderDialogObj.modal('show');
220
		loaderDialogObj.modal('show');
221
	xhttp.onreadystatechange = function () {
221
	xhttp.onreadystatechange = function() {
222
		var a;
222
		var a;
223
		if (xhttp.readyState === 2) {
223
		if (xhttp.readyState === 2) {
224
			if (xhttp.status == 200) {
224
			if (xhttp.status == 200) {
225
				xhttp.responseType = "blob";
225
				xhttp.responseType = "blob";
226
			} else {
226
			} else {
Line 263... Line 263...
263
	// xhttp.responseType = 'blob';
263
	// xhttp.responseType = 'blob';
264
	xhttp.send(data);
264
	xhttp.send(data);
265
}
265
}
266
 
266
 
267
function loadPaginatedCatalogNextItems(url, params, paginatedIdentifier,
267
function loadPaginatedCatalogNextItems(url, params, paginatedIdentifier,
268
									   tableIdentifier, detailsContainerIdentifier) {
268
	tableIdentifier, detailsContainerIdentifier) {
269
	var start = $("#" + paginatedIdentifier + " .start").text();
269
	var start = $("#" + paginatedIdentifier + " .start").text();
270
 
270
 
271
	var end = $("#" + paginatedIdentifier + " .end").text();
271
	var end = $("#" + paginatedIdentifier + " .end").text();
272
 
272
 
273
	url = context + url + "?offset=" + end;
273
	url = context + url + "?offset=" + end;
Line 279... Line 279...
279
				url = url + "&" + key + "=" + params[key];
279
				url = url + "&" + key + "=" + params[key];
280
			}
280
			}
281
		}
281
		}
282
	}
282
	}
283
 
283
 
284
	doGetAjaxRequestHandler(url, function (response) {
284
	doGetAjaxRequestHandler(url, function(response) {
285
		var size = $("#" + paginatedIdentifier + " .size").text();
285
		var size = $("#" + paginatedIdentifier + " .size").text();
286
		if ((parseInt(end) + 20) > parseInt(size)) {
286
		if ((parseInt(end) + 20) > parseInt(size)) {
287
			// console.log("(end + 10) > size == true");
287
			// console.log("(end + 10) > size == true");
288
			$("#" + paginatedIdentifier + " .end").text(size);
288
			$("#" + paginatedIdentifier + " .end").text(size);
289
		} else {
289
		} else {
Line 306... Line 306...
306
	});
306
	});
307
 
307
 
308
}
308
}
309
 
309
 
310
function loadPaginatedCatalogPreviousItem(url, params, paginatedIdentifier,
310
function loadPaginatedCatalogPreviousItem(url, params, paginatedIdentifier,
311
										  tableIdentifier, detailsContainerIdentifier) {
311
	tableIdentifier, detailsContainerIdentifier) {
312
	var start = $("#" + paginatedIdentifier + " .start").text();
312
	var start = $("#" + paginatedIdentifier + " .start").text();
313
	console.log("start" + start);
313
	console.log("start" + start);
314
	var end = $("#" + paginatedIdentifier + " .end").text();
314
	var end = $("#" + paginatedIdentifier + " .end").text();
315
	console.log("Startend" + end);
315
	console.log("Startend" + end);
316
	var size = $("#" + paginatedIdentifier + " .size").text();
316
	var size = $("#" + paginatedIdentifier + " .size").text();
Line 331... Line 331...
331
				url = url + "&" + key + "=" + params[key];
331
				url = url + "&" + key + "=" + params[key];
332
			}
332
			}
333
		}
333
		}
334
	}
334
	}
335
 
335
 
336
	doGetAjaxRequestHandler(url, function (response) {
336
	doGetAjaxRequestHandler(url, function(response) {
337
		$("#" + paginatedIdentifier + " .end").text(+end - +20);
337
		$("#" + paginatedIdentifier + " .end").text(+end - +20);
338
		$("#" + paginatedIdentifier + " .start").text(+start - +20);
338
		$("#" + paginatedIdentifier + " .start").text(+start - +20);
339
		$('#' + tableIdentifier).html(response);
339
		$('#' + tableIdentifier).html(response);
340
		if (detailsContainerIdentifier != null) {
340
		if (detailsContainerIdentifier != null) {
341
			$('#' + detailsContainerIdentifier).html('');
341
			$('#' + detailsContainerIdentifier).html('');
Line 347... Line 347...
347
	});
347
	});
348
 
348
 
349
}
349
}
350
 
350
 
351
function loadPaginatedNextItems(url, params, paginatedIdentifier,
351
function loadPaginatedNextItems(url, params, paginatedIdentifier,
352
								tableIdentifier, detailsContainerIdentifier) {
352
	tableIdentifier, detailsContainerIdentifier) {
353
	var start = $("#" + paginatedIdentifier + " .start").text();
353
	var start = $("#" + paginatedIdentifier + " .start").text();
354
	var end = $("#" + paginatedIdentifier + " .end").text();
354
	var end = $("#" + paginatedIdentifier + " .end").text();
355
	url = context + url + "?offset=" + end;
355
	url = context + url + "?offset=" + end;
356
 
356
 
357
	if (params != null) {
357
	if (params != null) {
Line 361... Line 361...
361
				url = url + "&" + key + "=" + params[key];
361
				url = url + "&" + key + "=" + params[key];
362
			}
362
			}
363
		}
363
		}
364
	}
364
	}
365
 
365
 
366
	doGetAjaxRequestHandler(url, function (response) {
366
	doGetAjaxRequestHandler(url, function(response) {
367
		var size = $("#" + paginatedIdentifier + " .size").text();
367
		var size = $("#" + paginatedIdentifier + " .size").text();
368
		if ((parseInt(end) + 10) > parseInt(size)) {
368
		if ((parseInt(end) + 10) > parseInt(size)) {
369
			console.log("(end + 10) > size == true");
369
			console.log("(end + 10) > size == true");
370
			$("#" + paginatedIdentifier + " .end").text(size);
370
			$("#" + paginatedIdentifier + " .end").text(size);
371
		} else {
371
		} else {
Line 387... Line 387...
387
	});
387
	});
388
 
388
 
389
}
389
}
390
 
390
 
391
function loadPaginatedPreviousItems(url, params, paginatedIdentifier,
391
function loadPaginatedPreviousItems(url, params, paginatedIdentifier,
392
									tableIdentifier, detailsContainerIdentifier) {
392
	tableIdentifier, detailsContainerIdentifier) {
393
	var start = $("#" + paginatedIdentifier + " .start").text();
393
	var start = $("#" + paginatedIdentifier + " .start").text();
394
	var end = $("#" + paginatedIdentifier + " .end").text();
394
	var end = $("#" + paginatedIdentifier + " .end").text();
395
	var size = $("#" + paginatedIdentifier + " .size").text();
395
	var size = $("#" + paginatedIdentifier + " .size").text();
396
	if (parseInt(end) == parseInt(size) && parseInt(end) % 10 != 0) {
396
	if (parseInt(end) == parseInt(size) && parseInt(end) % 10 != 0) {
397
		var mod = parseInt(end) % 10;
397
		var mod = parseInt(end) % 10;
Line 407... Line 407...
407
				url = url + "&" + key + "=" + params[key];
407
				url = url + "&" + key + "=" + params[key];
408
			}
408
			}
409
		}
409
		}
410
	}
410
	}
411
 
411
 
412
	doGetAjaxRequestHandler(url, function (response) {
412
	doGetAjaxRequestHandler(url, function(response) {
413
		$("#" + paginatedIdentifier + " .end").text(+end - +10);
413
		$("#" + paginatedIdentifier + " .end").text(+end - +10);
414
		$("#" + paginatedIdentifier + " .start").text(+start - +10);
414
		$("#" + paginatedIdentifier + " .start").text(+start - +10);
415
		$('#' + tableIdentifier).html(response);
415
		$('#' + tableIdentifier).html(response);
416
		if (detailsContainerIdentifier != null) {
416
		if (detailsContainerIdentifier != null) {
417
			$('#' + detailsContainerIdentifier).html('');
417
			$('#' + detailsContainerIdentifier).html('');
Line 456... Line 456...
456
	endMoment = end;
456
	endMoment = end;
457
	startDate = start.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
457
	startDate = start.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
458
	endDate = end.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
458
	endDate = end.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
459
}
459
}
460
 
460
 
-
 
461
function dateRangeCallBackFn(identifier) {
-
 
462
	return function(start, end) {
-
 
463
		statMoment = startMoment || {};
-
 
464
		endMoment = endMoment || {};
-
 
465
		startDate = startDate || {};
-
 
466
		endDate = endDate || {};
-
 
467
		startMoment[identifier] = start;
-
 
468
		endMoment[identifier] = end;
-
 
469
		startDate[identifier] = start.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
-
 
470
		endDate[identifier] = end.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
-
 
471
	}
-
 
472
}
-
 
473
 
461
function getSingleDatePicker() {
474
function getSingleDatePicker() {
462
	var singleDatePicker = {
475
	var singleDatePicker = {
463
		"todayHighlight": true,
476
		"todayHighlight": true,
464
		"startDate": startMoment || moment(),
477
		"startDate": startMoment || moment(),
465
		"autoclose": true,
478
		"autoclose": true,
Line 490... Line 503...
490
	};
503
	};
491
	if (showRanges) {
504
	if (showRanges) {
492
		rangedDatePicker['ranges'] = {
505
		rangedDatePicker['ranges'] = {
493
			'Today': [moment(), moment()],
506
			'Today': [moment(), moment()],
494
			'Yesterday': [moment().subtract(1, 'days'),
507
			'Yesterday': [moment().subtract(1, 'days'),
495
				moment().subtract(1, 'days')],
508
			moment().subtract(1, 'days')],
496
			'Last 7 Days': [moment().subtract(6, 'days'), moment()],
509
			'Last 7 Days': [moment().subtract(6, 'days'), moment()],
497
			'Last 30 Days': [moment().subtract(29, 'days'), moment()],
510
			'Last 30 Days': [moment().subtract(29, 'days'), moment()],
498
			'This Month': [moment().startOf('month'), moment().endOf('month')],
511
			'This Month': [moment().startOf('month'), moment().endOf('month')],
499
			'Last Month': [moment().subtract(1, 'month').startOf('month'),
512
			'Last Month': [moment().subtract(1, 'month').startOf('month'),
500
				moment()],
513
			moment()],
501
			'Last 3 Months': [moment().subtract(3, 'month').startOf('month'),
514
			'Last 3 Months': [moment().subtract(3, 'month').startOf('month'),
502
				moment()],
515
			moment()],
503
			'Last 6 Months': [moment().subtract(6, 'month').startOf('month'),
516
			'Last 6 Months': [moment().subtract(6, 'month').startOf('month'),
504
				moment()]
517
			moment()]
505
		}
518
		}
506
	}
519
	}
507
	return rangedDatePicker;
520
	return rangedDatePicker;
508
}
521
}
509
 
522
 
Line 512... Line 525...
512
		var coords = {
525
		var coords = {
513
			latitude: position.coords.latitude,
526
			latitude: position.coords.latitude,
514
			longitude: position.coords.longitude
527
			longitude: position.coords.longitude
515
		}
528
		}
516
		doAjaxRequestWithJsonHandler('partner/location', 'PUT', JSON
529
		doAjaxRequestWithJsonHandler('partner/location', 'PUT', JSON
517
			.stringify(coords), function () {
530
			.stringify(coords), function() {
518
			latitude = position.coords.latitude;
531
				latitude = position.coords.latitude;
519
			longitude = position.coords.longitude;
532
				longitude = position.coords.longitude;
520
		});
533
			});
521
	}
534
	}
522
	// distance = getDistance(latitude, longitude, position.coords.latitude,
535
	// distance = getDistance(latitude, longitude, position.coords.latitude,
523
	// position.coords.longitude);
536
	// position.coords.longitude);
524
}
537
}
525
 
538
 
Line 531... Line 544...
531
		inputType: 'select',
544
		inputType: 'select',
532
		inputOptions: typeof inputOptions == "undefined" ? undefined
545
		inputOptions: typeof inputOptions == "undefined" ? undefined
533
			: inputOptions
546
			: inputOptions
534
	}
547
	}
535
	if (typeof inputOptions == "undefined") {
548
	if (typeof inputOptions == "undefined") {
536
		doGetAjaxRequestHandler(context + "/authorisedWarehouses", function (
549
		doGetAjaxRequestHandler(context + "/authorisedWarehouses", function(
537
			response) {
550
			response) {
538
			response = JSON.parse(response);
551
			response = JSON.parse(response);
539
			inputOptions = [];
552
			inputOptions = [];
540
			response.forEach(function (warehouse) {
553
			response.forEach(function(warehouse) {
541
				inputOptions.push({
554
				inputOptions.push({
542
					text: warehouse.name,
555
					text: warehouse.name,
543
					value: warehouse.id,
556
					value: warehouse.id,
544
				});
557
				});
545
			});
558
			});
Line 558... Line 571...
558
	colorCheckboxHandler(catalogId, itemId, description, callback);
571
	colorCheckboxHandler(catalogId, itemId, description, callback);
559
}
572
}
560
 
573
 
561
function colorNumberHandler(catalogId, itemId, title, actionText, callback) {
574
function colorNumberHandler(catalogId, itemId, title, actionText, callback) {
562
	doGetAjaxRequestHandler(context + "/itemsByCatalogId?catalogId="
575
	doGetAjaxRequestHandler(context + "/itemsByCatalogId?catalogId="
563
		+ catalogId + "&itemId=" + itemId, function (response) {
576
		+ catalogId + "&itemId=" + itemId, function(response) {
564
		let coloredItems = JSON.parse(response);
577
			let coloredItems = JSON.parse(response);
565
		let modalBody = [];
578
			let modalBody = [];
566
		coloredItems.forEach(function (item) {
579
			coloredItems.forEach(function(item) {
567
			modalBody.push(`
580
				modalBody.push(`
568
                <div class="row">
581
                <div class="row">
569
                    <div class="col-sm-2">
582
                    <div class="col-sm-2">
570
                        ${item.color}
583
                        ${item.color}
571
                    </div>
584
                    </div>
572
                    <div class="col-sm-2">
585
                    <div class="col-sm-2">
573
                            <input data-itemid="${item.id}" type="text" class="form-control" />
586
                            <input data-itemid="${item.id}" type="text" class="form-control" />
574
                    </div>
587
                    </div>
575
                </div>
588
                </div>
576
            `);
589
            `);
577
		});
590
			});
578
		let dialogBoxHtml = `<div class="modal modal" tabindex="-1" role="dialog">
591
			let dialogBoxHtml = `<div class="modal modal" tabindex="-1" role="dialog">
579
                              <div class="modal-dialog" >
592
                              <div class="modal-dialog" >
580
                                <div class="modal-content">
593
                                <div class="modal-content">
581
                                  <div class="modal-header">
594
                                  <div class="modal-header">
582
                                    <h5 class="modal-title">${title}</h5>
595
                                    <h5 class="modal-title">${title}</h5>
583
                                  </div>
596
                                  </div>
Line 588... Line 601...
588
                                    <button type="button" class="btn btn-primary number_dialog">${actionText}</button>
601
                                    <button type="button" class="btn btn-primary number_dialog">${actionText}</button>
589
                                  </div>
602
                                  </div>
590
                                </div>
603
                                </div>
591
                              </div>
604
                              </div>
592
                            </div>`;
605
                            </div>`;
593
		let $dialog = $(dialogBoxHtml);
606
			let $dialog = $(dialogBoxHtml);
594
		let modalObj = $dialog.modal('show');
607
			let modalObj = $dialog.modal('show');
595
		modalObj.on('hidden.bs.modal', function (e) {
608
			modalObj.on('hidden.bs.modal', function(e) {
596
			$dialog.remove();
609
				$dialog.remove();
597
		});
610
			});
598
		$('button.number_dialog').on('click', function () {
611
			$('button.number_dialog').on('click', function() {
599
			let itemQty = [];
612
				let itemQty = [];
600
			let anySelected = false;
613
				let anySelected = false;
601
			$(modalObj).find('.modal-body').find('input').each(function () {
614
				$(modalObj).find('.modal-body').find('input').each(function() {
602
				$input = $(this);
615
					$input = $(this);
603
				if ($input.val() > 0) {
616
					if ($input.val() > 0) {
604
					itemQty.push({
617
						itemQty.push({
605
						itemId: $input.data("itemid"),
618
							itemId: $input.data("itemid"),
606
						quantity: $input.val()
619
							quantity: $input.val()
-
 
620
						});
-
 
621
						anySelected = true;
-
 
622
					}
-
 
623
				});
-
 
624
				if (anySelected && confirm("Are you sure want to notify?")) {
-
 
625
					$that = $(this);
-
 
626
					callback(itemQty, function() {
-
 
627
						$that.off('click');
-
 
628
						modalObj.hide();
607
					});
629
					});
-
 
630
				} else {
608
					anySelected = true;
631
					alert("Pls mention quantity");
609
				}
632
				}
610
			});
633
			});
611
			if (anySelected && confirm("Are you sure want to notify?")) {
-
 
612
				$that = $(this);
-
 
613
				callback(itemQty, function () {
-
 
614
					$that.off('click');
-
 
615
					modalObj.hide();
-
 
616
				});
-
 
617
			} else {
-
 
618
				alert("Pls mention quantity");
-
 
619
			}
-
 
620
		});
634
		});
621
	});
-
 
622
}
635
}
623
 
636
 
624
 
637
 
625
function colorCheckboxHandler(catalogId, itemId, description, callback) {
638
function colorCheckboxHandler(catalogId, itemId, description, callback) {
626
	let bootBoxObj = {
639
	let bootBoxObj = {
Line 629... Line 642...
629
		title: description,
642
		title: description,
630
		callback: callback,
643
		callback: callback,
631
		inputType: 'checkbox',
644
		inputType: 'checkbox',
632
	}
645
	}
633
	doGetAjaxRequestHandler(context + "/itemsByCatalogId?catalogId="
646
	doGetAjaxRequestHandler(context + "/itemsByCatalogId?catalogId="
634
		+ catalogId + "&itemId=" + itemId, function (response) {
647
		+ catalogId + "&itemId=" + itemId, function(response) {
635
		coloredItems = JSON.parse(response);
648
			coloredItems = JSON.parse(response);
636
		inputOptions = [{
649
			inputOptions = [{
637
			text: "All",
650
				text: "All",
638
			value: "0",
651
				value: "0",
639
			onclick: "toggleAll('itemIds')"
652
				onclick: "toggleAll('itemIds')"
640
		}];
653
			}];
641
		coloredItems.forEach(function (item) {
654
			coloredItems.forEach(function(item) {
642
			inputOptions.push({
655
				inputOptions.push({
643
				text: item.color,
656
					text: item.color,
644
				value: item.id,
657
					value: item.id,
645
				selected: item.active
658
					selected: item.active
-
 
659
				});
646
			});
660
			});
-
 
661
			bootBoxObj['inputOptions'] = inputOptions;
-
 
662
			promptObj = bootbox.prompt(bootBoxObj);
-
 
663
			promptObj.modal('show')
-
 
664
			$('.item-wrapper').find("input[type='checkbox']").slice(1).each(
-
 
665
				function(index, checkbox) {
-
 
666
					checkbox.checked = coloredItems[index].active;
-
 
667
				});
647
		});
668
		});
648
		bootBoxObj['inputOptions'] = inputOptions;
-
 
649
		promptObj = bootbox.prompt(bootBoxObj);
-
 
650
		promptObj.modal('show')
-
 
651
		$('.item-wrapper').find("input[type='checkbox']").slice(1).each(
-
 
652
			function (index, checkbox) {
-
 
653
				checkbox.checked = coloredItems[index].active;
-
 
654
			});
-
 
655
	});
-
 
656
}
669
}
657
 
670
 
658
function getHotdealsForItems(catalogId, itemId, description, callback) {
671
function getHotdealsForItems(catalogId, itemId, description, callback) {
659
	bootBoxObj = {
672
	bootBoxObj = {
660
		size: "small",
673
		size: "small",
Line 662... Line 675...
662
		title: description,
675
		title: description,
663
		callback: callback,
676
		callback: callback,
664
		inputType: 'checkbox',
677
		inputType: 'checkbox',
665
	}
678
	}
666
	doGetAjaxRequestHandler(context + "/hotdealsitemsByCatalogId?catalogId="
679
	doGetAjaxRequestHandler(context + "/hotdealsitemsByCatalogId?catalogId="
667
		+ catalogId + "&itemId=" + itemId, function (response) {
680
		+ catalogId + "&itemId=" + itemId, function(response) {
668
		coloredItems = JSON.parse(response);
681
			coloredItems = JSON.parse(response);
669
		inputOptions = [{
682
			inputOptions = [{
670
			text: "All",
683
				text: "All",
671
			value: "0",
684
				value: "0",
672
			onclick: "toggleAll('itemIds')"
685
				onclick: "toggleAll('itemIds')"
673
		}];
686
			}];
674
		coloredItems.forEach(function (item) {
687
			coloredItems.forEach(function(item) {
675
			inputOptions.push({
688
				inputOptions.push({
676
				text: item.color,
689
					text: item.color,
677
				value: item.id,
690
					value: item.id,
678
				selected: item.hotDeals
691
					selected: item.hotDeals
-
 
692
				});
679
			});
693
			});
-
 
694
			bootBoxObj['inputOptions'] = inputOptions;
-
 
695
			promptObj = bootbox.prompt(bootBoxObj);
-
 
696
			promptObj.modal('show')
-
 
697
			$('.item-wrapper').find("input[type='checkbox']").slice(1).each(
-
 
698
				function(index, checkbox) {
-
 
699
					checkbox.checked = coloredItems[index].hotDeals;
-
 
700
				});
680
		});
701
		});
681
		bootBoxObj['inputOptions'] = inputOptions;
-
 
682
		promptObj = bootbox.prompt(bootBoxObj);
-
 
683
		promptObj.modal('show')
-
 
684
		$('.item-wrapper').find("input[type='checkbox']").slice(1).each(
-
 
685
			function (index, checkbox) {
-
 
686
				checkbox.checked = coloredItems[index].hotDeals;
-
 
687
			});
-
 
688
	});
-
 
689
}
702
}
690
 
703
 
691
$(document).on('change', ".item-wrapper input[type='checkbox']:first",
704
$(document).on('change', ".item-wrapper input[type='checkbox']:first",
692
	function () {
705
	function() {
693
		if (this.value == "0") {
706
		if (this.value == "0") {
694
			$(this).closest('.item-wrapper').find("input[type='checkbox']")
707
			$(this).closest('.item-wrapper').find("input[type='checkbox']")
695
				.slice(1).prop('checked', $(this).prop('checked'));
708
				.slice(1).prop('checked', $(this).prop('checked'));
696
		}
709
		}
697
	});
710
	});
698
 
711
 
699
function getItemAheadOptions(jqElement, anyColor, callback) {
712
function getItemAheadOptions(jqElement, anyColor, callback) {
700
	console.log(anyColor)
713
	console.log(anyColor)
701
	jqElement.typeahead('destroy').typeahead({
714
	jqElement.typeahead('destroy').typeahead({
702
		source: function (q, process) {
715
		source: function(q, process) {
703
			if (q.length >= 3) {
716
			if (q.length >= 3) {
704
				return $.ajax(context + "/item?anyColor=" + anyColor, {
717
				return $.ajax(context + "/item?anyColor=" + anyColor, {
705
					global: false,
718
					global: false,
706
					data: {
719
					data: {
707
						query: q
720
						query: q
708
					},
721
					},
709
					success: function (data) {
722
					success: function(data) {
710
						queryData = JSON.parse(data);
723
						queryData = JSON.parse(data);
711
						process(queryData);
724
						process(queryData);
712
					},
725
					},
713
				});
726
				});
714
			}
727
			}
715
		},
728
		},
716
		delay: 300,
729
		delay: 300,
717
		items: 20,
730
		items: 20,
718
		displayText: function (item) {
731
		displayText: function(item) {
719
			return item.itemDescription;
732
			return item.itemDescription;
720
		},
733
		},
721
		autoSelect: true,
734
		autoSelect: true,
722
		afterSelect: callback
735
		afterSelect: callback
723
	});
736
	});
724
}
737
}
725
 
738
 
726
 
739
 
727
function getImeiAheadOptions(jqElement, fofoId, callback) {
740
function getImeiAheadOptions(jqElement, fofoId, callback) {
728
	jqElement.typeahead('destroy').typeahead({
741
	jqElement.typeahead('destroy').typeahead({
729
		source: function (q, process) {
742
		source: function(q, process) {
730
			if (q.length >= 3) {
743
			if (q.length >= 3) {
731
				return $.ajax(context + "/imei?fofoId=" + fofoId, {
744
				return $.ajax(context + "/imei?fofoId=" + fofoId, {
732
					global: false,
745
					global: false,
733
					data: {
746
					data: {
734
						query: q
747
						query: q
735
					},
748
					},
736
					success: function (data) {
749
					success: function(data) {
737
						queryData = JSON.parse(data);
750
						queryData = JSON.parse(data);
738
						process(queryData);
751
						process(queryData);
739
					},
752
					},
740
				});
753
				});
741
			}
754
			}
742
		},
755
		},
743
		delay: 300,
756
		delay: 300,
744
		items: 20,
757
		items: 20,
745
		displayText: function (imei) {
758
		displayText: function(imei) {
746
			return imei;
759
			return imei;
747
		},
760
		},
748
		autoSelect: true,
761
		autoSelect: true,
749
		afterSelect: callback
762
		afterSelect: callback
750
	});
763
	});
751
}
764
}
752
 
765
 
753
 
766
 
754
function getEntityAheadOptions(jqElement, callback) {
767
function getEntityAheadOptions(jqElement, callback) {
755
	jqElement.typeahead('destroy').typeahead({
768
	jqElement.typeahead('destroy').typeahead({
756
		source: function (q, process) {
769
		source: function(q, process) {
757
			if (q.length >= 3) {
770
			if (q.length >= 3) {
758
				return $.ajax(context + "/entity", {
771
				return $.ajax(context + "/entity", {
759
					global: false,
772
					global: false,
760
					data: {
773
					data: {
761
						query: q
774
						query: q
762
					},
775
					},
763
					success: function (data) {
776
					success: function(data) {
764
						queryData = JSON.parse(data);
777
						queryData = JSON.parse(data);
765
						process(queryData);
778
						process(queryData);
766
					},
779
					},
767
				});
780
				});
768
			}
781
			}
769
		},
782
		},
770
		delay: 300,
783
		delay: 300,
771
		items: 30,
784
		items: 30,
772
		displayText: function (entity) {
785
		displayText: function(entity) {
773
			return entity.title_s + "(" + entity.catalogId_i + ")";
786
			return entity.title_s + "(" + entity.catalogId_i + ")";
774
		},
787
		},
775
		autoSelect: true,
788
		autoSelect: true,
776
		afterSelect: callback
789
		afterSelect: callback
777
	});
790
	});
778
}
791
}
779
 
792
 
780
function getPartnerAheadOptions(jqElement, callback) {
793
function getPartnerAheadOptions(jqElement, callback) {
781
	jqElement.typeahead('destroy').typeahead({
794
	jqElement.typeahead('destroy').typeahead({
782
		source: function (q, process) {
795
		source: function(q, process) {
783
			if (q.length >= 3) {
796
			if (q.length >= 3) {
784
				return $.ajax(context + "/partners", {
797
				return $.ajax(context + "/partners", {
785
					global: false,
798
					global: false,
786
					data: {
799
					data: {
787
						query: q
800
						query: q
788
					},
801
					},
789
					success: function (data) {
802
					success: function(data) {
790
						queryData = JSON.parse(data);
803
						queryData = JSON.parse(data);
791
						process(queryData);
804
						process(queryData);
792
					},
805
					},
793
				});
806
				});
794
			}
807
			}
795
		},
808
		},
796
		delay: 300,
809
		delay: 300,
797
		items: 20,
810
		items: 20,
798
		displayText: function (partner) {
811
		displayText: function(partner) {
799
			return partner.displayName;
812
			return partner.displayName;
800
		},
813
		},
801
		autoSelect: true,
814
		autoSelect: true,
802
		afterSelect: callback
815
		afterSelect: callback
803
	});
816
	});
804
}
817
}
805
 
818
 
806
function loadPriceDrop(domId) {
819
function loadPriceDrop(domId) {
807
	doGetAjaxRequestHandler(context + "/getItemDescription",
820
	doGetAjaxRequestHandler(context + "/getItemDescription",
808
		function (response) {
821
		function(response) {
809
			$('#' + domId).html(response);
822
			$('#' + domId).html(response);
810
		});
823
		});
811
}
824
}
812
 
825
 
813
$(document).on('click', ".price_drop", function () {
826
$(document).on('click', ".price_drop", function() {
814
	loadPriceDrop("main-content");
827
	loadPriceDrop("main-content");
815
});
828
});
816
 
829
 
817
 
830
 
818
$(document).on('click', ".closed_pricedrop", function () {
831
$(document).on('click', ".closed_pricedrop", function() {
819
	loadClosedPriceDrop("main-content");
832
	loadClosedPriceDrop("main-content");
820
});
833
});
821
 
834
 
822
function loadClosedPriceDrop(domId) {
835
function loadClosedPriceDrop(domId) {
823
	doGetAjaxRequestHandler(context + "/getClosedPricedropItemDescription",
836
	doGetAjaxRequestHandler(context + "/getClosedPricedropItemDescription",
824
		function (response) {
837
		function(response) {
825
			$('#' + domId).html(response);
838
			$('#' + domId).html(response);
826
		});
839
		});
827
}
840
}
828
 
841
 
829
function notifyTypeChange(messageType, $container) {
842
function notifyTypeChange(messageType, $container) {
830
	var messageQueryString = "?messageType=" + messageType;
843
	var messageQueryString = "?messageType=" + messageType;
831
	if (messageType == null) {
844
	if (messageType == null) {
832
		messageQueryString = "";
845
		messageQueryString = "";
833
	}
846
	}
834
	doGetAjaxRequestHandler(context + "/notifications" + messageQueryString, function (response) {
847
	doGetAjaxRequestHandler(context + "/notifications" + messageQueryString, function(response) {
835
		if ($container != null) {
848
		if ($container != null) {
836
			loaderDialogObj.one('hidden.bs.modal', function () {
849
			loaderDialogObj.one('hidden.bs.modal', function() {
837
				$container.popover({
850
				$container.popover({
838
					container: $container,
851
					container: $container,
839
					template: '<div class="popover popover1" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content popover2"></div></div>',
852
					template: '<div class="popover popover1" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content popover2"></div></div>',
840
					content: response,
853
					content: response,
841
					html: true,
854
					html: true,
842
					placement: "bottom",
855
					placement: "bottom",
843
					trigger: "manual",
856
					trigger: "manual",
844
					sanitize: false
857
					sanitize: false
845
				}).popover('show');
858
				}).popover('show');
846
				setTimeout(function () {
859
				setTimeout(function() {
847
					$container.focus().one('blur', function () {
860
					$container.focus().one('blur', function() {
848
						$container.popover('destroy');
861
						$container.popover('destroy');
849
					});
862
					});
850
				}, 100);
863
				}, 100);
851
			});
864
			});
852
		}
865
		}
Line 858... Line 871...
858
		documentName);
871
		documentName);
859
}
872
}
860
 
873
 
861
 
874
 
862
/* Create an array with the values of all the input boxes in a column */
875
/* Create an array with the values of all the input boxes in a column */
863
$.fn.dataTable.ext.order['dom-text'] = function (settings, col) {
876
$.fn.dataTable.ext.order['dom-text'] = function(settings, col) {
864
	return this.api().column(col, {order: 'index'}).nodes().map(function (td, i) {
877
	return this.api().column(col, { order: 'index' }).nodes().map(function(td, i) {
865
		return $('input', td).val();
878
		return $('input', td).val();
866
	});
879
	});
867
}
880
}
868
 
881
 
869
/* Create an array with the values of all the input boxes in a column, parsed as numbers */
882
/* Create an array with the values of all the input boxes in a column, parsed as numbers */
870
$.fn.dataTable.ext.order['dom-text-numeric'] = function (settings, col) {
883
$.fn.dataTable.ext.order['dom-text-numeric'] = function(settings, col) {
871
	return this.api().column(col, {order: 'index'}).nodes().map(function (td, i) {
884
	return this.api().column(col, { order: 'index' }).nodes().map(function(td, i) {
872
		return $('input', td).val() * 1;
885
		return $('input', td).val() * 1;
873
	});
886
	});
874
}
887
}
875
 
888
 
876
$.fn.dataTable.ext.order['dom-stock-numeric'] = function (settings, col) {
889
$.fn.dataTable.ext.order['dom-stock-numeric'] = function(settings, col) {
877
	return this.api().column(col, {order: 'index'}).nodes().map(function (td, i) {
890
	return this.api().column(col, { order: 'index' }).nodes().map(function(td, i) {
878
		return $(td).html().split("/")[0] * 1;
891
		return $(td).html().split("/")[0] * 1;
879
	});
892
	});
880
}
893
}
881
/* Create an array with the values of all the select options in a column */
894
/* Create an array with the values of all the select options in a column */
882
$.fn.dataTable.ext.order['dom-select'] = function (settings, col) {
895
$.fn.dataTable.ext.order['dom-select'] = function(settings, col) {
883
	return this.api().column(col, {order: 'index'}).nodes().map(function (td, i) {
896
	return this.api().column(col, { order: 'index' }).nodes().map(function(td, i) {
884
		return $('select', td).val();
897
		return $('select', td).val();
885
	});
898
	});
886
}
899
}
887
 
900
 
888
/* Create an array with the values of all the checkboxes in a column */
901
/* Create an array with the values of all the checkboxes in a column */
889
$.fn.dataTable.ext.order['dom-checkbox'] = function (settings, col) {
902
$.fn.dataTable.ext.order['dom-checkbox'] = function(settings, col) {
-
 
903
	return this.api().column(col, {
-
 
904
		order: 'index'
890
	return this.api().column(col, {order: 'index'}).nodes().map(function (td, i) {
905
	}).nodes().map(function(td, i) {
891
		return $('input', td).prop('checked') ? '1' : '0';
906
		return $('input', td).prop('checked') ? '1' : '0';
892
	});
907
	});
893
}
908
}
894
 
909
 
895
$.fn.dataTable.Api.register('sum()', function () {
910
$.fn.dataTable.Api.register('sum()', function() {
896
	return this.flatten().reduce(function (a, b) {
911
	return this.flatten().reduce(function(a, b) {
897
		if (typeof a === 'string') {
912
		if (typeof a === 'string') {
898
			a = a.replace(/[^\d.-]/g, '') * 1;
913
			a = a.replace(/[^\d.-]/g, '') * 1;
899
			a = isNaN(a) ? 0 : a;
914
			a = isNaN(a) ? 0 : a;
900
		}
915
		}
901
		if (typeof b === 'string') {
916
		if (typeof b === 'string') {