Merge branch 'master' into file-v3

# Conflicts:
#	config/version.yml
This commit is contained in:
Mathieu Lagacé
2020-10-13 14:48:50 -04:00
30 changed files with 908 additions and 922 deletions

View File

@@ -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

View File

@@ -0,0 +1,81 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Schema;
class update extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'update';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Update C-CMS';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->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;
}
}

View File

@@ -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;
}
}

View File

@@ -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 '<div class="table calendar">';
echo '<div class="thead-dark">';
echo '<div class="row"><div class="col-2"><a class="btn" onclick="generate('.$prevMonth.','.$prevYear.')"><i class="fa fa-chevron-left" aria-hidden="true"></i></a></div><div class="col-8">'.ucfirst(strftime("%B %Y", strtotime("01-".$month."-".$year))).'</div><div class="col-2"><a class="btn" onclick="generate('.$nextMonth.','.$nextYear.')"><i class="fa fa-chevron-right" aria-hidden="true"></i></a></div></div>';
echo '<div class="row calendar-head"><div style="width:14%;">Dimanche</div><div style="width:14%;">Lundi</div><div style="width:14%;">Mardi</div><div style="width:14%;">Mercredi</div><div style="width:14%;">Jeudi</div><div style="width:14%;">Vendredi</div><div style="width:14%;">Samedi</div></div>';
echo '</div>';
echo '<div class="card-body">';
for ($i=0; $i < 6 ; $i++)
{
echo '<div class="row">';
for ($a=0; $a < 7 ; $a++)
{
if (isset($calendar[(($i*7) + $a)]))
{
/** Date info */
$today = date("Y-m-d", strtotime($year."-".$month."-".$calendar[(($i*7) + $a)]));
$activityToday = Schedule::where('date','=',$today)->get();
/** If nothing today */
if ($activityToday->isEmpty()) {
echo '<a class="calendar-container calendar-empty" name="'.$today.'" type="button" data-toggle="modal" data-target="#scrollmodal" id="calendar_'.$calendar[(($i*7) + $a)].'" class="btn btn-block btn-calendar" onclick="openCalendar(this.name)"><div class="calendar-date">'.date("j", strtotime($today)).'</div></a>';
} else {
echo '<a class="calendar-container" name="'.$today.'" type="button" data-toggle="modal" data-target="#scrollmodal" id="calendar_'.$calendar[(($i*7) + $a)].'" class="btn btn-block btn-calendar" onclick="openCalendar(this.name)"><div class="calendar-date">'.date("j", strtotime($today)).'</div>';
$text = "";
foreach ($activityToday as $activity) {
echo '<div class="calendar-text" style="width:90%;height:3rem;">';
switch ($activity->type) {
case 'regular':
echo '<div class="row" style="color:orange;"><span class="fa-stack fa-lg col-md-2"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-book fa-stack-1x fa-inverse"></i></span><div class="col-md-10 calendar_event_name">'.ucfirst($activity->data['event_name'])."</div></div>";
break;
case 'pilotage':
echo '<div class="row" style="color:#58D3F7;"><span class="fa-stack fa-lg col-md-2"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-plane fa-stack-1x fa-inverse"></i></span><div class="col-md-10 calendar_event_name">'.ucfirst($activity->data['event_name'])."</div></div>";
break;
case 'drill':
echo '<div class="row" style="color:blue;"><span class="fa-stack fa-lg col-md-2"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-trophy fa-stack-1x fa-inverse"></i></span><div class="col-md-10 calendar_event_name">'.ucfirst($activity->data['event_name'])."</div></div>";
break;
case 'music':
echo '<div class="row" style="color:green;"><span class="fa-stack fa-lg col-md-2"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-music fa-stack-1x fa-inverse"></i></span><div class="col-md-10 calendar_event_name">'.ucfirst($activity->data['event_name'])."</div></div>";
break;
case 'biathlon':
echo '<div class="row" style="color:red;"><span class="fa-stack fa-lg col-md-2"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-snowflake-o fa-stack-1x fa-inverse"></i></span><div class="col-md-10 calendar_event_name">'.ucfirst($activity->data['event_name'])."</div></div>";
break;
case 'marksmanship':
echo '<div class="row" style="color:grey;"><span class="fa-stack fa-lg col-md-2"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-star fa-stack-1x fa-inverse"></i></span><div class="col-md-10 calendar_event_name">'.ucfirst($activity->data['event_name'])."</div></div>";
break;
case 'founding':
echo '<div class="row" style="color:#00FF40;"><span class="fa-stack fa-lg col-md-2"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-usd fa-stack-1x fa-inverse"></i></span><div class="col-md-10 calendar_event_name">'.ucfirst($activity->data['event_name'])."</div></div>";
break;
case 'volunteer':
echo '<div class="row" style="color:#DF0174;"><span class="fa-stack fa-lg col-md-2"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-handshake-o fa-stack-1x fa-inverse"></i></span><div class="col-md-10 calendar_event_name">'.ucfirst($activity->data['event_name'])."</div></div>";
break;
case 'other':
echo '<div class="row" style="color:#DF0174;"><span class="fa-stack fa-lg col-md-2"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-handshake-o fa-stack-1x fa-inverse"></i></span><div class="col-md-10 calendar_event_name">'.ucfirst($activity->data['event_name'])."</div></div>";
break;
default:
echo '<div class="row" style="color:'.\App\ComplementaryActivity::find($activity->type)->calendar_color.';"><span class="fa-stack fa-lg col-md-2">'.\App\ComplementaryActivity::find($activity->type)->calendar_icon.'</span><div class="col-md-10 calendar_event_name">'.ucfirst($activity->data['event_name'])."</div></div>";
break;
}
echo '</div>';
}
echo '</a>';
}
} else {
echo '<div class="calendar-container¸calendar-empty" style="border:none !important; width:14%;"></div>';
}
}
echo '</div>';
}
}
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 '<div class="modal-content"><div class="modal-header"><h5 class="modal-title" id="scrollmodalLabel">'.ucfirst(strftime("%A le %e %B %Y", strtotime($Requestdate))).'</h5><button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span></button></div><div class="modal-body">';
foreach ($today as $date) {
if ($date->data['is_event_mandatory'] == "on") {
$is_mandatory = "<div class='btn btn-block btn-warning m-l-10 m-b-10 float-right'>Activité obligatoire</div>";
} else {
$is_mandatory = "<div class='btn btn-block btn-primary m-l-10 m-b-10 float-right'>Activité n'est pas obligatoire</div>";
}
echo(
'<div class="row">'.
'<div class="col-7">'.
'<p>'.$date->data['event_name'].trans('calendar.begin_at').$date->data['event_begin_time'].trans('calendar.end_at').$date->data['event_end_time'].'</p>'.
'</div>'.
'<div class="col-3">'.
$is_mandatory.
'</div>'.
'<div class="col-1">'.
'<a href="/admin/calendar/edit/'.$date->id.'" type="button" class="btn btn-secondary"><i class="fa fa-cog"></i>&nbsp; Modifier</a>'.
'</div>'.
'<div class="col-1">'.
'<a type="button" class="btn btn-danger" onclick="deleteEvent('.$date->id.');"><i class="fa fa-times-circle" style="color:white;"></i></a>'.
'</div>'.
'</div>'.
'<p>'.$date->data['event_desc'].
'</p>'
);
if ($date->type == "regular") {
if($date->data['n1_p1_plandone'] == "on")
{
$isdone_n1_p1 = '<span class="badge badge-success">Remis</span></i>';
} else {
$isdone_n1_p1 = '<span class="badge badge-danger">Non remis</span>';
}
if($date->data['n1_p2_plandone'] == "on")
{
$isdone_n1_p2 = '<span class="badge badge-success">Remis</span></i>';
} else {
$isdone_n1_p2 = '<span class="badge badge-danger">Non remis</span>';
}
if($date->data['n2_p1_plandone'] == "on")
{
$isdone_n2_p1 = '<span class="badge badge-success">Remis</span></i>';
} else {
$isdone_n2_p1 = '<span class="badge badge-danger">Non remis</span>';
}
if($date->data['n2_p2_plandone'] == "on")
{
$isdone_n2_p2 = '<span class="badge badge-success">Remis</span></i>';
} else {
$isdone_n2_p2 = '<span class="badge badge-danger">Non remis</span>';
}
if($date->data['n3_p1_plandone'] == "on")
{
$isdone_n3_p1 = '<span class="badge badge-success">Remis</span></i>';
} else {
$isdone_n3_p1 = '<span class="badge badge-danger">Non remis</span>';
}
if($date->data['n3_p2_plandone'] == "on")
{
$isdone_n3_p2 = '<span class="badge badge-success">Remis</span></i>';
} else {
$isdone_n3_p2 = '<span class="badge badge-danger">Non remis</span>';
}
echo '<table class="table">
<thead class="thead-dark">
<tr>
<th>Niveau</th>
<th style="width:45%">1er Période</th>
<th style="width:45%">2e Période</th>
</tr>
</thead>
<tbody>
<tr>
<th>1</th>
<td>
<table class="table float center" style="border:none; max-width:80%; margin:auto;">
<tbody>
<tr style="border:none;">
<td style="border:none; width:80%">'.User::find($date->data['n1_p1_instructor'])->fullname().'</td>
<td style="border:none;">'.$isdone_n1_p1.'</td>
<td style="border:none;"><a href="/admin/inventory/'.$date->id.'/1/1" type="button" class="btn btn-info"><i class="fa fa-archive" style="color:white;"></i></a></td>
</tr>
<tr style="border:none;">
<td style="border:none;width:80%">'.$date->data['n1_p1_ocom'].' - '.$date->data['n1_p1_name'].'</td>
<td style="border:none;">'.Local::find($date->data['n1_p1_local'])->name.'</td>
</tr>
</tbody>
</table>
</td>
<td>
<table class="table float center" style="border:none; max-width:80%; margin:auto;">
<tbody>
<tr style="border:none;">
<td style="border:none;width:80%">'.User::find($date->data['n1_p2_instructor'])->fullname().'</td>
<td style="border:none;">'.$isdone_n1_p2.'</td>
<td style="border:none;"><a href="/admin/inventory/'.$date->id.'/2/1" type="button" class="btn btn-info"><i class="fa fa-archive" style="color:white;"></i></a></td>
</tr>
<tr style="border:none;">
<td style="border:none;width:80%">'.$date->data['n1_p2_ocom'].' - '.$date->data['n1_p2_name'].'</td>
<td style="border:none;">'.Local::find($date->data['n1_p2_local'])->name.'</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<th>2</th>
<td>
<table class="table float center" style="border:none; max-width:80%; margin:auto;">
<tbody>
<tr style="border:none;">
<td style="border:none;width:80%">'.User::find($date->data['n2_p1_instructor'])->fullname().'</td>
<td style="border:none;">'.$isdone_n2_p1.'</td>
<td style="border:none;"><a href="/admin/inventory/'.$date->id.'/1/2" type="button" class="btn btn-info"><i class="fa fa-archive" style="color:white;"></i></a></td>
</tr>
<tr style="border:none;">
<td style="border:none;width:80%">'.$date->data['n2_p1_ocom'].' - '.$date->data['n2_p1_name'].'</td>
<td style="border:none;">'.Local::find($date->data['n2_p1_local'])->name.'</td>
</tr>
</tbody>
</table>
</td>
<td>
<table class="table float center" style="border:none; max-width:80%; margin:auto;">
<tbody>
<tr style="border:none;">
<td style="border:none;width:80%">'.User::find($date->data['n2_p2_instructor'])->fullname().'</td>
<td style="border:none;">'.$isdone_n2_p2.'</td>
<td style="border:none;"><a href="/admin/inventory/'.$date->id.'/2/2" type="button" class="btn btn-info"><i class="fa fa-archive" style="color:white;"></i></a></td>
</tr>
<tr style="border:none;">
<td style="border:none;width:80%">'.$date->data['n2_p2_ocom'].' - '.$date->data['n2_p2_name'].'</td>
<td style="border:none;">'.Local::find($date->data['n2_p2_local'])->name.'</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<th>3</th>
<td>
<table class="table float center" style="border:none; max-width:80%; margin:auto;">
<tbody>
<tr style="border:none;">
<td style="border:none;width:80%">'.User::find($date->data['n3_p1_instructor'])->fullname().'</td>
<td style="border:none;">'.$isdone_n3_p1.'</td>
<td style="border:none;"><a href="/admin/inventory/'.$date->id.'/1/3" type="button" class="btn btn-info"><i class="fa fa-archive" style="color:white;"></i></a></td>
</tr>
<tr style="border:none;">
<td style="border:none;width:80%">'.$date->data['n3_p1_ocom'].' - '.$date->data['n3_p1_name'].'</td>
<td style="border:none;">'.Local::find($date->data['n3_p1_local'])->name.'</td>
</tr>
</tbody>
</table>
</td>
<td>
<table class="table float center" style="border:none; max-width:80%; margin:auto;">
<tbody>
<tr style="border:none;">
<td style="border:none;width:80%">'.User::find($date->data['n3_p2_instructor'])->fullname().'</td>
<td style="border:none;">'.$isdone_n3_p2.'</td>
<td style="border:none;"><a href="/admin/inventory/'.$date->id.'/2/3" type="button" class="btn btn-info"><i class="fa fa-archive" style="color:white;"></i></a></td>
</tr>
<tr style="border:none;">
<td style="border:none;width:80%">'.$date->data['n3_p2_ocom'].' - '.$date->data['n3_p2_name'].'</td>
<td style="border:none;">'.Local::find($date->data['n3_p2_local'])->name.'</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>';
}
echo '<br><hr><br>';
}
echo '<a href="/admin/calendar/add/'.$url.'" type="button" class="btn btn-primary btn-lg btn-block">'.trans('calendar.add_to_schedule').'</a></div><div class="modal-footer"><button type="button" class="btn btn-secondary" data-dismiss="modal">'.trans('pagination.close').'</button></div></div>';
}
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 = "<ul>";
foreach ($changes as $value) {
$string_Change = $string_Change."<li>".$value."</li>";
}
$string_Change = $string_Change."</ul>";
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."<br>".$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]);
}
}

