Skip to content

Commit

Permalink
Melhorias nos relatorios (RamonSilva20#1358)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoshikawakun authored May 22, 2021
1 parent 99f833a commit ea68761
Show file tree
Hide file tree
Showing 12 changed files with 410 additions and 424 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ application/vendor/
vendor/
.idea/
.php_cs.cache
.php-cs-fixer.cache
application/logs/*
ci_sessions/

Expand Down
4 changes: 2 additions & 2 deletions .php_cs → .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
->name('*.php')
->notName('*.blade.php');

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
])
->setFinder($finder);
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ e [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [4.17.0] - 2020-10-04

## Added

- Modificado filtros de lançamentos para permitir período arbitrário de data e adicionado filtro de status. [@Pr3d4dor](https://github.com/Pr3d4dor)

## [4.16.0] - 2020-10-04
Expand Down
36 changes: 26 additions & 10 deletions application/controllers/Relatorios.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public function clientesRapid()
'CEP' => 'string',
'Contato' => 'string',
'Complemento' => 'string',
'Fornecedor' => 'string',
];

$writer = new XLSXWriter();
Expand Down Expand Up @@ -740,28 +741,36 @@ public function vendasRapid()
if ($format == 'xls') {
$vendasFormatadas = array_map(function ($item) {
return [
'#' => $item['idVendas'],
'cliente' => $item['nomeCliente'],
'total' => $item['valorTotal'] ?: 0,
'data' => $item['dataVenda'],
'vendedor' => $item['nome'],
'data' => $item['dataVenda'],
'total' => $item['valorTotal'] ?: 0,
];
}, $vendas);

$cabecalho = [
'#' => 'string',
'Cliente' => 'string',
'Total' => 'price',
'Data' => 'YYYY-MM-DD',
'Vendedor' => 'string',
'Data' => 'DD-MM-YYYY',
'Total' => 'price',
];

$writer = new XLSXWriter();

$writer->writeSheetRow(null, []);
$writer->writeSheetHeader('Sheet1', $cabecalho);
foreach ($vendasFormatadas as $venda) {
$writer->writeSheetRow('Sheet1', $venda);
}
$writer->writeSheetRow(null, []);
$writer->writeSheetRow(null, []);
$writer->writeSheetRow(null, []);
$writer->writeSheetRow('Sheet1', []);
$writer->writeSheetRow('Sheet1', [
null,
null,
null,
null,
$totalVendas,
]);
Expand Down Expand Up @@ -808,28 +817,35 @@ public function vendasCustom()
if ($format == 'xls') {
$vendasFormatadas = array_map(function ($item) {
return [
'#' => $item['idVendas'],
'cliente' => $item['nomeCliente'],
'total' => $item['valorTotal'] ?: 0,
'data' => $item['dataVenda'],
'vendedor' => $item['nome'],
'data' => $item['dataVenda'],
'total' => $item['valorTotal'] ?: 0,
];
}, $vendas);

$cabecalho = [
'#' => 'string',
'Cliente' => 'string',
'Total' => 'price',
'Data' => 'YYYY-MM-DD',
'Vendedor' => 'string',
'Data' => 'DD-MM-YYYY',
'Total' => 'price',
];

$writer = new XLSXWriter();

$writer->writeSheetHeader('Sheet1', $cabecalho);
foreach ($vendasFormatadas as $venda) {
$writer->writeSheetRow('Sheet1', $venda);
}
$writer->writeSheetRow(null, []);
$writer->writeSheetRow(null, []);
$writer->writeSheetRow(null, []);
$writer->writeSheetRow('Sheet1', []);
$writer->writeSheetRow('Sheet1', [
null,
null,
null,
null,
$totalVendas,
]);
Expand Down
38 changes: 26 additions & 12 deletions application/models/Relatorios_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,27 @@ public function clientesRapid($array = false)

public function produtosRapid()
{
$this->db->order_by('descricao', 'asc');
$query = "
SELECT produtos.*, SUM(produtos.estoque * produtos.precoVenda) as valorEstoque
FROM produtos
GROUP BY produtos.idProdutos
ORDER BY descricao
";

return $this->db->get('produtos')->result();
return $this->db->query($query)->result();
}

public function produtosRapidMin()
{
$this->db->order_by('descricao', 'asc');
$this->db->where('estoque <= estoqueMinimo');
$query = "
SELECT produtos.*, SUM(produtos.estoque * produtos.precoVenda) as valorEstoque
FROM produtos
WHERE estoque <= estoqueMinimo
GROUP BY produtos.idProdutos
ORDER BY descricao
";

return $this->db->get('produtos')->result();
return $this->db->query($query)->result();
}

public function produtosCustom($precoInicial = null, $precoFinal = null, $estoqueInicial = null, $estoqueFinal = null)
Expand All @@ -120,7 +130,13 @@ public function produtosCustom($precoInicial = null, $precoFinal = null, $estoqu
if ($estoqueInicial != null) {
$whereEstoque = "AND estoque BETWEEN " . $this->db->escape($estoqueInicial) . " AND " . $this->db->escape($estoqueFinal);
}
$query = "SELECT * FROM produtos WHERE estoque >= 0 $wherePreco $whereEstoque ORDER BY descricao";
$query = "
SELECT produtos.*, SUM(produtos.estoque * produtos.precoVenda) as valorEstoque
FROM produtos
WHERE estoque >= 0 $wherePreco $whereEstoque
GROUP BY produtos.idProdutos
ORDER BY descricao
";

return $this->db->query($query)->result();
}
Expand Down Expand Up @@ -339,12 +355,11 @@ public function financeiroCustom($dataInicial = null, $dataFinal = null, $tipo =

public function vendasRapid($array = false)
{
$this->db->select('vendas.*,clientes.nomeCliente, usuarios.nome,itens_de_vendas.subTotal as valorTotal, itens_de_vendas.vendas_id');
$this->db->select('vendas.*,clientes.nomeCliente, usuarios.nome');
$this->db->from('vendas');
$this->db->join('clientes', 'clientes.idClientes = vendas.clientes_id');
$this->db->join('usuarios', 'usuarios.idUsuarios = vendas.usuarios_id');
$this->db->join('itens_de_vendas', 'itens_de_vendas.vendas_id = vendas.idVendas');
$this->db->order_by('vendas.dataVenda', 'DESC');
$this->db->order_by('vendas.idVendas', 'ASC');

$result = $this->db->get();
if ($array) {
Expand Down Expand Up @@ -373,11 +388,10 @@ public function vendasCustom($dataInicial = null, $dataFinal = null, $cliente =
$whereResponsavel = "AND usuarios_id = " . $this->db->escape($responsavel);
}

$query = "SELECT vendas.*,clientes.nomeCliente, usuarios.nome,itens_de_vendas.subTotal as valorTotal, itens_de_vendas.vendas_id FROM vendas
$query = "SELECT vendas.*,clientes.nomeCliente, usuarios.nome FROM vendas
LEFT JOIN clientes ON vendas.clientes_id = clientes.idClientes
LEFT JOIN usuarios ON vendas.usuarios_id = usuarios.idUsuarios
LEFT JOIN itens_de_vendas ON itens_de_vendas.vendas_id = vendas.idVendas
WHERE idVendas != 0 $whereData $whereCliente $whereResponsavel ORDER BY vendas.dataVenda";
WHERE idVendas != 0 $whereData $whereCliente $whereResponsavel ORDER BY vendas.idVendas";

$result = $this->db->query($query);
if ($array) {
Expand Down
73 changes: 31 additions & 42 deletions application/views/relatorios/imprimir/imprimirClientes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
<html>

<head>
<title>MAPOS - <?= $title ?>
</title>
<title>MAPOS</title>
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
Expand All @@ -21,52 +20,42 @@
<div class="widget-box">
<?= $topo ?>
<div class="widget-title">
<h4 style="text-align: center">
<?= $title ?>
<h4 style="text-align: center; font-size: 1.1em; padding: 5px;">
<?= ucfirst($title) ?>
</h4>
<br>
</div>
<div class="widget-content nopadding tab-content">
<table class="table table-bordered">
<thead>
<tr>
<th style="font-size: 1.2em; padding: 5px;">Nome</th>
<th style="font-size: 1.2em; padding: 5px;">Documento</th>
<th style="font-size: 1.2em; padding: 5px;">Telefone</th>
<th style="font-size: 1.2em; padding: 5px;">Email</th>
<th style="font-size: 1.2em; padding: 5px;">Cadastro</th>
</tr>
</thead>
<tbody>
<?php foreach ($clientes as $c) : ?>
<?php $dataCadastro = date('d/m/Y', strtotime($c->dataCadastro)) ?>
<tr>
<td>
<?= $c->nomeCliente ?>
</td>
<td>
<?= $c->documento ?>
</td>
<td>
<?= $c->telefone ?>
</td>
<td>
<?= $c->email ?>
</td>
<td>
<?= $dataCadastro ?>
</td>
</tr>
<?php endforeach ?>
</tbody>
</table>
<div class="widget-content nopadding tab-content">
<table width="100%" class="table table-bordered">
<thead>
<tr>
<th width="480" style="font-size: 15px">Nome</th>
<th width="170" style="font-size: 15px">Documento</th>
<th width="150" style="font-size: 15px">Telefone</th>
<th width="200" style="font-size: 15px">Email</th>
<th width="120" style="font-size: 15px">Cadastro</th>
</tr>
</thead>
<tbody>
<?php foreach ($clientes as $c) : ?>
<?php $dataCadastro = date('d/m/Y', strtotime($c->dataCadastro)) ?>
<tr>
<td><?= $c->nomeCliente ?></td>
<td align="center"><?= $c->documento ?></td>
<td align="center"><?= $c->telefone ?></td>
<td align="center"><?= $c->email ?></td>
<td align="center"><?= $dataCadastro ?></td>
</tr>
<?php endforeach ?>
</tbody>
</table>

</div>
</div>
</div>

<h5 style="text-align: right">Data do Relatório:
</div>
<h5 style="text-align: right; font-size: 0.8em; padding: 5px;">Data do Relatório:
<?php echo date('d/m/Y'); ?>
</h5>

</div>
</div>
</div>
Expand Down
57 changes: 26 additions & 31 deletions application/views/relatorios/imprimir/imprimirOs.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,57 +20,52 @@
<div class="widget-box">
<?= $topo ?>
<div class="widget-title">
<h4 style="text-align: center">
<h4 style="text-align: center; font-size: 1.1em; padding: 5px;">
<?= ucfirst($title) ?>
</h4>
</div>
<div class="widget-content nopadding tab-content">
<table class="table table-striped table-bordered">
<table width="100%" class="table table-striped table-bordered">
<thead>
<tr>
<th style="padding: 5px;">ID OS</th>
<th style="padding: 5px;">CLIENTE</th>
<th style="padding: 5px;">STATUS</th>
<th style="padding: 5px;">DATA</th>
<th style="padding: 5px;">DESCRIÇÃO</th>
<th style="padding: 5px;">TOTAL PRODUTOS</th>
<th style="padding: 5px;">TOTAL SERVIÇOS</th>
<th style="padding: 5px;">TOTAL</th>
<th width="70" align="center" style="font-size: 12px">OS</th>
<th width="200" align="center" style="font-size: 12px">CLIENTE</th>
<th width="150" align="center" style="font-size: 12px">STATUS</th>
<th width="100" salign="center" style="font-size: 12px">DATA</th>
<th width="400" align="center" style="font-size: 12px">DESCRIÇÃO</th>
<th width="140" align="center" style="font-size: 12px">TOTAL PRODUTOS</th>
<th width="140" align="center" style="font-size: 12px">TOTAL SERVIÇOS</th>
<th width="100" align="center" style="font-size: 12px">TOTAL</th>
</tr>
</thead>
<tbody>
<?php
foreach ($os as $c) {
echo '<tr>';
echo '<td><small>' . $c->idOs . '</small></td>';
echo '<td><small>' . $c->nomeCliente . '</small></td>';
echo '<td><small>' . $c->status . '</small></td>';
echo '<td><small>' . date('d/m/Y', strtotime($c->dataInicial)) . '</small></td>';
echo '<td><small>' . $c->descricaoProduto . '</small></td>';
echo '<td><small>R$ ' . number_format($c->total_produto, 2, ',', '.') . '</small></td>';
echo '<td><small>R$ ' . number_format($c->total_servico, 2, ',', '.') . '</small></td>';
echo '<td><small>R$ ' . number_format($c->total_produto + $c->total_servico, 2, ',', '.') . '</small></td>';
echo '</tr>';
}
foreach ($os as $c) {
echo '<tr>';
echo '<td align="center"><small>' . $c->idOs . '</small></td>';
echo '<td><small>' . $c->nomeCliente . '</small></td>';
echo '<td align="center"><small>' . $c->status . '</small></td>';
echo '<td align="center"><small>' . date('d/m/Y', strtotime($c->dataInicial)) . '</small></td>';
echo '<td><small>' . $c->descricaoProduto . '</small></td>';
echo '<td align="center"><small>R$: ' . number_format($c->total_produto, 2, ',', '.') . '</small></td>';
echo '<td align="center"><small>R$: ' . number_format($c->total_servico, 2, ',', '.') . '</small></td>';
echo '<td align="center"><small>R$: ' . number_format($c->total_produto + $c->total_servico, 2, ',', '.') . '</small></td>';
echo '</tr>';
}
?>

<tr>
<td colspan="8"></td>
</tr>

<tr style="background-color: gainsboro;">
<td colspan="5"></td>
<td><small>R$ <?= number_format($total_produtos, 2, ',', '.') ?></small></td>
<td><small>R$ <?= number_format($total_servicos, 2, ',', '.') ?></small></td>
<td><small>R$ <?= number_format($total_geral, 2, ',', '.') ?></small></td>
<td align="center"><small>R$: <?= number_format($total_produtos, 2, ',', '.') ?></small></td>
<td align="center"><small>R$: <?= number_format($total_servicos, 2, ',', '.') ?></small></td>
<td align="center"><small>R$: <?= number_format($total_geral, 2, ',', '.') ?></small></td>
</tr>
</tbody>
</table>
</div>
</div>

<p style="text-align: right">Data do Relatório: <?php echo date('d/m/Y'); ?>
</p>
<h5 style="text-align: right; font-size: 0.8em; padding: 5px;">Data do Relatório: <?php echo date('d/m/Y'); ?>
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit ea68761

Please sign in to comment.