Subversion Repositories SmartDukaan

Rev

Rev 27754 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
23834 ashik.ali 1
$(function() {
24072 amit.gupta 2
 
27754 amit.gupta 3
	$(document).on('click', ".punch-in-outs", function() {
23834 ashik.ali 4
		loadPunchInOuts("main-content");
24159 tejbeer 5
 
23834 ashik.ali 6
	});
24072 amit.gupta 7
 
27755 amit.gupta 8
	$(document).on('click', "#punch-in-outs-paginated .next",
24072 amit.gupta 9
					function() {
10
						loadPaginatedNextItems('/getPaginatedPunchInOuts',
11
								null, 'punch-in-outs-paginated',
12
								'punch-in-outs-table', null);
13
						$(this).blur();
14
					});
15
 
27755 amit.gupta 16
	$(document).on('click', "#punch-in-outs-paginated .previous",
24072 amit.gupta 17
					function() {
18
						loadPaginatedPreviousItems('/getPaginatedPunchInOuts',
19
								null, 'punch-in-outs-paginated',
20
								'punch-in-outs-table', null);
21
						$(this).blur();
22
					});
23834 ashik.ali 23
});
24
 
24056 amit.gupta 25
function createPunchInOut(inOut) {
24072 amit.gupta 26
	if (confirm("Are you sure you want to do punch " + inOut)) {
24056 amit.gupta 27
		distance = undefined;
28
		if (navigator.geolocation) {
24608 tejbeer 29
			doPostAjaxRequestWithParamsHandler(context + "/createPunchInOut", {}, function(response) {
30
				$('#main-content').html(response);
31
				loadPunchInOuts("main-content")
32
				alert("Punch " + inOut + " done successfully");
33
				$('#punchInOutModal').modal('hide');
34
			});
35
		/*	navigator.geolocation.getCurrentPosition(function(position) {
24595 tejbeer 36
				console.log(position)
24077 amit.gupta 37
				if (typeof latitude == "undefined") {
38
					alert("Unable to fetch your device location");
39
				} else {
40
					distance = getDistance(latitude, longitude, position.coords.latitude, position.coords.longitude);
24595 tejbeer 41
					console.log(distance)
24077 amit.gupta 42
					if (distance < 500) {
43
						doPostAjaxRequestWithParamsHandler(context + "/createPunchInOut", {}, function(response) {
44
							$('#main-content').html(response);
24159 tejbeer 45
							loadPunchInOuts("main-content")
24077 amit.gupta 46
							alert("Punch " + inOut + " done successfully");
24595 tejbeer 47
							$('#punchInOutModal').modal('hide');
24077 amit.gupta 48
						});
49
					} else {
50
						alert("Punch " + inOut + " can only be done from store.");
24595 tejbeer 51
 
24077 amit.gupta 52
					}
53
 
54
				}
24595 tejbeer 55
			}, function(e) {console.log(e);});
24608 tejbeer 56
			*/
24072 amit.gupta 57
		} else {
58
			alert("Location cant be tracked. Please enable location");
23834 ashik.ali 59
		}
60
	}
24595 tejbeer 61
 
23834 ashik.ali 62
}
63
 
24159 tejbeer 64
function createPunchInOutForPromoter(inOut , userId){
65
	if (confirm("Are you sure you want to do punch " + inOut)) {
66
 
67
	  console.log(userId)
68
	  doPostAjaxRequestWithParamsHandler(context + "/createPunchInOutForPromoter?userId="+userId, {}, function(response) {
69
			//$('#main-content').html(response);
70
		  alert("Punch " + inOut + " done successfully");
71
			loadPunchInOuts("main-content")
24595 tejbeer 72
			$('#punchInOutModal').modal('hide');
24159 tejbeer 73
 
74
		});
75
	}
76
}
77
 
24072 amit.gupta 78
function loadPunchInOuts(domId) {
79
	doGetAjaxRequestHandler(context + "/getPunchInOuts", function(response) {
24159 tejbeer 80
		$('#' + domId).html(response);	
81
 
23834 ashik.ali 82
	});
24159 tejbeer 83
 
84
 
23834 ashik.ali 85
}
24159 tejbeer 86
 
87
function loadPromoterPunchInOuts(domId){
88
 
89
}