Subversion Repositories SmartDukaan

Rev

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

Rev 24072 Rev 24077
Line 27... Line 27...
27
 
27
 
28
function createPunchInOut(inOut) {
28
function createPunchInOut(inOut) {
29
	if (confirm("Are you sure you want to do punch " + inOut)) {
29
	if (confirm("Are you sure you want to do punch " + inOut)) {
30
		distance = undefined;
30
		distance = undefined;
31
		if (navigator.geolocation) {
31
		if (navigator.geolocation) {
32
			navigator.geolocation
-
 
33
					.getCurrentPosition(function(position) {
32
			navigator.geolocation.getCurrentPosition(function(position) {
34
						alert("Unable to fetch your device location");
-
 
35
						if (typeof latitude == "undefined") {
33
				if (typeof latitude == "undefined") {
36
							distance = getDistance(latitude, longitude,
34
					alert("Unable to fetch your device location");
37
									position.coords.latitude,
35
				} else {
38
									position.coords.longitude);
36
					distance = getDistance(latitude, longitude, position.coords.latitude, position.coords.longitude);
39
							if (distance < 500) {
37
					if (distance < 500) {
40
								doPostAjaxRequestWithParamsHandler(context
38
						doPostAjaxRequestWithParamsHandler(context + "/createPunchInOut", {}, function(response) {
41
										+ "/createPunchInOut", {}, function(
-
 
42
										response) {
-
 
43
									$('#main-content').html(response);
39
							$('#main-content').html(response);
44
									alert("Punch " + inOut
-
 
45
											+ " done successfully");
40
							alert("Punch " + inOut + " done successfully");
46
								});
41
						});
47
							} else {
42
					} else {
48
								alert("Punch " + inOut
-
 
49
										+ " can only be done from store.");
43
						alert("Punch " + inOut + " can only be done from store.");
50
							}
44
					}
51
						} else {
-
 
52
							alert("Location cant be tracked. Please enable location");
-
 
53
							return;
45
					
54
						}
46
				}
55
					});
47
			});
56
		} else {
48
		} else {
57
			alert("Location cant be tracked. Please enable location");
49
			alert("Location cant be tracked. Please enable location");
58
		}
50
		}
59
	}
51
	}
60
}
52
}