system.controller("FeedbackIssueController", FeedbackIssueController);

function FeedbackIssueController($scope, $http, $rootScope, Upload, $window) {

    this.__proto__ = new BaseController($scope, $http, $rootScope, Upload);

    $scope.report = {};

    $scope.initialize = function () {

        $("#date-from").datepicker({
            dateFormat: "yy-mm-dd",
        }).datepicker("setDate", "-1w");

        $("#date-to").datepicker({
            dateFormat: "yy-mm-dd",
        }).datepicker("setDate", "+0");

        $scope.feedReport();
    };

    $scope.feedReport = function () 
    {
        let dateFrom = $("#date-from").val();
        let dateTo = $("#date-to").val();

        dateFrom = new Date(dateFrom);
        dateFrom.setHours(0, 0, 0, 0);
        dateTo = new Date(dateTo)
        dateTo.setHours(23, 59, 59, 0);

        dateFrom = dateFrom.getTime() / 1000;
        dateTo = dateTo.getTime() / 1000;

        let apiUrl = `/print-suppliers/report/feedback-issues/get-report?dateFrom=${dateFrom}&dateTo=${dateTo}`;

        $http.get(apiUrl).then(function (response) {

            $scope.report = response.data;

        }, function (error) {
            console.warn(error);
        });
    }


    $scope.initialize();
}