Add Calendar in Admin

This commit is contained in:
Mathieu Lagace
2019-08-17 18:02:09 -04:00
parent d4b3b1b47d
commit a63eafb833
19 changed files with 649 additions and 219 deletions

View File

@@ -13,6 +13,11 @@ class Booking extends Model
public function user()
{
return $this->belongsTo('App\User');
return $this->belongsTo('App\User');
}
public function item()
{
return $this->belongsTo('App\Item');
}
}

View File

@@ -72,9 +72,9 @@ class ConfigController extends Controller
$config = Config::all()->where('name',request('perm'))->first();
if (request('value') == "true") {
$config->state = 1;
$config->data = ["true"];
} else {
$config->state = 0;
$config->data = ["false"];
}
$config->save();

View File

@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use \App\Schedule;
use function GuzzleHttp\json_encode;
use PDF;
class ScheduleController extends Controller
{
@@ -76,7 +77,7 @@ class ScheduleController extends Controller
if($event->date_begin >= $start && $event->date_begin <= $end) {
array_push($events,$event);
}
if($event->date_end >= $start && $event->date_end <= $end) {
else if($event->date_end >= $start && $event->date_end <= $end) {
array_push($events,$event);
}
}
@@ -91,6 +92,7 @@ class ScheduleController extends Controller
'start' => $schedule->date.'T'.$schedule->data['event_begin_time'],
'end' => $schedule->date.'T'.$schedule->data['event_end_time'],
'color' => $color,
'source' => 'schedule',
'id' => $schedule->id
];
array_push($jsonevents,$event);
@@ -105,6 +107,8 @@ class ScheduleController extends Controller
'start' => $event->date_begin,
'end' => $event->date_end,
'color' => $color,
'extraParams' => [
'db_type' => 'event'],
'id' => $event->id
];
array_push($jsonevents,$myevent);
@@ -113,14 +117,30 @@ class ScheduleController extends Controller
return json_encode($jsonevents);
}
public function loadModal($id)
public function loadModal($id,$db_type)
{
return view('public.modal.schedule',['event' => \App\Schedule::find($id)]);
if($db_type == "event")
{
$event = \App\Event::find($id);
}
else
{
$event = \App\Schedule::find($id);
}
return view('public.modal.schedule',['event' => $event]);
}
public function loadModalFull($id)
public function loadModalFull($id,$db_type)
{
return view('admin.schedule.modal.show',['event' => \App\Schedule::find($id)]);
if($db_type == "event")
{
$event = \App\Event::find($id);
}
else
{
$event = \App\Schedule::find($id);
}
return view('admin.schedule.modal.show',['event' => $event]);
}
public function getColor($type)
@@ -172,4 +192,11 @@ class ScheduleController extends Controller
};
return $color;
}
public function printtopdf($id)
{
$event = \App\Event::find($id);
$pdf = PDF::loadView('admin.schedule.modal.show',['event' => $event]);
return $pdf->download($event->date_begin.'.pdf');
}
}