1
@@ -64,7 +64,7 @@ @foreach($ocom->courses() as $course)diff --git a/app/Course.php b/app/Course.php index b1936890..6f5c241f 100644 --- a/app/Course.php +++ b/app/Course.php @@ -59,19 +59,27 @@ class Course extends Model public function instructor() { - if (\App\User::find($this->user_id)) - { + if (\App\User::find($this->user_id)) { return \App\User::find($this->user_id)->fullname(); - } - else - { + } else { return $this->user_id; } } + public function ocom() + { + if ($this->ocom != null) { + $ocom = \App\OCOM::findByOCOM($this->ocom); + if ($ocom != null) { + return $ocom; + } + } + return null; + } + public function event() { - return $this->belongsTo('App\Event'); + return $this->belongsTo('App\Event'); } public function logs() @@ -92,10 +100,8 @@ class Course extends Model public static function allFuture() { $courses = Course::all(); - foreach ($courses as $key => $course) - { - if (date('c',strtotime($course->event->date_begin)) <= date('c')) - { + foreach ($courses as $key => $course) { + if (date('c', strtotime($course->event->date_begin)) <= date('c')) { $courses->forget($key); } } @@ -105,14 +111,11 @@ class Course extends Model public static function allThisYear() { $courses = Course::all(); - foreach ($courses as $key => $course) - { - if (date('c',strtotime($course->event->date_begin)) <= date('c',strtotime(\App\Config::getData('instruction_year_begin')))) - { + foreach ($courses as $key => $course) { + if (date('c', strtotime($course->event->date_begin)) <= date('c', strtotime(\App\Config::getData('instruction_year_begin')))) { $courses->forget($key); } - if (date('c',strtotime($course->event->date_begin)) >= date('c',strtotime(\App\Config::getData('instruction_year_end')))) - { + if (date('c', strtotime($course->event->date_begin)) >= date('c', strtotime(\App\Config::getData('instruction_year_end')))) { $courses->forget($key); } } @@ -122,10 +125,8 @@ class Course extends Model public static function allForUser($user_id) { $courses = Course::all(); - foreach ($courses as $key => $course) - { - if ($course->user_id != $user_id) - { + foreach ($courses as $key => $course) { + if ($course->user_id != $user_id) { $courses->forget($key); } } @@ -140,14 +141,11 @@ class Course extends Model public static function allFutureForUser($user_id) { $courses = Course::all(); - foreach ($courses as $key => $course) - { - if (date('c',strtotime($course->event->date_begin)) <= date('c')) - { + foreach ($courses as $key => $course) { + if (date('c', strtotime($course->event->date_begin)) <= date('c')) { $courses->forget($key); } - if ($course->user_id != $user_id) - { + if ($course->user_id != $user_id) { $courses->forget($key); } } diff --git a/app/Event.php b/app/Event.php index 3f117be8..346b71d2 100644 --- a/app/Event.php +++ b/app/Event.php @@ -73,6 +73,11 @@ class Event extends Model return $this->hasMany('App\Course'); } + public function type() + { + return \App\EventType::find($this->type); + } + public function user() { return $this->belongsTo('App\User'); @@ -129,73 +134,13 @@ class Event extends Model return $events; } - public static function checkForError() + public function nbPeriode() { - $events = Event::all(); + return (count($this->schedule["periodes"])); + } - $warning = []; - $danger = []; - - foreach ($events as $event) - { - if($event->date_begin == null) - { - array_push($warning,'Évènement ID:'.$event->id.' - "date_begin", Incorrect'); - } - if($event->date_end == null) - { - array_push($warning,'Évènement ID:'.$event->id.' - "date_end", Incorrect'); - } - if($event->type == null || $event->type == "" || !\App\EventType::all()->has($event->type)) - { - $event->type = 1; - //$event->save(); - array_push($warning,'Évènement ID:'.$event->id.' - "type", Incorrect... Réinitialisé à la valeur par défaut'); - clog('error','danger','Évènement ID:'.$event->id.' - "type", Incorrect... Réinitialisé à la valeur par défaut'); - } - if($event->is_mandatory == null && $event->is_mandatory != 0) - { - array_push($warning,'Évènement ID:'.$event->id.' - "is_mandatory", Incorrect... Réinitialisé à la valeur par défaut'); - clog('error','danger','Évènement ID:'.$event->id.' - "is_mandatory", Incorrect... Réinitialisé à la valeur par défaut'); - } - if($event->use_weekly_msg == null && $event->use_weekly_msg != 0) - { - array_push($warning,'Évènement ID:'.$event->id.' - "use_weekly_msg", Incorrect... Réinitialisé à la valeur par défaut'); - clog('error','danger','Évènement ID:'.$event->id.' - "use_weekly_msg", Incorrect... Réinitialisé à la valeur par défaut'); - } - if($event->use_schedule == null && $event->use_schedule != 0) - { - array_push($warning,'Évènement ID:'.$event->id.' - "use_schedule", Incorrect... Réinitialisé à la valeur par défaut'); - clog('error','danger','Évènement ID:'.$event->id.' - "use_schedule", Incorrect... Réinitialisé à la valeur par défaut'); - } - if($event->schedule == null) - { - $event->schedule = '{"periodes":[{"name":"Periode 1","begin_time":"19:00","end_time":"20:10"},{"name":"Periode 2","begin_time":"20:30","end_time":"21:20"}],"niveaux":[{"name":"Niveau 1"},{"name":"Niveau 2"},{"name":"Niveau 3"}]}'; - $event->save(); - array_push($warning,'Évènement ID:'.$event->id.' - "schedule", Incorrect... Réinitialisé à la valeur par défaut'); - clog('error','danger','Évènement ID:'.$event->id.' - "schedule", Incorrect... Réinitialisé à la valeur par défaut'); - } - if($event->location == null || $event->location == "") - { - array_push($warning,'Évènement ID:'.$event->id.' - "location", Incorrect... Réinitialisé à la valeur par défaut'); - clog('error','danger','Évènement ID:'.$event->id.' - "location", Incorrect... Réinitialisé à la valeur par défaut'); - } - if($event->calendar_color == null || $event->calendar_color == "") - { - $event->calendar_color = '#A4A4A4'; - $event->save(); - array_push($warning,'Évènement ID:'.$event->id.' - "calendar_color", Incorrect... Réinitialisé à la valeur par défaut'); - clog('error','danger','Évènement ID:'.$event->id.' - "calendar_color", Incorrect... Réinitialisé à la valeur par défaut'); - } - if($event->calendar_icon == null || $event->calendar_icon == "") - { - $event->calendar_icon = 'fas fa-book'; - $event->save(); - array_push($warning,'Évènement ID:'.$event->id.' - "calendar_icon", Incorrect... Réinitialisé à la valeur par défaut'); - clog('error','danger','Évènement ID:'.$event->id.' - "calendar_icon", Incorrect... Réinitialisé à la valeur par défaut'); - } - } - - return [$warning,$danger]; + public function nbNiveau() + { + return count($this->schedule["niveaux"]); } } diff --git a/app/Http/Controllers/CourseController.php b/app/Http/Controllers/CourseController.php index 3be9ccb5..68ef3092 100644 --- a/app/Http/Controllers/CourseController.php +++ b/app/Http/Controllers/CourseController.php @@ -25,6 +25,13 @@ class CourseController extends Controller { $courses = Course::allFuture(); } + foreach ($courses as $course) + { + if($course->ocom() != null) + { + $course->ocom()->updateWasGiven(); + } + } return view('admin.course.index',['courses' => $courses,'mode' => $mode]); } diff --git a/app/Http/Controllers/EventController.php b/app/Http/Controllers/EventController.php index 26faf837..801ccf98 100644 --- a/app/Http/Controllers/EventController.php +++ b/app/Http/Controllers/EventController.php @@ -2,7 +2,9 @@ namespace App\Http\Controllers; +use App\Course; use App\Event; +use App\EventType; use App\GoogleDriveFile; use Illuminate\Http\Request; use Illuminate\Http\Response; @@ -57,6 +59,8 @@ class EventController extends Controller { $event->weekly_msg_file = ['']; } + } else { + $event->weekly_msg_file = ['']; } $event->name = request('name'); @@ -77,11 +81,13 @@ class EventController extends Controller if(\request("use_weekly_msg")) { $event->use_weekly_msg = 1; + $event->weekly_msg_publication_time = \request('date_msg'); $event->msg = request('admin_desc'); } else { $event->use_weekly_msg = 0; + $event->weekly_msg_publication_time = ""; $event->msg = ""; } @@ -203,7 +209,7 @@ class EventController extends Controller */ public function edit($id) { - return view('admin.schedule.event.edit',['activity' => \App\Event::find($id)]); + return view('admin.schedule.event.edit',['event' => \App\Event::find($id)]); } /** @@ -215,51 +221,104 @@ class EventController extends Controller */ public function update($id) { - $event = Event::find($id); + $event = Event::findOrFail($id); + +// if (\App\GoogleDriveFile::checkConfig()) +// { +// if (\request()->hasFile('files')) +// { +// $dir = \App\GoogleDriveFile::findByPath('.Systeme/.Fichier/.MessageDeLaSemaine'); +// $files = []; +// foreach (\request()->file('files') as $f) +// { +// $name = urlencode(pathinfo($f->getClientOriginalName())['filename'].'_'.uniqid().'.'.$f->getClientOriginalExtension()); +// \Storage::cloud()->putFileAs($dir->id,$f,$name); +// array_push($files,$name); +// } +// $event->weekly_msg_file = $files; +// } +// else +// { +// $event->weekly_msg_file = ['']; +// } +// } else { +// $event->weekly_msg_file = ['']; +// } $event->name = request('name'); - $event->date_begin = request('begin'); - $event->date_end = request('end'); + $event->date_begin = request('begin_time'); + $event->date_end = request('end_time'); + $event->user_id = \Auth::user()->id; $event->location = request('location'); + if(request('is_mandatory') != null){ $event->is_mandatory = 1; } else { $event->is_mandatory = 0; } - $event->desc = request('desc'); - if(\request('msg')) + + $event->desc = \request('admin_desc'); + + if(\request("use_weekly_msg")) { - $event->msg = request('msg'); + $event->use_weekly_msg = 1; + $event->weekly_msg_publication_time = \request('date_msg'); + $event->msg = request('admin_desc'); } else { + $event->use_weekly_msg = 0; + $event->weekly_msg_publication_time = ""; $event->msg = ""; } - if(\request('date_msg')) + + if(\request("use_schedule")) { - $event->date_msg = request('date_msg'); + $event->use_schedule = 1; } else { - $event->date_msg = ""; + $event->use_schedule = 0; } + + $event->calendar_color = \request('calendar_color'); + $event->calendar_icon = \request('calendar_icon'); + + $nbLevel = 1; + $niveaux = []; + while (\request('level_name_'.$nbLevel)) + { + array_push($niveaux,['name' => \request('level_name_'.$nbLevel)]); + $nbLevel++; + } + + $nbPeriode = 1; + $periodes = []; + while (\request('periode_name_'.$nbPeriode)) + { + array_push($periodes,[ + 'name' => \request('periode_name_'.$nbPeriode), + 'begin_time' => \request('periode_begin_time_'.$nbPeriode), + 'end_time' => \request('periode_end_time_'.$nbPeriode) + ]); + $nbPeriode++; + } + $event->schedule = [ + 'periodes' => $periodes, + 'niveaux' => $niveaux, + 'courses' => [] + ]; + $event->save(); - if ($event->type == 1) { - for ($l=1; $l <= \App\Config::getData('admin_level_in_schedule_nb'); $l++) { - for ($p=1; $p <= \App\Config::getData('admin_periode_nb'); $p++) { + if ($event->use_schedule) { + for ($l=1; $l < $nbLevel; $l++) { + for ($p=1; $p < $nbPeriode; $p++) { - $course = new \App\Course(); - - foreach ($event->courses as $c) + $course = $event->course($p,$l); + if ($course == null) { - if ($c->periode == $p) - { - if ($c->level == $l) - { - $course = $c; - } - } + $course = new Course(); } $users = \App\User::all(); @@ -271,23 +330,48 @@ class EventController extends Controller $instructor = $user->id; } } - - $course->name = request('name_n'.$l.'_p'.$p); $course->user_id = $instructor; - $course->ocom = request('ocom_n'.$l.'_p'.$p); - $course->location = request('loc_n'.$l.'_p'.$p); + $course->location = request('location_n'.$l.'_p'.$p); $course->periode = $p; $course->level = $l; - $course->comment_officer = ""; - $course->comment = ""; + $course->event_id = $event->id; + 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); + $course->desc = ""; + } + else + { + $course->name = ""; + $course->ocom = ""; + if (request('desc_n'.$l.'_p'.$p) == null) + { + $course->desc = ""; + } + else + { + $course->desc = request('desc_n'.$l.'_p'.$p); + } + } + $course->comment_officer = ""; + $course->comment = ""; $course->save(); + + $ocom = \App\OCOM::where('ocom','=',request('ocom_n'.$l.'_p'.$p))->first(); + if ($ocom != null) + { + $foo = $ocom->courses(); + $foo->push($course); + $ocom->saveCourses($foo); + } } } } - clog('edit','success','a modifié un évènement',null,'App\Event',$event->id); - return redirect('/admin/schedule')->with('success','Modification à l\'événement sauvegarder à l\'horaire'); + clog('add','success','a modifier un évènement',null,'App\Event',$event->id); + return redirect('/admin/schedule')->with('success','Événement modifier à l\'horaire'); } /** @@ -305,4 +389,37 @@ class EventController extends Controller { // } + + public function toJson($id) + { + $event = Event::findOrFail($id); + $model = $event->schedule; + $default_value = []; + if ($event->use_schedule == 1) { + foreach ($model['periodes'] as $periode_index => $periode) + { + $niveau_array = []; + foreach ($model['niveaux'] as $niveau_index => $niveau) + { + $course = $event->course($periode_index+1,$niveau_index+1); + $use_course = "on"; + if ($course->name == null) { + $use_course = "off"; + } + array_push($niveau_array,[ + 'ocom' => $course->ocom, + 'name' => $course->name, + 'location' => $course->location, + 'instructor' => $course->instructor(), + 'desc' => $course->desc, + 'use_course' => $use_course + ]); + } + array_push($default_value,$niveau_array); + } + $model['default_value'] = $default_value; + } + $event->schedule_model = $model; + return $event->toArray(); + } } diff --git a/app/Http/Controllers/OCOMController.php b/app/Http/Controllers/OCOMController.php index 4a6fb879..9ba7f6e5 100644 --- a/app/Http/Controllers/OCOMController.php +++ b/app/Http/Controllers/OCOMController.php @@ -18,6 +18,7 @@ class OCOMController extends Controller */ public function index() { + OCOM::wasUpdateGivenAll(); return view('admin.ocom.index',['ocoms' => OCOM::all()]); } diff --git a/app/Http/Controllers/ScheduleEditorController.php b/app/Http/Controllers/ScheduleEditorController.php index 9c8840bd..9dfb6b80 100644 --- a/app/Http/Controllers/ScheduleEditorController.php +++ b/app/Http/Controllers/ScheduleEditorController.php @@ -63,53 +63,4 @@ class ScheduleEditorController extends Controller { return view('admin.schedule.editor.levelHeader',['level_id' => $id,'level_name' => 'Niveau '.$id]); } - - public function test() - { - $evenType = new \App\EventType(); - - $evenType->name = "Soirée d'instruction régulière"; - $evenType->admin_desc = "Veuillez modifier la description admin par défaut"; - $evenType->calendar_color = "orange"; - $evenType->calendar_icon = "fas fa-book"; - $evenType->begin_time = "12:00"; - $evenType->end_time = "18:00"; - $evenType->location = "Escadron"; - $evenType->is_mandatory = true; - $evenType->use_weekly_msg = true; - $evenType->weekly_msg_publication_time = "-5days"; - $evenType->use_schedule = true; - $evenType->schedule_model = [ - "periodes" => [ - 0 => [ - "name" => "Periode 1", - "begin_time" => "19:00", - "end_time" => "20:10" - ], - 1 => [ - "name" => "Pause", - "begin_time" => "20:10", - "end_time" => "20:30" - ], - 2 => [ - "name" => "Periode 2", - "begin_time" => "20:30", - "end_time" => "21:20" - ] - ], - "niveaux" => [ - 0 => [ - "name" => "Niveau 1" - ], - 1 => [ - "name" => "Niveau 2" - ], - 2 => [ - "name" => "Niveau 3" - ] - ] - ]; - $evenType->is_promoted = true; - //$evenType->save(); - } } diff --git a/app/News.php b/app/News.php index 6cdaac1b..edfef7f3 100644 --- a/app/News.php +++ b/app/News.php @@ -3,6 +3,7 @@ namespace App; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\Date; /** * App\News @@ -63,7 +64,10 @@ class News extends Model { if($event->use_weekly_msg == 1) { - $news->push(self::getWeeklyMsg($event)); + if (strtotime($event->weekly_msg_publication_time) <= time()) + { + $news->push(self::getWeeklyMsg($event)); + } } } diff --git a/app/OCOM.php b/app/OCOM.php index b5daf5ca..80c0a178 100644 --- a/app/OCOM.php +++ b/app/OCOM.php @@ -3,6 +3,7 @@ namespace App; use Illuminate\Database\Eloquent\Model; +use function GuzzleHttp\Promise\all; /** * App\OCOM @@ -72,40 +73,47 @@ class OCOM extends Model public function wasGiven() { - $courses = $this->courses(); + $courses = Course::where('ocom',$this->ocom)->get(); $result = collect(); - $from = strtotime(\App\Config::getData('instruction_year_begin')); $to = strtotime(\App\Config::getData('instruction_year_end')); foreach ($courses as $course) { - $event = null; - try { - $event = $course->event; - } - catch (\Exception $e) - { - // Nettoyer ? - break; - } + $event = $course->event; if (strtotime($event->date_begin) >= $from) { if (strtotime($event->date_begin) <= $to) { - $result->push($event); + $result->push($course->id); } } } - if ($result->isEmpty()) - { - return false; - } return $result; } + public function updateWasGiven() + { + $this->course_id = implode(",",$this->wasGiven()->toArray()); + $this->save(); + } + + public static function wasUpdateGivenAll() + { + $ocoms = OCOM::all(); + foreach ($ocoms as $o) + { + $o->updateWasGiven(); + } + } + public static function findByOCOM($ocom) { return OCOM::where('ocom','=',$ocom)->first(); } + + public function getDurationInMin() + { + return $this->nbPeriode * 30; + } } diff --git a/app/Providers/TelescopeServiceProvider.php b/app/Providers/TelescopeServiceProvider.php new file mode 100644 index 00000000..a9ddad22 --- /dev/null +++ b/app/Providers/TelescopeServiceProvider.php @@ -0,0 +1,71 @@ +hideSensitiveRequestDetails(); + + Telescope::filter(function (IncomingEntry $entry) { + if ($this->app->environment('local')) { + return true; + } + + return $entry->isReportableException() || + $entry->isFailedRequest() || + $entry->isFailedJob() || + $entry->isScheduledTask() || + $entry->hasMonitoredTag(); + }); + } + + /** + * Prevent sensitive request details from being logged by Telescope. + * + * @return void + */ + protected function hideSensitiveRequestDetails() + { + if ($this->app->environment('local')) { + return; + } + + Telescope::hideRequestParameters(['_token']); + + Telescope::hideRequestHeaders([ + 'cookie', + 'x-csrf-token', + 'x-xsrf-token', + ]); + } + + /** + * Register the Telescope gate. + * + * This gate determines who can access Telescope in non-local environments. + * + * @return void + */ + protected function gate() + { + Gate::define('viewTelescope', function ($user) { + return in_array($user->email, [ + // + ]); + }); + } +} diff --git a/composer.json b/composer.json index 02a8d1b3..f4768c77 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,7 @@ "laravel/framework": "^7.0", "laravel/helpers": "^1.1", "laravel/nexmo-notification-channel": "^2.2", + "laravel/telescope": "^3.5", "laravel/tinker": "^2.0", "laravel/ui": "^2.0", "nao-pon/flysystem-google-drive": "^1.1", diff --git a/composer.lock b/composer.lock index 25299fe9..a22989bc 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e2dc7086eb67a56fb816e262934a3a2a", + "content-hash": "1039ad9d19c53cf0ed27db80f8923088", "packages": [ { "name": "barryvdh/laravel-dompdf", @@ -2310,6 +2310,69 @@ ], "time": "2019-12-10T16:54:57+00:00" }, + { + "name": "laravel/telescope", + "version": "v3.5.1", + "source": { + "type": "git", + "url": "https://github.com/laravel/telescope.git", + "reference": "a8d2e1106ba655006fde47a0b7ed53851c6398f5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/telescope/zipball/a8d2e1106ba655006fde47a0b7ed53851c6398f5", + "reference": "a8d2e1106ba655006fde47a0b7ed53851c6398f5", + "shasum": "" + }, + "require": { + "ext-json": "*", + "laravel/framework": "^6.0|^7.0", + "moontoast/math": "^1.1", + "php": "^7.2", + "symfony/var-dumper": "^4.4|^5.0" + }, + "require-dev": { + "ext-gd": "*", + "orchestra/testbench": "^4.0|^5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + }, + "laravel": { + "providers": [ + "Laravel\\Telescope\\TelescopeServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Laravel\\Telescope\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + }, + { + "name": "Mohamed Said", + "email": "mohamed@laravel.com" + } + ], + "description": "An elegant debug assistant for the Laravel framework.", + "keywords": [ + "debugging", + "laravel", + "monitoring" + ], + "time": "2020-07-28T19:12:33+00:00" + }, { "name": "laravel/tinker", "version": "v2.4.0", @@ -2822,6 +2885,57 @@ ], "time": "2020-05-22T08:12:19+00:00" }, + { + "name": "moontoast/math", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/ramsey/moontoast-math.git", + "reference": "5f47d34c87767dbcc08b30377a9827df71de91fa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ramsey/moontoast-math/zipball/5f47d34c87767dbcc08b30377a9827df71de91fa", + "reference": "5f47d34c87767dbcc08b30377a9827df71de91fa", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpseclib/bcmath_compat": ">=1.0.3" + }, + "require-dev": { + "jakub-onderka/php-parallel-lint": "^0.9.0", + "phpunit/phpunit": "^4.8 || ^5.5 || ^6.5 || ^7.0", + "satooshi/php-coveralls": "^0.6.1", + "squizlabs/php_codesniffer": "^2.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Moontoast\\Math\\": "src/Moontoast/Math", + "Moontoast\\Math\\Exception\\": "src/Moontoast/Math/Exception" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Ben Ramsey", + "email": "ben@benramsey.com", + "homepage": "https://benramsey.com" + } + ], + "description": "A mathematics library, providing functionality for large numbers", + "homepage": "https://github.com/ramsey/moontoast-math", + "keywords": [ + "bcmath", + "math" + ], + "abandoned": "brick/math", + "time": "2020-01-05T04:49:34+00:00" + }, { "name": "nao-pon/flysystem-cached-extra", "version": "1.0.3", @@ -3783,6 +3897,63 @@ ], "time": "2020-06-07T10:40:07+00:00" }, + { + "name": "phpseclib/bcmath_compat", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/phpseclib/bcmath_compat.git", + "reference": "89cbb63742a32730b7187773a60b6b12b9db4479" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpseclib/bcmath_compat/zipball/89cbb63742a32730b7187773a60b6b12b9db4479", + "reference": "89cbb63742a32730b7187773a60b6b12b9db4479", + "shasum": "" + }, + "require": { + "phpseclib/phpseclib": ">=2.0.19" + }, + "provide": { + "ext-bcmath": "7.3.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35|^5.7|^6.0", + "squizlabs/php_codesniffer": "^3.0" + }, + "suggest": { + "ext-gmp": "Will enable faster math operations" + }, + "type": "library", + "autoload": { + "files": [ + "lib/bcmath.php" + ], + "psr-4": { + "bcmath_compat\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jim Wigginton", + "email": "terrafrost@php.net", + "homepage": "http://phpseclib.sourceforge.net" + } + ], + "description": "PHP 5.x/7.x polyfill for bcmath extension", + "keywords": [ + "BigInteger", + "bcmath", + "bigdecimal", + "math", + "polyfill" + ], + "time": "2020-04-26T16:34:33+00:00" + }, { "name": "phpseclib/phpseclib", "version": "2.0.27", @@ -9321,7 +9492,7 @@ "prefer-stable": true, "prefer-lowest": false, "platform": { - "php": "^7.2" + "php": "^7.4" }, "platform-dev": [], "plugin-api-version": "1.1.0" diff --git a/config/app.php b/config/app.php index a4351240..935a268a 100644 --- a/config/app.php +++ b/config/app.php @@ -173,6 +173,7 @@ return [ App\Providers\BroadcastServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, + App\Providers\TelescopeServiceProvider::class, App\Providers\GoogleDriveServiceProvider::class, ], diff --git a/config/telescope.php b/config/telescope.php new file mode 100644 index 00000000..1fed214a --- /dev/null +++ b/config/telescope.php @@ -0,0 +1,163 @@ + env('TELESCOPE_DOMAIN', null), + + /* + |-------------------------------------------------------------------------- + | Telescope Path + |-------------------------------------------------------------------------- + | + | This is the URI path where Telescope will be accessible from. Feel free + | to change this path to anything you like. Note that the URI will not + | affect the paths of its internal API that aren't exposed to users. + | + */ + + 'path' => env('TELESCOPE_PATH', 'telescope'), + + /* + |-------------------------------------------------------------------------- + | Telescope Storage Driver + |-------------------------------------------------------------------------- + | + | This configuration options determines the storage driver that will + | be used to store Telescope's data. In addition, you may set any + | custom options as needed by the particular driver you choose. + | + */ + + 'driver' => env('TELESCOPE_DRIVER', 'database'), + + 'storage' => [ + 'database' => [ + 'connection' => env('DB_CONNECTION', 'mysql'), + 'chunk' => 1000, + ], + ], + + /* + |-------------------------------------------------------------------------- + | Telescope Master Switch + |-------------------------------------------------------------------------- + | + | This option may be used to disable all Telescope watchers regardless + | of their individual configuration, which simply provides a single + | and convenient way to enable or disable Telescope data storage. + | + */ + + 'enabled' => env('TELESCOPE_ENABLED', true), + + /* + |-------------------------------------------------------------------------- + | Telescope Route Middleware + |-------------------------------------------------------------------------- + | + | These middleware will be assigned to every Telescope route, giving you + | the chance to add your own middleware to this list or change any of + | the existing middleware. Or, you can simply stick with this list. + | + */ + + 'middleware' => [ + 'web', + Authorize::class, + ], + + /* + |-------------------------------------------------------------------------- + | Ignored Paths & Commands + |-------------------------------------------------------------------------- + | + | The following array lists the URI paths and Artisan commands that will + | not be watched by Telescope. In addition to this list, some Laravel + | commands, like migrations and queue commands, are always ignored. + | + */ + + 'ignore_paths' => [ + 'nova-api*', + ], + + 'ignore_commands' => [ + // + ], + + /* + |-------------------------------------------------------------------------- + | Telescope Watchers + |-------------------------------------------------------------------------- + | + | The following array lists the "watchers" that will be registered with + | Telescope. The watchers gather the application's profile data when + | a request or task is executed. Feel free to customize this list. + | + */ + + 'watchers' => [ + Watchers\CacheWatcher::class => env('TELESCOPE_CACHE_WATCHER', true), + + Watchers\CommandWatcher::class => [ + 'enabled' => env('TELESCOPE_COMMAND_WATCHER', true), + 'ignore' => [], + ], + + Watchers\DumpWatcher::class => env('TELESCOPE_DUMP_WATCHER', true), + + Watchers\EventWatcher::class => [ + 'enabled' => env('TELESCOPE_EVENT_WATCHER', true), + 'ignore' => [], + ], + + Watchers\ExceptionWatcher::class => env('TELESCOPE_EXCEPTION_WATCHER', true), + Watchers\JobWatcher::class => env('TELESCOPE_JOB_WATCHER', true), + Watchers\LogWatcher::class => env('TELESCOPE_LOG_WATCHER', true), + Watchers\MailWatcher::class => env('TELESCOPE_MAIL_WATCHER', true), + + Watchers\ModelWatcher::class => [ + 'enabled' => env('TELESCOPE_MODEL_WATCHER', true), + 'events' => ['eloquent.*'], + ], + + Watchers\NotificationWatcher::class => env('TELESCOPE_NOTIFICATION_WATCHER', true), + + Watchers\QueryWatcher::class => [ + 'enabled' => env('TELESCOPE_QUERY_WATCHER', true), + 'ignore_packages' => true, + 'slow' => 100, + ], + + Watchers\RedisWatcher::class => env('TELESCOPE_REDIS_WATCHER', true), + + Watchers\RequestWatcher::class => [ + 'enabled' => env('TELESCOPE_REQUEST_WATCHER', true), + 'size_limit' => env('TELESCOPE_RESPONSE_SIZE_LIMIT', 64), + ], + + Watchers\GateWatcher::class => [ + 'enabled' => env('TELESCOPE_GATE_WATCHER', true), + 'ignore_abilities' => [], + 'ignore_packages' => true, + ], + + Watchers\ScheduleWatcher::class => env('TELESCOPE_SCHEDULE_WATCHER', true), + + Watchers\ViewWatcher::class => env('TELESCOPE_VIEW_WATCHER', true), + ], +]; diff --git a/config/version.yml b/config/version.yml index 4683fb32..233416bd 100644 --- a/config/version.yml +++ b/config/version.yml @@ -5,7 +5,7 @@ current: major: 3 minor: 2 patch: 5 - prerelease: 8-gc16d1e7e + prerelease: 11-g4c5d635d buildmetadata: '' commit: 41845 timestamp: 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 26ee2b3c..3a00ebaf 100644 --- a/database/migrations/2019_08_17_102431_create_events_table.php +++ b/database/migrations/2019_08_17_102431_create_events_table.php @@ -30,6 +30,7 @@ class CreateEventsTable extends Migration $table->text('schedule'); $table->string('calendar_color'); $table->string('calendar_icon'); + $table->string('weekly_msg_publication_time')->default('-5day'); $table->timestamps(); }); } diff --git a/public/css/custom.css b/public/css/custom.css index 441752c3..87b1a4c7 100644 --- a/public/css/custom.css +++ b/public/css/custom.css @@ -1868,4 +1868,29 @@ tfoot > tr { .iconpicker-popover { z-index: 15 !important; +} + +.schedule-level-header { + border-right: 1px solid #dddddd; +} + +.schedule-periode-container { + border: 1px solid #dddddd; +} + +.schedule-body>.row:nth-of-type(odd) { + background-color: #f2f2f2; +} + +.schedule-course-container { + border-right: 1px solid #dddddd; + margin-left: -2px; +} + +.schedule-container { + min-width: 1500px; +} + +.overflow-auto { + overflow: auto; } \ No newline at end of file diff --git a/public/js/calendar.js b/public/js/calendar.js index a1753a70..9d073388 100644 --- a/public/js/calendar.js +++ b/public/js/calendar.js @@ -1,5 +1,13 @@ function initFullCalendar(authToken) { document.addEventListener('DOMContentLoaded', function () { + let urlParam = new URLSearchParams(window.location.search); + let initDate = urlParam.get("d"); + if (initDate == null) { + initDate = moment().format("YYYY-MM-DD"); + urlParam.set("d",initDate.toString()); + } + history.pushState({id: 'schedule'},'Horaire - C-CMS', '/admin/schedule?'+urlParam.toString()); + var calendarEl = document.getElementById('fullCalendar'); var calendar = new FullCalendar.Calendar(calendarEl, { @@ -10,6 +18,7 @@ function initFullCalendar(authToken) { center: 'dayGridMonth,listWeek', right: 'prev,next' }, + defaultDate: initDate, events: '/api/schedule/events', eventRender: function(event, element) { if (event.event.extendedProps.icon && event.view.type == 'dayGridMonth') @@ -28,9 +37,16 @@ function initFullCalendar(authToken) { eventClick: function (info) { $.get("/api/schedule/events/modal/full/" + info.event.id + "/"+ info.event.extendedProps.extraParams.db_type + "?api_token="+authToken, function (data) { $("#modal-content").html(data); + let urlParams = new URLSearchParams(window.location.search); + urlParams.set("e",info.event.id); + history.pushState({id: 'schedule'},'Horaire - C-CMS', '/admin/schedule?'+urlParams.toString()); }); $('#schedulemodal').modal('toggle') }, + datesRender(arg) { + urlParam.set("d",moment(arg.view.currentStart).format("YYYY-MM-DD")); + history.pushState({id: 'schedule'},'Horaire - C-CMS', '/admin/schedule?'+urlParam.toString()); + }, dateClick: function (info) { var date = moment(info.date).format("YYYY-MM-DD"); Swal.fire({ @@ -47,12 +63,28 @@ function initFullCalendar(authToken) { }) } }); - calendar.render(); + if (urlParam.get('e') != null) { + $.get("/api/schedule/events/modal/full/" + urlParam.get('e')+ "/event?api_token="+authToken, function (data) { + $("#modal-content").html(data); + $('#schedulemodal').modal('toggle') + }); + } }); } +function closeScheduleModal() { + let urlParams = new URLSearchParams(window.location.search); + urlParams.delete("e"); + if (urlParams.entries().next().done) { + history.pushState({id: 'schedule'},'Horaire - C-CMS', '/admin/schedule'); + } else { + history.pushState({id: 'schedule'},'Horaire - C-CMS', '/admin/schedule?'+urlParams.toString()); + } + $('#schedulemodal').modal('toggle'); +} + function switchType(date) { var selectInput = $('#type') diff --git a/public/js/plugins/schedule/editorv2.js b/public/js/plugins/schedule/editorv2.js index 42d764dc..037fd75d 100644 --- a/public/js/plugins/schedule/editorv2.js +++ b/public/js/plugins/schedule/editorv2.js @@ -8,16 +8,30 @@ function initEditor(event_id = 1, mode = 'schedule') let editor = $('#editor'); editorMode = mode; eventType = null; - let eventTypePromise = $.ajax({ - type: 'GET', - url: '/api/eventType/'+event_id+'?api_token='+api_token, - success: function (template) { - eventType = template; - }, - error: function () { - showNotification('error','Impossible d\'initialiser l\'éditeur d\'horaire ...','top', 'center') - } - }); + let eventTypePromise = null; + if (mode == "schedule-edit") { + eventTypePromise = $.ajax({ + type: 'GET', + url: '/api/event/'+event_id+'?api_token='+api_token, + success: function (template) { + eventType = template; + }, + error: function () { + showNotification('error','Impossible d\'initialiser l\'éditeur d\'horaire ...','top', 'center') + } + }); + } else { + eventTypePromise = $.ajax({ + type: 'GET', + url: '/api/eventType/'+event_id+'?api_token='+api_token, + success: function (template) { + eventType = template; + }, + error: function () { + showNotification('error','Impossible d\'initialiser l\'éditeur d\'horaire ...','top', 'center') + } + }); + } $.when(eventTypePromise).done(function () { console.log(eventType); @@ -45,7 +59,7 @@ function initEditor(event_id = 1, mode = 'schedule') ['fullscreen'] ] }); - if (mode == 'eventType' || mode == 'schedule-add') + if (mode == 'eventType' || mode == 'schedule-add' || mode == "schedule-edit") { let scheduleModel = eventType['schedule_model']; if (scheduleModel['default_value']) @@ -566,6 +580,116 @@ function loadEventType(date,id = 1) }) } +function loadEvent(date,id) +{ + initEditor(id,'schedule-edit').done(function () { + + if (eventType['is_mandatory'] == 1) + { + $('#is_mandatory').prop('checked',true); + } + else + { + $('#is_mandatory').removeAttr('checked'); + } + + if (eventType['use_schedule'] == 1) + { + $('#use_schedule').prop('checked',true); + switchUseSchedule(); + } + else + { + $('#use_schedule').removeAttr('checked'); + switchUseSchedule(); + } + + if (eventType['use_weekly_msg'] == 1) + { + $('#use_weekly_msg').prop('checked',true); + switchUseWeeklyMsg(); + } + else + { + $('#use_weekly_msg').removeAttr('checked'); + switchUseWeeklyMsg(); + } + let begin_time = $('#begin_time'); + begin_time.datetimepicker({ + icons: { + time: "fa fa-clock-o", + date: "fa fa-calendar", + up: "fa fa-chevron-up", + down: "fa fa-chevron-down", + previous: 'fa fa-chevron-left', + next: 'fa fa-chevron-right', + today: 'fa fa-screenshot', + clear: 'fa fa-trash', + close: 'fa fa-remove' + }, + date: new Date(moment(eventType['date_begin'],"MM/DD/YYYY HH:mm A")) + }); + let end_time = $('#end_time'); + end_time.datetimepicker({ + icons: { + time: "fa fa-clock-o", + date: "fa fa-calendar", + up: "fa fa-chevron-up", + down: "fa fa-chevron-down", + previous: 'fa fa-chevron-left', + next: 'fa fa-chevron-right', + today: 'fa fa-screenshot', + clear: 'fa fa-trash', + close: 'fa fa-remove' + }, + date: new Date(moment(eventType['date_end'],"MM/DD/YYYY HH:mm A")) + }); + let weekly_msg_publication_time = $('#weekly_msg_publication_time'); + if (eventType['use_schedule']) + { + weekly_msg_publication_time.datetimepicker({ + icons: { + time: "fa fa-clock-o", + date: "fa fa-calendar", + up: "fa fa-chevron-up", + down: "fa fa-chevron-down", + previous: 'fa fa-chevron-left', + next: 'fa fa-chevron-right', + today: 'fa fa-screenshot', + clear: 'fa fa-trash', + close: 'fa fa-remove' + }, + date: new Date(moment(eventType['weekly_msg_publication_time'],"MM/DD/YYYY HH:mm A")) + }); + } + else + { + weekly_msg_publication_time.datetimepicker({ + icons: { + time: "fa fa-clock-o", + date: "fa fa-calendar", + up: "fa fa-chevron-up", + down: "fa fa-chevron-down", + previous: 'fa fa-chevron-left', + next: 'fa fa-chevron-right', + today: 'fa fa-screenshot', + clear: 'fa fa-trash', + close: 'fa fa-remove' + }, + date: new Date(moment(eventType['date_begin'],"MM/DD/YYYY HH:mm A").subtract(1,'days')) + }); + } + $('#location').val(eventType['location']); + $('#name').val(eventType['name']); + $('#admin_desc').trumbowyg('html', eventType['desc']); + $('#calendar_color').val(eventType['calendar_color']); + pickr.setColor(eventType['calendar_color']); + $('#calendar_icon').val(eventType['calendar_icon']); + $('#calendar_icon_display').removeAttr('class'); + $('#calendar_icon_display').addClass(eventType['calendar_icon']); + }) +} + function switchUseSchedule() { if($('#use_schedule').is(":checked")) @@ -590,4 +714,10 @@ function switchUseWeeklyMsg() { $('#collmessagedelasemaine').addClass('d-none'); } +} + +function removeFile(file) { + document.getElementById("removedfile").setAttribute("value",document.getElementById("removedfile").getAttribute("value")+"|"+file); + document.getElementById(file).remove(); + console.log(file); } \ No newline at end of file diff --git a/resources/custom.css b/resources/custom.css index 441752c3..87b1a4c7 100644 --- a/resources/custom.css +++ b/resources/custom.css @@ -1868,4 +1868,29 @@ tfoot > tr { .iconpicker-popover { z-index: 15 !important; +} + +.schedule-level-header { + border-right: 1px solid #dddddd; +} + +.schedule-periode-container { + border: 1px solid #dddddd; +} + +.schedule-body>.row:nth-of-type(odd) { + background-color: #f2f2f2; +} + +.schedule-course-container { + border-right: 1px solid #dddddd; + margin-left: -2px; +} + +.schedule-container { + min-width: 1500px; +} + +.overflow-auto { + overflow: auto; } \ No newline at end of file diff --git a/resources/views/admin/course/show.blade.php b/resources/views/admin/course/show.blade.php index 8a98f0ec..6cea375a 100644 --- a/resources/views/admin/course/show.blade.php +++ b/resources/views/admin/course/show.blade.php @@ -20,7 +20,13 @@
{{$course->ocom}}
++ @if(\App\OCOM::findByOCOM($course->ocom) != null) + {{$course->ocom}} + @else + {{$course->ocom}} + @endif +
1
diff --git a/resources/views/admin/ocom/show.blade.php b/resources/views/admin/ocom/show.blade.php index b11cff99..ad2762ff 100644 --- a/resources/views/admin/ocom/show.blade.php +++ b/resources/views/admin/ocom/show.blade.php @@ -10,7 +10,7 @@1
@@ -64,7 +64,7 @@ @foreach($ocom->courses() as $course)