Skip to content

Commit

Permalink
adicionando a função de exporta para planilha.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielprospero committed Apr 17, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 1175211 commit fc4750b
Showing 130 changed files with 119,226 additions and 2 deletions.
2 changes: 1 addition & 1 deletion conecta.php
Original file line number Diff line number Diff line change
@@ -2,6 +2,6 @@
//$conexao = mysqli_connect("192.168.0.20:3306", "root", "192345", "cafeimetrodb");
//mysqli_set_charset($conexao, 'utf8');

$conexao = new mysqli("192.168.0.17:3306", "root", "192345", "cafeimetrodb");
$conexao = new mysqli("192.168.0.18:3306", "prospero", "192345", "cafeimetrodb");
$conexao->set_charset('utf8');
?>
40 changes: 40 additions & 0 deletions consumo-lista-planilha.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
include 'conecta.php';
include 'consumo-banco.php';

$o_arquivo = "meu-consumo.xls";

$html = "<meta charset='utf-8'>";
$html .= "<table border='1'>
<tr>
<td>Data Consumo</td>
<td>Hora Consumo</td>
<td>Dia Semana</td>
<td>Café</td>
<td>Qtd</td>
<td>R$ Preço</td>
</tr>";

$consumos = listaConsumo($conexao);
foreach ($consumos as $consumo)
{
$html .= "<tr>
<td>{$consumo["data_consumo"]}</td>
<td>{$consumo["hora_consumo"]}</td>
<td>{$consumo["dia_semana"]}</td>
<td>{$consumo["cafe_nome"]}</td>
<td>{$consumo["qtd"]}</td>
<td>{$consumo["preco"]}</td>
</tr>";
}

$html .= "</table>";

header("content-Type: application/xls");
header("content-Disposition:attachment; filename=" . $o_arquivo);
header("content-Discription: Dados gerados via PHP.");

echo $html;



42 changes: 42 additions & 0 deletions consumo-lista-report.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
include 'cabecalho-menu.php';
include 'conecta.php';
include 'consumo-banco.php';
?>
<h1>O que eu já consumir...</h1>

<button class="btn btn-primary" onclick="window.location.href='consumo-form-adiciona.php'">Mais café</button></button>
<button class="btn btn-secondary" onclick="window.open('consumo-lista-planilha.php', 'blank')">Exportar para planilha</button></button>
<button class="btn btn-secondary" onclick="window.open('consumo-lista-report.php', 'blank')">Relatório</button></button> <br> <br>


<table class="table table-striped table-bordered">

<?php
$consumos = listaConsumo($conexao);
foreach ($consumos as $consumo)
{
?>
<tr>
<td><?=$consumo['data_consumo']?></td>
<td><?=$consumo['hora_consumo']?></td>
<td><?=$consumo['dia_semana']?></td>
<td><?=$consumo['cafe_nome']?></td>
<td><?=$consumo['qtd']?>ml</td>
<td>R$ <?=number_format($consumo['preco'],2,',','.')?></td>
<td>
<form name="form-remove" method="post" action="consumo-exclui.php">
<input type="hidden" name="id" value="<?=$consumo['consumo_id']?>" />
<button class="btn btn-danger">remove</button>
</form>
</td>
</tr>
<?php
}
?>

</table>

<?php
include 'rodape.php';
?>
5 changes: 4 additions & 1 deletion consumo-lista.php
Original file line number Diff line number Diff line change
@@ -5,7 +5,10 @@
?>
<h1>O que eu já consumir...</h1>

<button class="btn btn-primary"onclick="window.location.href='consumo-form-adiciona.php'">Mais café</button></button> <br> <br>
<button class="btn btn-primary" onclick="window.location.href='consumo-form-adiciona.php'">Mais café</button></button>
<button class="btn btn-secondary" onclick="window.open('consumo-lista-planilha.php', 'blank')">Exportar para planilha</button></button>
<button class="btn btn-secondary" onclick="window.open('consumo-lista-report.php', 'blank')">Relatório</button></button> <br> <br>


<table class="table table-striped table-bordered">

Loading

0 comments on commit fc4750b

Please sign in to comment.