Subversion Repositories SmartDukaan

Rev

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
 
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
 
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) {
24608 tejbeer 33
			doPostAjaxRequestWithParamsHandler(context + "/createPunchInOut", {}, function(response) {
34
				$('#main-content').html(response);
35
				loadPunchInOuts("main-content")
36
				alert("Punch " + inOut + " done successfully");
37
				$('#punchInOutModal').modal('hide');
38
			});
39
		/*	navigator.geolocation.getCurrentPosition(function(position) {
24595 tejbeer 40
				console.log(position)
24077 amit.gupta 41
				if (typeof latitude == "undefined") {
42
					alert("Unable to fetch your device location");
43
				} else {
44
					distance = getDistance(latitude, longitude, position.coords.latitude, position.coords.longitude);
24595 tejbeer 45
					console.log(distance)
24077 amit.gupta 46
					if (distance < 500) {
47
						doPostAjaxRequestWithParamsHandler(context + "/createPunchInOut", {}, function(response) {
48
							$('#main-content').html(response);
24159 tejbeer 49
							loadPunchInOuts("main-content")
24077 amit.gupta 50
							alert("Punch " + inOut + " done successfully");
24595 tejbeer 51
							$('#punchInOutModal').modal('hide');
24077 amit.gupta 52
						});
53
					} else {
54
						alert("Punch " + inOut + " can only be done from store.");
24595 tejbeer 55
 
24077 amit.gupta 56
					}
57
 
58
				}
24595 tejbeer 59
			}, function(e) {console.log(e);});
24608 tejbeer 60
			*/
24072 amit.gupta 61
		} else {
62
			alert("Location cant be tracked. Please enable location");
23834 ashik.ali 63
		}
64
	}
24595 tejbeer 65
 
23834 ashik.ali 66
}
67
 
24159 tejbeer 68
function createPunchInOutForPromoter(inOut , userId){
69
	if (confirm("Are you sure you want to do punch " + inOut)) {
70
 
71
	  console.log(userId)
72
	  doPostAjaxRequestWithParamsHandler(context + "/createPunchInOutForPromoter?userId="+userId, {}, function(response) {
73
			//$('#main-content').html(response);
74
		  alert("Punch " + inOut + " done successfully");
75
			loadPunchInOuts("main-content")
24595 tejbeer 76
			$('#punchInOutModal').modal('hide');
24159 tejbeer 77
 
78
		});
79
	}
80
}
81
 
24072 amit.gupta 82
function loadPunchInOuts(domId) {
83
	doGetAjaxRequestHandler(context + "/getPunchInOuts", function(response) {
24159 tejbeer 84
		$('#' + domId).html(response);	
85
 
23834 ashik.ali 86
	});
24159 tejbeer 87
 
88
 
23834 ashik.ali 89
}
24159 tejbeer 90
 
91
function loadPromoterPunchInOuts(domId){
92
 
93
}