initial commit

This commit is contained in:
2021-09-02 08:27:03 -03:00
commit 7a18b18c39
72 changed files with 3489 additions and 0 deletions

51
prestadores/cad_pre.php Normal file
View File

@ -0,0 +1,51 @@
<?php
if (session_status() !== PHP_SESSION_ACTIVE){
session_start();
}
include('../menu.php');
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title> Cadastro de prestadores </title>
<link rel="stylesheet" href="../css/menu.css">
<link rel="stylesheet" href="../css/forms.css">
<link rel="stylesheet" href="../css/article.css">
<link rel="stylesheet" href="../css/input.css">
</head>
<body>
<?php
echo $nav;
?>
<article>
<section class='center'>
<a href="index.php">Listar</a>
<?php if(isset($_SESSION['msg'])){?>
<div class="msg">
<?php echo $_SESSION['msg'];
unset($_SESSION['msg']);?>
</div>
<?php }?>
<p><h1> Prestadores - inclusão</h1></p>
<form method="POST" action="inc_pre.php">
<p> Nome: <input type="text" name="nome" required></p>
<p> Endereço: <input type="text" name="endereco" required></p>
<p> Complemento: <input type="text" name="complemento" required></p>
<p> Bairro: <input type="text" name="bairro" required></p>
<p> Cidade: <input type="text" name="cidade" required></p>
<p> Estado: <input type="text" name="estado" required></p>
<p> CEP: <input type="text" name="cep" required></p>
<p> Email: <input type="email" name="email" placeholder="exemplo@hotmail.com" required></p>
<p> Telefone: <input type="tel" name="telefone" placeholder="(XX)XXXX-XXXX" required></p>
<p> Celular: <input type="tel" name="celular" placeholder="(XX)XXXXX-XXXX" required></p>
<table class='input'>
<td><input class='buttons' type="submit" value="Enviar"></td>
<td><input class='buttons' type="reset" value="Limpar"></td>
</table>
</form>
</section>
</article>
<?php echo $footer;?>
</body>
</html>

33
prestadores/del_pre.php Normal file
View File

@ -0,0 +1,33 @@
<?php
session_start();
include("../conexao.php");
$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
$result = "SELECT * FROM prestadores WHERE id = '$id'";
$resultado = mysqli_query($con, $result);
$row = mysqli_fetch_assoc($resultado);
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title>Excluir Prestador</title>
</head>
<body>
<a href="index.php">Listar</a><br>
<h1>Excluir Prestadores</h1>
<?php
if(isset($_SESSION['msg'])){
echo $_SESSION['msg'];
unset($_SESSION['msg']);
}
?>
<form method="POST" action="proc_del_pre.php">
<input type="hidden" name="id" value="<?php echo $row['id']; ?>">
<label>Prestador: </label>
<input type="text" name="nome" placeholder="Digite o prestador" value="<?php echo $row['nome']; ?>"><br><br>
<input type="submit" value="Confirma exclusão">
</form>
</body>
</html>

66
prestadores/edit_pre.php Normal file
View File

@ -0,0 +1,66 @@
<?php
session_start();
include_once("../conexao.php");
include('../menu.php');
$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
$result = "SELECT * FROM prestadores WHERE id = '$id'";
$resultado = mysqli_query($con, $result);
$row = mysqli_fetch_assoc($resultado);
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title>Editar Prestadores</title>
<link rel="stylesheet" href="../css/menu.css">
<link rel="stylesheet" href="../css/forms.css">
<link rel="stylesheet" href="../css/article.css">
<link rel="stylesheet" href="../css/input.css">
</head>
<body>
<?php
echo $nav;
?>
<article>
<section class='center'>
<a href="index.php">Listar</a>
<?php if(isset($_SESSION['msg'])){?>
<div class="msg">
<?php echo $_SESSION['msg'];
unset($_SESSION['msg']);?>
</div>
<?php }?>
<h1>Alteração - Prestadores</h1>
<form method="POST" action="proc_edit_pre.php">
<input type="hidden" name="id" value="<?php echo $row['id']; ?>">
<label>Nome: </label>
<input type="text" name="nome" placeholder="Digite o prestador" value="<?php echo $row['nome']; ?>"><br><br>
<label>Endereço: </label>
<input type="text" name="endereco" placeholder="Digite o endereço" value="<?php echo $row['endereco']; ?>"><br><br>
<label>Complemento: </label>
<input type="text" name="complemento" placeholder="Digite o complemento" value="<?php echo $row['complemento']; ?>"><br><br>
<label>Bairro: </label>
<input type="text" name="bairro" placeholder="Digite o bairro" value="<?php echo $row['bairro']; ?>"><br><br>
<label>Cidade: </label>
<input type="text" name="cidade" placeholder="Digite a cidade" value="<?php echo $row['cidade']; ?>"><br><br>
<label>Estado: </label>
<input type="text" name="estado" placeholder="Digite o estado" value="<?php echo $row['estado']; ?>"><br><br>
<label>CEP: </label>
<input type="text" name="cep" placeholder="Digite o CEP" value="<?php echo $row['cep']; ?>"><br><br>
<label>Email: </label>
<input type="text" name="email" placeholder="Digite o email" value="<?php echo $row['email']; ?>"><br><br>
<label>Telefone: </label>
<input type="text" name="telefone" placeholder="Digite o telefone" value="<?php echo $row['telefone']; ?>"><br><br>
<label>Celular: </label>
<input type="text" name="celular" placeholder="Digite o celular" value="<?php echo $row['celular']; ?>"><br><br>
<table class='input'>
<td><input class='buttons' type="submit" value="Salvar"></td>
<td><input class='buttons' type="reset" value="Limpar"></td>
</table>
</form>
</section>
</article>
<?php echo $footer;?>
</body>
</html>

