Subversion Repositories SmartDukaan

Rev

Rev 24440 | Rev 24649 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
24440 amit.gupta 1
var logosmapping = {
24595 tejbeer 2
	mobile_insurance_providers : {
3
		"0" : context + '/resources/images/icons/provider-logos/iffco.png',
4
		"1" : context + '/resources/images/icons/provider-logos/icici.jpg',
5
		"2" : context + '/resources/images/icons/provider-logos/tataaig.png'
6
	}
24440 amit.gupta 7
}
24595 tejbeer 8
function badRequestAlert(response) {
22956 ashik.ali 9
	console.log(response.responseText);
10
	var errorObject = JSON.parse(response.responseText);
11
	errorObject = errorObject.response;
24595 tejbeer 12
	bootbox.alert('Bad Request\n' + 'rejectedType : '
13
			+ errorObject.rejectedType + '\n' + 'rejectedValue : '
14
			+ errorObject.rejectedValue + '\n' + 'message : '
15
			+ errorObject.message);
22956 ashik.ali 16
}
24595 tejbeer 17
 
18
function internalServerErrorAlert(response) {
22956 ashik.ali 19
	console.log(response.responseText);
20
	var errorObject = JSON.parse(response.responseText);
21
	errorObject = errorObject.response;
24595 tejbeer 22
	bootbox.alert('Internal Server Error\n' + 'rejectedType : '
23
			+ errorObject.rejectedType + '\n' + 'rejectedValue : '
24
			+ errorObject.rejectedValue + '\n' + 'message : '
25
			+ errorObject.message);
22956 ashik.ali 26
}
27
 
24595 tejbeer 28
$(document).ajaxError(function(event, jqxhr, settings, thrownError) {
29
	if (typeof loaderDialogObj != "undefined")
24271 amit.gupta 30
		loaderDialogObj.modal('hide');
24595 tejbeer 31
	if (jqxhr.status == 400) {
23872 amit.gupta 32
		// $('#error-prompt-model').modal();
24595 tejbeer 33
		badRequestAlert(jqxhr);
34
	} else {
22956 ashik.ali 35
		internalServerErrorAlert(jqxhr);
36
	}
37
});
38
 
24595 tejbeer 39
$(document).ajaxComplete(function() {
40
	if (typeof loaderDialogObj != "undefined")
24271 amit.gupta 41
		loaderDialogObj.modal('hide');
23946 amit.gupta 42
});
43
 
24595 tejbeer 44
$(document)
45
		.ajaxStart(
46
				function() {
47
					if (typeof loaderDialogObj != "undefined")
48
						loaderDialogObj.modal('show');
49
					if (typeof isInvestmentOk != "undefined" && !isInvestmentOk
50
							&& $('#order-details').length == 0) {
51
						var investmentDialog = bootbox
52
								.dialog({
53
									title : '<h3	class="text-danger">ATTENTION!! ORDERING THROUGH APP MAY BE BLOCKED DUE TO LOW INVESTMENTS!</h3>',
54
									message : "<h3>Dear Partner, your investments are low by "
55
											+ shortPercentage
56
											+ "%</h3>"
57
											+ "<dl>"
58
											+ "<dt>Investment Should be</dt><dd>- "
59
											+ minimumInvestmentAmount
60
											+ "</dd>"
61
											+ "<dt>Total Invested Amount</dt><dd>-"
62
											+ totalInvestedAmount
63
											+ "</dd>"
64
											+ '<dt>Investment Amount Short By</dt><dd class="text-danger lead">-  '
65
											+ shortAmount
66
											+ '</dd></dl>'
67
											+ '<pre class="text-danger" style="font-size:18px;"><strong>To unblock your Billing, please \nadd Rs.'
68
											+ minAmountToBeAdded
69
											+ ' to wallet immediately.</strong></pre>',
70
									buttons : {
71
										cancel : {
72
											label : "OK",
73
											className : 'btn-primary'
74
										}
75
									},
76
								});
77
						investmentDialog.on('shown.bs.modal',
78
								function() {
79
									var dialogEl = investmentDialog
80
											.find('.modal-content')[0];
81
									var dialogRect = dialogEl
82
											.getBoundingClientRect();
83
									var height = window.innerHeight
84
											- dialogRect.height;
85
									var width = window.innerWidth
86
											- dialogRect.width;
87
									var left = Math
88
											.floor(Math.random() * width)
89
											- dialogRect.left
90
									var top = Math
91
											.floor(Math.random() * height)
92
											- dialogRect.top
93
									$(dialogEl).css("left", left).css("top",
94
											top);
95
								});
96
					}
97
				});
