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

View File

@ -0,0 +1,74 @@
<?php
if (session_status() !== PHP_SESSION_ACTIVE){
session_start();
}
include("../conexao.php");
include('../menu.php');
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title> Cadastro de Orçamento </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> Orçamento - Cadastro </h1></p>
<form method="POST" action="cad_orcamento2.php">
<p> Data: <input type="date" name="date_cad"></p>
<p> Valor: <input type="number" name="valor"></p>
<p> Data de Expiração: <input type="date" name="data_expiracao"></p>
<p> Observação: <input type="text" name="observacao"></p>
<label> Cliente: </label>
<select name="id_cliente">
<?php
$query = 'SELECT * FROM tbclientes ORDER BY nome';
$resu = mysqli_query($con, $query) or die(mysqli_connect_error());
while($reg = mysqli_fetch_array($resu)){
if(strcasecmp($reg['nome'],'ADMINISTRADOR') != 0){
?>
<option value="<?php echo $reg['id'];?>"><?php echo $reg['nome']?></option>
<?php
}
}
?>
</select>
<br><br>
<label> Prestadores: </label>
<select name="id_prestador">
<?php
$query = 'SELECT * FROM prestadores ORDER BY nome;';
$resu = mysqli_query($con, $query) or die(mysqli_connect_error());
while($reg = mysqli_fetch_array($resu)){
?>
<option value="<?php echo $reg['id'];?>"> <?php echo $reg['nome'];?></option>
<?php
}
?>
</select>
<br><br>
<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>

View File

@ -0,0 +1,72 @@
<?php
if (session_status() !== PHP_SESSION_ACTIVE){
session_start();
}
$id_prestador = empty($_POST['id_prestador']) ? NULL : $_POST['id_prestador'];
$id_cliente = empty($_POST['id_cliente']) ? NULL : $_POST['id_cliente'];
$date_cad = empty($_POST['date_cad']) ? NULL : $_POST['date_cad'];
$data_expiracao = empty($_POST['data_expiracao']) ? NULL : $_POST['data_expiracao'];
$observacao = empty($_POST['observacao']) ? NULL : $_POST['observacao'];
$valor = empty($_POST['valor']) ? NULL : $_POST['valor'];
if($id_prestador == NULL)
{
$_SESSION['msg'] = 'Prestador não selecionado!';
header('Location: cad_orcamento.php');
}
include("../conexao.php");
include('../menu.php');
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title> Cadastro de Orçamento </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>
<p><h1> Continuação do Cadastro </h1></p>
<form method="POST" action="inc_orcamento.php">
<input type="hidden" name="dat" value="<?php echo $date_cad; ?>">
<input type="hidden" name="valor" value="<?php echo $valor; ?>">
<input type="hidden" name="data_expiracao" value="<?php echo $data_expiracao;?>">
<input type="hidden" name="observacao" value="<?php echo $observacao;?>">
<input type="hidden" name="id_prestador" value="<?php echo $id_prestador;?>">
<input type="hidden" name="id_cliente" value="<?php echo $id_cliente;?>">
<label> Serviços: </label>
<select name="id_servico">
<?php
$query = 'SELECT * FROM consulta_prestador_servico WHERE id_prestador = ? ORDER BY servico ';
$stmt = $con->prepare($query);
$stmt->bind_param('s',$id_prestador);
$stmt->execute();
$resu = $stmt->get_result();
while($reg = $resu->fetch_assoc()){
?>
<option value="<?php echo $reg['id_servico'];?>"><?php echo $reg['servico']?></option>
<?php
}
?>
</select>
<br><br>
<table class='input'>
<td><input class='buttons' type="submit" value="Enviar"></td>
<td><button type="button" class='buttons' onclick="javascript:history.back()">Voltar</button></td>
</table>
</form>
</section>
</article>
<?php echo $footer;?>
</body>
</html>

View File

