diff --git a/app/Http/Controllers/CalendarController.php b/app/Http/Controllers/CalendarController.php index 5ff1421b..89e1ed2e 100644 --- a/app/Http/Controllers/CalendarController.php +++ b/app/Http/Controllers/CalendarController.php @@ -445,8 +445,15 @@ class CalendarController extends Controller $schedule->save(); /** Logs and Notification */ - Log::saveLog("Ajout de l'activité, ".$schedule->event_name." à l'horaire le ".$schedule->event_date); + Log::saveLog("Ajout de l'activité, ".$schedule->event_name." à l'horaire le ".$schedule->date); + $userToNotify = $schedule->getUserToNotify(); + \Notification::send($userToNotify, new Alert(\Auth::User()->id,"Ajout de l'activité, ".$schedule->event_name." à l'horaire le ".$schedule->date,"/admin/calendar")); + + if(\App\Config::where('name','is_schedule_build')->first()->state == 1) + { + \Notification::send($userToNotify, new mail(\Auth::User(),"Ajout d'une activité a l'horaire",\Auth::User()->fullname()." à ajouté l'activité, ".$schedule->event_name." à l'horaire le ".$schedule->date)); + } return redirect('/admin/calendar'); } @@ -527,5 +534,4 @@ class CalendarController extends Controller $schedule->delete(); } - } diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index dcb37558..27f62e27 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -165,4 +165,12 @@ class UserController extends Controller $user->delete(); } + + public function notificationmark($id) + { + $notification = \Auth::User()->unreadNotifications->where('id',$id)->first(); + + $notification->delete(); + return redirect(request('url')); + } } diff --git a/app/Notifications/Alert.php b/app/Notifications/Alert.php index 5ba775d1..24d8b1be 100644 --- a/app/Notifications/Alert.php +++ b/app/Notifications/Alert.php @@ -19,10 +19,11 @@ class Alert extends Notification * * @return void */ - public function __construct($user,$msg) + public function __construct($user,$msg,$url) { $this->myNotification = $msg; $this->fromUser = $user; + $this->myUrl = $url; } /** @@ -47,6 +48,7 @@ class Alert extends Notification return [ 'from' => $this->fromUser, 'msg' => $this->myNotification, + 'url' => $this->myUrl, ]; } } diff --git a/app/Schedule.php b/app/Schedule.php index ab01be60..28fb64e0 100644 --- a/app/Schedule.php +++ b/app/Schedule.php @@ -54,4 +54,24 @@ class Schedule extends Model return $dispo_item; } + + public function getUserToNotify($priority = 0) + { + $users = \App\User::all(); + + if($priority == 0) + { + $userToNotify = collect(); + foreach ($users as $user) { + if ($user->getPerm('schedule_notify')) { + $userToNotify->push($user); + } + } + + return $userToNotify; + } else if ($priority == 1) + { + return $users; + } + } } diff --git a/app/User.php b/app/User.php index 17296c45..4ced72fa 100644 --- a/app/User.php +++ b/app/User.php @@ -65,13 +65,13 @@ class User extends Authenticatable $user_perm_value = $this->$perm; if ($user_perm_value == 1 ) { - $perm_value = 1; + $perm_value = true; } else if ($job_perm_value== 1) { - $perm_value = 1; + $perm_value = true; } else if ($rank_perm_value == 1) { - $perm_value = 1; + $perm_value = true; } else { - $perm_value = 0; + $perm_value = false; } return $perm_value; diff --git a/config/mail.php b/config/mail.php index 86eaf54d..1848486d 100644 --- a/config/mail.php +++ b/config/mail.php @@ -56,8 +56,8 @@ return [ */ 'from' => [ - 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), - 'name' => env('MAIL_FROM_NAME', 'Example'), + 'address' => 'noreply@c-cms.cf', + 'name' => 'C-CMS', ], /* diff --git a/database/seeds/ConfigsTableSeeder.php b/database/seeds/ConfigsTableSeeder.php index c13f2602..cefb3ea9 100644 --- a/database/seeds/ConfigsTableSeeder.php +++ b/database/seeds/ConfigsTableSeeder.php @@ -16,6 +16,11 @@ class ConfigsTableSeeder extends Seeder 'name' => 'is_schedule_public', 'state' => 0, 'data' => 'null' + ], + [ + 'name' => 'is_schedule_build', + 'state' => 0, + 'data' => 'null' ] ]); } diff --git a/public/assets/admin/assets/scss/style.css b/public/assets/admin/assets/scss/style.css index 571b177f..78397373 100644 --- a/public/assets/admin/assets/scss/style.css +++ b/public/assets/admin/assets/scss/style.css @@ -2318,4 +2318,8 @@ header .form-inline { @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } +} +.cs-notification:hover { + background-color: #F2F2F2 !important; + color:white; } \ No newline at end of file diff --git a/resources/views/admin/update.blade.php b/resources/views/admin/update.blade.php index b232b269..d79d288b 100644 --- a/resources/views/admin/update.blade.php +++ b/resources/views/admin/update.blade.php @@ -2,6 +2,38 @@ @section('content') + +
+ Nouveauté +
+ Back End & API +
+ Correction de bug +