-- --------------------------------------------------------
-- Servidor:                     127.0.0.1
-- Versão do servidor:           5.7.38-log - MySQL Community Server (GPL)
-- OS do Servidor:               Win64
-- HeidiSQL Versão:              12.4.0.6659
-- --------------------------------------------------------

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;


-- Copiando estrutura do banco de dados para ti_inventory
CREATE DATABASE IF NOT EXISTS `ti_inventory` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `ti_inventory`;

-- Copiando estrutura para tabela ti_inventory.nps_qr
CREATE TABLE IF NOT EXISTS `nps_qr` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `filial_id` int(10) unsigned NOT NULL,
  `pdv_numero` varchar(20) NOT NULL,
  `code` varchar(64) NOT NULL,
  `url` varchar(255) NOT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `code` (`code`),
  KEY `idx_filial_pdv` (`filial_id`,`pdv_numero`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4;

-- Copiando dados para a tabela ti_inventory.nps_qr: ~1 rows (aproximadamente)
INSERT INTO `nps_qr` (`id`, `filial_id`, `pdv_numero`, `code`, `url`, `is_active`, `created_at`, `updated_at`) VALUES
	(2, 13, '01', '0b0eb4f7ccfd', 'http://191.241.79.154:9080/invent/nps.php?qr=0b0eb4f7ccfd', 1, '2025-09-22 21:43:07', '2025-09-22 21:43:07');

-- Copiando estrutura para tabela ti_inventory.nps_respostas
CREATE TABLE IF NOT EXISTS `nps_respostas` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `qr_id` int(10) unsigned DEFAULT NULL,
  `filial_id` int(10) unsigned NOT NULL,
  `pdv_numero` varchar(20) NOT NULL,
  `cpf` varchar(14) NOT NULL,
  `nota` tinyint(3) unsigned NOT NULL,
  `user_agent` varchar(255) DEFAULT NULL,
  `ip` varchar(64) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `idx_filial_pdv_created` (`filial_id`,`pdv_numero`,`created_at`),
  KEY `idx_qr_id` (`qr_id`),
  CONSTRAINT `fk_nps_respostas_qr` FOREIGN KEY (`qr_id`) REFERENCES `nps_qr` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4;

-- Copiando dados para a tabela ti_inventory.nps_respostas: ~3 rows (aproximadamente)
INSERT INTO `nps_respostas` (`id`, `qr_id`, `filial_id`, `pdv_numero`, `cpf`, `nota`, `user_agent`, `ip`, `created_at`) VALUES
	(1, NULL, 13, '05', '116.012.477-96', 10, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:143.0) Gecko/20100101 Firefox/143.0', '172.16.1.48', '2025-09-22 21:34:49'),
	(2, 2, 13, '01', '116.012.477-96', 1, 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3 Mobile/15E148 Safari/604.1', '191.57.10.19', '2025-09-22 21:47:37'),
	(3, 2, 13, '01', '126.957.237-76', 0, 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3 Mobile/15E148 Safari/604.1', '191.57.10.19', '2025-09-22 21:53:52'),
	(4, 2, 13, '01', '053.267.426-08', 10, 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3 Mobile/15E148 Safari/604.1', '191.57.8.108', '2025-09-23 09:18:21'),
	(5, 2, 13, '01', '116.012.477-96', 10, 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.7 Mobile/15E148 Safari/604.1', '191.57.26.13', '2025-12-18 09:45:03');

/*!40103 SET TIME_ZONE=IFNULL(@OLD_TIME_ZONE, 'system') */;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40111 SET SQL_NOTES=IFNULL(@OLD_SQL_NOTES, 1) */;
