<?php
$empresasDao = new \Dao\Empresas();
$empresasDao->getEmpresaPorId($conecta, base64_decode(filter_input(INPUT_GET, 'empresa')));
// 
$acessosDao = new \Dao\Acessos();
$acessosDao->getAcessoPorId($conecta, base64_decode(filter_input(INPUT_GET, 'id')));
?>
<div class="breadcrumb-holder">
    <div class="container-fluid">
        <ul class="breadcrumb">
            <li class="breadcrumb-item"><a href="./">Home</a></li>
            <li class="breadcrumb-item"><a href="empresas.php">Empresas</a></li>
            <li class="breadcrumb-item"><a href="?p=acessos&id=<?php echo base64_encode($empresasDao->id); ?>">Acessos</a></li>
            <li class="breadcrumb-item active"><?php echo ($acessosDao->id == 0 ? 'Adicionar Acesso' : 'Editar Acesso'); ?></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"><?php echo ($acessosDao->id == 0 ? 'Adicionar Acesso' : 'Editar - ' . $acessosDao->nome); ?></h2>
                    </div><!--/.card-header -->
                    <div class="card-body">
                        <form class="form-horizontal" method="post" action="?p=salvar-acesso" enctype="multipart/form-data">
                            <input type="hidden" name="id" id="id" value="<?php echo $acessosDao->id; ?>">
                            <input type="hidden" name="id_empresa" id="id_empresa" value="<?php echo $empresasDao->id; ?>">
                            <div class="form-group row">
                                <div class="col-md-5">
                                    <label class="form-label">Nome</label>
                                    <input type="text" name="nome" id="nome" placeholder="Nome" value="<?php echo $acessosDao->nome; ?>" maxlength="40" class="form-control" required>
                                </div><!--/.col-md-5 -->
                                <div class="col-md-4">
                                    <label class="form-label">Email</label>
                                    <input type="email" id="email" name="email" placeholder="Email" value="<?php echo $acessosDao->email; ?>" class="form-control" maxlength="50">
                                </div><!--/.col-md-4 -->
                                <div class="col-md-3">
                                    <label class="form-label">Usuário</label>
                                    <input type="text" name="usuario" id="usuario" placeholder="Usuário" value="<?php echo $acessosDao->usuario; ?>" maxlength="15" class="form-control" required>
                                </div><!--/.col-md-3 -->
                            </div><!--/.form-group -->
                            <div class="form-group row">
                                <div class="col-md-2">
                                    <label class="form-label">Senha</label>
                                    <input type="password" id="senha" name="senha" placeholder="Senha" value="" class="form-control" maxlength="12" <?php echo ($acessosDao->id == 0 ? 'required' : ''); ?>>
                                </div><!--/.col-md-2 -->
                                <div class="col-md-2">
                                    <label class="form-label">Conf. Senha</label>
                                    <input type="password" name="conf_senha" id="conf_senha" class="form-control" placeholder="Conf. Senha" value="" maxlength="12" <?php echo ($acessosDao->id == 0 ? 'required' : ''); ?>>
                                </div><!--/.col-md-2 -->
                                <div class="col-md-3">
                                    <label class="form-label">Situação</label>
                                    <select name="situacao" id="situacao" class="form-control" required>
                                        <option value="A" <?php echo ($acessosDao->situacao == 'A' ? 'selected' : ''); ?>>Ativo</option>
                                        <option value="B" <?php echo ($acessosDao->situacao == 'B' ? 'selected' : ''); ?>>Bloqueado</option>
                                    </select>
                                </div><!--/.col-md-3 -->
                            </div><!--/.form-group -->
                            <div class="form-group row">
                                <div class="col-md-12 text-right">
                                    <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 -->