Subversion Repositories SmartDukaan

Rev

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

Rev 28870 Rev 30017
Line 38... Line 38...
38
	} else {
38
	} else {
39
		internalServerErrorAlert(jqxhr);
39
		internalServerErrorAlert(jqxhr);
40
	}
40
	}
41
});
41
});
42
 
42
 
43
$(document).ajaxComplete(function() {
43
$(document).ajaxComplete(function () {
44
	if (typeof loaderDialogObj != "undefined") {
44
	if (typeof loaderDialogObj != "undefined") {
45
		loaderDialogObj.modal('hide');
45
		loaderDialogObj.modal('hide');
46
		// $('div.modal-backdrop.fade').remove();
46
		// $('div.modal-backdrop.fade').remove();
47
	}
47
	}
48
});
48
});
-
 
49
 
49
function ajaxStartHandler() {
50
function ajaxStartHandler() {
50
	if (typeof loaderDialogObj != "undefined")
51
	if (typeof loaderDialogObj != "undefined")
51
		loaderDialogObj.modal('show');
52
		loaderDialogObj.modal('show');
52
	/*if (typeof isInvestmentOk != "undefined" && !isInvestmentOk
53
	/*if (typeof isInvestmentOk != "undefined" && !isInvestmentOk
53
		&& $('#order-details').length == 0) {
54
		&& $('#order-details').length == 0) {
Line 86... Line 87...
86
			var top = Math.floor(Math.random() * height) - dialogRect.top
87
			var top = Math.floor(Math.random() * height) - dialogRect.top
87
			$(dialogEl).css("left", left).css("top", top);
88
			$(dialogEl).css("left", left).css("top", top);
88
		});
89
		});
89
	}*/
90
	}*/
90
}
91
}
-
 
92
 
91
$(document).ajaxStart(ajaxStartHandler);
93
$(document).ajaxStart(ajaxStartHandler);
92
 
94
 
