This commit is contained in:
TheGamecraft
2018-12-03 17:21:50 -05:00
parent 0fddd138bf
commit 9dc4d1103f
8 changed files with 190 additions and 50 deletions

View File

@@ -119,37 +119,41 @@ class Schedule extends Model
{
$schedule = Schedule::all();
$warning = collect();
$today = date('U');
foreach ($schedule as $activity) {
if ($activity->type == "regular") {
for ($niv=1; $niv < 3; $niv++) {
for ($pe=1; $pe < 2; $pe++) {
/** Check name */
if ($activity->data['n'.$niv."_p".$pe."_name"] == "") {
$warning->push(['warning' => 'Il doit y avoir un nom pour le cours', 'niveau' => $niv, 'periode' => $pe,'date' => $activity->date]);
}
/** Check OCOM */
if ($activity->data['n'.$niv."_p".$pe."_ocom"] == "") {
$warning->push(['warning' => "Il doit y avoir un OCOM pour le cours", 'niveau' => $niv, 'periode' => $pe,'date' => $activity->date]);
} else {
$regex = '/[MC]['.$niv.']\d\d.\d\d/';
if (preg_match($regex,trim($activity->data['n'.$niv."_p".$pe."_ocom"])) == 0) {
$warning->push(['warning' => "L'OCOM du cours de semble pas être valide", 'niveau' => $niv, 'periode' => $activity->data['n'.$niv."_p".$pe."_ocom"],'date' => $activity->date]);
$time = date('U',strtotime($activity->date));
if ($time >= $today) {
for ($niv=1; $niv <= 3; $niv++) {
for ($pe=1; $pe <= 2; $pe++) {
/** Check name */
if ($activity->data['n'.$niv."_p".$pe."_name"] == "") {
$warning->push(['warning' => 'Il doit y avoir un nom pour le cours', 'niveau' => $niv, 'periode' => $pe,'date' => $activity->date]);
}
/** Check OCOM */
if ($activity->data['n'.$niv."_p".$pe."_ocom"] == "") {
$warning->push(['warning' => "Il doit y avoir un OCOM pour le cours", 'niveau' => $niv, 'periode' => $pe,'date' => $activity->date]);
} else {
$regex = '/[MC]['.$niv.']\d\d.\d\d/';
if (preg_match($regex,trim($activity->data['n'.$niv."_p".$pe."_ocom"])) == 0 && $activity->data['n'.$niv."_p".$pe."_ocom"] != "S.O") {
$warning->push(['warning' => "L'OCOM du cours de semble pas être valide", 'niveau' => $niv, 'periode' => $activity->data['n'.$niv."_p".$pe."_ocom"],'date' => $activity->date]);
}
}
/** Check Instructor */
if ($activity->data['n'.$niv."_p".$pe."_instructor"] == "") {
$warning->push(['warning' => "Il doit y avoir un instructeur pour le cours", 'niveau' => $niv, 'periode' => $pe,'date' => $activity->date]);
}
/** Check local */
if ($activity->data['n'.$niv."_p".$pe."_local"] == "") {
$warning->push(['warning' => "Il doit y avoir un local pour le cours", 'niveau' => $niv, 'periode' => $pe,'date' => $activity->date]);
}
}
/** Check Instructor */
if ($activity->data['n'.$niv."_p".$pe."_instructor"] == "") {
$warning->push(['warning' => "Il doit y avoir un instructeur pour le cours", 'niveau' => $niv, 'periode' => $pe,'date' => $activity->date]);
}
/** Check local */
if ($activity->data['n'.$niv."_p".$pe."_local"] == "") {
$warning->push(['warning' => "Il doit y avoir un local pour le cours", 'niveau' => $niv, 'periode' => $pe,'date' => $activity->date]);
}
}
}