diff --git a/complete_schema.sql b/db/schema.sql similarity index 72% rename from complete_schema.sql rename to db/schema.sql index 90b1906..1572283 100644 --- a/complete_schema.sql +++ b/db/schema.sql @@ -34,7 +34,7 @@ CREATE TABLE `acc_accounts` ( UNIQUE KEY `code` (`code`), KEY `parent_id` (`parent_id`), CONSTRAINT `acc_accounts_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `acc_accounts` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=46 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -53,7 +53,7 @@ CREATE TABLE `acc_journal_entries` ( `source_id` int(11) DEFAULT NULL, `created_at` timestamp NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=102 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=136 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -74,7 +74,7 @@ CREATE TABLE `acc_ledger` ( KEY `account_id` (`account_id`), CONSTRAINT `acc_ledger_ibfk_1` FOREIGN KEY (`journal_entry_id`) REFERENCES `acc_journal_entries` (`id`) ON DELETE CASCADE, CONSTRAINT `acc_ledger_ibfk_2` FOREIGN KEY (`account_id`) REFERENCES `acc_accounts` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=309 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=409 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -133,7 +133,7 @@ CREATE TABLE `customers` ( `loyalty_tier` enum('bronze','silver','gold') DEFAULT 'bronze', `total_spent` decimal(15,3) DEFAULT 0.000, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -154,7 +154,7 @@ CREATE TABLE `discount_codes` ( `created_at` timestamp NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), UNIQUE KEY `code` (`code`) -) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -339,14 +339,13 @@ CREATE TABLE `invoice_items` ( `item_id` int(11) NOT NULL, `quantity` decimal(15,2) NOT NULL, `unit_price` decimal(15,3) DEFAULT 0.000, - `vat_amount` decimal(15,3) DEFAULT 0.000, `total_price` decimal(15,3) DEFAULT 0.000, PRIMARY KEY (`id`), KEY `invoice_id` (`invoice_id`), KEY `item_id` (`item_id`), CONSTRAINT `invoice_items_ibfk_1` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE, CONSTRAINT `invoice_items_ibfk_2` FOREIGN KEY (`item_id`) REFERENCES `stock_items` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -358,9 +357,9 @@ DROP TABLE IF EXISTS `invoices`; /*!40101 SET character_set_client = utf8mb4 */; CREATE TABLE `invoices` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `transaction_no` varchar(50) DEFAULT NULL, `customer_id` int(11) DEFAULT NULL, `invoice_date` date NOT NULL, + `type` enum('sale','purchase') NOT NULL, `payment_type` varchar(100) DEFAULT NULL, `total_amount` decimal(15,3) DEFAULT 0.000, `created_at` timestamp NULL DEFAULT current_timestamp(), @@ -368,18 +367,11 @@ CREATE TABLE `invoices` ( `total_with_vat` decimal(15,3) DEFAULT 0.000, `terms_conditions` text DEFAULT NULL, `paid_amount` decimal(15,3) DEFAULT 0.000, - `status` enum('paid','unpaid','partially_paid','refunded','cancelled') DEFAULT 'unpaid', - `register_session_id` int(11) DEFAULT NULL, - `due_date` date DEFAULT NULL, - `is_pos` tinyint(1) DEFAULT 0, - `discount_amount` decimal(15,3) DEFAULT 0.000, - `loyalty_points_earned` decimal(15,3) DEFAULT 0.000, - `loyalty_points_redeemed` decimal(15,3) DEFAULT 0.000, - `created_by` int(11) DEFAULT NULL, + `status` enum('paid','unpaid','partially_paid') DEFAULT 'unpaid', PRIMARY KEY (`id`), KEY `customer_id` (`customer_id`), CONSTRAINT `invoices_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`) ON DELETE SET NULL -) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -421,7 +413,7 @@ CREATE TABLE `loyalty_transactions` ( PRIMARY KEY (`id`), KEY `customer_id` (`customer_id`), CONSTRAINT `loyalty_transactions_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -445,7 +437,7 @@ CREATE TABLE `lpo_items` ( KEY `item_id` (`item_id`), CONSTRAINT `lpo_items_ibfk_1` FOREIGN KEY (`lpo_id`) REFERENCES `lpos` (`id`) ON DELETE CASCADE, CONSTRAINT `lpo_items_ibfk_2` FOREIGN KEY (`item_id`) REFERENCES `stock_items` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -467,9 +459,9 @@ CREATE TABLE `lpos` ( `terms_conditions` text DEFAULT NULL, `created_at` timestamp NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), - KEY `lpos_ibfk_1` (`supplier_id`), - CONSTRAINT `lpos_ibfk_1` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + KEY `supplier_id` (`supplier_id`), + CONSTRAINT `lpos_ibfk_1` FOREIGN KEY (`supplier_id`) REFERENCES `customers` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -484,7 +476,7 @@ CREATE TABLE `migrations` ( `migration` varchar(255) NOT NULL, `executed_at` timestamp NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -518,11 +510,10 @@ CREATE TABLE `payments` ( `payment_method` varchar(50) DEFAULT 'Cash', `notes` text DEFAULT NULL, `created_at` timestamp NULL DEFAULT current_timestamp(), - `transaction_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `invoice_id` (`invoice_id`), CONSTRAINT `payments_ibfk_1` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -562,7 +553,7 @@ CREATE TABLE `pos_held_carts` ( PRIMARY KEY (`id`), KEY `customer_id` (`customer_id`), CONSTRAINT `pos_held_carts_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`) ON DELETE SET NULL -) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -578,13 +569,11 @@ CREATE TABLE `pos_items` ( `product_id` int(11) NOT NULL, `quantity` decimal(15,3) NOT NULL, `unit_price` decimal(15,3) NOT NULL, - `vat_rate` decimal(5,2) DEFAULT 0.00, - `vat_amount` decimal(15,3) DEFAULT 0.000, `subtotal` decimal(15,3) NOT NULL, PRIMARY KEY (`id`), KEY `transaction_id` (`transaction_id`), CONSTRAINT `pos_items_ibfk_1` FOREIGN KEY (`transaction_id`) REFERENCES `pos_transactions` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=73 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -628,10 +617,9 @@ CREATE TABLE `pos_transactions` ( `status` enum('completed','refunded','cancelled') DEFAULT 'completed', `created_at` timestamp NULL DEFAULT current_timestamp(), `created_by` int(11) DEFAULT NULL, - `register_session_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `transaction_no` (`transaction_no`) -) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -691,7 +679,7 @@ CREATE TABLE `purchase_return_items` ( KEY `item_id` (`item_id`), CONSTRAINT `purchase_return_items_ibfk_1` FOREIGN KEY (`return_id`) REFERENCES `purchase_returns` (`id`) ON DELETE CASCADE, CONSTRAINT `purchase_return_items_ibfk_2` FOREIGN KEY (`item_id`) REFERENCES `stock_items` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -703,18 +691,18 @@ DROP TABLE IF EXISTS `purchase_returns`; /*!40101 SET character_set_client = utf8mb4 */; CREATE TABLE `purchase_returns` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `purchase_id` int(11) NOT NULL, + `invoice_id` int(11) NOT NULL, `supplier_id` int(11) DEFAULT NULL, `return_date` date NOT NULL, `total_amount` decimal(15,3) NOT NULL DEFAULT 0.000, `notes` text DEFAULT NULL, `created_at` timestamp NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), - KEY `purchase_returns_ibfk_1` (`purchase_id`), - KEY `purchase_returns_ibfk_2` (`supplier_id`), - CONSTRAINT `purchase_returns_ibfk_1` FOREIGN KEY (`purchase_id`) REFERENCES `purchases` (`id`) ON DELETE CASCADE, + KEY `invoice_id` (`invoice_id`), + KEY `supplier_id` (`supplier_id`), + CONSTRAINT `purchase_returns_ibfk_1` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE, CONSTRAINT `purchase_returns_ibfk_2` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`id`) ON DELETE SET NULL -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -755,7 +743,6 @@ CREATE TABLE `quotation_items` ( `item_id` int(11) NOT NULL, `quantity` decimal(15,2) NOT NULL, `unit_price` decimal(15,3) DEFAULT 0.000, - `vat_amount` decimal(15,3) DEFAULT 0.000, `total_price` decimal(15,3) DEFAULT 0.000, PRIMARY KEY (`id`), KEY `quotation_id` (`quotation_id`), @@ -821,6 +808,7 @@ DROP TABLE IF EXISTS `role_groups`; CREATE TABLE `role_groups` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, + `permissions` text DEFAULT NULL, `created_at` timestamp NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; @@ -862,7 +850,7 @@ CREATE TABLE `sales_return_items` ( KEY `item_id` (`item_id`), CONSTRAINT `sales_return_items_ibfk_1` FOREIGN KEY (`return_id`) REFERENCES `sales_returns` (`id`) ON DELETE CASCADE, CONSTRAINT `sales_return_items_ibfk_2` FOREIGN KEY (`item_id`) REFERENCES `stock_items` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -885,7 +873,7 @@ CREATE TABLE `sales_returns` ( KEY `customer_id` (`customer_id`), CONSTRAINT `sales_returns_ibfk_1` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE, CONSTRAINT `sales_returns_ibfk_2` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`) ON DELETE SET NULL -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -916,7 +904,7 @@ CREATE TABLE `stock_categories` ( `name_ar` varchar(255) NOT NULL, `created_at` timestamp NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -954,7 +942,7 @@ CREATE TABLE `stock_items` ( CONSTRAINT `fk_stock_items_supplier` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`id`) ON DELETE SET NULL, CONSTRAINT `stock_items_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `stock_categories` (`id`) ON DELETE SET NULL, CONSTRAINT `stock_items_ibfk_2` FOREIGN KEY (`unit_id`) REFERENCES `stock_units` (`id`) ON DELETE SET NULL -) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -993,7 +981,7 @@ CREATE TABLE `suppliers` ( `created_at` timestamp NULL DEFAULT current_timestamp(), `total_spent` decimal(15,3) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -1015,7 +1003,7 @@ CREATE TABLE `system_license` ( `trial_started_at` datetime DEFAULT NULL, `allowed_activations` int(11) DEFAULT 1, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -1033,9 +1021,9 @@ CREATE TABLE `users` ( `email` varchar(255) DEFAULT NULL, `phone` varchar(20) DEFAULT NULL, `profile_pic` varchar(255) DEFAULT NULL, + `theme` varchar(20) DEFAULT 'default', `status` enum('active','inactive') DEFAULT 'active', `created_at` timestamp NULL DEFAULT current_timestamp(), - `theme` varchar(50) DEFAULT 'default', PRIMARY KEY (`id`), UNIQUE KEY `username` (`username`), KEY `group_id` (`group_id`), @@ -1052,373 +1040,4 @@ CREATE TABLE `users` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2026-02-21 7:13:34 -/*M!999999\- enable the sandbox mode */ --- MariaDB dump 10.19 Distrib 10.11.14-MariaDB, for debian-linux-gnu (x86_64) --- --- Host: 127.0.0.1 Database: app_38471 --- ------------------------------------------------------ --- Server version 10.11.14-MariaDB-0+deb12u2 - -/*!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 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Dumping data for table `migrations` --- - -LOCK TABLES `migrations` WRITE; -/*!40000 ALTER TABLE `migrations` DISABLE KEYS */; -INSERT INTO `migrations` VALUES -(1,'20260216_add_invoices.sql','2026-02-21 06:58:26'), -(2,'20260216_add_quotations.sql','2026-02-21 06:58:26'), -(3,'20260216_add_stock_tables.sql','2026-02-21 06:58:26'), -(4,'20260216_pos_advanced_features.sql','2026-02-21 06:58:26'), -(5,'20260216_setup_pos_full.sql','2026-02-21 06:58:27'), -(6,'20260216_update_precision_3_decimal.sql','2026-02-21 06:58:28'), -(7,'20260217_accounting_module.sql','2026-02-21 06:58:28'), -(8,'20260217_biometric_devices.sql','2026-02-21 06:58:28'), -(9,'20260217_hr_module.sql','2026-02-21 06:58:28'), -(10,'20260217_purchase_returns.sql','2026-02-21 06:58:28'), -(11,'20260217_sales_returns.sql','2026-02-21 06:58:28'), -(12,'20260217_vat_accounts.sql','2026-02-21 06:58:28'), -(13,'20260218_create_license_table.sql','2026-02-21 06:58:28'), -(14,'20260218_pos_payments.sql','2026-02-21 06:58:28'), -(15,'20260220_license_server_schema.sql','2026-02-21 06:58:28'), -(16,'20260220_unify_pos_sales.sql','2026-02-21 06:58:29'), -(17,'fix_lpo_foreign_key.sql','2026-02-21 06:58:29'), -(18,'20260216_add_credit_limit.sql','2026-02-21 07:12:15'), -(19,'20260216_add_invoice_status.sql','2026-02-21 07:12:15'), -(20,'20260216_add_payments_table.sql','2026-02-21 07:12:15'), -(21,'20260216_update_invoices_payment.sql','2026-02-21 07:12:15'), -(22,'20260216_vat_and_profile.sql','2026-02-21 07:12:15'), -(23,'20260217_biometric_attendance.sql','2026-02-21 07:12:15'), -(24,'20260217_biometric_logs_update.sql','2026-02-21 07:12:15'), -(25,'20260217_hr_payroll_unique.sql','2026-02-21 07:12:15'), -(26,'20260218_modern_loyalty_system.sql','2026-02-21 07:12:15'), -(27,'20260219_add_license_fields.sql','2026-02-21 07:12:15'), -(28,'20260219_add_trial_logic.sql','2026-02-21 07:12:15'), -(29,'20260219_add_vat_to_pos_items.sql','2026-02-21 07:12:15'), -(30,'20260219_fix_vat_columns.sql','2026-02-21 07:12:15'), -(31,'20260220_add_due_date_to_invoices.sql','2026-02-21 07:12:15'), -(32,'20260220_split_customers_suppliers.sql','2026-02-21 07:12:15'), -(33,'20260220_split_invoices_purchases.sql','2026-02-21 07:12:15'), -(34,'20260220_unify_pos_sales.php','2026-02-21 07:13:28'); -/*!40000 ALTER TABLE `migrations` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `payment_methods` --- - -LOCK TABLES `payment_methods` WRITE; -/*!40000 ALTER TABLE `payment_methods` DISABLE KEYS */; -INSERT INTO `payment_methods` VALUES -(1,'Cash','كاش','2026-02-16 08:33:31'), -(2,'Credit Card','بطاقة ائتمان','2026-02-16 08:33:53'), -(3,'Bank Transfer','تحويل بنكي','2026-02-16 08:34:17'); -/*!40000 ALTER TABLE `payment_methods` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `role_groups` --- - -LOCK TABLES `role_groups` WRITE; -/*!40000 ALTER TABLE `role_groups` DISABLE KEYS */; -INSERT INTO `role_groups` VALUES -(1,'Administrator','2026-02-18 05:30:12'), -(4,'Cashier','2026-02-18 09:32:14'), -(5,'Admin','2026-02-18 09:33:29'), -(6,'Accountant','2026-02-18 09:34:03'); -/*!40000 ALTER TABLE `role_groups` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `role_permissions` --- - -LOCK TABLES `role_permissions` WRITE; -/*!40000 ALTER TABLE `role_permissions` DISABLE KEYS */; -INSERT INTO `role_permissions` VALUES -(58,1,'accounting_add'), -(60,1,'accounting_delete'), -(59,1,'accounting_edit'), -(57,1,'accounting_view'), -(154,1,'backups_add'), -(156,1,'backups_delete'), -(155,1,'backups_edit'), -(153,1,'backups_view'), -(70,1,'balance_sheet_add'), -(72,1,'balance_sheet_delete'), -(71,1,'balance_sheet_edit'), -(69,1,'balance_sheet_view'), -(138,1,'cash_registers_add'), -(140,1,'cash_registers_delete'), -(139,1,'cash_registers_edit'), -(137,1,'cash_registers_view'), -(102,1,'cashflow_report_add'), -(104,1,'cashflow_report_delete'), -(103,1,'cashflow_report_edit'), -(101,1,'cashflow_report_view'), -(10,1,'categories_add'), -(12,1,'categories_delete'), -(11,1,'categories_edit'), -(9,1,'categories_view'), -(150,1,'customer_display_settings_add'), -(152,1,'customer_display_settings_delete'), -(151,1,'customer_display_settings_edit'), -(149,1,'customer_display_settings_view'), -(94,1,'customer_statement_add'), -(96,1,'customer_statement_delete'), -(95,1,'customer_statement_edit'), -(93,1,'customer_statement_view'), -(18,1,'customers_add'), -(20,1,'customers_delete'), -(19,1,'customers_edit'), -(17,1,'customers_view'), -(2,1,'dashboard_add'), -(4,1,'dashboard_delete'), -(3,1,'dashboard_edit'), -(1,1,'dashboard_view'), -(122,1,'devices_add'), -(124,1,'devices_delete'), -(123,1,'devices_edit'), -(121,1,'devices_view'), -(50,1,'expense_categories_add'), -(52,1,'expense_categories_delete'), -(51,1,'expense_categories_edit'), -(49,1,'expense_categories_view'), -(54,1,'expenses_add'), -(56,1,'expenses_delete'), -(55,1,'expenses_edit'), -(53,1,'expenses_view'), -(106,1,'expiry_report_add'), -(108,1,'expiry_report_delete'), -(107,1,'expiry_report_edit'), -(105,1,'expiry_report_view'), -(86,1,'hr_attendance_add'), -(88,1,'hr_attendance_delete'), -(87,1,'hr_attendance_edit'), -(85,1,'hr_attendance_view'), -(78,1,'hr_departments_add'), -(80,1,'hr_departments_delete'), -(79,1,'hr_departments_edit'), -(77,1,'hr_departments_view'), -(82,1,'hr_employees_add'), -(84,1,'hr_employees_delete'), -(83,1,'hr_employees_edit'), -(81,1,'hr_employees_view'), -(90,1,'hr_payroll_add'), -(92,1,'hr_payroll_delete'), -(91,1,'hr_payroll_edit'), -(89,1,'hr_payroll_view'), -(6,1,'items_add'), -(8,1,'items_delete'), -(7,1,'items_edit'), -(5,1,'items_view'), -(158,1,'logs_add'), -(160,1,'logs_delete'), -(159,1,'logs_edit'), -(157,1,'logs_view'), -(110,1,'low_stock_report_add'), -(112,1,'low_stock_report_delete'), -(111,1,'low_stock_report_edit'), -(109,1,'low_stock_report_view'), -(114,1,'loyalty_history_add'), -(116,1,'loyalty_history_delete'), -(115,1,'loyalty_history_edit'), -(113,1,'loyalty_history_view'), -(211,1,'lpos_add'), -(213,1,'lpos_delete'), -(212,1,'lpos_edit'), -(210,1,'lpos_view'), -(118,1,'payment_methods_add'), -(120,1,'payment_methods_delete'), -(119,1,'payment_methods_edit'), -(117,1,'payment_methods_view'), -(26,1,'pos_add'), -(28,1,'pos_delete'), -(27,1,'pos_edit'), -(25,1,'pos_view'), -(66,1,'profit_loss_add'), -(68,1,'profit_loss_delete'), -(67,1,'profit_loss_edit'), -(65,1,'profit_loss_view'), -(46,1,'purchase_returns_add'), -(48,1,'purchase_returns_delete'), -(47,1,'purchase_returns_edit'), -(45,1,'purchase_returns_view'), -(42,1,'purchases_add'), -(44,1,'purchases_delete'), -(43,1,'purchases_edit'), -(41,1,'purchases_view'), -(38,1,'quotations_add'), -(40,1,'quotations_delete'), -(39,1,'quotations_edit'), -(37,1,'quotations_view'), -(142,1,'register_sessions_add'), -(144,1,'register_sessions_delete'), -(143,1,'register_sessions_edit'), -(141,1,'register_sessions_view'), -(130,1,'role_groups_add'), -(132,1,'role_groups_delete'), -(131,1,'role_groups_edit'), -(129,1,'role_groups_view'), -(30,1,'sales_add'), -(32,1,'sales_delete'), -(31,1,'sales_edit'), -(34,1,'sales_returns_add'), -(36,1,'sales_returns_delete'), -(35,1,'sales_returns_edit'), -(33,1,'sales_returns_view'), -(29,1,'sales_view'), -(146,1,'scale_devices_add'), -(148,1,'scale_devices_delete'), -(147,1,'scale_devices_edit'), -(145,1,'scale_devices_view'), -(126,1,'settings_add'), -(128,1,'settings_delete'), -(127,1,'settings_edit'), -(125,1,'settings_view'), -(98,1,'supplier_statement_add'), -(100,1,'supplier_statement_delete'), -(99,1,'supplier_statement_edit'), -(97,1,'supplier_statement_view'), -(22,1,'suppliers_add'), -(24,1,'suppliers_delete'), -(23,1,'suppliers_edit'), -(21,1,'suppliers_view'), -(62,1,'trial_balance_add'), -(64,1,'trial_balance_delete'), -(63,1,'trial_balance_edit'), -(61,1,'trial_balance_view'), -(14,1,'units_add'), -(16,1,'units_delete'), -(15,1,'units_edit'), -(13,1,'units_view'), -(134,1,'users_add'), -(136,1,'users_delete'), -(135,1,'users_edit'), -(133,1,'users_view'), -(74,1,'vat_report_add'), -(76,1,'vat_report_delete'), -(75,1,'vat_report_edit'), -(73,1,'vat_report_view'), -(162,4,'items_add'), -(161,4,'items_view'), -(164,4,'pos_add'), -(163,4,'pos_view'), -(166,4,'sales_add'), -(165,4,'sales_view'), -(174,5,'customers_add'), -(175,5,'customers_edit'), -(173,5,'customers_view'), -(186,5,'hr_add'), -(188,5,'hr_delete'), -(187,5,'hr_edit'), -(185,5,'hr_view'), -(215,5,'lpos_add'), -(217,5,'lpos_delete'), -(216,5,'lpos_edit'), -(214,5,'lpos_view'), -(168,5,'pos_add'), -(169,5,'pos_edit'), -(167,5,'pos_view'), -(183,5,'purchases_add'), -(184,5,'purchases_edit'), -(182,5,'purchases_view'), -(171,5,'quotations_add'), -(172,5,'quotations_edit'), -(170,5,'quotations_view'), -(180,5,'sales_add'), -(181,5,'sales_edit'), -(179,5,'sales_view'), -(177,5,'suppliers_add'), -(178,5,'suppliers_edit'), -(176,5,'suppliers_view'), -(189,5,'users_view'), -(191,6,'accounting_add'), -(193,6,'accounting_delete'), -(192,6,'accounting_edit'), -(190,6,'accounting_view'), -(203,6,'balance_sheet_add'), -(205,6,'balance_sheet_delete'), -(204,6,'balance_sheet_edit'), -(202,6,'balance_sheet_view'), -(199,6,'profit_loss_add'), -(201,6,'profit_loss_delete'), -(200,6,'profit_loss_edit'), -(198,6,'profit_loss_view'), -(195,6,'trial_balance_add'), -(197,6,'trial_balance_delete'), -(196,6,'trial_balance_edit'), -(194,6,'trial_balance_view'), -(207,6,'vat_report_add'), -(209,6,'vat_report_delete'), -(208,6,'vat_report_edit'), -(206,6,'vat_report_view'); -/*!40000 ALTER TABLE `role_permissions` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `settings` --- - -LOCK TABLES `settings` WRITE; -/*!40000 ALTER TABLE `settings` DISABLE KEYS */; -INSERT INTO `settings` VALUES -('allow_zero_stock_sell','1','2026-02-18 05:23:57'), -('bank_name','','2026-02-16 09:49:27'), -('company_address','AL Hamra\r\nOman','2026-02-16 10:05:55'), -('company_email','aalabry@gmail.com','2026-02-16 09:49:27'), -('company_iban','','2026-02-16 09:49:27'), -('company_logo','uploads/logo.png','2026-02-16 09:49:48'), -('company_name','Bahjet Al-Safa Trading','2026-02-16 09:49:26'), -('company_phone','99359472','2026-02-16 09:49:26'), -('company_website','','2026-02-16 09:49:27'), -('cr_number','','2026-02-16 09:18:20'), -('customer_display_greeting_text','أهلا وسهلاً بكــم','2026-02-18 17:02:02'), -('customer_display_greeting_title','Welcome','2026-02-18 17:02:02'), -('default_vat_rate','5','2026-02-16 09:49:27'), -('favicon','uploads/favicon.png','2026-02-16 10:09:59'), -('invoice_footer','','2026-02-16 09:49:27'), -('loyalty_enabled','0','2026-02-18 05:06:52'), -('loyalty_points_per_unit','1','2026-02-18 05:06:52'), -('loyalty_redeem_points_per_unit','100','2026-02-18 05:06:52'), -('manager_name','','2026-02-16 09:49:27'), -('registration_no','','2026-02-16 10:05:55'), -('vat_enabled','1','2026-02-16 09:18:20'), -('vat_number','OM25418','2026-02-16 09:49:27'); -/*!40000 ALTER TABLE `settings` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `stock_units` --- - -LOCK TABLES `stock_units` WRITE; -/*!40000 ALTER TABLE `stock_units` DISABLE KEYS */; -INSERT INTO `stock_units` VALUES -(1,'piece','حبة','pcs','حبة','2026-02-16 08:01:29'), -(2,'Box','صندوق','Box','صندوق','2026-02-16 08:01:55'), -(3,'Kilogram','كيلوجرام','Kg','ك.ج','2026-02-16 08:02:53'); -/*!40000 ALTER TABLE `stock_units` ENABLE KEYS */; -UNLOCK TABLES; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!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 */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - --- Dump completed on 2026-02-21 7:13:34 +-- Dump completed on 2026-02-21 10:01:19 diff --git a/db/seed.sql b/db/seed.sql new file mode 100644 index 0000000..541053b --- /dev/null +++ b/db/seed.sql @@ -0,0 +1,394 @@ +/*M!999999\- enable the sandbox mode */ +-- MariaDB dump 10.19 Distrib 10.11.14-MariaDB, for debian-linux-gnu (x86_64) +-- +-- Host: 127.0.0.1 Database: app_38471 +-- ------------------------------------------------------ +-- Server version 10.11.14-MariaDB-0+deb12u2 + +/*!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 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Dumping data for table `migrations` +-- + +LOCK TABLES `migrations` WRITE; +/*!40000 ALTER TABLE `migrations` DISABLE KEYS */; +INSERT INTO `migrations` VALUES +(1,'20260216_add_invoices.sql','2026-02-21 06:58:26'), +(2,'20260216_add_quotations.sql','2026-02-21 06:58:26'), +(3,'20260216_add_stock_tables.sql','2026-02-21 06:58:26'), +(4,'20260216_pos_advanced_features.sql','2026-02-21 06:58:26'), +(5,'20260216_setup_pos_full.sql','2026-02-21 06:58:27'), +(6,'20260216_update_precision_3_decimal.sql','2026-02-21 06:58:28'), +(7,'20260217_accounting_module.sql','2026-02-21 06:58:28'), +(8,'20260217_biometric_devices.sql','2026-02-21 06:58:28'), +(9,'20260217_hr_module.sql','2026-02-21 06:58:28'), +(10,'20260217_purchase_returns.sql','2026-02-21 06:58:28'), +(11,'20260217_sales_returns.sql','2026-02-21 06:58:28'), +(12,'20260217_vat_accounts.sql','2026-02-21 06:58:28'), +(13,'20260218_create_license_table.sql','2026-02-21 06:58:28'), +(14,'20260218_pos_payments.sql','2026-02-21 06:58:28'), +(15,'20260220_license_server_schema.sql','2026-02-21 06:58:28'), +(16,'20260220_unify_pos_sales.sql','2026-02-21 06:58:29'), +(17,'fix_lpo_foreign_key.sql','2026-02-21 06:58:29'), +(18,'20260216_add_credit_limit.sql','2026-02-21 07:12:15'), +(19,'20260216_add_invoice_status.sql','2026-02-21 07:12:15'), +(20,'20260216_add_payments_table.sql','2026-02-21 07:12:15'), +(21,'20260216_update_invoices_payment.sql','2026-02-21 07:12:15'), +(22,'20260216_vat_and_profile.sql','2026-02-21 07:12:15'), +(23,'20260217_biometric_attendance.sql','2026-02-21 07:12:15'), +(24,'20260217_biometric_logs_update.sql','2026-02-21 07:12:15'), +(25,'20260217_hr_payroll_unique.sql','2026-02-21 07:12:15'), +(26,'20260218_modern_loyalty_system.sql','2026-02-21 07:12:15'), +(27,'20260219_add_license_fields.sql','2026-02-21 07:12:15'), +(28,'20260219_add_trial_logic.sql','2026-02-21 07:12:15'), +(29,'20260219_add_vat_to_pos_items.sql','2026-02-21 07:12:15'), +(30,'20260219_fix_vat_columns.sql','2026-02-21 07:12:15'), +(31,'20260220_add_due_date_to_invoices.sql','2026-02-21 07:12:15'), +(32,'20260220_split_customers_suppliers.sql','2026-02-21 07:12:15'), +(33,'20260220_split_invoices_purchases.sql','2026-02-21 07:12:15'), +(34,'20260220_unify_pos_sales.php','2026-02-21 07:13:28'), +(35,'20260221_fix_supplier_foreign_keys.sql','2026-02-21 08:29:25'), +(36,'20260221_add_theme_to_users.sql','2026-02-21 10:01:17'); +/*!40000 ALTER TABLE `migrations` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `role_groups` +-- + +LOCK TABLES `role_groups` WRITE; +/*!40000 ALTER TABLE `role_groups` DISABLE KEYS */; +INSERT INTO `role_groups` VALUES +(1,'Administrator','all','2026-02-18 05:30:12'), +(4,'Cashier','[\"pos_view\",\"pos_add\",\"items_view\",\"items_add\"]','2026-02-18 09:32:14'), +(5,'Admin','[\"pos_view\",\"pos_add\",\"pos_edit\",\"quotations_view\",\"quotations_add\",\"quotations_edit\",\"customers_view\",\"customers_add\",\"customers_edit\",\"suppliers_view\",\"suppliers_add\",\"suppliers_edit\",\"sales_view\",\"sales_add\",\"sales_edit\",\"purchases_view\",\"purchases_add\",\"purchases_edit\",\"hr_view\",\"hr_add\",\"hr_edit\",\"hr_delete\",\"users_view\"]','2026-02-18 09:33:29'), +(6,'Accountant','[\"accounting_view\",\"accounting_add\",\"accounting_edit\"]','2026-02-18 09:34:03'); +/*!40000 ALTER TABLE `role_groups` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `role_permissions` +-- + +LOCK TABLES `role_permissions` WRITE; +/*!40000 ALTER TABLE `role_permissions` DISABLE KEYS */; +INSERT INTO `role_permissions` VALUES +(58,1,'accounting_add'), +(60,1,'accounting_delete'), +(59,1,'accounting_edit'), +(57,1,'accounting_view'), +(154,1,'backups_add'), +(156,1,'backups_delete'), +(155,1,'backups_edit'), +(153,1,'backups_view'), +(70,1,'balance_sheet_add'), +(72,1,'balance_sheet_delete'), +(71,1,'balance_sheet_edit'), +(69,1,'balance_sheet_view'), +(138,1,'cash_registers_add'), +(140,1,'cash_registers_delete'), +(139,1,'cash_registers_edit'), +(137,1,'cash_registers_view'), +(102,1,'cashflow_report_add'), +(104,1,'cashflow_report_delete'), +(103,1,'cashflow_report_edit'), +(101,1,'cashflow_report_view'), +(10,1,'categories_add'), +(12,1,'categories_delete'), +(11,1,'categories_edit'), +(9,1,'categories_view'), +(150,1,'customer_display_settings_add'), +(152,1,'customer_display_settings_delete'), +(151,1,'customer_display_settings_edit'), +(149,1,'customer_display_settings_view'), +(94,1,'customer_statement_add'), +(96,1,'customer_statement_delete'), +(95,1,'customer_statement_edit'), +(93,1,'customer_statement_view'), +(18,1,'customers_add'), +(20,1,'customers_delete'), +(19,1,'customers_edit'), +(17,1,'customers_view'), +(2,1,'dashboard_add'), +(4,1,'dashboard_delete'), +(3,1,'dashboard_edit'), +(1,1,'dashboard_view'), +(122,1,'devices_add'), +(124,1,'devices_delete'), +(123,1,'devices_edit'), +(121,1,'devices_view'), +(50,1,'expense_categories_add'), +(52,1,'expense_categories_delete'), +(51,1,'expense_categories_edit'), +(49,1,'expense_categories_view'), +(54,1,'expenses_add'), +(56,1,'expenses_delete'), +(55,1,'expenses_edit'), +(53,1,'expenses_view'), +(106,1,'expiry_report_add'), +(108,1,'expiry_report_delete'), +(107,1,'expiry_report_edit'), +(105,1,'expiry_report_view'), +(86,1,'hr_attendance_add'), +(88,1,'hr_attendance_delete'), +(87,1,'hr_attendance_edit'), +(85,1,'hr_attendance_view'), +(78,1,'hr_departments_add'), +(80,1,'hr_departments_delete'), +(79,1,'hr_departments_edit'), +(77,1,'hr_departments_view'), +(82,1,'hr_employees_add'), +(84,1,'hr_employees_delete'), +(83,1,'hr_employees_edit'), +(81,1,'hr_employees_view'), +(90,1,'hr_payroll_add'), +(92,1,'hr_payroll_delete'), +(91,1,'hr_payroll_edit'), +(89,1,'hr_payroll_view'), +(6,1,'items_add'), +(8,1,'items_delete'), +(7,1,'items_edit'), +(5,1,'items_view'), +(158,1,'logs_add'), +(160,1,'logs_delete'), +(159,1,'logs_edit'), +(157,1,'logs_view'), +(110,1,'low_stock_report_add'), +(112,1,'low_stock_report_delete'), +(111,1,'low_stock_report_edit'), +(109,1,'low_stock_report_view'), +(114,1,'loyalty_history_add'), +(116,1,'loyalty_history_delete'), +(115,1,'loyalty_history_edit'), +(113,1,'loyalty_history_view'), +(211,1,'lpos_add'), +(213,1,'lpos_delete'), +(212,1,'lpos_edit'), +(210,1,'lpos_view'), +(118,1,'payment_methods_add'), +(120,1,'payment_methods_delete'), +(119,1,'payment_methods_edit'), +(117,1,'payment_methods_view'), +(26,1,'pos_add'), +(28,1,'pos_delete'), +(27,1,'pos_edit'), +(25,1,'pos_view'), +(66,1,'profit_loss_add'), +(68,1,'profit_loss_delete'), +(67,1,'profit_loss_edit'), +(65,1,'profit_loss_view'), +(46,1,'purchase_returns_add'), +(48,1,'purchase_returns_delete'), +(47,1,'purchase_returns_edit'), +(45,1,'purchase_returns_view'), +(42,1,'purchases_add'), +(44,1,'purchases_delete'), +(43,1,'purchases_edit'), +(41,1,'purchases_view'), +(38,1,'quotations_add'), +(40,1,'quotations_delete'), +(39,1,'quotations_edit'), +(37,1,'quotations_view'), +(142,1,'register_sessions_add'), +(144,1,'register_sessions_delete'), +(143,1,'register_sessions_edit'), +(141,1,'register_sessions_view'), +(130,1,'role_groups_add'), +(132,1,'role_groups_delete'), +(131,1,'role_groups_edit'), +(129,1,'role_groups_view'), +(30,1,'sales_add'), +(32,1,'sales_delete'), +(31,1,'sales_edit'), +(34,1,'sales_returns_add'), +(36,1,'sales_returns_delete'), +(35,1,'sales_returns_edit'), +(33,1,'sales_returns_view'), +(29,1,'sales_view'), +(146,1,'scale_devices_add'), +(148,1,'scale_devices_delete'), +(147,1,'scale_devices_edit'), +(145,1,'scale_devices_view'), +(126,1,'settings_add'), +(128,1,'settings_delete'), +(127,1,'settings_edit'), +(125,1,'settings_view'), +(98,1,'supplier_statement_add'), +(100,1,'supplier_statement_delete'), +(99,1,'supplier_statement_edit'), +(97,1,'supplier_statement_view'), +(22,1,'suppliers_add'), +(24,1,'suppliers_delete'), +(23,1,'suppliers_edit'), +(21,1,'suppliers_view'), +(62,1,'trial_balance_add'), +(64,1,'trial_balance_delete'), +(63,1,'trial_balance_edit'), +(61,1,'trial_balance_view'), +(14,1,'units_add'), +(16,1,'units_delete'), +(15,1,'units_edit'), +(13,1,'units_view'), +(134,1,'users_add'), +(136,1,'users_delete'), +(135,1,'users_edit'), +(133,1,'users_view'), +(74,1,'vat_report_add'), +(76,1,'vat_report_delete'), +(75,1,'vat_report_edit'), +(73,1,'vat_report_view'), +(162,4,'items_add'), +(161,4,'items_view'), +(164,4,'pos_add'), +(163,4,'pos_view'), +(166,4,'sales_add'), +(165,4,'sales_view'), +(174,5,'customers_add'), +(175,5,'customers_edit'), +(173,5,'customers_view'), +(186,5,'hr_add'), +(188,5,'hr_delete'), +(187,5,'hr_edit'), +(185,5,'hr_view'), +(215,5,'lpos_add'), +(217,5,'lpos_delete'), +(216,5,'lpos_edit'), +(214,5,'lpos_view'), +(168,5,'pos_add'), +(169,5,'pos_edit'), +(167,5,'pos_view'), +(183,5,'purchases_add'), +(184,5,'purchases_edit'), +(182,5,'purchases_view'), +(171,5,'quotations_add'), +(172,5,'quotations_edit'), +(170,5,'quotations_view'), +(180,5,'sales_add'), +(181,5,'sales_edit'), +(179,5,'sales_view'), +(177,5,'suppliers_add'), +(178,5,'suppliers_edit'), +(176,5,'suppliers_view'), +(189,5,'users_view'), +(191,6,'accounting_add'), +(193,6,'accounting_delete'), +(192,6,'accounting_edit'), +(190,6,'accounting_view'), +(203,6,'balance_sheet_add'), +(205,6,'balance_sheet_delete'), +(204,6,'balance_sheet_edit'), +(202,6,'balance_sheet_view'), +(199,6,'profit_loss_add'), +(201,6,'profit_loss_delete'), +(200,6,'profit_loss_edit'), +(198,6,'profit_loss_view'), +(195,6,'trial_balance_add'), +(197,6,'trial_balance_delete'), +(196,6,'trial_balance_edit'), +(194,6,'trial_balance_view'), +(207,6,'vat_report_add'), +(209,6,'vat_report_delete'), +(208,6,'vat_report_edit'), +(206,6,'vat_report_view'); +/*!40000 ALTER TABLE `role_permissions` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `users` +-- + +LOCK TABLES `users` WRITE; +/*!40000 ALTER TABLE `users` DISABLE KEYS */; +INSERT INTO `users` VALUES +(1,1,'admin','$2y$10$uLxB5VJa9nZ3nGhukx7jOeBotQ/PtumL3ndbzTZ.TjrAr9yJH/hIq','admin@example.com',NULL,'uploads/profile_1_1771401598.png','default','active','2026-02-18 05:30:12'), +(2,1,'admin2','$2y$10$A299UOd8VZWXyuKcbcLwWewIg.7V2ti3oomGaKH9qhMm4vdG6a/xi',NULL,NULL,NULL,'default','active','2026-02-18 06:44:10'), +(5,1,'moosa','$2y$10$Ho5NrFTAb6HUH4VvCd4NZuCsKGMl4v1pvWiesEuC29fDDu6Pkg7AS','aalabry@gmail.com',NULL,NULL,'default','active','2026-02-18 09:30:38'); +/*!40000 ALTER TABLE `users` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `payment_methods` +-- + +LOCK TABLES `payment_methods` WRITE; +/*!40000 ALTER TABLE `payment_methods` DISABLE KEYS */; +INSERT INTO `payment_methods` VALUES +(1,'Cash','كاش','2026-02-16 08:33:31'), +(2,'Credit Card','بطاقة بنكية','2026-02-16 08:33:53'), +(3,'Bank Transfer','تحويل بنكي','2026-02-16 08:34:17'); +/*!40000 ALTER TABLE `payment_methods` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `settings` +-- + +LOCK TABLES `settings` WRITE; +/*!40000 ALTER TABLE `settings` DISABLE KEYS */; +INSERT INTO `settings` VALUES +('allow_zero_stock_sell','1','2026-02-18 05:23:57'), +('bank_name','','2026-02-16 09:49:27'), +('company_address','AL Hamra\r\nOman','2026-02-16 10:05:55'), +('company_email','aalabry@gmail.com','2026-02-16 09:49:27'), +('company_iban','','2026-02-16 09:49:27'), +('company_logo','uploads/logo.png','2026-02-16 09:49:48'), +('company_name','Bahjet Al-Safa Trading','2026-02-16 09:49:26'), +('company_phone','99359472','2026-02-16 09:49:26'), +('company_website','','2026-02-16 09:49:27'), +('cr_number','','2026-02-16 09:18:20'), +('default_vat_rate','5','2026-02-16 09:49:27'), +('favicon','uploads/favicon.png','2026-02-16 10:09:59'), +('invoice_footer','','2026-02-16 09:49:27'), +('loyalty_enabled','0','2026-02-18 05:06:52'), +('loyalty_points_per_unit','1','2026-02-18 05:06:52'), +('loyalty_redeem_points_per_unit','100','2026-02-18 05:06:52'), +('manager_name','','2026-02-16 09:49:27'), +('registration_no','','2026-02-16 10:05:55'), +('vat_enabled','1','2026-02-16 09:18:20'), +('vat_number','OM25418','2026-02-16 09:49:27'); +/*!40000 ALTER TABLE `settings` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `acc_accounts` +-- + +LOCK TABLES `acc_accounts` WRITE; +/*!40000 ALTER TABLE `acc_accounts` DISABLE KEYS */; +INSERT INTO `acc_accounts` VALUES +(1,'1000','Assets','الأصول','asset',NULL), +(2,'1100','Cash on Hand','النقدية','asset',1), +(3,'1200','Bank Account','حساب البنك','asset',1), +(4,'1300','Accounts Receivable','حسابات العملاء','asset',1), +(5,'1400','Inventory','المخزون','asset',1), +(6,'2000','Liabilities','الالتزامات','liability',NULL), +(7,'2100','Accounts Payable','حسابات الموردين','liability',6), +(8,'3000','Equity','حقوق الملكية','equity',NULL), +(9,'4000','Revenue','الإيرادات','revenue',NULL), +(10,'4100','Sales Revenue','إيرادات المبيعات','revenue',9), +(11,'5000','Expenses','المصروفات','expense',NULL), +(12,'5100','Cost of Goods Sold','تكلفة البضاعة المباعة','expense',11), +(13,'5200','Operating Expenses','مصاريف تشغيلية','expense',11), +(14,'1500','VAT Input','ضريبة القيمة المضافة - مدخلات','asset',1), +(15,'2300','VAT Payable','ضريبة القيمة المضافة - مستحقة','liability',6); +/*!40000 ALTER TABLE `acc_accounts` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!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 */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2026-02-21 10:01:20 diff --git a/includes/DatabaseInstaller.php b/includes/DatabaseInstaller.php new file mode 100644 index 0000000..fd1d414 --- /dev/null +++ b/includes/DatabaseInstaller.php @@ -0,0 +1,58 @@ +query("SHOW TABLES LIKE 'users'"); + return $stmt->fetch() !== false; + } catch (PDOException $e) { + return false; + } + } + + public static function install() { + require_once __DIR__ . '/../db/config.php'; + + $schemaFile = __DIR__ . '/../db/schema.sql'; + $seedFile = __DIR__ . '/../db/seed.sql'; + + if (!file_exists($schemaFile)) { + throw new Exception("Schema file not found at $schemaFile"); + } + + self::executeSqlFile($schemaFile); + + if (file_exists($seedFile)) { + self::executeSqlFile($seedFile); + } + + return true; + } + + private static function executeSqlFile($filePath) { + // Use constants from db/config.php + $host = DB_HOST; + $name = DB_NAME; + $user = DB_USER; + $pass = DB_PASS; + + $command = sprintf( + 'mysql -h %s -u %s -p%s %s < %s', + escapeshellarg($host), + escapeshellarg($user), + escapeshellarg($pass), + escapeshellarg($name), + escapeshellarg($filePath) + ); + + $output = []; + $returnVar = 0; + exec($command . ' 2>&1', $output, $returnVar); + + if ($returnVar !== 0) { + throw new Exception("Failed to execute SQL file: " . implode("\n", $output)); + } + } +} diff --git a/index.php b/index.php index fa958fa..6433c24 100644 --- a/index.php +++ b/index.php @@ -39,6 +39,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { file_put_contents('post_debug.log', date('Y-m-d H:i:s') . " - POST: " . json_encode($_POST) . "\n", FILE_APPEND); } require_once 'db/config.php'; +require_once 'includes/DatabaseInstaller.php'; + +// Auto-install database if not installed +if (!DatabaseInstaller::isInstalled()) { + try { + DatabaseInstaller::install(); + } catch (Exception $e) { + die("Installation Error: " . $e->getMessage()); + } +} + require_once 'lib/LicenseService.php'; require_once 'includes/lang.php';