|
|
@@ -78,8 +78,11 @@ class alert
|
|
|
return (empty($_SESSION["alert"]["tab"])) ? FALSE : TRUE;
|
|
|
}
|
|
|
|
|
|
- public static function printAlert(array $_array)
|
|
|
+ public static function printAlert(?array $_array = NULL)
|
|
|
{
|
|
|
+ if($_array == NULL){
|
|
|
+ return NULL;
|
|
|
+ }
|
|
|
$return = NULL;
|
|
|
foreach ($_array as $value) {
|
|
|
$return .= "<div>" . $value . "</div>";
|
|
|
@@ -100,43 +103,45 @@ class alert
|
|
|
return (in_array($_string, $_SESSION["alert"]["input"])) ? TRUE : FALSE;
|
|
|
}
|
|
|
|
|
|
- private static function printToast(string $_style, string $_icon, array $_texte)
|
|
|
+ private static function printToast(string $_idAlert, string $_style, string $_icon, ?array $_texte = NULL)
|
|
|
{
|
|
|
- echo ' <div class="toast hide" role="alert" aria-live="assertive" aria-atomic="true" data-delay="1500" style="margin-top:10px; ' . $_style . '">
|
|
|
- <div class="toast-header">' . $_icon . '</div><div class="toast-body">' . self::printAlert($_texte) . '</div>
|
|
|
+ $text = ($_texte != NULL) ? self::printAlert($_texte) : NULL;
|
|
|
+
|
|
|
+ echo ' <div id="' . $_idAlert . '" class="toast hide" role="alert" aria-live="assertive" aria-atomic="true" data-delay="1500" style="margin-top:10px; ' . $_style . '">
|
|
|
+ <div class="toast-header">' . $_icon . '</div><div class="toast-body" id="' . $_idAlert . 'Txt">' . $text . '</div>
|
|
|
</div>';
|
|
|
}
|
|
|
|
|
|
public static function show()
|
|
|
{
|
|
|
historique::recordLogs();
|
|
|
-
|
|
|
- if (self::getSuccess() or self::getWarning() or self::getError()) {
|
|
|
-
|
|
|
- echo '<div aria-live="polite" aria-atomic="true" class="position-fixed bottom-0 right-0 p-3" style="z-index: 5; right: 5px; bottom: 0;">';
|
|
|
-
|
|
|
- if (self::getSuccess()) {
|
|
|
- $style = 'background:#d4edda;';
|
|
|
- $icon = '<span data-feather="info" style="color:green;"></span> <strong style="color:green; margin-left:5px;" class="mr-auto">Succès</strong>';
|
|
|
- $texte = self::getSuccess();
|
|
|
- self::printToast($style, $icon, $texte);
|
|
|
- }
|
|
|
-
|
|
|
- if (self::getWarning()) {
|
|
|
- $style = 'background:#fff3cd;';
|
|
|
- $icon = '<span data-feather="alert-circle" style="color:orange;"></span> <strong style="color:orange; margin-left:5px;" class="mr-auto">Attention</strong>';
|
|
|
- $texte = self::getWarning();
|
|
|
- self::printToast($style, $icon, $texte);
|
|
|
- }
|
|
|
-
|
|
|
- if (self::getError()) {
|
|
|
- $style = 'background:#f8d7da;';
|
|
|
- $icon = '<span data-feather="alert-triangle" style="color:red;"></span> <strong style="color:red; margin-left:5px;" class="mr-auto">Erreur</strong>';
|
|
|
- $texte = self::getError();
|
|
|
- self::printToast($style, $icon, $texte);
|
|
|
- }
|
|
|
- echo '</div>';
|
|
|
- }
|
|
|
+
|
|
|
+ echo '<div class="position-fixed bottom-0 right-0 p-3" style="z-index: 5; right: 5px; bottom: 0;">';
|
|
|
+
|
|
|
+ $idAlert = "printToastSuccess";
|
|
|
+ $texte1 = (self::getSuccess()) ? self::getSuccess() : NULL;
|
|
|
+ $style = 'background:#d4edda;';
|
|
|
+ $icon = '<span data-feather="info" style="color:green;"></span> <strong style="color:green; margin-left:5px;" class="mr-auto">Succès</strong>';
|
|
|
+ self::printToast($idAlert, $style, $icon, $texte1);
|
|
|
+
|
|
|
+ $idAlert = "printToastWarning";
|
|
|
+ $texte2 = (self::getWarning()) ? self::getWarning() : NULL;
|
|
|
+ $style = 'background:#fff3cd;';
|
|
|
+ $icon = '<span data-feather="alert-circle" style="color:orange;"></span> <strong style="color:orange; margin-left:5px;" class="mr-auto">Attention</strong>';
|
|
|
+ self::printToast($idAlert, $style, $icon, $texte2);
|
|
|
+
|
|
|
+ $idAlert = "printToastError";
|
|
|
+ $texte3 = (self::getError()) ? self::getError() : NULL;
|
|
|
+ $style = 'background:#f8d7da;';
|
|
|
+ $icon = '<span data-feather="alert-triangle" style="color:red;"></span> <strong style="color:red; margin-left:5px;" class="mr-auto">Erreur</strong>';
|
|
|
+ self::printToast($idAlert, $style, $icon, $texte3);
|
|
|
+
|
|
|
+ echo '</div>';
|
|
|
+
|
|
|
+ echo ($texte1 == NULL) ? '' : '<script>$("#printToastSuccess").toast("show");</script>';
|
|
|
+ echo ($texte2 == NULL) ? '' : '<script>$("#printToastWarning").toast("show");</script>';
|
|
|
+ echo ($texte3 == NULL) ? '' : '<script>$("#printToastError").toast("show");</script>';
|
|
|
+
|
|
|
self::destroyAlert();
|
|
|
}
|
|
|
|