30
prestadores/inc_pre.php Normal file
View File

@ -0,0 +1,30 @@
<?php
if (session_status() !== PHP_SESSION_ACTIVE){
session_start();
}
$nome=(empty($_POST["nome"])) ? " ": $_POST["nome"];
$endereco=(empty($_POST["endereco"])) ? " ": $_POST["endereco"];
$complemento=(empty($_POST["complemento"])) ? " ": $_POST["complemento"];
$bairro=(empty($_POST["bairro"])) ? " ": $_POST["bairro"];
$cidade=(empty($_POST["cidade"])) ? " ": $_POST["cidade"];
$estado=(empty($_POST["estado"])) ? " ": $_POST["estado"];
$cep=(empty($_POST["cep"])) ? " ": $_POST["cep"];
$email=(empty($_POST["email"])) ? " ": $_POST["email"];
$telefone=(empty($_POST["telefone"])) ? 0.0: $_POST["telefone"];
$celular=(empty($_POST["celular"])) ? 0.0: $_POST["celular"];
include("../conexao.php");
$query= "INSERT INTO prestadores (nome, endereco, complemento, bairro, cidade, estado, cep, email, telefone, celular)
VALUES ('$nome', '$endereco', '$complemento', '$bairro', '$cidade', '$estado', '$cep', '$email', '$telefone', '$celular')";
$resu= mysqli_query($con,$query);
if (mysqli_insert_id($con)) {
$_SESSION['msg']= "<p style='color:blue;'> Prestador cadastrado com sucesso!</p>";
header('Location: index.php');
}
else{
$_session['msg']= "<p style='color:red;'> Prestador não foi cadastrado!</p>";
header('Location: index.php');
}
mysqli_close($con);
?>

95
prestadores/index.php Normal file
View File

