From 87264660bcc589da04d5dfed077c47a782ab5810 Mon Sep 17 00:00:00 2001 From: TheGamecraft Date: Wed, 10 Oct 2018 17:52:21 -0400 Subject: [PATCH] ALPHA 3.0.5e --- app/Http/Controllers/CalendarController.php | 164 ++++++++++++++++++ app/Http/Controllers/UserController.php | 24 +++ public/assets/js/calendar/calendar.js | 6 +- resources/views/admin/dashboard.blade.php | 2 +- resources/views/admin/user/profil.blade.php | 126 ++++++++++++++ .../views/admin/user/profil/avatar.blade.php | 57 ++++++ .../vendor/notifications/email.blade.php | 2 +- routes/web.php | 8 +- 8 files changed, 383 insertions(+), 6 deletions(-) create mode 100644 resources/views/admin/user/profil.blade.php create mode 100644 resources/views/admin/user/profil/avatar.blade.php diff --git a/app/Http/Controllers/CalendarController.php b/app/Http/Controllers/CalendarController.php index 957259ff..8c2d5b4d 100644 --- a/app/Http/Controllers/CalendarController.php +++ b/app/Http/Controllers/CalendarController.php @@ -458,6 +458,7 @@ class CalendarController extends Controller public function patch($id) { $schedule = Schedule::find($id); + $original = clone($schedule); $schedule->date = request('event_date'); $schedule->type = request('event_type'); @@ -519,6 +520,169 @@ class CalendarController extends Controller $schedule->save(); + /** Notification */ + $asChange = false; + $userToNotify = $schedule->getUserToNotify(); + $changes = []; + $found = false; + + if ($schedule->type == "regular") { + for ($p=1; $p < 3; $p++) { + for ($n=1; $n < 4; $n++) { + $pUser = \App\User::find($schedule->data['n'.$n.'_p'.$p.'_instructor']); + foreach ($userToNotify as $user) { + if ($user->id == $pUser->id) { + $found = true; + } + } + if (!$found) { + $userToNotify->push($pUser); + } + } + } + } + + if ($schedule->data['event_begin_time'] != $original->data['event_begin_time']) { + array_push($changes,"L'heure de début a été modifié de ".$original->data['event_begin_time']." à ".$schedule->data['event_begin_time']); + } + if ($schedule->data['event_end_time'] != $original->data['event_end_time']) { + array_push($changes,"L'heure de fin a été modifié de ".$original->data['event_end_time']." à ".$schedule->data['event_end_time']); + } + if ($schedule->type != $original->type) { + array_push($changes,"Le type d'évenement a été modifié de ".$original->type." à ".$schedule->type); + } + if ($schedule->data['event_name'] != $original->data['event_name']) { + array_push($changes,"Le nom de l'évenement a été modifié de ".$original->data['event_name']." à ".$schedule->data['event_name']); + } + if ($schedule->data['is_event_mandatory'] != $original->data['is_event_mandatory']) { + if ($schedule->data['is_event_mandatory'] == "on") { + array_push($changes,"L'évenement est maintenant obligatoire"); + } else { + array_push($changes,"L'évenement n'est plus obligatoire"); + } + } + if ($schedule->data['event_location'] != $original->data['event_location']) { + array_push($changes,"Le lieu de l'évenement a été modifié de ".$original->data['event_location']." à ".$schedule->data['event_location']); + } + if ($schedule->data['event_desc'] != $original->data['event_desc']) { + array_push($changes,"La description de l'évenement a été modifié de ".$original->data['event_desc']." à ".$schedule->data['event_desc']); + } + + if ($schedule->type == "regular") { + /** Check Instructor */ + if ($schedule->data['n1_p1_instructor'] != $original->data['n1_p1_instructor']) { + array_push($changes,"L'instructeur du niveau 1 pour la première période a été changé de ".$original->data['n1_p1_instructor']." à ".$schedule->data['n1_p1_instructor']); + \Notification::send(\App\User::find($original->data['n1_p1_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","Le cours ".$original->data['n1_p1_name']." du ".$original->date." vous a été retiré.")); + \Notification::send(\App\User::find($schedule->data['n1_p1_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","Le cours ".$schedule->data['n1_p1_name']." du ".$schedule->date." vous a été ajouté.")); + } + if ($schedule->data['n1_p2_instructor'] != $original->data['n1_p2_instructor']) { + array_push($changes,"L'instructeur du niveau 1 pour la deuxième période a été changé de ".$original->data['n1_p2_instructor']." à ".$schedule->data['n1_p2_instructor']); + \Notification::send(\App\User::find($original->data['n1_p2_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","Le cours ".$original->data['n1_p2_name']." du ".$original->date." vous a été retiré.")); + \Notification::send(\App\User::find($schedule->data['n1_p2_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","Le cours ".$schedule->data['n1_p2_name']." du ".$schedule->date." vous a été ajouté.")); + } + if ($schedule->data['n2_p1_instructor'] != $original->data['n2_p1_instructor']) { + array_push($changes,"L'instructeur du niveau 2 pour la première période a été changé de ".$original->data['n2_p1_instructor']." à ".$schedule->data['n2_p1_instructor']); + \Notification::send(\App\User::find($original->data['n2_p1_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","Le cours ".$original->data['n2_p1_name']." du ".$original->date." vous a été retiré.")); + \Notification::send(\App\User::find($schedule->data['n2_p1_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","Le cours ".$schedule->data['n2_p1_name']." du ".$schedule->date." vous a été ajouté.")); + } + if ($schedule->data['n2_p2_instructor'] != $original->data['n2_p2_instructor']) { + array_push($changes,"L'instructeur du niveau 2 pour la deuxième période a été changé de ".$original->data['n2_p2_instructor']." à ".$schedule->data['n2_p2_instructor']); + \Notification::send(\App\User::find($original->data['n2_p2_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","Le cours ".$original->data['n2_p2_name']." du ".$original->date." vous a été retiré.")); + \Notification::send(\App\User::find($schedule->data['n2_p2_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","Le cours ".$schedule->data['n2_p2_name']." du ".$schedule->date." vous a été ajouté.")); + } + if ($schedule->data['n3_p1_instructor'] != $original->data['n3_p1_instructor']) { + array_push($changes,"L'instructeur du niveau 3 pour la première période a été changé de ".$original->data['n3_p1_instructor']." à ".$schedule->data['n3_p1_instructor']); + \Notification::send(\App\User::find($original->data['n3_p1_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","Le cours ".$original->data['n3_p1_name']." du ".$original->date." vous a été retiré.")); + \Notification::send(\App\User::find($schedule->data['n3_p1_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","Le cours ".$schedule->data['n3_p1_name']." du ".$schedule->date." vous a été ajouté.")); + } + if ($schedule->data['n3_p2_instructor'] != $original->data['n3_p2_instructor']) { + array_push($changes,"L'instructeur du niveau 3 pour la deuxième période a été changé de ".$original->data['n3_p2_instructor']." à ".$schedule->data['n3_p2_instructor']); + \Notification::send(\App\User::find($original->data['n3_p2_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","Le cours ".$original->data['n3_p2_name']." du ".$original->date." vous a été retiré.")); + \Notification::send(\App\User::find($schedule->data['n3_p2_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","Le cours ".$schedule->data['n3_p2_name']." du ".$schedule->date." vous a été ajouté.")); + } + /** Check OCOM */ + if ($schedule->data['n1_p1_ocom'] != $original->data['n1_p1_ocom']) { + array_push($changes,"L'OCOM du niveau 1 pour la première période a été changé de ".$original->data['n1_p1_ocom']." à ".$schedule->data['n1_p1_ocom']); + \Notification::send(\App\User::find($schedule->data['n1_p1_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","L'ocom du cours ".$schedule->data['n1_p1_name']." du ".$schedule->date." a été changé pour ".$schedule->data['n1_p1_ocom'])); + } + if ($schedule->data['n1_p2_ocom'] != $original->data['n1_p2_ocom']) { + array_push($changes,"L'OCOM du niveau 1 pour la deuxième période a été changé de ".$original->data['n1_p2_ocom']." à ".$schedule->data['n1_p2_ocom']); + \Notification::send(\App\User::find($schedule->data['n1_p2_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","L'ocom du cours ".$schedule->data['n1_p2_name']." du ".$schedule->date." a été changé pour ".$schedule->data['n1_p2_ocom'])); + } + if ($schedule->data['n2_p1_ocom'] != $original->data['n2_p1_ocom']) { + array_push($changes,"L'OCOM du niveau 2 pour la première période a été changé de ".$original->data['n2_p1_ocom']." à ".$schedule->data['n2_p1_ocom']); + \Notification::send(\App\User::find($schedule->data['n2_p1_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","L'ocom du cours ".$schedule->data['n2_p1_name']." du ".$schedule->date." a été changé pour ".$schedule->data['n2_p1_ocom'])); + } + if ($schedule->data['n2_p2_ocom'] != $original->data['n2_p2_ocom']) { + array_push($changes,"L'OCOM du niveau 2 pour la deuxième période a été changé de ".$original->data['n2_p2_ocom']." à ".$schedule->data['n2_p2_ocom']); + \Notification::send(\App\User::find($schedule->data['n2_p2_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","L'ocom du cours ".$schedule->data['n2_p2_name']." du ".$schedule->date." a été changé pour ".$schedule->data['n2_p2_ocom'])); + } + if ($schedule->data['n3_p1_ocom'] != $original->data['n3_p1_ocom']) { + array_push($changes,"L'OCOM du niveau 3 pour la première période a été changé de ".$original->data['n3_p1_ocom']." à ".$schedule->data['n3_p1_ocom']); + \Notification::send(\App\User::find($schedule->data['n3_p1_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","L'ocom du cours ".$schedule->data['n3_p1_name']." du ".$schedule->date." a été changé pour ".$schedule->data['n3_p1_ocom'])); + } + if ($schedule->data['n3_p2_ocom'] != $original->data['n3_p2_ocom']) { + array_push($changes,"L'OCOM du niveau 3 pour la deuxième période a été changé de ".$original->data['n3_p2_ocom']." à ".$schedule->data['n3_p2_ocom']); + \Notification::send(\App\User::find($schedule->data['n3_p2_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","L'ocom du cours ".$schedule->data['n3_p2_name']." du ".$schedule->date." a été changé pour ".$schedule->data['n3_p2_ocom'])); + } + /** Check Local */ + if ($schedule->data['n1_p1_local'] != $original->data['n1_p1_local']) { + array_push($changes,"Le local du niveau 1 pour la première période a été changé de ".$original->data['n1_p1_local']." à ".$schedule->data['n1_p1_local']); + } + if ($schedule->data['n1_p2_local'] != $original->data['n1_p2_local']) { + array_push($changes,"Le local du niveau 1 pour la deuxième période a été changé de ".$original->data['n1_p2_local']." à ".$schedule->data['n1_p2_local']); + } + if ($schedule->data['n2_p1_local'] != $original->data['n2_p1_local']) { + array_push($changes,"Le local du niveau 2 pour la première période a été changé de ".$original->data['n2_p1_local']." à ".$schedule->data['n2_p1_local']); + } + if ($schedule->data['n2_p2_local'] != $original->data['n2_p2_local']) { + array_push($changes,"Le local du niveau 2 pour la deuxième période a été changé de ".$original->data['n2_p2_local']." à ".$schedule->data['n2_p2_local']); + } + if ($schedule->data['n3_p1_local'] != $original->data['n3_p1_local']) { + array_push($changes,"Le local du niveau 3 pour la première période a été changé de ".$original->data['n3_p1_local']." à ".$schedule->data['n3_p1_local']); + } + if ($schedule->data['n3_p2_local'] != $original->data['n3_p2_local']) { + array_push($changes,"Le local du niveau 3 pour la deuxième période a été changé de ".$original->data['n3_p2_local']." à ".$schedule->data['n3_p2_local']); + } + /** Check Name */ + if ($schedule->data['n1_p1_name'] != $original->data['n1_p1_name']) { + array_push($changes,"Le nom du cours niveau 1 pour la première période a été changé de ".$original->data['n1_p1_name']." à ".$schedule->data['n1_p1_name']); + \Notification::send(\App\User::find($schedule->data['n1_p1_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","Le nom du cours ".$original->data['n1_p1_name']." du ".$schedule->date." a été changé pour ".$schedule->data['n1_p1_name'])); + } + if ($schedule->data['n1_p2_name'] != $original->data['n1_p2_name']) { + array_push($changes,"Le nom du cours niveau 1 pour la deuxième période a été changé de ".$original->data['n1_p2_name']." à ".$schedule->data['n1_p2_name']); + \Notification::send(\App\User::find($schedule->data['n1_p2_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","Le nom du cours ".$original->data['n1_p2_name']." du ".$schedule->date." a été changé pour ".$schedule->data['n1_p2_name'])); + } + if ($schedule->data['n2_p1_name'] != $original->data['n2_p1_name']) { + array_push($changes,"Le nom du cours niveau 2 pour la première période a été changé de ".$original->data['n2_p1_name']." à ".$schedule->data['n2_p1_name']); + \Notification::send(\App\User::find($schedule->data['n2_p1_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","Le nom du cours ".$original->data['n2_p1_name']." du ".$schedule->date." a été changé pour ".$schedule->data['n2_p1_name'])); + } + if ($schedule->data['n2_p2_name'] != $original->data['n2_p2_name']) { + array_push($changes,"Le nom du cours niveau 2 pour la deuxième période a été changé de ".$original->data['n2_p2_name']." à ".$schedule->data['n2_p2_name']); + \Notification::send(\App\User::find($schedule->data['n2_p2_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","Le nom du cours ".$original->data['n2_p2_name']." du ".$schedule->date." a été changé pour ".$schedule->data['n2_p2_name'])); + } + if ($schedule->data['n3_p1_name'] != $original->data['n3_p1_name']) { + array_push($changes,"Le nom du cours niveau 3 pour la première période a été changé de ".$original->data['n3_p1_name']." à ".$schedule->data['n3_p1_name']); + \Notification::send(\App\User::find($schedule->data['n3_p1_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","Le nom du cours ".$original->data['n3_p1_name']." du ".$schedule->date." a été changé pour ".$schedule->data['n3_p1_name'])); + } + if ($schedule->data['n3_p2_name'] != $original->data['n3_p2_name']) { + array_push($changes,"Le nom du cours niveau 3 pour la deuxième période a été changé de ".$original->data['n3_p2_name']." à ".$schedule->data['n3_p2_name']); + \Notification::send(\App\User::find($schedule->data['n3_p2_instructor']), new mail(\Auth::User(),"Modification d'un de vos cours","Le nom du cours ".$original->data['n3_p2_name']." du ".$schedule->date." a été changé pour ".$schedule->data['n3_p2_name'])); + } + } + + \Notification::send($userToNotify, new Alert(\Auth::User()->id,"Modification de l'activité, ".$schedule->data['event_name']." à l'horaire le ".$schedule->date,"/admin/calendar")); + + $string_Change = ""; + if(\App\Config::where('name','is_schedule_build')->first()->state == 1) + { + \Notification::send($userToNotify, new mail(\Auth::User(),"Modification d'une activité a l'horaire",\Auth::User()->fullname()." à modifié l'activité, ".$schedule->data['event_name']." à l'horaire le ".$schedule->date."
".$string_Change)); + } + return redirect('/admin/calendar'); } diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 27f62e27..a85519ff 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -173,4 +173,28 @@ class UserController extends Controller $notification->delete(); return redirect(request('url')); } + + public function showUserProfil($id = 0) + { + if ($id == 0) { + $id = \Auth::User()->id; + } + return view('admin.user.profil',['user' => \App\User::find($id)]); + } + + public function editUserAvatar($id) + { + $user = \Auth::User(); + + $user->avatar = $id; + + $user->save(); + + return redirect('/admin/profil/avatar')->with('status', 'Modification enregistré'); + } + + public function UserAvatar() + { + return view('admin.user.profil.avatar'); + } } diff --git a/public/assets/js/calendar/calendar.js b/public/assets/js/calendar/calendar.js index 50c6cbb4..f1231eda 100644 --- a/public/assets/js/calendar/calendar.js +++ b/public/assets/js/calendar/calendar.js @@ -180,7 +180,7 @@ function switchType() eventBeginTime.value = ""; eventEndTime.value = ""; eventLocation.value = ""; - eventDesc.value = ""; + eventDesc.value = "Financement"; divSpecialSection.style.display = "none"; break; @@ -190,7 +190,7 @@ function switchType() eventBeginTime.value = ""; eventEndTime.value = ""; eventLocation.value = ""; - eventDesc.value = ""; + eventDesc.value = "Bénévolat"; divSpecialSection.style.display = "none"; break; @@ -200,7 +200,7 @@ function switchType() eventBeginTime.value = ""; eventEndTime.value = ""; eventLocation.value = ""; - eventDesc.value = ""; + eventDesc.value = "Autre"; divSpecialSection.style.display = "none"; break; } diff --git a/resources/views/admin/dashboard.blade.php b/resources/views/admin/dashboard.blade.php index 13a546dc..3eb8507a 100644 --- a/resources/views/admin/dashboard.blade.php +++ b/resources/views/admin/dashboard.blade.php @@ -113,7 +113,7 @@
- Profil + Profil
diff --git a/resources/views/admin/user/profil.blade.php b/resources/views/admin/user/profil.blade.php new file mode 100644 index 00000000..288e280c --- /dev/null +++ b/resources/views/admin/user/profil.blade.php @@ -0,0 +1,126 @@ +@extends('layouts.admin.main') + +@section('content') +
id == \Auth::User()->id) class="col-md-12 col-lg-9" @else class="col-sm-12" @endif> +
+
+
+
+ Card image cap +
{{\Auth::User()->fullname()}}
+
{{\App\Rank::find(\Auth::User()->rank)->name}}
+
+
+
+
+
+

{{\App\Rank::find($user->job)->name}}

+
+
+
+

+ Genre
+ @if ($user->sexe == "m") + + @elseif($user->sexe == "f") + + @else + + @endif +

+
+
+

+ Age
+ @if ($user->age != "Inconnu") + {{$user->age}} ans + @else + Inconnu + @endif +

+
+
+

Téléphone
+ @if ($user->telephone != "Inconnu") + @php + $data = '+'.$user->telephone; + if(preg_match( '/^\+\d(\d{3})(\d{3})(\d{4})$/',$data,$matches)) + { + $result = $matches[1] . '-' .$matches[2] . '-' . $matches[3]; + echo $result; + } + @endphp + @else + Inconnu + @endif +

+
+
+

Adresse
+ {{$user->adress}} +

+
+
+
+
+

Dernières activitées de l'utilisateur

+ + + + + + + + + @foreach ($user->logs()->take(6)->get() as $log) + + + + + @endforeach + +
HorodatageAction
{{$log->created_at}}{{$log->action}}
+
+
+
+
+@if ($user->id == \Auth::User()->id) +
+ +
+@endif +@endsection + +@section('breadcrumb') + +@endsection + +@section('scripts') + +@endsection diff --git a/resources/views/admin/user/profil/avatar.blade.php b/resources/views/admin/user/profil/avatar.blade.php new file mode 100644 index 00000000..ccccbf49 --- /dev/null +++ b/resources/views/admin/user/profil/avatar.blade.php @@ -0,0 +1,57 @@ +@extends('layouts.admin.main') + +@section('content') +
+
+
+ @if (session('status')) +
+ Félicitation + Votre avatar a été mis a jour ! + +
+ @endif + Votre Avatar +
+ Card image cap +
+
+ Cliquer sur un avatar pour mettre a jour votre avatar +
+ @for ($i = 1; $i < 16; $i++) +
+ Card image cap +
+ @endfor +
+
+
+
+@endsection + +@section('breadcrumb') + +@endsection + +@section('scripts') + +@endsection diff --git a/resources/views/vendor/notifications/email.blade.php b/resources/views/vendor/notifications/email.blade.php index 2ce6fdf7..b2c8c1f1 100644 --- a/resources/views/vendor/notifications/email.blade.php +++ b/resources/views/vendor/notifications/email.blade.php @@ -12,7 +12,7 @@ {{-- Intro Lines --}} @foreach ($introLines as $line) -{{ $line }} +{!! $line !!} @endforeach diff --git a/routes/web.php b/routes/web.php index 0e953d6c..f79ab7fa 100644 --- a/routes/web.php +++ b/routes/web.php @@ -16,7 +16,7 @@ Auth::routes(); /* Index Route */ Route::get('/', function () { - return view('public'); + return view('default'); }); Route::middleware(['auth','admin'])->group(function () { @@ -75,6 +75,12 @@ Route::middleware(['auth','admin'])->group(function () { /** Notification */ Route::post('/admin/notication/mark/{id}','UserController@notificationmark'); + + /** Profil */ + Route::get('/admin/profil/avatar' , 'UserController@UserAvatar'); + Route::get('/admin/profil/edit/avatar/{id}' , 'UserController@editUserAvatar'); + Route::get('/admin/profil/{id?}' , 'UserController@showUserProfil'); + }); Route::middleware(['auth','staff'])->group(function () {