-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: May 19, 2025 at 06:30 AM
-- Server version: 10.4.28-MariaDB
-- PHP Version: 8.1.17

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: `viveks`
--

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

--
-- Table structure for table `crm_tickets`
--

CREATE TABLE `crm_tickets` (
  `id` int(11) NOT NULL,
  `ticket_no` varchar(255) DEFAULT NULL,
  `mobile` varchar(20) DEFAULT NULL,
  `customer_name` varchar(255) DEFAULT NULL,
  `email` varchar(100) DEFAULT NULL,
  `location` varchar(150) DEFAULT NULL,
  `product_enquiry` int(11) DEFAULT NULL,
  `branch_id` int(11) DEFAULT NULL,
  `branch` varchar(255) DEFAULT NULL,
  `department` int(11) DEFAULT NULL,
  `ticket_category` int(11) DEFAULT NULL,
  `users` int(11) DEFAULT NULL,
  `reason` int(11) DEFAULT NULL,
  `ticket_source` int(11) DEFAULT NULL,
  `ticket_type` int(11) DEFAULT NULL,
  `priority` int(11) DEFAULT NULL,
  `expected_date` date DEFAULT NULL,
  `expected_price` decimal(12,2) DEFAULT NULL,
  `offer_price` decimal(12,2) DEFAULT NULL,
  `ticket_comment` text DEFAULT NULL,
  `secondary_mobile` varchar(20) DEFAULT NULL,
  `address` varchar(255) DEFAULT NULL,
  `request_category` int(11) DEFAULT NULL,
  `attachments` text DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `read_status` tinyint(4) DEFAULT NULL COMMENT '1 - read\r\n2 - call done',
  `status` tinyint(4) NOT NULL DEFAULT 1,
  `call_type` varchar(100) DEFAULT NULL,
  `called_for` varchar(100) DEFAULT NULL,
  `follwup_date` date DEFAULT NULL,
  `talked_with` varchar(100) DEFAULT NULL,
  `update_comments` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `crm_tickets`
--
ALTER TABLE `crm_tickets`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `deleted_at` (`deleted_at`),
  ADD KEY `crm_ticket_branch_foreign_constraints` (`branch_id`),
  ADD KEY `created_at` (`created_at`),
  ADD KEY `crm_product_foreign_constrainst` (`product_enquiry`),
  ADD KEY `crm_sub_dept_foreign_constrainst` (`department`),
  ADD KEY `crm_ticket_category_foreign_constrainst` (`ticket_category`),
  ADD KEY `crm_agent_foreign_constrainsts` (`users`),
  ADD KEY `crm_ticket_source_foreign_constraints` (`ticket_source`),
  ADD KEY `crm_ticket_type_foreign_constraints` (`ticket_type`),
  ADD KEY `crm_ticket_priority_foreign_constraints` (`priority`),
  ADD KEY `crm_ticket_request_category_foreign_constrainst` (`request_category`),
  ADD KEY `crm_tickets_reason_foreign_constrainst` (`reason`);

--
-- AUTO_INCREMENT for dumped tables
--

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `crm_tickets`
--
ALTER TABLE `crm_tickets`
  ADD CONSTRAINT `crm_agent_foreign_constrainsts` FOREIGN KEY (`users`) REFERENCES `agent_master` (`id`),
  ADD CONSTRAINT `crm_branch_foreign_constrainst` FOREIGN KEY (`branch_id`) REFERENCES `branch_master` (`id`),
  ADD CONSTRAINT `crm_product_foreign_constrainst` FOREIGN KEY (`product_enquiry`) REFERENCES `crm_products` (`id`),
  ADD CONSTRAINT `crm_sub_dept_foreign_constrainst` FOREIGN KEY (`department`) REFERENCES `sub_departments` (`id`),
  ADD CONSTRAINT `crm_ticket_branch_foreign_constraints` FOREIGN KEY (`branch_id`) REFERENCES `branch_master` (`id`),
  ADD CONSTRAINT `crm_ticket_category_foreign_constrainst` FOREIGN KEY (`ticket_category`) REFERENCES `ticket_category` (`id`),
  ADD CONSTRAINT `crm_ticket_priority_foreign_constraints` FOREIGN KEY (`priority`) REFERENCES `priority_type` (`id`),
  ADD CONSTRAINT `crm_ticket_request_category_foreign_constrainst` FOREIGN KEY (`request_category`) REFERENCES `request_category` (`id`),
  ADD CONSTRAINT `crm_ticket_source_foreign_constraints` FOREIGN KEY (`ticket_source`) REFERENCES `ticket_source` (`id`),
  ADD CONSTRAINT `crm_ticket_type_foreign_constraints` FOREIGN KEY (`ticket_type`) REFERENCES `ticket_type` (`id`),
  ADD CONSTRAINT `crm_tickets_reason_foreign_constrainst` FOREIGN KEY (`reason`) REFERENCES `ticket_close_reason` (`id`);
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 */;