View File

@@ -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
}
}
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')
{
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;
}
}
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;

View File

@@ -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;

View File

@@ -46,6 +46,11 @@ class ScheduleController extends Controller
}
foreach ($allevents as $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);
}
@@ -53,6 +58,18 @@ class ScheduleController extends Controller
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);
}
}
}
foreach ($schedules as $schedule) {
@@ -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();

View File

@@ -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 = [];

View File

@@ -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();
});
}

View File

@@ -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();
});
}

13
public/css/custom.css vendored
View File

@@ -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;

26
public/js/calendar.js vendored
View File

@@ -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,13 +130,7 @@ function deleteEvent(pid){
if (result.value) {
(function($) {
$.post('/api/schedule/event/delete/'+pid+'?api_token='+api_token, function(data) {
console.log('Delete');
});
})(jQuery);
$.post('/api/schedule/event/delete/'+pid+'?api_token='+api_token, function(data, status, xhr) {
swal(
'Supprimé!',
"L'évenement a été supprimé",
@@ -146,6 +140,22 @@ function deleteEvent(pid){
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);
}
})
}

View File

@@ -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);

13
resources/custom.css vendored
View File

@@ -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;

View File

@@ -1,6 +1,11 @@
@extends('layouts.admin.main')
@section('content')
<div class="col-sm-12 col-lg-12 text-right">
<a class="btn btn-primary btn-round" href="/admin/schedule/table">
<i class="material-icons">table_view</i> Vue Tableau
</a>
</div>
<div class="col-sm-12 col-lg-12">
<div class="card">
<div class="card-body pb-0">

