index.php 2.67 KB
<div class="inner"><?= $this->flash->output(); ?></div>
<a class="btn btn-primary" href="<?= $this->url->get([ 'for' => 'add_fields', "type"=>$type]) ?>">Добавить</a>
<table class="table table-hover" data-url="/sort_user">
    <thead>
    <tr>
        <th>#</th>
        <th><p>Название</p></th>
        <th>Вес</th>
        <th class="table-buttons"></th>
    </tr>
    </thead>
    <tbody id="result">
    <?php foreach ($data as $item):?>
        <tr  class="main_row_block <?=$item['children'] ? "parent" : "" ?>" data-id="<?= $item['id']?>">
            <td><?=$item['id']; ?></td>
            <td><?= $item['name'] ?></td>
            <td><?= $item['weight']?></td>
            <td>
                <a href="<?= $this->url->get([ 'for' => 'delete_fields',  "type"=>$type, "id"=>$item['id']]) ?>" class="action-img delete_icon" title="Удалить" onclick="return confirm('Вы действительно хотите удалить пункт?')"></a>
                <a href="<?= $this->url->get([ 'for' => 'update_fields',  "type"=>$type, "id"=>$item['id'] ]) ?>" class="action-img edit-icon" title="Редактировать"></a>
            </td>
        </tr>
        <?php if($item['children']): ?>
                <tr class="subrow_block_<?= $item['id']?>">
                    <td colspan="3">
                        <table class="table table-hover">
                            <tbody>
                            <?php foreach($item['children'] as $row): ?>
                            <tr class="subrow" data-parentId="">
                                <td><?=$row['id']; ?></td>
                                <td><?= $row['name'] ?></td>
                                <td><?= $row['weight']?></td>
                                <td class="table-buttons">
                                    <a href="<?= $this->url->get([ 'for' => 'delete_fields',  "type"=>$type, "id"=>$row['id']]) ?>" class="action-img delete_icon" title="Удалить" onclick="return confirm('Вы действительно хотите удалить пункт?')"></a>
                                    <a href="<?= $this->url->get([ 'for' => 'update_fields',  "type"=>$type, "id"=>$row['id'] ]) ?>" class="action-img edit-icon" title="Редактировать"></a>
                                </td>
                            </tr>
                            <?php endforeach; ?>
                            </tbody>
                        </table>
                    </td>
                </tr>

           <?php endif;?>
        <?php endforeach; ?>
    </tbody>
</table>
<a class="btn btn-primary" href="<?= $this->url->get([ 'for' => 'add_fields', "type"=>$type]) ?>">Добавить</a>