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
4cd76b5a04
commit
ff034b08c0
@ -125,17 +125,19 @@ class CreateTestData extends Command
|
||||
$this->info('Client: ' . $client->name);
|
||||
|
||||
$this->createInvoices($client);
|
||||
$this->createInvoices($client, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $client
|
||||
*/
|
||||
private function createInvoices($client)
|
||||
private function createInvoices($client, $isQuote = false)
|
||||
{
|
||||
for ($i = 0; $i < $this->count; $i++) {
|
||||
$data = [
|
||||
'is_public' => true,
|
||||
'is_quote' => $isQuote,
|
||||
'client_id' => $client->id,
|
||||
'invoice_date_sql' => date_create()->modify(rand(-100, 100) . ' days')->format('Y-m-d'),
|
||||
'due_date_sql' => date_create()->modify(rand(-100, 100) . ' days')->format('Y-m-d'),
|
||||
@ -206,7 +208,7 @@ class CreateTestData extends Command
|
||||
$data = [
|
||||
'vendor_id' => $vendor->id,
|
||||
'amount' => $this->faker->randomFloat(2, 1, 10),
|
||||
'expense_date' => null,
|
||||
'expense_date' => date_create()->modify(rand(-100, 100) . ' days')->format('Y-m-d'),
|
||||
'public_notes' => '',
|
||||
];
|
||||
|
||||
|
@ -14,12 +14,8 @@ class CalendarController extends BaseController
|
||||
*/
|
||||
public function showCalendar()
|
||||
{
|
||||
if (! auth()->user()->hasPermission('view_all')) {
|
||||
return redirect('/');
|
||||
}
|
||||
|
||||
$data = [
|
||||
//'showBreadcrumbs' => false,
|
||||
'account' => auth()->user()->account,
|
||||
];
|
||||
|
||||
return view('calendar', $data);
|
||||
@ -27,12 +23,11 @@ class CalendarController extends BaseController
|
||||
|
||||
public function loadEvents()
|
||||
{
|
||||
$events = dispatch(new GenerateCalendarEvents());
|
||||
//dd($events);
|
||||
\Log::info(print_r(request()->input(), true));
|
||||
//\Log::info(print_r($events, true));
|
||||
//echo '[{"title": "Test Event", "start": "2017-09-14T16:00:00", "color": "green"}]';
|
||||
//exit;
|
||||
if (auth()->user()->account->hasFeature(FEATURE_REPORTS)) {
|
||||
$events = dispatch(new GenerateCalendarEvents());
|
||||
} else {
|
||||
$events = [];
|
||||
}
|
||||
|
||||
return response()->json($events);
|
||||
}
|
||||
|
@ -23,14 +23,18 @@ class GenerateCalendarEvents extends Job
|
||||
$data = [
|
||||
ENTITY_INVOICE => Invoice::scope()->invoices(),
|
||||
ENTITY_QUOTE => Invoice::scope()->quotes(),
|
||||
ENTITY_TASK => Task::scope(),
|
||||
ENTITY_PAYMENT => Payment::scope(),
|
||||
ENTITY_EXPENSE => Expense::scope(),
|
||||
ENTITY_TASK => Task::scope()->with(['project']),
|
||||
ENTITY_PAYMENT => Payment::scope()->with(['invoice']),
|
||||
ENTITY_EXPENSE => Expense::scope()->with(['expense_category']),
|
||||
];
|
||||
|
||||
foreach ($data as $type => $source) {
|
||||
if (! count($filter) || in_array($type, $filter)) {
|
||||
foreach ($source->get() as $entity) {
|
||||
foreach ($source->with(['account', 'client.contacts'])->get() as $entity) {
|
||||
if ($entity->client && $entity->client->trashed()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$subColors = count($filter) == 1;
|
||||
$events[] = $entity->present()->calendarEvent($subColors);
|
||||
}
|
||||
|
@ -2446,6 +2446,7 @@ $LANG = array(
|
||||
'stripe_alipay_help' => 'These gateways also need to be activated in :link.',
|
||||
'gocardless_webhook_help_link_text' => 'add this URL as an endpoint in GoCardless',
|
||||
'calendar' => 'Calendar',
|
||||
'pro_plan_calendar' => ':link to enable the calendar by joining the Pro Plan',
|
||||
|
||||
);
|
||||
|
||||
|
@ -33,6 +33,14 @@
|
||||
|
||||
@section('content')
|
||||
|
||||
@if (!Utils::isPro())
|
||||
<div class="alert alert-warning" style="font-size:larger">
|
||||
<center>
|
||||
{!! trans('texts.pro_plan_calendar', ['link'=>'<a href="javascript:showUpgradeModal()">' . trans('texts.pro_plan_remove_logo_link') . '</a>']) !!}
|
||||
</center>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div id='calendar'></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
@ -57,7 +65,7 @@
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
locale: '{{ App::getLocale() }}',
|
||||
//timezone: 'America/Chicago',
|
||||
firstDay: {{ $account->start_of_week ?: '0' }},
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
@ -74,10 +82,8 @@
|
||||
};
|
||||
},
|
||||
error: function() {
|
||||
alert('there was an error while fetching events!');
|
||||
alert("{{ trans('texts.error_refresh_page') }}");
|
||||
},
|
||||
color: 'red', // a non-ajax option
|
||||
textColor: 'white' // a non-ajax option
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user