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