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

START TRANSACTION;



--
-- Database: `erp`
--

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

--
-- Table structure for table `assets_cctv`
--

CREATE TABLE `assets_cctv` (
  `id` int(11) NOT NULL,
  `contract_id` int(11) NOT NULL,
  `camera_no` varchar(20) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `floor_area` varchar(100) DEFAULT NULL,
  `location_details` text DEFAULT NULL,
  `megapixel` varchar(20) DEFAULT NULL,
  `model` varchar(100) DEFAULT NULL,
  `dvr_connection` varchar(50) DEFAULT NULL,
  `channel_no` varchar(20) DEFAULT NULL,
  `client_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `assets_cctv`
--

INSERT INTO `assets_cctv` (`id`, `contract_id`, `camera_no`, `description`, `floor_area`, `location_details`, `megapixel`, `model`, `dvr_connection`, `channel_no`, `client_id`) VALUES
(1, 8, 'cam1', 'شارع امام البوابه الرئيسيه', 'خارجي', 'امام البوابه مباشره', '4', 'Hikvision', 'DVR-1', 'CH1', 0),
(2, 8, 'Cam-2', 'يمين البوابه', 'خارجي', 'يمين البوابه', '4', 'HIKVision', 'DVR-1', 'CH2', 0),
(3, 8, 'Cam-3', 'شمال البوابه', 'خارجي', 'يسار البوابه', '4', 'HIKVision', 'DVR-1', 'CH3', 0),
(4, 8, 'Cam-4', 'كاميرا السور', 'خارجي', 'السور الامامي', '4', 'Hikvision', 'DVR--1', 'CH4', 0),
(5, 8, 'Cam-5', 'كاميرا السور الاخر', 'خارجي', 'السور الجانبي', '4', 'Hikvision', 'DVR-1', 'CH5', 0),
(6, 8, 'Cam-6', 'خلف المستشفي ', 'خارجي', 'الساحات الخلفيه', '4', 'Hikvision', 'DVR-1', 'CH6', 0),
(7, 8, 'Cam-7', 'الباب الخلفي', 'خارجي', 'امام باب المخازن الخلفي', '4', 'Hikvision', 'DVR-1', 'CH7', 0),
(8, 8, 'Cam-8', 'يسار الباب الخلفي', 'خارجي', 'يسار باب الخدمات', '4', 'Hikvision', 'DVR-1', 'CH8', 0),
(9, 8, 'Cam-9', 'يمين الباب الخلفي', 'خارجي', 'يمين باب الخدمات', '4', 'Hikvision', 'DVR-1', 'CH9', 0),
(10, 8, 'Cam-10', 'مداخل المستشفي من الباب الرئيسي', 'داخلي', 'ريسبشن امام الباب', '4', 'Hikvision', 'DVR-1', 'CH10', 0),
(11, 8, 'Cam11', 'الطرقه 1', 'داخلي', 'الطابق الارضي-ممر رقم 1', '2', 'Hikvision', 'DVR-1', 'CH11', 0),
(12, 8, 'Cam12', 'الطرقه 2', 'داخلي', 'الطابق الارضي-ممر رقم 2', '2', 'Hikvision', 'DVR-1', 'CH12', 0),
(13, 8, 'Cam13', 'الطرقه 3', 'داخلي', 'الطابق الارضي-ممر رقم 3', '2', 'Hikvision', 'DVR-1', 'CH13', 0),
(14, 8, 'Cam14', 'الطرقه 4', 'داخلي', 'الطابق الارضي-ممر رقم 4', '2', 'Hikvision', 'DVR-1', 'CH14', 0),
(15, 8, 'Cam15', '', '', '', '', '', '', '', 0),
(16, 8, 'Cam15', '', '', '', '2', 'Hikvision', 'DVR-1', 'CH15', 0),
(17, 8, 'Cam16', '', '', '', '2', 'Hikvision', 'DVR-1', 'CH16', 0),
(18, 8, 'Cam17', 'خلف المستشفي', 'خارجي', 'ساحه خلفيه', '4', 'HIKVision', 'DVR-2', 'CH1', 0),
(19, 8, 'Cam-18', 'الباب الخلفي', 'خارجي', 'مخازن', '4', 'Hikvision', 'DVR-2', 'CH2', 0),
(20, 8, 'Cam-19', 'يسار الباب الخلفي', 'خارجي', 'خدمات', '4', 'Hikvision', 'DVR-2', 'CH3', 0),
(21, 8, 'Cam-20', 'يمين الباب الخلفي', 'خارجي', 'خدمات', '4', 'Hikvision', 'DVR-2', 'CH4', 0),
(22, 8, 'Cam-21', 'كاميرا ممر الدور الاول', 'داخلي', 'ممر رئيسي', '4', 'Hikvision', 'DVR-2', 'CH5', 0),
(23, 8, 'Cam-22', 'كاميرا عيادات الدور الاول', 'داخلي', 'عيادات-مدخل', '4', 'Hikvision', 'DVR-2', 'CH6', 0),
(24, 2, 'Gateway Router', 'admin', 'Glob2@255255', '192.168.1.1', '', 'Hik', '', '', 0),
(25, 2, 'camera 1', 'admin', 'Glob@255255', '192.168.1.10', '', 'Hik', '', '', 0),
(26, 2, 'camera 2', 'admin', 'Glob@255255', '192.168.1.11', '', 'Hik', '', '', 0),
(27, 2, 'camera 3', 'admin', 'Glob@255255', '192.168.1.12', '', 'Hik', '', '', 0),
(28, 2, 'camera 4', 'admin', 'Glob@255255', '192.168.1.13', '', 'Hik', '', '', 0),
(29, 2, 'camera 5', 'admin', 'Glob@255255', '192.168.1.14', '', 'Hik', '', '', 0),
(30, 2, 'Camera 6', 'admin', 'Glob@255255', '192.168.1.15', '', 'Hik', '', '', 0);

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

--
-- Table structure for table `client_files`
--

CREATE TABLE `client_files` (
  `id` int(11) NOT NULL,
  `contract_id` int(11) DEFAULT NULL,
  `file_name` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `contracts`
--

CREATE TABLE `contracts` (
  `id` int(11) NOT NULL,
  `contract_status` varchar(50) DEFAULT NULL,
  `client_name` varchar(200) DEFAULT NULL,
  `contact_person` varchar(200) DEFAULT NULL,
  `job_title` varchar(200) DEFAULT NULL,
  `phone` varchar(50) DEFAULT NULL,
  `address` text DEFAULT NULL,
  `payment_plan` varchar(50) DEFAULT NULL,
  `visits` int(11) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `contract_value` decimal(10,2) NOT NULL DEFAULT 0.00,
  `currency` varchar(10) DEFAULT NULL,
  `location_link` text DEFAULT NULL,
  `start_date` date DEFAULT NULL,
  `end_date` date DEFAULT NULL,
  `contract_duration` int(11) DEFAULT NULL COMMENT 'مدة العقد بالشهور',
  `contract_file` text DEFAULT NULL,
  `client_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `contracts`
--

INSERT INTO `contracts` (`id`, `contract_status`, `client_name`, `contact_person`, `job_title`, `phone`, `address`, `payment_plan`, `visits`, `created_at`, `contract_value`, `currency`, `location_link`, `start_date`, `end_date`, `contract_duration`, `contract_file`, `client_id`) VALUES
(2, 'جاري', 'جولدن فوياج ', 'Mr. Mohamed Shaban', 'CEO', '01140685555', 'المعادى - عين الحياة \r\n5,000- غير شامل ضريبه المبيعات ', '6', 4, '2026-06-13 11:14:58', 5000.00, 'EGP', 'https://maps.app.goo.gl/g3oqzS99djznrz486?g_st=ipc', '2026-04-20', '2026-10-20', 12, '', 0),
(3, 'جاري', 'kabaa bazar', NULL, NULL, '01140685555', NULL, NULL, NULL, '2026-06-13 11:37:36', 0.00, NULL, NULL, NULL, NULL, NULL, NULL, 0),
(4, 'جاري', 'ميتالتك ', 'م. شيماء صقر', 'CEO', '01050898142', 'التجمع - قليوبيه', 'شهري', 1, '2026-06-14 07:31:37', 3000.00, 'EGP', 'https://www.google.com/maps?q=30.1571679,31.2218388&z=17&hl=en', '2026-04-01', '2027-01-14', 12, 'contracts_files/1783865179_Globnetwork maintenance contract -Metal tech 2026-2027 (1).pdf', 0),
(5, 'جاري', 'ارك زوون ', 'م.محمد  سمارة', 'CEO', '01066614824', 'مدينة نصر', 'شهري', 2, '2026-06-14 07:38:16', 3300.00, 'EGP', '', '2026-04-01', '2027-01-14', 12, '', 0),
(6, 'جاري', 'ريبرندينج', 'ياسين محى -', 'Billing', '01156671577', '', '1', 4, '2026-06-14 07:41:33', 7000.00, 'EGP', 'https://maps.google.com/?q=30.112911,31.335041', '2026-05-01', '2026-07-14', 12, '', 0),
(7, 'جاري', 'إسكان', 'مدحت القاضى', 'المدير العام', '01096066614', 'الدقى', 'شهري', 2, '2026-06-14 07:44:26', 5000.00, 'EGP', 'https://maps.google.com/?q=30.055504,31.203060', '2026-06-14', '2027-01-14', 12, '', 0),
(8, 'جاري', 'مستشفى الريان الخيرى 2', 'ايمان عبد الرحمن ', 'CEO', '01002338168', 'المعادى - العميل يحتاج فاتوره ضريبيه', 'شهري', 1, '2026-06-14 07:49:31', 8000.00, 'EGP', 'https://maps.google.com/?q=30.112911,31.335041', '2026-05-01', '2027-05-01', 12, '', 0),
(9, 'جاري', 'Zoho Egypt', 'مونيكا توفيق', 'Operation', '01119984730', 'التجمع الخامس ', '12', 1, '2026-06-14 07:53:51', 12000.00, 'EGP', '', '2026-06-14', '2027-01-14', 12, '', 0),
(10, 'جاري', 'Asset', 'Essra', 'Operation', '01214448351', '', '1', 3, '2026-06-14 07:58:34', 8000.00, 'EGP', '', '2026-05-01', '2026-07-01', 2, '', 0),
(11, 'جاري', 'شركة حراء العقارية', NULL, NULL, '0100161150', NULL, NULL, NULL, '2026-06-14 11:50:54', 0.00, NULL, NULL, NULL, NULL, NULL, NULL, 0);

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

--
-- Table structure for table `contract_payments`
--

CREATE TABLE `contract_payments` (
  `id` int(11) NOT NULL,
  `contract_id` int(11) DEFAULT NULL,
  `payment_date` date DEFAULT NULL,
  `amount` decimal(10,2) DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `status` varchar(20) DEFAULT 'pending'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `contract_payments`
--

INSERT INTO `contract_payments` (`id`, `contract_id`, `payment_date`, `amount`, `notes`, `created_at`, `status`) VALUES
(1, 1, '2026-06-14', 83333.33, NULL, '2026-06-13 11:00:29', 'paid'),
(2, 1, '2026-07-14', 83333.33, NULL, '2026-06-13 11:00:29', 'pending'),
(3, 1, '2026-08-14', 83333.33, NULL, '2026-06-13 11:00:29', 'pending'),
(4, 1, '2026-09-14', 83333.33, NULL, '2026-06-13 11:00:29', 'pending'),
(5, 1, '2026-10-14', 83333.33, NULL, '2026-06-13 11:00:29', 'pending'),
(6, 1, '2026-11-14', 83333.33, NULL, '2026-06-13 11:00:29', 'pending'),
(7, 1, '2026-12-14', 83333.33, NULL, '2026-06-13 11:00:29', 'pending'),
(8, 1, '2027-01-14', 83333.33, NULL, '2026-06-13 11:00:29', 'pending'),
(9, 1, '2027-02-14', 83333.33, NULL, '2026-06-13 11:00:29', 'pending'),
(10, 1, '2027-03-14', 83333.33, NULL, '2026-06-13 11:00:29', 'pending'),
(11, 1, '2027-04-14', 83333.33, NULL, '2026-06-13 11:00:29', 'pending'),
(12, 1, '2027-05-14', 83333.33, NULL, '2026-06-13 11:00:29', 'pending'),
(13, 2, '2026-04-20', 2500.00, NULL, '2026-06-17 08:17:40', 'pending'),
(14, 2, '2026-10-20', 2500.00, NULL, '2026-06-17 08:17:40', 'pending'),
(15, 8, '2026-05-01', 666.67, NULL, '2026-06-17 08:19:14', 'pending'),
(16, 8, '2026-06-01', 666.67, NULL, '2026-06-17 08:19:14', 'pending'),
(17, 8, '2026-07-01', 666.67, NULL, '2026-06-17 08:19:14', 'pending'),
(18, 8, '2026-08-01', 666.67, NULL, '2026-06-17 08:19:14', 'pending'),
(19, 8, '2026-09-01', 666.67, NULL, '2026-06-17 08:19:14', 'pending'),
(20, 8, '2026-10-01', 666.67, NULL, '2026-06-17 08:19:14', 'pending'),
(21, 8, '2026-11-01', 666.67, NULL, '2026-06-17 08:19:14', 'pending'),
(22, 8, '2026-12-01', 666.67, NULL, '2026-06-17 08:19:14', 'pending'),
(23, 8, '2027-01-01', 666.67, NULL, '2026-06-17 08:19:14', 'pending'),
(24, 8, '2027-02-01', 666.67, NULL, '2026-06-17 08:19:14', 'pending'),
(25, 8, '2027-03-01', 666.67, NULL, '2026-06-17 08:19:14', 'pending'),
(26, 8, '2027-04-01', 666.67, NULL, '2026-06-17 08:19:14', 'pending');

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

--
-- Table structure for table `customers`
--

CREATE TABLE `customers` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `phone1` varchar(50) DEFAULT NULL,
  `phone1_name` varchar(100) DEFAULT NULL,
  `phone2` varchar(50) DEFAULT NULL,
  `phone2_name` varchar(100) DEFAULT NULL,
  `email1` varchar(255) DEFAULT NULL,
  `email2` varchar(255) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `engineers`
--

CREATE TABLE `engineers` (
  `id` int(11) NOT NULL,
  `name` varchar(150) DEFAULT NULL,
  `phone` varchar(50) DEFAULT NULL,
  `email` varchar(150) DEFAULT NULL,
  `specialization` varchar(150) DEFAULT NULL,
  `contract_file` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `engineers`
--

INSERT INTO `engineers` (`id`, `name`, `phone`, `email`, `specialization`, `contract_file`) VALUES
(1, 'م أشرف عبد الله', '', '', 'CEO', ''),
(2, 'م محمود محمد أحمد', '', '', 'أنفرا', ''),
(3, 'م رامى رجب ', '', '', 'G I M', ''),
(4, 'م فتحى', '', '', 'برمجه و شبكات', ''),
(5, 'م أسلام', '', '', 'شبكات', ''),
(6, 'م محمد طنطاوى', '', '', 'شبكات ', '');

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

--
-- Table structure for table `engineer_sessions`
--

CREATE TABLE `engineer_sessions` (
  `id` int(11) NOT NULL,
  `engineer_id` int(11) DEFAULT NULL,
  `login_time` datetime DEFAULT NULL,
  `logout_time` datetime DEFAULT NULL,
  `status` varchar(20) DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `invoices`
--

CREATE TABLE `invoices` (
  `id` int(11) NOT NULL,
  `contract_id` int(11) NOT NULL,
  `invoice_date` datetime DEFAULT current_timestamp(),
  `total_amount` decimal(10,2) DEFAULT 0.00,
  `sub_total` decimal(10,2) DEFAULT 0.00,
  `tax_percent` decimal(5,2) DEFAULT 0.00,
  `tax_amount` decimal(10,2) DEFAULT 0.00,
  `notes` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `invoice_installments`
--

CREATE TABLE `invoice_installments` (
  `id` int(11) NOT NULL,
  `invoice_id` int(11) DEFAULT NULL,
  `amount` decimal(10,2) DEFAULT NULL,
  `due_date` date DEFAULT NULL,
  `status` varchar(50) DEFAULT 'unpaid'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `invoice_installments`
--

INSERT INTO `invoice_installments` (`id`, `invoice_id`, `amount`, `due_date`, `status`) VALUES
(1, 1, 15.00, '2026-06-19', 'unpaid'),
(2, 2, 120.00, '2026-06-20', 'unpaid');

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

--
-- Table structure for table `pages`
--

CREATE TABLE `pages` (
  `id` int(11) NOT NULL,
  `page_key` varchar(100) NOT NULL,
  `page_name` varchar(150) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `pages`
--

INSERT INTO `pages` (`id`, `page_key`, `page_name`) VALUES
(1, 'dashboard.php', 'لوحة التحكم الرئيسية'),
(2, 'add_asset.php', 'إضافة أصل جديد'),
(3, 'add_contract.php', 'إضافة عقد جديد'),
(4, 'add_engineer.php', 'إضافة مهندس'),
(5, 'add_quotation.php', 'إضافة عرض سعر'),
(6, 'add_user.php', 'إضافة مستخدم'),
(7, 'calendar.php', 'التقويم والمواعيد'),
(8, 'client_dashboard.php', 'لوحة تحكم العميل'),
(9, 'client_profile.php', 'ملف العميل الشخصي'),
(10, 'contracts.php', 'إدارة العقود'),
(11, 'customer_details.php', 'تفاصيل العميل'),
(12, 'customers.php', 'إدارة العملاء'),
(13, 'edit_contract.php', 'تعديل عقد'),
(14, 'edit_invoice.php', 'تعديل فاتورة'),
(15, 'edit_product.php', 'تعديل صنف / منتج'),
(16, 'edit_purchase.php', 'تعديل فاتورة شراء'),
(17, 'edit_sale.php', 'تعديل فاتورة بيع'),
(18, 'edit_supplier.php', 'تعديل بيانات مورد'),
(19, 'edit_user.php', 'تعديل مستخدم'),
(20, 'engineer_dashboard.php', 'لوحة تحكم المهندس'),
(21, 'engineer_profile.php', 'ملف المهندس الشخصي'),
(22, 'engineer_tracking.php', 'تتبع حركة المهندس'),
(23, 'engineers_live_map.php', 'خريطة المهندسين المباشرة'),
(24, 'engineers.php', 'إدارة المهندسين'),
(25, 'inventory_dashboard.php', 'لوحة تحكم المخزون'),
(26, 'live_engineers_map.php', 'خريطة المهندسين الحية'),
(27, 'print_invoice.php', 'طباعة فاتورة'),
(28, 'print_purchase.Php', 'طباعة فاتورة شراء'),
(29, 'products.php', 'إدارة المنتجات'),
(30, 'purchases.php', 'إدارة المشتريات'),
(31, 'quotations.php', 'قائمة عروض الأسعار'),
(32, 'sales.php', 'إدارة المبيعات'),
(33, 'supplier_invoices.php', 'فواتير الموردين'),
(34, 'suppliers.php', 'إدارة الموردين'),
(35, 'users.php', 'إدارة المستخدمين والصلاحيات'),
(36, 'view_quotation.php', 'عرض عرض السعر');

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

--
-- Table structure for table `permissions`
--

CREATE TABLE `permissions` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `page_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `permissions`
--

INSERT INTO `permissions` (`id`, `user_id`, `page_id`) VALUES
(1, 1, 2),
(2, 1, 3),
(3, 1, 4),
(4, 1, 5),
(5, 1, 6),
(6, 1, 7),
(7, 1, 8),
(8, 1, 9),
(9, 1, 10),
(10, 1, 12),
(11, 1, 11),
(12, 1, 1),
(13, 1, 13),
(14, 1, 14),
(15, 1, 15),
(16, 1, 16),
(17, 1, 17),
(18, 1, 18),
(19, 1, 19),
(20, 1, 24),
(21, 1, 23),
(22, 1, 20),
(23, 1, 21),
(24, 1, 22),
(25, 1, 25),
(26, 1, 26),
(27, 1, 27),
(28, 1, 28),
(29, 1, 29),
(30, 1, 30),
(31, 1, 31),
(32, 1, 32),
(33, 1, 34),
(34, 1, 33),
(35, 1, 35),
(36, 1, 36),
(64, 13, 1),
(65, 13, 4),
(66, 13, 7),
(67, 14, 1),
(68, 14, 2),
(69, 14, 3),
(70, 14, 4),
(71, 14, 5),
(72, 14, 6),
(73, 14, 7),
(74, 14, 8),
(75, 14, 9),
(76, 14, 10),
(77, 14, 11),
(78, 14, 12),
(79, 14, 13),
(80, 14, 14),
(81, 14, 15),
(82, 14, 16),
(83, 14, 17),
(84, 14, 18),
(85, 14, 19),
(86, 14, 20),
(87, 14, 21),
(88, 14, 22),
(89, 14, 23),
(90, 14, 24),
(91, 14, 25),
(92, 14, 26),
(93, 14, 27),
(94, 14, 28),
(95, 14, 29),
(96, 14, 30),
(97, 14, 31),
(98, 14, 32),
(99, 14, 33),
(100, 14, 34),
(101, 14, 35),
(102, 14, 36);

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

--
-- Table structure for table `products`
--

CREATE TABLE `products` (
  `id` int(11) NOT NULL,
  `p_name` varchar(255) NOT NULL,
  `category` varchar(100) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `brand` varchar(100) DEFAULT NULL,
  `supplier_id` int(11) DEFAULT NULL,
  `quantity` int(11) DEFAULT 0,
  `buying_price` decimal(10,2) DEFAULT 0.00,
  `selling_price` decimal(10,2) DEFAULT 0.00,
  `min_quantity` int(11) DEFAULT 5,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `barcode` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `products`
--

INSERT INTO `products` (`id`, `p_name`, `category`, `description`, `brand`, `supplier_id`, `quantity`, `buying_price`, `selling_price`, `min_quantity`, `created_at`, `barcode`) VALUES
(3, 'UCM Series  - 6300 A', 'IP PBX / VoIP Central', 'Enterprise-grade IP PBX solution supporting HD voice, video conferencing, SIP trunk/accounts, call recording, IVR, remote extensions, and unified communication management', 'GrandStream', 2, 10, 0.00, 0.00, 10, '2026-06-13 10:28:51', NULL),
(4, 'UCM 6304A', 'IP PBX / VoIP Central', 'Enterprise-grade IP PBX solution supporting HD voice, video conferencing, SIP trunk/accounts, call recording, IVR, remote extensions, and unified communication management', 'GrandStream ', 2, 10, 0.00, 0.00, 5, '2026-06-13 10:37:34', NULL),
(6, 'P520', 'IP PBX / VoIP Central', 'Compact IP PBX supporting up to 20 users with HD voice, SIP trunk support, IVR, call recording, and remote extensions', 'Yeastar', 3, 10, 18200.00, 21000.00, 10, '2026-06-13 10:49:50', NULL),
(7, 'P520 - License - Enterprise', 'IP PBX / VoIP Central', 'The Yeastar P520 Enterprise Plan is an annual add-on software license that upgrades the Yeastar P520 IP PBX into a full-featured unified communications platform', 'Yeastar', 3, 10, 7280.00, 10000.00, 10, '2026-06-13 10:57:05', NULL),
(8, 'P520 - License - Enterprise', 'IP PBX / VoIP Central', 'The Yeastar P520 Enterprise Plan is an annual add-on software license that upgrades the Yeastar P520 IP PBX into a full-featured unified communications platform', 'Yeastar', 3, 10, 7280.00, 10000.00, 10, '2026-06-13 10:57:39', NULL),
(10, 'CAT7305M', 'Network Cables', 'كابلات برولينك 305 متر', 'Prolink', 2, 5, 0.00, 0.00, 5, '2026-06-13 11:49:13', NULL),
(11, 'Rack 6 U', 'Racks & Cabinets', 'Wall Mount Rack', 'Pro-Rack', 2, 3, 0.00, 0.00, 5, '2026-06-13 11:50:46', NULL),
(12, 'Rack 9 U', 'Racks & Cabinets', 'Wall Mount Rack', 'Pro-Rack', 2, 3, 0.00, 0.00, 5, '2026-06-13 11:51:34', NULL),
(13, 'TA810 Series', 'IP PBX / VoIP Central', 'Analog VoIP gateway with FXO ports for connecting traditional PSTN landlines to IP PBX systems, supporting SIP protocol, HD voice, and easy deployment', 'Yeastar', 3, 5, 0.00, 0.00, 5, '2026-06-15 04:32:27', NULL),
(14, 'TA810 Series', 'IP PBX / VoIP Central', 'Analog VoIP gateway with FXO ports for connecting traditional PSTN landlines to IP PBX systems, supporting SIP protocol, HD voice, and easy deployment', 'Yeastar', 3, 5, 0.00, 0.00, 5, '2026-06-15 04:32:58', NULL),
(15, 'TA810 Series', 'IP PBX / VoIP Central', 'Analog VoIP gateway with FXO ports for connecting traditional PSTN landlines to IP PBX systems, supporting SIP protocol, HD voice, and easy deployment', 'Yeastar', 3, 5, 0.00, 0.00, 5, '2026-06-15 04:33:22', NULL),
(16, 'TA810 Series', 'IP PBX / VoIP Central', 'Analog VoIP gateway with FXO ports for connecting traditional PSTN landlines to IP PBX systems, supporting SIP protocol, HD voice, and easy deployment', 'Yeastar', 3, 5, 0.00, 0.00, 5, '2026-06-15 04:33:33', NULL),
(19, 'UH42', 'IP PBX / VoIP Central', 'Yealink UH42 USB-C/A Mono Headset With Mic For PC Computer, Wired Headphones Teams Certified, Noise Cancelling Microphone, In-Line Controls, All Day Comfort', 'Yealink', 3, 5, 0.00, 0.00, 5, '2026-06-15 06:54:58', NULL),
(20, 'T30P', 'IP PBX / VoIP Central', 'A classic IP phone for small business users, the SIP-T30P delivers a fashionable and user-friendly dialing experience', 'Yealink', 3, 5, 1560.00, 0.00, 5, '2026-06-15 06:57:17', NULL),
(21, 'TG400', 'IP PBX / VoIP Central', '4-channel GSM VoIP gateway supporting SIP and GSM networks, enabling cost-effective mobile-to-VoIP communication with reliable voice quality and easy integration with IP PBX systems', 'Yeastar', 3, 5, 49920.00, 0.00, 5, '2026-06-15 07:00:04', NULL),
(22, 'TA810 Series', 'IP PBX / VoIP Central', 'Analog VoIP gateway with FXO ports for connecting traditional PSTN landlines to IP PBX systems, supporting SIP protocol, HD voice, and easy deployment', 'Yeastar', 3, 5, 0.00, 0.00, 5, '2026-06-15 07:03:16', NULL),
(23, 'O2 Module', 'IP PBX / VoIP Central', '2 RJ11 FXO Ports', 'Yeastar', 3, 5, 0.00, 0.00, 5, '2026-06-15 07:04:35', NULL),
(25, 'VoIP FXO Gateway', 'IP PBX / VoIP Central', 'Analog VoIP gateway with FXO ports for connecting traditional PSTN landlines to IP PBX systems, supporting SIP protocol, HD voice, and easy deployment', 'Yeastar', 3, 5, 0.00, 0.00, 5, '2026-06-15 08:22:54', NULL),
(26, 'TG400', 'VoIP GSM Gateway', '4-channel GSM VoIP gateway supporting SIP and GSM networks, enabling cost-effective mobile-to-VoIP communication with reliable voice quality and easy integration with IP PBX systems', 'Yeastar', 3, 5, 49920.00, 0.00, 5, '2026-06-15 08:27:09', NULL),
(27, 'TG400', 'VoIP GSM Gateway', '4-channel GSM VoIP gateway supporting SIP and GSM networks, enabling cost-effective mobile-to-VoIP communication with reliable voice quality and easy integration with IP PBX systems', 'Yeastar', 3, 5, 49920.00, 0.00, 5, '2026-06-15 08:29:26', NULL),
(28, 'UH34 Dual', 'Headsets', 'Professional USB headset with HD audio, noise cancelling microphone, and comfortable lightweight design for office and call center use', 'Yealink', 3, 5, 1820.00, 2000.00, 5, '2026-06-15 08:32:27', NULL),
(29, 'UH42', 'Headsets', 'Yealink UH42 USB-C/A Mono Headset With Mic For PC Computer, Wired Headphones Teams Certified, Noise Cancelling Microphone, In-Line Controls, All Day Comfort', 'Yealink', 3, 5, 0.00, 0.00, 5, '2026-06-15 08:34:04', NULL),
(30, 'P560', 'IP PBX / VoIP Central', 'Advanced IP PBX supporting up to 100 users with HD audio, remote working, call recording, CRM integration, and unified communication features', 'Yeastar', 3, 5, 0.00, 0.00, 5, '2026-06-15 08:38:46', NULL),
(31, 'P550', 'IP PBX / VoIP Central', 'Business IP PBX supporting up to 50 users with unified communications, HD voice, SIP integration, IVR, and call center features', 'Yeastar', 3, 5, 0.00, 0.00, 5, '2026-06-15 08:40:40', NULL),
(32, 'P520 - License - Enterprise', 'IP PBX / VoIP Central', 'The Yeastar P520 Enterprise Plan is an annual add-on software license that upgrades the Yeastar P520 IP PBX into a full-featured unified communications platform', 'Yeastar', 3, 5, 7280.00, 10000.00, 5, '2026-06-15 08:43:58', NULL),
(33, 'GrandStream 4-port VoIP gateway (HT841)', 'VOIP LandLine Gateway', 'The HT841 is a powerful 4-port VoIP gateway with 4 FXS ports and an integrated Gigabit NAT router. Built for users looking for a strong analog-to-VoIP converter', 'Grandstream', 3, 5, 8715.00, 9100.00, 5, '2026-06-15 08:57:41', NULL),
(34, 'GrandStream 8-port VoIP gateway (HT818 v2)', 'VOIP LandLine Gateway', 'The GUV3000 is HD USB Headsets that pair with Laptops,Computers, IP Telephones and other devices to offer high quality sound ', 'Grandstream', 3, 5, 1417.00, 1500.00, 5, '2026-06-15 08:59:47', NULL);

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

--
-- Table structure for table `purchases`
--

CREATE TABLE `purchases` (
  `id` int(11) NOT NULL,
  `product_id` int(11) DEFAULT NULL,
  `supplier_id` int(11) DEFAULT NULL,
  `p_name` varchar(255) DEFAULT NULL,
  `quantity` int(11) DEFAULT NULL,
  `purchase_price` decimal(10,2) DEFAULT NULL,
  `purchase_date` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `quotations`
--

CREATE TABLE `quotations` (
  `id` int(11) NOT NULL,
  `customer_name` varchar(255) NOT NULL,
  `tax_percentage` decimal(5,2) DEFAULT 0.00,
  `special_terms` text DEFAULT NULL,
  `grand_total` decimal(10,2) NOT NULL DEFAULT 0.00,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `quotations`
--

INSERT INTO `quotations` (`id`, `customer_name`, `tax_percentage`, `special_terms`, `grand_total`, `created_at`) VALUES
(1, 'Ora Dev.', 14.00, 'Down Payment \r\n20% in advance \r\n80% after installation', 25992.00, '2026-06-17 11:18:34');

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

--
-- Table structure for table `quotation_items`
--

CREATE TABLE `quotation_items` (
  `id` int(11) NOT NULL,
  `quotation_id` int(11) NOT NULL,
  `product_name` varchar(255) NOT NULL,
  `quantity` int(11) NOT NULL,
  `selling_price` decimal(10,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `quotation_items`
--

INSERT INTO `quotation_items` (`id`, `quotation_id`, `product_name`, `quantity`, `selling_price`) VALUES
(1, 1, 'P520', 1, 21000.00),
(2, 1, 'T30P', 1, 1800.00);

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

--
-- Table structure for table `received_payments`
--

CREATE TABLE `received_payments` (
  `id` int(11) NOT NULL,
  `contract_id` int(11) DEFAULT NULL,
  `payment_date` date DEFAULT NULL,
  `amount` decimal(10,2) DEFAULT NULL,
  `payment_method` varchar(50) DEFAULT NULL,
  `notes` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `received_payments`
--

INSERT INTO `received_payments` (`id`, `contract_id`, `payment_date`, `amount`, `payment_method`, `notes`) VALUES
(1, 1, '2026-06-14', 83333.33, 'نقدي', ''),
(2, 2, '2026-04-20', 2500.00, 'نقدي', '');

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

--
-- Table structure for table `sales`
--

CREATE TABLE `sales` (
  `id` int(11) NOT NULL,
  `customer_name` varchar(255) DEFAULT NULL,
  `product_id` int(11) DEFAULT NULL,
  `p_name` varchar(255) DEFAULT NULL,
  `quantity` int(11) DEFAULT NULL,
  `buying_price` decimal(10,2) DEFAULT NULL,
  `selling_price` decimal(10,2) DEFAULT NULL,
  `sale_date` timestamp NOT NULL DEFAULT current_timestamp(),
  `invoice_id` int(11) DEFAULT NULL,
  `quantity_delivered` int(11) DEFAULT 0,
  `quantity_pending` int(11) DEFAULT 0,
  `delivery_due_date` date DEFAULT NULL,
  `item_barcode` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `sales`
--

INSERT INTO `sales` (`id`, `customer_name`, `product_id`, `p_name`, `quantity`, `buying_price`, `selling_price`, `sale_date`, `invoice_id`, `quantity_delivered`, `quantity_pending`, `delivery_due_date`, `item_barcode`) VALUES
(1, NULL, 1, 'سيرفر', 2, 100.00, 500.00, '2026-06-14 09:36:16', 1, 1, 1, '2026-06-23', '125125'),
(2, NULL, 1, 'سيرفر', 1, 100.00, 500.00, '2026-06-14 09:38:31', 2, 1, 0, '2026-06-29', '123'),
(3, NULL, 1, 'سيرفر', 1, 100.00, 500.00, '2026-06-14 09:38:31', 2, 1, 0, '2026-06-28', '1234'),
(4, NULL, 5, 'فلاشه', 1, 100.00, 100.00, '2026-06-14 10:08:23', 3, 1, 0, '2026-06-19', '100'),
(7, NULL, 5, 'فلاشه', 20, 100.00, 100.00, '2026-06-14 10:22:10', 4, 15, 5, '2026-06-10', '200'),
(8, NULL, 1, 'سيرفر', 2, 100.00, 500.00, '2026-06-14 10:22:10', 4, 1, 1, '2026-06-22', '150');

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

--
-- Table structure for table `suppliers`
--

CREATE TABLE `suppliers` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `phone` varchar(50) DEFAULT NULL,
  `address` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

--
-- Dumping data for table `suppliers`
--

INSERT INTO `suppliers` (`id`, `name`, `phone`, `address`, `created_at`) VALUES
(2, 'Brand Connection', '', 'التجمع الخامس', '2026-06-13 10:32:12'),
(3, 'Provad', '', 'مصر الجديده', '2026-06-13 10:32:21'),
(5, 'محمد - ديجتال دريمز', '01004402290', 'مصر الجديدة', '2026-06-13 11:21:47'),
(6, 'الشعار', '01092959721', 'مصر الجديدة', '2026-06-13 11:24:23'),
(7, 'حليم - سمارت زوم', '01066936816', 'التجمع الخامس', '2026-06-13 11:26:37'),
(8, ' تريزا- Smart vision', '01228258502', 'مساكن شيراتون', '2026-06-13 11:27:39'),
(9, 'رضوى - Fiber Me', '01276001166', 'التجمع الخامس', '2026-06-15 06:40:03'),
(10, 'حسين- Gila', '01099917708', 'وسط البلد', '2026-06-15 10:15:03');

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

--
-- Table structure for table `visits`
--

CREATE TABLE `visits` (
  `id` int(11) NOT NULL,
  `contract_id` int(11) DEFAULT NULL,
  `visit_date` date DEFAULT NULL,
  `engineer_name` varchar(150) DEFAULT NULL,
  `report_file` varchar(255) DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `engineer_id` int(11) DEFAULT NULL,
  `client_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `visits`
--

INSERT INTO `visits` (`id`, `contract_id`, `visit_date`, `engineer_name`, `report_file`, `notes`, `engineer_id`, `client_id`) VALUES
(1, 8, '2026-07-11', NULL, '1783776162_Clinic Dr Mohamed Rabie.pdf', NULL, 4, 0);

--
-- Indexes for dumped tables
--

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

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

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

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

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

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

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

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

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

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

--
-- Indexes for table `permissions`
--
ALTER TABLE `permissions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `page_id` (`page_id`);

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

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

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

--
-- Indexes for table `quotation_items`
--
ALTER TABLE `quotation_items`
  ADD PRIMARY KEY (`id`),
  ADD KEY `quotation_id` (`quotation_id`);

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

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

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

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

--
-- AUTO_INCREMENT for dumped tables
--

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `quotation_items`
--
ALTER TABLE `quotation_items`
  ADD CONSTRAINT `quotation_items_ibfk_1` FOREIGN KEY (`quotation_id`) REFERENCES `quotations` (`id`) ON DELETE CASCADE;
COMMIT;

