Subversion Repositories SmartDukaan

Rev

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

Rev 24159 Rev 24595
Line 29... Line 29...
29
function createPunchInOut(inOut) {
29
function createPunchInOut(inOut) {
30
	if (confirm("Are you sure you want to do punch " + inOut)) {
30
	if (confirm("Are you sure you want to do punch " + inOut)) {
31
		distance = undefined;
31
		distance = undefined;
32
		if (navigator.geolocation) {
32
		if (navigator.geolocation) {
33
			navigator.geolocation.getCurrentPosition(function(position) {
33
			navigator.geolocation.getCurrentPosition(function(position) {
-
 
34
				console.log(position)
34
				if (typeof latitude == "undefined") {
35
				if (typeof latitude == "undefined") {
-
 
36
					
-
 
37
					console.log(latitude)
35
					alert("Unable to fetch your device location");
38
					alert("Unable to fetch your device location");
36
				} else {
39
				} else {
37
					distance = getDistance(latitude, longitude, position.coords.latitude, position.coords.longitude);
40
					distance = getDistance(latitude, longitude, position.coords.latitude, position.coords.longitude);
-
 
41
					console.log(distance)
38
					if (distance < 500) {
42
					if (distance < 500) {
39
						doPostAjaxRequestWithParamsHandler(context + "/createPunchInOut", {}, function(response) {
43
						doPostAjaxRequestWithParamsHandler(context + "/createPunchInOut", {}, function(response) {
40
							$('#main-content').html(response);
44
							$('#main-content').html(response);
41
							loadPunchInOuts("main-content")
45
							loadPunchInOuts("main-content")
42
							alert("Punch " + inOut + " done successfully");
46
							alert("Punch " + inOut + " done successfully");
-
 
47
							$('#punchInOutModal').modal('hide');
43
						});
48
						});
44
					} else {
49
					} else {
45
						alert("Punch " + inOut + " can only be done from store.");
50
						alert("Punch " + inOut + " can only be done from store.");
-
 
51
						
46
					}
52
					}
47
					
53
					
48
				}
54
				}
49
			});
55
			}, function(e) {console.log(e);});
50
		} else {
56
		} else {
51
			alert("Location cant be tracked. Please enable location");
57
			alert("Location cant be tracked. Please enable location");
52
		}
58
		}
53
	}
59
	}
-
 
60
	
54
}
61
}
55
 
62
 
56
function createPunchInOutForPromoter(inOut , userId){
63
function createPunchInOutForPromoter(inOut , userId){
57
	if (confirm("Are you sure you want to do punch " + inOut)) {
64
	if (confirm("Are you sure you want to do punch " + inOut)) {
58
	 
65
	 
59
	  console.log(userId)
66
	  console.log(userId)
60
	  doPostAjaxRequestWithParamsHandler(context + "/createPunchInOutForPromoter?userId="+userId, {}, function(response) {
67
	  doPostAjaxRequestWithParamsHandler(context + "/createPunchInOutForPromoter?userId="+userId, {}, function(response) {
61
			//$('#main-content').html(response);
68
			//$('#main-content').html(response);
62
		  alert("Punch " + inOut + " done successfully");
69
		  alert("Punch " + inOut + " done successfully");
63
			loadPunchInOuts("main-content")
70
			loadPunchInOuts("main-content")
-
 
71
			$('#punchInOutModal').modal('hide');
64
			
72
			
65
		});
73
		});
66
	}
74
	}
67
}
75
}
68
 
76