Subversion Repositories SmartDukaan

Rev

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

$(function () {

        $(document).on('click', 'button.imeiactivationsupload',
                function () {
                        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 obvRecommended = $('#obvrecommended').val();
                        var obvMinimumQty = $('#obvminimumQuantity').val();


                        var regionId = $('#regionType').val();


                        if (catalogId === null) {
                                alert("please choose item");
                                return;
                        }

                        if (recommended != "" && minimumQty == "") {
                                alert("please fill minimumQty qty");
                                return;
                        }

                        if (recommended == "" && minimumQty != "") {
                                alert("please fill recommended qty");
                                return;
                        }


                        if (obvRecommended != "" && obvMinimumQty == "") {
                                alert("please fill obvMinimum qty");
                                return;
                        }

                        if (obvRecommended == "" && obvMinimumQty != "") {
                                alert("please fill obvRecommended qty");
                                return;
                        }

                        if (regionId == "") {
                                alert("Select Region");
                                return;
                        }
                        var params = {
                                "catalogId": catalogId,
                                "recommended": recommended,
                                "minimumQty": minimumQty,
                                "obvrecommend": obvRecommended,
                                "obvminimum": obvMinimumQty,
                                "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);
        });
}