-- https://www.phpmyadmin.net/
--

START TRANSACTION;



--
-- Database: `oxygen_dashboard`
--

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

--
-- Table structure for table `audit_logs`
--

CREATE TABLE `audit_logs` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `action_performed` varchar(255) NOT NULL,
  `ip_address` varchar(45) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `coupons`
--

CREATE TABLE `coupons` (
  `id` int(11) NOT NULL,
  `category` varchar(100) NOT NULL,
  `coupon_number` varchar(100) NOT NULL,
  `amount` decimal(10,3) NOT NULL,
  `valid_days` int(11) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `coupons`
--

INSERT INTO `coupons` (`id`, `category`, `coupon_number`, `amount`, `valid_days`, `created_at`) VALUES
(1, 'Gift', '123456', 50.000, 30, '2026-08-19 19:58:19');

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

--
-- Table structure for table `coupon_requests`
--

CREATE TABLE `coupon_requests` (
  `id` int(11) NOT NULL,
  `customer_id` int(11) NOT NULL,
  `request_name` varchar(255) NOT NULL,
  `civil_id` varchar(50) NOT NULL,
  `mobile_no` varchar(50) NOT NULL,
  `email` varchar(255) DEFAULT NULL,
  `requested_amount` decimal(10,3) DEFAULT NULL,
  `civil_id_front` varchar(255) NOT NULL,
  `civil_id_back` varchar(255) NOT NULL,
  `status` varchar(50) DEFAULT 'Pending',
  `assigned_coupon` varchar(100) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `reject_notes` text DEFAULT NULL,
  `payment_screenshot` varchar(255) DEFAULT NULL,
  `sms_sent` tinyint(1) DEFAULT 0,
  `payment_status` varchar(50) DEFAULT 'Unpaid',
  `payment_id` varchar(255) DEFAULT NULL,
  `expires_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `coupon_requests`
--

INSERT INTO `coupon_requests` (`id`, `customer_id`, `request_name`, `civil_id`, `mobile_no`, `email`, `requested_amount`, `civil_id_front`, `civil_id_back`, `status`, `assigned_coupon`, `created_at`, `reject_notes`, `payment_screenshot`, `sms_sent`, `payment_status`, `payment_id`, `expires_at`) VALUES
(1, 1, 'test', '287052002590', '50538778', 'test1@gmail.com', 50.000, 'uploads/1787170885_front_SAS Network Diagram.png', 'uploads/1787170885_back_SAS Network Diagram.png', 'Pending', NULL, '2026-08-19 20:21:25', NULL, NULL, 0, 'Unpaid', NULL, NULL);

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

--
-- Table structure for table `roles`
--

CREATE TABLE `roles` (
  `id` int(11) NOT NULL,
  `role_name` varchar(100) NOT NULL,
  `description` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `roles`
--

INSERT INTO `roles` (`id`, `role_name`, `description`, `created_at`) VALUES
(1, 'Super Admin', 'Full system access and management.', '2026-08-19 20:23:52'),
(2, 'Accounts', '', '2026-08-19 20:43:10');

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

--
-- Table structure for table `role_permissions`
--

CREATE TABLE `role_permissions` (
  `id` int(11) NOT NULL,
  `role_id` int(11) NOT NULL,
  `module` varchar(50) NOT NULL,
  `can_view` tinyint(1) DEFAULT 0,
  `can_add` tinyint(1) DEFAULT 0,
  `can_edit` tinyint(1) DEFAULT 0,
  `can_delete` tinyint(1) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `role_permissions`
--

INSERT INTO `role_permissions` (`id`, `role_id`, `module`, `can_view`, `can_add`, `can_edit`, `can_delete`) VALUES
(1, 2, 'Customers', 1, 1, 1, 0),
(2, 2, 'Coupons', 1, 1, 1, 0),
(3, 2, 'Requests', 0, 0, 0, 0),
(4, 2, 'Users', 0, 0, 0, 0),
(5, 2, 'Roles', 0, 0, 0, 0);

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

--
-- Table structure for table `webhook_settings`
--

CREATE TABLE `webhook_settings` (
  `id` int(11) NOT NULL DEFAULT 1,
  `slack_url` varchar(255) DEFAULT NULL,
  `slack_enabled` tinyint(1) DEFAULT 0,
  `teams_url` varchar(255) DEFAULT NULL,
  `teams_enabled` tinyint(1) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `webhook_settings`
--

INSERT INTO `webhook_settings` (`id`, `slack_url`, `slack_enabled`, `teams_url`, `teams_enabled`) VALUES
(1, NULL, 0, NULL, 0);

--
-- Indexes for dumped tables
--

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

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

--
-- Indexes for table `coupon_requests`
--
ALTER TABLE `coupon_requests`
  ADD PRIMARY KEY (`id`),
  ADD KEY `customer_id` (`customer_id`),
  ADD KEY `idx_civil_id` (`civil_id`);

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

--
-- Indexes for table `role_permissions`
--
ALTER TABLE `role_permissions`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `role_module` (`role_id`,`module`);

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

--
-- AUTO_INCREMENT for dumped tables
--

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

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

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

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

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `coupon_requests`
--
ALTER TABLE `coupon_requests`
  ADD CONSTRAINT `coupon_requests_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `role_permissions`
--
ALTER TABLE `role_permissions`
  ADD CONSTRAINT `role_permissions_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE;
COMMIT;

