Subversion Repositories SmartDukaan

Rev

Rev 25587 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed

$(function() {

        $(".refferal").live('click', function() {

                loadRefferals("main-content");
        });

        $(".refferal-approve").live('click', function() {

                loadApproveRefferals("main-content");
        });

        $(".refferal-transferred").live('click', function() {
                loadTransferredRefferals("main-content");
        });

        $("#refferal-paginated .next").live(
                        'click',
                        function() {
                                var url = $('#url').val();
                                console.log(url);
                                if (url == "/getPaginatedRefferalsRequest") {
                                        loadPaginatedNextItems('/getPaginatedRefferalsRequest',
                                                        null, 'refferal-paginated', 'refferal-table',
                                                        'refferal-container');
                                } else if (url == "/getPaginatedTransferredRefferals") {
                                        loadPaginatedNextItems('/getPaginatedTransferredRefferals',
                                                        null, 'refferal-paginated', 'refferal-table',
                                                        'refferal-container');
                                }
                                $(this).blur();
                        });

        $("#refferal-paginated .previous").live(
                        'click',
                        function() {
                                var url = $('#url').val();
                                if (url == "/getPaginatedRefferalsRequest") {
                                        loadPaginatedPreviousItems('/getPaginatedRefferalsRequest',
                                                        null, 'refferal-paginated', 'refferal-table',
                                                        'refferal-container');
                                } else if (url == "/getPaginatedTransferredRefferals") {
                                        loadPaginatedNextItems('/getPaginatedTransferredRefferals',
                                                        null, 'refferal-paginated', 'refferal-table',
                                                        'refferal-container');
                                }
                                $(this).blur();
                        });

        $(".refferal-reject")
                        .live(
                                        'click',
                                        function() {
                                                if (confirm("Are you sure you want to Reject the refferal") == true) {

                                                        refferalId = $(this).data('requestid');
                                                        console.log(refferalId);
                                                        doPutAjaxRequestHandler(context
                                                                        + "/rejectRefferal?refferalId="
                                                                        + refferalId, function(response) {
                                                                if (response == 'true') {
                                                                        alert("successfully Rejected");
                                                                        loadRefferals("main-content");
                                                                }

                                                        });
                                                }
                                        });

        $(".reffral-approve")
                        .live(
                                        'click',
                                        function() {
                                                if (confirm("Are you sure you want to approve the refferal") == true) {

                                                        refferalId = $(this).data('requestid');
                                                        console.log(refferalId);
                                                        doPutAjaxRequestHandler(context
                                                                        + "/approveRefferal?refferalId="
                                                                        + refferalId, function(response) {
                                                                if (response == 'true') {
                                                                        alert("successfully Approved");
                                                                        loadRefferals("main-content");
                                                                }

                                                        });
                                                }
                                        });

        $(".fetchApproveRefferals").live(
                        'click',
                        function() {
                                currentFofoId = currentFofoId;
                                currentFofoEmail = currentFofoEmail;

                                console.log(currentFofoId);
                                console.log(currentFofoEmail);

                                doGetAjaxRequestHandler(context
                                                + "/getApprovedRefferals?refereeEmail="
                                                + currentFofoEmail, function(response) {
                                        $('.refferal-approve-info-container').html(response);
                                });

                        });

        $(".refferalAmountSubmit").live(
                        'click',
                        function() {
                                currentFofoId = currentFofoId;
                                currentFofoEmail = currentFofoEmail;
                                var count = $('#count').val();
                                var refferalAmount = $('#refferalAmount').val();
                                var month = $('#previousMonth').val();
                                $('#count').attr('readonly', true);
                                $('#refferalAmount').attr('readonly', true);
                                $('#previousMonth').attr('readonly', true);
                                
                                if (confirm("Are you sure you want add money!") == true) {
                                        doPostAjaxRequestHandler(context
                                                        + "/addMoneyToWallet?amount=" + refferalAmount
                                                        + "&count=" + count + "&refereeEmail="
                                                        + currentFofoEmail + "&month=" + month,
                                                        function(response) {
                                                                if (response == 'true') {
                                                                        alert("successfully submit");

                                                                        loadApproveRefferals("main-content");
                                                                }

                                                                return false;
                                                        });
                                }

                        });

        $(".oldRefferalAmountSubmit").live(
                        'click',
                        function() {
                                currentFofoId = currentFofoId;
                                currentFofoEmail = currentFofoEmail;
                                var count = $('#oldMonthCount').val();
                                var refferalAmount = $('#oldMonthrefferalAmount').val();
                                var month = $('#oldMonth').val();
                                $('#oldMonthCount').attr('readonly', true);
                                $('#oldMonthrefferalAmount').attr('readonly', true);
                                $('#oldMonth').attr('readonly', true);

                                if (confirm("Are you sure you want add money!") == true) {
                                        doPostAjaxRequestHandler(context
                                                        + "/addMoneyToWalletPreviousMonth?amount="
                                                        + refferalAmount + "&count=" + count
                                                        + "&refereeEmail=" + currentFofoEmail + "&month="
                                                        + month, function(response) {
                                                if (response == 'true') {
                                                        alert("successfully submit");

                                                        loadApproveRefferals("main-content");
                                                }

                                                return false;
                                        });
                                }

                        });

});

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

}

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

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

}