<div class="breadcrumb-holder">
    <div class="container-fluid">
        <ul class="breadcrumb">
            <li class="breadcrumb-item"><a href="./">Home</a></li>
            <li class="breadcrumb-item active">Editar Dados Usuário</li>
        </ul><!--/.breadcrumb -->
    </div><!---/.container-fluid -->
</div><!--/.breadcrumb-holder -->
<section class="dashboard-counts section-padding">
    <div class="container-fluid">
        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-header d-flex align-items-center">
                        <h2 class="h5 display">Editar Dados Usuário</h2>
                    </div><!--/.card-header -->
                    <div class="card-body">
                        <form class="form-horizontal" method="post" action="?p=salvar" enctype="multipart/form-data">
                            <input type="hidden" name="id" id="id" value="<?php echo $logedUser->id; ?>">
                            <div class="form-group row">
                                <label class="col-sm-2 form-label">Nome</label>
                                <div class="col-sm-6">
                                    <input type="text" name="nome" id="nome" placeholder="Nome" value="<?php echo $logedUser->nome; ?>" maxlength="70" class="form-control" required autofocus>
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-sm-2 form-label">Email</label>
                                <div class="col-sm-7">
                                    <input type="email" name="email" id="email" placeholder="Email" value="<?php echo $logedUser->email; ?>" maxlength="60" class="form-control" required>
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-sm-2 form-label">Usuário</label>
                                <div class="col-sm-3">
                                    <input type="text" name="usuario" id="usuario" placeholder="Usuário" value="<?php echo $logedUser->login; ?>" maxlength="15" class="form-control" required>
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-sm-2 form-label">Senha</label>
                                <div class="col-sm-2">
                                    <input type="password" name="senha" id="senha" placeholder="Senha" class="form-control">
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-sm-2 form-label">Confirmação</label>
                                <div class="col-sm-2">
                                    <input type="password" name="conf_senha" id="conf_senha" placeholder="Confirmação" class="form-control">
                                </div>
                            </div>
                            <?php
                            if ($logedUser->tipo == 'A') {
                                ?>
                                <div class="form-group row">
                                    <label class="col-sm-2 form-label">Tipo</label>
                                    <div class="col-sm-3">
                                        <select name="tipo" id="tipo" class="form-control" required>
                                            <option value="">Tipo</option>
                                            <option value="U" <?php echo ($logedUser->tipo == 'U' ? 'selected' : ''); ?>>Usuário</option>
                                            <option value="A" <?php echo ($logedUser->tipo == 'A' ? 'selected' : ''); ?>>Administrador</option>
                                        </select>
                                    </div>
                                </div>
                                <?php
                            }
                            ?>
                            <div class="form-group row">
                                <label class="col-sm-2 form-label">Foto</label>
                                <div class="col-sm-6">
                                    <input type="file" name="foto" id="foto" class="file-input">
                                </div>
                            </div>
                            <div class="form-group cropper row">
                                <label class="col-sm-2 form-label"></label>
                                <div class="col-sm-10">
                                    <div class="img-container">
                                        <?php
                                        if ($logedUser->image != '' && file_exists($pasta . $logedUser->image))
                                            echo '<img id="imagem" src="' . $pasta . $logedUser->image . '" class="height200" alt="">';
                                        else
                                            echo '<img id="imagem" src="https://placehold.it/300x300" class="height200" alt="">';
                                        ?>
                                    </div><!--/.img-container -->
                                </div><!--/.col-md-9 -->
                            </div><!--/.cropper -->
                            <?php
                            if ($logedUser->tipo == 'A') {
                                ?>
                                <div class="form-group row">
                                    <label class="col-sm-2 form-label">Permissões</label>
                                    <div class="col-sm-10">
                                        <div class="i-checks">
                                            <?php
                                            $perm = explode(';', $logedUser->permissoes);
                                            foreach ($lst_paginas as $key => $permissao) {
                                                $checked = (in_array($key, $perm)) ? 'checked' : '';
                                                echo '
                                                    <input id="' . $key . '" type="checkbox" name="perm[]" value="' . $key . '" class="form-control-custom" ' . $checked . '>
                                                    <label for="' . $key . '">' . $permissao['title'] . '</label>
                                                ';
                                            }
                                            ?>
                                        </div>
                                    </div>
                                </div>
                                <?php
                                }
                            ?>
                            <div class="form-group row">
                                <label class="col-sm-2"></label>
                                <div class="col-sm-2">
                                    <button class="btn btn-sm btn-primary">
                                        <i class="fa fa-database"></i> Salvar
                                    </button>
                                </div>
                            </div><!--/.form-group -->
                        </form>
                    </div><!--/.card-body -->
                </div><!--/.card -->
            </div><!--/.col-lg-12 -->
        </div><!--/.row -->
    </div><!--/.container-fluid -->
</section><!--/.dashboard-counts -->