98
 
99
function doAjaxRequestWithParamsHandler(urlString, httpType, params,
100
		callback_function) {
101
	$.ajax({
102
		url : urlString,
103
		async : true,
104
		cache : false,
105
		data : params,
106
		// dataType:'json',
107
		type : httpType,
108
		success : function(response) {
109
			callback_function(response);
110
			$('.currency').each(function(index, ele) {
111
				if (!isNaN(parseInt($(ele).html()))) {
112
					$(ele).html(numberToComma($(ele).html()));
113
				}
23918 amit.gupta 114
			});
115
		}
116
	});
23193 ashik.ali 117
}
118
 
24595 tejbeer 119
function doGetAjaxRequestWithParamsHandler(urlString, params, callback_function) {
23500 ashik.ali 120
	doAjaxRequestWithParamsHandler(urlString, "GET", params, callback_function);
121
}
122
 
24595 tejbeer 123
function doPostAjaxRequestWithParamsHandler(urlString, params,
124
		callback_function) {
23500 ashik.ali 125
	doAjaxRequestWithParamsHandler(urlString, "POST", params, callback_function);
126
}
127
 
24595 tejbeer 128
function doAjaxRequestWithJsonHandler(urlString, httpType, json,
129
		callback_function) {
23032 ashik.ali 130
	$.ajax({
24595 tejbeer 131
		url : urlString,
132
		async : true,
133
		cache : false,
134
		processData : false,
135
		data : json,
136
		contentType : 'application/json',
137
		type : httpType,
138
		success : function(response) {
139
			// console.log("response"+JSON.stringify(data));
140
			callback_function(response);
141
			$('.currency').each(function(index, ele) {
142
				if (!isNaN(parseInt($(ele).html()))) {
143
					$(ele).html(numberToComma($(ele).html()));
144
				}
145
			});
146
		}
23032 ashik.ali 147
	});
148
}
149
 
24595 tejbeer 150
function doPostAjaxRequestWithJsonHandler(urlString, json, callback_function) {
23500 ashik.ali 151
	doAjaxRequestWithJsonHandler(urlString, "POST", json, callback_function);
152
}
23032 ashik.ali 153
 
24595 tejbeer 154
function doPutAjaxRequestWithJsonHandler(urlString, json, callback_function) {
23500 ashik.ali 155
	doAjaxRequestWithJsonHandler(urlString, "PUT", json, callback_function);
156
}
157
 
24595 tejbeer 158
function doAjaxRequestHandler(urlString, httpType, callback_function) {
22982 ashik.ali 159
	$.ajax({
24595 tejbeer 160
		url : urlString,
161
		async : true,
162
		cache : false,
163
		type : httpType,
164
		success : function(response) {
165
			callback_function(response);
166
			$('.currency').each(function(index, ele) {
167
				if (!isNaN(parseInt($(ele).html()))) {
168
					$(ele).html(numberToComma($(ele).html()));
169
				}
170
			});
171
		}
22982 ashik.ali 172
	});
173
}
174
 
24595 tejbeer 175
function doGetAjaxRequestHandler(urlString, callback_function) {
23500 ashik.ali 176
	doAjaxRequestHandler(urlString, "GET", callback_function);
177
}
178
 
24595 tejbeer 179
function doPutAjaxRequestHandler(urlString, callback_function) {
23500 ashik.ali 180
	doAjaxRequestHandler(urlString, "PUT", callback_function);
181
}
182
 
24595 tejbeer 183
function doPostAjaxRequestHandler(urlString, callback_function) {
23629 ashik.ali 184
	doAjaxRequestHandler(urlString, "POST", callback_function);
185
}
186
 
24595 tejbeer 187
function doDeleteAjaxRequestHandler(urlString, callback_function) {
23783 ashik.ali 188
	doAjaxRequestHandler(urlString, "DELETE", callback_function);
189
}
190
 
24595 tejbeer 191
function doAjaxUploadRequest(urlString, httpType, file) {
23347 ashik.ali 192
	var response;
24595 tejbeer 193
	doAjaxUploadRequestHandler(urlString, httpType, file,
194
			function(ajaxResponse) {
195
				response = ajaxResponse;
196
			});
23347 ashik.ali 197
	return response;
198
}
199
 
