# Installation Guide Follow these steps to set up the application on your server. ## 1. Requirements Before you begin, ensure your server meets the following requirements: * **Operating System:** Linux, Windows, or macOS. * **Web Server:** Apache 2.4+ (with `mod_rewrite` enabled). * **PHP:** Version 8.0 or higher. * **Database:** MariaDB 10.4+ or MySQL 5.7+. * **PHP Extensions:** * `pdo_mysql` * `curl` * `gd` (for image processing) * `mbstring` * `json` ## 2. Database Setup 1. **Create a Database:** Create a new MySQL/MariaDB database (e.g., `pos_system`). 2. **Configure Connection:** Rename `db/config.php.example` to `db/config.php` (if not already present) and update the database credentials: ```php define('DB_HOST', 'localhost'); define('DB_NAME', 'your_database_name'); define('DB_USER', 'your_username'); define('DB_PASS', 'your_password'); ``` 3. **Import Schema:** Import the base schema from `db/schema.sql` into your database. 4. **Run Migrations:** Import all SQL files located in `db/migrations/` in sequential order (001, 002, etc.). 5. **Initialize Data:** Run the initialization script by visiting `http://your-domain.com/db/init.php` in your browser. This will seed categories, products, and outlets. ## 3. Creating a Super Admin Since the initial setup does not include a default user for security reasons, you must create the first Administrator account. ### Option A: Using the Setup Script (Recommended) Create a temporary file named `setup_admin.php` in the root directory with the following content: ```php prepare("SELECT id FROM user_groups WHERE name = 'Administrator' LIMIT 1"); $stmt->execute(); $group_id = $stmt->fetchColumn(); if (!$group_id) { $pdo->exec("INSERT INTO user_groups (name, permissions) VALUES ('Administrator', 'all')"); $group_id = $pdo->lastInsertId(); } // Create the user try { $stmt = $pdo->prepare("INSERT INTO users (group_id, username, password, full_name, email, is_active) VALUES (?, ?, ?, ?, ?, 1)"); $stmt->execute([$group_id, $username, $password, $full_name, $email]); echo "Super Admin created successfully!
Username: admin
Password: admin123
Please delete this file immediately!"; } catch (Exception $e) { echo "Error: " . $e->getMessage(); } ``` Visit `http://your-domain.com/setup_admin.php` and then **delete the file**. ### Option B: Manual SQL If you prefer SQL, run the following (replace the password hash with one generated via `password_hash()` in PHP): ```sql INSERT INTO users (group_id, username, password, full_name, email, is_active) VALUES (1, 'admin', 'REPLACE_WITH_HASH', 'Super Admin', 'admin@example.com', 1); ``` ## 4. Final Steps 1. **File Permissions:** Ensure the `assets/images/` directory is writable by the web server for uploading product and ad images. 2. **Login:** Go to `http://your-domain.com/login.php` and log in with your new credentials. 3. **Company Settings:** Navigate to **Admin -> Company Settings** to configure your restaurant name, address, and currency. --- **Security Note:** Always ensure your `db/config.php` and `.env` files are not accessible from the public web.