@ -0,0 +1,41 @@
<?php
session_start();
include_once("../conexao.php");
$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
$result = "SELECT * FROM orcamentos WHERE id = '$id'";
$resultado = mysqli_query($con, $result);
$row = mysqli_fetch_assoc($resultado);
include('../menu.php');
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title> Exclusão de orçamento </title>
<link rel="stylesheet" href="../css/menu.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"> Orçamentos</a><br>
<h1> Excluir orçamento </h1>
<?php
if (isset($_SESSION['msg'])) {
echo $_SESSION['msg'];
unset($_SESSION['msg']);
}
?>
<form method="POST" action="proc_del_orcamento.php">
<label> ID: </label>
<input type="text" name="id" placeholder="Digite o id do orçamento" value="<?php echo $row['id']; ?>"><br><br>
<input class='buttons' type="submit" value="Confirmar exclusão">
</form>
</section>
</article>
<?php echo $footer;?>
</body>
</html>

View File

@ -0,0 +1,71 @@
<?php
session_start();
include_once("../conexao.php");
include('../menu.php');
$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
$result = "SELECT * FROM orcamentos WHERE id = '$id'";
$resultado = mysqli_query($con, $result);
$row = mysqli_fetch_assoc($resultado);
$id_cli = $row['id_cliente'];
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title> Editar orçamento </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> Alterar orçamentos </h1>
<form method="POST" action="proc_edit_orcamento.php">
<input type="hidden" name="id" value="<?php echo $row['id']; ?>">
<input type="hidden" name="id_prestador" value="<?php echo $row['id_prestador']; ?>">
<input type="hidden" name="id_cliente" value="<?php echo $row['id_cliente']; ?>">
<input type="hidden" name="id_servico" value="<?php echo $row['id_servico']; ?>">
<p>Data: <input type="date" name="data" value="<?php echo $row['data'];?>"></p>
<p>Valor: <input type="number" name="valor" value="<?php echo $row['valor'];?>"></p>
<p>Data de expiração: <input type="date" name="data_expiracao" value="<?php echo $row['data_expiracao'];?>"></p>
<p>Oberservação: <input type="text" name="observacao" value="<?php echo $row['observacao'];?>"></p>
<label> Cliente: </label>
<select name="id_cliente">
<?php
$query = 'SELECT * FROM tbclientes ORDER BY nome';
$resu = mysqli_query($con, $query) or die(mysqli_connect_error());
while($reg = mysqli_fetch_array($resu)){
if(strcasecmp($reg['nome'],'ADMINISTRADOR') != 0){
?>
<option value="<?php echo $reg['id'];?>" <?php if($reg['id'] == $id_cli) echo "selected";?>><?php echo $reg['nome']?></option>
<?php
}
}
?>
</select><br><br>
<p><a class='button' href='edit_servico.php?id=<?php echo $id?>'>Alterar Serviço</a></p>
<p><a class='button' href='edit_prestador.php?id=<?php echo $id?>&id_pre=<?php echo $row['id_prestador']?>'>Alterar Prestador</a></p>
<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>

View File

@ -0,0 +1,60 @@
<?php
session_start();
include_once("../conexao.php");
include('../menu.php');
$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
$id_pre = filter_input(INPUT_GET, 'id_pre', FILTER_SANITIZE_NUMBER_INT);
$result = "SELECT * FROM prestadores;";
$resultado = mysqli_query($con, $result);
$row = mysqli_fetch_assoc($resultado);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title> Editar orçamento - Prestador </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>
<a href="javascript:history.back()">Voltar</a>
<?php if(isset($_SESSION['msg'])){?>
<div class="msg">
<?php echo $_SESSION['msg'];
unset($_SESSION['msg']);?>
</div>
<?php }?>
<h1> Alterar Prestador </h1>
<form method="POST" action="edit_servico.php">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<label> Prestadores: </label>
<select name="id_prestador">
<?php
$query= 'SELECT * from prestadores ORDER BY nome;';
$resu = mysqli_query($con,$query) or die(mysqli_connect_error());
while ($reg = mysqli_fetch_array($resu)){
?>
<option value="<?php echo $reg['id'];?>" <?php if($reg['id'] == $id_pre) echo "selected";?>> <?php echo $reg['nome'];?> </option>
<?php
}
?>
</select>
<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>

