# MTIMS — Quick Setup Guide

## Requirements
- PHP 8.3+
- Composer 2.x
- MySQL 8.0+
- Web server (Apache/Nginx) or `php artisan serve`

## Installation Steps

### 1. Clone / extract the project
```bash
cd /var/www   # or your preferred path
# place the mtims folder here
cd mtims
```

### 2. Install PHP dependencies
```bash
composer install --no-interaction --prefer-dist --optimize-autoloader
```

### 3. Configure environment
```bash
cp .env.example .env
php artisan key:generate
```

Edit `.env` and set your database credentials:
```env
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=cras_mtims
DB_USERNAME=your_db_user
DB_PASSWORD=your_db_password
```

### 4. Create the database
```sql
CREATE DATABASE cras_mtims CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
```

### 5. Run migrations and seed
```bash
php artisan migrate --seed
```

### 6. Set storage permissions
```bash
chmod -R 775 storage bootstrap/cache
chown -R www-data:www-data storage bootstrap/cache  # Linux only
```

### 7. Cache configuration (production)
```bash
php artisan config:cache
php artisan route:cache
php artisan view:cache
```

### 8. Run locally
```bash
php artisan serve
```
Open: http://localhost:8000

## Default Login Credentials

| Role             | Email                | Password      |
|------------------|----------------------|---------------|
| Super Admin      | admin@cras.lk        | Admin@1234    |
| Inventory Manager| manager@cras.lk      | Manager@1234  |
| Staff            | staff@cras.lk        | Staff@1234    |

## cPanel Deployment
1. Upload files to `public_html/mtims/` (or subdomain root)
2. Set document root to `public_html/mtims/public/`
3. Set PHP version to 8.3 in cPanel MultiPHP Manager
4. Run migrations via cPanel Terminal or SSH
5. Set file permissions: `storage/` and `bootstrap/cache/` to 755

## Test Data Summary (seeded)
- 4 roles, 3 users
- 14 inventory categories
- 5 suppliers
- 6 training courses
- 8 medical treatments
- 12 inventory items (with opening balances and stock transactions)
  - Includes: 1 out-of-stock item, 1 expiring in 20 days, 1 expiring in 2 months