93
function doAjaxRequestWithParamsHandler(urlString, httpType, params,
95
function doAjaxRequestWithParamsHandler(urlString, httpType, params,
94
	callback_function) {
96
										callback_function) {
95
	$.ajax({
97
	$.ajax({
96
		url: urlString,
98
		url: urlString,
97
		async: true,
99
		async: true,
98
		cache: false,
100
		cache: false,
99
		data: params,
101
		data: params,
100
		// dataType:'json',
102
		// dataType:'json',
101
		type: httpType,
103
		type: httpType,
102
		success: function(response) {
104
		success: function (response) {
103
			callback_function(response);
105
			callback_function(response);
104
			$('.currency').each(function(index, ele) {
106
			$('.currency').each(function (index, ele) {
105
				if (!isNaN(parseInt($(ele).html()))) {
107
				if (!isNaN(parseInt($(ele).html()))) {
106
					$(ele).html(numberToComma($(ele).html()));
108
					$(ele).html(numberToComma($(ele).html()));
107
				}
109
				}
108
			});
110
			});
109
		}
111
		}
Line 113... Line 115...
113
function doGetAjaxRequestWithParamsHandler(urlString, params, callback_function) {
115
function doGetAjaxRequestWithParamsHandler(urlString, params, callback_function) {
114
	doAjaxRequestWithParamsHandler(urlString, "GET", params, callback_function);
116
	doAjaxRequestWithParamsHandler(urlString, "GET", params, callback_function);
115
}
117
}
116
 
118
 
117
function doPostAjaxRequestWithParamsHandler(urlString, params,
119
function doPostAjaxRequestWithParamsHandler(urlString, params,
118
	callback_function) {
120
											callback_function) {
119
	doAjaxRequestWithParamsHandler(urlString, "POST", params, callback_function);
121
	doAjaxRequestWithParamsHandler(urlString, "POST", params, callback_function);
120
}
122
}
121
 
123
 
122
function doAjaxRequestWithJsonHandler(urlString, httpType, json,
124
function doAjaxRequestWithJsonHandler(urlString, httpType, json,
123
	callback_function) {
125
									  callback_function) {
124
	$.ajax({
126
	$.ajax({
125
		url: urlString,
127
		url: urlString,
126
		async: true,
128
		async: true,
127
		cache: false,
129
		cache: false,
128
		processData: false,
130
		processData: false,
129
		data: json,
131
		data: json,
130
		contentType: 'application/json',
132
		contentType: 'application/json',
131
		type: httpType,
133
		type: httpType,
132
		success: function(response) {
134
		success: function (response) {
133
			// console.log("response"+JSON.stringify(data));
135
			// console.log("response"+JSON.stringify(data));
134
			callback_function(response);
136
			callback_function(response);
135
			$('.currency').each(function(index, ele) {
137
			$('.currency').each(function (index, ele) {
136
				if (!isNaN(parseInt($(ele).html()))) {
138
				if (!isNaN(parseInt($(ele).html()))) {
137
					$(ele).html(numberToComma($(ele).html()));
139
					$(ele).html(numberToComma($(ele).html()));
138
				}
140
				}
139
			});
141
			});
140
		}
142
		}
Line 153... Line 155...
153
	$.ajax({
155
	$.ajax({
154
		url: urlString,
156
		url: urlString,
155
		async: true,
157
		async: true,
156
		cache: false,
158
		cache: false,
157
		type: httpType,
159
		type: httpType,
158
		success: function(response) {
160
		success: function (response) {
159
			callback_function(response);
161
			callback_function(response);
160
			$('.currency').each(function(index, ele) {
162
			$('.currency').each(function (index, ele) {
161
				if (!isNaN(parseInt($(ele).html()))) {
163
				if (!isNaN(parseInt($(ele).html()))) {
162
					$(ele).html(numberToComma($(ele).html()));
164
					$(ele).html(numberToComma($(ele).html()));
163
				}
165
				}
164
			});
166
			});
165
		}
167
		}
Line 183... Line 185...
183
}
185
}
184
 
186
 
185
function doAjaxUploadRequest(urlString, httpType, file) {
187
function doAjaxUploadRequest(urlString, httpType, file) {
186
	var response;
188
	var response;
187
	doAjaxUploadRequestHandler(urlString, httpType, file,
189
	doAjaxUploadRequestHandler(urlString, httpType, file,
188
		function(ajaxResponse) {
190
		function (ajaxResponse) {
189
			response = ajaxResponse;
191
			response = ajaxResponse;
190
		});
192
		});
191
	return response;
193
	return response;
192
}
194
}
193
 
195
 
194
function doAjaxUploadRequestHandler(urlString, httpType, file,
196
function doAjaxUploadRequestHandler(urlString, httpType, file,
195
	callback_function) {
197
									callback_function) {
196
	var formData = new FormData();
198
	var formData = new FormData();
197
	formData.append("file", file);
199
	formData.append("file", file);
198
	$.ajax({
200
	$.ajax({
199
		url: urlString,
201
		url: urlString,
200
		type: httpType,
202
		type: httpType,
Line 203... Line 205...
203
		async: true,
205
		async: true,
204
		cache: false,
206
		cache: false,
205
		contentType: false,
207
		contentType: false,
206
		enctype: 'multipart/form-data',
208
		enctype: 'multipart/form-data',
207
		processData: false,
209
		processData: false,
208
		success: function(response) {
210
		success: function (response) {
209
			// console.log("response"+JSON.stringify(data));
211
			// console.log("response"+JSON.stringify(data));
210
			callback_function(response);
212
			callback_function(response);
211
		}
213
		}
212
	});
214
	});
213
}
215
}
-
 
216
 
214
function doAjaxUploadRequestJsonHandler(urlString, httpType, file, json,
217
function doAjaxUploadRequestJsonHandler(urlString, httpType, file, json,
215
	callback_function) {
218
										callback_function) {
216
	var formData = new FormData();
219
	var formData = new FormData();
217
	formData.append("file", file);
220
	formData.append("file", file);
218
	formData.append('json', new Blob([json]));
221
	formData.append('json', new Blob([json]));
219
	$.ajax({
222
	$.ajax({
220
		url: urlString,
223
		url: urlString,
221
		type: httpType,
224
		type: httpType,
222
		data: formData,
225
		data: formData,
223
		enctype: 'multipart/form-data',
226
		enctype: 'multipart/form-data',
224
		contentType: false,
227
		contentType: false,
225
		processData: false,
228
		processData: false,
226
		success: function(response) {
229
		success: function (response) {
227
			// console.log("response"+JSON.stringify(data));
230
			// console.log("response"+JSON.stringify(data));
228
			callback_function(response);
231
			callback_function(response);
229
		}
232
		}
230
	});
233
	});
231
}
234
}
232
 
235
 
233
function uploadDocument(file) {
236
function uploadDocument(file) {
234
	var url = context + '/document-upload';
237
	var url = context + '/document-upload';
235
	doAjaxUploadRequestHandler(url, 'POST', file, function(response) {
238
	doAjaxUploadRequestHandler(url, 'POST', file, function (response) {
236
		var documentId = response.response.document_id;
239
		var documentId = response.response.document_id;
237
		console.log("documentId : " + documentId);
240
		console.log("documentId : " + documentId);
238
		return documentId;
241
		return documentId;
239
	});
242
	});
240
}
243
}
Line 250... Line 253...
250
 
253
 
251
function doAjaxDownload(urlString, httpType, data, fileName) {
254
function doAjaxDownload(urlString, httpType, data, fileName) {
252
	xhttp = new XMLHttpRequest();
255
	xhttp = new XMLHttpRequest();
253
	if (typeof loaderDialogObj != "undefined")
256
	if (typeof loaderDialogObj != "undefined")
254
		loaderDialogObj.modal('show');
257
		loaderDialogObj.modal('show');
255
	xhttp.onreadystatechange = function() {
258
	xhttp.onreadystatechange = function () {
256
		var a;
259
		var a;
257
		if (xhttp.readyState === 2) {
260
		if (xhttp.readyState === 2) {
258
			if (xhttp.status == 200) {
261
			if (xhttp.status == 200) {
259
				xhttp.responseType = "blob";
262
				xhttp.responseType = "blob";
260
			} else {
263
			} else {
Line 295... Line 298...
295
	}
298
	}
296
	// You should set responseType as blob for binary responses
299
	// You should set responseType as blob for binary responses
297
	// xhttp.responseType = 'blob';
300
	// xhttp.responseType = 'blob';
298
	xhttp.send(data);
301
	xhttp.send(data);
299
}
302
}
-
 
303
 
300
function loadPaginatedCatalogNextItems(url, params, paginatedIdentifier,
304
function loadPaginatedCatalogNextItems(url, params, paginatedIdentifier,
301
	tableIdentifier, detailsContainerIdentifier) {
305
									   tableIdentifier, detailsContainerIdentifier) {
302
	var start = $("#" + paginatedIdentifier + " .start").text();
306
	var start = $("#" + paginatedIdentifier + " .start").text();
303
 
307
 
304
	var end = $("#" + paginatedIdentifier + " .end").text();
308
	var end = $("#" + paginatedIdentifier + " .end").text();
305
 
309
 
306
	url = context + url + "?offset=" + end;
310
	url = context + url + "?offset=" + end;
Line 312... Line 316...
312
				url = url + "&" + key + "=" + params[key];
316
				url = url + "&" + key + "=" + params[key];
313
			}
317
			}
314
		}
318
		}
315
	}
319
	}
316
 
320
 
317
	doGetAjaxRequestHandler(url, function(response) {
321
	doGetAjaxRequestHandler(url, function (response) {
318
		var size = $("#" + paginatedIdentifier + " .size").text();
322
		var size = $("#" + paginatedIdentifier + " .size").text();
319
		if ((parseInt(end) + 20) > parseInt(size)) {
323
		if ((parseInt(end) + 20) > parseInt(size)) {
320
			// console.log("(end + 10) > size == true");
324
			// console.log("(end + 10) > size == true");
321
			$("#" + paginatedIdentifier + " .end").text(size);
325
			$("#" + paginatedIdentifier + " .end").text(size);
322
		} else {
326
		} else {
Line 337... Line 341...
337
		}
341
		}
338
		$("#" + paginatedIdentifier + " .previous").prop('disabled', false);
342
		$("#" + paginatedIdentifier + " .previous").prop('disabled', false);
339
	});
343
	});
340
 
344
 
341
}
345
}
-
 
346
 
342
function loadPaginatedCatalogPreviousItem(url, params, paginatedIdentifier,
347
function loadPaginatedCatalogPreviousItem(url, params, paginatedIdentifier,
343
	tableIdentifier, detailsContainerIdentifier) {
348
										  tableIdentifier, detailsContainerIdentifier) {
344
	var start = $("#" + paginatedIdentifier + " .start").text();
349
	var start = $("#" + paginatedIdentifier + " .start").text();
345
	console.log("start" + start);
350
	console.log("start" + start);
346
	var end = $("#" + paginatedIdentifier + " .end").text();
351
	var end = $("#" + paginatedIdentifier + " .end").text();
347
	console.log("Startend" + end);
352
	console.log("Startend" + end);
348
	var size = $("#" + paginatedIdentifier + " .size").text();
353
	var size = $("#" + paginatedIdentifier + " .size").text();
Line 363... Line 368...
363
				url = url + "&" + key + "=" + params[key];
368
				url = url + "&" + key + "=" + params[key];
364
			}
369
			}
365
		}
370
		}
366
	}
371
	}
367
 
372
 
368
	doGetAjaxRequestHandler(url, function(response) {
373
	doGetAjaxRequestHandler(url, function (response) {
369
		$("#" + paginatedIdentifier + " .end").text(+end - +20);
374
		$("#" + paginatedIdentifier + " .end").text(+end - +20);
370
		$("#" + paginatedIdentifier + " .start").text(+start - +20);
375
		$("#" + paginatedIdentifier + " .start").text(+start - +20);
371
		$('#' + tableIdentifier).html(response);
376
		$('#' + tableIdentifier).html(response);
372
		if (detailsContainerIdentifier != null) {
377
		if (detailsContainerIdentifier != null) {
373
			$('#' + detailsContainerIdentifier).html('');
378
			$('#' + detailsContainerIdentifier).html('');
Line 379... Line 384...
379
	});
384
	});
380
 
385
 
381
}
386
}
382
 
387
 
383
function loadPaginatedNextItems(url, params, paginatedIdentifier,
388
function loadPaginatedNextItems(url, params, paginatedIdentifier,
384
	tableIdentifier, detailsContainerIdentifier) {
389
								tableIdentifier, detailsContainerIdentifier) {
385
	var start = $("#" + paginatedIdentifier + " .start").text();
390
	var start = $("#" + paginatedIdentifier + " .start").text();
386
	var end = $("#" + paginatedIdentifier + " .end").text();
391
	var end = $("#" + paginatedIdentifier + " .end").text();
387
	url = context + url + "?offset=" + end;
392
	url = context + url + "?offset=" + end;
388
 
393
 
389
	if (params != null) {
394
	if (params != null) {
Line 393... Line 398...
393
				url = url + "&" + key + "=" + params[key];
398
				url = url + "&" + key + "=" + params[key];
394
			}
399
			}
395
		}
400
		}
396
	}
401
	}
397
 
402
 
398
	doGetAjaxRequestHandler(url, function(response) {
403
	doGetAjaxRequestHandler(url, function (response) {
399
		var size = $("#" + paginatedIdentifier + " .size").text();
404
		var size = $("#" + paginatedIdentifier + " .size").text();
400
		if ((parseInt(end) + 10) > parseInt(size)) {
405
		if ((parseInt(end) + 10) > parseInt(size)) {
401
			console.log("(end + 10) > size == true");
406
			console.log("(end + 10) > size == true");
402
			$("#" + paginatedIdentifier + " .end").text(size);
407
			$("#" + paginatedIdentifier + " .end").text(size);
403
		} else {
408
		} else {
Line 419... Line 424...
419
	});
424
	});
420
 
425
 
421
}
426
}
422
 
427
 
423
function loadPaginatedPreviousItems(url, params, paginatedIdentifier,
428
function loadPaginatedPreviousItems(url, params, paginatedIdentifier,
424
	tableIdentifier, detailsContainerIdentifier) {
429
									tableIdentifier, detailsContainerIdentifier) {
425
	var start = $("#" + paginatedIdentifier + " .start").text();
430
	var start = $("#" + paginatedIdentifier + " .start").text();
426
	var end = $("#" + paginatedIdentifier + " .end").text();
431
	var end = $("#" + paginatedIdentifier + " .end").text();
427
	var size = $("#" + paginatedIdentifier + " .size").text();
432
	var size = $("#" + paginatedIdentifier + " .size").text();
428
	if (parseInt(end) == parseInt(size) && parseInt(end) % 10 != 0) {
433
	if (parseInt(end) == parseInt(size) && parseInt(end) % 10 != 0) {
429
		var mod = parseInt(end) % 10;
434
		var mod = parseInt(end) % 10;
Line 439... Line 444...
439
				url = url + "&" + key + "=" + params[key];
444
				url = url + "&" + key + "=" + params[key];
440
			}
445
			}
441
		}
446
		}
442
	}
447
	}
443
 
448
 
444
	doGetAjaxRequestHandler(url, function(response) {
449
	doGetAjaxRequestHandler(url, function (response) {
445
		$("#" + paginatedIdentifier + " .end").text(+end - +10);
450
		$("#" + paginatedIdentifier + " .end").text(+end - +10);
446
		$("#" + paginatedIdentifier + " .start").text(+start - +10);
451
		$("#" + paginatedIdentifier + " .start").text(+start - +10);
447
		$('#' + tableIdentifier).html(response);
452
		$('#' + tableIdentifier).html(response);
448
		if (detailsContainerIdentifier != null) {
453
		if (detailsContainerIdentifier != null) {
449
			$('#' + detailsContainerIdentifier).html('');
454
			$('#' + detailsContainerIdentifier).html('');
Line 479... Line 484...
479
	startMoment = start;
484
	startMoment = start;
480
	endMoment = end;
485
	endMoment = end;
481
	startDate = start.format(moment.HTML5_FMT.DATE);
486
	startDate = start.format(moment.HTML5_FMT.DATE);
482
	endDate = end.format(moment.HTML5_FMT.DATE);
487
	endDate = end.format(moment.HTML5_FMT.DATE);
483
}
488
}
-
 
489
 
484
// Custom formatters should be handled specifically at the controller side
490
// Custom formatters should be handled specifically at the controller side
485
function dateRangeCallback(start, end) {
491
function dateRangeCallback(start, end) {
486
	startMoment = start;
492
	startMoment = start;
487
	endMoment = end;
493
	endMoment = end;
488
	startDate = start.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
494
	startDate = start.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
Line 521... Line 527...
521
	};
527
	};
522
	if (showRanges) {
528
	if (showRanges) {
523
		rangedDatePicker['ranges'] = {
529
		rangedDatePicker['ranges'] = {
524
			'Today': [moment(), moment()],
530
			'Today': [moment(), moment()],
525
			'Yesterday': [moment().subtract(1, 'days'),
531
			'Yesterday': [moment().subtract(1, 'days'),
526
			moment().subtract(1, 'days')],
532
				moment().subtract(1, 'days')],
527
			'Last 7 Days': [moment().subtract(6, 'days'), moment()],
533
			'Last 7 Days': [moment().subtract(6, 'days'), moment()],
528
			'Last 30 Days': [moment().subtract(29, 'days'), moment()],
534
			'Last 30 Days': [moment().subtract(29, 'days'), moment()],
529
			'This Month': [moment().startOf('month'), moment().endOf('month')],
535
			'This Month': [moment().startOf('month'), moment().endOf('month')],
530
			'Last Month': [moment().subtract(1, 'month').startOf('month'),
536
			'Last Month': [moment().subtract(1, 'month').startOf('month'),
531
			moment()],
537
				moment()],
532
			'Last 3 Months': [moment().subtract(3, 'month').startOf('month'),
538
			'Last 3 Months': [moment().subtract(3, 'month').startOf('month'),
533
			moment()],
539
				moment()],
534
			'Last 6 Months': [moment().subtract(6, 'month').startOf('month'),
540
			'Last 6 Months': [moment().subtract(6, 'month').startOf('month'),
535
			moment()]
541
				moment()]
536
		}
542
		}
537
	}
543
	}
538
	return rangedDatePicker;
544
	return rangedDatePicker;
539
}
545
}
-
 
546
 
540
function showPosition(position) {
547
function showPosition(position) {
541
	if (typeof latitude == "undefined") {
548
	if (typeof latitude == "undefined") {
542
		var coords = {
549
		var coords = {
543
			latitude: position.coords.latitude,
550
			latitude: position.coords.latitude,
544
			longitude: position.coords.longitude
551
			longitude: position.coords.longitude
545
		}
552
		}
546
		doAjaxRequestWithJsonHandler('partner/location', 'PUT', JSON
553
		doAjaxRequestWithJsonHandler('partner/location', 'PUT', JSON
547
			.stringify(coords), function() {
554
			.stringify(coords), function () {
548
				latitude = position.coords.latitude;
555
			latitude = position.coords.latitude;
549
				longitude = position.coords.longitude;
556
			longitude = position.coords.longitude;
550
			});
557
		});
551
	}
558
	}
552
	// distance = getDistance(latitude, longitude, position.coords.latitude,
559
	// distance = getDistance(latitude, longitude, position.coords.latitude,
553
	// position.coords.longitude);
560
	// position.coords.longitude);
554
}
561
}
555
 
562
 
Line 561... Line 568...
561
		inputType: 'select',
568
		inputType: 'select',
562
		inputOptions: typeof inputOptions == "undefined" ? undefined
569
		inputOptions: typeof inputOptions == "undefined" ? undefined
563
			: inputOptions
570
			: inputOptions
564
	}
571
	}
565
	if (typeof inputOptions == "undefined") {
572
	if (typeof inputOptions == "undefined") {
566
		doGetAjaxRequestHandler(context + "/authorisedWarehouses", function(
573
		doGetAjaxRequestHandler(context + "/authorisedWarehouses", function (
567
			response) {
574
			response) {
568
			response = JSON.parse(response);
575
			response = JSON.parse(response);
569
			inputOptions = [];
576
			inputOptions = [];
570
			response.forEach(function(warehouse) {
577
			response.forEach(function (warehouse) {
571
				inputOptions.push({
578
				inputOptions.push({
572
					text: warehouse.name,
579
					text: warehouse.name,
573
					value: warehouse.id,
580
					value: warehouse.id,
574
				});
581
				});
575
			});
582
			});
Line 581... Line 588...
581
	} else {
588
	} else {
582
		bootbox.prompt(bootBoxObj);
589
		bootbox.prompt(bootBoxObj);
583
	}
590
	}
584
 
591
 
585
}
592
}
-
 
593
 
586
function getColorsForItems(catalogId, itemId, description, callback) {
594
function getColorsForItems(catalogId, itemId, description, callback) {
-
 
595
	colorCheckboxHandler(catalogId, itemId, description, callback);
-
 
596
}
-
 
597
 
-
 
598
function colorNumberHandler(catalogId, itemId, title, actionText, callback) {
-
 
599
	doGetAjaxRequestHandler(context + "/itemsByCatalogId?catalogId="
-
 
600
		+ catalogId + "&itemId=" + itemId, function (response) {
-
 
601
		let coloredItems = JSON.parse(response);
-
 
602
		let modalBody = [];
-
 
603
		coloredItems.forEach(function (item) {
-
 
604
			modalBody.push(`
-
 
605
                <div class="row">
-
 
606
                    <div class="col-sm-2">
-
 
607
                        ${item.color}
-
 
608
                    </div>
-
 
609
                    <div class="col-sm-2">
-
 
610
                            <input data-itemid="${item.id}" type="text" class="form-control" />
-
 
611
                    </div>
-
 
612
                </div>
-
 
613
            `);
-
 
614
		});
-
 
615
		let dialogBoxHtml = `<div class="modal modal" tabindex="-1" role="dialog">
-
 
616
                              <div class="modal-dialog" >
-
 
617
                                <div class="modal-content">
-
 
618
                                  <div class="modal-header">
-
 
619
                                    <h5 class="modal-title">${title}</h5>
-
 
620
                                  </div>
-
 
621
                                  <div class="modal-body">
-
 
622
                                        ${modalBody.join('')}
-
 
623
                                  </div>
-
 
624
                                  <div class="modal-footer">
-
 
625
                                    <button type="button" class="btn btn-primary number_dialog">${actionText}</button>
-
 
626
                                  </div>
-
 
627
                                </div>
-
 
628
                              </div>
-
 
629
                            </div>`;
-
 
630
		let $dialog = $(dialogBoxHtml);
-
 
631
		let modalObj = $dialog.modal('show');
-
 
632
		modalObj.on('hidden.bs.modal', function (e) {
-
 
633
			$dialog.remove();
-
 
634
		});
-
 
635
		$('button.number_dialog').on('click', function () {
-
 
636
			let itemQty = [];
-
 
637
			let anySelected = false;
-
 
638
			$(modalObj).find('.modal-body').find('input').each(function () {
-
 
639
				$input = $(this);
-
 
640
				if ($input.val() > 0) {
-
 
641
					itemQty.push({
-
 
642
						itemId: $input.data("itemid"),
-
 
643
						quantity: $input.val()
-
 
644
					});
-
 
645
					anySelected = true;
-
 
646
				}
-
 
647
			});
-
 
648
			if (anySelected) {
-
 
649
				$that = $(this);
-
 
650
				callback(itemQty, function () {
-
 
651
					$that.off('click');
-
 
652
					modalObj.hide();
-
 
653
				});
-
 
654
			} else {
-
 
655
				alert("Pls mention quantity");
-
 
656
			}
-
 
657
		});
-
 
658
	});
-
 
659
}
-
 
660
 
-
 
661
 
-
 
662
function colorCheckboxHandler() {
587
	bootBoxObj = {
663
	let bootBoxObj = {
588
		size: "small",
664
		size: "small",
589
		className: "item-wrapper",
665
		className: "item-wrapper",
590
		title: description,
666
		title: description,
591
		callback: callback,
667
		callback: callback,
592
		inputType: 'checkbox',
668
		inputType: 'checkbox',
593
	}
669
	}
594
	doGetAjaxRequestHandler(context + "/itemsByCatalogId?catalogId="
670
	doGetAjaxRequestHandler(context + "/itemsByCatalogId?catalogId="
595
		+ catalogId + "&itemId=" + itemId, function(response) {
671
		+ catalogId + "&itemId=" + itemId, function (response) {
596
			coloredItems = JSON.parse(response);
672
		coloredItems = JSON.parse(response);
597
			inputOptions = [{
673
		inputOptions = [{
598
				text: "All",
674
			text: "All",
599
				value: "0",
675
			value: "0",
600
				onclick: "toggleAll('itemIds')"
676
			onclick: "toggleAll('itemIds')"
601
			}];
677
		}];
602
			coloredItems.forEach(function(item) {
678
		coloredItems.forEach(function (item) {
603
				inputOptions.push({
679
			inputOptions.push({
604
					text: item.color,
680
				text: item.color,
605
					value: item.id,
681
				value: item.id,
606
					selected: item.active
682
				selected: item.active
607
				});
-
 
608
			});
683
			});
609
			bootBoxObj['inputOptions'] = inputOptions;
-
 
610
			promptObj = bootbox.prompt(bootBoxObj);
-
 
611
			promptObj.modal('show')
-
 
612
			$('.item-wrapper').find("input[type='checkbox']").slice(1).each(
-
 
613
				function(index, checkbox) {
-
 
614
					checkbox.checked = coloredItems[index].active;
-
 
615
				});
-
 
616
		});
684
		});
-
 
685
		bootBoxObj['inputOptions'] = inputOptions;
-
 
686
		promptObj = bootbox.prompt(bootBoxObj);
-
 
687
		promptObj.modal('show')
-
 
688
		$('.item-wrapper').find("input[type='checkbox']").slice(1).each(
-
 
689
			function (index, checkbox) {
-
 
690
				checkbox.checked = coloredItems[index].active;
-
 
691
			});
-
 
692
	});
617
}
693
}
618
 
694
 
619
 
-
 
620
function getHotdealsForItems(catalogId, itemId, description, callback) {
695
function getHotdealsForItems(catalogId, itemId, description, callback) {
621
	bootBoxObj = {
696
	bootBoxObj = {
622
		size: "small",
697
		size: "small",
623
		className: "item-wrapper",
698
		className: "item-wrapper",
624
		title: description,
699
		title: description,
625
		callback: callback,
700
		callback: callback,
626
		inputType: 'checkbox',
701
		inputType: 'checkbox',
627
	}
702
	}
628
	doGetAjaxRequestHandler(context + "/hotdealsitemsByCatalogId?catalogId="
703
	doGetAjaxRequestHandler(context + "/hotdealsitemsByCatalogId?catalogId="
629
		+ catalogId + "&itemId=" + itemId, function(response) {
704
		+ catalogId + "&itemId=" + itemId, function (response) {
630
			coloredItems = JSON.parse(response);
705
		coloredItems = JSON.parse(response);
631
			inputOptions = [{
706
		inputOptions = [{
632
				text: "All",
707
			text: "All",
633
				value: "0",
708
			value: "0",
634
				onclick: "toggleAll('itemIds')"
709
			onclick: "toggleAll('itemIds')"
635
			}];
710
		}];
636
			coloredItems.forEach(function(item) {
711
		coloredItems.forEach(function (item) {
637
				inputOptions.push({
712
			inputOptions.push({
638
					text: item.color,
713
				text: item.color,
639
					value: item.id,
714
				value: item.id,
640
					selected: item.hotDeals
715
				selected: item.hotDeals
641
				});
-
 
642
			});
716
			});
643
			bootBoxObj['inputOptions'] = inputOptions;
-
 
644
			promptObj = bootbox.prompt(bootBoxObj);
-
 
645
			promptObj.modal('show')
-
 
646
			$('.item-wrapper').find("input[type='checkbox']").slice(1).each(
-
 
647
				function(index, checkbox) {
-
 
648
					checkbox.checked = coloredItems[index].hotDeals;
-
 
649
				});
-
 
650
		});
717
		});
-
 
718
		bootBoxObj['inputOptions'] = inputOptions;
-
 
719
		promptObj = bootbox.prompt(bootBoxObj);
-
 
720
		promptObj.modal('show')
-
 
721
		$('.item-wrapper').find("input[type='checkbox']").slice(1).each(
-
 
722
			function (index, checkbox) {
-
 
723
				checkbox.checked = coloredItems[index].hotDeals;
-
 
724
			});
-
 
725
	});
651
}
726
}
-
 
727
 
652
$(document).on('change', ".item-wrapper input[type='checkbox']:first",
728
$(document).on('change', ".item-wrapper input[type='checkbox']:first",
653
	function() {
729
	function () {
654
		if (this.value == "0") {
730
		if (this.value == "0") {
655
			$(this).closest('.item-wrapper').find("input[type='checkbox']")
731
			$(this).closest('.item-wrapper').find("input[type='checkbox']")
656
				.slice(1).prop('checked', $(this).prop('checked'));
732
				.slice(1).prop('checked', $(this).prop('checked'));
657
		}
733
		}
658
	});
734
	});
-
 
735
 
659
function getItemAheadOptions(jqElement, anyColor, callback) {
736
function getItemAheadOptions(jqElement, anyColor, callback) {
660
	console.log(anyColor)
737
	console.log(anyColor)
661
	jqElement.typeahead('destroy').typeahead({
738
	jqElement.typeahead('destroy').typeahead({
662
		source: function(q, process) {
739
		source: function (q, process) {
663
			if (q.length >= 3) {
740
			if (q.length >= 3) {
664
				return $.ajax(context + "/item?anyColor=" + anyColor, {
741
				return $.ajax(context + "/item?anyColor=" + anyColor, {
665
					global: false,
742
					global: false,
666
					data: {
743
					data: {
667
						query: q
744
						query: q
668
					},
745
					},
669
					success: function(data) {
746
					success: function (data) {
670
						queryData = JSON.parse(data);
747
						queryData = JSON.parse(data);
671
						process(queryData);
748
						process(queryData);
672
					},
749
					},
673
				});
750
				});
674
			}
751
			}
675
		},
752
		},
676
		delay: 300,
753
		delay: 300,
677
		items: 20,
754
		items: 20,
678
		displayText: function(item) {
755
		displayText: function (item) {
679
			return item.itemDescription;
756
			return item.itemDescription;
680
		},
757
		},
681
		autoSelect: true,
758
		autoSelect: true,
682
		afterSelect: callback
759
		afterSelect: callback
683
	});
760
	});
684
}
761
}
685
 
762
 
686
 
763
 
687
function getImeiAheadOptions(jqElement, fofoId, callback) {
764
function getImeiAheadOptions(jqElement, fofoId, callback) {
688
	jqElement.typeahead('destroy').typeahead({
765
	jqElement.typeahead('destroy').typeahead({
689
		source: function(q, process) {
766
		source: function (q, process) {
690
			if (q.length >= 3) {
767
			if (q.length >= 3) {
691
				return $.ajax(context + "/imei?fofoId=" + fofoId, {
768
				return $.ajax(context + "/imei?fofoId=" + fofoId, {
692
					global: false,
769
					global: false,
693
					data: {
770
					data: {
694
						query: q
771
						query: q
695
					},
772
					},
696
					success: function(data) {
773
					success: function (data) {
697
						queryData = JSON.parse(data);
774
						queryData = JSON.parse(data);
698
						process(queryData);
775
						process(queryData);
699
					},
776
					},
700
				});
777
				});
701
			}
778
			}
702
		},
779
		},
703
		delay: 300,
780
		delay: 300,
704
		items: 20,
781
		items: 20,
705
		displayText: function(imei) {
782
		displayText: function (imei) {
706
			return imei;
783
			return imei;
707
		},
784
		},
708
		autoSelect: true,
785
		autoSelect: true,
709
		afterSelect: callback
786
		afterSelect: callback
710
	});
787
	});
711
}
788
}
712
 
789
 
713
 
790
 
714
 
-
 
715
function getEntityAheadOptions(jqElement, callback) {
791
function getEntityAheadOptions(jqElement, callback) {
716
	jqElement.typeahead('destroy').typeahead({
792
	jqElement.typeahead('destroy').typeahead({
717
		source: function(q, process) {
793
		source: function (q, process) {
718
			if (q.length >= 3) {
794
			if (q.length >= 3) {
719
				return $.ajax(context + "/entity", {
795
				return $.ajax(context + "/entity", {
720
					global: false,
796
					global: false,
721
					data: {
797
					data: {
722
						query: q
798
						query: q
723
					},
799
					},
724
					success: function(data) {
800
					success: function (data) {
725
						queryData = JSON.parse(data);
801
						queryData = JSON.parse(data);
726
						process(queryData);
802
						process(queryData);
727
					},
803
					},
728
				});
804
				});
729
			}
805
			}
730
		},
806
		},
731
		delay: 300,
807
		delay: 300,
732
		items: 20,
808
		items: 20,
733
		displayText: function(entity) {
809
		displayText: function (entity) {
734
			return entity.title_s + "(" + entity.catalogId_i + ")";
810
			return entity.title_s + "(" + entity.catalogId_i + ")";
735
		},
811
		},
736
		autoSelect: true,
812
		autoSelect: true,
737
		afterSelect: callback
813
		afterSelect: callback
738
	});
814
	});
739
}
815
}
-
 
816
 
740
function getPartnerAheadOptions(jqElement, callback) {
817
function getPartnerAheadOptions(jqElement, callback) {
741
	jqElement.typeahead('destroy').typeahead({
818
	jqElement.typeahead('destroy').typeahead({
742
		source: function(q, process) {
819
		source: function (q, process) {
743
			if (q.length >= 3) {
820
			if (q.length >= 3) {
744
				return $.ajax(context + "/partners", {
821
				return $.ajax(context + "/partners", {
745
					global: false,
822
					global: false,
746
					data: {
823
					data: {
747
						query: q
824
						query: q
748
					},
825
					},
749
					success: function(data) {
826
					success: function (data) {
750
						queryData = JSON.parse(data);
827
						queryData = JSON.parse(data);
751
						process(queryData);
828
						process(queryData);
752
					},
829
					},
753
				});
830
				});
754
			}
831
			}
755
		},
832
		},
756
		delay: 300,
833
		delay: 300,
757
		items: 20,
834
		items: 20,
758
		displayText: function(partner) {
835
		displayText: function (partner) {
759
			return partner.displayName;
836
			return partner.displayName;
760
		},
837
		},
761
		autoSelect: true,
838
		autoSelect: true,
762
		afterSelect: callback
839
		afterSelect: callback
763
	});
840
	});
764
}
841
}
765
 
842
 
766
function loadPriceDrop(domId) {
843
function loadPriceDrop(domId) {
767
	doGetAjaxRequestHandler(context + "/getItemDescription",
844
	doGetAjaxRequestHandler(context + "/getItemDescription",
768
		function(response) {
845
		function (response) {
769
			$('#' + domId).html(response);
846
			$('#' + domId).html(response);
770
		});
847
		});
771
}
848
}
-
 
849
 
772
$(document).on('click', ".price_drop", function() {
850
$(document).on('click', ".price_drop", function () {
773
	loadPriceDrop("main-content");
851
	loadPriceDrop("main-content");
774
});
852
});
775
 
853
 
776
 
854
 
777
$(document).on('click', ".closed_pricedrop", function() {
855
$(document).on('click', ".closed_pricedrop", function () {
778
	loadClosedPriceDrop("main-content");
856
	loadClosedPriceDrop("main-content");
779
});
857
});
780
 
858
 
781
function loadClosedPriceDrop(domId) {
859
function loadClosedPriceDrop(domId) {
782
	doGetAjaxRequestHandler(context + "/getClosedPricedropItemDescription",
860
	doGetAjaxRequestHandler(context + "/getClosedPricedropItemDescription",
783
		function(response) {
861
		function (response) {
784
			$('#' + domId).html(response);
862
			$('#' + domId).html(response);
785
		});
863
		});
786
}
864
}
787
 
865
 
788
function notifyTypeChange(messageType, $container) {
866
function notifyTypeChange(messageType, $container) {
789
	var messageQueryString = "?messageType=" + messageType;
867
	var messageQueryString = "?messageType=" + messageType;
790
	if (messageType == null) {
868
	if (messageType == null) {
791
		messageQueryString = "";
869
		messageQueryString = "";
792
	}
870
	}
793
	doGetAjaxRequestHandler(context + "/notifications" + messageQueryString, function(response) {
871
	doGetAjaxRequestHandler(context + "/notifications" + messageQueryString, function (response) {
794
		if ($container != null) {
872
		if ($container != null) {
795
			loaderDialogObj.one('hidden.bs.modal', function() {
873
			loaderDialogObj.one('hidden.bs.modal', function () {
796
				$container.popover({
874
				$container.popover({
797
					container: $container,
875
					container: $container,
798
					template: '<div class="popover popover1" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content popover2"></div></div>',
876
					template: '<div class="popover popover1" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content popover2"></div></div>',
799
					content: response,
877
					content: response,
800
					html: true,
878
					html: true,
801
					placement: "bottom",
879
					placement: "bottom",
802
					trigger: "manual",
880
					trigger: "manual",
803
					sanitize: false
881
					sanitize: false
804
				}).popover('show');
882
				}).popover('show');
805
				setTimeout(function() {
883
				setTimeout(function () {
806
					$container.focus().one('blur', function() {
884
					$container.focus().one('blur', function () {
807
						$container.popover('destroy');
885
						$container.popover('destroy');
808
					});
886
					});
809
				}, 100);
887
				}, 100);
810
			});
888
			});
811
		}
889
		}
Line 817... Line 895...
817
		documentName);
895
		documentName);
818
}
896
}
819
 
897
 
820
 
898
 
821
/* Create an array with the values of all the input boxes in a column */
899
/* Create an array with the values of all the input boxes in a column */
822
$.fn.dataTable.ext.order['dom-text'] = function(settings, col) {
900
$.fn.dataTable.ext.order['dom-text'] = function (settings, col) {
823
	return this.api().column(col, { order: 'index' }).nodes().map(function(td, i) {
901
	return this.api().column(col, {order: 'index'}).nodes().map(function (td, i) {
824
		return $('input', td).val();
902
		return $('input', td).val();
825
	});
903
	});
826
}
904
}
827
 
905
 
828
/* Create an array with the values of all the input boxes in a column, parsed as numbers */
906
/* Create an array with the values of all the input boxes in a column, parsed as numbers */
829
$.fn.dataTable.ext.order['dom-text-numeric'] = function(settings, col) {
907
$.fn.dataTable.ext.order['dom-text-numeric'] = function (settings, col) {
830
	return this.api().column(col, { order: 'index' }).nodes().map(function(td, i) {
908
	return this.api().column(col, {order: 'index'}).nodes().map(function (td, i) {
831
		return $('input', td).val() * 1;
909
		return $('input', td).val() * 1;
832
	});
910
	});
833
}
911
}
834
 
912
 
835
$.fn.dataTable.ext.order['dom-stock-numeric'] = function(settings, col) {
913
$.fn.dataTable.ext.order['dom-stock-numeric'] = function (settings, col) {
836
	return this.api().column(col, { order: 'index' }).nodes().map(function(td, i) {
914
	return this.api().column(col, {order: 'index'}).nodes().map(function (td, i) {
837
		return $(td).html().split("/")[0] * 1;
915
		return $(td).html().split("/")[0] * 1;
838
	});
916
	});
839
}
917
}
840
/* Create an array with the values of all the select options in a column */
918
/* Create an array with the values of all the select options in a column */
841
$.fn.dataTable.ext.order['dom-select'] = function(settings, col) {
919
$.fn.dataTable.ext.order['dom-select'] = function (settings, col) {
842
	return this.api().column(col, { order: 'index' }).nodes().map(function(td, i) {
920
	return this.api().column(col, {order: 'index'}).nodes().map(function (td, i) {
843
		return $('select', td).val();
921
		return $('select', td).val();
844
	});
922
	});
845
}
923
}
846
 
924
 
847
/* Create an array with the values of all the checkboxes in a column */
925
/* Create an array with the values of all the checkboxes in a column */
848
$.fn.dataTable.ext.order['dom-checkbox'] = function(settings, col) {
926
$.fn.dataTable.ext.order['dom-checkbox'] = function (settings, col) {
849
	return this.api().column(col, { order: 'index' }).nodes().map(function(td, i) {
927
	return this.api().column(col, {order: 'index'}).nodes().map(function (td, i) {
850
		return $('input', td).prop('checked') ? '1' : '0';
928
		return $('input', td).prop('checked') ? '1' : '0';
851
	});
929
	});
852
}
930
}
853
931