View File

@ -0,0 +1,70 @@
<?php
session_start();
include_once("../conexao.php");
include('../menu.php');
$id = (empty($_POST['id']) ? $_GET['id']: $_POST['id']);
$result = "SELECT * FROM orcamentos WHERE id = '$id'";
$resultado = mysqli_query($con, $result);
$row = mysqli_fetch_assoc($resultado);
$id_prest = (empty($_POST['id_prestador']) ? $row['id_prestador'] : $_POST['id_prestador']);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title> Editar orçamento </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>
<a href="javascript:history.back()">Voltar</a>
<?php if(isset($_SESSION['msg'])){?>
<div class="msg">
<?php echo $_SESSION['msg'];
unset($_SESSION['msg']);?>
</div>
<?php }?>
<h1> Alterar orçamentos </h1>
<form method="POST" action="proc_edit_orcamento.php">
<input type="hidden" name="id" value="<?php echo $row['id']; ?>">
<input type="hidden" name="data" value="<?php echo $row['data'];?>">
<input type="hidden" name="valor" value="<?php echo $row['valor'];?>">
<input type="hidden" name="data_expiracao" value="<?php echo $row['data_expiracao'];?>">
<input type="hidden" name="observacao" value="<?php echo $row['observacao'];?>">
<input type="hidden" name="id_cliente" value="<?php echo $row['id_cliente'];?>">
<input type="hidden" name="id_prestador" value="<?php echo $id_prest;?>">
<label> Serviços: </label>
<select name="id_servico">
<?php
$query = 'SELECT * FROM consulta_prestador_servico WHERE id_prestador = ? ORDER BY servico ';
$stmt = $con->prepare($query);
$stmt->bind_param('s',$id_prest);
$stmt->execute();
$resu = $stmt->get_result();
while($reg = $resu->fetch_assoc()){
?>
<option value="<?php echo $reg['id_servico'];?>"><?php echo $reg['servico']?></option>
<?php
}
?>
</select>
<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>

View File

@ -0,0 +1,27 @@
<?php
if (session_status() !== PHP_SESSION_ACTIVE){
session_start();
}
$data = (empty($_POST["dat"])) ? 0: $_POST["dat"];
$valor = (empty($_POST["valor"])) ? 0: $_POST["valor"];
$id_prestador = (empty($_POST["id_prestador"])) ? 0: $_POST["id_prestador"];
$data_expiracao = (empty($_POST["data_expiracao"])) ? 0: $_POST["data_expiracao"];
$id_cliente = (empty($_POST["id_cliente"])) ? 0: $_POST["id_cliente"];
$id_servico = (empty($_POST["id_servico"])) ? 0: $_POST["id_servico"];
$observacao = (empty($_POST["observacao"])) ? " ": $_POST["observacao"];
include('../conexao.php');
$query = "INSERT INTO orcamentos (data, valor, id_prestador, data_expiracao, id_cliente, id_servico, observacao)
VALUES ('$data', '$valor', '$id_prestador', '$data_expiracao', '$id_cliente', '$id_servico', '$observacao')";
$resu = mysqli_query($con, $query);
if (mysqli_insert_id($con)) {
$_SESSION['msg'] = "<p style='color: blue;'> Orçamento cadastrado com sucesso!</p>";
header('Location: index.php');
}
else{
$_SESSION['msg'] = "<p style='color: red;'> Orçamento não foi cadastrado!</p>";
header('Location: index.php');
}
mysqli_close($con);
?>

102
orcamento/index.php Normal file
View File

