Skip to content

Commit

Permalink
fix/pix qr code (#1319)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pr3d4dor authored Mar 24, 2021
1 parent a3509f7 commit 33f1b90
Show file tree
Hide file tree
Showing 9 changed files with 227 additions and 159 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +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.32.0] - 2021-03-07
## [4.32.0] - 2021-03-23

### Added
- Criada uma forma configurável de como o padrão básico de exibição da listagem de OS.[@bulfaitelo](https://github.com/bulfaitelo)

### Fixed
- Corrigido problema ao gerar qr code de PIX. [@Pr3d4dor](https://github.com/Pr3d4dor)
- Corrigido erro ao selecionar filtro faturado e nome do cliente, não vinha os dados existentes. [@willph](https://github.com/willph)
- Corrigido autocomplete de CEP do viacep. [@douglascoe](https://github.com/douglascoe)

## [4.31.1] - 2021-02-13

### Fixed
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.31.1';
$config['app_version'] = '4.32.0';

/**
* Nome do sistema
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/Mapos.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public function configurar()
$this->form_validation->set_rules('control_baixa', 'Controle de Baixa', 'required|trim');
$this->form_validation->set_rules('control_editos', 'Controle de Edição de OS', 'required|trim');
$this->form_validation->set_rules('control_datatable', 'Controle de Visualização em DataTables', 'required|trim');
$this->form_validation->set_rules('os_status_list[]', 'Controle de visualização de OS', 'required|trim', array('required' => 'Selecione ao menos uma das opções!'));
$this->form_validation->set_rules('os_status_list[]', 'Controle de visualização de OS', 'required|trim', ['required' => 'Selecione ao menos uma das opções!']);
$this->form_validation->set_rules('pix_key', 'Chave Pix', 'trim|valid_pix_key', [
'valid_pix_key' => 'Chave Pix inválida!',
]);
Expand All @@ -364,7 +364,7 @@ public function configurar()
'control_editos' => $this->input->post('control_editos'),
'control_datatable' => $this->input->post('control_datatable'),
'pix_key' => $this->input->post('pix_key'),
'os_status_list' => json_encode($this->input->post('os_status_list')),
'os_status_list' => json_encode($this->input->post('os_status_list')),
];
if ($this->mapos_model->saveConfiguracao($data) == true) {
$this->session->set_flashdata('success', 'Configurações do sistema atualizadas com sucesso!');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

class Migration_add_os_status_list extends CI_Migration
{
public function up()
{
$sql = "INSERT INTO `configuracoes` (`idConfig`, `config`, `valor`) VALUES (12, 'os_status_list', '[\"Aberto\",\"Faturado\",\"Negocia\\u00e7\\u00e3o\",\"Em Andamento\",\"Or\\u00e7amento\",\"Finalizado\",\"Cancelado\",\"Aguardando Pe\\u00e7as\"]')";
$this->db->query($sql);
}

public function down()
{
$this->db->query("DELETE FROM `configuracoes` WHERE `configuracoes`.`idConfig` = 12");
}
}
12 changes: 5 additions & 7 deletions application/models/Os_model.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use Piggly\Pix\Payload;
use Piggly\Pix\StaticPayload;

class Os_model extends CI_Model
{
Expand Down Expand Up @@ -359,17 +359,15 @@ public function getQrCode($id, $pixKey, $emitente)
return;
}

$pix = (new Payload())
$pix = (new StaticPayload())
->applyValidCharacters()
->applyUppercase()
->applyEmailWhitespace()
->setPixKey(getPixKeyType($pixKey), $pixKey)
->setMerchantName($emitente->nome)
->setMerchantCity($emitente->cidade)
->setMerchantName($emitente->nome, true)
->setMerchantCity($emitente->cidade, true)
->setAmount($amount)
->setTid($id)
->setDescription(sprintf("%s - Pagamento - OS %s", $emitente->nome, $id))
->setAsReusable(false);
->setDescription(sprintf("%s OS %s", $emitente->nome, $id), true);

return $pix->getQRCode();
}
Expand Down
12 changes: 5 additions & 7 deletions application/models/Vendas_model.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use Piggly\Pix\Payload;
use Piggly\Pix\StaticPayload;

if (! defined('BASEPATH')) {
exit('No direct script access allowed');
Expand Down Expand Up @@ -187,17 +187,15 @@ function ($carry, $produto) {
return;
}

$pix = (new Payload())
$pix = (new StaticPayload())
->applyValidCharacters()
->applyUppercase()
->applyEmailWhitespace()
->setPixKey(getPixKeyType($pixKey), $pixKey)
->setMerchantName($emitente->nome)
->setMerchantCity($emitente->cidade)
->setMerchantName($emitente->nome, true)
->setMerchantCity($emitente->cidade, true)
->setAmount($amount)
->setTid($id)
->setDescription(sprintf("%s - Pagamento - Venda %s", $emitente->nome, $id))
->setAsReusable(false);
->setDescription(sprintf("%s Venda %s", $emitente->nome, $id), true);

return $pix->getQRCode();
}
Expand Down
4 changes: 2 additions & 2 deletions application/views/os/os.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@
$dataFinal = date(('d/m/Y'), strtotime($r->dataFinal));
} else {
$dataFinal = "";
}
}
if ($this->input->get('pesquisa') === null && is_array(json_decode($configuration['os_status_list']))) {
if (in_array($r->status, json_decode($configuration['os_status_list'])) != true) {
if (in_array($r->status, json_decode($configuration['os_status_list'])) != true) {
continue;
}
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"mk-j/php_xlsxwriter": "^0.38.0",
"mpdf/qrcode": "^1.1",
"phpoffice/phpword": "^0.18.0",
"piggly/php-pix": "^1.1.2"
"piggly/php-pix": "^1.2.5"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16",
Expand Down
Loading

0 comments on commit 33f1b90

Please sign in to comment.