Subversion Repositories SmartDukaan

Rev

View as "text/plain" | Blame | Last modification | View Log | RSS feed

$(function() {

        $(document).on('click', ".monthly-target", function() {
                loadMonthlyTarget("main-content");
        });

        $(document).on('click', "#monthlytargetdownload", function() {

                window.location.href = context + "/downloadMonthlyTargetTemplate";
        })


        $(document).on('click', '#yearmonthtarget-submit', function() {
                let yearMonth = $("#yearmonthtarget").val();
                loadMonthWiseTarget('#main-content', yearMonth);

        });
        $(document).on('click', ".monthlyTargetUpload", function() {

                console.log("hello");
                if (confirm('Confirm upload ?')) {
                        var fileSelector = $(this)[0];
                        console.log(fileSelector)
                        if (fileSelector != undefined) {
                                var url = `${context}/monthlyTargetUploader`;
                                console.log(url);
                                var file = $("#monthlytargetfile")[0].files[0];
                                let fileInput = $(this);
                                console.log("file" + file);
                                console.log("fileInput" + fileInput);
                                doAjaxUploadRequestHandler(
                                        url,
                                        'POST',
                                        file, function(response) {

                                                console.log(response)

                                                if (response == true) {
                                                        alert("successfully uploaded");

                                                        loadMonthlyTarget("main-content");

                                                }


                                        });

                        }
                }

        });

});

function loadMonthlyTarget(domId) {
        doGetAjaxRequestHandler(context + "/monthlyTarget", function(response) {
                $('#' + domId).html(response);

        });

}

function loadMonthWiseTarget(domId, yearMonth) {

        console.log(yearMonth)

        doGetAjaxRequestHandler(`${context}/targetHistory?yearMonth=${yearMonth}`, function(response) {
                $('.monthly-target-table-container').html(response);
        });

}