Subversion Repositories SmartDukaan

Rev

Rev 27754 | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed

$(function() {

        $(document).on('click', ".punch-in-outs", function() {
                loadPunchInOuts("main-content");
                
        });

        $(document).on('click', "#punch-in-outs-paginated .next",
                                        function() {
                                                loadPaginatedNextItems('/getPaginatedPunchInOuts',
                                                                null, 'punch-in-outs-paginated',
                                                                'punch-in-outs-table', null);
                                                $(this).blur();
                                        });

        $(document).on('click', "#punch-in-outs-paginated .previous",
                                        function() {
                                                loadPaginatedPreviousItems('/getPaginatedPunchInOuts',
                                                                null, 'punch-in-outs-paginated',
                                                                'punch-in-outs-table', null);
                                                $(this).blur();
                                        });
});

function createPunchInOut(inOut) {
        if (confirm("Are you sure you want to do punch " + inOut)) {
                distance = undefined;
                if (navigator.geolocation) {
                        doPostAjaxRequestWithParamsHandler(context + "/createPunchInOut", {}, function(response) {
                                $('#main-content').html(response);
                                loadPunchInOuts("main-content")
                                alert("Punch " + inOut + " done successfully");
                                $('#punchInOutModal').modal('hide');
                        });
                /*      navigator.geolocation.getCurrentPosition(function(position) {
                                console.log(position)
                                if (typeof latitude == "undefined") {
                                        alert("Unable to fetch your device location");
                                } else {
                                        distance = getDistance(latitude, longitude, position.coords.latitude, position.coords.longitude);
                                        console.log(distance)
                                        if (distance < 500) {
                                                doPostAjaxRequestWithParamsHandler(context + "/createPunchInOut", {}, function(response) {
                                                        $('#main-content').html(response);
                                                        loadPunchInOuts("main-content")
                                                        alert("Punch " + inOut + " done successfully");
                                                        $('#punchInOutModal').modal('hide');
                                                });
                                        } else {
                                                alert("Punch " + inOut + " can only be done from store.");
                                                
                                        }
                                        
                                }
                        }, function(e) {console.log(e);});
                        */
                } else {
                        alert("Location cant be tracked. Please enable location");
                }
        }
        
}

function createPunchInOutForPromoter(inOut , userId){
        if (confirm("Are you sure you want to do punch " + inOut)) {
         
          console.log(userId)
          doPostAjaxRequestWithParamsHandler(context + "/createPunchInOutForPromoter?userId="+userId, {}, function(response) {
                        //$('#main-content').html(response);
                  alert("Punch " + inOut + " done successfully");
                        loadPunchInOuts("main-content")
                        $('#punchInOutModal').modal('hide');
                        
                });
        }
}

function loadPunchInOuts(domId) {
        doGetAjaxRequestHandler(context + "/getPunchInOuts", function(response) {
                $('#' + domId).html(response);  
                
        });

        
}

function loadPromoterPunchInOuts(domId){

}