Exemple #1
0
 public function primeiroAcesso()
 {
     //Pega a conexão
     $conexao = new conexao();
     $conexao->getConnectionLocal();
     //Início à pesquisa da tabela de tipos de acesso
     $tipoacesso = new classeTipoAcesso();
     //Início à pesquisa de clientes
     $clientes = new classeCliente();
     //Início à pesquisa dos status
     $statusUsuario = new classeStatus();
     echo "<form id='contact-form' name='contact-form' method='post' action='primeiroAcesso.php'>";
     echo "  <div class='row wow fadeInUp' data-wow-duration='1000ms' data-wow-delay='300ms'>";
     echo "      <div class='col-sm-6'>";
     echo "          <div class='form-group'>";
     echo "              <input type='text' name='login' class='form-control' placeholder='Login' required='required'>";
     echo "          </div>";
     echo "      </div>";
     echo "      <div class='col-sm-6'>";
     echo "          <div class='form-group'>";
     echo "              <input type='password' name='senha' class='form-control' placeholder='senha' required='required'>";
     echo "          </div>";
     echo "      </div>";
     echo "      <div class='col-sm-12'>";
     echo "          <div class='form-group'>";
     echo "              <input type='text' name='email' class='form-control' placeholder='E-mail' required='required'>";
     echo "          </div>";
     echo "      </div>";
     echo "      <div class='col-sm-6'>";
     echo "          <div class='form-group'>";
     echo "              <select name='cliente' class='form-control'>";
     echo "                  <option value='99'>Cliente</option>";
     echo "                  <option value=''>&nbsp;</option>";
     echo $clientes->consultaComboClientes();
     echo "              </select>";
     echo "          </div>";
     echo "      </div>";
     echo "      <div class='col-sm-6'>";
     echo "          <div class='form-group'>";
     echo "              <select name='tipoAcesso' class='form-control'>";
     echo "                  <option value='99'>Tipo de Acesso</option>";
     echo "                  <option value=''>&nbsp;</option>";
     echo $tipoacesso->consultaComboTipoAcesso();
     echo "              </select>";
     echo "          </div>";
     echo "      </div>";
     echo "      <div class='col-sm-12'>";
     echo "          <div class='form-group'>";
     echo "              <select name='statusUsuario' class='form-control'>";
     echo "                  <option value='99'>Status</option>";
     echo "                  <option value=''>&nbsp;</option>";
     echo $statusUsuario->consultaComboStatusUsuario();
     echo "              </select>";
     echo "          </div>";
     echo "      </div>";
     echo "  </div>";
     echo "  <div class='form-group'>";
     echo "      <button type='submit' class='btn-submit'>Incluir</button>";
     echo "  </div>";
     echo "  <input type='hidden' name='dataCadastro' id='dataCadastro' value='" . date('Y-m-d') . "'>";
     echo "  <input type='hidden' name='dataAlteracao' id='dataCadastro' value='" . date('Y-m-d') . "'>";
     echo "</form>";
 }
 public function modalNovoUsuario()
 {
     echo "<script>\$('novoUsuario').on('show.bs.modal', function(){";
     echo "\$('#myInput').focus();";
     echo "});</script>";
     //        echo "<script>$(document).ready(function(){";
     //        echo "$('#novoUsuario').modal('show');";
     //        echo "});</script>";
     echo "<!-- Modal -->";
     echo "<div class='modal fade' id='novoUsuario' tabindex='-1' role='dialog' aria-labelledby='myModalLabel'>";
     echo "  <div class='modal-dialog' role='document'>";
     echo "    <div class='modal-content'>";
     echo "      <div class='modal-header'>";
     echo "        <button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>";
     echo "        <h4 class='modal-title' id='myModalLabel'>Novo Usuário</h4>";
     echo "      </div>";
     echo "      <div class='modal-body'>";
     echo "          <form name='incluirUsuario' method='post' action='index.php?opcao=usuarios&inclusao=sim'>";
     echo "              <div class='row wow fadeInUp' data-wow-duration='1000ms' data-wow-delay='300ms'>";
     echo "                  <div class='col-sm-6'>";
     echo "                      <div class='form-group'>";
     echo "                          <input type='hidden' name='formPost' id='formPost' value='inclusao' class='form-control'>";
     echo "                          <input type='text' name='login' class='form-control' placeholder='Login' required='required'>";
     echo "                      </div>";
     echo "                  </div>";
     echo "                  <div class='col-sm-6'>";
     echo "                      <div class='form-group'>";
     echo "                          <input type='password' name='senha' class='form-control' placeholder='senha' required='required'>";
     echo "                      </div>";
     echo "                  </div>";
     echo "              </div>";
     echo "              <div class='row wow fadeInUp' data-wow-duration='1000ms' data-wow-delay='300ms'>";
     echo "                  <div class='col-sm-6'>";
     echo "                      <div class='form-group'>";
     echo "                          <input type='email' name='email' class='form-control' placeholder='E-mail' required='required'>";
     echo "                      </div>";
     echo "                  </div>";
     echo "                  <div class='col-sm-6'>";
     echo "                      <div class='form-group'>";
     echo "                          &nbsp;";
     echo "                      </div>";
     echo "                  </div>";
     echo "              </div>";
     echo "              <div class='row wow fadeInUp' data-wow-duration='1000ms' data-wow-delay='300ms'>";
     echo "                  <div class='col-sm-6'>";
     echo "                      <div class='form-group'>";
     echo "                          <select name='tipoacesso' class='form-control'>";
     echo "                              <option value='acesso'>Tipo de Acesso</option>";
     echo "                              <option value='nulo'>&nbsp;</option>";
     $acesso = new classeTipoAcesso();
     $acesso->consultaComboTipoAcesso();
     echo "                          </select>";
     echo "                      </div>";
     echo "                  </div>";
     echo "                  <div class='col-sm-6'>";
     echo "                      <div class='form-group'>";
     echo "                          <select name='status' class='form-control'>";
     echo "                              <option value='Status'>Status</option>";
     echo "                              <option value='nulo'>&nbsp;</option>";
     $status = new classeStatus();
     $status->consultaComboStatusUsuario();
     echo "                          </select>";
     echo "                      </div>";
     echo "                  </div>";
     echo "              </div>";
     echo "              <div class='row wow fadeInUp' data-wow-duration='1000ms' data-wow-delay='300ms'>";
     echo "                  <div class='col-sm-12'>";
     echo "                      <div class='form-group'>";
     echo "                          <select name='cliente' class='form-control'>";
     echo "                              <option value='Cliente'>Cliente</option>";
     echo "                              <option value='nulo'>&nbsp;</option>";
     $clientes = new classeCliente();
     $clientes->consultaComboClientes();
     echo "                          </select>";
     echo "                      </div>";
     echo "                  </div>";
     echo "              </div>";
     echo "              <div class='modal-footer'>";
     echo "                  <button type='button' class='btn btn-default' data-dismiss='modal'>Fechar</button>";
     echo "                  <button type='submit' class='btn btn-primary'>Salvar</button>";
     echo "              </div>";
     echo "          </form>";
     echo "      </div>";
     echo "    </div>";
     echo "  </div>";
     echo "</div>";
     if ($_POST['formPost'] === "inclusao") {
         $nome = filter_input(INPUT_POST, "login");
         $senha = filter_input(INPUT_POST, "senha");
         $email = filter_input(INPUT_POST, "email");
         $tipoacesso = filter_input(INPUT_POST, "tipoacesso");
         $status = filter_input(INPUT_POST, "status");
         $cliente = filter_input(INPUT_POST, "cliente");
         $data = date('Y-m-d');
         $this->setNome($nome);
         $this->setSenha($senha);
         $this->setEmail($email);
         $this->setDataCadastro($data);
         $this->setDataAlteracao($data);
         $this->setCodCliente($cliente);
         $this->setCodStatusUsuario($status);
         $this->setCodTipoAcesso($tipoacesso);
         if ($this->inserirUsuario()) {
             echo "<label class='text-success'>Usuário cadastrado com sucesso!</label>";
             echo "<meta HTTP-EQUIV='refresh' CONTENT='2;URL=index.php?opcao=usuarios'>";
         } else {
             echo "<label class='text-alert'>Usuário não cadastrado. Verifique com o seu analista de sistemas.</label>";
         }
     }
 }