@ -0,0 +1,95 @@
<?php
session_start();
include_once("../conexao.php");
include('../menu.php');
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title>Prestadores</title>
<link rel="stylesheet" href="../css/menu.css">
<link rel="stylesheet" href="../css/tables.css">
</head>
<body>
<?php echo $nav;?>
<section>
<?php if(isset($_SESSION['msg'])){?>
<div class="msg">
<?php echo $_SESSION['msg'];
unset($_SESSION['msg']);?>
</div>
<?php }?>
<a href="cad_pre.php">Cadastrar</a><br>
<h1>Listar Prestadores</h1>
<table border="1" width="100%">
<tr>
<td>N°</td>
<td>Prestador</td>
<td>Endereço</td>
<td>Complemento</td>
<td>Bairro</td>
<td>Cidade</td>
<td>Estado</td>
<td>CEP</td>
<td>Email</td>
<td>Telefone</td>
<td>Celular</td>
<td colspan='2'>Operações</td>
</tr>
<?php
$pagina_atual = filter_input(INPUT_GET,'pagina', FILTER_SANITIZE_NUMBER_INT);
$pagina = (!empty($pagina_atual)) ? $pagina_atual : 1;
$qnt_result_pg = 15;
$inicio = ($qnt_result_pg * $pagina) - $qnt_result_pg;
$result_usuarios = "SELECT * FROM prestadores LIMIT $inicio, $qnt_result_pg";
$resultado_usuarios = mysqli_query($con, $result_usuarios);
while($row = mysqli_fetch_assoc($resultado_usuarios)){
echo "<tr><td>" . $row['id'] . "</td><td> ";
echo $row['nome'] . "</td><td>".$row['endereco']."</td><td>".$row['complemento']."</td><td>".$row['bairro']."</td><td>".$row['cidade']."</td><td>".$row['estado']."</td><td>".$row['cep']."</td><td>".$row['email']."</td><td>".$row['telefone']."</td><td>".$row['celular']."</td><td> <a href='edit_pre.php?id=". $row['id'] . "'>Editar</a>";
echo "</td><td> <a href='del_pre.php?id=". $row['id'] . "'>Excluir </a></td></tr>";
}
echo "</table>";
$result_pg = "SELECT COUNT(id) AS num_result FROM prestadores";
$resultado_pg = mysqli_query($con, $result_pg);
$row_pg = mysqli_fetch_assoc($resultado_pg);
$quantidade_pg = ceil($row_pg['num_result'] / $qnt_result_pg);
$max_links = 2;
echo "<a href='index.php?pagina=1'>Primeira</a> ";
$paginant = $pagina - 1;
$pagprox = $pagina + 1;
if($paginant >= 1)
{
echo "<a href='index.php?pagina=$paginant'><<</a> ";
}
for($pag_ant = $pagina - $max_links; $pag_ant <= $pagina - 1; $pag_ant++){
if($pag_ant >= 1){
echo "<a href='index.php?pagina=$pag_ant'>$pag_ant</a> ";
}
}
echo "$pagina ";
for($pag_dep = $pagina + 1; $pag_dep <= $pagina + $max_links; $pag_dep++){
if($pag_dep <= $quantidade_pg){
echo "<a href='index.php?pagina=$pag_dep'>$pag_dep</a> ";
}
}
if($pagprox <= $quantidade_pg)
{
echo "<a href='index.php?pagina=$pagprox'>>></a> ";
}
echo "<a href='index.php?pagina=$quantidade_pg'>Última</a>";
?>
</section>
<?php echo $footer;?>
</body>
</html>

View File

@ -0,0 +1,26 @@
<?php
session_start();
include("../conexao.php");
$id = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT);
$nome = filter_input(INPUT_POST, 'nome', FILTER_SANITIZE_STRING);
$verif="SELECT * from orcamentos, prestadores_servicos WHERE id_prestador='$id'";
$resu= mysqli_query($con, $verif);
if (mysqli_affected_rows($con)){
$_SESSION['msg'] = "<p style='color:green;'>Este prestador não pode ser excluído, pois existe orçamento ou prestadores_serviços cadastrado</p>";
header("Location: index.php");
}else{
$result= "DELETE FROM prestadores WHERE id='$id'";
$resultado= mysqli_query($con, $result);
if(mysqli_affected_rows($con)){
$_SESSION['msg'] = "<p style='color:green;'>Prestador excluido com sucesso</p>";
header("Location: index.php");
}else{
$_SESSION['msg'] = "<p style='color:red;'>Prestador não foi excluido</p>";
header("Location: edit_pre.php?id=$id");
}
}
?>

View File

@ -0,0 +1,28 @@
<?php
session_start();
include("../conexao.php");
$id = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT);
$nome = filter_input(INPUT_POST, 'nome', FILTER_SANITIZE_STRING);
$endereco = filter_input(INPUT_POST, 'endereco', FILTER_SANITIZE_STRING);
$complemento = filter_input(INPUT_POST, 'complemento', FILTER_SANITIZE_STRING);
$bairro = filter_input(INPUT_POST, 'bairro', FILTER_SANITIZE_STRING);
$cidade = filter_input(INPUT_POST, 'cidade', FILTER_SANITIZE_STRING);
$estado = filter_input(INPUT_POST, 'estado', FILTER_SANITIZE_STRING);
$cep = filter_input(INPUT_POST, 'cep', FILTER_SANITIZE_NUMBER_INT);
$telefone = filter_input(INPUT_POST, 'telefone', FILTER_SANITIZE_STRING);
$celular = filter_input(INPUT_POST, 'celular', FILTER_SANITIZE_STRING);
$result= "UPDATE prestadores SET nome='$nome', endereco='$endereco', complemento='$complemento', bairro='$bairro', cidade='$cidade', estado='$estado', cep='$cep', telefone='$telefone', celular='$celular' WHERE id='$id'";
$resultado= mysqli_query($con, $result);
if(mysqli_affected_rows($con)){
$_SESSION['msg'] = "<p style='color:green;'>Prestador alterado com sucesso</p>";
header("Location: index.php");
}else{
$_SESSION['msg'] = "<p style='color:red;'>Prestador não foi alterado</p>";
header("Location: edit_pre.php?id=$id");
}
?>