View File

@@ -31,41 +31,34 @@
<p>
Choisissez quels permissions doivent être associé avec ce grade.
</p>
<div id="accordion" role="tablist">
<table id="permission-table" class="table table-bordered" style="width:100%">
<thead class="d-none">
<th class="d-none">Cat</th>
<th>Nom</th>
<th></th>
</thead>
<tbody>
@foreach(\App\Permission::allToArray() as $key => $cat)
<div class="card card-collapse">
<div class="card-header" role="tab" id="headingOne">
<h5 class="mb-0">
<a class="text-capitalize" data-toggle="collapse" href="#coll-{{$key}}" @if ($loop->first) aria-expanded="true" @endif aria-controls="collapseOne">
{{$key}}
<i class="material-icons">keyboard_arrow_down</i>
</a>
</h5>
</div>
<div id="coll-{{$key}}" class="collapse @if ($loop->first) show @endif" role="tabpanel" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body">
<div class="row">
@foreach($cat as $r)
<div class="col-3 text-center">
<tr>
<td class="d-none">{{$key}}</td>
<td>
<input class="d-none" type="text" id="{{$r['ckey']}}" name="{{$r['ckey']}}">
<h5>{{$r['communName']}}</h5>
{{$r['communName']}}<br>
<small>{{$r['desc']}}</small>
</td>
<td class="text-center">
<div class="btn-group">
<button type="button" id="{{$r['ckey']}}-close" class="btn btn-just-icon btn-outline-danger" onclick="switchPermissionSwitch('{{$r['ckey']}}','close')"><i class="fas fa-times"></i></button>
<!--<button type="button" id="{{$r['ckey']}}-slash" class="btn btn-just-icon btn-warning" onclick="switchPermissionSwitch('{{$r['ckey']}}','slash')"><i class="fa fa-slash"></i></button>-->
<button type="button" id="{{$r['ckey']}}-plus" class="btn btn-just-icon btn-outline-success" onclick="switchPermissionSwitch('{{$r['ckey']}}','plus')"><i class="fa fa-plus"></i></button>
</div>
<p>
<small>{{$r['desc']}}</small>
</p>
</div>
</td>
</tr>
@endforeach
</div>
</div>
</div>
</div>
@endforeach
</div>
</tbody>
</table>
</div>
<div class="col-md-12 mt-5">
<button type="submit" class="btn btn-primary">Sauvegarder</button>
@@ -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] }
]
});
} );
</script>
@endsection