24595 tejbeer 200
function doAjaxUploadRequestHandler(urlString, httpType, file,
201
		callback_function) {
22982 ashik.ali 202
	var formData = new FormData();
203
	formData.append("file", file);
204
	$.ajax({
24595 tejbeer 205
		url : urlString,
206
		type : httpType,
207
		data : formData,
208
		dataType : 'json',
209
		async : true,
210
		cache : false,
211
		contentType : false,
212
		enctype : 'multipart/form-data',
213
		processData : false,
214
		success : function(response) {
215
			// console.log("response"+JSON.stringify(data));
216
			callback_function(response);
217
		}
22982 ashik.ali 218
	});
219
}
24595 tejbeer 220
function doAjaxUploadRequestJsonHandler(urlString, httpType, file, json,
221
		callback_function) {
24171 govind 222
	var formData = new FormData();
223
	formData.append("file", file);
24595 tejbeer 224
	formData.append('json', new Blob([ json ]));
24171 govind 225
	$.ajax({
24595 tejbeer 226
		url : urlString,
227
		type : httpType,
228
		data : formData,
229
		enctype : 'multipart/form-data',
230
		contentType : false,
231
		processData : false,
232
		success : function(response) {
233
			// console.log("response"+JSON.stringify(data));
234
			callback_function(response);
235
		}
24171 govind 236
	});
237
}
22982 ashik.ali 238
 
24595 tejbeer 239
function uploadDocument(file) {
240
	var url = webApiScheme + '://' + webApiHost + ':' + webApiPort + webApiRoot
241
			+ '/document-upload';
242
	doAjaxUploadRequestHandler(url, 'POST', file, function(response) {
243
		var documentId = response.response.document_id;
244
		console.log("documentId : " + documentId);
23377 ashik.ali 245
		return documentId;
246
	});
23347 ashik.ali 247
}
248
 
24595 tejbeer 249
function doAjaxGetDownload(urlString, fileName) {
250
	console.log("fileName : " + fileName);
23343 ashik.ali 251
	doAjaxDownload(urlString, "GET", null, fileName);
22982 ashik.ali 252
}
253
 
24595 tejbeer 254
function doAjaxPostDownload(urlString, data, fileName) {
23343 ashik.ali 255
	doAjaxDownload(urlString, "POST", data, fileName);
21627 kshitij.so 256
}
257
 
24595 tejbeer 258
function doAjaxDownload(urlString, httpType, data, fileName) {
22488 ashik.ali 259
	xhttp = new XMLHttpRequest();
260
	xhttp.onreadystatechange = function() {
24595 tejbeer 261
		var a;
262
		if (xhttp.readyState === 2) {
263
			if (xhttp.status == 200) {
264
				xhttp.responseType = "blob";
265
			} else {
266
				xhttp.responseType = "text";
267
			}
268
		} else if (xhttp.readyState === 4 && xhttp.status === 200) {
269
			// Trick for making downloadable link
270
			a = document.createElement('a');
271
			a.href = window.URL.createObjectURL(xhttp.response);
272
			// Give filename you wish to download
273
			a.download = fileName;
274
			a.style.display = 'none';
275
			document.body.appendChild(a);
276
			a.click();
277
		} else if (xhttp.readyState == 4 && xhttp.status === 400) {
278
			badRequestAlert(xhttp);
279
		} else if (xhttp.readyState == 4 && xhttp.status === 500) {
280
			internalServerErrorAlert(xhttp);
281
		}
22488 ashik.ali 282
	};
283
	// Post data to URL which handles post request
23343 ashik.ali 284
	xhttp.open(httpType, urlString);
24595 tejbeer 285
	if (httpType == "POST") {
23343 ashik.ali 286
		xhttp.setRequestHeader("Content-Type", "application/json");
287
	}
22488 ashik.ali 288
	// You should set responseType as blob for binary responses
23872 amit.gupta 289
	// xhttp.responseType = 'blob';
22488 ashik.ali 290
	xhttp.send(data);
23405 amit.gupta 291
}
292
 
