Skip to content

Commit

Permalink
Implement Task Management System
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Oct 16, 2024
1 parent 4ffc698 commit 3851cac
Show file tree
Hide file tree
Showing 13 changed files with 780 additions and 172 deletions.
109 changes: 37 additions & 72 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,92 +219,57 @@ LINKEDIN_CLIENT_SECRET=your_linkedin_client_secret

For more detailed information on using the advertising account management features, please refer to the user guide in the `docs` folder.

## Usage

### Reporting and Analytics

The CRM now includes enhanced reporting and analytics capabilities. To access these features:

1. Navigate to the Analytics Dashboard:
- Go to `/analytics-dashboard` to view key metrics and trends.

2. Generate Custom Reports:
- Visit `/reports/contact-interactions` for Contact Interactions report
- Visit `/reports/sales-pipeline` for Sales Pipeline report
- Visit `/reports/customer-engagement` for Customer Engagement report

3. Customize Reports:
- Use the Report Customizer component to filter and tailor reports to your needs.

4. Data Visualization:
- The Analytics Dashboard includes interactive charts and graphs for better data interpretation.

5. Export Reports:
- Each report page includes options to export data in various formats (CSV, PDF, Excel).

For more detailed information on using the reporting and analytics features, please refer to the user guide in the `docs` folder.

### Task Reminders and Google Calendar Integration

Liberu CRM now includes a powerful task reminder system with Google Calendar integration:

1. Creating Tasks with Reminders:
- When creating or editing a task, you can set a reminder date and time.
- Choose to sync the task with Google Calendar by toggling the "Sync to Google Calendar" option.

2. Receiving Reminders:
- You'll receive email notifications for task reminders at the specified time.
- Reminders are also visible in the CRM's notification center.

3. Google Calendar Sync:
- To enable Google Calendar sync, go to your user settings and connect your Google account.
- Tasks synced with Google Calendar will appear in your Google Calendar and update automatically when changed in the CRM.
# CRM Laravel

4. Managing Reminders:
- View all upcoming reminders in the "My Reminders" section of the dashboard.
- Mark reminders as complete or snooze them for later.
## Task Management System

For more information on using the task reminder system and Google Calendar integration, please refer to the user guide in the `docs` folder.
The CRM now includes a robust task management system that allows users to create, assign, and track tasks related to contacts and leads. Key features include:

# CRM Laravel
- Create tasks associated with contacts or leads
- Assign tasks to users
- Set due dates and reminders for tasks
- Mark tasks as complete or incomplete
- Filter and search tasks
- Receive notifications for task reminders

## OAuth Configuration
### Using the Task Management System

This application now supports configuring OAuth settings for social media accounts, advertising accounts, Mailchimp, WhatsApp Business, and Facebook Messenger directly through the browser interface.
1. To create a new task, navigate to the Tasks page and click on "Create New Task".
2. Fill in the task details, including name, description, due date, and optional reminder date.
3. Associate the task with a contact or lead if applicable.
4. Assign the task to a user.
5. Tasks can be edited, marked as complete/incomplete, or deleted from the task list.
6. Use the search and filter options to find specific tasks.

### Setting up OAuth Configurations
### Task Reminders

1. Log in to the admin panel.
2. Navigate to the OAuth Configurations section.
3. Click on "New OAuth Configuration" to add a new provider.
4. Fill in the required information:
- Service Name (e.g., facebook, google, mailchimp)
- Client ID
- Client Secret
- Additional Settings (if required)
5. Save the configuration.
Task reminders are sent automatically based on the reminder date set for each task. Reminders are sent to:
- The assigned user
- The associated contact or lead (if applicable)

### Using OAuth in the Application
Ensure that your email settings are configured correctly to receive these notifications.

Once configured, the application will automatically use the database-stored OAuth settings for authentication and API interactions with the respective services.
## Development

### Fallback to Environment Variables
To set up the project for development:

If a configuration is not found in the database, the application will fall back to using the settings defined in the .env file.
1. Clone the repository
2. Install dependencies: `composer install`
3. Set up your `.env` file
4. Run migrations: `php artisan migrate`
5. Seed the database (if applicable): `php artisan db:seed`
6. Start the development server: `php artisan serve`

### Supported Services
### Running Tests

- Facebook
- Google
- Mailchimp
- WhatsApp Business
- Facebook Messenger
- (Add other supported services here)
To run the test suite:

For more detailed information on setting up each service, please refer to their respective documentation.
```
php artisan test
```

## Contributors
This will run all feature and unit tests, including the new tests for the task management system.

## Contributing

<a href = "https://github.com/liberu-crm/crm-laravel/graphs/contributors">
<img src = "https://contrib.rocks/image?repo=liberu-crm/crm-laravel"/>
Please refer to our contributing guidelines for information on how to propose changes and improvements to the CRM.
115 changes: 115 additions & 0 deletions app/Http/Controllers/TaskController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?php

namespace App\Http\Controllers;