@ -0,0 +1,102 @@
<?php
session_start();
include_once("../conexao.php");
include_once("../menu.php");
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title>Orçamentos</title>
<link rel="stylesheet" href="../css/menu.css">
<link rel="stylesheet" href="../css/tables.css">
</head>
<body>
<?php echo $nav;?>
<section>
<a href="cad_orcamento.php">Cadastrar</a><br>
<?php if(isset($_SESSION['msg'])){?>
<div class="msg">
<?php echo $_SESSION['msg'];
unset($_SESSION['msg']);?>
</div>
<?php }?>
<h1>Listar orçamentos</h1>
<table border="1" width="100%">
<tr>
<td>N°</td>
<td>Data de Abertura</td>
<td>Valor</td>
<td>Data Expiração</td>
<td>Cliente</td>
<td>Prestador</td>
<td>Serviço</td>
<td>Observação</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_orcamentos = "SELECT * FROM consulta_orcamentos LIMIT $inicio, $qnt_result_pg";
$resultado_orcamentos = mysqli_query($con, $result_orcamentos);
while($row = mysqli_fetch_assoc($resultado_orcamentos)){
echo "<tr><td>" . $row['orcamento']."</td>" ;
echo "<td>" . $row['data']."</td>";
echo "<td>R$" . $row['valor']."</td>";
echo "<td>" . $row['data_expiracao']."</td>";
echo "<td>" . $row['cliente']."</td>";
echo "<td>" . $row['prestador']."</td>";
echo "<td>" . $row['servico']."</td>";
echo "<td>" . $row['observacao']."</td>";
echo "<td> <a href='edit_orcamento.php?id=". $row['orcamento'] . "'>Editar </a></td>";
echo "<td> <a href='del_orcamento.php?id=". $row['orcamento'] . "'>Excluir </a></td></tr>";
}
echo "</table>";
$result_pg = "SELECT COUNT(orcamento) AS num_result FROM consulta_orcamentos";
$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,18 @@
<?php
session_start();
include_once("../conexao.php");
$id = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT);
$result= "DELETE FROM orcamentos WHERE id='$id'";
$resultado= mysqli_query($con, $result);
if(mysqli_affected_rows($con)){
$_SESSION['msg'] = "<p style='color:green;'> Orçamento excluído com sucesso</p>";
header("Location: index.php");
}else{
$_SESSION['msg'] = "<p style='color:red;'> Orçamento não foi excluído</p>";
header("Location: edit_orcamento.php?id=$id");
}
?>

View File

@ -0,0 +1,26 @@
<?php
session_start();
include_once("../conexao.php");
$id = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT);
$data = filter_input(INPUT_POST, 'data', FILTER_SANITIZE_STRING);
$valor = filter_input(INPUT_POST, 'valor', FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
$id_prestador = filter_input(INPUT_POST, 'id_prestador', FILTER_SANITIZE_NUMBER_INT);
$data_expiracao = filter_input(INPUT_POST, 'data_expiracao', FILTER_SANITIZE_STRING);
$id_cliente = filter_input(INPUT_POST, 'id_cliente', FILTER_SANITIZE_NUMBER_INT);
$id_servico = filter_input(INPUT_POST, 'id_servico', FILTER_SANITIZE_NUMBER_INT);
$observacao = filter_input(INPUT_POST, 'observacao', FILTER_SANITIZE_STRING);
$result= "UPDATE orcamentos SET data='$data', valor='$valor', id_prestador='$id_prestador', data_expiracao='$data_expiracao', id_cliente='$id_cliente', id_servico='$id_servico', observacao='$observacao' WHERE id='$id'";
$resultado= mysqli_query($con, $result);
if(mysqli_affected_rows($con)){
$_SESSION['msg'] = "<p style='color:green;'>Orçamento alterado com sucesso!</p>";
header("Location: index.php");
}else{
$_SESSION['msg'] = "<p style='color:red;'>Orçamento não foi alterado</p>";
header("Location: edit_orcamento.php?id=$id");
}
?>