From 7349f221c65b4f52c58efff444399b7d0cf368f6 Mon Sep 17 00:00:00 2001
From: Malf Furious <m@lfurio.us>
Date: Fri, 20 Jul 2018 04:37:05 -0400
Subject: Add the notice modal

---
 app/model/noticemodal.php | 40 +++++++++++++++++++++++++++++++++++
 app/view/stdpage.php      | 53 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 93 insertions(+)
 create mode 100644 app/model/noticemodal.php

diff --git a/app/model/noticemodal.php b/app/model/noticemodal.php
new file mode 100644
index 0000000..c1e99c3
--- /dev/null
+++ b/app/model/noticemodal.php
@@ -0,0 +1,40 @@
+<?php
+
+/*
+ * SCROTT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * For more information, please refer to UNLICENSE
+ */
+
+require_once "class/globals.php";
+
+prep:
+
+if (isError(ERROR))
+{
+    $noticeModalAlertClass = "alert-danger";
+    $noticeModalGlyphicon  = "glyphicon-remove-sign";
+}
+else if (isError(WARNING))
+{
+    $noticeModalAlertClass = "alert-warning";
+    $noticeModalGlyphicon  = "glyphicon-exclamation-sign";
+}
+else if (isError(NOTICE))
+{
+    $noticeModalAlertClass = "alert-info";
+    $noticeModalGlyphicon  = "glyphicon-info-sign";
+}
+else
+{
+    $noticeModalAlertClass = "";
+    $noticeModalGlyphicon  = "";
+}
+
+?>
diff --git a/app/view/stdpage.php b/app/view/stdpage.php
index 7797ef5..2dd29a4 100644
--- a/app/view/stdpage.php
+++ b/app/view/stdpage.php
@@ -73,12 +73,65 @@ require_once "class/user.class.php";
 <?php } ?>
 <?php function top() : void { ?>
 
+    <?php require "model/noticemodal.php"; ?>
+
+    <?php if (isError(ERROR) || isError(WARNING) || isError(NOTICE)) { ?>
+        <div id="noticeModal" class="modal fade" tabindex="-1" role="dialog">
+            <div class="modal-dialog" role="document">
+                <div class="modal-content">
+                    <div class="modal-body alert <?=$noticeModalAlertClass?>" style="margin: 0;">
+                        <h1 class="text-center"><span class="glyphicon <?=$noticeModalGlyphicon?>"></span></h1>
+                        <h5 class="text-center">Something Happened</h5>
+
+                        <?php if (isError(ERROR)) { ?>
+                            <p>
+                                <?php foreach (getErrors(ERROR) as $err) { ?>
+                                    <span class="label label-danger">Error</span> <?=$err?><br />
+                                <?php } ?>
+                            </p>
+                        <?php } ?>
+
+                        <?php if (isError(WARNING)) { ?>
+                            <p>
+                                <?php foreach (getErrors(WARNING) as $err) { ?>
+                                    <span class="label label-warning">Warning</span> <?=$err?><br />
+                                <?php } ?>
+                            </p>
+                        <?php } ?>
+
+                        <?php if (isError(NOTICE)) { ?>
+                            <p>
+                                <?php foreach (getErrors(NOTICE) as $err) { ?>
+                                    <span class="label label-info">Notice</span> <?=$err?><br />
+                                <?php } ?>
+                            </p>
+                        <?php } ?>
+
+                        <div class="text-center">
+                            <button type="button" class="btn btn-default" data-dismiss="modal">
+                                <span class="glyphicon glyphicon-ok"></span> Got it
+                            </button>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    <?php } ?>
+
 <?php } ?>
 <?php function foot() : void { ?>
 
     <script type="text/javascript" src="<?=ar()?>/static/js/jquery.min.js"></script>
     <script type="text/javascript" src="<?=ar()?>/static/js/bootstrap.min.js"></script>
 
+    <?php if (isError(ERROR) || isError(WARNING) || isError(NOTICE)) { ?>
+        <script type="text/javascript">
+            $(window).on('load', function () {
+                $("#noticeModal").modal("show");
+            });
+        </script>
+    <?php } ?>
+
 <?php } ?>
 <?php function nav() : void { ?>
 
-- 
cgit v1.2.3