24595 tejbeer 293
function loadPaginatedNextItems(url, params, paginatedIdentifier,
294
		tableIdentifier, detailsContainerIdentifier) {
295
	var start = $("#" + paginatedIdentifier + " .start").text();
296
	var end = $("#" + paginatedIdentifier + " .end").text();
23629 ashik.ali 297
	url = context + url + "?offset=" + end;
24595 tejbeer 298
 
299
	if (params != null) {
300
		for ( var key in params) {
23629 ashik.ali 301
			if (params.hasOwnProperty(key)) {
23872 amit.gupta 302
				// console.log(key + " -> " + p[key]);
24595 tejbeer 303
				url = url + "&" + key + "=" + params[key];
23629 ashik.ali 304
			}
305
		}
306
	}
24595 tejbeer 307
 
308
	doGetAjaxRequestHandler(url, function(response) {
309
		var size = $("#" + paginatedIdentifier + " .size").text();
310
		if ((parseInt(end) + 10) > parseInt(size)) {
23629 ashik.ali 311
			console.log("(end + 10) > size == true");
24595 tejbeer 312
			$("#" + paginatedIdentifier + " .end").text(size);
313
		} else {
23629 ashik.ali 314
			console.log("(end + 10) > size == false");
24595 tejbeer 315
			$("#" + paginatedIdentifier + " .end").text(+end + +10);
23629 ashik.ali 316
		}
24595 tejbeer 317
		$("#" + paginatedIdentifier + " .start").text(+start + +10);
318
		var last = $("#" + paginatedIdentifier + " .end").text();
319
		var temp = $("#" + paginatedIdentifier + " .size").text();
320
		if (parseInt(last) >= parseInt(temp)) {
321
			$("#" + paginatedIdentifier + " .next").prop('disabled', true);
23872 amit.gupta 322
			// $( "#good-inventory-paginated .end" ).text(temp);
23629 ashik.ali 323
		}
24595 tejbeer 324
		$('#' + tableIdentifier).html(response);
325
		if (detailsContainerIdentifier != null) {
326
			$('#' + detailsContainerIdentifier).html('');
23629 ashik.ali 327
		}
24595 tejbeer 328
		$("#" + paginatedIdentifier + " .previous").prop('disabled', false);
23629 ashik.ali 329
	});
24595 tejbeer 330
 
23629 ashik.ali 331
}
23405 amit.gupta 332
 
24595 tejbeer 333
function loadPaginatedPreviousItems(url, params, paginatedIdentifier,
334
		tableIdentifier, detailsContainerIdentifier) {
335
	var start = $("#" + paginatedIdentifier + " .start").text();
336
	var end = $("#" + paginatedIdentifier + " .end").text();
337
	var size = $("#" + paginatedIdentifier + " .size").text();
338
	if (parseInt(end) == parseInt(size) && parseInt(end) % 10 != 0) {
23629 ashik.ali 339
		var mod = parseInt(end) % 10;
24595 tejbeer 340
		end = parseInt(end) + (10 - mod);
23629 ashik.ali 341
	}
342
	var pre = end - 20;
24595 tejbeer 343
 
23629 ashik.ali 344
	url = context + url + "?offset=" + pre;
24595 tejbeer 345
 
346
	if (params != null) {
347
		for ( var key in params) {
23629 ashik.ali 348
			if (params.hasOwnProperty(key)) {
24595 tejbeer 349
				url = url + "&" + key + "=" + params[key];
23629 ashik.ali 350
			}
351
		}
352
	}
24595 tejbeer 353
 
354
	doGetAjaxRequestHandler(url, function(response) {
355
		$("#" + paginatedIdentifier + " .end").text(+end - +10);
356
		$("#" + paginatedIdentifier + " .start").text(+start - +10);
357
		$('#' + tableIdentifier).html(response);
358
		if (detailsContainerIdentifier != null) {
359
			$('#' + detailsContainerIdentifier).html('');
23629 ashik.ali 360
		}
24595 tejbeer 361
		$("#" + paginatedIdentifier + " .next").prop('disabled', false);
362
		if (parseInt(pre) == 0) {
363
			$("#" + paginatedIdentifier + " .previous").prop('disabled', true);
23629 ashik.ali 364
		}
24595 tejbeer 365
	});
366
 
23629 ashik.ali 367
}
368
 
23405 amit.gupta 369
function numberToComma(x) {
24595 tejbeer 370
	x = parseInt(x);
371
	x = x.toString();
372
	var lastThree = x.substring(x.length - 3);
373
	var otherNumbers = x.substring(0, x.length - 3);
374
	if (otherNumbers != '')
375
		lastThree = ',' + lastThree;
23405 amit.gupta 376
	return otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g, ",") + lastThree;
23786 amit.gupta 377
}
23870 amit.gupta 378
 
379
function dateRangeCallback(start, end) {
23886 amit.gupta 380
	startMoment = start;
381
	endMoment = end;
382
	startDate = start.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
383
	endDate = end.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
23872 amit.gupta 384
}
385
 
