This commit is contained in:
TheGamecraft
2018-12-03 10:51:24 -05:00
parent f98cd85872
commit 0fddd138bf
7 changed files with 130 additions and 2 deletions

View File

@@ -114,4 +114,48 @@ class Schedule extends Model
return $users;
}
}
public static function checkForWarning()
{
$schedule = Schedule::all();
$warning = collect();
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]);
}
}
/** 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]);
}
}
}
}
}
return $warning;
}
}