# CP Inventory — Setup Instructions

## Directory layout on the server

Upload everything into:  public_html/inventory/

    public_html/
    └── inventory/
        ├── admin/
        │   ├── add_item.php
        │   ├── locations.php
        │   ├── login.php
        │   ├── logout.php
        │   └── upload_batch.php
        ├── includes/
        │   ├── auth.php
        │   ├── db.php
        │   └── sku.php
        └── uploads/
            └── photos/          ← must be writable (chmod 755)

---

## Step 1 — Create the database in phpMyAdmin

1. Log in to cPanel → phpMyAdmin.
2. Click "New" in the left panel to create a database, e.g. user123_inventory.
3. Create a user and grant ALL PRIVILEGES on that database
   (cPanel → MySQL Databases → Add User to Database).
4. Select the database in the left panel, click the SQL tab.
5. Paste and run schema.sql, then migration_002_physical_attrs.sql.

---

## Step 2 — Configure includes/db.php

    define('DB_NAME', 'user123_inventory');
    define('DB_USER', 'user123_invuser');
    define('DB_PASS', 'your_db_password');
    define('ADMIN_PASSWORD', 'choose_a_strong_password');
    define('UPLOAD_URL', '/inventory/uploads/photos/');

---

## Step 3 — Upload files and set permissions

Upload all files preserving the folder structure above.
Set uploads/photos/ to writable: right-click in File Manager → Permissions → 755.

---

## Step 4 — First login

Visit: https://yourdomain.com/inventory/admin/login.php

---

## Labeling items

Use a handheld label maker (e.g. Brother P-touch PTM95, ~$15–20) to print
the SKU onto a small label and attach it to each item before or after photographing.

The SKU is shown prominently in the success bar after saving each item.

---

## SKU format

Labels read:  CP-00001, CP-00002, etc.
The prefix is set in includes/db.php → SKU_PREFIX.
The sequence counter lives in the sku_sequence table.

---

## Storage location codes

Use the format S1-L3-B2 (Shelf unit 1, Level 3, Bin 2).
Add locations before cataloguing via admin/locations.php.

---

## Photo naming for batch upload

For upload_batch.php, name files:
    CP00142_1.jpg        item CP-00142, photo 1
    CP00142_2.jpg        item CP-00142, photo 2

Unknown filenames are skipped safely — mixed folders are fine.

---

## What's next (future files)

- admin/edit_item.php    — edit any item's details
- admin/dashboard.php   — overview stats
- index.php             — public browsing/search page
- item.php              — single item page for buyers
