# Standalone Conflict Review System

## Overview

The standalone conflict review system allows users to create conflict reviews independently of proposals. This is useful when you need to check for potential conflicts before creating a formal proposal.

## Features

### Creating Standalone Conflicts

1. **Access**: Navigate to the CRM Dashboard
2. **Button**: Click the "New Conflict Review" button (red button with warning icon)
3. **Form Fields**:
   - **Title**: Title of the potential proposal
   - **Description**: Detailed description of the proposal
   - **Client**: Select from the list of existing clients
   - **UBO's**: Ultimate Beneficial Owners information
   - **Requested By**: User requesting the conflict analysis

### Conflict Review Process

1. **Automatic Assignment**: When a conflict is created, it's automatically sent to all users with the "lawyer" role
2. **Notifications**: All lawyers receive email and in-app notifications
3. **Review**: Lawyers can review and mark conflicts as:
   - **Pending**: Still under review
   - **No Conflict**: No conflicts found
   - **Conflict Exists**: Conflicts detected

### Converting to Proposal

- **Eligibility**: Standalone conflicts can be converted to proposals only when:
  - Status is "No Conflict"
  - Has a valid client
  - Has a valid title
- **Process**: Click "Convert to Proposal" button on the conflict
- **Result**: Creates a new proposal in "draft" status

## User Permissions

### Creating Conflicts
- All authenticated users can create conflict reviews
- No special permissions required

### Reviewing Conflicts
- Only users with "lawyer" role can review conflicts
- Lawyers receive automatic notifications for new conflicts

### Converting to Proposals
- Users who requested the conflict
- Administrators
- Super administrators

## Database Schema

The `conflict_reviews` table has been updated with new fields:

```sql
-- New fields for standalone conflicts
title VARCHAR(255) NULL
description TEXT NULL
client_id BIGINT UNSIGNED NULL
ubos TEXT NULL
requested_by BIGINT UNSIGNED NULL

-- Modified fields
proposal_id BIGINT UNSIGNED NULL -- Now nullable
```

## Technical Implementation

### Components
- `CreateConflict`: Livewire component for creating conflicts
- `CrmDashboard`: Updated to include conflict creation button
- `ConflictReview`: Enhanced model with new methods

### Notifications
- `ConflictReviewNotification`: Email and in-app notifications
- Sent to all active lawyers when conflicts are created

### CSS Styling
- External CSS file: `resources/css/conflicts.css`
- Follows user preference for external styling
- Uses Tailwind CSS classes

## Workflow

1. **User creates conflict** → Form validation → Database storage
2. **System identifies lawyers** → Creates review records for each lawyer
3. **Notifications sent** → All lawyers receive conflict review requests
4. **Lawyers review** → Mark conflicts as resolved or existing
5. **Optional conversion** → Convert no-conflict reviews to proposals

## Benefits

- **Early Conflict Detection**: Identify conflicts before proposal creation
- **Efficient Workflow**: Streamlined conflict review process
- **Audit Trail**: Complete history of conflict reviews
- **Flexibility**: Can be used independently of proposals
- **Integration**: Seamlessly converts to proposals when appropriate

## Troubleshooting

### Common Issues

1. **No lawyers found**: Ensure users have "lawyer" role assigned
2. **Conversion fails**: Check that conflict meets all conversion criteria
3. **Notifications not sent**: Verify email configuration and notification settings

### Debugging

- Check Laravel logs for error messages
- Verify user roles and permissions
- Ensure database migration has been run
- Check Livewire component registration

## Future Enhancements

- Bulk conflict creation
- Advanced conflict detection algorithms
- Integration with external conflict checking services
- Automated conflict resolution workflows
- Conflict review templates
