# MySQL + Admin Login Setup

This version keeps the public store working even when MySQL is not enabled yet. While MySQL is disabled, the store uses `data/products.php` and saves inquiries to `storage/orders/` as JSON. After MySQL is enabled, products and orders will use the database.

## 1. Create MySQL database

In cPanel or your hosting panel, create:

- Database name
- Database user
- Database password

Assign the user to the database with full privileges.

## 2. Import schema

Open phpMyAdmin, select the database, then import:

```text
database/schema.sql
```

This creates:

- `admins`
- `products`
- `orders`
- `order_items`

It also inserts the sample sofas and a default admin account.

## 3. Edit database credentials

Open:

```text
data/database.php
```

Change this:

```php
'enabled' => false,
```

To this:

```php
'enabled' => true,
```

Then enter your database details:

```php
'host' => 'localhost',
'database' => 'your_database_name',
'username' => 'your_database_user',
'password' => 'your_database_password',
```

## 4. Login to admin

Open:

```text
https://your-domain.com/admin/login.php
```

Default login:

```text
Username: admin
Password: Admin@12345
```

Change this password immediately by updating the `admins.password_hash` value in the database or by creating another admin account.

## 5. Add a new sofa

Go to:

```text
Admin > Products > Add Sofa
```

You can upload:

- Product image: JPG, PNG, WEBP
- AR model: GLB, GLTF, USDZ

For accurate AR, set:

- Width cm
- Depth cm
- Height cm
- AR floor offset cm

Best practice: export GLB models in meters and make sure the bottom of the sofa sits exactly on the floor line/origin.

## 6. View orders

Go to:

```text
Admin > Orders
```

You can search orders and update status:

- Pending quotation
- Confirmed
- Preparing
- For Delivery
- Delivered
- Cancelled

## Notes

- Public pages automatically read products from MySQL when enabled.
- Checkout recalculates prices on the server from the product table.
- If MySQL is disabled or unavailable, the store falls back to file-based products and JSON order saving.
- Folders `data/`, `database/`, and `storage/` include `.htaccess` protection.

## Furnify Re-Up update

This version adds a Re-Up request table. If you are upgrading from the previous ZIP and already imported the older schema, import this migration only:

```text
database/migration_reup.sql
```

Admin Re-Up page:

```text
/admin/reup.php
```

Public Re-Up page:

```text
/reup.php
```


## Custom Sofa Quote

This version includes a personalized custom sofa quote form at `custom-sofa.php` and admin monitoring at `admin/custom-quotes.php`. If you already imported an older database, import `database/migration_custom_sofa_quotes.sql`.