View File

@@ -31,7 +31,41 @@
<p>
Choisissez quels permissions doivent être associé avec ce grade.
</p>
<div id="accordion" role="tablist">
<table id="permission-table" class="table table-bordered" style="width:100%">
<thead class="d-none">
<th class="d-none">Cat</th>
<th>Nom</th>
<th></th>
</thead>
<tbody>
@foreach(\App\Permission::allToArray() as $key => $cat)
@foreach($cat as $r)
<tr>
<td class="d-none">{{$key}}</td>
<td>
<input class="d-none" type="text" id="{{$r['ckey']}}"
name="{{$r['ckey']}}" value="{{$rank->p($r['ckey'])}}">
{{$r['communName']}}<br>
<small>{{$r['desc']}}</small>
</td>
<td class="text-center">
<div class="btn-group">
<button type="button" id="{{$r['ckey']}}-close"
class="btn btn-just-icon @if($rank->p($r['ckey']) != -1) btn-outline-danger @else btn-danger @endif"
onclick="switchPermissionSwitch('{{$r['ckey']}}','close')">
<i class="fas fa-times"></i></button>
<button type="button" id="{{$r['ckey']}}-plus"
class="btn btn-just-icon @if($rank->p($r['ckey']) != 1) btn-outline-success @else btn-success @endif"
onclick="switchPermissionSwitch('{{$r['ckey']}}','plus')">
<i class="fa fa-plus"></i></button>
</div>
</td>
</tr>
@endforeach
@endforeach
</tbody>
</table>
{{--<div id="accordion" role="tablist">
@foreach(\App\Permission::allToArray() as $key => $cat)
<div class="mb-4">
<h3 class="text-capitalize">{{$key}}</h3>
@@ -56,12 +90,11 @@
<i class="fa fa-plus"></i></button>
</div>
</div>
<hr>
@endforeach
</div>
</div>
@endforeach
</div>
</div>--}}
</div>
<div class="col-md-12 mt-5">
<button type="submit" class="btn btn-primary">Sauvegarder</button>
@@ -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] }
]
});
} );
</script>
@endsection

View File

@@ -69,7 +69,7 @@
@else
@foreach ($futureEvent as $event)
<div class="col-md-12">
<div class="alert" style="background-color: @if($event->calendar_color == null){{ \App\ComplementaryActivity::find($event->type)->calendar_color}} @else {{$event->calendar_color}} @endif">
<div class="alert cursor" style="background-color: @if($event->calendar_color == null){{ \App\ComplementaryActivity::find($event->type)->calendar_color}} @else {{$event->calendar_color}} @endif" onclick="navigate('schedule?e={{$event->id}}')">
<div class="row text-white">
<div class="col-md-2 text-capitalize m-auto d-none d-md-flex">
<h3 class="m-0 p-0" style="margin-top: -0.5rem !important;">@if($event->calendar_icon == null) {!! \App\ComplementaryActivity::find($event->type)->calendar_icon !!} @else <i class="{{$event->calendar_icon}}"></i> @endif</h3>

