Subversion Repositories SmartDukaan

Rev

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

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