-- phpMyAdmin SQL Dump
-- version 5.2.2
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Generation Time: Feb 14, 2026 at 05:43 PM
-- Server version: 10.6.25-MariaDB
-- PHP Version: 8.4.16

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 */;

--
-- Database: `movihac1_xui`
--

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

--
-- Table structure for table `admins`
--

CREATE TABLE `admins` (
  `id` int(11) NOT NULL,
  `username` varchar(100) NOT NULL,
  `password` varchar(255) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `admins`
--

INSERT INTO `admins` (`id`, `username`, `password`, `created_at`) VALUES
(1, 'admin', '$2y$10$HPrA366SY.bnSQzSgGcdKeX5wM5tcbjJ2iC.4BPMQSQGauLRdal3W', '2026-02-14 14:36:29');

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

--
-- Table structure for table `panels`
--

CREATE TABLE `panels` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `url` varchar(500) NOT NULL,
  `username` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `status` varchar(20) DEFAULT 'active',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `panels`
--

INSERT INTO `panels` (`id`, `name`, `url`, `username`, `password`, `status`, `created_at`) VALUES
(1, 'irancell', 'https://irancell.upjet.ir:2053/mute', 'ahmad@mute', 'ahmad@2405', 'active', '2026-02-14 14:42:04'),
(2, 'al', 'https://panel.omid-part.ir:2053/', 'a', 'a', 'active', '2026-02-14 14:44:07');

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

--
-- Table structure for table `representatives`
--

CREATE TABLE `representatives` (
  `id` int(11) NOT NULL,
  `username` varchar(100) NOT NULL,
  `password` varchar(255) NOT NULL,
  `full_name` varchar(255) DEFAULT NULL,
  `email` varchar(255) DEFAULT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `panel_id` int(11) NOT NULL,
  `traffic_limit` bigint(20) DEFAULT 0 COMMENT 'حد ترافیک کل نماینده (بایت)',
  `used_traffic` bigint(20) DEFAULT 0 COMMENT 'ترافیک مصرف شده نماینده (بایت)',
  `expiry_date` datetime DEFAULT NULL COMMENT 'تاریخ انقضای دسترسی نماینده',
  `status` varchar(20) DEFAULT 'active',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `representatives`
--

INSERT INTO `representatives` (`id`, `username`, `password`, `full_name`, `email`, `phone`, `panel_id`, `traffic_limit`, `used_traffic`, `expiry_date`, `status`, `created_at`) VALUES
(1, 'ahmad', '$2y$10$EDZ3D40UfbOhNbYb/TAoHOuo0/CkRcBD4E2jLIQ4Yq.AlDt9bGHim', 'ahmad', 'ahmad.s2405@gmail.com', '09361217580', 1, 0, 0, NULL, 'active', '2026-02-14 14:42:32');

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

--
-- Table structure for table `representative_inbounds`
--

CREATE TABLE `representative_inbounds` (
  `id` int(11) NOT NULL,
  `representative_id` int(11) NOT NULL,
  `inbound_id` int(11) NOT NULL COMMENT 'ID inbound در پنل 3x-ui',
  `inbound_name` varchar(255) DEFAULT NULL COMMENT 'نام inbound برای نمایش',
  `status` varchar(20) DEFAULT 'active',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `representative_logs`
--

CREATE TABLE `representative_logs` (
  `id` int(11) NOT NULL,
  `representative_id` int(11) NOT NULL,
  `action` varchar(100) NOT NULL COMMENT 'نوع عمل: create_user, update_user, delete_user',
  `user_id` int(11) DEFAULT NULL COMMENT 'ID کاربر در reseller_users',
  `details` text DEFAULT NULL COMMENT 'جزئیات عمل',
  `ip_address` varchar(45) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `reseller_users`
--

CREATE TABLE `reseller_users` (
  `id` int(11) NOT NULL,
  `representative_id` int(11) NOT NULL,
  `panel_id` int(11) NOT NULL,
  `xray_user_id` varchar(255) DEFAULT NULL,
  `inbound_id` int(11) DEFAULT NULL,
  `email` varchar(255) NOT NULL,
  `remark` varchar(255) DEFAULT NULL,
  `total_traffic` bigint(20) DEFAULT 0,
  `traffic_limit` bigint(20) DEFAULT 0,
  `expiry_date` datetime DEFAULT NULL,
  `status` varchar(20) DEFAULT 'active',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `admins`
--
ALTER TABLE `admins`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `username` (`username`);

--
-- Indexes for table `panels`
--
ALTER TABLE `panels`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `representatives`
--
ALTER TABLE `representatives`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `username` (`username`),
  ADD KEY `panel_id` (`panel_id`);

--
-- Indexes for table `representative_inbounds`
--
ALTER TABLE `representative_inbounds`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unique_rep_inbound` (`representative_id`,`inbound_id`),
  ADD KEY `representative_id` (`representative_id`);

--
-- Indexes for table `representative_logs`
--
ALTER TABLE `representative_logs`
  ADD PRIMARY KEY (`id`),
  ADD KEY `representative_id` (`representative_id`),
  ADD KEY `created_at` (`created_at`);

--
-- Indexes for table `reseller_users`
--
ALTER TABLE `reseller_users`
  ADD PRIMARY KEY (`id`),
  ADD KEY `representative_id` (`representative_id`),
  ADD KEY `panel_id` (`panel_id`),
  ADD KEY `email` (`email`),
  ADD KEY `status` (`status`),
  ADD KEY `expiry_date` (`expiry_date`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `admins`
--
ALTER TABLE `admins`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `panels`
--
ALTER TABLE `panels`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `representatives`
--
ALTER TABLE `representatives`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `representative_inbounds`
--
ALTER TABLE `representative_inbounds`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `representative_logs`
--
ALTER TABLE `representative_logs`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `reseller_users`
--
ALTER TABLE `reseller_users`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `representatives`
--
ALTER TABLE `representatives`
  ADD CONSTRAINT `fk_representatives_panel` FOREIGN KEY (`panel_id`) REFERENCES `panels` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `reseller_users`
--
ALTER TABLE `reseller_users`
  ADD CONSTRAINT `fk_reseller_users_panel` FOREIGN KEY (`panel_id`) REFERENCES `panels` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_reseller_users_representative` FOREIGN KEY (`representative_id`) REFERENCES `representatives` (`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 */;
