mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Add projects to the calendar
This commit is contained in:
parent
4e97ec00c7
commit
0af7c15456
@ -7,6 +7,7 @@ use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use App\Models\Expense;
|
||||
use App\Models\Task;
|
||||
use App\Models\Project;
|
||||
|
||||
class GenerateCalendarEvents extends Job
|
||||
{
|
||||
@ -26,6 +27,7 @@ class GenerateCalendarEvents extends Job
|
||||
ENTITY_TASK => Task::scope()->with(['project']),
|
||||
ENTITY_PAYMENT => Payment::scope()->with(['invoice']),
|
||||
ENTITY_EXPENSE => Expense::scope()->with(['expense_category']),
|
||||
ENTITY_PROJECT => Project::scope(),
|
||||
];
|
||||
|
||||
foreach ($data as $type => $source) {
|
||||
|
@ -33,7 +33,7 @@ class Project extends EntityModel
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $presenter = 'App\Ninja\Presenters\EntityPresenter';
|
||||
protected $presenter = 'App\Ninja\Presenters\ProjectPresenter';
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
@ -51,6 +51,14 @@ class Project extends EntityModel
|
||||
return "/projects/{$this->public_id}/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function account()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Account');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
@ -66,6 +74,13 @@ class Project extends EntityModel
|
||||
{
|
||||
return $this->hasMany('App\Models\Task');
|
||||
}
|
||||
|
||||
public function scopeDateRange($query, $startDate, $endDate)
|
||||
{
|
||||
return $query->where(function ($query) use ($startDate, $endDate) {
|
||||
$query->whereBetween('due_date', [$startDate, $endDate]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Project::creating(function ($project) {
|
||||
|
26
app/Ninja/Presenters/ProjectPresenter.php
Normal file
26
app/Ninja/Presenters/ProjectPresenter.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Presenters;
|
||||
|
||||
use Utils;
|
||||
|
||||
class ProjectPresenter extends EntityPresenter
|
||||
{
|
||||
public function calendarEvent($subColors = false)
|
||||
{
|
||||
$data = parent::calendarEvent();
|
||||
$project = $this->entity;
|
||||
|
||||
$data->title = trans('texts.project') . ': ' . $project->name;
|
||||
$data->start = $project->due_date;
|
||||
|
||||
if ($subColors) {
|
||||
$data->borderColor = $data->backgroundColor = Utils::brewerColor($project->public_id);
|
||||
} else {
|
||||
$data->borderColor = $data->backgroundColor = '#676767';
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
@ -26,7 +26,7 @@
|
||||
@section('top-right')
|
||||
<div id="entityTypeFilterWrapper" style="display:none">
|
||||
<select class="form-control" style="width: 220px;" id="entityTypeFilter" multiple="true">
|
||||
@foreach ([ENTITY_INVOICE, ENTITY_QUOTE, ENTITY_PAYMENT, ENTITY_TASK, ENTITY_EXPENSE] as $value)
|
||||
@foreach ([ENTITY_INVOICE, ENTITY_QUOTE, ENTITY_PAYMENT, ENTITY_TASK, ENTITY_EXPENSE, ENTITY_PROJECT] as $value)
|
||||
<option value="{{ $value }}">{{ trans("texts.{$value}") }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
Loading…
x
Reference in New Issue
Block a user