Subversion Repositories SmartDukaan

Rev

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

$(function() {
        $(".promoter-info").live('click', function() {
                loadPromotor("main-content");
        });
        
        
        
        $("#promoter-info-paginated .next").live(
                        'click',
                        function() {
                                loadPaginatedNextItems('/getPaginatedPromoterInfo', null,
                                                'promoter-info-paginated', 'promoter-Info-table',
                                                'promoter-container');

                                $(this).blur();
                        });

        $("#promoter-info-paginated .previous").live(
                        'click',
                        function() {

                                loadPaginatedPreviousItems('/getPaginatedPromoterInfo', null,
                                                'promoter-info-paginated', 'promoter-Info-table',
                                                'promoter-container');

                                $(this).blur();
                        });

        var id = 0;
        $(".create-promoter").live(
                        'click',
                        function() {
                                var name = $('#promoterName').val();
                                var brand = $('#tag-listing-brands').val();
                                var email=$('#promoterEmail').val();
                                var mobile=$('#promoterMobile').val();
                                var retailerId = currentFofoId;
                                var portalAccess =$('#sd-Portal-Access').val();

                                console.log(id);

                                if (name === "" && brand === "" && email===""&&mobile ==="") {
                                        alert("Field can't be empty");
                                        return;
                                }

                                if (name === "") {
                                        alert("Promoter Name is required");
                                        return;
                                }
                                if (brand === "") {
                                        alert("Brand is required");
                                        return;
                                }
                                if (email === "") {
                                        alert("email is required");
                                        return;
                                }
                                if (mobile === "") {
                                        alert("mobile Number is required");
                                        return;
                                }
                                var promoterdetailData = {}
                                promoterdetailData['id'] = id;
                                promoterdetailData['name'] = $('#promoterName').val();
                                promoterdetailData['brand'] = $('#tag-listing-brands').val();
                                promoterdetailData['email'] = $('#promoterEmail').val();
                                promoterdetailData['mobile'] = $('#promoterMobile').val();
                                promoterdetailData['retailerId'] = currentFofoId;
                                promoterdetailData['sdPortalAccess']=$('#sd-Portal-Access').val();
                                console.log(promoterdetailData);
                                if (confirm("Are you sure you want to add Promoter!") == true) {
                                        doPostAjaxRequestWithJsonHandler(context
                                                        + "/createPromoter", JSON
                                                        .stringify(promoterdetailData), function(response) {
                                                if (response == 'true') {
                                                        alert("successfully Add");
                                                        loadPromotor("main-content");
                                                        id = 0;

                                                }
                                        });

                                        return false;
                                }
                        });

        $(".updatePromoterdetail").live('click', function() {
                id = $(this).data('requestid');
                name = $(this).data('name');
                brand = $(this).data('brand');
                partner = $(this).data('partner');
                email =$(this).data('email')
                mobile=$(this).data('mobile')
                console.log(name);
                console.log(brand);
                console.log(partner);
                $('#promoterName').val(name);
                $('#tag-listing-brands').val(brand);
                $('#promoterEmail').val(email);
                $('#promoterMobile').val(mobile);
                $('#promoterName').attr('readonly', true);
                $('#promoterMobile').attr('readonly', true);
                $('#promoterEmail').attr('readonly', true);
                $('#promoterMobile').attr('readonly', true);
                $('#tag-listing-brands').attr('disabled', true);

        });
        $(".removePromoter")
                        .live(
                                        'click',
                                        function() {
                                                id = $(this).data('requestid');
                                                if (confirm("Are you sure you want to remove Promoter Partner Store!") == true) {
                                                        doPostAjaxRequestHandler(context
                                                                        + "/removePromoterfromPartnerStore?id="
                                                                        + id, function(response) {
                                                                if (response == 'true') {
                                                                        alert("successfully remove");
                                                                        loadPromotor("main-content");
                                                                        id =0;

                                                                }
                                                        });

                                                        return false;
                                                }

                                        });
});

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