View File

@@ -11,13 +11,13 @@
<form method="post">
@csrf
<div class="row">
<div class="col-md-5">
<div class="col-md-4">
<div class="form-group">
<label class="label-control">Nom</label>
<input type="text" class="form-control" name="name" required/>
</div>
</div>
<div class="col-md-5">
<div class="col-md-4">
<div class="form-group">
<label class="label-control">Emplacement</label>
<input type="text" class="form-control" name="location" required/>
@@ -32,6 +32,15 @@
</label>
</div>
</div>
<div class="col-md-2">
<div class="togglebutton">
<label>
<input type="checkbox" name="hidden">
<span class="toggle"></span>
Évenement caché
</label>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label class="label-control">Heure de début</label>

View File

@@ -12,13 +12,13 @@
@method('PATCH')
@csrf
<div class="row">
<div class="col-md-5">
<div class="col-md-4">
<div class="form-group">
<label class="label-control">Nom</label>
<input type="text" class="form-control" value="{{$event_type->name}}" name="name" />
</div>
</div>
<div class="col-md-5">
<div class="col-md-4">
<div class="form-group">
<label class="label-control">Emplacement</label>
<input type="text" class="form-control" value="{{$event_type->location}}" name="location" />
@@ -33,6 +33,15 @@
</label>
</div>
</div>
<div class="col-md-2">
<div class="togglebutton">
<label>
<input type="checkbox" name="hidden" @if($event_type->hidden == 1) checked @endif>
<span class="toggle"></span>
Évenement caché
</label>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label class="label-control">Heure de début</label>

View File

@@ -31,7 +31,35 @@
<p>
Choisissez quels permissions doivent être associé avec ce poste.
</p>
<div id="accordion" role="tablist">
<table id="permission-table" class="table table-bordered" style="width:100%">
<thead class="d-none">
<th class="d-none">Cat</th>
<th>Nom</th>
<th></th>
</thead>
<tbody>
@foreach(\App\Permission::allToArray() as $key => $cat)
@foreach($cat as $r)
<tr>
<td class="d-none">{{$key}}</td>
<td>
<input class="d-none" type="text" id="{{$r['ckey']}}" name="{{$r['ckey']}}">
{{$r['communName']}}<br>
<small>{{$r['desc']}}</small>
</td>
<td class="text-center">
<div class="btn-group">
<button type="button" id="{{$r['ckey']}}-close" class="btn btn-just-icon btn-outline-danger" onclick="switchPermissionSwitch('{{$r['ckey']}}','close')"><i class="fas fa-times"></i></button>
<button type="button" id="{{$r['ckey']}}-slash" class="btn btn-just-icon btn-warning" onclick="switchPermissionSwitch('{{$r['ckey']}}','slash')"><i class="fa fa-slash"></i></button>
<button type="button" id="{{$r['ckey']}}-plus" class="btn btn-just-icon btn-outline-success" onclick="switchPermissionSwitch('{{$r['ckey']}}','plus')"><i class="fa fa-plus"></i></button>
</div>
</td>
</tr>
@endforeach
@endforeach
</tbody>
</table>
{{--<div id="accordion" role="tablist">
@foreach(\App\Permission::allToArray() as $key => $cat)
<div class="card card-collapse">
<div class="card-header" role="tab" id="headingOne">
@@ -65,7 +93,7 @@
</div>
</div>
@endforeach
</div>
</div>--}}
</div>
<div class="col-md-12 mt-5">
<button type="submit" class="btn btn-primary">Sauvegarder</button>
@@ -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] }
]
});
} );
</script>
@endsection

View File

@@ -31,7 +31,35 @@
<p>
Choisissez quels permissions doivent être associé avec ce poste.
</p>
<div id="accordion" role="tablist">
<table id="permission-table" class="table table-bordered" style="width:100%">
<thead class="d-none">
<th class="d-none">Cat</th>
<th>Nom</th>
<th></th>
</thead>
<tbody>
@foreach(\App\Permission::allToArray() as $key => $cat)
@foreach($cat as $r)
<tr>
<td class="d-none">{{$key}}</td>
<td>
<input class="d-none" type="text" id="{{$r['ckey']}}" name="{{$r['ckey']}}" value="{{$job->p($r['ckey'])}}">
{{$r['communName']}}<br>
<small>{{$r['desc']}}</small>
</td>
<td class="text-center">
<div class="btn-group">
<button type="button" id="{{$r['ckey']}}-close" class="btn btn-just-icon @if($job->p($r['ckey']) != -1) btn-outline-danger @else btn-danger @endif" onclick="switchPermissionSwitch('{{$r['ckey']}}','close')"><i class="fas fa-times"></i></button>
<button type="button" id="{{$r['ckey']}}-slash" class="btn btn-just-icon @if($job->p($r['ckey']) == 0) btn-warning @else btn-outline-warning @endif" onclick="switchPermissionSwitch('{{$r['ckey']}}','slash')"><i class="fas fa-slash"></i></button>
<button type="button" id="{{$r['ckey']}}-plus" class="btn btn-just-icon @if($job->p($r['ckey']) != 1) btn-outline-success @else btn-success @endif" onclick="switchPermissionSwitch('{{$r['ckey']}}','plus')"><i class="fas fa-plus"></i></button>
</div>
</td>
</tr>
@endforeach
@endforeach
</tbody>
</table>
{{-- <div id="accordion" role="tablist">
@foreach(\App\Permission::allToArray() as $key => $cat)
<div class="card card-collapse">
<div class="card-header" role="tab" id="headingOne">
@@ -65,7 +93,7 @@
</div>
</div>
@endforeach
</div>
</div>--}}
</div>
<div class="col-md-12 mt-5">
<button type="submit" class="btn btn-primary">Sauvegarder</button>
@@ -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] }
]
});
} );
</script>
@endsection

