Skip to content

Commit

Permalink
Feature/melhorias (#1006)
Browse files Browse the repository at this point in the history
* Implementado relatório de vendas (rápido e custom) em XLS

* Adicionado campo de observações para cliente em vendas

* Corrigido bug de visualização de sidebar em mobile

* Corrigido exibição de ícones em mobile
  • Loading branch information
Pr3d4dor authored Oct 17, 2020
1 parent 51477f3 commit 7912e5f
Show file tree
Hide file tree
Showing 56 changed files with 317 additions and 112 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ Todas as alterações serão documentadas neste arquivo
Formato baseado em [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
e [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [4.18.0] - 2020-10-17

## Fixed
- Corrigido bug de visualização de sidebar em mobile. [@visaotec](https://github.com/visaotec)
- Corrigido exibição de ícones em mobile. [@visaotec](https://github.com/visaotec)

## Added
- Implementado relatório de vendas (rápido e custom) em XLS. [@Pr3d4dor](https://github.com/Pr3d4dor)
- Adicionado campo de observações para cliente em vendas. [@Flexotron20](https://github.com/Flexotron20)

## [4.17.1] - 2020-10-05

## Fixed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

![MapOS](https://raw.githubusercontent.com/RamonSilva20/mapos/master/assets/img/logo.png)

![version](https://img.shields.io/badge/version-4.17.1-blue.svg?longCache=true&style=flat-square)
![version](https://img.shields.io/badge/version-4.18.0-blue.svg?longCache=true&style=flat-square)
![license](https://img.shields.io/badge/license-MIT-green.svg?longCache=true&style=flat-square)
![theme](https://img.shields.io/badge/theme-Matrix--Admin-lightgrey.svg?longCache=true&style=flat-square)
![issues](https://img.shields.io/github/issues/RamonSilva20/mapos.svg?longCache=true&style=flat-square)
Expand Down
2 changes: 1 addition & 1 deletion application/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/**
* App current version
*/
$config['app_version'] = '4.17.1';
$config['app_version'] = '4.18.0';

/**
* Nome do sistema
Expand Down
106 changes: 100 additions & 6 deletions application/controllers/Relatorios.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ public function clientesCustom()

$data['clientes'] = $this->Relatorios_model->clientesCustom($dataInicial, $dataFinal);
$data['emitente'] = $this->Mapos_model->getEmitente();
$data['title'] = 'Relatório de Clientes Custumizado';
$data['title'] = 'Relatório de Clientes Customizado';
$data['topo'] = $this->load->view('relatorios/imprimir/imprimirTopo', $data, true);

$this->load->helper('mpdf');
//$this->load->view('relatorios/imprimir/imprimirClientes', $data);
$html = $this->load->view('relatorios/imprimir/imprimirClientes', $data, true);
pdf_create($html, 'relatorio_clientes' . date('d/m/y'), true);
}
Expand Down Expand Up @@ -717,9 +716,57 @@ public function vendasRapid()
$this->session->set_flashdata('error', 'Você não tem permissão para gerar relatórios de vendas.');
redirect(base_url());
}
$data['vendas'] = $this->Relatorios_model->vendasRapid();

$format = $this->input->get('format');
$isXls = $format === 'xls';
$vendas = $this->Relatorios_model->vendasRapid($isXls);
$totalVendas = 0;
foreach ($vendas as $venda) {
$totalVendas += $isXls
? floatval($venda['valorTotal'])
: floatval($venda->valorTotal);
}

if ($format == 'xls') {
$vendasFormatadas = array_map(function ($item) {
return [
'cliente' => $item['nomeCliente'],
'total' => $item['valorTotal'] ?: 0,
'data' => $item['dataVenda'],
'vendedor' => $item['nome'],
];
}, $vendas);

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

$writer = new XLSXWriter();

$writer->writeSheetHeader('Sheet1', $cabecalho);
foreach ($vendasFormatadas as $venda) {
$writer->writeSheetRow('Sheet1', $venda);
}
$writer->writeSheetRow('Sheet1', []);
$writer->writeSheetRow('Sheet1', [
null,
$totalVendas,
]);

$arquivo = $writer->writeToString();
$this->load->helper('download');
force_download('relatorio_vendas.xlsx', $arquivo);

return;
}

$data['vendas'] = $vendas;
$data['total_vendas'] = $totalVendas;
$data['emitente'] = $this->Mapos_model->getEmitente();
$data['title'] = 'Relatório de Clientes Custumizado';
$data['title'] = 'Relatório de Vendas Rápido';
$data['topo'] = $this->load->view('relatorios/imprimir/imprimirTopo', $data, true);

$this->load->helper('mpdf');
Expand All @@ -737,10 +784,57 @@ public function vendasCustom()
$dataFinal = $this->input->get('dataFinal');
$cliente = $this->input->get('cliente');
$responsavel = $this->input->get('responsavel');
$format = $this->input->get('format');

$isXls = $format === 'xls';
$vendas = $this->Relatorios_model->vendasCustom($dataInicial, $dataFinal, $cliente, $responsavel, $isXls);
$totalVendas = 0;
foreach ($vendas as $venda) {
$totalVendas += $isXls
? floatval($venda['valorTotal'])
: floatval($venda->valorTotal);
}

if ($format == 'xls') {
$vendasFormatadas = array_map(function ($item) {
return [
'cliente' => $item['nomeCliente'],
'total' => $item['valorTotal'] ?: 0,
'data' => $item['dataVenda'],
'vendedor' => $item['nome'],
];
}, $vendas);

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

$writer = new XLSXWriter();

$writer->writeSheetHeader('Sheet1', $cabecalho);
foreach ($vendasFormatadas as $venda) {
$writer->writeSheetRow('Sheet1', $venda);
}
$writer->writeSheetRow('Sheet1', []);
$writer->writeSheetRow('Sheet1', [
null,
$totalVendas,
]);

$arquivo = $writer->writeToString();
$this->load->helper('download');
force_download('relatorio_vendas.xlsx', $arquivo);

return;
}

$data['vendas'] = $this->Relatorios_model->vendasCustom($dataInicial, $dataFinal, $cliente, $responsavel);
$data['vendas'] = $vendas;
$data['total_vendas'] = $totalVendas;
$data['emitente'] = $this->Mapos_model->getEmitente();
$data['title'] = 'Relatório de Vendas Custumizado';
$data['title'] = 'Relatório de Vendas Customizado';
$data['topo'] = $this->load->view('relatorios/imprimir/imprimirTopo', $data, true);

$this->load->helper('mpdf');
Expand Down
2 changes: 2 additions & 0 deletions application/controllers/Vendas.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function adicionar()
$data = [
'dataVenda' => $dataVenda,
'observacoes' => $this->input->post('observacoes'),
'observacoes_cliente' => $this->input->post('observacoes_cliente'),
'clientes_id' => $this->input->post('clientes_id'),
'usuarios_id' => $this->input->post('usuarios_id'),
'faturado' => 0,
Expand Down Expand Up @@ -118,6 +119,7 @@ public function editar()
$data = [
'dataVenda' => $dataVenda,
'observacoes' => $this->input->post('observacoes'),
'observacoes_cliente' => $this->input->post('observacoes_cliente'),
'usuarios_id' => $this->input->post('usuarios_id'),
'clientes_id' => $this->input->post('clientes_id'),
];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

class Migration_add_observacoes_cliente_to_vendas_table extends CI_Migration
{
public function up()
{
$this->dbforge->add_column('vendas', [
'observacoes_cliente' => [
'type' => 'TEXT',
'null' => true,
'default' => null,
],
]);
}

public function down()
{
$this->dbforge->drop_column('vendas', 'observacoes_cliente');
}
}
19 changes: 14 additions & 5 deletions application/models/Relatorios_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,19 +334,23 @@ public function financeiroCustom($dataInicial = null, $dataFinal = null, $tipo =
return $result->result();
}

public function vendasRapid()
public function vendasRapid($array = false)
{
$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->order_by('vendas.dataVenda', 'DESC');

return $this->db->get()->result();
$result = $this->db->get();
if ($array) {
return $result->result_array();
}

return $result->result();
}

public function vendasCustom($dataInicial = null, $dataFinal = null, $cliente = null, $responsavel = null)
public function vendasCustom($dataInicial = null, $dataFinal = null, $cliente = null, $responsavel = null, $array = false)
{
$whereData = "";
$whereCliente = "";
Expand All @@ -367,6 +371,11 @@ public function vendasCustom($dataInicial = null, $dataFinal = null, $cliente =

$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 WHERE idVendas != 0 $whereData $whereCliente $whereResponsavel ORDER BY vendas.dataVenda";

return $this->db->query($query)->result();
$result = $this->db->query($query);
if ($array) {
return $result->result_array();
}

return $result->result();
}
}
2 changes: 1 addition & 1 deletion application/views/arquivos/adicionarArquivo.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</span>
<h5>Cadastro de Arquivo</h5>
</div>
<div class="widget-content nopadding">
<div class="widget-content nopadding tab-content">
<?= $custom_error ?>

<form action="<?= current_url() ?>" id="formArquivo" enctype="multipart/form-data" method="post" class="form-horizontal">
Expand Down
2 changes: 1 addition & 1 deletion application/views/arquivos/arquivos.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</span>
<h5>Arquivos</h5>
</div>
<div class="widget-content nopadding">
<div class="widget-content nopadding tab-content">
<table width="100%" class="table table-bordered ">
<thead>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion application/views/arquivos/editarArquivo.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</span>
<h5>Cadastro de Arquivo</h5>
</div>
<div class="widget-content nopadding">
<div class="widget-content nopadding tab-content">
<?php echo $custom_error; ?>
<form action="<?php echo current_url(); ?>" id="formArquivo" method="post" class="form-horizontal">

Expand Down
2 changes: 1 addition & 1 deletion application/views/auditoria/logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</span>
<h5>Logs</h5>
</div>
<div class="widget-content nopadding">
<div class="widget-content nopadding tab-content">
<table class="table table-bordered ">
<thead>
<tr style="backgroud-color: #2D335B">
Expand Down
2 changes: 1 addition & 1 deletion application/views/clientes/adicionarCliente.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</span>
<h5>Cadastro de Cliente</h5>
</div>
<div class="widget-content nopadding">
<div class="widget-content nopadding tab-content">
<?php if ($custom_error != '') {
echo '<div class="alert alert-danger">' . $custom_error . '</div>';
} ?>
Expand Down
6 changes: 3 additions & 3 deletions application/views/clientes/clientes.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<h5>Clientes</h5>
</div>

<div class="widget-content nopadding">
<div class="widget-content nopadding tab-content">
<table class="table table-bordered ">
<thead>
<tr>
Expand All @@ -24,7 +24,7 @@
</thead>
<tbody>
<?php

if (!$results) {
echo '<tr>
<td colspan="5">Nenhum Cliente Cadastrado</td>
Expand All @@ -50,7 +50,7 @@
echo '</td>';
echo '</tr>';
} ?>

</tbody>
</table>
</div>
Expand Down
2 changes: 1 addition & 1 deletion application/views/clientes/editarCliente.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</span>
<h5>Editar Cliente</h5>
</div>
<div class="widget-content nopadding">
<div class="widget-content nopadding tab-content">
<?php if ($custom_error != '') {
echo '<div class="alert alert-danger">' . $custom_error . '</div>';
} ?>
Expand Down
2 changes: 1 addition & 1 deletion application/views/conecte/adicionarOs.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</span>
<h5>Cadastro de OS</h5>
</div>
<div class="widget-content nopadding">
<div class="widget-content nopadding tab-content">


<div class="span12" id="divProdutosServicos" style=" margin-left: 0">
Expand Down
2 changes: 1 addition & 1 deletion application/views/conecte/cadastrar.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</span>
<h5>Cadastre-se no sistema</h5>
</div>
<div class="widget-content nopadding">
<div class="widget-content nopadding tab-content">

<form action="<?php echo current_url(); ?>" id="formCliente" method="post" class="form-horizontal">
<div class="control-group">
Expand Down
6 changes: 3 additions & 3 deletions application/views/conecte/compras.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

</div>

<div class="widget-content nopadding">
<div class="widget-content nopadding tab-content">


<table class="table table-bordered ">
Expand Down Expand Up @@ -45,7 +45,7 @@

</div>

<div class="widget-content nopadding">
<div class="widget-content nopadding tab-content">


<table class="table table-bordered ">
Expand Down Expand Up @@ -74,7 +74,7 @@

echo '<td><a href="' . base_url() . 'index.php/mine/visualizarCompra/' . $r->idVendas . '" class="btn tip-top" title="Ver mais detalhes"><i class="fas fa-eye"></i></a>
<a href="' . base_url() . 'index.php/mine/imprimirCompra/' . $r->idVendas . '" target="_blank" class="btn btn-inverse tip-top" title="Imprimir"><i class="fas fa-print"></i></a>
</td>';
echo '</tr>';
} ?>
Expand Down
2 changes: 1 addition & 1 deletion application/views/conecte/detalhes_os.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</span>
<h5>Detalhes OS</h5>
</div>
<div class="widget-content nopadding">
<div class="widget-content nopadding tab-content">


<div class="span12" id="divProdutosServicos" style=" margin-left: 0">
Expand Down
2 changes: 1 addition & 1 deletion application/views/conecte/editar_dados.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</span>
<h5>Editar Meus Dados</h5>
</div>
<div class="widget-content nopadding">
<div class="widget-content nopadding tab-content">

<form action="<?php echo current_url(); ?>" id="formCliente" method="post" class="form-horizontal">
<div class="control-group">
Expand Down
Loading

0 comments on commit 7912e5f

Please sign in to comment.