mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 12:12:48 +01:00
Working on the calendar
This commit is contained in:
parent
c472bf92c8
commit
a7dcc30711
@ -30,7 +30,7 @@ class CalendarController extends BaseController
|
||||
$events = dispatch(new GenerateCalendarEvents());
|
||||
//dd($events);
|
||||
\Log::info(print_r(request()->input(), true));
|
||||
\Log::info(print_r($events, true));
|
||||
//\Log::info(print_r($events, true));
|
||||
//echo '[{"title": "Test Event", "start": "2017-09-14T16:00:00", "color": "green"}]';
|
||||
//exit;
|
||||
|
||||
|
@ -17,33 +17,25 @@ class GenerateCalendarEvents extends Job
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$data = [];
|
||||
$events = [];
|
||||
$filter = request()->filter ?: [];
|
||||
|
||||
$invoices = Invoice::scope()
|
||||
->where('is_recurring', '=', false)
|
||||
->get();
|
||||
foreach ($invoices as $invoice) {
|
||||
$data[] = $invoice->present()->calendarEvent;
|
||||
$data = [
|
||||
ENTITY_INVOICE => Invoice::scope()->invoices(),
|
||||
ENTITY_QUOTE => Invoice::scope()->quotes(),
|
||||
ENTITY_TASK => Task::scope(),
|
||||
ENTITY_PAYMENT => Payment::scope(),
|
||||
ENTITY_EXPENSE => Expense::scope(),
|
||||
];
|
||||
|
||||
foreach ($data as $type => $source) {
|
||||
if (! count($filter) || in_array($type, $filter)) {
|
||||
foreach ($source->get() as $entity) {
|
||||
$events[] = $entity->present()->calendarEvent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$tasks = Task::scope()
|
||||
->get();
|
||||
foreach ($tasks as $task) {
|
||||
$data[] = $task->present()->calendarEvent;
|
||||
}
|
||||
|
||||
$payments = Payment::scope()
|
||||
->get();
|
||||
foreach ($payments as $payment) {
|
||||
$data[] = $payment->present()->calendarEvent;
|
||||
}
|
||||
|
||||
$expenses = Expense::scope()
|
||||
->get();
|
||||
foreach ($expenses as $expense) {
|
||||
$data[] = $expense->present()->calendarEvent;
|
||||
}
|
||||
|
||||
return $data;
|
||||
return $events;
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ class ExpensePresenter extends EntityPresenter
|
||||
|
||||
|
||||
$data->start = $expense->expense_date;
|
||||
$data->borderColor = $data->backgroundColor = 'gray';
|
||||
$data->borderColor = $data->backgroundColor = '#F45D01';
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ class InvoicePresenter extends EntityPresenter
|
||||
|
||||
$data->title = trans("texts.{$entityType}") . ' ' . $invoice->invoice_number . ' | ' . $this->amount() . ' | ' . $this->client();
|
||||
$data->start = $invoice->invoice_date;
|
||||
$data->borderColor = $data->backgroundColor = $invoice->isQuote() ? 'orange' : 'blue';
|
||||
$data->borderColor = $data->backgroundColor = $invoice->isQuote() ? '#2D7DD2' : '#474647';
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ class PaymentPresenter extends EntityPresenter
|
||||
|
||||
$data->title = trans('texts.payment') . ' ' . $invoice->invoice_number . ' | ' . $this->amount() . ' | ' . $this->client();
|
||||
$data->start = $payment->payment_date;
|
||||
$data->borderColor = $data->backgroundColor = 'green';
|
||||
$data->borderColor = $data->backgroundColor = '#7FB800';
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ class TaskPresenter extends EntityPresenter
|
||||
$data->title .= ' | ' . $this->description();
|
||||
|
||||
$data->allDay = false;
|
||||
$data->borderColor = $data->backgroundColor = 'purple';
|
||||
$data->borderColor = $data->backgroundColor = '#EEB902';
|
||||
|
||||
$parts = json_decode($task->time_log) ?: [];
|
||||
if (count($parts)) {
|
||||
|
@ -99,7 +99,8 @@ elixir(function(mix) {
|
||||
], 'public/js/daterangepicker.min.js');
|
||||
|
||||
mix.scripts([
|
||||
bowerDir + '/fullcalendar/dist/fullcalendar.js'
|
||||
bowerDir + '/fullcalendar/dist/fullcalendar.js',
|
||||
bowerDir + '/fullcalendar/dist/locale-all.js',
|
||||
], 'public/js/fullcalendar.min.js');
|
||||
|
||||
mix.scripts([
|
||||
|
16
public/js/fullcalendar.min.js
vendored
16
public/js/fullcalendar.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -11,6 +11,18 @@
|
||||
|
||||
@stop
|
||||
|
||||
@section('head_css')
|
||||
@parent
|
||||
|
||||
<style type="text/css">
|
||||
.fc-day,
|
||||
.fc-list-item {
|
||||
background-color: white;
|
||||
}
|
||||
</style>
|
||||
@stop
|
||||
|
||||
|
||||
@section('top-right')
|
||||
<select class="form-control" style="width: 220px" id="entityTypeFilter" multiple="true">
|
||||
@foreach ([ENTITY_INVOICE, ENTITY_QUOTE, ENTITY_PAYMENT, ENTITY_TASK, ENTITY_EXPENSE] as $value)
|
||||
@ -41,34 +53,27 @@
|
||||
}
|
||||
*/
|
||||
}).on('change', function() {
|
||||
/*
|
||||
var filter = $('#statuses').val();
|
||||
if (filter) {
|
||||
filter = filter.join(',');
|
||||
} else {
|
||||
filter = '';
|
||||
}
|
||||
*/
|
||||
$('#calendar').fullCalendar('refetchEvents');
|
||||
}).maximizeSelect2Height();
|
||||
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
locale: '{{ App::getLocale() }}',
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,basicWeek,basicDay,listWeek'
|
||||
},
|
||||
defaultDate: '{{ date('Y-m-d') }}',
|
||||
//navLinks: true,
|
||||
//editable: true,
|
||||
eventLimit: true,
|
||||
events: {
|
||||
url: '{{ url('/calendar_events') }}',
|
||||
type: 'GET',
|
||||
data: {
|
||||
custom_param1: 'something',
|
||||
custom_param2: 'somethingelse'
|
||||
},
|
||||
data: function() {
|
||||
return {
|
||||
filter: $('#entityTypeFilter').val()
|
||||
};
|
||||
},
|
||||
error: function() {
|
||||
alert('there was an error while fetching events!');
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user