View File

@@ -157,6 +157,17 @@
</label>
</div>
</div>
<div class="form-group">
<label class="m-0" for="type">Évenement caché</label>
<small class="text-muted d-block">L'évenement doit t-il être caché?</small>
<div class="togglebutton">
<label>
<input type="checkbox" id="hidden" name="hidden">
<span class="toggle"></span>
Caché
</label>
</div>
</div>
<div id="accordion-apparence" role="tablist">
<div class="card card-collapse">
<div class="card-header" role="tab" id="heading-apparence">

View File

@@ -170,6 +170,17 @@
</label>
</div>
</div>
<div class="form-group">
<label class="m-0" for="type">Évenement caché</label>
<small class="text-muted d-block">L'évenement doit t-il être caché?</small>
<div class="togglebutton">
<label>
<input type="checkbox" id="hidden" name="hidden">
<span class="toggle"></span>
Caché
</label>
</div>
</div>
<div id="accordion-apparence" role="tablist">
<div class="card card-collapse">
<div class="card-header" role="tab" id="heading-apparence">

View File

@@ -0,0 +1,140 @@
@extends('layouts.admin.main')
@section('content')
<div class="col-sm-12 col-lg-12 text-right">
<a class="btn btn-primary btn-round" href="/admin/schedule">
<i class="material-icons">today</i> Vue Horaire
</a>
</div>
<div class="col-sm-12 col-lg-12">
<div class="card">
<div class="card-header">
<h3 class="card-title">Horaire tableau</h3>
</div>
<div class="card-body" style="overflow: scroll;max-height: 79vh">
<div>
<table class="table table-bordered">
<thead class="table-dark">
<tr>
<th></th>
@for($i = 1;$i <= \App\Event::getMaxLevels($events); $i++)
<th>
Niveau {{$i}}
</th>
@endfor
</tr>
<tr>
<td>
<div class="row" style="width: 29rem">
<div class="col-2 pr-0">
Semaine
</div>
<div class="col-4">
Nom
</div>
<div class="col-3">
Date
</div>
<div class="col-3">
Période
</div>
</div>
</td>
@for($i = 1;$i <= \App\Event::getMaxLevels($events); $i++)
<td>
<div class="row" style="width: 35rem">
<div class="col-5">
OCOM - Description
</div>
<div class="col-3">
Instructeur
</div>
<div class="col-2">
Salle
</div>
<div class="col-2">
Materiel
</div>
</div>
</td>
@endfor
</tr>
</thead>
@foreach($events as $event)
<tr class="schedule-table-week">
<td>
<div class="row" style="width: 29rem">
<div class="col-2 text-center m-auto">
{{ $loop->iteration }}
</div>
<div class="col-4 m-auto">
{{$event->name}}
</div>
<div class="col-3 m-auto">
{{$event->date_begin}} à {{ $event->date_end }}
</div>
<div class="col-3 m-auto pr-0">
@if($event->use_schedule == 1)
@foreach($event->schedule["periodes"] as $periode)
<table class="table-borderless">
<tr>
<td style="height: 6rem;vertical-align: middle">
P{{$loop->iteration}} - {{ $periode['begin_time'] }} à {{ $periode['end_time'] }}
</td>
</tr>
</table>
@endforeach
@endif
</div>
</div>
</td>
@if($event->use_schedule == 1)
@for($n = 1;$n <= $event->nbNiveau();$n++)
<td style="padding: 0px;">
@for($p = 1;$p <= $event->nbPeriode();$p++)
<table class="table-borderless">
<tr @if($p != $event->nbPeriode())class="border-bottom"@endif>
<td style="height: 6rem;">
<div class="row" style="width: 35rem">
@php($course = $event->course($p,$n))
<div class="col-5 m-auto">
@if(!$course->use_course())
<b>{{ $course->ocom }}</b> - {{ $course->name }}
@else
{{ $course->desc }}
@endif
</div>
<div class="col-3">
{{ $course->instructor() }}
</div>
<div class="col-2">
{{ $course->location }}
</div>
<div class="col-2">
NA
</div>
@php($course = null)
</div>
</td>
</tr>
</table>
@endfor
</td>
@endfor
@else
<td colspan="{{\App\Event::getMaxLevels($events)}}">
{!! $event->desc !!}
</td>
@endif
</tr>
@endforeach
</table>
</div>
</div>
</div>
</div>
@endsection
@section('custom_scripts')
@endsection

View File

