Subversion Repositories SmartDukaan

Rev

Rev 24159 | Rev 24608 | 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) {
24595 tejbeer 34
				console.log(position)
24077 amit.gupta 35
				if (typeof latitude == "undefined") {
24595 tejbeer 36
 
37
					console.log(latitude)
24077 amit.gupta 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);});
24072 amit.gupta 56
		} else {
57
			alert("Location cant be tracked. Please enable location");
23834 ashik.ali 58
		}
59
	}
24595 tejbeer 60
 
23834 ashik.ali 61
}
62
 
24159 tejbeer 63
function createPunchInOutForPromoter(inOut , userId){
64
	if (confirm("Are you sure you want to do punch " + inOut)) {
65
 
66
	  console.log(userId)
67
	  doPostAjaxRequestWithParamsHandler(context + "/createPunchInOutForPromoter?userId="+userId, {}, function(response) {
68
			//$('#main-content').html(response);
69
		  alert("Punch " + inOut + " done successfully");
70
			loadPunchInOuts("main-content")
24595 tejbeer 71
			$('#punchInOutModal').modal('hide');
24159 tejbeer 72
 
73
		});
74
	}
75
}
76
 
24072 amit.gupta 77
function loadPunchInOuts(domId) {
78
	doGetAjaxRequestHandler(context + "/getPunchInOuts", function(response) {
24159 tejbeer 79
		$('#' + domId).html(response);	
80
 
23834 ashik.ali 81
	});
24159 tejbeer 82
 
83
 
23834 ashik.ali 84
}
24159 tejbeer 85
 
86
function loadPromoterPunchInOuts(domId){
87
 
88
}