24595 tejbeer 386
function getSingleDatePicker() {
387
	var singleDatePicker = {
388
		"todayHighlight" : true,
389
		"startDate" : startMoment || moment(),
390
		"autoclose" : true,
391
		"autoUpdateInput" : true,
392
		"singleDatePicker" : true,
393
		"locale" : {
394
			'format' : 'DD/MM/YYYY'
395
		}
396
	};
23872 amit.gupta 397
	return singleDatePicker;
23886 amit.gupta 398
}
399
 
24595 tejbeer 400
function getRangedDatePicker(showRanges) {
401
	if (typeof showRanges == "undefined") {
23886 amit.gupta 402
		showRanges = false;
403
	}
24595 tejbeer 404
	var rangedDatePicker = {
405
		"todayHighlight" : true,
406
		"opens" : "right",
407
		"startDate" : startMoment || moment(),
408
		"endDate" : endMoment || moment(),
409
		"autoclose" : true,
410
		"alwaysShowCalendars" : false,
411
		"autoUpdateInput" : true,
412
		"locale" : {
413
			'format' : 'DD/MM/YYYY'
414
		}
23886 amit.gupta 415
	};
24595 tejbeer 416
	if (showRanges) {
417
		rangedDatePicker['ranges'] = {
418
			'Today' : [ moment(), moment() ],
419
			'Yesterday' : [ moment().subtract(1, 'days'),
420
					moment().subtract(1, 'days') ],
421
			'Last 7 Days' : [ moment().subtract(6, 'days'), moment() ],
422
			'Last 30 Days' : [ moment().subtract(29, 'days'), moment() ],
423
			'This Month' : [ moment().startOf('month'), moment().endOf('month') ],
424
			'Last Month' : [ moment().subtract(1, 'month').startOf('month'),
425
					moment().subtract(1, 'month').endOf('month') ]
426
		}
23886 amit.gupta 427
	}
428
	return rangedDatePicker;
23892 amit.gupta 429
}
23946 amit.gupta 430
function showPosition(position) {
24595 tejbeer 431
	if (typeof latitude == "undefined") {
432
		var coords = {
433
			latitude : position.coords.latitude,
434
			longitude : position.coords.longitude
435
		}
436
		doAjaxRequestWithJsonHandler('partner/location', 'PUT', JSON
437
				.stringify(coords), function() {
24016 amit.gupta 438
			latitude = position.coords.latitude;
439
			longitude = position.coords.longitude;
24052 amit.gupta 440
		});
441
	}
24176 amit.gupta 442
	// distance = getDistance(latitude, longitude, position.coords.latitude,
443
	// position.coords.longitude);
24168 amit.gupta 444
}
445
 
24595 tejbeer 446
function getAuthorisedWarehouses(callback) {
447
	bootBoxObj = {
448
		size : "small",
449
		title : "Choose Warehouse",
450
		callback : callback,
451
		inputType : 'select',
452
		inputOptions : typeof inputOptions == "undefined" ? undefined
453
				: inputOptions
24168 amit.gupta 454
	}
24595 tejbeer 455
	if (typeof inputOptions == "undefined") {
456
		doGetAjaxRequestHandler(context + "/authorisedWarehouses", function(
457
				response) {
24168 amit.gupta 458
			response = JSON.parse(response);
459
			inputOptions = [];
24595 tejbeer 460
			response.forEach(function(warehouse) {
24168 amit.gupta 461
				inputOptions.push({
24595 tejbeer 462
					text : warehouse.name,
463
					value : warehouse.id,
24168 amit.gupta 464
				});
465
			});
466
			bootBoxObj['inputOptions'] = inputOptions;
467
			bootbox.prompt(bootBoxObj);
468
		});
24595 tejbeer 469
	} else if (inputOptions.length == 1) {
24168 amit.gupta 470
		callback(inputOptions[0].warehouse.id);
24595 tejbeer 471
	} else {
24168 amit.gupta 472
		bootbox.prompt(bootBoxObj);
473
	}
24595 tejbeer 474
 
24176 amit.gupta 475
}
24410 amit.gupta 476
function getColorsForItems(catalogId, itemId, description, callback) {
24595 tejbeer 477
	bootBoxObj = {
478
		size : "small",
479
		className : "item-wrapper",
480
		title : description,
481
		callback : callback,
482
		inputType : 'checkbox',
24349 amit.gupta 483
	}
24595 tejbeer 484
	doGetAjaxRequestHandler(context + "/itemsByCatalogId?catalogId="
485
			+ catalogId + "&itemId=" + itemId, function(response) {
24406 amit.gupta 486
		coloredItems = JSON.parse(response);
24595 tejbeer 487
		inputOptions = [ {
488
			text : "All",
489
			value : "0",
490
			onclick : "toggleAll('itemIds')"
491
		} ];
492
		coloredItems.forEach(function(item) {
24406 amit.gupta 493
			inputOptions.push({
24595 tejbeer 494
				text : item.color,
495
				value : item.id,
496
				selected : item.active
24349 amit.gupta 497
			});
498
		});
24406 amit.gupta 499
		bootBoxObj['inputOptions'] = inputOptions;
24349 amit.gupta 500
		bootbox.prompt(bootBoxObj);
24595 tejbeer 501
		$('.item-wrapper').find('input[type="checkbox"]').slice(1).each(
502
				function(index, checkbox) {
503
					checkbox.checked = coloredItems[index].active;
504
				});
24406 amit.gupta 505
	});
506
}
24595 tejbeer 507
$(".item-wrapper").find("input[type='checkbox']:first").live(
508
		'change',
509
		function() {
510
			if (this.value == "0") {
511
				$(this).closest('.item-wrapper').find("input[type='checkbox']")
512
						.slice(1).prop('checked', $(this).prop('checked'));
513
			}
514
		});
