Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexavierDev committed Feb 4, 2024
0 parents commit a577318
Show file tree
Hide file tree
Showing 23 changed files with 895 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Easy Vagas 🚘
<img src="img/index-screenshot.png">



![GitHub last commit](https://img.shields.io/github/last-commit/alexavierdev/CRUD-PHP)

O Easy Vagas é uma aplicação desenvolvida para gerenciar estacionamentos de veículos, permitindo o registro de entrada e saída, além de fornecer informações relevantes para o controle eficiente como horarios de entrada e saida, placas e etc.

# Funcionalidades

### Registro de Veículos:
- Adição de novos veículos com detalhes como nome do proprietário, categoria, modelo, placa e cor.
- Validação da placa do veículo.
- Registro de Saída

### Listagem de Veículos:
- Visualização de todos os veículos registrados.
- Filtragem por veículos que já saíram e os que ainda estão no estacionamento.
### Gestão de Funcionários:
Cadastro de novos funcionários com diferentes níveis de permissão (ADMIN, FUNCIONARIO).

# Tecnologias Utilizadas

[![PHP](https://img.shields.io/badge/PHP-8.0.-blue.svg)](https://www.php.net/releases/7_4_12.php)

[![MySQL](https://img.shields.io/badge/MySQL-8.0-blue.svg)](https://dev.mysql.com/doc/relnotes/mysql/8.0/en/)

[![Bootstrap](https://img.shields.io/badge/Bootstrap-5.0-blueviolet.svg)](https://getbootstrap.com/docs/4.5/getting-started/introduction/)


# Como Usar

1. Clone este repositório para o seu ambiente local.
2. Importe o arquivo `database.sql` para criar a tabela de tarefas no banco de dados.
3. Configure o acesso ao banco de dados no arquivo `actions/connectDB.php`.
4. Inicie um servidor PHP local ou utilize algum serviço de hospedagem que suporte PHP e MySQL.
5. Acesse o projeto através do navegador e comece a utilizar o Easy Vagas.
6. Login: admin@easyvagas.com || Senha: 123


# Licença

Este projeto é de código aberto e está sob a licença [MIT](https://opensource.org/licenses/MIT).

# Redes Sociais
[![Instagram](https://img.shields.io/badge/Instagram-%23E4405F.svg?&style=for-the-badge&logo=Instagram&logoColor=white)](https://www.instagram.com/alexavierdev)
[![LinkedIn](https://img.shields.io/badge/LinkedIn-%230077B5.svg?&style=for-the-badge&logo=LinkedIn&logoColor=white)](https://www.linkedin.com/in/alexsandroxavier)


33 changes: 33 additions & 0 deletions actions/cadastrarFuncionario.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

require_once 'connectBD.php';

function clearInput($input){
global $connectBD;
$inputClear = mysqli_escape_string($connectBD, $input);
$inputClear = htmlspecialchars($inputClear);
return $inputClear;
}

if (isset($_POST['btn-cadastrar'])){
$nome = clearInput($_POST['nomeFuncionario']);
$email = clearInput(filter_var($_POST['email'], FILTER_SANITIZE_EMAIL));
$senha = clearInput($_POST['senha']);
$nivelPermissao = clearInput($_POST['nivelPermissao']);
$hashedSenha = password_hash($senha, PASSWORD_BCRYPT);

$sql = "INSERT INTO usuarios (nome, email, senha, nivel_permissao) VALUES (?, ?, ?, ?)";
$stmt = mysqli_prepare($connectBD, $sql);

mysqli_stmt_bind_param($stmt, "ssss", $nome, $email, $hashedSenha, $nivelPermissao);

if (mysqli_stmt_execute($stmt)) {
header('location:../pages/cadastrarFuncionario.php?sucesso=3');
} else {
header('location:../pages/cadastrarFuncionario.php?erro=3');
}

mysqli_stmt_close($stmt);


}
12 changes: 12 additions & 0 deletions actions/connectBD.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

$nameserver = 'localhost';
$user = 'root';
$password = '';
$nameBD = 'parksystem';

$connectBD = mysqli_connect($nameserver, $user, $password, $nameBD);

if (!$connectBD) {
die("Falha na conexão com o banco de dados: " . mysqli_connect_error());
}
43 changes: 43 additions & 0 deletions actions/login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
session_start();
require_once 'connectBD.php';
include 'registrar.php';


if (isset($_POST['btn-login'])) {

$email = clearInput($_POST['loginEmail']);
$senha = clearInput($_POST['loginSenha']);
$sql = "SELECT * FROM usuarios WHERE email = '$email'";
$resultado = mysqli_query($connectBD,$sql);

if (mysqli_num_rows($resultado) > 0){
//usuario ENCONTRADO
$usuario = mysqli_fetch_assoc($resultado);
$hash = $usuario['senha'];

if (password_verify($senha,$hash)){
//usuario verificado, senha CORRETA

$_SESSION['permissao'] = $usuario['nivel_permissao'];
$_SESSION['usuario'] = $usuario['nome'];
$_SESSION['logado'] = true;
header('location:../pages/listarVeiculos.php');
exit();
}else{
//usuario nao verificado, senha INCORRETA
header('location:../index.php?erro=4');
}

}else{
//usuario nao encontrado
header('location:../index.php?erro=5');
}

}






5 changes: 5 additions & 0 deletions actions/logout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
session_start();
session_unset();
session_destroy();
header('location:../index.php');
37 changes: 37 additions & 0 deletions actions/registrar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
//ADICIONA A CONEXÃO COM BANCO DE DADOS
require_once 'connectBD.php';

//FUNCAO PARA LIMPAR OS INPUTS ANTES DE INSERIR NO BD
function clearInput($input){
global $connectBD;
$inputClear = mysqli_escape_string($connectBD, $input);
$inputClear = htmlspecialchars($inputClear);
return $inputClear;
}


if(isset($_POST['btn-registrar'])){
$nomePropietario = clearInput($_POST['nomePropietario']);
$categoria = clearInput($_POST['categoriaVeiculo']);
$modelo = clearInput($_POST['modelo']);
$placa = clearInput($_POST['placa']);
$cor = clearInput($_POST['cor']);

//QUERY PARA INSERÇÃO DO DADOS NO BD
$sql = "INSERT INTO veiculos (nome_proprietario, categoria, modelo, placa, cor) VALUES ('$nomePropietario', '$categoria','$modelo', '$placa', '$cor')";

if (mysqli_query($connectBD, $sql)){
header('location:../pages/listarVeiculos.php?sucesso=1');
}else{
header('../pages/listarVeiculos.php?sucesso=1');
}


}




?>

15 changes: 15 additions & 0 deletions actions/registrarSaida.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

require_once 'connectBD.php';


if (isset($_GET['id'])){
$id = $_GET['id'];
$sql = "UPDATE veiculos SET hora_saida = NOW() WHERE id = '$id'";
$resultado = mysqli_query($connectBD,$sql);
header('location:../pages/listarVeiculos.php?sucesso=2');
}




17 changes: 17 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
*{
margin: 0;
padding: 0;
box-sizing: border-box;

}

#container{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
}



96 changes: 96 additions & 0 deletions database.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
-- phpMyAdmin SQL Dump
-- version 5.2.0
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Tempo de geração: 04-Fev-2024 às 09:47
-- Versão do servidor: 8.0.31
-- versão do PHP: 8.0.26

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Banco de dados: `parksystem`
--

-- --------------------------------------------------------

--
-- Estrutura da tabela `usuarios`
--

DROP TABLE IF EXISTS `usuarios`;
CREATE TABLE IF NOT EXISTS `usuarios` (
`id` int NOT NULL AUTO_INCREMENT,
`nome` varchar(100) DEFAULT NULL,
`email` varchar(100) DEFAULT NULL,
`senha` varchar(255) DEFAULT NULL,
`nivel_permissao` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Extraindo dados da tabela `usuarios`
--

INSERT INTO `usuarios` (`id`, `nome`, `email`, `senha`, `nivel_permissao`) VALUES
(17, 'Admin', 'admin@easyvagas.com', '$2y$10$cNO7qWWZdnXh9xQdIUF6QesFU57VXgZp7CziiBGWRoMrRBT1i8KFO', 'ADMIN'),
(16, 'Funcionario 01', 'funcionario@easyvagas.com', '$2y$10$0UiyD7R670.WfECvbHQqiudp/MIUQrWK43uZuObA7q601u6/z5vlC', 'FUNCIONARIO');

-- --------------------------------------------------------

--
-- Estrutura da tabela `veiculos`
--

DROP TABLE IF EXISTS `veiculos`;
CREATE TABLE IF NOT EXISTS `veiculos` (
`id` int NOT NULL AUTO_INCREMENT,
`nome_proprietario` varchar(100) NOT NULL,
`categoria` enum('CARRO','MOTO','CAMINHAO') NOT NULL,
`modelo` varchar(100) NOT NULL,
`placa` varchar(20) NOT NULL,
`cor` varchar(50) NOT NULL,
`data_registro` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`hora_saida` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Extraindo dados da tabela `veiculos`
--

INSERT INTO `veiculos` (`id`, `nome_proprietario`, `categoria`, `modelo`, `placa`, `cor`, `data_registro`, `hora_saida`) VALUES
(19, 'CARLOS', 'CARRO', 'CELTA', 'ABC1234', 'AMARELO', '2023-09-13 11:55:06', '2023-09-13 10:13:27'),
(6, 'ALEXSANDRO', 'CARRO', 'HILUX', 'NCO-4920', 'PRETO', '2023-07-24 23:27:58', '2023-07-25 13:32:20'),
(7, 'ALEXSANDRO', 'CARRO', 'HILUX', 'NCO-4920', 'PRETO', '2023-07-24 23:29:36', '2023-07-25 13:34:34'),
(8, 'ALEXSANDRO', 'CARRO', 'HILUX', 'NCO-4920', 'PRETO', '2023-07-24 23:34:24', '2023-07-25 13:36:56'),
(9, 'DSDS', 'CAMINHAO', 'HILUX', 'IAC-123444S', 'PRETO', '2023-07-25 01:44:59', '2023-07-25 13:23:41'),
(10, 'ALEXSANDRO', 'CARRO', 'HILUX', 'ABC-1234', 'PRETO', '2023-07-25 02:08:05', '2023-07-25 13:41:17'),
(11, 'ALEXSANDRO', 'CAMINHAO', 'HILUX', 'ASASASAS', 'PRETO', '2023-07-25 02:08:56', '2023-07-25 13:23:10'),
(12, 'ALEXSANDRO', 'CARRO', 'HILUX', 'ABC-1234', 'PRETO', '2023-07-25 02:26:29', '2023-07-25 14:32:44'),
(13, 'ALEXSANDRO', 'CARRO', 'HILUX', 'ABC1234', 'PRETO', '2023-07-25 12:49:29', '2023-07-25 14:41:15'),
(14, 'ALEXSANDRO', 'CAMINHAO', 'HILUX', 'ABC1234', 'PRETO', '2023-07-25 13:06:58', '2023-07-25 14:43:21'),
(15, 'ALEXSANDRO', 'CARRO', 'HILUX', 'NCO-4920', 'PRETO', '2023-07-25 17:41:26', '2023-07-26 21:13:22'),
(16, 'JOSE', 'CAMINHAO', 'HILUX', 'ABC1234', 'PRETO', '2023-07-25 17:41:42', '2023-07-27 11:06:24'),
(17, 'JOSE', 'CAMINHAO', 'MERCEDES', 'ABC1234', 'PRETO', '2023-07-25 19:20:47', '2023-07-25 16:20:58'),
(18, 'JOSE', 'CARRO', 'HILUX', 'ABC1234', 'SDSDS', '2023-07-26 22:54:34', '2023-09-13 08:42:28'),
(20, 'ROBSON', 'MOTO', 'HONDA 160', 'ABC1234', 'PRETO', '2023-09-13 11:56:32', '2023-09-13 10:13:52'),
(21, 'ROBSON', 'MOTO', 'HONDA 160', 'ABC1234', 'PRETO', '2023-09-13 11:57:12', '2023-09-13 10:16:30'),
(22, 'ROBSON', 'CAMINHAO', 'SCANIA', 'ABC1234', 'PRETO', '2023-09-13 11:57:33', '2023-09-13 10:22:34'),
(23, 'ROBSON', 'CAMINHAO', 'SCANIA', 'ABC1234', 'PRETO', '2023-09-13 11:58:18', '2024-02-04 05:36:36'),
(24, 'TESTE', 'CARRO', 'SCANIA', 'ABC1234', 'PRETO', '2024-02-04 08:37:11', '2024-02-04 05:37:43'),
(25, 'JOSE', 'CARRO', 'HILUX', 'ABC1234', 'PRETO', '2024-02-04 08:38:09', NULL);
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Binary file added img/easy-vagas-logotipo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/favicon-easy-vagas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/index-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/teste.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions includes/footer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

<footer class="text-center text-white" style="background-color: #f1f1f1;">
<!-- Grid container -->
<div class="container pt-4">
<!-- Section: Social media -->
<section class="mb-4">
<!-- Instagram -->
<a
class="btn btn-link btn-floating btn-lg text-dark m-1"
href="https://www.instagram.com/alexavierdev/"
role="button"
data-mdb-ripple-color="dark"
><i class="fab fa-instagram"></i
></a>
<!-- Linkedin -->
<a
class="btn btn-link btn-floating btn-lg text-dark m-1"
href="https://www.linkedin.com/in/alexsandroxavier/"
role="button"
data-mdb-ripple-color="dark"
><i class="fab fa-linkedin"></i
></a>
<!-- Github -->
<a
class="btn btn-link btn-floating btn-lg text-dark m-1"
href="https://github.com/AlexavierDev"
role="button"
data-mdb-ripple-color="dark"
><i class="fab fa-github"></i
></a>
</section>
</div>
<!-- Grid container -->
<!-- Copyright -->
<div class="text-center text-dark p-3" style="background-color: rgba(0, 0, 0, 0.2);">
Copyrigth @ <span id="anoAtual"></span>
<a class="text-dark" target="_blank" href="https://github.com/AlexavierDev">Alex Xavier</a>
</div>
<!-- Copyright -->
</footer>
<script>
let date = new Date();
let anoAtual = date.getFullYear();
let anoCopyrigth = document.getElementById('anoAtual');
anoCopyrigth.innerText = anoAtual;
</script>
</body>
</html>
Loading

0 comments on commit a577318

Please sign in to comment.