# FINEART Plugin v3.1 - Dashboard Navigation Update

## What's New

### Dashboard Navigation System
- **Clean modular structure** - All dashboard navigation code moved from functions.php to plugin
- **Role-based navigation** - Different menus for pending vs validated artists
- **Artist utilities** - Helper functions for profile completion, validation, etc.

## Installation Steps

### 1. Backup First
```bash
# Backup your current plugin
cp -r /wp-content/plugins/fineart-plugin /wp-content/plugins/fineart-plugin-backup
```

### 2. Upload New Files
Upload these new files to your plugin:
```
fineart-plugin/
├── includes/
│   ├── vendor-dashboard/
│   │   ├── class-fineart-dashboard-nav.php     (NEW)
│   │   └── class-fineart-artist-utils.php      (NEW)
│   └── class-fineart-loader.php                (UPDATED)
```

### 3. Remove Old Code from functions.php
**IMPORTANT:** Remove this entire block from your theme's functions.php:

```php
// DELETE THIS ENTIRE SECTION:
add_filter('wcmp_vendor_dashboard_nav', 'callback_wcmp_vendor_dashboard_nav', 99);
function callback_wcmp_vendor_dashboard_nav($vendor_nav){
    // ... all the old navigation code ...
}

add_action('mvx_init', 'after_mvx_init');
function after_mvx_init() {
    // ... all the old MVX code ...
}

// And all related functions
```

### 4. Verify Plugin Structure
Make sure these directories exist:
```bash
mkdir -p /wp-content/plugins/fineart-plugin/includes/vendor-dashboard
```

### 5. Clear Caches
- Clear any WordPress caching plugins
- Clear browser cache
- If using Redis/Memcached, flush those too

## New Features

### Artist Profile Completion Tracking
The plugin now tracks:
- Legal information completion
- Artist signature upload
- Minimum 5 artworks for pending artists
- Ready-for-validation status

### Role-Based Navigation

**Pending Artists (dc_pending_vendor):**
- Artist Profile menu (Legal Info, Profile, Signature)
- First Artwork Submission menu
- Disabled: Gallery link, Orders, Payments, Share Gallery

**Validated Artists (dc_vendor):**
- Full navigation access
- Artwork Manager (My artworks, Submit, File Reviewal)
- Orders tracking
- Payments & commissions
- Share gallery tools

## Testing Checklist

### As Pending Artist
- [ ] Can access Legal Informations page
- [ ] Can access Artist Signature page
- [ ] Can submit artworks
- [ ] "Go to My Gallery" is disabled/grayed
- [ ] Orders/Payments sections are grayed out
- [ ] Can see submission progress (X/5 artworks)

### As Validated Artist
- [ ] Full navigation visible
- [ ] Can access all Artwork Manager submenu items
- [ ] Can view Orders
- [ ] Can access Payments menu
- [ ] Can access Share Gallery > Embed
- [ ] "Go to My Gallery" works

### General
- [ ] No PHP errors in dashboard
- [ ] Navigation icons display correctly
- [ ] Submenus expand/collapse properly
- [ ] All links work correctly
- [ ] Log out works

## Helper Functions Available

### Check Artist Status
```php
// Check if pending
if (FineArt_Artist_Utils::is_pending_artist()) {
    // Show pending artist content
}

// Check if validated
if (FineArt_Artist_Utils::is_validated_artist()) {
    // Show validated artist content
}
```

### Get Profile Completion
```php
$completion = FineArt_Artist_Utils::get_profile_completion();
// Returns:
// [
//     'legal_complete' => bool,
//     'signature_complete' => bool,
//     'artwork_count' => int,
//     'ready_for_validation' => bool,
//     'missing_items' => array
// ]
```

### Save Legal Information
```php
$data = [
    'company_name' => 'Artist Studio Inc.',
    'company_street' => '123 Art Street',
    'company_city' => 'Paris',
    'company_postal_code' => '75001',
    'company_country' => 'France',
    'vat_number' => 'FR123456789'
];
FineArt_Artist_Utils::save_legal_info($user_id, $data);
```

### Artist Validation Workflow
```php
// Submit for validation
FineArt_Artist_Utils::submit_for_validation($user_id);

// Approve artist (admin only)
FineArt_Artist_Utils::approve_artist($user_id);

// Reject artist (admin only)
FineArt_Artist_Utils::reject_artist($user_id, 'Reason for rejection');
```

## Database Structure

### User Meta Keys
```
fineart_legal_info_complete          // 'yes' or empty
fineart_signature_file_id            // Google Drive file ID
fineart_company_name                 // Company name
fineart_company_street               // Street address
fineart_company_city                 // City
fineart_company_postal_code          // Postal code
fineart_company_country              // Country
fineart_vat_number                   // VAT number (optional)
fineart_validation_status            // pending_review, approved, rejected
fineart_validation_submitted_date    // Submission datetime
fineart_validation_approved_date     // Approval datetime
fineart_validation_rejected_date     // Rejection datetime
fineart_rejection_reason             // Rejection reason text
```

## Next Steps

After this navigation update is working:
1. Build the Legal Informations page
2. Build the Artist Signature page
3. Build the new artwork uploader with Cloudinary integration
4. Add conditional dashboard content (alert banners, stat boxes)

## Troubleshooting

### Navigation not showing
1. Check if plugin is active: `/wp-admin/plugins.php`
2. Verify file permissions (644 for files, 755 for directories)
3. Check PHP error logs

### Old navigation still appears
1. Make sure old code removed from functions.php
2. Clear all caches
3. Try logging out and back in

### Missing submenus
1. Verify user has correct role (dc_pending_vendor or dc_vendor)
2. Check if MVX is active and updated
3. Review PHP error logs

## Support

If you encounter issues:
1. Check PHP error log: `/wp-content/debug.log`
2. Enable WP_DEBUG in wp-config.php temporarily
3. Test with all other plugins disabled
4. Check browser console for JavaScript errors

## Version History

### v3.1 (Current)
- Added modular dashboard navigation system
- Added artist utilities helper class
- Separated pending/validated artist navigation
- Moved all dashboard code to plugin
- Added profile completion tracking

### v3.0 (Previous)
- Certificates system
- Announcements
- Basic vendor dashboard customizations
