# Deploy JAN Enterprises ERP to jan.doctorlabs.in

Target paths confirmed from cPanel:

- Laravel application: `/home2/doctorlabs/jan-enterprises-erp`
- Domain document root: `/home2/doctorlabs/public_html/jan.doctorlabs.in`
- URL: `https://jan.doctorlabs.in`

## 1. Create the MySQL database in cPanel
Create a database and user. Recommended names (cPanel may prefix automatically):

- Database: `doctorlabs_janerp`
- User: `doctorlabs_janerp`

Give the user **ALL PRIVILEGES** on the database and keep the password ready.

## 2. Upload and extract this release
Upload the final ZIP to `/home2/doctorlabs/` and extract it there. It is packaged so these paths are created:

- `/home2/doctorlabs/jan-enterprises-erp`
- `/home2/doctorlabs/public_html/jan.doctorlabs.in`

The Laravel source is kept outside `public_html`; only the public entry point/assets are exposed.

## 3. Install PHP dependencies
In cPanel Terminal:

```bash
cd /home2/doctorlabs/jan-enterprises-erp
composer install --no-dev --optimize-autoloader
```

If `composer` is not on PATH, use the Composer command/path shown by your cPanel/WHM host.

Required PHP: **8.2+**. Recommended extensions: `pdo_mysql`, `mbstring`, `openssl`, `tokenizer`, `xml`, `dom`, `ctype`, `fileinfo`, `zip`, `curl`.

## 4. Configure `.env`

```bash
cp .env.example .env
```

Edit `.env` and set the real database password. Also set SMTP credentials if you want email reminders.

Then:

```bash
php artisan key:generate --force
php artisan migrate --seed --force
php artisan config:cache
php artisan route:cache
php artisan view:cache
```

## 5. Permissions

```bash
chmod -R 775 storage bootstrap/cache
```

If your server uses a different web-server group, adjust ownership according to your hosting setup.

## 6. Scheduler / reminders
Add this cPanel Cron Job to run every minute:

```bash
* * * * * cd /home2/doctorlabs/jan-enterprises-erp && php artisan schedule:run >> /dev/null 2>&1
```

The ERP scheduler currently runs:

- Agreement expiry check: 08:00 IST
- Invoice due/overdue check: 08:15 IST
- Email reminder digest: 08:30 IST (only when enabled in ERP Settings and SMTP is configured)

## 7. First login

- URL: `https://jan.doctorlabs.in`
- Username: `admin`
- Password: `Jan@123`

Immediately go to **Settings** and change the admin password.

Then fill in JAN Enterprises legal invoice details, GSTIN, registered address, bank details, invoice prefix, GST default, reminder email, and invoice/warranty terms.

## 8. First production checks

1. Open Dashboard and confirm historical totals/order counts.
2. Open Companies & Agreements and confirm all 8 seeded companies.
3. Open Asset Master and add/verify HSN codes before statutory invoicing.
4. Create one test order.
5. Generate one test delivery challan.
6. Generate one test invoice and confirm GST treatment with your accountant.
7. Download the PDF.
8. Record a partial payment and verify the balance/receipt.
9. Test CSV/XLSX bulk uploads.
10. Confirm SSL is active for `jan.doctorlabs.in`.

## Data already included
The seed data contains your existing historical workbook conversion:

- 8 companies
- one-year agreement dates
- company-specific pricing
- 41 historical order groups
- 79 order line items
- 9 active orders

The system recalculates dashboard totals from the live MySQL database after installation.
