<?php $__env->startSection('titulo'); ?>
    <i class="fas fa-route"></i> Rotas
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
    <script src="<?php echo e(URL::asset('js/treetable/treeTable.js')); ?>"></script>
    <script src="<?php echo e(URL::asset('js/views/adm/rota.js')); ?>"></script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('pagina'); ?>

    <div class="container-fluid">
        <div class="card rounded text-left">
            <div class="card-body">
                <?php if($permEditar): ?>
                    <div class="row" >
                        <div class="col text-right">
                            <button id="btnNovaRota" type="button" class="btn btn-primary" aria-label="Left Align" >
                                <i class="fas fa-plus-circle"></i> Nova Rota
                            </button>
                        </div>
                    </div>
                    <br/>
                <?php endif; ?>
            </div>
        </div>

        <div class="card mt-2">
            <div class="card-body">
                <div class="row" >
                    <div class="col panel panel-primary table-responsive">
                        <table id="tbRotas" class="table table-hover text-left">
                            <thead>
                                <tr>
                                    <th>Nome</th>
                                    <th>Rota</th>
                                    <th>Rota Pai</th>
                                    <th>Menu</th>
                                    <th>Ícone</th>

                                    <?php if($permEditar || $permDelete): ?>
                                        <th>Ações</th>
                                    <?php endif; ?>

                                </tr>
                            </thead>
                            <tbody>

                                <?php $__currentLoopData = $rotas; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $rota): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr data-tt-id="<?php echo e($rota->getId()); ?>" data-tt-parent-id="<?php echo e((empty($rota->RotaPai) ? '' : $rota->RotaPai->getId())); ?>">
                                        <td id="<?php echo e($rota->getId()); ?>_nome"><?php echo e($rota->getNome()); ?></td>
                                        <td id="<?php echo e($rota->getId()); ?>_rota"><?php echo e($rota->getRota()); ?></td>
                                        <td id="<?php echo e($rota->getId()); ?>_rota_pai" data="<?php echo e((empty($rota->RotaPai) ? '' : $rota->RotaPai->getId())); ?>">
                                            <?php echo e((empty($rota->RotaPai) ? '' : $rota->RotaPai->getNome())); ?>

                                        </td>
                                        <td id="<?php echo e($rota->getId()); ?>_menu" data="<?php echo e($rota->isMenu()); ?>">

                                            <?php if($rota->isMenu()): ?>
                                                <span class="badge badge-success">SIM</span>
                                            <?php else: ?>
                                                <span class="badge badge-danger">NÃO</span>
                                            <?php endif; ?>

                                        </td>
                                        <td id="<?php echo e($rota->getId()); ?>_icone" data="<?php echo e($rota->getIcone()); ?>">
                                            <i class="<?php echo e($rota->getIcone()); ?> fa-2x"></i>
                                        </td>

                                        <?php if($permEditar || $permDelete): ?>
                                            <td>
                                                <?php if($permEditar): ?>
                                                    <span name="editBtn" class="fas fa-edit fa-2x cursor-pointer text-success" data="<?php echo e($rota->getId()); ?>" title="Editar"></span>
                                                <?php endif; ?>

                                                <?php if($permDelete): ?>
                                                    <span name="delBtn" class="fas fa-trash-alt fa-2x cursor-pointer text-danger" data="<?php echo e($rota->getId()); ?>" title="Excluir"></span>
                                                <?php endif; ?>
                                            </td>
                                        <?php endif; ?>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                            </tbody>
                        </table>

                    </div>
                </div>
            </div>
        </div>
    </div>

    <?php if($permEditar): ?>

        <!-- Inclui formulário modal -->
        <?php echo $__env->make('partials._modal_form',
        [
            'idModal'=>'dlgRota',
            'titulo'=> 'Nova Rota',
            'icone'=>'fa-route',
            'rota' => 'adm.rota.salvar',
            'campos'=>
            [
                [
                    'tipo'=>'array',
                    'campos'=>
                    [
                        [
                            'largura'=>'5',
                            'id' =>'cbMenu',
                            'label'=>'Menu',
                            'nome'=>'menu',
                            'tipo'=>'slider'
                        ]
                    ]
                   
                ],
                [
                    'id' =>'txtNome',
                    'label'=>'Nome',
                    'nome'=>'nome',
                    'tamanho'=>'50',
                    'tipo'=>'txt',
                    'required'=> true,
                    'autofocus'=> true,
                    'autocomplete'=>'off'
                ],
                [
                    'id' =>'txtRota',
                    'label'=>'Rota',
                    'nome'=>'rota',
                    'tamanho'=>'50',
                    'tipo'=>'txt',
                    'required'=> true,
                    'autocomplete'=>'off'
                ],
                [
                    'tipo'=>'array',
                    'campos'=>
                    [
                        [
                            'largura'=>'10',
                            'id' =>'txtIcone',
                            'label'=>'icone',
                            'nome'=>'icone',
                            'tamanho'=>'50',
                            'tipo'=>'txt'
                        ],
                        [
                            'largura'=>'2',
                            'id' =>'icnRota',
                            'label'=>'',
                            'style'=>'font-size:xx-large;padding-top:32px;',
                            'tipo'=>'icone'
                        ]
                    ]
                ],
                [
                    'id' =>'cbPai',
                    'label'=>'Rota pai',
                    'nome'=>'pai',
                    'tipo'=>'combo',
                    'opcoes'=>[]
                ]
            ]
        ], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
    <?php endif; ?>

    <?php if($permDelete): ?>
        <?php echo $__env->make('partials._modal_delete',
        [
            'rota'=>'adm.rota.delete',
            'titulo'=>'Confirma Exclusão',
            'mensagem_delete'=>'Tem certeza que deseja excluir a rota'
        ], \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>
    <?php endif; ?>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>