diff --git a/Envoy.blade.php b/Envoy.blade.php index 176b11af..0f9ac980 100644 --- a/Envoy.blade.php +++ b/Envoy.blade.php @@ -1,175 +1,178 @@ @servers(['web' => 'deployer@vps188754.vps.ovh.ca']) @setup - $repository = 'git@gitlab.com:TheGamecraft/c-cms.git'; - $release = date('YmdHis'); +$repository = 'git@gitlab.com:TheGamecraft/c-cms.git'; +$release = date('YmdHis'); - $releases_dir_697 = '/var/www/c-cms/escadron697/releases'; - $app_dir_697 = '/var/www/c-cms/escadron697'; - $new_release_dir_697 = $releases_dir_697 .'/'. $release; +$releases_dir_697 = '/var/www/c-cms/escadron697/releases'; +$app_dir_697 = '/var/www/c-cms/escadron697'; +$new_release_dir_697 = $releases_dir_697 .'/'. $release; - $releases_dir_736 = '/var/www/c-cms/escadron736/releases'; - $app_dir_736 = '/var/www/c-cms/escadron736'; - $new_release_dir_736 = $releases_dir_736 .'/'. $release; +$releases_dir_736 = '/var/www/c-cms/escadron736/releases'; +$app_dir_736 = '/var/www/c-cms/escadron736'; +$new_release_dir_736 = $releases_dir_736 .'/'. $release; - $releases_dir_dev = '/var/www/c-cms/dev/releases'; - $app_dir_dev = '/var/www/c-cms/dev'; - $new_release_dir_dev = $releases_dir_dev .'/'. $release; +$releases_dir_dev = '/var/www/c-cms/dev/releases'; +$app_dir_dev = '/var/www/c-cms/dev'; +$new_release_dir_dev = $releases_dir_dev .'/'. $release; - $releases_dir_227 = '/var/www/c-cms/ccmrc227/releases'; - $app_dir_227 = '/var/www/c-cms/ccmrc227'; - $new_release_dir_227 = $releases_dir_227 .'/'. $release; +$releases_dir_227 = '/var/www/c-cms/ccmrc227/releases'; +$app_dir_227 = '/var/www/c-cms/ccmrc227'; +$new_release_dir_227 = $releases_dir_227 .'/'. $release; - $releases_dir_117 = '/var/www/c-cms/ccmrc117/releases'; - $app_dir_117 = '/var/www/c-cms/ccmrc117'; - $new_release_dir_117 = $releases_dir_117 .'/'. $release; +$releases_dir_117 = '/var/www/c-cms/ccmrc117/releases'; +$app_dir_117 = '/var/www/c-cms/ccmrc117'; +$new_release_dir_117 = $releases_dir_117 .'/'. $release; @endsetup @story('deploy_697') - clone_repository_697 - run_composer_697 - update_symlinks_697 +clone_repository_697 +run_composer_697 +update_symlinks_697 @endstory @story('deploy_736') - clone_repository_736 - run_composer_736 - update_symlinks_736 +clone_repository_736 +run_composer_736 +update_symlinks_736 @endstory @story('deploy_dev') - clone_repository_dev - run_composer_dev - update_symlinks_dev - remove_old_release_dev +clone_repository_dev +run_composer_dev +update_symlinks_dev +remove_old_release_dev @endstory @story('deploy_227') - clone_repository_227 - run_composer_227 - update_symlinks_227 +clone_repository_227 +run_composer_227 +update_symlinks_227 @endstory @story('deploy_117') - clone_repository_117 - run_composer_117 - update_symlinks_117 +clone_repository_117 +run_composer_117 +update_symlinks_117 @endstory @task('clone_repository_697') - echo 'Cloning repository' - [ -d {{ $releases_dir_697 }} ] || mkdir {{ $releases_dir_697 }} - git clone --depth 1 {{ $repository }} {{ $new_release_dir_697 }} - cd {{ $new_release_dir_697 }} - git reset --hard {{ $commit }} +echo 'Cloning repository' +[ -d {{ $releases_dir_697 }} ] || mkdir {{ $releases_dir_697 }} +git clone --depth 1 {{ $repository }} {{ $new_release_dir_697 }} +cd {{ $new_release_dir_697 }} +git reset --hard {{ $commit }} @endtask @task('run_composer_697') - echo "Starting deployment ({{ $release }})" - cd {{ $new_release_dir_697 }} - composer install --prefer-dist --no-scripts -q -o --no-dev - npm install - npm run production +echo "Starting deployment ({{ $release }})" +cd {{ $new_release_dir_697 }} +composer install --prefer-dist --no-scripts -q -o --no-dev +npm install +npm run production @endtask @task('update_symlinks_697') - echo "Linking storage directory" - rm -rf {{ $new_release_dir_697 }}/storage - ln -nfs {{ $app_dir_697 }}/storage {{ $new_release_dir_697 }}/storage +echo "Linking storage directory" +rm -rf {{ $new_release_dir_697 }}/storage +ln -nfs {{ $app_dir_697 }}/storage {{ $new_release_dir_697 }}/storage - echo 'Linking .env file' - ln -nfs {{ $app_dir_697 }}/.env {{ $new_release_dir_697 }}/.env +echo 'Linking .env file' +ln -nfs {{ $app_dir_697 }}/.env {{ $new_release_dir_697 }}/.env - echo 'Linking current release' - ln -nfs {{ $new_release_dir_697 }} {{ $app_dir_697 }}/current +echo 'Linking current release' +ln -nfs {{ $new_release_dir_697 }} {{ $app_dir_697 }}/current - echo 'Setting permission' - chmod -R 777 {{ $app_dir_697 }}/current/bootstrap/ +echo 'Setting permission' +chmod -R 777 {{ $app_dir_697 }}/current/bootstrap/ - echo 'Migrate DB' - cd {{ $app_dir_697 }}/current/ - yes|php artisan migrate - yes|php artisan db:seed --class=ConfigsTableSeeder +echo 'Migrate DB' +cd {{ $app_dir_697 }}/current/ +yes|php artisan migrate +yes|php artisan db:seed --class=ConfigsTableSeeder +php artisan update @endtask @task('clone_repository_736') - echo 'Cloning repository' - [ -d {{ $releases_dir_736 }} ] || mkdir {{ $releases_dir_736 }} - git clone --depth 1 {{ $repository }} {{ $new_release_dir_736 }} - cd {{ $new_release_dir_736 }} - git reset --hard {{ $commit }} +echo 'Cloning repository' +[ -d {{ $releases_dir_736 }} ] || mkdir {{ $releases_dir_736 }} +git clone --depth 1 {{ $repository }} {{ $new_release_dir_736 }} +cd {{ $new_release_dir_736 }} +git reset --hard {{ $commit }} @endtask @task('run_composer_736') - echo "Starting deployment ({{ $release }})" - cd {{ $new_release_dir_736 }} - composer install --prefer-dist --no-scripts -q -o --no-dev - npm install - npm run production +echo "Starting deployment ({{ $release }})" +cd {{ $new_release_dir_736 }} +composer install --prefer-dist --no-scripts -q -o --no-dev +npm install +npm run production @endtask @task('update_symlinks_736') - echo "Linking storage directory" - rm -rf {{ $new_release_dir_736 }}/storage - ln -nfs {{ $app_dir_736 }}/storage {{ $new_release_dir_736 }}/storage +echo "Linking storage directory" +rm -rf {{ $new_release_dir_736 }}/storage +ln -nfs {{ $app_dir_736 }}/storage {{ $new_release_dir_736 }}/storage - echo 'Linking .env file' - ln -nfs {{ $app_dir_736 }}/.env {{ $new_release_dir_736 }}/.env +echo 'Linking .env file' +ln -nfs {{ $app_dir_736 }}/.env {{ $new_release_dir_736 }}/.env - echo 'Linking current release' - ln -nfs {{ $new_release_dir_736 }} {{ $app_dir_736 }}/current +echo 'Linking current release' +ln -nfs {{ $new_release_dir_736 }} {{ $app_dir_736 }}/current - echo 'Setting permission' - chmod -R 777 {{ $app_dir_736 }}/current/bootstrap/ +echo 'Setting permission' +chmod -R 777 {{ $app_dir_736 }}/current/bootstrap/ - echo 'Migrate DB' - cd {{ $app_dir_736 }}/current/ - yes|php artisan migrate - yes|php artisan db:seed --class=ConfigsTableSeeder +echo 'Migrate DB' +cd {{ $app_dir_736 }}/current/ +yes|php artisan migrate +yes|php artisan db:seed --class=ConfigsTableSeeder +php artisan update @endtask @task('clone_repository_dev') - echo 'Cloning repository' - [ -d {{ $releases_dir_dev }} ] || mkdir {{ $releases_dir_dev }} - git clone --depth 1 --single-branch -b dev {{ $repository }} {{ $new_release_dir_dev }} - cd {{ $new_release_dir_dev }} - git reset --hard {{ $commit }} +echo 'Cloning repository' +[ -d {{ $releases_dir_dev }} ] || mkdir {{ $releases_dir_dev }} +git clone --depth 1 --single-branch -b dev {{ $repository }} {{ $new_release_dir_dev }} +cd {{ $new_release_dir_dev }} +git reset --hard {{ $commit }} @endtask @task('run_composer_dev') - echo "Starting deployment ({{ $release }})" - cd {{ $new_release_dir_dev }} - composer install --prefer-dist --no-scripts -q -o --no-dev - npm install - npm run production +echo "Starting deployment ({{ $release }})" +cd {{ $new_release_dir_dev }} +composer install --prefer-dist --no-scripts -q -o --no-dev +npm install +npm run production @endtask @task('update_symlinks_dev') - echo "Linking storage directory" - rm -rf {{ $new_release_dir_dev }}/storage - ln -nfs {{ $app_dir_dev }}/storage {{ $new_release_dir_dev }}/storage +echo "Linking storage directory" +rm -rf {{ $new_release_dir_dev }}/storage +ln -nfs {{ $app_dir_dev }}/storage {{ $new_release_dir_dev }}/storage - echo 'Linking .env file' - ln -nfs {{ $app_dir_dev }}/.env {{ $new_release_dir_dev }}/.env +echo 'Linking .env file' +ln -nfs {{ $app_dir_dev }}/.env {{ $new_release_dir_dev }}/.env - echo 'Linking current release' - ln -nfs {{ $new_release_dir_dev }} {{ $app_dir_dev }}/current +echo 'Linking current release' +ln -nfs {{ $new_release_dir_dev }} {{ $app_dir_dev }}/current - echo 'Setting permission' - chmod -R 777 {{ $app_dir_dev }}/current/bootstrap/ +echo 'Setting permission' +chmod -R 777 {{ $app_dir_dev }}/current/bootstrap/ - echo 'Migrate DB' - cd {{ $app_dir_dev }}/current/ - yes|php artisan migrate - yes|php artisan db:seed --class=ConfigsTableSeeder +echo 'Migrate DB' +cd {{ $app_dir_dev }}/current/ +yes|php artisan migrate +yes|php artisan db:seed --class=ConfigsTableSeeder +php artisan update @endtask @task('remove_old_release_dev') - cd {{ $releases_dir_dev }} - rm -fr $(ls -t1 | tail -n +3) +cd {{ $releases_dir_dev }} +rm -fr $(ls -t1 | tail -n +3) @endtask @task('clone_repository_227') @@ -204,8 +207,9 @@ chmod -R 777 {{ $app_dir_227 }}/current/bootstrap/ echo 'Migrate DB' cd {{ $app_dir_227 }}/current/ - yes|php artisan migrate - yes|php artisan db:seed --class=ConfigsTableSeeder +yes|php artisan migrate +yes|php artisan db:seed --class=ConfigsTableSeeder +php artisan update @endtask @@ -241,7 +245,8 @@ chmod -R 777 {{ $app_dir_117 }}/current/bootstrap/ echo 'Migrate DB' cd {{ $app_dir_117 }}/current/ - yes|php artisan migrate - yes|php artisan db:seed --class=ConfigsTableSeeder +yes|php artisan migrate +yes|php artisan db:seed --class=ConfigsTableSeeder +php artisan update @endtask diff --git a/app/Console/Commands/update.php b/app/Console/Commands/update.php new file mode 100644 index 00000000..72cbd7d8 --- /dev/null +++ b/app/Console/Commands/update.php @@ -0,0 +1,81 @@ +info('Starting update ...'); + + $this->updateDatabase(); + + $this->info('Update completed !'); + + } + + private function updateDatabase() + { + $this->info('Updating database ...'); + + // Check event table + if (!Schema::hasColumn('events','hidden')) + { + $this->info('Updating events table ...'); + Schema::table('events', function ($table) { + $table->boolean('hidden')->default(0); + }); + } + else + { + $this->info('Events table is up to date ...'); + } + + // Check event_type table + if (!Schema::hasColumn('event_types','hidden')) + { + $this->info('Updating event_types table ...'); + Schema::table('event_types', function ($table) { + $table->boolean('hidden')->default(0); + }); + } + else + { + $this->info('Event_types table is up to date ...'); + } + + return 0; + } +} diff --git a/app/Event.php b/app/Event.php index 346b71d2..9b704abf 100644 --- a/app/Event.php +++ b/app/Event.php @@ -94,8 +94,18 @@ class Event extends Model return $c; } } - - return false; + $error = new \App\Course(); + $error->name = "Cours manquant dans la BD"; + $error->ocom = "ERREUR"; + $error->periode = $p; + $error->level = $l; + $error->location = ""; + $error->desc = ""; + $error->comment = "Le cours est manquant dans la base de données"; + $error->comment_officier = "Le cours est manquant dans la base de données"; + $error->event_id = $this->id; + $error->user_id = 1; + return $error; } public function logs() @@ -143,4 +153,17 @@ class Event extends Model { return count($this->schedule["niveaux"]); } + + static function getMaxLevels($events) + { + $maxlevel = 0; + foreach ($events as $e) + { + if ($e->nbNiveau() > $maxlevel) + { + $maxlevel = $e->nbNiveau(); + } + } + return $maxlevel; + } } diff --git a/app/Http/Controllers/CalendarController.php b/app/Http/Controllers/CalendarController.php index d020b94e..cea52376 100644 --- a/app/Http/Controllers/CalendarController.php +++ b/app/Http/Controllers/CalendarController.php @@ -32,715 +32,14 @@ class CalendarController extends Controller */ public function index() { - - $this->listClass(); - return view('admin.calendar.calendar_display'); } - public function generate() + public function indexTable() { - $lang = str_replace('_', '-', app()->getLocale()); - setlocale(LC_ALL, $lang.'_'.strtoupper($lang).'.utf8','fra'); - - $month = request('month'); - $year = request('year'); - - $nextMonth = $month + 1; - $nextYear = $year; - - if ($nextMonth > 12) { - $nextMonth = 1; - $nextYear = $nextYear + 1; - } - - $prevMonth = $month - 1; - $prevYear = $year; - - if ($prevMonth < 1) { - $prevMonth = 12; - $prevYear = $prevYear - 1; - } - - $calendar = array(); - - $dayinmonth = cal_days_in_month(CAL_GREGORIAN, $month, $year); - - $firstdaymonth = date("w", strtotime("01-".$month."-".$year)); - - $addingday = 0; - - for ($i=$firstdaymonth ; $addingday < $dayinmonth ; $i++) { - $addingday = $addingday + 1; - $calendar[$i] = $addingday; - } - - echo '
'; - echo '
'; - echo '
'.ucfirst(strftime("%B %Y", strtotime("01-".$month."-".$year))).'
'; - echo '
Dimanche
Lundi
Mardi
Mercredi
Jeudi
Vendredi
Samedi
'; - echo '
'; - echo '
'; - for ($i=0; $i < 6 ; $i++) - { - echo ''; - } - - } - - public function load() - { - - $lang = str_replace('_', '-', app()->getLocale()); - setlocale(LC_ALL, $lang.'_'.strtoupper($lang).'.utf8','fra'); - - $Requestdate = request('date'); - - $url = str_replace("-","_", $Requestdate); - - - $today = Schedule::where('date','=',$Requestdate)->get(); - $isEmpty = $today->isEmpty(); - - echo ''; - } - - public function add($date) - { - $lang = str_replace('_', '-', app()->getLocale()); - setlocale(LC_ALL, $lang.'_'.strtoupper($lang).'.utf8','fra'); - - $date = str_replace("_", "-", $date); - - $UserList = User::all(); - $LocalList = Local::all(); - - return view('admin.calendar.calendar_add' ,[ - 'RequestDate' => $date, - 'Userslist' => $UserList, - 'LocalsList' => $LocalList, - 'ComplementaryActivity' => \App\ComplementaryActivity::all()]); - } - - public function edit($id) - { - $schedule = Schedule::find($id); - $UserList = User::all(); - $LocalList = Local::all(); - - return view('admin.calendar.calendar_edit' ,['RequestSchedule' => $schedule, 'Userslist' => $UserList, 'LocalsList' => $LocalList]); - } - - public function store() - { - $schedule = new Schedule; - - $schedule->date = request('event_date'); - $schedule->type = request('event_type'); - - if(request('event_type') == "regular") - { - $eventData = [ - "event_name" => request('event_name'), - "is_event_mandatory" => request('is_event_mandatory'), - "event_date" => request('event_date'), - "event_begin_time" => request('event_begin_time'), - "event_end_time" => request('event_end_time'), - "event_location" => request('event_location'), - "event_desc" => request('event_desc'), - "n1_p1_name" => request('n1_p1_name'), - "n1_p1_ocom" => request('n1_p1_ocom'), - "n1_p1_instructor" => request('n1_p1_instructor'), - "n1_p1_local" => request('n1_p1_local'), - "n1_p1_plandone" => request('n1_p1_plandone'), - "n1_p2_name" => request('n1_p2_name'), - "n1_p2_ocom" => request('n1_p2_ocom'), - "n1_p2_instructor" => request('n1_p2_instructor'), - "n1_p2_local" => request('n1_p2_local'), - "n1_p2_plandone" => request('n1_p2_plandone'), - "n2_p1_name" => request('n2_p1_name'), - "n2_p1_ocom" => request('n2_p1_ocom'), - "n2_p1_instructor" => request('n2_p1_instructor'), - "n2_p1_local" => request('n2_p1_local'), - "n2_p1_plandone" => request('n2_p1_plandone'), - "n2_p2_name" => request('n2_p2_name'), - "n2_p2_ocom" => request('n2_p2_ocom'), - "n2_p2_instructor" => request('n2_p2_instructor'), - "n2_p2_local" => request('n2_p2_local'), - "n2_p2_plandone" => request('n2_p2_plandone'), - "n3_p1_name" => request('n3_p1_name'), - "n3_p1_ocom" => request('n3_p1_ocom'), - "n3_p1_instructor" => request('n3_p1_instructor'), - "n3_p1_local" => request('n3_p1_local'), - "n3_p1_plandone" => request('n3_p1_plandone'), - "n3_p2_name" => request('n3_p2_name'), - "n3_p2_ocom" => request('n3_p2_ocom'), - "n3_p2_instructor" => request('n3_p2_instructor'), - "n3_p2_local" => request('n3_p2_local'), - "n3_p2_plandone" => request('n3_p2_plandone'), - ]; - } else { - $eventData = [ - "event_name" => request('event_name'), - "is_event_mandatory" => request('is_event_mandatory'), - "event_date" => request('event_date'), - "event_begin_time" => request('event_begin_time'), - "event_end_time" => request('event_end_time'), - "event_location" => request('event_location'), - "event_desc" => request('event_desc'), - ]; - } - - $schedule->data = $eventData; - - $schedule->save(); - - - $userToNotify = $schedule->getUserToNotify(); - \Notification::send($userToNotify, new Alert(\Auth::User()->id,"Ajout de l'activité, ".$schedule->data['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->data['event_name']." à l'horaire le ".$schedule->date)); - } - return redirect('/admin/calendar'); - - } - - public function patch($id) - { - $schedule = Schedule::find($id); - $original = clone($schedule); - - $schedule->date = request('event_date'); - $schedule->type = request('event_type'); - - if(request('event_type') == "regular") - { - $eventData = [ - "event_name" => request('event_name'), - "is_event_mandatory" => request('is_event_mandatory'), - "event_date" => request('event_date'), - "event_begin_time" => request('event_begin_time'), - "event_end_time" => request('event_end_time'), - "event_location" => request('event_location'), - "event_desc" => request('event_desc'), - "n1_p1_name" => request('n1_p1_name'), - "n1_p1_ocom" => request('n1_p1_ocom'), - "n1_p1_instructor" => request('n1_p1_instructor'), - "n1_p1_local" => request('n1_p1_local'), - "n1_p1_plandone" => request('n1_p1_plandone'), - "n1_p2_name" => request('n1_p2_name'), - "n1_p2_ocom" => request('n1_p2_ocom'), - "n1_p2_instructor" => request('n1_p2_instructor'), - "n1_p2_local" => request('n1_p2_local'), - "n1_p2_plandone" => request('n1_p2_plandone'), - "n2_p1_name" => request('n2_p1_name'), - "n2_p1_ocom" => request('n2_p1_ocom'), - "n2_p1_instructor" => request('n2_p1_instructor'), - "n2_p1_local" => request('n2_p1_local'), - "n2_p1_plandone" => request('n2_p1_plandone'), - "n2_p2_name" => request('n2_p2_name'), - "n2_p2_ocom" => request('n2_p2_ocom'), - "n2_p2_instructor" => request('n2_p2_instructor'), - "n2_p2_local" => request('n2_p2_local'), - "n2_p2_plandone" => request('n2_p2_plandone'), - "n3_p1_name" => request('n3_p1_name'), - "n3_p1_ocom" => request('n3_p1_ocom'), - "n3_p1_instructor" => request('n3_p1_instructor'), - "n3_p1_local" => request('n3_p1_local'), - "n3_p1_plandone" => request('n3_p1_plandone'), - "n3_p2_name" => request('n3_p2_name'), - "n3_p2_ocom" => request('n3_p2_ocom'), - "n3_p2_instructor" => request('n3_p2_instructor'), - "n3_p2_local" => request('n3_p2_local'), - "n3_p2_plandone" => request('n3_p2_plandone'), - ]; - } else { - $eventData = [ - "event_name" => request('event_name'), - "is_event_mandatory" => request('is_event_mandatory'), - "event_date" => request('event_date'), - "event_begin_time" => request('event_begin_time'), - "event_end_time" => request('event_end_time'), - "event_location" => request('event_location'), - "event_desc" => request('event_desc'), - ]; - } - - $schedule->data = $eventData; - - $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 ".\App\User::find($original->data['n1_p1_instructor'])->fullname()." à ".\App\User::find($schedule->data['n1_p1_instructor'])->fullname()); - \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 ".\App\User::find($original->data['n1_p2_instructor'])->fullname()." à ".\App\User::find($schedule->data['n1_p2_instructor'])->fullname()); - \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 ".\App\User::find($original->data['n2_p1_instructor'])->fullname()." à ".\App\User::find($schedule->data['n2_p1_instructor'])->fullname()); - \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 ".\App\User::find($original->data['n2_p2_instructor'])->fullname()." à ".\App\User::find($schedule->data['n2_p2_instructor'])->fullname()); - \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 ".\App\User::find($original->data['n3_p1_instructor'])->fullname()." à ".\App\User::find($schedule->data['n3_p1_instructor'])->fullname()); - \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 ".\App\User::find($original->data['n3_p2_instructor'])->fullname()." à ".\App\User::find($schedule->data['n3_p2_instructor'])->fullname()); - \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'); - - } - - public function delete() - { - $id = request('id'); - - $schedule = Schedule::find($id); - - $schedule->delete(); - - \Notification::send($userToNotify, new Alert(\Auth::User()->id,"Suppresion de l'activité, ".$schedule->data['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(),"Suppression d'une activité a l'horaire",\Auth::User()->fullname()." à supprimé l'activité, ".$schedule->data['event_name']." à l'horaire le ".$schedule->date)); - } - - - } - - private function listClass() - { - $schedules = \App\Schedule::all(); - $filtered_schedules = collect(); - $classes = []; - - foreach($schedules as $schedule) - { - if($schedule->type == "regular") - { - $filtered_schedules->push($schedule); - } - } - - foreach($filtered_schedules as $schedule) - { - array_push($classes,$schedule->data['n1_p1_ocom']); - array_push($classes,$schedule->data['n1_p2_ocom']); - array_push($classes,$schedule->data['n2_p1_ocom']); - array_push($classes,$schedule->data['n2_p2_ocom']); - array_push($classes,$schedule->data['n3_p1_ocom']); - array_push($classes,$schedule->data['n3_p2_ocom']); - } - - $filtered_classes = array_unique($classes); - - return $filtered_classes; - } - - public function show() - { - $date = request('date'); - return view('admin.calendar.modal.show',['schedules' => \App\Schedule::all()->where('date',$date),'date' => $date]); + $event = \App\Event::allThisYear()->sortBy('date_begin')->filter(function ($value,$key) { + return $value->hidden != 1; + }); + return view('admin.schedule.table.index',['events' => $event]); } } diff --git a/app/Http/Controllers/EventController.php b/app/Http/Controllers/EventController.php index 6bf5fb62..b256bf46 100644 --- a/app/Http/Controllers/EventController.php +++ b/app/Http/Controllers/EventController.php @@ -100,6 +100,15 @@ class EventController extends Controller $event->use_schedule = 0; } + if(\request("hidden")) + { + $event->hidden = 1; + } + else + { + $event->hidden = 0; + } + $event->calendar_color = \request('calendar_color'); $event->calendar_icon = \request('calendar_icon'); @@ -146,7 +155,11 @@ class EventController extends Controller } } - $course->user_id = $instructor; + if ($instructor == null) { + $course->user_id = ''; + } else { + $course->user_id = $instructor; + } if (request('location_n'.$l.'_p'.$p) != null) { $course->location = request('location_n'.$l.'_p'.$p); } else { @@ -159,8 +172,16 @@ class EventController extends Controller if(\request("use_course_n".$l."_p".$p) == 'on') { - $course->name = request('name_n'.$l.'_p'.$p); - $course->ocom = request('ocom_n'.$l.'_p'.$p); + if (request('name_n'.$l.'_p'.$p) == null) { + $course->name = ""; + } else { + $course->name = request('name_n'.$l.'_p'.$p); + } + if (request('ocom_n'.$l.'_p'.$p) == null) { + $course->ocom = ""; + } else { + $course->ocom = request('ocom_n'.$l.'_p'.$p); + } $course->desc = ""; } else @@ -213,7 +234,15 @@ class EventController extends Controller */ public function edit($id) { - return view('admin.schedule.event.edit',['event' => \App\Event::find($id)]); + $event = \App\Event::find($id); + if ($event->hidden == 1) + { + if (\Auth::user()->p('instruction_see_hidden_event') != 1) + { + return redirect('/admin/schedule')->with('error','Modification non authorisé'); + } + } + return view('admin.schedule.event.edit',['event' => $event]); } /** @@ -226,6 +255,13 @@ class EventController extends Controller public function update($id) { $event = Event::findOrFail($id); + if ($event->hidden == 1) + { + if (\Auth::user()->p('instruction_see_hidden_event') != 1) + { + return redirect('/admin/schedule')->with('error','Modification non authorisé'); + } + } // if (\App\GoogleDriveFile::checkConfig()) // { @@ -285,6 +321,15 @@ class EventController extends Controller $event->use_schedule = 0; } + if(\request("hidden")) + { + $event->hidden = 1; + } + else + { + $event->hidden = 0; + } + $event->calendar_color = \request('calendar_color'); $event->calendar_icon = \request('calendar_icon'); @@ -334,8 +379,16 @@ class EventController extends Controller $instructor = $user->id; } } - $course->user_id = $instructor; - $course->location = request('location_n'.$l.'_p'.$p); + if ($instructor == null) { + $course->user_id = ""; + } else { + $course->user_id = $instructor; + } + if (request('location_n'.$l.'_p'.$p) == null) { + $course->location = ""; + } else { + $course->location = request('location_n'.$l.'_p'.$p); + } $course->periode = $p; $course->level = $l; diff --git a/app/Http/Controllers/EventTypeController.php b/app/Http/Controllers/EventTypeController.php index 2f327fe7..717eb3a8 100644 --- a/app/Http/Controllers/EventTypeController.php +++ b/app/Http/Controllers/EventTypeController.php @@ -62,6 +62,14 @@ class EventTypeController extends Controller { $eventType->use_schedule = 0; } + if(\request("hidden")) + { + $eventType->hidden = 1; + } + else + { + $eventType->hidden = 0; + } if ($request->is_mandatory == 'on') { $eventType->is_mandatory = 1; @@ -174,6 +182,14 @@ class EventTypeController extends Controller { $eventType->use_schedule = 0; } + if(\request("hidden")) + { + $eventType->hidden = 1; + } + else + { + $eventType->hidden = 0; + } if ($request->is_mandatory == 'on') { $eventType->is_mandatory = 1; diff --git a/app/Http/Controllers/ScheduleController.php b/app/Http/Controllers/ScheduleController.php index 5722d60c..9f9b5e95 100644 --- a/app/Http/Controllers/ScheduleController.php +++ b/app/Http/Controllers/ScheduleController.php @@ -46,11 +46,28 @@ class ScheduleController extends Controller } foreach ($allevents as $event) { - if(strtotime($event->date_begin) >= $start && strtotime($event->date_begin) <= $end) { - array_push($events,$event); + if ($event->hidden == 1) { + if (\Auth::check()) + { + if (\Auth::user()->p('instruction_see_hidden_event') == 1) + { + if(strtotime($event->date_begin) >= $start && strtotime($event->date_begin) <= $end) { + array_push($events,$event); + } + else if(strtotime($event->date_end) >= $start && strtotime($event->date_end) <= $end) { + array_push($events,$event); + } + } + } } - else if(strtotime($event->date_end) >= $start && strtotime($event->date_end) <= $end) { - array_push($events,$event); + else + { + if(strtotime($event->date_begin) >= $start && strtotime($event->date_begin) <= $end) { + array_push($events,$event); + } + else if(strtotime($event->date_end) >= $start && strtotime($event->date_end) <= $end) { + array_push($events,$event); + } } } @@ -90,8 +107,16 @@ class ScheduleController extends Controller $icon = $event->calendar_icon; } + $name = $event->name; + + if ($event->hidden == 1) { + $color = $this->hex2rgba($color,0.5); + $icon = 'fas fa-eye-slash'; + $name = 'Caché - '.$name; + } + $myevent = [ - 'title' => $event->name, + 'title' => $name, 'start' => date('c',strtotime($event->date_begin)), 'end' => date('c',strtotime($event->date_end)), 'color' => $color, @@ -106,6 +131,45 @@ class ScheduleController extends Controller return json_encode($jsonevents); } + function hex2rgba($color, $opacity = false) { + + $default = 'rgb(0,0,0)'; + + //Return default if no color provided + if(empty($color)) + return $default; + + //Sanitize $color if "#" is provided + if ($color[0] == '#' ) { + $color = substr( $color, 1 ); + } + + //Check if color has 6 or 3 characters and get values + if (strlen($color) == 6) { + $hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] ); + } elseif ( strlen( $color ) == 3 ) { + $hex = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] ); + } else { + return $default; + } + + //Convert hexadec to rgb + $rgb = array_map('hexdec', $hex); + + //Check if opacity is set(rgba or rgb) + if($opacity){ + if(abs($opacity) > 1) + $opacity = 1.0; + $output = 'rgba('.implode(",",$rgb).','.$opacity.')'; + } else { + $output = 'rgb('.implode(",",$rgb).')'; + } + + //Return rgb(a) color string + return $output; + } + + public function loadModal($id,$db_type) { if($db_type == "event") @@ -216,6 +280,13 @@ class ScheduleController extends Controller public function delete($id) { $event = \App\Event::find($id); + if ($event->hidden == 1) + { + if (\Auth::user()->p('instruction_see_hidden_event') != 1) + { + abort(403); + } + } foreach ($event->courses as $course) { $course->delete(); diff --git a/app/Permission.php b/app/Permission.php index a7609aba..3c08747a 100644 --- a/app/Permission.php +++ b/app/Permission.php @@ -16,7 +16,7 @@ use Illuminate\Support\Arr; class Permission extends Model { const PERMISSIONS = [ - 'news' => [ + 'Nouvelle' => [ 'news_see' => [ 'ckey' => 'news_see', 'communName' => 'Voir les nouvelles', @@ -46,7 +46,7 @@ class Permission extends Model 'valeur' => 0 ] ], - 'inventory' => [ + 'Inventaire' => [ 'inventory_see' => [ 'ckey' => 'inventory_see', 'communName' => 'Voir l\'inventaire', @@ -76,7 +76,7 @@ class Permission extends Model 'valeur' => 0 ], ], - 'user' => [ + 'Utilisateur' => [ 'user_see' => [ 'ckey' => 'user_see', 'communName' => 'Voir la liste des utilisateurs', @@ -106,7 +106,7 @@ class Permission extends Model 'valeur' => 0 ], ], - 'config' => [ + 'Configuration' => [ 'config_see' => [ 'ckey' => 'config_see', 'communName' => 'Voir les configurations', @@ -116,13 +116,48 @@ class Permission extends Model ], 'config_edit' => [ 'ckey' => 'config_edit', - 'communName' => 'Modifier les configurations', - 'desc' => 'L\'utilisateur peut-il modifier les configurations', + 'communName' => 'Modifier les configurations générales', + 'desc' => 'L\'utilisateur peut-il modifier les configurations générales', + 'icon' => 'fa-eye', + 'valeur' => 0 + ], + 'config_edit_instruction' => [ + 'ckey' => 'config_edit_instruction', + 'communName' => 'Modifier les configurations de l\'instruction', + 'desc' => 'L\'utilisateur peut-il modifier les configurations de l\'instruction', + 'icon' => 'fa-eye', + 'valeur' => 0 + ], + 'config_edit_administration' => [ + 'ckey' => 'config_edit_administration', + 'communName' => 'Modifier les configurations de l\'administration', + 'desc' => 'L\'utilisateur peut-il modifier les configurations de l\'administration', + 'icon' => 'fa-eye', + 'valeur' => 0 + ], + 'config_edit_rank' => [ + 'ckey' => 'config_edit_rank', + 'communName' => 'Modifier les configurations des grades', + 'desc' => 'L\'utilisateur peut-il modifier les configurations des grades', + 'icon' => 'fa-eye', + 'valeur' => 0 + ], + 'config_edit_job' => [ + 'ckey' => 'config_edit_job', + 'communName' => 'Modifier les configurations des postes', + 'desc' => 'L\'utilisateur peut-il modifier les configurations des postes', + 'icon' => 'fa-eye', + 'valeur' => 0 + ], + 'config_edit_customization' => [ + 'ckey' => 'config_edit_customization', + 'communName' => 'Modifier les configurations de l\'apparence du site', + 'desc' => 'L\'utilisateur peut-il modifier les configurations de l\'apparence du site', 'icon' => 'fa-eye', 'valeur' => 0 ] ], - 'statistique' => [ + 'Statistique' => [ 'stats_see' => [ 'ckey' => 'stats_see', 'communName' => 'Voir les statistiques', @@ -195,6 +230,20 @@ class Permission extends Model 'icon' => 'fa-eye', 'valeur' => 0 ], + 'stats_instruction_see' => [ + 'ckey' => 'stats_instruction_see', + 'communName' => 'Voir les statistiques de l\'instruction', + 'desc' => 'L\'utilisateur peut-il voir les statistiques de l\'instruction', + 'icon' => 'fa-eye', + 'valeur' => 0 + ], + 'instruction_see_hidden_event' => [ + 'ckey' => 'instruction_see_hidden_event', + 'communName' => 'Voir les évenements cachés', + 'desc' => 'L\'utilisateur peut-il voir les évenements cachés', + 'icon' => 'fa-eye', + 'valeur' => 0 + ], ], 'Administration' => [ 'cadet_list_see' => [ @@ -235,7 +284,7 @@ class Permission extends Model 'valeur' => 0 ] ], - 'article' => [ + 'Articles' => [ 'article_see' => [ 'ckey' => 'article_see', 'communName' => 'Voir les articles', @@ -265,7 +314,7 @@ class Permission extends Model 'valeur' => 0 ], ], - 'picture' => [ + 'Photos & Images' => [ 'picture_see' => [ 'ckey' => 'picture_see', 'communName' => 'Voir les images', @@ -295,7 +344,7 @@ class Permission extends Model 'valeur' => 0 ], ], - 'file' => [ + 'Fichiers' => [ 'file_see' => [ 'ckey' => 'file_see', 'communName' => 'Voir les fichiers publiques', @@ -346,6 +395,11 @@ class Permission extends Model return self::PERMISSIONS; } + public static function allToJSON() + { + return self::all()->toJson(); + } + public static function allToString($value = null) { $perm = []; diff --git a/database/migrations/2019_08_17_102431_create_events_table.php b/database/migrations/2019_08_17_102431_create_events_table.php index 3a00ebaf..dfb9596c 100644 --- a/database/migrations/2019_08_17_102431_create_events_table.php +++ b/database/migrations/2019_08_17_102431_create_events_table.php @@ -31,6 +31,7 @@ class CreateEventsTable extends Migration $table->string('calendar_color'); $table->string('calendar_icon'); $table->string('weekly_msg_publication_time')->default('-5day'); + $table->boolean('hidden')->default(0); $table->timestamps(); }); } diff --git a/database/migrations/2019_12_22_145445_create_event_types_table.php b/database/migrations/2019_12_22_145445_create_event_types_table.php index 0c33fdf3..a8c494f9 100644 --- a/database/migrations/2019_12_22_145445_create_event_types_table.php +++ b/database/migrations/2019_12_22_145445_create_event_types_table.php @@ -28,6 +28,7 @@ class CreateEventTypesTable extends Migration $table->boolean('use_schedule')->default(false); $table->text('schedule_model'); $table->boolean('is_promoted')->default(false); + $table->boolean('hidden')->default(false); $table->timestamps(); }); } diff --git a/public/css/custom.css b/public/css/custom.css index a648f115..e8c53df6 100644 --- a/public/css/custom.css +++ b/public/css/custom.css @@ -243,6 +243,19 @@ height: 3rem; overflow: hidden; } + +.schedule-table-ocom { + width: 200rem; +} + +.table-borderless > tbody > tr > td { + border: none !important; +} + +.schedule-table-week > td { + border: lightgrey 2px solid; +} + .autocomplete-items { position: absolute; border: 1px solid #d4d4d4; diff --git a/public/js/calendar.js b/public/js/calendar.js index 9d073388..64ef6cc3 100644 --- a/public/js/calendar.js +++ b/public/js/calendar.js @@ -19,7 +19,7 @@ function initFullCalendar(authToken) { right: 'prev,next' }, defaultDate: initDate, - events: '/api/schedule/events', + events: '/api/schedule/events/auth?api_token='+authToken, eventRender: function(event, element) { if (event.event.extendedProps.icon && event.view.type == 'dayGridMonth') { @@ -130,22 +130,32 @@ function deleteEvent(pid){ if (result.value) { (function($) { - $.post('/api/schedule/event/delete/'+pid+'?api_token='+api_token, function(data) { - console.log('Delete'); + $.post('/api/schedule/event/delete/'+pid+'?api_token='+api_token, function(data, status, xhr) { + swal( + 'Supprimé!', + "L'évenement a été supprimé", + 'success' + ).then((result) => { + if (result.value) { + location.reload(); + } + }) + }).fail(function (data, status, xhr) { + if (xhr == 'Forbidden') { + swal( + 'Oups!', + "Vous n'avez pas les permissions nécessaires...", + 'error' + ).then((result) => { + if (result.value) { + location.reload(); + } + }) + } }); })(jQuery); - - swal( - 'Supprimé!', - "L'évenement a été supprimé", - 'success' - ).then((result) => { - if (result.value) { - location.reload(); - } - }) } }) } diff --git a/public/js/plugins/schedule/editorv2.js b/public/js/plugins/schedule/editorv2.js index 037fd75d..a8de7910 100644 --- a/public/js/plugins/schedule/editorv2.js +++ b/public/js/plugins/schedule/editorv2.js @@ -488,6 +488,15 @@ function loadEventType(date,id = 1) switchUseSchedule(); } + if (eventType['hidden'] == 1) + { + $('#hidden').prop('checked',true); + } + else + { + $('#hidden').removeAttr('checked'); + } + if (eventType['use_weekly_msg'] == 1) { $('#use_weekly_msg').prop('checked',true); @@ -604,6 +613,15 @@ function loadEvent(date,id) switchUseSchedule(); } + if (eventType['hidden'] == 1) + { + $('#hidden').prop('checked',true); + } + else + { + $('#hidden').removeAttr('checked'); + } + if (eventType['use_weekly_msg'] == 1) { $('#use_weekly_msg').prop('checked',true); diff --git a/resources/custom.css b/resources/custom.css index a648f115..e8c53df6 100644 --- a/resources/custom.css +++ b/resources/custom.css @@ -243,6 +243,19 @@ height: 3rem; overflow: hidden; } + +.schedule-table-ocom { + width: 200rem; +} + +.table-borderless > tbody > tr > td { + border: none !important; +} + +.schedule-table-week > td { + border: lightgrey 2px solid; +} + .autocomplete-items { position: absolute; border: 1px solid #d4d4d4; diff --git a/resources/views/admin/calendar/calendar_display.blade.php b/resources/views/admin/calendar/calendar_display.blade.php index aa524fa2..92d5b4a3 100644 --- a/resources/views/admin/calendar/calendar_display.blade.php +++ b/resources/views/admin/calendar/calendar_display.blade.php @@ -1,6 +1,11 @@ @extends('layouts.admin.main') @section('content') +
diff --git a/resources/views/admin/configs/ranks/add.blade.php b/resources/views/admin/configs/ranks/add.blade.php index fd262bde..a9a3d3a9 100644 --- a/resources/views/admin/configs/ranks/add.blade.php +++ b/resources/views/admin/configs/ranks/add.blade.php @@ -31,41 +31,34 @@

Choisissez quels permissions doivent être associé avec ce grade.

-
+ + + + + + + @foreach(\App\Permission::allToArray() as $key => $cat) -
- - -
-
-
- @foreach($cat as $r) -
- -
{{$r['communName']}}
-
- - - -
-

- {{$r['desc']}} -

-
- @endforeach + @foreach($cat as $r) +
+ + + + + @endforeach @endforeach - + +
CatNom
{{$key}} + + {{$r['communName']}}
+ {{$r['desc']}} +
+
+ + +
- - - +
@@ -83,5 +76,17 @@ $('#desc').trumbowyg({ lang: 'fr' }); + $(document).ready(function() { + $('#permission-table').DataTable({ + rowGroup: { + dataSrc: 0 + }, + pageLength: 100, + lengthChange: false, + columnDefs: [ + { "visible": false, "targets": [0] } + ] + }); + } ); @endsection \ No newline at end of file diff --git a/resources/views/admin/configs/ranks/show.blade.php b/resources/views/admin/configs/ranks/show.blade.php index 58822c77..27eca320 100644 --- a/resources/views/admin/configs/ranks/show.blade.php +++ b/resources/views/admin/configs/ranks/show.blade.php @@ -31,7 +31,41 @@

Choisissez quels permissions doivent être associé avec ce grade.

-
+ + + + + + + + @foreach(\App\Permission::allToArray() as $key => $cat) + @foreach($cat as $r) + + + + + + @endforeach + @endforeach + +
CatNom
{{$key}} + + {{$r['communName']}}
+ {{$r['desc']}} +
+
+ + +
+
+ {{--
@foreach(\App\Permission::allToArray() as $key => $cat)

{{$key}}

@@ -56,12 +90,11 @@
-
@endforeach
@endforeach -
+
--}}
@@ -79,5 +112,17 @@ $('#desc').trumbowyg({ lang: 'fr' }); + $(document).ready(function() { + $('#permission-table').DataTable({ + rowGroup: { + dataSrc: 0 + }, + pageLength: 100, + lengthChange: false, + columnDefs: [ + { "visible": false, "targets": [0] } + ] + }); + } ); @endsection \ No newline at end of file diff --git a/resources/views/admin/dashboard.blade.php b/resources/views/admin/dashboard.blade.php index 10bbba9e..60a635eb 100644 --- a/resources/views/admin/dashboard.blade.php +++ b/resources/views/admin/dashboard.blade.php @@ -69,7 +69,7 @@ @else @foreach ($futureEvent as $event)
-
+

@if($event->calendar_icon == null) {!! \App\ComplementaryActivity::find($event->type)->calendar_icon !!} @else @endif

diff --git a/resources/views/admin/event_type/create.blade.php b/resources/views/admin/event_type/create.blade.php index 02e30f9f..93757360 100644 --- a/resources/views/admin/event_type/create.blade.php +++ b/resources/views/admin/event_type/create.blade.php @@ -11,13 +11,13 @@
@csrf
-
+
-
+
@@ -32,6 +32,15 @@
+
+
+ +
+
diff --git a/resources/views/admin/event_type/show.blade.php b/resources/views/admin/event_type/show.blade.php index cfd03c58..d8cf75b9 100644 --- a/resources/views/admin/event_type/show.blade.php +++ b/resources/views/admin/event_type/show.blade.php @@ -12,13 +12,13 @@ @method('PATCH') @csrf
-
+
-
+
@@ -33,6 +33,15 @@
+
+
+ +
+
diff --git a/resources/views/admin/job/add.blade.php b/resources/views/admin/job/add.blade.php index 02ba8049..04e0250e 100644 --- a/resources/views/admin/job/add.blade.php +++ b/resources/views/admin/job/add.blade.php @@ -31,7 +31,35 @@

Choisissez quels permissions doivent être associé avec ce poste.

-
+ + + + + + + + @foreach(\App\Permission::allToArray() as $key => $cat) + @foreach($cat as $r) + + + + + + @endforeach + @endforeach + +
CatNom
{{$key}} + + {{$r['communName']}}
+ {{$r['desc']}} +
+
+ + + +
+
+ {{--
@foreach(\App\Permission::allToArray() as $key => $cat)
@endforeach -
+
--}}
@@ -83,5 +111,17 @@ $('#desc').trumbowyg({ lang: 'fr' }); + $(document).ready(function() { + $('#permission-table').DataTable({ + rowGroup: { + dataSrc: 0 + }, + pageLength: 100, + lengthChange: false, + columnDefs: [ + { "visible": false, "targets": [0] } + ] + }); + } ); @endsection \ No newline at end of file diff --git a/resources/views/admin/job/edit.blade.php b/resources/views/admin/job/edit.blade.php index e628e8fa..07c481cc 100644 --- a/resources/views/admin/job/edit.blade.php +++ b/resources/views/admin/job/edit.blade.php @@ -31,7 +31,35 @@

Choisissez quels permissions doivent être associé avec ce poste.

-
+ + + + + + + + @foreach(\App\Permission::allToArray() as $key => $cat) + @foreach($cat as $r) + + + + + + @endforeach + @endforeach + +
CatNom
{{$key}} + + {{$r['communName']}}
+ {{$r['desc']}} +
+
+ + + +
+
+ {{--
@foreach(\App\Permission::allToArray() as $key => $cat)
@endforeach -
+
--}}
@@ -83,5 +111,17 @@ $('#desc').trumbowyg({ lang: 'fr' }); + $(document).ready(function() { + $('#permission-table').DataTable({ + rowGroup: { + dataSrc: 0 + }, + pageLength: 100, + lengthChange: false, + columnDefs: [ + { "visible": false, "targets": [0] } + ] + }); + } ); @endsection \ No newline at end of file diff --git a/resources/views/admin/schedule/event/add.blade.php b/resources/views/admin/schedule/event/add.blade.php index 27184777..9960175b 100644 --- a/resources/views/admin/schedule/event/add.blade.php +++ b/resources/views/admin/schedule/event/add.blade.php @@ -157,6 +157,17 @@
+
+ + L'évenement doit t-il être caché? +
+ +
+
+
+ + L'évenement doit t-il être caché? +
+ +
+