<?php
    if(isset($_GET['idusuario'])){
        $idusuario = $_GET['idusuario'];
    }else{
        $idusuario = 0;
    }
?>
<style>
    ol{
        list-style: none;
    }
</style>
<div class="page-content-wrapper">
    <div class="page-content">
        <!-- BEGIN PAGE HEAD -->
        <div class="page-head">
            <!-- BEGIN PAGE TITLE -->
            <div class="page-title">
                <h3>Permissões</h3>
            </div>
            <!-- END PAGE TITLE -->            
        </div>
        <!-- END PAGE HEAD -->
        <?php helper('mensagem');?>
        <div class="row">		
            <div class="col-md-12">         
                <div class="portlet box blue-hoki">
                    <div class="portlet-title">
                        <div class="caption">Permissões do sistema</div>
                    </div>
                    <div class="portlet-body">
                        <form novalidate action="/Configuracoes/Permissoes/permissoesInserir" method="POST" id="frmPermissoes"> 
                        <?= csrf_field() ?>
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <h5>Usuário</h5>
                                        <div class="controls">
                                            <select name="permissoes_usuarios" id="permissoes_usuarios" required class="form-control select2" data-validation-required-message="Campo obrigatório">
                                                <option value="">Selecione um usuário</option>
                                                <?php 
                                                    foreach ($usuarios->getResult() as $usuario) {
                                                        if($idusuario==$usuario->ID_USUARIO){$selected='selected';}else{$selected='';}
                                                        echo "<option ".$selected." value=".$usuario->ID_USUARIO.">".$usuario->NOME."</option>";
                                                    }
                                                ?>
                                            </select>
                                            <div class="help-block">Selecione um usuário para definir as permissões</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <h5>Perfil</h5>
                                        <div class="controls">
                                            <select name="permissoes_perfil" id="permissoes_perfil" class="form-control select2">
                                                <option value="">Selecione um perfil</option>
                                                <?php 
                                                    foreach ($perfis->getResult() as $perfil) {
                                                        echo "<option value=".$perfil->ID_PERFIL.">".$perfil->DESCRICAO."</option>";
                                                    }
                                                ?>
                                            </select>
                                            <div class="help-block">Selecione um perfil para permissões pré-selecionados</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <hr>
                            <div class="row">
                                <div class="col-md-6">
                                    <fieldset>
                                        <input type="checkbox" id="permissoes_chk_all">
                                        <label for="permissoes_chk_all">Marcar todas as opções</label>
                                    </fieldset>
                                    <div class="row">
                                        <div class="col-md-6">
                                            <!-- Default box -->
                                            <div class="box">
                                                <div class="box-header with-border">
                                                    <h4 class="box-title">Configurações</h4>
                                                </div>
                                                <div class="box-body">
                                                    <div class="myadmin-dd">
                                                        <ol class="dd-list">
                                                            <li class="dd-item">
                                                                <div class="dd-handle collapsed" data-toggle="collapse" data-target="#usuarios" aria-expanded="false" aria-controls="usuarios"><i class="fa fa-plus"></i> Usuários</div>
                                                                <ol class="dd-list controls collapse" id="usuarios" aria-expanded="false" class="collapse">
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="usuarios_chk_cons" value="2" class="checkboxes" name="checkperm[]">
                                                                                <label for="usuarios_chk_cons">Consultar</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="usuarios_chk_ins" value="3" class="checkboxes" name="checkperm[]">
                                                                                <label for="usuarios_chk_ins">Inserir</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="usuarios_chk_edt" value="4" class="checkboxes" name="checkperm[]">
                                                                                <label for="usuarios_chk_edt">Editar</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                </ol>
                                                            </li>
                                                        </ol>
                                                        <ol class="dd-list">
                                                            <li class="dd-item">
                                                                <div class="dd-handle collapsed" data-toggle="collapse" data-target="#empresa" aria-expanded="false" aria-controls="empresa"><i class="fa fa-plus"></i> Empresa</div>
                                                                <ol class="dd-list controls collapse" id="empresa" aria-expanded="false" class="collapse">
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="usuarios_chk_cons" value="33" class="checkboxes" name="checkperm[]">
                                                                                <label for="empresa_chk_cons">Consultar</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="usuarios_chk_ins" value="34" class="checkboxes" name="checkperm[]">
                                                                                <label for="empresa_chk_ins">Inserir</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                </ol>
                                                            </li>
                                                        </ol>
                                                       
                                                        <ol class="dd-list">
                                                            <li class="dd-item">
                                                                <div class="dd-handle collapsed" data-toggle="collapse" data-target="#permissoes" aria-expanded="false" aria-controls="permissoes"><i class="fa fa-plus"></i> Permissões</div>
                                                                <ol class="dd-list controls collapse" id="permissoes" aria-expanded="false" class="collapse">
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="permissoes_chk_cons" value="5" class="checkboxes" name="checkperm[]">
                                                                                <label for="permissoes_chk_cons">Consultar</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="permissoes_chk_mod" value="6" class="checkboxes" name="checkperm[]">
                                                                                <label for="permissoes_chk_mod">Modificar</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                </ol>
                                                            </li>
                                                        </ol>
                                                        <ol class="dd-list">
                                                            <li class="dd-item">
                                                                <div class="dd-handle collapsed" data-toggle="collapse" data-target="#perfil" aria-expanded="false" aria-controls="perfil"><i class="fa fa-plus"></i> Perfil</div>
                                                                <ol class="dd-list controls collapse" id="perfil" aria-expanded="false" class="collapse">
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="perfil_chk_cons" value="7" class="checkboxes" name="checkperm[]">
                                                                                <label for="perfil_chk_cons">Consultar</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                </ol>
                                                            </li>
                                                        </ol>
                                                        <ol class="dd-list">
                                                            <li class="dd-item">
                                                                <div class="dd-handle collapsed" data-toggle="collapse" data-target="#log" aria-expanded="false" aria-controls="log"><i class="fa fa-plus"></i> Logs</div>
                                                                <ol class="dd-list controls collapse" id="log" aria-expanded="false" class="collapse">
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="log_chk_cons" value="8" class="checkboxes" name="checkperm[]">
                                                                                <label for="log_chk_cons">Consultar</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                </ol>
                                                            </li>
                                                        </ol>
                                                        
                                                            </li>
                                                        </ol>
                                                    </div>
                                                </div>

                                                
                                            </div> 
                                             

                                        </div>
                                        <div class="col-md-6">
                                        <div class="box">
                                                <div class="box-header with-border">
                                                    <h4 class="box-title">Administrativo</h4>
                                                </div>
                                                <div class="box-body">
                                                    <div class="myadmin-dd">
                                                        <ol class="dd-list">
                                                            <li class="dd-item">
                                                                <div class="dd-handle collapsed" data-toggle="collapse" data-target="#pessoas" aria-expanded="false" aria-controls="pessoas"><i class="fa fa-plus"></i> Pessoas</div>
                                                                <ol class="dd-list controls collapse" id="pessoas" aria-expanded="false" class="collapse">
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="pessoas_chk_cons" value="9" class="checkboxes" name="checkperm[]">
                                                                                <label for="pessoas_chk_cons">Consultar</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="pessoas_chk_ins" value="10" class="checkboxes" name="checkperm[]">
                                                                                <label for="pessoas_chk_ins">Inserir</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="pessoas_chk_edt" value="11" class="checkboxes" name="checkperm[]">
                                                                                <label for="pessoas_chk_edt">Editar</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="pessoas_chk_excs" value="12" class="checkboxes" name="checkperm[]">
                                                                                <label for="pessoas_chk_excs">Excluir</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                </ol>
                                                            </li>
                                                        </ol>
                                                        <ol class="dd-list">
                                                            <li class="dd-item">
                                                                <div class="dd-handle collapsed" data-toggle="collapse" data-target="#armazens" aria-expanded="false" aria-controls="armazens"><i class="fa fa-plus"></i> Armazens</div>
                                                                <ol class="dd-list controls collapse" id="armazens" aria-expanded="false" class="collapse">
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="armazens_chk_cons" value="13" class="checkboxes" name="checkperm[]">
                                                                                <label for="armazens_chk_cons">Consultar</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="armazens_chk_ins" value="14" class="checkboxes" name="checkperm[]">
                                                                                <label for="armazens_chk_ins">Inserir</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="armazens_chk_edt" value="15" class="checkboxes" name="checkperm[]">
                                                                                <label for="armazens_chk_edt">Editar</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="armazens_chk_excs" value="16" class="checkboxes" name="checkperm[]">
                                                                                <label for="armazens_chk_excs">Excluir</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                </ol>
                                                            </li>
                                                        </ol>
                                                        <ol class="dd-list">
                                                            <li class="dd-item">
                                                                <div class="dd-handle collapsed" data-toggle="collapse" data-target="#modalidades" aria-expanded="false" aria-controls="modalidades"><i class="fa fa-plus"></i> Modalidades</div>
                                                                <ol class="dd-list controls collapse" id="modalidades" aria-expanded="false" class="collapse">
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="modalidades_chk_cons" value="17" class="checkboxes" name="checkperm[]">
                                                                                <label for="modalidades_chk_cons">Consultar</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="modalidades_chk_ins" value="18" class="checkboxes" name="checkperm[]">
                                                                                <label for="modalidades_chk_ins">Inserir</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="modalidades_chk_edt" value="19" class="checkboxes" name="checkperm[]">
                                                                                <label for="modalidades_chk_edt">Editar</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="modalidades_chk_excs" value="20" class="checkboxes" name="checkperm[]">
                                                                                <label for="modalidades_chk_excs">Excluir</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    
                                                                </ol>
                                                            </li>
                                                        </ol>
                                                        <ol class="dd-list">
                                                            <li class="dd-item">
                                                                <div class="dd-handle collapsed" data-toggle="collapse" data-target="#transportes" aria-expanded="false" aria-controls="transportes"><i class="fa fa-plus"></i> Transportes</div>
                                                                <ol class="dd-list controls collapse" id="transportes" aria-expanded="false" class="collapse">
                                                                <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="transportes_chk_cons" value="21" class="checkboxes" name="checkperm[]">
                                                                                <label for="transportes_chk_cons">Consultar</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="transportes_chk_ins" value="22" class="checkboxes" name="checkperm[]">
                                                                                <label for="transportes_chk_ins">Inserir</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="transportes_chk_edt" value="23" class="checkboxes" name="checkperm[]">
                                                                                <label for="transportes_chk_edt">Editar</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="transportes_chk_excs" value="24" class="checkboxes" name="checkperm[]">
                                                                                <label for="transportes_chk_excs">Excluir</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    
                                                                </ol>
                                                            </li>
                                                        </ol>
                                                        <ol class="dd-list">
                                                            <li class="dd-item">
                                                                <div class="dd-handle collapsed" data-toggle="collapse" data-target="#contratos" aria-expanded="false" aria-controls="transportes"><i class="fa fa-plus"></i> Contratos</div>
                                                                <ol class="dd-list controls collapse" id="contratos" aria-expanded="false" class="collapse">
                                                                <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="contratos_chk_cons" value="25" class="checkboxes" name="checkperm[]">
                                                                                <label for="contratos_chk_cons">Consultar</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="contratos_chk_ins" value="26" class="checkboxes" name="checkperm[]">
                                                                                <label for="contratos_chk_ins">Inserir</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="contratos_chk_edt" value="27" class="checkboxes" name="checkperm[]">
                                                                                <label for="contratos_chk_edt">Editar</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="contratos_chk_excs" value="28" class="checkboxes" name="checkperm[]">
                                                                                <label for="contratos_chk_excs">Excluir</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    
                                                                </ol>
                                                            </li>
                                                        </ol>
                                                        <ol class="dd-list">
                                                            <li class="dd-item">
                                                                <div class="dd-handle collapsed" data-toggle="collapse" data-target="#tpagamentos" aria-expanded="false" aria-controls="transportes"><i class="fa fa-plus"></i> Tipos De Pagamentos</div>
                                                                <ol class="dd-list controls collapse" id="tpagamentos" aria-expanded="false" class="collapse">
                                                                <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="tpagamentos_chk_cons" value="29" class="checkboxes" name="checkperm[]">
                                                                                <label for="tpagamentos_chk_cons">Consultar</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="tpagamentos_chk_ins" value="30" class="checkboxes" name="checkperm[]">
                                                                                <label for="tpagamentos_chk_ins">Inserir</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="tpagamentos_chk_edt" value="31" class="checkboxes" name="checkperm[]">
                                                                                <label for="tpagamentos_chk_edt">Editar</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    <li class="dd-item">
                                                                        <div class="dd-handle collapsed">
                                                                            <fieldset>
                                                                                <input type="checkbox" id="tpagamentos_chk_excs" value="32" class="checkboxes" name="checkperm[]">
                                                                                <label for="tpagamentos_chk_excs">Excluir</label>
                                                                            </fieldset>
                                                                        </div>
                                                                    </li>
                                                                    
                                                                </ol>
                                                            </li>
                                                        </ol>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                
                                    
                                    <div class="text-xs-right bt-1 pt-10">
                                        <div class="pull-right">
                                            <button type="button" id="gravar_permissoes" class="btn btn-sm blue"><span class="fa fa-save"> Salvar</span></button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form> 
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>     <!-- /.box -->
<script src="/template/assets/global/scripts/permissao.min.js"></script>