<div class="row row-relative-10">
    <div class="col-xs-12">
        <div class="pull-right">
            <a class="btn btn-success btn-flat" href="#" id="DodajOcenePracownikaButton">
                <span style="margin-right: 10px;"><i class="fa fa-plus"></i> Dodaj</span>
                <label class="switch"></label>
            </a>
        </div>
    </div>
</div>
<table id="OcenyTable" class="table hover-rows custom-table HalfTable" data-start-sort="1" data-start-sort-direction="desc" data-start-height="25vh">
    <thead>
    <tr class="text-uppercase">
        <th>Ocena</th>
        <th>Za okres od</th>
        <th>Za okres do</th>
        <th>Data następnej oceny</th>
        <th>Punktów</th>
        <th class="no-sortable"></th>
    </tr>
    </thead>
    <tbody>
    <?php foreach ($ratings['bOceny']['bOcena'] as $k => $rating): ?>
        <tr
            <?php if (!empty($rating['bInformacjeDodatkowe'])): ?>
                class="more-info-append" data-append-to="#more-info-container"
                data-more-info="<?php echo $rating['bInformacjeDodatkowe']; ?>"
            <?php endif; ?>
        >
            <td class="info-addon"><?php echo $rating['bKod']['cOpis']; ?></td>
            <td><span class="span-date"><?php echo $rating['bDataOd']; ?></span></td>
            <td><span class="span-date"><?php echo $rating['bDataDo']; ?></span></td>
            <td><span class="span-date"><?php if(!empty($rating['bDataNastepnej'])) echo $this->App->notEmpty($rating['bDataNastepnej'], 'Y-m-d'); ?></span></td>
            <td><span class="span-date"><?php echo $rating['bPunktow1']; ?></span></td>
            <td class="text-right">
                <?php
                /**
                <?php if($rating['bCzyAktualnyUserMozePrzegladac'] == 'true') : ?>
                <a rel="tooltip" data-placement="left" title="Pokaż ocenę" class="btn btn-success" href="/pokaz_ocene/<?php echo $rating['bGid']; ?>">
                <i class="fa fa-eye"></i>
                </a>
                <?php endif; ?>
                 */
                ?>

                <?php if($rating['bCzyAktualnyUserMozeEdytowac'] == 'true') : ?>
                    <a data-menu-action="edytuj_ocene/<?php echo $rating['bGid']; ?>" rel="tooltip" data-placement="left" title="Edytuj ocenę" class="btn btn-primary">
                        <i class="fa fa-pencil"></i>
                    </a>
                <?php endif; ?>

                <?php if($rating['bCzyAktualnyUserMozeUsunac'] == 'true') : ?>
                    <a class="btn btn-danger" data-remove-entry data-gid="<?php echo $rating['bGid']; ?>" data-url="usun_ocene" data-title="Na pewno usunąć?"><i class="fa fa-trash"></i></a>
                <?php endif; ?>
            </td>
        </tr>
    <?php endforeach; ?>
    </tbody>
</table>

<script>
    $(function(){
        const elemsData = document.querySelectorAll('[data-menu-action]');
        elemsData.forEach(elem => elem.onclick = testFun);
    })

    function testFun(e) {
        e.preventDefault();

        $(this).parents('.sidebar').find('li.active:not(.treeview)').removeClass('active');
        $(this).parents('li').addClass('active');

        var url = $(this).data('menu-action');
        localStorage.setItem('menu_action', url);

        loadAjaxView(url);
    }
</script>

<?php echo $this->element('alert_close'); ?>
