mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on the calendar
This commit is contained in:
parent
9b370a3e8d
commit
5d3bad8331
@ -31,7 +31,8 @@ class GenerateCalendarEvents extends Job
|
|||||||
foreach ($data as $type => $source) {
|
foreach ($data as $type => $source) {
|
||||||
if (! count($filter) || in_array($type, $filter)) {
|
if (! count($filter) || in_array($type, $filter)) {
|
||||||
foreach ($source->get() as $entity) {
|
foreach ($source->get() as $entity) {
|
||||||
$events[] = $entity->present()->calendarEvent;
|
$subColors = count($filter) == 1;
|
||||||
|
$events[] = $entity->present()->calendarEvent($subColors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1304,6 +1304,21 @@ class Utils
|
|||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function brewerColor($number) {
|
||||||
|
$colors = [
|
||||||
|
'#377eb8',
|
||||||
|
'#4daf4a',
|
||||||
|
'#984ea3',
|
||||||
|
'#ff7f00',
|
||||||
|
'#a65628',
|
||||||
|
'#f781bf',
|
||||||
|
'#e41a1c',
|
||||||
|
];
|
||||||
|
$number = ($number-1) % count($colors);
|
||||||
|
|
||||||
|
return $colors[$number];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace language-specific characters by ASCII-equivalents.
|
* Replace language-specific characters by ASCII-equivalents.
|
||||||
* @param string $s
|
* @param string $s
|
||||||
|
@ -69,7 +69,7 @@ class EntityPresenter extends Presenter
|
|||||||
return sprintf('%s: %s', trans('texts.' . $entityType), $entity->getDisplayName());
|
return sprintf('%s: %s', trans('texts.' . $entityType), $entity->getDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calendarEvent()
|
public function calendarEvent($subColors = false)
|
||||||
{
|
{
|
||||||
$entity = $this->entity;
|
$entity = $this->entity;
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ class ExpensePresenter extends EntityPresenter
|
|||||||
return $this->entity->expense_category ? $this->entity->expense_category->name : '';
|
return $this->entity->expense_category ? $this->entity->expense_category->name : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calendarEvent()
|
public function calendarEvent($subColors = false)
|
||||||
{
|
{
|
||||||
$data = parent::calendarEvent();
|
$data = parent::calendarEvent();
|
||||||
$expense = $this->entity;
|
$expense = $this->entity;
|
||||||
@ -66,7 +66,12 @@ class ExpensePresenter extends EntityPresenter
|
|||||||
|
|
||||||
|
|
||||||
$data->start = $expense->expense_date;
|
$data->start = $expense->expense_date;
|
||||||
$data->borderColor = $data->backgroundColor = '#F45D01';
|
|
||||||
|
if ($subColors && $expense->expense_category_id) {
|
||||||
|
$data->borderColor = $data->backgroundColor = Utils::brewerColor($expense->expense_category->public_id);
|
||||||
|
} else {
|
||||||
|
$data->borderColor = $data->backgroundColor = '#e41a1c';
|
||||||
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ class InvoicePresenter extends EntityPresenter
|
|||||||
return $link;
|
return $link;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calendarEvent()
|
public function calendarEvent($subColors = false)
|
||||||
{
|
{
|
||||||
$data = parent::calendarEvent();
|
$data = parent::calendarEvent();
|
||||||
$invoice = $this->entity;
|
$invoice = $this->entity;
|
||||||
@ -332,7 +332,7 @@ class InvoicePresenter extends EntityPresenter
|
|||||||
|
|
||||||
$data->title = trans("texts.{$entityType}") . ' ' . $invoice->invoice_number . ' | ' . $this->amount() . ' | ' . $this->client();
|
$data->title = trans("texts.{$entityType}") . ' ' . $invoice->invoice_number . ' | ' . $this->amount() . ' | ' . $this->client();
|
||||||
$data->start = $invoice->invoice_date;
|
$data->start = $invoice->invoice_date;
|
||||||
$data->borderColor = $data->backgroundColor = $invoice->isQuote() ? '#2D7DD2' : '#474647';
|
$data->borderColor = $data->backgroundColor = $invoice->isQuote() ? '#984ea3' : '#377eb8';
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ class PaymentPresenter extends EntityPresenter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calendarEvent()
|
public function calendarEvent($subColors = false)
|
||||||
{
|
{
|
||||||
$data = parent::calendarEvent();
|
$data = parent::calendarEvent();
|
||||||
$payment = $this->entity;
|
$payment = $this->entity;
|
||||||
@ -54,7 +54,7 @@ class PaymentPresenter extends EntityPresenter
|
|||||||
|
|
||||||
$data->title = trans('texts.payment') . ' ' . $invoice->invoice_number . ' | ' . $this->amount() . ' | ' . $this->client();
|
$data->title = trans('texts.payment') . ' ' . $invoice->invoice_number . ' | ' . $this->amount() . ' | ' . $this->client();
|
||||||
$data->start = $payment->payment_date;
|
$data->start = $payment->payment_date;
|
||||||
$data->borderColor = $data->backgroundColor = '#7FB800';
|
$data->borderColor = $data->backgroundColor = '#4daf4a';
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Ninja\Presenters;
|
namespace App\Ninja\Presenters;
|
||||||
|
|
||||||
|
use Utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class TaskPresenter.
|
* Class TaskPresenter.
|
||||||
*/
|
*/
|
||||||
@ -71,7 +73,7 @@ class TaskPresenter extends EntityPresenter
|
|||||||
return $str . implode("\n", $times);
|
return $str . implode("\n", $times);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calendarEvent()
|
public function calendarEvent($subColors = false)
|
||||||
{
|
{
|
||||||
$data = parent::calendarEvent();
|
$data = parent::calendarEvent();
|
||||||
$task = $this->entity;
|
$task = $this->entity;
|
||||||
@ -82,10 +84,16 @@ class TaskPresenter extends EntityPresenter
|
|||||||
if ($project = $this->project()) {
|
if ($project = $this->project()) {
|
||||||
$data->title .= ' | ' . $project;
|
$data->title .= ' | ' . $project;
|
||||||
}
|
}
|
||||||
$data->title .= ' | ' . $this->description();
|
if ($description = $this->description()) {
|
||||||
|
$data->title .= ' | ' . $description;
|
||||||
|
}
|
||||||
$data->allDay = false;
|
$data->allDay = false;
|
||||||
$data->borderColor = $data->backgroundColor = '#EEB902';
|
|
||||||
|
if ($subColors && $task->project_id) {
|
||||||
|
$data->borderColor = $data->backgroundColor = Utils::brewerColor($task->project->public_id);
|
||||||
|
} else {
|
||||||
|
$data->borderColor = $data->backgroundColor = '#ff7f00';
|
||||||
|
}
|
||||||
|
|
||||||
$parts = json_decode($task->time_log) ?: [];
|
$parts = json_decode($task->time_log) ?: [];
|
||||||
if (count($parts)) {
|
if (count($parts)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user