use App\Models\Task;
use App\Models\Contact;
use App\Models\Lead;
use App\Models\User;
use App\Services\ReminderService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class TaskController extends Controller
{
protected $reminderService;

public function __construct(ReminderService $reminderService)
{
$this->reminderService = $reminderService;
}

public function index()
{
$tasks = Task::where('assigned_to', Auth::id())->orderBy('due_date')->get();
return view('tasks.index', compact('tasks'));
}

public function create()
{
$contacts = Contact::all();
$leads = Lead::all();
$users = User::all();
return view('tasks.create', compact('contacts', 'leads', 'users'));
}

public function store(Request $request)
{
$validatedData = $request->validate([
'name' => 'required|string|max:255',
'description' => 'nullable|string',
'due_date' => 'required|date',
'contact_id' => 'nullable|exists:contacts,id',
'lead_id' => 'nullable|exists:leads,id',
'assigned_to' => 'required|exists:users,id',
'reminder_date' => 'nullable|date|before_or_equal:due_date',
]);

$task = Task::create($validatedData);

if ($request->has('reminder_date')) {
$this->reminderService->scheduleReminder($task, $request->reminder_date);
}

return redirect()->route('tasks.index')->with('success', 'Task created successfully.');
}

public function edit(Task $task)
{
$contacts = Contact::all();
$leads = Lead::all();
$users = User::all();
return view('tasks.edit', compact('task', 'contacts', 'leads', 'users'));
}

public function update(Request $request, Task $task)
{
$validatedData = $request->validate([
'name' => 'required|string|max:255',
'description' => 'nullable|string',
'due_date' => 'required|date',
'contact_id' => 'nullable|exists:contacts,id',
'lead_id' => 'nullable|exists:leads,id',
'assigned_to' => 'required|exists:users,id',
'reminder_date' => 'nullable|date|before_or_equal:due_date',
]);

$task->update($validatedData);

if ($request->has('reminder_date')) {
$this->reminderService->scheduleReminder($task, $request->reminder_date);
}

return redirect()->route('tasks.index')->with('success', 'Task updated successfully.');
}

public function destroy(Task $task)
{
$task->delete();
return redirect()->route('tasks.index')->with('success', 'Task deleted successfully.');
}

public function complete(Task $task)
{
$task->markAsComplete();
return redirect()->back()->with('success', 'Task marked as complete.');
}

public function incomplete(Task $task)
{
$task->markAsIncomplete();
return redirect()->back()->with('success', 'Task marked as incomplete.');
}

public function assign(Request $request, Task $task)
{
$validatedData = $request->validate([
'user_id' => 'required|exists:users,id',
]);

$user = User::findOrFail($validatedData['user_id']);
$task->assign($user);

return redirect()->back()->with('success', 'Task assigned successfully.');
}
}
81 changes: 81 additions & 0 deletions app/Http/Livewire/TaskForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

namespace App\Http\Livewire;

use App\Models\Task;
use App\Models\Contact;
use App\Models\Lead;
use App\Models\User;
use Livewire\Component;

class TaskForm extends Component
{
public $task;
public $taskId;
public $name;
public $description;
public $due_date;
public $contact_id;
public $lead_id;
public $assigned_to;
public $reminder_date;

protected $rules = [
'name' => 'required|string|max:255',
'description' => 'nullable|string',
'due_date' => 'required|date',
'contact_id' => 'nullable|exists:contacts,id',
'lead_id' => 'nullable|exists:leads,id',
'assigned_to' => 'required|exists:users,id',
'reminder_date' => 'nullable|date|before_or_equal:due_date',
];

public function mount($taskId = null)
{
if ($taskId) {
$this->task = Task::findOrFail($taskId);
$this->taskId = $this->task->id;
$this->name = $this->task->name;
$this->description = $this->task->description;
$this->due_date = $this->task->due_date->format('Y-m-d\TH:i');
$this->contact_id = $this->task->contact_id;
$this->lead_id = $this->task->lead_id;
$this->assigned_to = $this->task->assigned_to;
$this->reminder_date = $this->task->reminder_date ? $this->task->reminder_date->format('Y-m-d\TH:i') : null;
}
}

public function save()
{
$this->validate();

$taskData = [
'name' => $this->name,
'description' => $this->description,
'due_date' => $this->due_date,
'contact_id' => $this->contact_id,
'lead_id' => $this->lead_id,
'assigned_to' => $this->assigned_to,
'reminder_date' => $this->reminder_date,
];

if ($this->taskId) {
$this->task->update($taskData);
session()->flash('message', 'Task updated successfully.');
} else {
Task::create($taskData);
session()->flash('message', 'Task created successfully.');
}

return redirect()->route('tasks.index');
}

public function render()
{
return view('livewire.task-form', [
'contacts' => Contact::all(),
'leads' => Lead::all(),
'users' => User::all(),
]);
}
}
52 changes: 52 additions & 0 deletions app/Http/Livewire/TaskList.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace App\Http\Livewire;

use App\Models\Task;
use Livewire\Component;
use Livewire\WithPagination;

class TaskList extends Component
{
use WithPagination;

public $search = '';
public $status = '';
public $sortField = 'due_date';
public $sortDirection = 'asc';

protected $queryString = ['search', 'status', 'sortField', 'sortDirection'];

public function updatingSearch()
{
$this->resetPage();
}

public function sortBy($field)
{
if ($this->sortField === $field) {
$this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc';
} else {
$this->sortDirection = 'asc';
}

$this->sortField = $field;
}

public function render()
{
$tasks = Task::query()
->when($this->search, function ($query) {
$query->where('name', 'like', '%' . $this->search . '%');
})
->when($this->status, function ($query) {
$query->where('status', $this->status);
})
->orderBy($this->sortField, $this->sortDirection)
->paginate(10);

return view('livewire.task-list', [
'tasks' => $tasks,
]);
}
}
Loading

0 comments on commit 3851cac

Please sign in to comment.