diff --git a/app/Http/Controllers/CalendarController.php b/app/Http/Controllers/CalendarController.php index 4857e18b..c7f87d39 100644 --- a/app/Http/Controllers/CalendarController.php +++ b/app/Http/Controllers/CalendarController.php @@ -5,6 +5,8 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; use \App\Log; use \App\Schedule; +use \App\Local; +use \App\User; use Carbon\Carbon; @@ -29,7 +31,7 @@ class CalendarController extends Controller { Log::saveLog("Affichage de l'horaire"); - return view('admin.calendar'); + return view('admin.calendar.calendar_display'); } public function generate() @@ -111,68 +113,57 @@ class CalendarController extends Controller public function load() { + $lang = str_replace('_', '-', app()->getLocale()); setlocale(LC_ALL, $lang.'_'.strtoupper($lang).'.utf8','fra'); - $date = request('date'); + $Requestdate = request('date'); - $today = Schedule::where('date','=',$date)->get(); + $url = str_replace("-","_", $Requestdate); + + /** Dont work ... API stuff + * Log::saveLog("a consulté l'horaire du ".$date); + **/ + + $today = Schedule::where('date','=',$Requestdate)->get(); $isEmpty = $today->isEmpty(); - if ($isEmpty) { ?> -
id) { - switch ($date->type) { - case 'pilotage': - $this->loadPilotage($date); - break; + echo ''; } private function loadPilotage($schedule) - { ?> - -'.trans('calendar.pilotage_title').''.trans('calendar.begin_at').$schedule->data['begin_at'].trans('calendar.end_at').$schedule->data['end_at'].'
'; + } + + public function add($date) + { + $lang = str_replace('_', '-', app()->getLocale()); + setlocale(LC_ALL, $lang.'_'.strtoupper($lang).'.utf8','fra'); + + $UserList = User::all(); + $LocalList = Local::all(); + + return view('admin.calendar.calendar_add' ,['RequestDate' => $date, 'Userslist' => $UserList, 'LocalsList' => $LocalList]); + } } diff --git a/app/Local.php b/app/Local.php new file mode 100644 index 00000000..6b6597e4 --- /dev/null +++ b/app/Local.php @@ -0,0 +1,10 @@ +belongsTo(User::class); } - public static function saveLog($action) + public static function saveLog($action, $user = "default") { $log = new Log; + + if ($user == "default") { + $user = \Auth::User()->id; + } $log->action = $action; - $log->user_id = \Auth::User()->id; + $log->user_id = $user; $log->save(); } diff --git a/database/migrations/2018_08_01_231647_create_locals_table.php b/database/migrations/2018_08_01_231647_create_locals_table.php new file mode 100644 index 00000000..3eed8aed --- /dev/null +++ b/database/migrations/2018_08_01_231647_create_locals_table.php @@ -0,0 +1,32 @@ +increments('id'); + $table->string('name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('locals'); + } +} diff --git a/public/assets/js/calendar/calendar.js b/public/assets/js/calendar/calendar.js index 3a381fa3..8fdd0ead 100644 --- a/public/assets/js/calendar/calendar.js +++ b/public/assets/js/calendar/calendar.js @@ -63,4 +63,103 @@ function generate(pmonth,pyear){ console.log('Calendar Initialised'); }); })(jQuery); -} \ No newline at end of file +} + +function switchType() +{ + + (function($) { + var eventInput = document.getElementById("event_type"); + var eventName = document.getElementById('event_name'); + var isEventMandatory = document.getElementById('is_event_mandatory'); + var eventBeginTime = document.getElementById('event_begin_time'); + var eventEndTime = document.getElementById('event_end_time'); + var eventLocation = document.getElementById('event_location'); + var eventDesc = document.getElementById('event_desc'); + + + + switch (eventInput.value) { + case "pilotage": + eventName.value = "Test"; + isEventMandatory.checked = false; + eventBeginTime.value = "09:30"; + eventEndTime.value = "11:30"; + eventLocation.value = "Escadron"; + eventDesc.value = "Cours de pilotage"; + break; + + case "regular": + eventName.value = "Soirée d'instruction régulière"; + isEventMandatory.checked = true; + eventBeginTime.value = "06:30"; + eventEndTime.value = "9:45"; + eventLocation.value = "Escadron"; + eventDesc.value = "Soirée d'instruction régulière"; + break; + + case "drill": + eventName.value = "Cours de précidrill"; + isEventMandatory.checked = false; + eventBeginTime.value = ""; + eventEndTime.value = ""; + eventLocation.value = "Maison de mon père"; + eventDesc.value = "Cours de précidrill"; + break; + + case "music": + eventName.value = "Cours de musique"; + isEventMandatory.checked = false; + eventBeginTime.value = ""; + eventEndTime.value = ""; + eventLocation.value = ""; + eventDesc.value = "Cours de musique"; + break; + + case "biathlon": + eventName.value = "Cour de Biathlon"; + isEventMandatory.checked = false; + eventBeginTime.value = ""; + eventEndTime.value = ""; + eventLocation.value = ""; + eventDesc.value = "Cours de biathlon"; + break; + + case "marksmanship": + eventName.value = "Tir de précision"; + isEventMandatory.checked = false; + eventBeginTime.value = ""; + eventEndTime.value = ""; + eventLocation.value = ""; + eventDesc.value = "Tir de précision"; + break; + + case "founding": + eventName.value = ""; + isEventMandatory.checked = true; + eventBeginTime.value = ""; + eventEndTime.value = ""; + eventLocation.value = ""; + eventDesc.value = ""; + break; + + case "volunteer": + eventName.value = ""; + isEventMandatory.checked = true; + eventBeginTime.value = ""; + eventEndTime.value = ""; + eventLocation.value = ""; + eventDesc.value = ""; + break; + + default: + eventName.value = ""; + isEventMandatory.checked = false; + eventBeginTime.value = ""; + eventEndTime.value = ""; + eventLocation.value = ""; + eventDesc.value = ""; + break; + } + })(jQuery); +} diff --git a/resources/lang/fr/calendar.php b/resources/lang/fr/calendar.php index 653399dc..8892b5f3 100644 --- a/resources/lang/fr/calendar.php +++ b/resources/lang/fr/calendar.php @@ -6,14 +6,72 @@ return [ |-------------------------------------------------------------------------- | Calendar Language Lines |-------------------------------------------------------------------------- - | + |General Translation */ 'nothing_today' => "Il n'y a rien a l'horaire pour cette date", - 'admin_page_title' => "Horaire", - 'admin_breadcrumb' => "Horaire", 'add_to_schedule' => "Ajouter une activité a l'horaire", 'begin_at' => "Commence a ", 'end_at' => " et termine a ", + + /** Admin Display Page */ + 'admin_page_title' => "Horaire", + 'admin_breadcrumb' => "Horaire", + + /** Admin Add Page */ + 'add_title' => "Ajouter a l'horaire", + 'add_breadcrumb' => "Horaire/Ajouter", + /** Event Type */ + 'add_form_event_type' => "Type d'évenement", + 'add_form_event_type_pilotage' => "Activité complémentaire - Pilotage", + 'add_form_event_type_dril' => "Activité complémentaire - Précidrill", + 'add_form_event_type_music' => "Activité complémentaire - Musique", + 'add_form_event_type_biathlon' => "Activité complémentaire - Biathlon", + 'add_form_event_type_marksmanship' => "Activité complémentaire - Tir", + 'add_form_event_type_founding' => "Financement", + 'add_form_event_type_volunteer' => "Bénévolat", + 'add_form_event_type_other' => "Autre", + 'add_form_event_type_instruction' => "Soirée d'instruction régulière", + 'add_form_event_type_select' => "Choisir le type d'évenement", + /** Event Name */ + 'add_form_event_name' => "Nom de l'évenement", + 'add_form_event_name_placeholder' => "Nom", + 'add_form_event_name_help' => "Veuillez indiquer le nom de l'événement.", + + /** Event Date */ + 'add_form_event_date' => "Date de l'evenement", + + /** Event Time */ + 'add_form_event_time_begin' => "Heure de début", + 'add_form_event_time_begin_help' => "Veuillez indiquer l'heure de début.", + 'add_form_event_time_end' => "Heure de fin", + 'add_form_event_time_end_help' => "Veuillez indiquer l'heure de fin.", + + /** Event Location */ + 'add_form_event_place' => "Lieux de l'évenement", + 'add_form_event_place_placeholder' => "Ex: Escadron (540 Rue St Germain E, Rimouski, QC G5L 1E9)", + 'add_form_event_place_help' => "Veuillez indiquer le lieux de l'évenement.", + + /** Event Mandatory */ + 'add_form_event_mandatory' => "Evenement obligatoire", + 'add_form_event_mandatory_help' => "L'evenement est-il obligatoire pour tous les cadets ?", + + /** Event description */ + 'add_form_event_desc' => "Description", + 'add_form_event_desc_placeholder' => "Écriver ici ...", + 'add_form_event_desc_help' => "Veuillez entrer ici une courte description de l'événement ainsi que toutes autres informations utiles", + + /** Regular day event */ + 'reg_p1' => "Première période", + 'reg_p2' => "Deuxième période", + 'reg_classe_name' => "Nom du cours", + 'reg_ocom' => "OCOM", + 'reg_plan_done' => "Plan de cours remis?", + 'reg_instructor_name' => "Instructeur", + 'reg_location' => "Local", + + /** + * Translation for the pilotage activity + */ 'pilotage_title' => "Cours de pilotage", ]; diff --git a/resources/views/admin/calendar/calendar_add.blade.php b/resources/views/admin/calendar/calendar_add.blade.php new file mode 100644 index 00000000..f74fa2ae --- /dev/null +++ b/resources/views/admin/calendar/calendar_add.blade.php @@ -0,0 +1,175 @@ +@extends('layouts.admin.main') + +@section('content') +