Subversion Repositories SmartDukaan

Rev

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

$(function() {

        $(document).on('click', 'button.imeiactivationsupload',
                        function() {
                                debugger;
                                var fileSelector = $('#imeiactivations')[0];
                                if (fileSelector != undefined
                                                && fileSelector.files[0] != undefined) {
                                        if (confirm("Confirm Upload?")) {
                                                doAjaxUploadRequestHandler(context + "/imei/upload",
                                                                "POST", fileSelector.files[0], function(
                                                                                response) {
                                                                        if (response) {
                                                                                alert("Content updated successfully");
                                                                        }
                                                                });
                                        }
                                } else {
                                        alert("Please upload file!");
                                }
                                return false;
                        });

        $(document).on('click', ".focused_model",
                        function() {
                                loadModel("main-content");

                                $(document).on('click', "#focused-model-paginated .next",
                                                function() {
                                                        loadPaginatedNextItems('/getPaginatedFocusedModel',
                                                                        null, 'focused-model-paginated',
                                                                        'focused-model-table',
                                                                        'focused-model-container');

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

                                $(document).on('click', "#focused-model-paginated .previous",
                                                function() {

                                                        loadPaginatedPreviousItems(
                                                                        '/getPaginatedFocusedModel', null,
                                                                        'focused-model-paginated',
                                                                        'focused-model-table',
                                                                        'focused-model-container');

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

                        });

        $(document).on('click', ".add-model",
                        function() {
                                var catalogId = itemCatalogId;
                                var recommended = $('#recommended').val();
                                var minimumQty = $('#minimumQuantity').val();
                                var regionId = $('#regionType').val();

                                if (catalogId === null && recommended === ""
                                                && minimumQty === "") {
                                        alert("Field can't be empty");
                                        return;
                                }

                                if (recommended === "") {
                                        alert("recommended quantity is required");
                                        return;
                                }
                                if (minimumQty === "") {
                                        alert("minimumQty is required");
                                        return;
                                }
                                if (catalogId === null) {
                                        alert("please choose item");
                                        return;
                                }
                                var params = {
                                        "catalogId" : catalogId,
                                        "recommended" : recommended,
                                        "minimumQty" : minimumQty,
                                        "regionId" : regionId
                                }
                                if (confirm("Are you sure you want to add item!") == true) {
                                        doPostAjaxRequestWithParamsHandler(context
                                                        + "/focusedModel", params, function(response) {
                                                alert("Add Item Successfully");
                                                loadModel("main-content");
                                        });
                                }
                        });

        $(document).on('click', ".remove-model",
                                        function() {
                                                if (confirm("Are you sure you want to Remove the Item") == true) {
                                                        id = $(this).data('requestid');
                                                        console.log(id);
                                                        doDeleteAjaxRequestHandler(context
                                                                        + "/removeItem?id=" + id,
                                                                        function(response) {
                                                                                if (response == 'true') {
                                                                                        alert("successfully Removed");
                                                                                        loadModel("main-content");
                                                                                }

                                                                        });
                                                }

                                        });
});

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