@@ -95,7 +95,7 @@ $sidebar = [
'Configuration' => [
'route' => null,
'icon' => 'menu_book',
'perm' => 'config_edit',
'perm' => 'config_see',
'child' => [
'Général' => [
'route' => 'admin.config.general',
@@ -136,7 +136,7 @@ $sidebar = [
'Apparence' => [
'route' => 'admin.config.customisation',
'icon' => 'fas fa-palette',
'perm' => 'config_edit_instruction',
'perm' => 'config_edit_customization',
'child' => null
]
]

View File

@@ -1,3 +1,8 @@
@if($event->hidden == 1)
<div class="alert alert-danger text-center" role="alert" style="margin-top:-4rem">
<b>Évenement caché</b>
</div>
@endif
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">{{$event->name}}</h5>
<button type="button" class="close" onclick="closeScheduleModal()" aria-label="Close">

View File

@@ -17,6 +17,7 @@ Route::get('/schedule/events/modal/{id}/{db_type}','ScheduleController@loadModal
Route::middleware('auth:api')->group(function () {
Route::get('/schedule/events/auth','ScheduleController@apiIndex');
Route::get('/schedule/events/modal/full/{id}/{db_type}','ScheduleController@loadModalFull')->middleware('perm:schedule_see');
Route::get('/schedule/events/add/modal/{type}/{date}','ScheduleController@loadModalDefautType')->middleware('perm:schedule_add');
Route::get('/schedule/editor/init/{id}','ScheduleEditorController@getTemplate')->middleware('perm:schedule_edit');

View File

@@ -37,6 +37,12 @@ Breadcrumbs::for('admin.schedule', function ($trail) {
$trail->push('Horaire', route('admin.schedule'));
});
// Admin > Schedule > Table
Breadcrumbs::for('admin.schedule.tableview', function ($trail) {
$trail->parent('admin.schedule');
$trail->push('Tableau', route('admin.schedule.tableview'));
});
// Admin > Schedule > Add
Breadcrumbs::for('admin.schedule.add', function ($trail,$date) {
$trail->parent('admin.schedule');

View File

@@ -49,6 +49,7 @@ Route::middleware(['auth', 'firstlogin'])->name('admin.')->group(function () {
/** Schedule */
Route::get('/admin/schedule', 'CalendarController@index')->middleware('perm:schedule_see')->name('schedule');
Route::get('/admin/schedule/table', 'CalendarController@indexTable')->middleware('perm:schedule_see')->name('schedule.tableview');
Route::get('/admin/schedule/pdf/event/{id}', 'ScheduleController@printtopdf')->middleware('perm:schedule_see')->name('schedule.pdf');
Route::get('/admin/schedule/add/{date}', 'ScheduleController@create')->middleware('perm:schedule_add')->name('schedule.add');
Route::get('/admin/schedule/edit/{id}', 'EventController@edit')->middleware('perm:schedule_edit')->name('schedule.edit');
@@ -57,7 +58,7 @@ Route::middleware(['auth', 'firstlogin'])->name('admin.')->group(function () {
/** Statistique */
Route::get('/admin/stats/log', 'LogController@index')->middleware('perm:stats_see')->name('stats.log');
Route::get('/admin/stats/instruction', 'StatsController@instruction')->middleware('perm:stats_see')->name('stats.instruction');
Route::get('/admin/stats/instruction', 'StatsController@instruction')->middleware('perm:stats_instruction_see')->name('stats.instruction');
/** Message */
Route::get('/admin/message', 'MessageController@index')->middleware('perm:msg_see')->name('message');
@@ -75,39 +76,39 @@ Route::middleware(['auth', 'firstlogin'])->name('admin.')->group(function () {
Route::post('/admin/user/edit/{id}', 'UserController@update')->middleware('perm:user_edit');
/** Config */
Route::get('/admin/config/instruction', 'ScheduleController@index')->middleware('perm:config_edit')->name('config.schedule');
Route::get('/admin/config/instruction/event_type/create', 'EventTypeController@create')->middleware('perm:config_edit')->name('config.schedule.event_type.create');
Route::post('/admin/config/instruction/event_type/create', 'EventTypeController@store')->middleware('perm:config_edit');
Route::get('/admin/config/instruction/event_type/{id}', 'EventTypeController@show')->middleware('perm:config_edit')->name('config.schedule.event_type');
Route::patch('/admin/config/instruction/event_type/{id}', 'EventTypeController@update')->middleware('perm:config_edit');
Route::patch('/admin/config/instruction', 'ScheduleController@update')->middleware('perm:config_edit');
Route::get('/admin/config/activity', 'ComplementaryActivityController@index')->middleware('perm:config_edit')->name('config.complementary-activity');
Route::get('/admin/config/activity/add', 'ComplementaryActivityController@create')->middleware('perm:config_edit')->name('config.complementary-activity.add');
Route::post('/admin/config/activity/add', 'ComplementaryActivityController@store')->middleware('perm:config_edit');
Route::get('/admin/config/activity/edit/{id}', 'ComplementaryActivityController@edit')->middleware('perm:config_edit')->name('config.complementary-activity.edit');
Route::post('/admin/config/activity/edit/{id}', 'ComplementaryActivityController@update')->middleware('perm:config_edit');
Route::get('/admin/config/instruction', 'ScheduleController@index')->middleware('perm:config_edit_instruction')->name('config.schedule');
Route::get('/admin/config/instruction/event_type/create', 'EventTypeController@create')->middleware('perm:config_edit_instruction')->name('config.schedule.event_type.create');
Route::post('/admin/config/instruction/event_type/create', 'EventTypeController@store')->middleware('perm:config_edit_instruction');
Route::get('/admin/config/instruction/event_type/{id}', 'EventTypeController@show')->middleware('perm:config_edit_instruction')->name('config.schedule.event_type');
Route::patch('/admin/config/instruction/event_type/{id}', 'EventTypeController@update')->middleware('perm:config_edit_instruction');
Route::patch('/admin/config/instruction', 'ScheduleController@update')->middleware('perm:config_edit_instruction');
Route::get('/admin/config/activity', 'ComplementaryActivityController@index')->middleware('perm:config_edit_administration')->name('config.complementary-activity');
Route::get('/admin/config/activity/add', 'ComplementaryActivityController@create')->middleware('perm:config_edit_administration')->name('config.complementary-activity.add');
Route::post('/admin/config/activity/add', 'ComplementaryActivityController@store')->middleware('perm:config_edit_administration');
Route::get('/admin/config/activity/edit/{id}', 'ComplementaryActivityController@edit')->middleware('perm:config_edit_administration')->name('config.complementary-activity.edit');
Route::post('/admin/config/activity/edit/{id}', 'ComplementaryActivityController@update')->middleware('perm:config_edit_administration');
Route::post('/admin/config/general/edit', 'ConfigController@update')->middleware('perm:config_edit');
Route::get('/admin/config/', 'ConfigController@index')->middleware('perm:config_edit')->name('config.general');
Route::get('/admin/config/customisation', 'ConfigController@customisation')->middleware('perm:config_edit')->name('config.customisation');
Route::post('/admin/config/customisation', 'ConfigController@customisationUpdate')->middleware('perm:config_edit');
Route::get('/admin/config/customisation', 'ConfigController@customisation')->middleware('perm:config_edit_customization')->name('config.customisation');
Route::post('/admin/config/customisation', 'ConfigController@customisationUpdate')->middleware('perm:config_edit_customization');
Route::get('/admin/config/ranks', 'RankController@index')->middleware('perm:config_edit')->name('config.rank');
Route::get('/admin/config/ranks/add', 'RankController@create')->middleware('perm:config_edit')->name('config.rank.add');
Route::post('/admin/config/ranks/add', 'RankController@store')->middleware('perm:config_edit');
Route::get('/admin/config/ranks/{id}', 'RankController@show')->middleware('perm:config_edit')->name('config.rank.edit');
Route::post('/admin/config/ranks/{id}', 'RankController@update')->middleware('perm:config_edit');
Route::get('/admin/config/jobs', 'JobController@index')->middleware('perm:config_edit')->name('config.jobs');
Route::get('/admin/config/jobs/add', 'JobController@create')->middleware('perm:config_edit')->name('config.jobs.add');
Route::post('/admin/config/jobs/add', 'JobController@store')->middleware('perm:config_edit');
Route::get('/admin/config/jobs/{id}', 'JobController@edit')->middleware('perm:config_edit')->name('config.jobs.edit');
Route::post('/admin/config/jobs/{id}', 'JobController@update')->middleware('perm:config_edit');
Route::get('/admin/config/ranks', 'RankController@index')->middleware('perm:config_edit_rank')->name('config.rank');
Route::get('/admin/config/ranks/add', 'RankController@create')->middleware('perm:config_edit_rank')->name('config.rank.add');
Route::post('/admin/config/ranks/add', 'RankController@store')->middleware('perm:config_edit_rank');
Route::get('/admin/config/ranks/{id}', 'RankController@show')->middleware('perm:config_edit_rank')->name('config.rank.edit');
Route::post('/admin/config/ranks/{id}', 'RankController@update')->middleware('perm:config_edit_rank');
Route::get('/admin/config/jobs', 'JobController@index')->middleware('perm:config_edit_job')->name('config.jobs');
Route::get('/admin/config/jobs/add', 'JobController@create')->middleware('perm:config_edit_job')->name('config.jobs.add');
Route::post('/admin/config/jobs/add', 'JobController@store')->middleware('perm:config_edit_job');
Route::get('/admin/config/jobs/{id}', 'JobController@edit')->middleware('perm:config_edit_job')->name('config.jobs.edit');
Route::post('/admin/config/jobs/{id}', 'JobController@update')->middleware('perm:config_edit_job');
Route::get('/admin/config/files', 'ConfigController@showfilesConfig')->middleware('perm:config_edit')->name('config.files');
Route::post('/admin/config/files', 'ConfigController@editfilesConfig')->middleware('perm:config_edit');
/** Public page */
Route::get('/admin/public/edit/{config}', 'PublicController@edit')->middleware('perm:config_edit');
Route::post('/admin/public/edit/{config}', 'PublicController@update')->middleware('perm:config_edit');
Route::get('/admin/public/edit/{config}', 'PublicController@edit')->middleware('perm:config_edit_customization');
Route::post('/admin/public/edit/{config}', 'PublicController@update')->middleware('perm:config_edit_customization');
/** Picture */
Route::get('/admin/picture', 'PictureController@indexAdmin')->middleware('perm:picture_see')->name('picture');