function initializeDailyPlanItems() {

    var fromDailyPlan = localStorage.getItem('WoFromDailyPlan');

    $itemsTable = $('#mainGridDailyPlanItems');
    var itemsTable = $itemsTable.DataTable({
        ajax: {
            url: $itemsTable.attr('data-url'),
            data: function (d) {
                d.Key = $("#AcKey").val();
                d.DataFromDailyPlan = fromDailyPlan;
            }
        },
        columns: [
            {
                data: "OperationName",
                name: "OperationName",
                filtertype: "text",
                className: "dt-body-left",
                render: function (data, type, full) {
                    return type === 'display' ?
                        '<div class="margin-top-10">' +
                        '<label class="control-label">Operacija</label>' +
                        '<div>' +
                        '<span >' + full.No + ' - ' + data + '</span>' +
                        '</div>' +
                        '</div >' : data;
                }
            },
            {
                data: "ResursID",
                name: "ResursID",
                filtertype: "text",
                className: "card-label",
                render: function (data, type, full) {
                    return type === 'display' ?
                        '<h3 class="card-header text-success"><span><i class="fas fa-cogs"></i></span>  ' + data + ' - ' + full.ResourceName + '</h3 >' : data;

                }
            },
            {
                data: "KeyView",
                name: "KeyView",
                render: function (data, type, full) {
                    return type === 'display' ?
                        '<span style="margin-right:2px"></span> <i class="far fa-hashtag"></i> <span>' + data + '</span>' : data;
                }
            },
            {
                data: "ShiftName",
                name: "ShiftName",
                render: function (data, type, full) {
                    return type === 'display' ?
                        '<span style="margin-right:2px"></span> <span>' + data + '</span>' : data;
                }
            },
            {
                data: "StartEnd",
                name: "StartEnd",
                render: function (data, type, full) {
                    return type === 'display' ?
                        '<span style="margin-right:2px"> <i class="far fa-clock"></i> </span> <span>' + data + '</span>' : data;
                }
            },
            {
                data: 'CompletedPrc',
                render: function (data, type, row, meta) {
                    return type === 'display' ?
                        '<progress value=' + data + ' max="100"  style="width: 100%"></progress>' :
                        data;
                }
            },

            {
                data: 'StatusName',
                render: function (data, type, full) {
                    var completedPrc = $.fn.dataTable.render.number('.', ',', 0, '', "").display(full.CompletedPrc);
                    var planTime = $.fn.dataTable.render.number('.', ',', 2, '', "").display(full.PlanTime);
                    var doneTime = $.fn.dataTable.render.number('.', ',', 2, '', "").display(full.DoneTime);
                    return type === 'display' ?
                        '<span>' + data + ' (' + completedPrc + ' %)' + '</span>  <span class="pull-right">' + doneTime + '/' + planTime + '</span>' : data;
                }
            }

        ],
        createdRow: function (row, data, dataIndex) {
            $(row).css('cursor', 'pointer');
        },
        drawCallback: function () {
            $("[data-toggle='tooltip']").tooltip({
                container: 'body'
            });
        }
    })

    itemsTable.on('click', 'tr', function () {
        var data = itemsTable.row($(this)).data();
        var fromDP = localStorage.getItem('WoFromDailyPlan');
        window.location.href = "WorkReg?key=" + data.WOKey + '&no=' + data.No + '&resID=' + data.ResursID + '&dailyPlan=' + fromDP;
    });

};




