-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Tempo de geração: 25/08/2025 às 14:18
-- Versão do servidor: 10.4.32-MariaDB
-- Versão do PHP: 8.0.30

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Banco de dados: `fiadofacil`
--

-- --------------------------------------------------------

--
-- Estrutura para tabela `admin_users`
--

CREATE TABLE `admin_users` (
  `id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `email` varchar(150) NOT NULL,
  `password` varchar(255) NOT NULL,
  `created_at` datetime DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Estrutura para tabela `client_customers`
--

CREATE TABLE `client_customers` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `cpf` varchar(20) DEFAULT NULL,
  `created_at` datetime DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Despejando dados para a tabela `client_customers`
--

INSERT INTO `client_customers` (`id`, `user_id`, `name`, `phone`, `cpf`, `created_at`) VALUES
(1, 1, 'FreeCoin', '83998533151', '', '2025-07-13 19:54:01'),
(2, 1, 'angela mayle', '83998546107', '', '2025-07-13 20:37:52'),
(3, 2, 'maria', '83998677890', '', '2025-07-13 23:56:14'),
(4, 2, 'Rauan silva', '(83) 99854-6107', '000.000.000-00', '2025-07-20 00:50:51'),
(5, 4, 'ronison fagno', '(83) 99853-3151', '', '2025-08-23 17:17:11');

-- --------------------------------------------------------

--
-- Estrutura para tabela `fiados`
--

CREATE TABLE `fiados` (
  `id` int(11) NOT NULL,
  `customer_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `description` varchar(255) DEFAULT NULL,
  `total_amount` decimal(10,2) NOT NULL,
  `created_at` datetime DEFAULT current_timestamp(),
  `valor_pago` decimal(10,2) DEFAULT 0.00,
  `saldo` decimal(10,2) DEFAULT 0.00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Despejando dados para a tabela `fiados`
--

INSERT INTO `fiados` (`id`, `customer_id`, `user_id`, `description`, `total_amount`, `created_at`, `valor_pago`, `saldo`) VALUES
(6, 2, 1, 'valor venda teste', 150.00, '2025-07-13 22:05:04', 100.00, 50.00),
(7, 3, 2, 'peneu', 123.00, '2025-07-13 23:56:36', 61.50, 61.50),
(8, 5, 4, 'feira', 1250.00, '2025-08-23 17:17:40', 1250.00, 0.00),
(9, 5, 4, 'feira 2', 155.00, '2025-08-23 20:35:55', 155.00, 0.00);

-- --------------------------------------------------------

--
-- Estrutura para tabela `installments`
--

CREATE TABLE `installments` (
  `id` int(11) NOT NULL,
  `fiado_id` int(11) NOT NULL,
  `due_date` date NOT NULL,
  `amount` decimal(10,2) NOT NULL,
  `paid` tinyint(1) DEFAULT 0,
  `paid_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Despejando dados para a tabela `installments`
--

INSERT INTO `installments` (`id`, `fiado_id`, `due_date`, `amount`, `paid`, `paid_at`) VALUES
(12, 6, '2025-07-13', 50.00, 1, NULL),
(13, 6, '2025-08-13', 50.00, 1, NULL),
(14, 6, '2025-09-13', 50.00, 0, NULL),
(15, 7, '2025-07-13', 61.50, 1, NULL),
(16, 7, '2025-08-13', 61.50, 0, NULL),
(17, 8, '2025-09-23', 1250.00, 1, NULL),
(18, 9, '2025-09-23', 155.00, 1, NULL);

-- --------------------------------------------------------

--
-- Estrutura para tabela `payments`
--

CREATE TABLE `payments` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `reference_month` varchar(7) NOT NULL,
  `paid` tinyint(1) DEFAULT 0,
  `paid_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Estrutura para tabela `settings`
--

CREATE TABLE `settings` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `nome_empresa` varchar(100) DEFAULT NULL,
  `cnpj` varchar(25) DEFAULT NULL,
  `endereco` varchar(150) DEFAULT NULL,
  `telefone` varchar(30) DEFAULT NULL,
  `email_contato` varchar(80) DEFAULT NULL,
  `logo` varchar(200) DEFAULT NULL,
  `pix_key` varchar(120) DEFAULT NULL,
  `updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Despejando dados para a tabela `settings`
--

INSERT INTO `settings` (`id`, `user_id`, `nome_empresa`, `cnpj`, `endereco`, `telefone`, `email_contato`, `logo`, `pix_key`, `updated_at`) VALUES
(1, 2, 'Lidernetwork', '00000000000', 'rua das pastilas', '8399097854', '', 'https://mir-s3-cdn-cf.behance.net/projects/404/f6044e88749841.Y3JvcCwyNDgyLDE5NDEsMCwzMjU.png', 'ronisonfagno@gmail.com', '2025-07-20 09:20:45'),
(2, 1, 'Tecnolider informatica', '00000000000', 'Rua julho carlos,160', '83998533151', '', 'https://img.cdndsgni.com/preview/10431212.jpg', 'ronisonfagno@gmail.com', '2025-07-14 13:12:44'),
(3, 4, 'Mercado Pageu', '19.501.313/0001-51', 'rua teste , 120 ,centro ,Malta-pb', '(83) 99856-2331', '', 'uploads/Red_Apple.jpg', 'mercadopageu@gmail.com', '2025-08-23 20:37:31');

-- --------------------------------------------------------

--
-- Estrutura para tabela `superadmins`
--

CREATE TABLE `superadmins` (
  `id` int(11) NOT NULL,
  `nome` varchar(120) NOT NULL,
  `email` varchar(140) NOT NULL,
  `senha` varchar(255) NOT NULL,
  `criado_em` datetime DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Despejando dados para a tabela `superadmins`
--

INSERT INTO `superadmins` (`id`, `nome`, `email`, `senha`, `criado_em`) VALUES
(1, 'Super Admin', 'ronisonfagno@gmail.com', '$2y$10$.kzVhsAkYyNMJ1L0778wf.2grCdVkKd8Uyq4T.WiWWPYofngJ1T.2', '2025-07-13 22:26:49');

-- --------------------------------------------------------

--
-- Estrutura para tabela `users`
--

CREATE TABLE `users` (
  `id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `email` varchar(150) NOT NULL,
  `password` varchar(255) NOT NULL,
  `active` tinyint(1) DEFAULT 1,
  `created_at` datetime DEFAULT current_timestamp(),
  `phone` varchar(25) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Despejando dados para a tabela `users`
--

INSERT INTO `users` (`id`, `name`, `email`, `password`, `active`, `created_at`, `phone`) VALUES
(1, 'ronison', 'admin@admin.com', '$2y$10$3NtvJOgrgC4rirjL7tfU5OVHFaFBEHH29seP/wWOzdqEF6UcKGDkW', 1, '2025-07-13 19:52:50', '83998533151'),
(2, 'jurandi', 'jurandi@gmail.com', '$2y$10$pxFXoz3G9859RoBSShG/.eIonSh0fNyCssN.VGOLH.Rbk1I3cfitu', 1, '2025-07-13 21:12:53', NULL),
(3, 'jordao sousa', 'jordaosousa@gmail.com', '$2y$10$s.mVEvEGeqIND0uRHxprS..pm1KK32.SVrLxD1P/RgcRstBf.T3ze', 1, '2025-07-14 00:13:03', '83988671389'),
(4, 'ronison', 'ronisonfagno@gmail.com', '$2y$10$.kzVhsAkYyNMJ1L0778wf.2grCdVkKd8Uyq4T.WiWWPYofngJ1T.2', 1, '2025-08-23 17:16:07', '(83) 99853-3151'),
(5, 'marcia', 'admin@sistemas.com', '$2y$10$n6y5ZGXaC7acpIbA0zZ6n.6XxDBqXPR2/JdifLnKTBYvUcCyBxAfC', 1, '2025-08-24 15:04:02', '(83) 99856-5656');

--
-- Índices para tabelas despejadas
--

--
-- Índices de tabela `admin_users`
--
ALTER TABLE `admin_users`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `email` (`email`);

--
-- Índices de tabela `client_customers`
--
ALTER TABLE `client_customers`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`);

--
-- Índices de tabela `fiados`
--
ALTER TABLE `fiados`
  ADD PRIMARY KEY (`id`),
  ADD KEY `customer_id` (`customer_id`),
  ADD KEY `user_id` (`user_id`);

--
-- Índices de tabela `installments`
--
ALTER TABLE `installments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fiado_id` (`fiado_id`);

--
-- Índices de tabela `payments`
--
ALTER TABLE `payments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`);

--
-- Índices de tabela `settings`
--
ALTER TABLE `settings`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`);

--
-- Índices de tabela `superadmins`
--
ALTER TABLE `superadmins`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `email` (`email`);

--
-- Índices de tabela `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `email` (`email`);

--
-- AUTO_INCREMENT para tabelas despejadas
--

--
-- AUTO_INCREMENT de tabela `admin_users`
--
ALTER TABLE `admin_users`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT de tabela `client_customers`
--
ALTER TABLE `client_customers`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT de tabela `fiados`
--
ALTER TABLE `fiados`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;

--
-- AUTO_INCREMENT de tabela `installments`
--
ALTER TABLE `installments`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19;

--
-- AUTO_INCREMENT de tabela `payments`
--
ALTER TABLE `payments`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT de tabela `settings`
--
ALTER TABLE `settings`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT de tabela `superadmins`
--
ALTER TABLE `superadmins`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT de tabela `users`
--
ALTER TABLE `users`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- Restrições para tabelas despejadas
--

--
-- Restrições para tabelas `client_customers`
--
ALTER TABLE `client_customers`
  ADD CONSTRAINT `client_customers_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Restrições para tabelas `fiados`
--
ALTER TABLE `fiados`
  ADD CONSTRAINT `fiados_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `client_customers` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fiados_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Restrições para tabelas `installments`
--
ALTER TABLE `installments`
  ADD CONSTRAINT `installments_ibfk_1` FOREIGN KEY (`fiado_id`) REFERENCES `fiados` (`id`) ON DELETE CASCADE;

--
-- Restrições para tabelas `payments`
--
ALTER TABLE `payments`
  ADD CONSTRAINT `payments_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Restrições para tabelas `settings`
--
ALTER TABLE `settings`
  ADD CONSTRAINT `settings_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
