diff --git a/ai/config.php b/ai/config.php index c890698..9664928 100644 --- a/ai/config.php +++ b/ai/config.php @@ -5,6 +5,7 @@ $projectUuid = getenv('PROJECT_UUID'); $projectId = getenv('PROJECT_ID'); +$envVars = []; if ( ($projectUuid === false || $projectUuid === null || $projectUuid === '') || ($projectId === false || $projectId === null || $projectId === '') @@ -25,17 +26,23 @@ if ( continue; } $value = trim($value, "\"' "); + $envVars[$key] = $value; if (getenv($key) === false || getenv($key) === '') { putenv("{$key}={$value}"); } } - $projectUuid = getenv('PROJECT_UUID'); - $projectId = getenv('PROJECT_ID'); + + if (empty($projectUuid) && isset($envVars['PROJECT_UUID'])) { + $projectUuid = $envVars['PROJECT_UUID']; + } + if (empty($projectId) && isset($envVars['PROJECT_ID'])) { + $projectId = $envVars['PROJECT_ID']; + } } } -$projectUuid = ($projectUuid === false) ? null : $projectUuid; -$projectId = ($projectId === false) ? null : $projectId; +$projectUuid = ($projectUuid === false || $projectUuid === '') ? null : $projectUuid; +$projectId = ($projectId === false || $projectId === '') ? null : $projectId; $baseUrl = 'https://flatlogic.com'; $responsesPath = $projectId ? "/projects/{$projectId}/ai-request" : null; diff --git a/assets/pasted-20260221-055630-326bb37b.png b/assets/pasted-20260221-055630-326bb37b.png new file mode 100644 index 0000000..2132855 Binary files /dev/null and b/assets/pasted-20260221-055630-326bb37b.png differ diff --git a/check_schema.php b/check_schema.php deleted file mode 100644 index fdcea91..0000000 --- a/check_schema.php +++ /dev/null @@ -1,14 +0,0 @@ -query("DESCRIBE $t"); - while ($r = $res->fetch(PDO::FETCH_ASSOC)) { - echo " {$r['Field']} ({$r['Type']})\n"; - } - } catch (Exception $e) { - echo " Error: " . $e->getMessage() . "\n"; - } -} diff --git a/complete_schema.sql b/complete_schema.sql index ad25a50..0cef087 100644 --- a/complete_schema.sql +++ b/complete_schema.sql @@ -34,34 +34,9 @@ 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=16 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=46 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- 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; - -- -- Table structure for table `acc_journal_entries` -- @@ -78,64 +53,9 @@ 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=91 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=102 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `acc_journal_entries` --- - -LOCK TABLES `acc_journal_entries` WRITE; -/*!40000 ALTER TABLE `acc_journal_entries` DISABLE KEYS */; -INSERT INTO `acc_journal_entries` VALUES -(46,'2026-02-16','Sale Invoice #1','INV-1','invoice',1,'2026-02-18 02:04:43'), -(47,'2026-02-16','Sale Invoice #2','INV-2','invoice',2,'2026-02-18 02:04:44'), -(48,'2026-02-16','Sale Invoice #3','INV-3','invoice',3,'2026-02-18 02:04:44'), -(49,'2026-02-16','Sale Invoice #4','INV-4','invoice',4,'2026-02-18 02:04:44'), -(50,'2026-02-16','Sale Invoice #5','INV-5','invoice',5,'2026-02-18 02:04:44'), -(51,'2026-02-16','Purchase Invoice #6','PINV-6','invoice',6,'2026-02-18 02:04:45'), -(52,'2026-02-16','Sale Invoice #12','INV-12','invoice',12,'2026-02-18 02:04:45'), -(53,'2026-02-16','Sale Invoice #14','INV-14','invoice',14,'2026-02-18 02:04:45'), -(54,'2026-02-16','Sale Invoice #15','INV-15','invoice',15,'2026-02-18 02:04:45'), -(55,'2026-02-16','Sale Invoice #16','INV-16','invoice',16,'2026-02-18 02:04:45'), -(56,'2026-02-16','Sale Invoice #17','INV-17','invoice',17,'2026-02-18 02:04:45'), -(57,'2026-02-16','Sale Invoice #18','INV-18','invoice',18,'2026-02-18 02:04:45'), -(58,'2026-02-16','Sale Invoice #19','INV-19','invoice',19,'2026-02-18 02:04:45'), -(59,'2026-02-16','Sale Invoice #20','INV-20','invoice',20,'2026-02-18 02:04:45'), -(60,'2026-02-16','Sale Invoice #21','INV-21','invoice',21,'2026-02-18 02:04:46'), -(61,'2026-02-16','Sale Invoice #22','INV-22','invoice',22,'2026-02-18 02:04:46'), -(62,'2026-02-16','Sale Invoice #23','INV-23','invoice',23,'2026-02-18 02:04:46'), -(63,'2026-02-16','Sale Invoice #24','INV-24','invoice',24,'2026-02-18 02:04:46'), -(64,'2026-02-16','Sale Invoice #25','INV-25','invoice',25,'2026-02-18 02:04:46'), -(65,'2026-02-16','Sale Invoice #26','INV-26','invoice',26,'2026-02-18 02:04:46'), -(66,'2026-02-17','Sale Invoice #27','INV-27','invoice',27,'2026-02-18 02:04:46'), -(67,'2026-02-17','Sale Invoice #28','INV-28','invoice',28,'2026-02-18 02:04:46'), -(68,'2026-02-17','Sale Invoice #29','INV-29','invoice',29,'2026-02-18 02:04:47'), -(69,'2026-02-16','Payment Received #1','PAY-1','payment',1,'2026-02-18 02:04:47'), -(70,'2026-02-16','Payment Received #2','PAY-2','payment',2,'2026-02-18 02:04:47'), -(71,'2026-02-16','Payment Received #3','PAY-3','payment',3,'2026-02-18 02:04:47'), -(72,'2026-02-16','Payment Received #4','PAY-4','payment',4,'2026-02-18 02:04:47'), -(73,'2026-02-16','Payment Received #5','PAY-5','payment',5,'2026-02-18 02:04:47'), -(74,'2026-02-16','Payment Received #6','PAY-6','payment',6,'2026-02-18 02:04:47'), -(75,'2026-02-16','Payment Made #7','PAY-7','payment',7,'2026-02-18 02:04:47'), -(76,'2026-02-16','Payment Made #8','PAY-8','payment',8,'2026-02-18 02:04:47'), -(77,'2026-02-16','Payment Received #9','PAY-9','payment',9,'2026-02-18 02:04:47'), -(78,'2026-02-16','Payment Received #10','PAY-10','payment',10,'2026-02-18 02:04:47'), -(79,'2026-02-16','Payment Received #11','PAY-11','payment',11,'2026-02-18 02:04:47'), -(80,'2026-02-16','Payment Received #12','PAY-12','payment',12,'2026-02-18 02:04:48'), -(81,'2026-02-16','Payment Received #13','PAY-13','payment',13,'2026-02-18 02:04:48'), -(82,'2026-02-16','Payment Received #14','PAY-14','payment',14,'2026-02-18 02:04:48'), -(83,'2026-02-16','Payment Received #15','PAY-15','payment',15,'2026-02-18 02:04:48'), -(84,'2026-02-16','Payment Received #16','PAY-16','payment',16,'2026-02-18 02:04:48'), -(85,'2026-02-16','Payment Received #17','PAY-17','payment',17,'2026-02-18 02:04:48'), -(86,'2026-02-17','Payment Received #18','PAY-18','payment',18,'2026-02-18 02:04:48'), -(87,'2026-02-17','Payment Received #19','PAY-19','payment',19,'2026-02-18 02:04:48'), -(88,'2026-02-17','Expense: Electricity & Water','EXP-1','expense',1,'2026-02-18 02:04:48'), -(89,'2026-02-17','Sales Return #1','SRET-1','sales_return',1,'2026-02-18 02:04:48'), -(90,'2026-02-17','Purchase Return #1','PRET-1','purchase_return',1,'2026-02-18 02:04:48'); -/*!40000 ALTER TABLE `acc_journal_entries` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `acc_ledger` -- @@ -154,154 +74,28 @@ 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=273 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=309 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Dumping data for table `acc_ledger` +-- Table structure for table `activations` -- -LOCK TABLES `acc_ledger` WRITE; -/*!40000 ALTER TABLE `acc_ledger` DISABLE KEYS */; -INSERT INTO `acc_ledger` VALUES -(137,46,4,0.225,0.000), -(138,46,10,0.000,0.225), -(139,46,12,0.200,0.000), -(140,46,5,0.000,0.200), -(141,47,4,2.250,0.000), -(142,47,10,0.000,2.250), -(143,47,12,2.000,0.000), -(144,47,5,0.000,2.000), -(145,48,4,4.950,0.000), -(146,48,10,0.000,4.950), -(147,48,12,4.400,0.000), -(148,48,5,0.000,4.400), -(149,49,4,4.500,0.000), -(150,49,10,0.000,4.500), -(151,49,12,4.000,0.000), -(152,49,5,0.000,4.000), -(153,50,4,0.450,0.000), -(154,50,10,0.000,0.450), -(155,50,12,0.400,0.000), -(156,50,5,0.000,0.400), -(157,51,5,40.000,0.000), -(158,51,7,0.000,40.000), -(159,52,4,1.350,0.000), -(160,52,10,0.000,1.350), -(161,52,12,1.200,0.000), -(162,52,5,0.000,1.200), -(163,53,4,0.900,0.000), -(164,53,10,0.000,0.900), -(165,53,12,0.800,0.000), -(166,53,5,0.000,0.800), -(167,54,4,0.450,0.000), -(168,54,10,0.000,0.450), -(169,54,12,0.400,0.000), -(170,54,5,0.000,0.400), -(171,55,4,0.450,0.000), -(172,55,10,0.000,0.450), -(173,55,12,0.400,0.000), -(174,55,5,0.000,0.400), -(175,56,4,0.900,0.000), -(176,56,10,0.000,0.900), -(177,56,12,0.800,0.000), -(178,56,5,0.000,0.800), -(179,57,4,0.450,0.000), -(180,57,10,0.000,0.450), -(181,57,12,0.400,0.000), -(182,57,5,0.000,0.400), -(183,58,4,0.450,0.000), -(184,58,10,0.000,0.450), -(185,58,12,0.400,0.000), -(186,58,5,0.000,0.400), -(187,59,4,0.450,0.000), -(188,59,10,0.000,0.450), -(189,59,12,0.400,0.000), -(190,59,5,0.000,0.400), -(191,60,4,0.900,0.000), -(192,60,10,0.000,0.900), -(193,60,12,0.800,0.000), -(194,60,5,0.000,0.800), -(195,61,4,0.450,0.000), -(196,61,10,0.000,0.450), -(197,61,12,0.400,0.000), -(198,61,5,0.000,0.400), -(199,62,4,0.900,0.000), -(200,62,10,0.000,0.900), -(201,62,12,0.800,0.000), -(202,62,5,0.000,0.800), -(203,63,4,0.900,0.000), -(204,63,10,0.000,0.900), -(205,63,12,0.800,0.000), -(206,63,5,0.000,0.800), -(207,64,4,0.900,0.000), -(208,64,10,0.000,0.900), -(209,64,12,0.800,0.000), -(210,64,5,0.000,0.800), -(211,65,4,2.700,0.000), -(212,65,10,0.000,2.700), -(213,65,12,2.400,0.000), -(214,65,5,0.000,2.400), -(215,66,4,4.500,0.000), -(216,66,10,0.000,4.500), -(217,66,12,4.000,0.000), -(218,66,5,0.000,4.000), -(219,67,4,0.713,0.000), -(220,67,10,0.000,0.700), -(221,67,15,0.000,0.013), -(222,67,12,0.550,0.000), -(223,67,5,0.000,0.550), -(224,68,4,0.788,0.000), -(225,68,10,0.000,0.750), -(226,68,15,0.000,0.038), -(227,68,12,0.450,0.000), -(228,68,5,0.000,0.450), -(229,69,2,2.250,0.000), -(230,69,4,0.000,2.250), -(231,70,2,2.250,0.000), -(232,70,4,0.000,2.250), -(233,71,2,2.000,0.000), -(234,71,4,0.000,2.000), -(235,72,2,2.500,0.000), -(236,72,4,0.000,2.500), -(237,73,2,0.225,0.000), -(238,73,4,0.000,0.225), -(239,74,2,0.450,0.000), -(240,74,4,0.000,0.450), -(241,75,7,20.000,0.000), -(242,75,2,0.000,20.000), -(243,76,7,20.000,0.000), -(244,76,2,0.000,20.000), -(245,77,2,1.350,0.000), -(246,77,4,0.000,1.350), -(247,78,2,0.900,0.000), -(248,78,4,0.000,0.900), -(249,79,2,5.000,0.000), -(250,79,4,0.000,5.000), -(251,80,2,0.450,0.000), -(252,80,4,0.000,0.450), -(253,81,2,0.900,0.000), -(254,81,4,0.000,0.900), -(255,82,2,0.900,0.000), -(256,82,4,0.000,0.900), -(257,83,2,0.450,0.000), -(258,83,4,0.000,0.450), -(259,84,2,0.900,0.000), -(260,84,4,0.000,0.900), -(261,85,2,0.900,0.000), -(262,85,4,0.000,0.900), -(263,86,2,0.713,0.000), -(264,86,4,0.000,0.713), -(265,87,2,0.788,0.000), -(266,87,4,0.000,0.788), -(267,88,13,75.000,0.000), -(268,88,2,0.000,75.000), -(269,89,10,0.500,0.000), -(270,89,4,0.000,0.500), -(271,90,7,20.000,0.000), -(272,90,5,0.000,20.000); -/*!40000 ALTER TABLE `acc_ledger` ENABLE KEYS */; -UNLOCK TABLES; +DROP TABLE IF EXISTS `activations`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `activations` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `license_id` int(11) NOT NULL, + `fingerprint` varchar(255) NOT NULL, + `domain` varchar(255) DEFAULT NULL, + `product` varchar(255) DEFAULT NULL, + `activated_at` timestamp NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + UNIQUE KEY `license_id` (`license_id`,`fingerprint`), + CONSTRAINT `activations_ibfk_1` FOREIGN KEY (`license_id`) REFERENCES `licenses` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `cash_registers` @@ -319,18 +113,6 @@ CREATE TABLE `cash_registers` ( ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `cash_registers` --- - -LOCK TABLES `cash_registers` WRITE; -/*!40000 ALTER TABLE `cash_registers` DISABLE KEYS */; -INSERT INTO `cash_registers` VALUES -(1,'Counter 1','active','2026-02-18 11:33:57'), -(2,'Counter 2','active','2026-02-18 11:34:15'); -/*!40000 ALTER TABLE `cash_registers` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `customers` -- @@ -347,29 +129,13 @@ CREATE TABLE `customers` ( `balance` decimal(15,3) DEFAULT 0.000, `credit_limit` decimal(15,3) DEFAULT 0.000, `created_at` timestamp NULL DEFAULT current_timestamp(), - `type` enum('customer','supplier') DEFAULT 'customer', `loyalty_points` decimal(15,3) DEFAULT 0.000, `loyalty_tier` enum('bronze','silver','gold') DEFAULT 'bronze', `total_spent` decimal(15,3) DEFAULT 0.000, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `customers` --- - -LOCK TABLES `customers` WRITE; -/*!40000 ALTER TABLE `customers` DISABLE KEYS */; -INSERT INTO `customers` VALUES -(1,'Moosa Ali Al-Abri','aalabry@gmail.com','99359472',NULL,-2.650,0.000,'2026-02-16 08:11:42','customer',1.000,'bronze',10.688), -(2,'Cash','cash@cash.com','',NULL,0.000,0.000,'2026-02-16 08:12:03','customer',0.000,'bronze',0.450), -(4,'ahmed moosa','','',NULL,-1.350,0.000,'2026-02-16 08:26:36','customer',0.000,'bronze',15.788), -(5,'CASH','','',NULL,0.000,0.000,'2026-02-16 08:26:55','supplier',0.000,'bronze',0.000), -(6,'شركة المراعي','','',NULL,20.000,0.000,'2026-02-16 08:27:07','supplier',0.000,'bronze',0.000); -/*!40000 ALTER TABLE `customers` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `discount_codes` -- @@ -388,21 +154,9 @@ CREATE TABLE `discount_codes` ( `created_at` timestamp NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), UNIQUE KEY `code` (`code`) -) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `discount_codes` --- - -LOCK TABLES `discount_codes` WRITE; -/*!40000 ALTER TABLE `discount_codes` DISABLE KEYS */; -INSERT INTO `discount_codes` VALUES -(1,'WELCOME10','percentage',10.000,0.000,NULL,'active','2026-02-16 12:12:09'), -(2,'SAVE5','fixed',5.000,50.000,NULL,'active','2026-02-16 12:12:09'); -/*!40000 ALTER TABLE `discount_codes` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `expense_categories` -- @@ -419,18 +173,6 @@ CREATE TABLE `expense_categories` ( ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `expense_categories` --- - -LOCK TABLES `expense_categories` WRITE; -/*!40000 ALTER TABLE `expense_categories` DISABLE KEYS */; -INSERT INTO `expense_categories` VALUES -(1,'Salary','رواتب','2026-02-17 09:03:22'), -(2,'Electricity & Water','كهرباء وماء','2026-02-17 09:03:56'); -/*!40000 ALTER TABLE `expense_categories` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `expenses` -- @@ -452,17 +194,6 @@ CREATE TABLE `expenses` ( ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `expenses` --- - -LOCK TABLES `expenses` WRITE; -/*!40000 ALTER TABLE `expenses` DISABLE KEYS */; -INSERT INTO `expenses` VALUES -(1,2,75.000,'2026-02-17','','3655','2026-02-17 09:04:33'); -/*!40000 ALTER TABLE `expenses` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `hr_attendance` -- @@ -484,15 +215,6 @@ CREATE TABLE `hr_attendance` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `hr_attendance` --- - -LOCK TABLES `hr_attendance` WRITE; -/*!40000 ALTER TABLE `hr_attendance` DISABLE KEYS */; -/*!40000 ALTER TABLE `hr_attendance` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `hr_biometric_devices` -- @@ -514,15 +236,6 @@ CREATE TABLE `hr_biometric_devices` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `hr_biometric_devices` --- - -LOCK TABLES `hr_biometric_devices` WRITE; -/*!40000 ALTER TABLE `hr_biometric_devices` DISABLE KEYS */; -/*!40000 ALTER TABLE `hr_biometric_devices` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `hr_biometric_logs` -- @@ -547,17 +260,6 @@ CREATE TABLE `hr_biometric_logs` ( ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `hr_biometric_logs` --- - -LOCK TABLES `hr_biometric_logs` WRITE; -/*!40000 ALTER TABLE `hr_biometric_logs` DISABLE KEYS */; -INSERT INTO `hr_biometric_logs` VALUES -(1,'999',NULL,NULL,'2026-02-17 08:30:00','check_in',0,'2026-02-17 17:26:09'); -/*!40000 ALTER TABLE `hr_biometric_logs` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `hr_departments` -- @@ -573,17 +275,6 @@ CREATE TABLE `hr_departments` ( ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `hr_departments` --- - -LOCK TABLES `hr_departments` WRITE; -/*!40000 ALTER TABLE `hr_departments` DISABLE KEYS */; -INSERT INTO `hr_departments` VALUES -(1,'purchase','2026-02-17 17:10:46'); -/*!40000 ALTER TABLE `hr_departments` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `hr_employees` -- @@ -610,15 +301,6 @@ CREATE TABLE `hr_employees` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `hr_employees` --- - -LOCK TABLES `hr_employees` WRITE; -/*!40000 ALTER TABLE `hr_employees` DISABLE KEYS */; -/*!40000 ALTER TABLE `hr_employees` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `hr_payroll` -- @@ -644,15 +326,6 @@ CREATE TABLE `hr_payroll` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `hr_payroll` --- - -LOCK TABLES `hr_payroll` WRITE; -/*!40000 ALTER TABLE `hr_payroll` DISABLE KEYS */; -/*!40000 ALTER TABLE `hr_payroll` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `invoice_items` -- @@ -666,49 +339,16 @@ 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=30 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `invoice_items` --- - -LOCK TABLES `invoice_items` WRITE; -/*!40000 ALTER TABLE `invoice_items` DISABLE KEYS */; -INSERT INTO `invoice_items` VALUES -(5,3,1,11.00,0.450,4.950), -(6,2,1,5.00,0.450,2.250), -(7,1,1,0.50,0.450,0.225), -(8,4,1,10.00,0.450,4.500), -(9,5,1,1.00,0.450,0.450), -(10,6,1,100.00,0.400,40.000), -(11,12,1,3.00,0.450,1.350), -(12,14,1,2.00,0.450,0.900), -(13,15,1,1.00,0.450,0.450), -(14,16,1,1.00,0.450,0.450), -(15,17,1,2.00,0.450,0.900), -(16,18,1,1.00,0.450,0.450), -(17,19,1,1.00,0.450,0.450), -(18,20,1,1.00,0.450,0.450), -(19,21,1,2.00,0.450,0.900), -(20,22,1,1.00,0.450,0.450), -(21,23,1,2.00,0.450,0.900), -(22,24,1,2.00,0.450,0.900), -(23,25,1,2.00,0.450,0.900), -(24,26,1,6.00,0.450,2.700), -(25,27,1,10.00,0.450,4.500), -(26,28,1,1.00,0.450,0.450), -(27,28,2,1.00,0.250,0.250), -(29,29,2,3.00,0.250,0.750); -/*!40000 ALTER TABLE `invoice_items` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `invoices` -- @@ -718,9 +358,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(), @@ -728,46 +368,40 @@ 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') DEFAULT 'unpaid', + `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, 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=30 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Dumping data for table `invoices` +-- Table structure for table `licenses` -- -LOCK TABLES `invoices` WRITE; -/*!40000 ALTER TABLE `invoices` DISABLE KEYS */; -INSERT INTO `invoices` VALUES -(1,4,'2026-02-16','sale','cash',0.225,'2026-02-16 09:03:24',0.000,0.225,NULL,0.225,'paid',NULL), -(2,1,'2026-02-16','sale','credit',2.250,'2026-02-16 09:12:02',0.000,2.250,NULL,4.500,'paid',NULL), -(3,4,'2026-02-16','sale','cash',4.950,'2026-02-16 09:53:11',0.000,4.950,NULL,0.000,'paid',NULL), -(4,1,'2026-02-16','sale','credit',4.500,'2026-02-16 10:58:38',0.000,4.500,NULL,4.500,'paid',NULL), -(5,2,'2026-02-16','sale','cash',0.450,'2026-02-16 11:20:39',0.000,0.450,NULL,0.450,'paid',NULL), -(6,6,'2026-02-16','purchase','credit',40.000,'2026-02-16 11:21:59',0.000,40.000,NULL,40.000,'paid',NULL), -(12,NULL,'2026-02-16','sale','cash',0.000,'2026-02-16 12:22:22',0.000,1.350,NULL,1.350,'paid',NULL), -(14,NULL,'2026-02-16','sale','cash',0.000,'2026-02-16 12:31:20',0.000,0.900,NULL,0.900,'paid',NULL), -(15,NULL,'2026-02-16','sale',NULL,0.000,'2026-02-16 12:57:53',0.000,0.450,NULL,0.450,'paid',NULL), -(16,4,'2026-02-16','sale',NULL,0.000,'2026-02-16 13:00:02',0.000,0.450,NULL,0.450,'paid',NULL), -(17,NULL,'2026-02-16','sale',NULL,0.000,'2026-02-16 13:04:16',0.000,0.900,NULL,0.900,'paid',NULL), -(18,4,'2026-02-16','sale','credit',0.450,'2026-02-16 13:34:29',0.000,0.450,NULL,0.000,'unpaid',NULL), -(19,4,'2026-02-16','sale','credit',0.450,'2026-02-16 13:37:35',0.000,0.450,NULL,0.000,'unpaid',NULL), -(20,4,'2026-02-16','sale','credit',0.450,'2026-02-16 13:46:45',0.000,0.450,NULL,0.000,'unpaid',NULL), -(21,4,'2026-02-16','sale',NULL,0.000,'2026-02-16 14:12:31',0.000,0.900,NULL,0.900,'paid',NULL), -(22,1,'2026-02-16','sale',NULL,0.000,'2026-02-16 14:46:12',0.000,0.450,NULL,0.450,'paid',NULL), -(23,1,'2026-02-16','sale',NULL,0.000,'2026-02-16 14:47:25',0.000,0.900,NULL,0.900,'paid',NULL), -(24,1,'2026-02-16','sale',NULL,0.000,'2026-02-16 14:49:19',0.000,0.900,NULL,0.900,'paid',NULL), -(25,1,'2026-02-16','sale','credit',0.000,'2026-02-16 14:53:43',0.000,0.900,NULL,0.000,'unpaid',NULL), -(26,4,'2026-02-16','sale','cash',2.700,'2026-02-16 14:56:40',0.000,2.700,NULL,0.000,'unpaid',NULL), -(27,4,'2026-02-17','sale',NULL,4.500,'2026-02-17 02:19:50',0.000,4.500,NULL,0.000,'unpaid',NULL), -(28,4,'2026-02-17','sale','cash',0.700,'2026-02-17 07:43:25',0.013,0.713,NULL,0.713,'paid',NULL), -(29,1,'2026-02-17','sale','cash',0.750,'2026-02-17 15:07:01',0.038,0.788,NULL,0.788,'paid',NULL); -/*!40000 ALTER TABLE `invoices` ENABLE KEYS */; -UNLOCK TABLES; +DROP TABLE IF EXISTS `licenses`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `licenses` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `license_key` varchar(255) NOT NULL, + `max_activations` int(11) DEFAULT 1, + `max_counters` int(11) DEFAULT 1, + `status` enum('active','suspended','expired') DEFAULT 'active', + `owner` varchar(255) DEFAULT NULL, + `address` text DEFAULT NULL, + `created_at` timestamp NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + UNIQUE KEY `license_key` (`license_key`) +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `loyalty_transactions` @@ -787,20 +421,9 @@ 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=2 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 */; --- --- Dumping data for table `loyalty_transactions` --- - -LOCK TABLES `loyalty_transactions` WRITE; -/*!40000 ALTER TABLE `loyalty_transactions` DISABLE KEYS */; -INSERT INTO `loyalty_transactions` VALUES -(1,1,14,1.000,'earned','Earned from POS order #POS-177142159441','2026-02-18 13:33:15'); -/*!40000 ALTER TABLE `loyalty_transactions` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `lpo_items` -- @@ -822,18 +445,9 @@ 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 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 */; --- --- Dumping data for table `lpo_items` --- - -LOCK TABLES `lpo_items` WRITE; -/*!40000 ALTER TABLE `lpo_items` DISABLE KEYS */; -/*!40000 ALTER TABLE `lpo_items` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `lpos` -- @@ -853,19 +467,25 @@ CREATE TABLE `lpos` ( `terms_conditions` text DEFAULT NULL, `created_at` timestamp NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), - 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; + 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; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Dumping data for table `lpos` +-- Table structure for table `migrations` -- -LOCK TABLES `lpos` WRITE; -/*!40000 ALTER TABLE `lpos` DISABLE KEYS */; -/*!40000 ALTER TABLE `lpos` ENABLE KEYS */; -UNLOCK TABLES; +DROP TABLE IF EXISTS `migrations`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `migrations` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `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; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `payment_methods` @@ -883,19 +503,6 @@ CREATE TABLE `payment_methods` ( ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- 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; - -- -- Table structure for table `payments` -- @@ -911,41 +518,13 @@ 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=20 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `payments` --- - -LOCK TABLES `payments` WRITE; -/*!40000 ALTER TABLE `payments` DISABLE KEYS */; -INSERT INTO `payments` VALUES -(1,2,'2026-02-16',2.250,'Cash','','2026-02-16 10:42:56'), -(2,2,'2026-02-16',2.250,'Cash','','2026-02-16 10:43:33'), -(3,4,'2026-02-16',2.000,'Cash','','2026-02-16 10:58:51'), -(4,4,'2026-02-16',2.500,'Cash','','2026-02-16 11:06:09'), -(5,1,'2026-02-16',0.225,'Cash','Initial payment','2026-02-16 11:08:23'), -(6,5,'2026-02-16',0.450,'Cash','Initial payment','2026-02-16 11:20:39'), -(7,6,'2026-02-16',20.000,'Cash','','2026-02-16 11:22:38'), -(8,6,'2026-02-16',20.000,'Cash','','2026-02-16 11:22:52'), -(9,12,'2026-02-16',1.350,'cash','POS Transaction','2026-02-16 12:22:22'), -(10,14,'2026-02-16',0.900,'cash','POS Transaction','2026-02-16 12:31:21'), -(11,15,'2026-02-16',5.000,'cash','POS Transaction','2026-02-16 12:57:53'), -(12,16,'2026-02-16',0.450,'credit','POS Transaction','2026-02-16 13:00:02'), -(13,17,'2026-02-16',0.900,'cash','POS Transaction','2026-02-16 13:04:16'), -(14,21,'2026-02-16',0.900,'credit','POS Transaction','2026-02-16 14:12:31'), -(15,22,'2026-02-16',0.450,'credit','POS Transaction','2026-02-16 14:46:12'), -(16,23,'2026-02-16',0.900,'credit','POS Transaction','2026-02-16 14:47:25'), -(17,24,'2026-02-16',0.900,'credit','POS Transaction','2026-02-16 14:49:19'), -(18,28,'2026-02-17',0.713,'Cash','Initial payment','2026-02-17 07:43:25'), -(19,29,'2026-02-17',0.788,'Cash','Payment via edit','2026-02-17 15:07:28'); -/*!40000 ALTER TABLE `payments` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `pos_devices` -- @@ -967,15 +546,6 @@ CREATE TABLE `pos_devices` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `pos_devices` --- - -LOCK TABLES `pos_devices` WRITE; -/*!40000 ALTER TABLE `pos_devices` DISABLE KEYS */; -/*!40000 ALTER TABLE `pos_devices` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `pos_held_carts` -- @@ -995,15 +565,6 @@ CREATE TABLE `pos_held_carts` ( ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `pos_held_carts` --- - -LOCK TABLES `pos_held_carts` WRITE; -/*!40000 ALTER TABLE `pos_held_carts` DISABLE KEYS */; -/*!40000 ALTER TABLE `pos_held_carts` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `pos_items` -- @@ -1017,40 +578,15 @@ 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=18 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=73 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `pos_items` --- - -LOCK TABLES `pos_items` WRITE; -/*!40000 ALTER TABLE `pos_items` DISABLE KEYS */; -INSERT INTO `pos_items` VALUES -(1,4,1,3.000,0.450,1.350), -(2,5,1,2.000,0.450,0.900), -(3,6,1,1.000,0.450,0.450), -(4,7,1,1.000,0.450,0.450), -(5,8,1,2.000,0.450,0.900), -(6,9,1,2.000,0.450,0.900), -(7,10,1,1.000,0.450,0.450), -(8,11,1,2.000,0.450,0.900), -(9,12,1,2.000,0.450,0.900), -(10,13,1,2.000,0.450,0.900), -(11,14,1,2.000,0.383,0.765), -(12,14,2,2.000,0.213,0.425), -(13,15,1,1.000,0.383,0.383), -(14,15,2,1.000,0.213,0.213), -(15,16,1,1.000,0.383,0.383), -(16,17,2,1.000,0.213,0.213), -(17,17,1,1.000,0.383,0.383); -/*!40000 ALTER TABLE `pos_items` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `pos_payments` -- @@ -1067,33 +603,9 @@ CREATE TABLE `pos_payments` ( PRIMARY KEY (`id`), KEY `transaction_id` (`transaction_id`), CONSTRAINT `pos_payments_ibfk_1` FOREIGN KEY (`transaction_id`) REFERENCES `pos_transactions` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `pos_payments` --- - -LOCK TABLES `pos_payments` WRITE; -/*!40000 ALTER TABLE `pos_payments` DISABLE KEYS */; -INSERT INTO `pos_payments` VALUES -(1,4,'cash',1.350,'2026-02-18 12:07:43'), -(2,5,'cash',0.900,'2026-02-18 12:07:43'), -(3,6,'cash',0.450,'2026-02-18 12:07:43'), -(4,7,'credit',0.450,'2026-02-18 12:07:43'), -(5,8,'cash',0.900,'2026-02-18 12:07:43'), -(6,9,'credit',0.900,'2026-02-18 12:07:43'), -(7,10,'credit',0.450,'2026-02-18 12:07:43'), -(8,11,'credit',0.900,'2026-02-18 12:07:43'), -(9,12,'credit',0.900,'2026-02-18 12:07:43'), -(10,13,'credit',0.900,'2026-02-18 12:07:43'), -(16,14,'credit',1.190,'2026-02-18 13:33:15'), -(17,15,'cash',0.595,'2026-02-18 15:32:30'), -(18,16,'cash',0.383,'2026-02-18 18:09:25'), -(19,17,'cash',0.595,'2026-02-18 18:09:44'); -/*!40000 ALTER TABLE `pos_payments` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `pos_transactions` -- @@ -1119,32 +631,46 @@ CREATE TABLE `pos_transactions` ( `register_session_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `transaction_no` (`transaction_no`) -) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Dumping data for table `pos_transactions` +-- Table structure for table `purchase_items` -- -LOCK TABLES `pos_transactions` WRITE; -/*!40000 ALTER TABLE `pos_transactions` DISABLE KEYS */; -INSERT INTO `pos_transactions` VALUES -(4,'POS-1771244542359',NULL,1.350,0.000,NULL,0.000,1.000,0.000,1.350,'cash','completed','2026-02-16 12:22:22',NULL,NULL), -(5,'POS-1771245080116',NULL,0.900,0.000,NULL,0.000,0.000,0.000,0.900,'cash','completed','2026-02-16 12:31:20',NULL,NULL), -(6,'POS-1771246673214',NULL,0.450,0.000,NULL,0.000,0.000,0.000,0.450,'cash','completed','2026-02-16 12:57:53',NULL,NULL), -(7,'POS-1771246802602',4,0.450,0.000,NULL,0.000,0.000,0.000,0.450,'credit','completed','2026-02-16 13:00:02',NULL,NULL), -(8,'POS-1771247056481',NULL,0.900,0.000,NULL,0.000,0.000,0.000,0.900,'cash','completed','2026-02-16 13:04:16',NULL,NULL), -(9,'POS-1771251151407',4,0.900,0.000,NULL,0.000,0.000,0.000,0.900,'credit','completed','2026-02-16 14:12:31',NULL,NULL), -(10,'POS-1771253172485',1,0.450,0.000,NULL,0.000,0.000,0.000,0.450,'credit','completed','2026-02-16 14:46:12',NULL,NULL), -(11,'POS-1771253245896',1,0.900,0.000,NULL,0.000,0.000,0.000,0.900,'credit','completed','2026-02-16 14:47:25',NULL,NULL), -(12,'POS-1771253359500',1,0.900,0.000,NULL,0.000,0.000,0.000,0.900,'credit','completed','2026-02-16 14:49:19',NULL,NULL), -(13,'POS-1771253623949',1,0.900,0.000,NULL,0.000,0.000,0.000,0.900,'credit','completed','2026-02-16 14:53:43',NULL,NULL), -(14,'POS-177142159441',1,1.190,0.000,NULL,0.000,1.000,0.000,1.190,NULL,'completed','2026-02-18 13:33:14',1,NULL), -(15,'POS-177142875034',NULL,0.595,0.000,NULL,0.000,0.000,0.000,0.595,NULL,'completed','2026-02-18 15:32:30',1,NULL), -(16,'POS-177143816521',NULL,0.383,0.000,NULL,0.000,0.000,0.000,0.383,NULL,'completed','2026-02-18 18:09:25',1,2), -(17,'POS-177143818439',NULL,0.595,0.000,NULL,0.000,0.000,0.000,0.595,NULL,'completed','2026-02-18 18:09:44',1,2); -/*!40000 ALTER TABLE `pos_transactions` ENABLE KEYS */; -UNLOCK TABLES; +DROP TABLE IF EXISTS `purchase_items`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `purchase_items` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `purchase_id` int(11) NOT NULL, + `item_id` int(11) NOT NULL, + `quantity` decimal(15,2) NOT NULL, + `unit_price` decimal(15,3) DEFAULT NULL, + `vat_amount` decimal(15,3) DEFAULT NULL, + `total_price` decimal(15,3) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `purchase_payments` +-- + +DROP TABLE IF EXISTS `purchase_payments`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `purchase_payments` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `purchase_id` int(11) NOT NULL, + `payment_date` date NOT NULL, + `amount` decimal(15,3) DEFAULT NULL, + `payment_method` varchar(50) DEFAULT NULL, + `notes` text DEFAULT NULL, + `created_at` timestamp NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `purchase_return_items` @@ -1165,20 +691,9 @@ 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=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `purchase_return_items` --- - -LOCK TABLES `purchase_return_items` WRITE; -/*!40000 ALTER TABLE `purchase_return_items` DISABLE KEYS */; -INSERT INTO `purchase_return_items` VALUES -(1,1,1,50.00,0.400,20.000); -/*!40000 ALTER TABLE `purchase_return_items` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `purchase_returns` -- @@ -1188,30 +703,44 @@ DROP TABLE IF EXISTS `purchase_returns`; /*!40101 SET character_set_client = utf8mb4 */; CREATE TABLE `purchase_returns` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `invoice_id` int(11) NOT NULL, + `purchase_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 `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 `customers` (`id`) ON DELETE SET NULL -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + 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, + 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; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Dumping data for table `purchase_returns` +-- Table structure for table `purchases` -- -LOCK TABLES `purchase_returns` WRITE; -/*!40000 ALTER TABLE `purchase_returns` DISABLE KEYS */; -INSERT INTO `purchase_returns` VALUES -(1,6,6,'2026-02-17',20.000,'','2026-02-17 16:52:23'); -/*!40000 ALTER TABLE `purchase_returns` ENABLE KEYS */; -UNLOCK TABLES; +DROP TABLE IF EXISTS `purchases`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `purchases` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `supplier_id` int(11) DEFAULT NULL, + `invoice_date` date NOT NULL, + `payment_type` varchar(100) DEFAULT NULL, + `total_amount` decimal(15,3) DEFAULT NULL, + `vat_amount` decimal(15,3) DEFAULT NULL, + `total_with_vat` decimal(15,3) DEFAULT NULL, + `terms_conditions` text DEFAULT NULL, + `paid_amount` decimal(15,3) DEFAULT NULL, + `status` enum('paid','unpaid','partially_paid') DEFAULT NULL, + `register_session_id` int(11) DEFAULT NULL, + `due_date` date DEFAULT NULL, + `created_at` timestamp NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `quotation_items` @@ -1226,6 +755,7 @@ 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`), @@ -1235,18 +765,6 @@ CREATE TABLE `quotation_items` ( ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `quotation_items` --- - -LOCK TABLES `quotation_items` WRITE; -/*!40000 ALTER TABLE `quotation_items` DISABLE KEYS */; -INSERT INTO `quotation_items` VALUES -(1,1,1,10.00,0.450,4.500), -(2,2,2,10.00,0.250,2.500); -/*!40000 ALTER TABLE `quotation_items` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `quotations` -- @@ -1271,18 +789,6 @@ CREATE TABLE `quotations` ( ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `quotations` --- - -LOCK TABLES `quotations` WRITE; -/*!40000 ALTER TABLE `quotations` DISABLE KEYS */; -INSERT INTO `quotations` VALUES -(1,4,'2026-02-16','2026-02-20','converted',4.500,0.000,4.500,NULL,'2026-02-16 17:08:34'), -(2,4,'2026-02-17','2026-02-20','pending',2.500,0.125,2.625,NULL,'2026-02-17 07:44:12'); -/*!40000 ALTER TABLE `quotations` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `register_sessions` -- @@ -1302,21 +808,9 @@ CREATE TABLE `register_sessions` ( `status` enum('open','closed') DEFAULT 'open', `notes` text DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=3 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 */; --- --- Dumping data for table `register_sessions` --- - -LOCK TABLES `register_sessions` WRITE; -/*!40000 ALTER TABLE `register_sessions` DISABLE KEYS */; -INSERT INTO `register_sessions` VALUES -(1,1,1,0.000,0.000,0.000,'2026-02-18 11:43:14','2026-02-18 12:01:49','closed',''), -(2,1,1,0.000,0.978,5.000,'2026-02-18 18:09:07','2026-02-18 18:10:17','closed',''); -/*!40000 ALTER TABLE `register_sessions` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `role_groups` -- @@ -1337,6 +831,8 @@ CREATE TABLE `role_groups` ( -- DROP TABLE IF EXISTS `role_permissions`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; CREATE TABLE `role_permissions` ( `id` int(11) NOT NULL AUTO_INCREMENT, `role_id` int(11) NOT NULL, @@ -1344,35 +840,8 @@ CREATE TABLE `role_permissions` ( PRIMARY KEY (`id`), UNIQUE KEY `role_id` (`role_id`,`permission`), CONSTRAINT `role_permissions_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES `role_groups` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - --- --- 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` (role_id, permission) VALUES -(1,'all'), -(4,'pos_view'),(4,'pos_add'),(4,'items_view'),(4,'items_add'), -(5,'pos_view'),(5,'pos_add'),(5,'pos_edit'),(5,'quotations_view'),(5,'quotations_add'),(5,'quotations_edit'),(5,'customers_view'),(5,'customers_add'),(5,'customers_edit'),(5,'suppliers_view'),(5,'suppliers_add'),(5,'suppliers_edit'),(5,'sales_view'),(5,'sales_add'),(5,'sales_edit'),(5,'purchases_view'),(5,'purchases_add'),(5,'purchases_edit'),(5,'hr_view'),(5,'hr_add'),(5,'hr_edit'),(5,'hr_delete'),(5,'users_view'), -(6,'accounting_view'),(6,'accounting_add'),(6,'accounting_edit'); -/*!40000 ALTER TABLE `role_permissions` ENABLE KEYS */; -UNLOCK TABLES; +) ENGINE=InnoDB AUTO_INCREMENT=218 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `sales_return_items` @@ -1393,20 +862,9 @@ 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=2 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 */; --- --- Dumping data for table `sales_return_items` --- - -LOCK TABLES `sales_return_items` WRITE; -/*!40000 ALTER TABLE `sales_return_items` DISABLE KEYS */; -INSERT INTO `sales_return_items` VALUES -(1,1,2,2.00,0.250,0.500); -/*!40000 ALTER TABLE `sales_return_items` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `sales_returns` -- @@ -1427,20 +885,9 @@ 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=2 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 */; --- --- Dumping data for table `sales_returns` --- - -LOCK TABLES `sales_returns` WRITE; -/*!40000 ALTER TABLE `sales_returns` DISABLE KEYS */; -INSERT INTO `sales_returns` VALUES -(1,29,1,'2026-02-17',0.500,'','2026-02-17 16:30:50'); -/*!40000 ALTER TABLE `sales_returns` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `settings` -- @@ -1456,38 +903,6 @@ CREATE TABLE `settings` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- 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; - -- -- Table structure for table `stock_categories` -- @@ -1501,21 +916,9 @@ CREATE TABLE `stock_categories` ( `name_ar` varchar(255) NOT NULL, `created_at` timestamp NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `stock_categories` --- - -LOCK TABLES `stock_categories` WRITE; -/*!40000 ALTER TABLE `stock_categories` DISABLE KEYS */; -INSERT INTO `stock_categories` VALUES -(1,'Spices','بهارات','2026-02-16 08:00:02'), -(2,'Food Stuff','مواد غذائية','2026-02-16 08:00:36'); -/*!40000 ALTER TABLE `stock_categories` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `stock_items` -- @@ -1551,21 +954,9 @@ CREATE TABLE `stock_items` ( CONSTRAINT `fk_stock_items_supplier` FOREIGN KEY (`supplier_id`) REFERENCES `customers` (`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=3 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 */; --- --- Dumping data for table `stock_items` --- - -LOCK TABLES `stock_items` WRITE; -/*!40000 ALTER TABLE `stock_items` DISABLE KEYS */; -INSERT INTO `stock_items` VALUES -(1,2,3,NULL,'Tomato','طماطم','1234567',0.400,0.450,-20.50,0.00,NULL,'uploads/items/item_6992d1c375bb8.jfif','2026-02-16 08:13:55',0.00,1,'2026-02-18','2026-02-19',15.00), -(2,2,3,6,'onion','بصل','123456',0.150,0.250,24.00,20.00,NULL,'uploads/items/item_699421bad9019.jfif','2026-02-17 04:22:48',5.00,1,'2026-02-18','2026-02-19',15.00); -/*!40000 ALTER TABLE `stock_items` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `stock_units` -- @@ -1585,17 +976,25 @@ CREATE TABLE `stock_units` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Dumping data for table `stock_units` +-- Table structure for table `suppliers` -- -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; +DROP TABLE IF EXISTS `suppliers`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `suppliers` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL, + `email` varchar(255) DEFAULT NULL, + `phone` varchar(50) DEFAULT NULL, + `tax_id` varchar(50) DEFAULT NULL, + `balance` decimal(15,3) DEFAULT NULL, + `credit_limit` decimal(15,3) DEFAULT NULL, + `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; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `system_license` @@ -1609,25 +1008,16 @@ CREATE TABLE `system_license` ( `license_key` varchar(255) NOT NULL, `activation_token` text DEFAULT NULL, `fingerprint` varchar(255) DEFAULT NULL, - `status` enum('pending','active','expired','suspended') DEFAULT 'pending', + `status` enum('pending','active','expired','suspended','trial') DEFAULT 'pending', `activated_at` datetime DEFAULT NULL, `last_checked_at` datetime DEFAULT NULL, `created_at` timestamp NULL DEFAULT current_timestamp(), + `trial_started_at` datetime DEFAULT NULL, + `allowed_activations` int(11) DEFAULT 1, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Dumping data for table `system_license` --- - -LOCK TABLES `system_license` WRITE; -/*!40000 ALTER TABLE `system_license` DISABLE KEYS */; -INSERT INTO `system_license` VALUES -(1,'FLAT-8822-1192-3301','60952c06f50b36017a6626afe5196de6b08b49692db26716ebd90f25f791c0ca','e43ab74edcde18e3edea26e701d07c17cfdddf5e33a8e0f64bf56ff50e2c34bb','active','2026-02-18 10:48:04',NULL,'2026-02-18 10:48:04'); -/*!40000 ALTER TABLE `system_license` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `users` -- @@ -1652,19 +1042,6 @@ CREATE TABLE `users` ( CONSTRAINT `users_ibfk_1` FOREIGN KEY (`group_id`) REFERENCES `role_groups` (`id`) ON DELETE SET NULL ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; - --- --- 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','active','2026-02-18 05:30:12','default'), -(2,1,'admin2','$2y$10$A299UOd8VZWXyuKcbcLwWewIg.7V2ti3oomGaKH9qhMm4vdG6a/xi',NULL,NULL,NULL,'active','2026-02-18 06:44:10','default'), -(5,1,'moosa','$2y$10$Ho5NrFTAb6HUH4VvCd4NZuCsKGMl4v1pvWiesEuC29fDDu6Pkg7AS','aalabry@gmail.com',NULL,NULL,'active','2026-02-18 09:30:38','default'); -/*!40000 ALTER TABLE `users` ENABLE KEYS */; -UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; @@ -1675,4 +1052,373 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2026-02-19 4:47:13 +-- 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 diff --git a/cookies.txt b/cookies.txt new file mode 100644 index 0000000..c9d73f7 --- /dev/null +++ b/cookies.txt @@ -0,0 +1,5 @@ +# Netscape HTTP Cookie File +# https://curl.se/docs/http-cookies.html +# This file was generated by libcurl! Edit at your own risk. + +127.0.0.1 FALSE / FALSE 0 PHPSESSID b6ihps49oas08569v0vg5i1hnb diff --git a/db/migrations/20260220_unify_pos_sales.php b/db/migrations/20260220_unify_pos_sales.php index 56a8ec2..113ba9e 100644 --- a/db/migrations/20260220_unify_pos_sales.php +++ b/db/migrations/20260220_unify_pos_sales.php @@ -1,5 +1,5 @@ query("DESCRIBE $t"); - while($r = $res->fetch(PDO::FETCH_ASSOC)) { - echo " {$r['Field']} ({$r['Type']})\n"; - } - } catch (Exception $e) { - echo " Error: " . $e->getMessage() . "\n"; - } -} diff --git a/get_schema.php b/get_schema.php deleted file mode 100644 index c9246d7..0000000 --- a/get_schema.php +++ /dev/null @@ -1,10 +0,0 @@ -query("SHOW TABLES")->fetchAll(PDO::FETCH_COLUMN); -foreach ($tables as $t) { - echo "TABLE: $t\n"; - $cols = db()->query("SHOW COLUMNS FROM $t")->fetchAll(PDO::FETCH_ASSOC); - foreach ($cols as $c) { - echo " - {$c['Field']} ({$c['Type']})\n"; - } -} diff --git a/includes/lang.php b/includes/lang.php index b75b43d..6a8db71 100644 --- a/includes/lang.php +++ b/includes/lang.php @@ -18,7 +18,7 @@ $translations = [ 'quotations' => 'Quotations', 'expenses' => 'Expenses', 'expense_categories' => 'Expense Categories', - 'accounting' => 'Accounting', + 'accounting' => 'Meezan Accounting System', 'trial_balance' => 'Trial Balance', 'profit_loss' => 'Profit & Loss', 'balance_sheet' => 'Balance Sheet', @@ -113,7 +113,7 @@ $translations = [ 'quotations' => 'عروض الأسعار', 'expenses' => 'المصاريف', 'expense_categories' => 'فئات المصاريف', - 'accounting' => 'المحاسبة', + 'accounting' => 'نظام ميزان المحاسبي', 'trial_balance' => 'ميزان المراجعة', 'profit_loss' => 'الأرباح والخسائر', 'balance_sheet' => 'الميزانية العمومية', diff --git a/index.php b/index.php index be38c72..118444d 100644 --- a/index.php +++ b/index.php @@ -120,7 +120,7 @@ if ($page === 'activate') { <?= __('activate_product') ?> - + '); printWindow.document.write(''); printWindow.document.write(content.innerHTML); diff --git a/installation/index.php b/installation/index.php index 18494b5..e36224e 100644 --- a/installation/index.php +++ b/installation/index.php @@ -130,6 +130,50 @@ if ($step === 3 && $_SERVER['REQUEST_METHOD'] === 'POST') { )"); } + // --- Run Migrations --- + $stmt = $pdo->query("SHOW TABLES LIKE 'migrations'"); + if ($stmt->rowCount() == 0) { + $pdo->exec("CREATE TABLE migrations ( + id INT AUTO_INCREMENT PRIMARY KEY, + migration VARCHAR(255) NOT NULL, + executed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP + )"); + } + + $stmt = $pdo->query("SELECT migration FROM migrations"); + $executed = $stmt->fetchAll(PDO::FETCH_COLUMN); + + $files = glob(__DIR__ . '/../db/migrations/*.sql'); + sort($files); + + foreach ($files as $file) { + $migrationName = basename($file); + if (!in_array($migrationName, $executed)) { + $sql = file_get_contents($file); + try { + $pdo->exec($sql); + $stmt = $pdo->prepare("INSERT INTO migrations (migration) VALUES (?)"); + $stmt->execute([$migrationName]); + } catch (PDOException $e) { + // Ignore duplicate column errors or missing columns if schema already has them + // This is safe because complete_schema.sql might be partially updated + } + } + } + + $php_files = glob(__DIR__ . '/../db/migrations/*.php'); + sort($php_files); + foreach ($php_files as $pfile) { + $migrationName = basename($pfile); + if (!in_array($migrationName, $executed)) { + try { + include $pfile; + $stmt = $pdo->prepare("INSERT INTO migrations (migration) VALUES (?)"); + $stmt->execute([$migrationName]); + } catch (Exception $e) {} + } + } + // --- End Migrations --- // Ensure Admin Role exists (might be in schema but just in case) $stmt = $pdo->prepare("SELECT id FROM role_groups WHERE name = 'Administrator'"); $stmt->execute(); diff --git a/lib/LicenseService.php b/lib/LicenseService.php index c9022f3..849495c 100644 --- a/lib/LicenseService.php +++ b/lib/LicenseService.php @@ -88,7 +88,7 @@ class LicenseService { $stmt = db()->prepare("SELECT COUNT(*) FROM system_license"); $stmt->execute(); if ($stmt->fetchColumn() == 0) { - db()->exec("INSERT INTO system_license (status, trial_started_at) VALUES ('trial', NOW())"); + db()->exec("INSERT INTO system_license (license_key, status, trial_started_at) VALUES ('TRIAL', 'trial', NOW())"); } else { db()->exec("UPDATE system_license SET trial_started_at = NOW() WHERE trial_started_at IS NULL"); } diff --git a/post_debug.log b/post_debug.log index 02ae818..e2709a1 100644 --- a/post_debug.log +++ b/post_debug.log @@ -168,3 +168,15 @@ 2026-02-20 13:31:46 - POST: {"action":"save_pos_transaction","customer_id":"7","payments":"[{\"method\":\"credit\",\"amount\":2.3}]","total_amount":"2.3","tax_amount":"0","discount_code_id":"","discount_amount":"0","loyalty_redeemed":"0","items":"[{\"id\":1,\"qty\":4,\"price\":0.45,\"vat_rate\":0,\"vat_amount\":0},{\"id\":3,\"qty\":2,\"price\":0.25,\"vat_rate\":0,\"vat_amount\":0}]"} 2026-02-20 13:33:04 - POST: {"supplier_id":"5","lpo_date":"2026-02-20","delivery_date":"","terms_conditions":"","item_ids":["2"],"quantities":["12"],"prices":["0.150"],"add_lpo":""} 2026-02-20 13:33:26 - POST: {"convert_lpo_to_purchase":"","lpo_id":"22"} +2026-02-21 07:33:44 - POST: {"action":"translate","text":"sugar 5 kg","target":"ar"} +2026-02-21 07:34:05 - POST: {"name_en":"sugar 5 kg","name_ar":"\u0633\u0643\u0631","category_id":"2","unit_id":"3","supplier_id":"7","sku":"834687678048","sale_price":"1","purchase_price":"0.8","stock_quantity":"0.000","min_stock_level":"0.000","vat_rate":"5","expiry_date":"","promotion_start":"","promotion_end":"","promotion_percent":"0.00","add_item":""} +2026-02-21 08:09:18 - POST: {"license_key":"FLAT-ED9A-CBE3-A23D","activate":""} +2026-02-21 08:13:32 - POST: {"action":"translate","text":"onion","target":"ar"} +2026-02-21 08:16:19 - POST: {"type":"supplier","name":"al baimani","email":"","phone":"","tax_id":"","balance":"0.000","add_customer":""} +2026-02-21 08:16:34 - POST: {"type":"supplier","name":"al marai","email":"","phone":"","tax_id":"","balance":"0.000","add_customer":""} +2026-02-21 08:16:47 - POST: {"type":"supplier","name":"cash","email":"","phone":"","tax_id":"","balance":"0.000","add_customer":""} +2026-02-21 08:17:45 - POST: {"name_en":"green onion","name_ar":"\u0628\u0635\u0644 \u0627\u062e\u0636\u0631","category_id":"2","unit_id":"1","supplier_id":"8","sku":"778690168233","sale_price":"0.1","purchase_price":"0.08","stock_quantity":"0.000","min_stock_level":"0.000","vat_rate":"5","expiry_date":"","promotion_start":"","promotion_end":"","promotion_percent":"0.00","add_item":""} +2026-02-21 08:19:13 - POST: {"name_en":"green onion","name_ar":"\u0628\u0635\u0644 \u0627\u062e\u0636\u0631","category_id":"2","unit_id":"1","supplier_id":"8","sku":"778690168233","sale_price":"0.1","purchase_price":"0.08","stock_quantity":"0.000","min_stock_level":"0.000","vat_rate":"5","expiry_date":"","promotion_start":"","promotion_end":"","promotion_percent":"0.00","add_item":""} +2026-02-21 08:21:09 - POST: {"text":"Hello","target":"ar"} +2026-02-21 08:22:20 - POST: {"text":"Hello","target":"ar"} +2026-02-21 08:24:11 - POST: {"name_en":"green onion","name_ar":"\u0628\u0635\u0644 \u0627\u062e\u0636\u0631","category_id":"2","unit_id":"1","supplier_id":"8","sku":"778690168233","sale_price":"0.1","purchase_price":"0.08","stock_quantity":"0.000","min_stock_level":"0.000","vat_rate":"5","expiry_date":"","promotion_start":"","promotion_end":"","promotion_percent":"0.00","add_item":""} diff --git a/run_migrations.php b/run_migrations.php new file mode 100644 index 0000000..20771cc --- /dev/null +++ b/run_migrations.php @@ -0,0 +1,62 @@ +query("SHOW TABLES LIKE 'migrations'"); + if ($stmt->rowCount() == 0) { + $pdo->exec("CREATE TABLE migrations ( + id INT AUTO_INCREMENT PRIMARY KEY, + migration VARCHAR(255) NOT NULL, + executed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP + )"); + echo "Created migrations table.\n"; + } + + $stmt = $pdo->query("SELECT migration FROM migrations"); + $executed = $stmt->fetchAll(PDO::FETCH_COLUMN); + + $files = glob('db/migrations/*.sql'); + sort($files); + + foreach ($files as $file) { + $migrationName = basename($file); + if (!in_array($migrationName, $executed)) { + echo "Executing: $migrationName...\n"; + $sql = file_get_contents($file); + try { + $pdo->exec($sql); + $stmt = $pdo->prepare("INSERT INTO migrations (migration) VALUES (?)"); + $stmt->execute([$migrationName]); + echo "Success: $migrationName\n"; + } catch (PDOException $e) { + echo "Error executing $migrationName: " . $e->getMessage() . "\n"; + } + } + } + + + +} catch (Exception $e) { + echo "DB Error: " . $e->getMessage() . "\n"; +} + + $php_files = glob('db/migrations/*.php'); + sort($php_files); + foreach ($php_files as $pfile) { + $migrationName = basename($pfile); + if (!in_array($migrationName, $executed)) { + echo "Executing PHP: $migrationName...\n"; + try { + include $pfile; + $stmt = $pdo->prepare("INSERT INTO migrations (migration) VALUES (?)"); + $stmt->execute([$migrationName]); + echo "Success: $migrationName\n"; + } catch (Exception $e) { + echo "Error executing $migrationName: " . $e->getMessage() . "\n"; + } + } + } +echo "Done checking migrations.\n";