diff --git a/CHANGELOG.md b/CHANGELOG.md index e86fceda6..7deea35d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ 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.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 ## Added diff --git a/README.md b/README.md index fcd314a60..ee5807ca9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ![MapOS](https://raw.githubusercontent.com/RamonSilva20/mapos/master/assets/img/logo.png) -![version](https://img.shields.io/badge/version-4.16.0-blue.svg?longCache=true&style=flat-square) +![version](https://img.shields.io/badge/version-4.17.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) diff --git a/application/config/config.php b/application/config/config.php index 3d76426dd..6dd4e5dea 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -4,7 +4,7 @@ /** * App current version */ -$config['app_version'] = '4.16.0'; +$config['app_version'] = '4.17.0'; /** * Nome do sistema diff --git a/application/controllers/Financeiro.php b/application/controllers/Financeiro.php index 7d7a07b4f..3b9470f5d 100644 --- a/application/controllers/Financeiro.php +++ b/application/controllers/Financeiro.php @@ -31,106 +31,38 @@ public function lancamentos() } $where = ''; - $periodo = $this->input->get('periodo'); - $situacao = $this->input->get('situacao'); + $vencimento_de = $this->input->get('vencimento_de') ?: date('d/m/Y'); + $vencimento_ate = $this->input->get('vencimento_ate') ?: date('d/m/Y'); $cliente = $this->input->get('cliente'); $tipo = $this->input->get('tipo'); + $status = $this->input->get('status'); + $periodo = $this->input->get('periodo'); - // busca todos os lançamentos - if ($periodo == 'todos') { - if ($situacao == 'previsto') { - $where = 'data_vencimento > "' . date('Y-m-d') . '" AND baixado = "0"'; + if (! empty($vencimento_de)) { + $date = DateTime::createFromFormat('d/m/Y', $vencimento_de)->format('Y-m-d'); + + if (empty($where)) { + $where = "data_vencimento >= '$date'"; } else { - if ($situacao == 'atrasado') { - $where = 'data_vencimento < "' . date('Y-m-d') . '" AND baixado = "0"'; - } else { - if ($situacao == 'realizado') { - $where = 'baixado = "1"'; - } - - if ($situacao == 'pendente') { - $where = 'baixado = "0"'; - } - } + $where .= " AND data_vencimento >= '$date'"; } - } else { + } + + if (! empty($vencimento_ate)) { + $date = DateTime::createFromFormat('d/m/Y', $vencimento_ate)->format('Y-m-d'); - // busca lançamentos do dia - if ($periodo == null || $periodo == 'dia') { - $where = 'data_vencimento = "' . date('Y-m-d' . '"'); - } // fim lançamentos dia - - else { - - // busca lançamentos da semana - if ($periodo == 'semana') { - $semana = $this->getThisWeek(); - - if (!isset($situacao) || $situacao == 'todos') { - $where = 'data_vencimento BETWEEN "' . $semana[0] . '" AND "' . $semana[1] . '"'; - } else { - if ($situacao == 'previsto') { - $where = 'data_vencimento BETWEEN "' . date('Y-m-d') . '" AND "' . $semana[1] . '" AND baixado = "0"'; - } else { - if ($situacao == 'atrasado') { - $where = 'data_vencimento BETWEEN "' . $semana[0] . '" AND "' . date('Y-m-d') . '" AND baixado = "0"'; - } else { - if ($situacao == 'realizado') { - $where = 'data_vencimento BETWEEN "' . $semana[0] . '" AND "' . $semana[1] . '" AND baixado = "1"'; - } else { - $where = 'data_vencimento BETWEEN "' . $semana[0] . '" AND "' . $semana[1] . '" AND baixado = "0"'; - } - } - } - } - } // fim lançamentos dia - else { - - // busca lançamento do mês - - if ($periodo == 'mes') { - $mes = $this->getThisMonth(); - - if (!isset($situacao) || $situacao == 'todos') { - $where = 'data_vencimento BETWEEN "' . $mes[0] . '" AND "' . $mes[1] . '"'; - } else { - if ($situacao == 'previsto') { - $where = 'data_vencimento BETWEEN "' . date('Y-m-d') . '" AND "' . $mes[1] . '" AND baixado = "0"'; - } else { - if ($situacao == 'atrasado') { - $where = 'data_vencimento BETWEEN "' . $mes[0] . '" AND "' . date('Y-m-d') . '" AND baixado = "0"'; - } else { - if ($situacao == 'realizado') { - $where = 'data_vencimento BETWEEN "' . $mes[0] . '" AND "' . $mes[1] . '" AND baixado = "1"'; - } else { - $where = 'data_vencimento BETWEEN "' . $mes[0] . '" AND "' . $mes[1] . '" AND baixado = "0"'; - } - } - } - } - } // busca lançamentos do ano - else { - $ano = $this->getThisYear(); - - if (!isset($situacao) || $situacao == 'todos') { - $where = 'data_vencimento BETWEEN "' . $ano[0] . '" AND "' . $ano[1] . '"'; - } else { - if ($situacao == 'previsto') { - $where = 'data_vencimento BETWEEN "' . date('Y-m-d') . '" AND "' . $ano[1] . '" AND baixado = "0"'; - } else { - if ($situacao == 'atrasado') { - $where = 'data_vencimento BETWEEN "' . $ano[0] . '" AND "' . date('Y-m-d') . '" AND baixado = "0"'; - } else { - if ($situacao == 'realizado') { - $where = 'data_vencimento BETWEEN "' . $ano[0] . '" AND "' . $ano[1] . '" AND baixado = "1"'; - } else { - $where = 'data_vencimento BETWEEN "' . $ano[0] . '" AND "' . $ano[1] . '" AND baixado = "0"'; - } - } - } - } - } - } + if (empty($where)) { + $where = "data_vencimento <= '$date'"; + } else { + $where .= " AND data_vencimento <= '$date'"; + } + } + + if (! empty($status)) { + if (empty($where)) { + $where = "baixado = '$status'"; + } else { + $where .= " AND baixado = '$status'"; } } @@ -142,7 +74,7 @@ public function lancamentos() } } - if (!empty($tipo)) { + if (! empty($tipo)) { if (empty($where)) { $where = "tipo = '$tipo'"; } else { @@ -152,7 +84,7 @@ public function lancamentos() $this->load->library('pagination'); - $this->data['configuration']['base_url'] = site_url("financeiro/lancamentos/?periodo=$periodo&situacao=$situacao&cliente=$cliente&tipo=$tipo"); + $this->data['configuration']['base_url'] = site_url("financeiro/lancamentos/?vencimento_de=$vencimento_de&vencimento_ate=$vencimento_ate&cliente=$cliente&tipo=$tipo&status=$status&periodo=$periodo"); $this->data['configuration']['total_rows'] = $this->financeiro_model->count('lancamentos', $where); $this->data['configuration']['page_query_string'] = true; diff --git a/application/views/financeiro/lancamentos.php b/application/views/financeiro/lancamentos.php index 868fb5210..9cb35de9c 100644 --- a/application/views/financeiro/lancamentos.php +++ b/application/views/financeiro/lancamentos.php @@ -1,6 +1,7 @@ + input->get('situacao'); $periodo = $this->input->get('periodo'); @@ -32,40 +33,22 @@
- + + + +
- - + + +
+ +
+ +
@@ -77,6 +60,15 @@
+
+ + +
+
@@ -120,8 +112,8 @@ if (!$results) { echo ' - Nenhum lançamento encontrado - '; + Nenhum lançamento encontrado + '; } foreach ($results as $r) { $vencimento = date(('d/m/Y'), strtotime($r->data_vencimento)); @@ -582,5 +574,27 @@ dateFormat: 'dd/mm/yy' }); + $('#periodo').on('change', function(event) { + const period = $('#periodo').val(); + + switch (period) { + case 'dia': + $('#vencimento_de').val(dayjs().locale('pt-br').format('DD/MM/YYYY')); + $('#vencimento_ate').val(dayjs().locale('pt-br').format('DD/MM/YYYY')); + break; + case 'semana': + $('#vencimento_de').val(dayjs().startOf('week').locale('pt-br').format('DD/MM/YYYY')); + $('#vencimento_ate').val(dayjs().endOf('week').locale('pt-br').format('DD/MM/YYYY')); + break; + case 'mes': + $('#vencimento_de').val(dayjs().startOf('month').locale('pt-br').format('DD/MM/YYYY')); + $('#vencimento_ate').val(dayjs().endOf('month').locale('pt-br').format('DD/MM/YYYY')); + break; + case 'ano': + $('#vencimento_de').val(dayjs().startOf('year').locale('pt-br').format('DD/MM/YYYY')); + $('#vencimento_ate').val(dayjs().endOf('year').locale('pt-br').format('DD/MM/YYYY')); + break; + } + }); }); diff --git a/assets/js/dayjs.min.js b/assets/js/dayjs.min.js new file mode 100644 index 000000000..93f8b9abe --- /dev/null +++ b/assets/js/dayjs.min.js @@ -0,0 +1 @@ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.dayjs=e()}(this,function(){"use strict";var t="millisecond",e="second",n="minute",r="hour",i="day",s="week",u="month",a="quarter",o="year",f="date",h=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[^0-9]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?.?(\d+)?$/,c=/\[([^\]]+)]|Y{2,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,d={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},$=function(t,e,n){var r=String(t);return!r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},l={s:$,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?"+":"-")+$(r,2,"0")+":"+$(i,2,"0")},m:function t(e,n){if(e.date()