# ✅ Upload Modal Added to Pages

## Pages Updated

I've added the universal upload modal to these 3 key pages:

### 1. ✅ Customer/Company Details Page
**File:** `views/companies/show.php`  
**Location:** Files tab  
**Button:** Green "Upload Files" button  

**What you'll see:**
- Go to any customer/company detail page
- Click "Files" tab
- See "Upload Files" button at top right
- Click → Modal opens → Upload documents & images
- Files appear in the file widget below

**URL Example:** `http://your-domain/companies/123`

---

### 2. ✅ Opportunity Details Page
**File:** `views/crm/opportunities_show.php`  
**Location:** Documents & Files section (right sidebar)  
**Button:** Small green "Upload" button  

**What you'll see:**
- Go to any opportunity detail page
- Scroll to "Documents & Files" card in right sidebar
- See small "Upload" button next to title
- Click → Modal opens → Upload documents & images
- Page refreshes showing new files

**URL Example:** `http://your-domain/crm/opportunities/456`

---

### 3. ✅ Support Ticket Page
**File:** `views/crm/support/show.php`  
**Location:** Attachments section  
**Button:** Blue "Attach Files" button  

**What you'll see:**
- Go to any support ticket detail page
- See "Attachments" section
- See "Attach Files" button at top right
- Click → Modal opens → Upload documents, images, archives (up to 20MB)
- Page refreshes showing new attachments

**URL Example:** `http://your-domain/crm/support/789`

---

## What Happens When You Upload

1. **Click button** → Modal opens
2. **Select files** → Can choose multiple
3. **Add description** (optional)
4. **Add tags** (optional)
5. **Click Upload** → Progress bar shows
6. **Success!** → Files uploaded
7. **Page refreshes** → New files visible
8. **Database updated** → All tracked in `file_uploads` table

---

## Test It Now!

### Customer Page
```
1. Go to any customer (e.g., http://your-domain/companies/1)
2. Click "Files" tab
3. Click "Upload Files" button (green)
4. Select a PDF or image
5. Click Upload
6. Watch it appear in the file list!
```

### Opportunity Page
```
1. Go to any opportunity (e.g., http://your-domain/crm/opportunities/1)
2. Scroll to "Documents & Files" (right side)
3. Click "Upload" button
4. Upload some files
5. See them in the widget below
```

### Support Ticket
```
1. Go to any ticket (e.g., http://your-domain/crm/support/1)
2. See "Attachments" section
3. Click "Attach Files"
4. Upload documents/images/zip files
5. See them listed below
```

---

## Configuration Per Page

### Customer Page
```php
Context: 'crm'
Entity: 'customer'
Types: document, image
Max Size: 10MB (default)
Multiple: Yes
```

### Opportunity Page
```php
Context: 'opportunities'
Entity: 'opportunity'
Types: document, image
Max Size: 10MB (default)
Multiple: Yes
```

### Support Ticket
```php
Context: 'support'
Entity: 'ticket'
Types: document, image, archive
Max Size: 20MB
Multiple: Yes
```

---

## Where Files Are Stored

| Page | Directory | Database Table |
|------|-----------|----------------|
| Customer | `uploads/crm/` | `file_uploads` (context='crm') |
| Opportunity | `uploads/opportunities/` | `file_uploads` (context='opportunities') |
| Support | `uploads/support/` | `file_uploads` (context='support') |

---

## Check Database

```sql
-- Customer files
SELECT * FROM file_uploads 
WHERE context = 'crm' AND entity_type = 'customer' AND entity_id = 123;

-- Opportunity files
SELECT * FROM file_uploads 
WHERE context = 'opportunities' AND entity_type = 'opportunity' AND entity_id = 456;

-- Support ticket files
SELECT * FROM file_uploads 
WHERE context = 'support' AND entity_type = 'ticket' AND entity_id = 789;
```

---

## Add to More Pages

Want the upload button on other pages? Just add these 2 lines:

```php
<?php include BASE_PATH . '/views/components/upload_modal.php'; ?>
<?php renderUploadModal('context', 'entity_type', $entityId, [
    'buttonText' => 'Upload',
    'allowedTypes' => ['document', 'image']
]); ?>
```

Examples of other pages you might want:
- Expense forms → Upload receipts
- HR applications → Upload resumes
- Product pages → Upload images
- Invoice pages → Upload attachments
- Project pages → Upload documents

---

## Summary

✅ **3 pages updated**  
✅ **Upload buttons visible**  
✅ **Modals working**  
✅ **Files tracked in database**  
✅ **Ready to use!**  

**Go test it now on any of those 3 pages!** 🎉