24176 amit.gupta 515
function getItemAheadOptions(jqElement, callback) {
516
	jqElement.typeahead('destroy').typeahead({
24595 tejbeer 517
		source : function(q, process) {
518
			if (q.length >= 3) {
519
				return $.ajax(context + "/item", {
520
					global : false,
521
					data : {
522
						query : q
523
					},
524
					success : function(data) {
24191 amit.gupta 525
						queryData = JSON.parse(data);
526
						process(queryData);
24176 amit.gupta 527
					},
528
				});
24378 amit.gupta 529
			}
24176 amit.gupta 530
		},
24595 tejbeer 531
		delay : 400,
532
		items : 20,
533
		displayText : function(item) {
534
			return item.itemDescription;
535
		},
536
		autoSelect : true,
537
		afterSelect : callback
24176 amit.gupta 538
	});
539
}
24349 amit.gupta 540
function getPartnerAheadOptions(jqElement, callback) {
541
	jqElement.typeahead('destroy').typeahead({
24595 tejbeer 542
		source : function(q, process) {
543
			if (q.length >= 3) {
544
				return $.ajax(context + "/partners", {
545
					global : false,
546
					data : {
547
						query : q
548
					},
549
					success : function(data) {
24349 amit.gupta 550
						queryData = JSON.parse(data);
551
						process(queryData);
552
					},
553
				});
554
			}
555
		},
24595 tejbeer 556
		delay : 300,
557
		items : 20,
558
		displayText : function(partner) {
559
			return partner.displayName;
560
		},
561
		autoSelect : true,
562
		afterSelect : callback
24349 amit.gupta 563
	});
564
}
24406 amit.gupta 565
 
24595 tejbeer 566
function loadPriceDrop(domId) {
567
	doGetAjaxRequestHandler(context + "/getItemDescription",
568
			function(response) {
569
				$('#' + domId).html(response);
570
			});
24406 amit.gupta 571
}
572
$(".price_drop").live('click', function() {
573
	loadPriceDrop("main-content");
24595 tejbeer 574
});
575
var stopInterval;
576
$(document).ready(function(){
577
 
578
	 stopInterval = setInterval(showAttendanceModal, 10000);
579
 
580
});
581
function showAttendanceModal() {
582
	var today = new Date().getTime();
583
	if ($.cookie("punchIn") == undefined) {
584
		document.cookie = "punchIn=" + today;
585
	}
586
	if (today >= parseInt($.cookie("punchIn"))) {
587
		doGetAjaxRequestHandler(context + "/getPunchInOutForModel", function(
588
				response) {
589
		      if(response == 'true'){
590
		    	  $('#punchInOutModal').modal('hide');
591
		    	  clearInterval(stopInterval);
592
		    	  console.log("hide");
593
		      }else{
594
		    	  $("#punch-in-out-model").html(response);
595
					$('#punchInOutModal').modal('show');
596
					var time = today + 30 * 60 * 1000
597
					document.cookie = "punchIn=" + time; 
598
					console.log("show");
599
		      }
600
 
601
 
602
 
603
		});	}
604
}