This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use webpdv_log; | |
DELIMITER $$ | |
CREATE TRIGGER `veiculos_BUPD` | |
BEFORE UPDATE ON `veiculos` | |
FOR EACH ROW BEGIN | |
INSERT INTO `webpdv_log`.`veiculos` | |
SET `id_veiculo` = OLD.id_veiculo, | |
`placa` = OLD.placa, | |
`veiculo` = OLD.veiculo, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE webpdv_log.produto ( | |
id int AUTO_INCREMENT, | |
prdno char(16) NOT NULL, | |
clno int(10) NOT NULL, | |
name varchar(120) NOT NULL, | |
vendno int(11) NOT NULL DEFAULT '0', | |
typeno smallint(6) NOT NULL DEFAULT '0', | |
deptno smallint(6) NOT NULL DEFAULT '0', | |
groupno smallint(6) NOT NULL DEFAULT '0', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE webpdv_log.produto ( | |
id int AUTO_INCREMENT, | |
prdno char(16) NOT NULL, | |
clno int(10) NOT NULL, | |
name varchar(120) NOT NULL, | |
vendno int(11) NOT NULL DEFAULT '0', | |
typeno smallint(6) NOT NULL DEFAULT '0', | |
deptno smallint(6) NOT NULL DEFAULT '0', | |
groupno smallint(6) NOT NULL DEFAULT '0', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Triggers para Criação de Log no cadastro de Produtos | |
USE `webpdv`; | |
DELIMITER $$ | |
CREATE TRIGGER `produto_AUPD` | |
AFTER UPDATE ON `produto` | |
FOR EACH ROW BEGIN | |
INSERT INTO webpdv_log.produto | |
SET prdno = OLD.prdno, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER TABLE webpdv.produto | |
ADD COLUMN id_usuario_alteracao INT, | |
ADD COLUMN data_alteracao DATETIME; | |
ALTER TABLE webpdv.produto_campo_livre | |
ADD COLUMN id_usuario_alteracao INT, | |
ADD COLUMN data_alteracao DATETIME; | |
ALTER TABLE webpdv.produto_caracteristica | |
ADD COLUMN id_usuario_alteracao INT, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
CONCAT(itxa.storeno, ' / ', pxa.eordno) AS 'Loja / Pedido', | |
CONCAT(pe.id_pessoa, ' - ', pe.nome_pessoa) AS Pestador, | |
DATE_FORMAT(inst.date, '%d/%m/%Y') AS 'Data Compra', | |
itxa.contrno AS Contrato, | |
REPLACE(ROUND((inst.cashamt - inst.downpay) / 100, 2), '.',',') AS 'Valor Financiado', | |
CONCAT(itxa.instno, ' x de ', ROUND(itxa.instamt / 100, 2)) AS 'Parcela/Valor', | |
REPLACE(ROUND(itxa.paidamt / 100, 2), '.', ',') AS 'Valor Pago', | |
DATE_FORMAT(itxa.duedate,'%d/%m/%Y') AS 'Data Vencimento', | |
itxa.paiddate AS 'Data Pagamento', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT t1.storeno, t1.pdvno, t1.xano, t1.date, t1.valor_total, | |
t1.xatype, t1.metodo_pagamento, t1.tipo_transacao, t1.id_pessoa, | |
t1.nome_pessoa, t1.ddd_telefone, t1.telefone | |
FROM ( | |
SELECT xalog2.storeno, xalog2.pdvno, xalog2.xano, xalog2.date, | |
SUM(xalog2.qtty/1000 * xalog2.price) AS valor_total, | |
xalog2.xatype, | |
IF(xalog2.qtty <0, 1, 0) AS troca_devolucao, | |
( | |
SELECT GROUP_CONCAT(pay.name SEPARATOR ', ') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
prd.storeno AS loja, | |
concat(pro.prdno_int) AS 'Codigo', | |
concat(pro.name) AS 'Produto', | |
concat(prd.grade) AS 'Grade', | |
ROUND(prd.qtty / 1000) AS 'Quantidade', | |
vend.sname AS 'Marca', | |
IF(EXISTS( | |
SELECT 'X' | |
FROM webpdv.produto_brecho pb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
IF(0 < m.data_agendamento, IF(m.data_agendamento < DATE_FORMAT(NOW(), '%Y-%m-%d'), 1,0), | |
IF(0 < pe.data_agendamento_montagem, | |
IF(pe.data_agendamento_montagem < DATE_FORMAT(NOW(), '%Y-%m-%d'), 1, 0), | |
IF(pe.previsao_montagem < DATE_FORMAT(NOW(), '%Y%m%d'), 1, 0)) | |
) AS retorno | |
FROM webpdv.pedidos_entregas pe | |
LEFT JOIN webpdv.montagens m ON (m.id_origem = pe.id_pedido_entrega) | |
WHERE id_pedido_entrega = 46611021; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
nfce.nfno_nfname AS NF, | |
rm.storeno AS Loja, | |
TRIM(rmp.prdno) AS Produto, | |
prod.name AS 'Nome Produto', | |
ROUND(rmp.qtty_fiscal / 1000) AS Quantidade, | |
REPLACE(ROUND(prp.cost / 10000, 2), '.', ',') AS 'Valor Custo', | |
REPLACE(ROUND(rmp.valor_unitario / 100, 2), '.', ',') AS 'Valor Venda', | |
REPLACE(ROUND(rmp.qtty_fiscal / 1000 * prp.cost / 10000, 2), '.', ',') AS 'Valor Custo Total', | |
REPLACE(ROUND(rmp.qtty_fiscal / 1000 * rmp.valor_unitario / 100, 2), '.', ',') AS 'Valor Total Venda' |
OlderNewer