# Task Creation Guide

## Overview

The application now supports creating tasks in two ways:

1. **Personal Tasks** - Tasks not associated with any specific matter
2. **Matter-Related Tasks** - Tasks associated with a specific matter

## How to Create Tasks

### Method 1: From the Tasks List Page

1. Navigate to `http://localhost:8000/tasks`
2. Click the **"Create Task"** button (blue button)
3. This will take you to the full task creation form

### Method 2: From a Matter Detail Page

1. Navigate to a specific matter (e.g., `http://localhost:8000/matters/19`)
2. Click the **"Create Task"** button in the tasks section
3. This will create a task specifically for that matter

### Method 3: Quick Task Creation

1. Navigate to `http://localhost:8000/tasks`
2. Click the **"Quick Task"** button (gray button)
3. This opens a modal for quick task creation

## Task Creation Form Features

### Task Type Selection
- **Personal Task**: Creates a task not associated with any matter
- **Matter-Related Task**: Creates a task associated with a specific matter

### Form Fields
- **Title** (required): The task title
- **Description**: Detailed description of the task
- **Category**: Task category (if available for the selected matter)
- **Assigned To**: User assigned to the task
- **Status**: Current status (Pending, In Progress, Completed, etc.)
- **Priority**: Task priority (Low, Medium, High, Urgent)
- **Start Date** (required): When the task starts
- **Due Date**: When the task is due
- **Estimated Hours**: Estimated time to complete
- **Actual Hours**: Actual time spent (for completed tasks)
- **Notes**: Additional notes

### Validation
- Title is required
- Start date is required
- Due date must be after or equal to start date
- Matter selection is required when creating matter-related tasks

## Database Changes

The `tasks` table has been updated to allow `matter_id` to be nullable, enabling personal tasks that are not associated with any specific matter.

## Navigation

- **Back to Tasks**: Returns to the tasks list page
- **Cancel**: Cancels the task creation and returns to the tasks list
- **Create Task**: Saves the task and redirects to the tasks list

## Categories

- For **Personal Tasks**: Shows all active categories
- For **Matter-Related Tasks**: Shows only categories associated with the selected matter

## Notes

- Personal tasks will have `matter_id` set to `null`
- Matter-related tasks will have `matter_id` set to the selected matter
- All tasks are created by the currently authenticated user
- Tasks can be edited later using the edit functionality 