function initializeReportsPackaging() {
    initializePartnerTypeahead($('#SupplierId').attr('dataUrl'), $('#SupplierId'), $("#SupplierId"), function (item) {
        $("#SupplierId").val(item.value);
        $.fn.dataTable.reload($dataTable);
        return { selected: true, value: item.id };
    });

    initializeIdentBasicTypeahead($('#IdentFilterSearch').attr('dataUrl'), $('#IdentFilterSearch'), $('#IdentFilterSearch'), { item: $("#ItemLoc").val(), name: $("#NameLoc").val() }, null, function (item) {
        $("#ProductPlaceholder").val(item.id);
        $("#IdentFilterSearch").val(item.id);
        $.fn.dataTable.reload($dataTable);
        return { selected: true, value: item.id };
    });

    $("#downloadPackaging").show();

    var getSearchData = function () {
        return {
            DateFrom: reformatDate($("#DateFrom").val()),
            DateTo: reformatDate($("#DateTo").val()),
            Type: $("#Type option:selected").val(),
            SupplierId: $("#SupplierId").val(),
            Ident: $("#ProductPlaceholder").val()
        };
    };

    $dataTable = $('#grid-data');
    $dataTable.DataTable({
        paginate: false,
        info: false,
        ordering: false,
        scroller: false,
        ajax: {
            url: $dataTable.attr('data-url'),
            data: function (d) {
                d.DateFrom = reformatDate($("#DateFrom").val());
                d.DateTo = reformatDate($("#DateTo").val());
                d.Type = $("#Type option:selected").val();
                d.SupplierId = $("#SupplierId").val();
                d.Ident = $("#ProductPlaceholder").val();
            }
        },
        columns: [
            { data: "Type" },
            { data: "Quantity", render: $.fn.dataTable.render.number('.', ',', $("#DefaultDecimalPlacesQuantity").val()), className: 'dt-body-right' },
            { data: "EndUserQuantity", render: $.fn.dataTable.render.number('.', ',', $("#DefaultDecimalPlacesQuantity").val()), className: 'dt-body-right' },
            { data: "TotalWeight", render: $.fn.dataTable.render.number('.', ',', $("#DefaultDecimalPlacesQuantity").val()), className: 'dt-body-right' }
        ]
    });

    $('.datepicker').datepicker()
        .on('click', function (e) {
            $(this).select();
        }).on('changeDate', function () {
            $(this).datepicker('hide');
            $.fn.dataTable.reload($dataTable);
        });

    $("#downloadPackagingReport").on("click", function () {
        var href = $(this).attr("href");
        var params = getSearchData();

        var form = $('<form id="exportForm" method="POST" style="display:none;"></form>');
        form.attr("action", $("#packagingReportUrl").val());
        var form_data = new FormData();

        for (var key in params) {
            var input = $("<input>")
                .attr("name", key).val(params[key]);
            form.append(input);
        }

        $("body").append(form);
        form.submit();
        $("#exportForm").remove();
    });

    $("#downloadPackagingQuantitySold").on("click", function () {
        var href = $(this).attr("href");
        var params = getSearchData();

        var form = $('<form id="exportForm" method="POST" style="display:none;"></form>');
        form.attr("action", $("#packagingQuantitySold").val());
        var form_data = new FormData();

        for (var key in params) {
            var input = $("<input>")
                .attr("name", key).val(params[key]);
            form.append(input);
        }

        $("body").append(form);
        form.submit();
        $("#exportForm").remove();
    });
}