diff --git a/README.md b/README.md index cc8261e..bd336f2 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ # atlhousingreport + +# Summary diff --git a/classes/Alerts.php b/classes/Alerts.php new file mode 100644 index 0000000..04f2af4 --- /dev/null +++ b/classes/Alerts.php @@ -0,0 +1,392 @@ +current_user_id = $_SESSION[self::USER_ID] ?? ""; + $this->current_user_name = $_SESSION[self::USER_NAME] ?? ""; + $this->current_user_email = $_SESSION[self::USER_EMAIL] ?? ""; + + $this->pagination_page = $_SESSION[self::PAGINATION_PAGE] ?? 1; + } + + // ============ + // Setup Alerts + // ============ + + public function setupAlerts() { + + $alerts = $this->getAlertsPage(); + + $popovers = (new Popovers())->getPopovers(); + + $XML = $this->mergeXML($alerts, ""); + $XML = $this->mergeXML($popovers, $XML); + + $content = $this->applyXSL($XML, $this->getXSL("setupAlerts")); + + $this->displayContent($content); + } + + // ========= + // Add Alert + // ========= + + public function addAlert() { + + $step = filter_input(INPUT_POST, "step") ?: "prompt"; + + switch ($step) { + + case "prompt": + + $content = $this->applyXSL("", $this->getXSL("addAlert")); + + $this->displayContent($content); + + break; + + case "add": + + $alert_title = filter_input(INPUT_POST, "alert_title") ?: ""; + $alert_starts_date = filter_input(INPUT_POST, "alert_starts_date") ?: ""; + $alert_starts_time = filter_input(INPUT_POST, "alert_starts_time") ?: ""; + $alert_expires_date = filter_input(INPUT_POST, "alert_expires_date") ?: ""; + $alert_expires_time = filter_input(INPUT_POST, "alert_expires_time") ?: ""; + $alert_message = filter_input(INPUT_POST, "alert_message") ?: ""; + + $alert_starts = date("Y-m-d H:i", strtotime("{$alert_starts_date} {$alert_starts_time}")); + $alert_expires = date("Y-m-d H:i", strtotime("{$alert_expires_date} {$alert_expires_time}")); + + $SQL = "insert into alerts + + ( alert_title, + alert_started, + alert_expired, + alert_message, + alert_creator, + alert_created ) + + VALUES ( :alert_title, + :alert_started, + :alert_expired, + :alert_message, + :alert_creator, + :alert_created )"; + + $statement = $this->connect()->prepare($SQL); + + $statement->bindValue(":alert_title", $alert_title); + $statement->bindValue(":alert_started", $alert_starts); + $statement->bindValue(":alert_expired", $alert_expires); + $statement->bindValue(":alert_message", $alert_message); + $statement->bindValue(":alert_creator", $this->current_user_name); + $statement->bindValue(":alert_created", $this->getTimestamp()); + + $statement->execute(); + + break; + + default: + + $this->displayHome(); + } + } + + // ============ + // Delete Alert + // ============ + + public function deleteAlert() { + + $alert_serial = filter_input(INPUT_POST, "alert_serial", FILTER_SANITIZE_NUMBER_INT) ?: 0; + + $alert = $this->getAlert($alert_serial); + + if ($alert->count() == 0) { + $this->logError("Invalid Alert ({$alert_serial}). " . __METHOD__); + } + + $SQL = "delete from alerts + where alert_serial = {$alert_serial}"; + + $this->executeSQL($SQL); + } + + // ========== + // Edit Alert + // ========== + + public function editAlert() { + + $step = filter_input(INPUT_POST, "step") ?: "prompt"; + + switch ($step) { + + case "prompt": + + $alert_serial = filter_input(INPUT_POST, "alert_serial", FILTER_SANITIZE_NUMBER_INT) ?: 0; + + $alert = $this->getAlert($alert_serial); + + if ($alert->count() == 0) { + $this->logError("Invalid Alert ({$alert_serial}): " . __METHOD__); + } + + $content = $this->applyXSL($alert, $this->getXSL("editAlert")); + + $this->displayContent($content); + + break; + + case "update": + + $alert_serial = filter_input(INPUT_POST, "alert_serial") ?: 0; + $alert_title = filter_input(INPUT_POST, "alert_title") ?: ""; + $alert_starts_date = filter_input(INPUT_POST, "alert_starts_date") ?: ""; + $alert_starts_time = filter_input(INPUT_POST, "alert_starts_time") ?: ""; + $alert_expires_date = filter_input(INPUT_POST, "alert_expires_date") ?: ""; + $alert_expires_time = filter_input(INPUT_POST, "alert_expires_time") ?: ""; + $alert_message = filter_input(INPUT_POST, "alert_message") ?: ""; + + $alert_starts = date("Y-m-d H:i", strtotime("{$alert_starts_date} {$alert_starts_time}")); + $alert_expires = date("Y-m-d H:i", strtotime("{$alert_expires_date} {$alert_expires_time}")); + + $alert = $this->getAlert($alert_serial); + + if ($alert->count() === 0) { + $this->logError("Invalid Alert ({$alert_serial}). " . __METHOD__); + } + + $connection = $this->connect(); + + $SQL = "update alerts + set alert_title = :alert_title, + alert_started = :alert_started, + alert_expired = :alert_expired, + alert_message = :alert_message + where alert_serial = :alert_serial"; + + $statement = $connection->prepare($SQL); + + $statement->bindValue(":alert_serial", $alert_serial); + $statement->bindValue(":alert_title", $alert_title); + $statement->bindValue(":alert_started", $alert_starts); + $statement->bindValue(":alert_expired", $alert_expires); + $statement->bindValue(":alert_message", $alert_message); + + $statement->execute(); + + break; + + default: + + $this->displayHome(); + } + } + + // ===================== + // Return a Alert Object + // ===================== + + public function getAlert($alert_serial = 0) { + + $SQL = "select *, + date_format(alert_started, '%Y') as alert_started_year, + date_format(alert_started, '%m') as alert_started_month, + date_format(alert_started, '%b') as alert_started_month_abbreviated, + date_format(alert_started, '%M') as alert_started_month_verbose, + date_format(alert_started, '%d') as alert_started_day, + date_format(alert_started, '%a') as alert_started_day_abbreviated, + date_format(alert_started, '%W') as alert_started_day_verbose, + date_format(alert_started, '%Y-%m-%d') as alert_started_date, + date_format(alert_started, '%W, %M %D') as alert_started_date_verbose, + date_format(alert_started, '%H:%i') as alert_started_time, + date_format(alert_started, '%l:%i %p') as alert_started_time_verbose, + date_format(alert_started, '%Y-%m-%d %l:%i %p') as alert_started_verbose, + + date_format(alert_expired, '%Y') as alert_expired_year, + date_format(alert_expired, '%m') as alert_expired_month, + date_format(alert_expired, '%b') as alert_expired_month_abbreviated, + date_format(alert_expired, '%M') as alert_expired_month_verbose, + date_format(alert_expired, '%d') as alert_expired_day, + date_format(alert_expired, '%a') as alert_expired_day_abbreviated, + date_format(alert_expired, '%W') as alert_expired_day_verbose, + date_format(alert_expired, '%Y-%m-%d') as alert_expired_date, + date_format(alert_expired, '%W, %M %D') as alert_expired_date_verbose, + date_format(alert_expired, '%H:%i') as alert_expired_time, + date_format(alert_expired, '%l:%i %p') as alert_expired_time_verbose, + date_format(alert_expired, '%Y-%m-%d %l:%i %p') as alert_expired_verbose + + from alerts + + where alert_serial = {$alert_serial}"; + + return $this->getTable("alerts", $SQL); + } + + // ======================== + // Return a Alerts Object + // ======================== + + public function getAlerts() { + + $SQL = "select view_alerts.* + from view_alerts"; + + return $this->getTable("alerts", $SQL); + } + + // =========================== + // Return a Alerts Page Object + // =========================== + + public function getAlertsPage() { + + // Find Criteria + + $find_alert = filter_input(INPUT_POST, "find_alert") ?: ""; + $find_words = $this->sanitizeString($find_alert); + + // Show Per Page + + $this->pagination_size = filter_input(INPUT_POST, "alerts_per_page", FILTER_SANITIZE_NUMBER_INT) ?: $this->pagination_size; + + // Record Count + + $connection = $this->connect(); + + $SQL = "select count(*) as count + from view_alerts + where alert_title regexp :alert_title"; + + $statement = $connection->prepare($SQL); + + $statement->bindValue(":alert_title", $find_words); + + $statement->execute(); + + $recordset = $statement->fetch(PDO::FETCH_ASSOC); + + $count = (count($recordset) > 0) ? (integer) $recordset["count"] : (integer) 0; + + // Pagination + + $pagination = filter_input(INPUT_POST, "pagination") ?: ""; + + switch ($pagination) { + + case "first" : $this->pagination_page = 1; + break; + case "previous" : $this->pagination_page = max(($this->pagination_page - 1), 1); + break; + case "next" : $this->pagination_page = ($this->pagination_page + 1); + break; + case "last" : $this->pagination_page = ($count / $this->pagination_size); + break; + } + + $offset = (($this->pagination_page * $this->pagination_size) - $this->pagination_size); + $start = ($offset + 1); + $end = min($count, (($start + $this->pagination_size) - 1)); + + // Data + + $SQL = "select view_alerts.* + from view_alerts + where alert_title regexp :alert_title + limit {$this->pagination_size} + offset {$offset}"; + + $statement = $connection->prepare($SQL); + + $statement->bindValue(":alert_title", $find_words); + + $statement->execute(); + + $alerts = $this->getTableXML("alerts", $statement); + + // Insert Pagination Attributes + + $alerts->addAttribute("count", $count); + $alerts->addAttribute("start", $start); + $alerts->addAttribute("end", $end); + $alerts->addAttribute("page", $this->pagination_page); + + $_SESSION[self::PAGINATION_PAGE] = $this->pagination_page; + + return $alerts; + } + + // =============================== + // Return an Active Alerts Object. + // =============================== + + public function getActiveAlerts() { + + $SQL = "select *, + + date_format(alert_started, '%Y') as alert_started_year, + date_format(alert_started, '%m') as alert_started_month, + date_format(alert_started, '%b') as alert_started_month_abbreviated, + date_format(alert_started, '%M') as alert_started_month_verbose, + date_format(alert_started, '%d') as alert_started_day, + date_format(alert_started, '%a') as alert_started_day_abbreviated, + date_format(alert_started, '%W') as alert_started_day_verbose, + date_format(alert_started, '%Y-%m-%d') as alert_started_date, + date_format(alert_started, '%W, %M %D') as alert_started_date_verbose, + date_format(alert_started, '%H:%i') as alert_started_time, + date_format(alert_started, '%l:%i %p') as alert_started_time_verbose, + date_format(alert_started, '%Y-%m-%d %l:%i %p') as alert_started_verbose, + + date_format(alert_expired, '%Y') as alert_expired_year, + date_format(alert_expired, '%m') as alert_expired_month, + date_format(alert_expired, '%b') as alert_expired_month_abbreviated, + date_format(alert_expired, '%M') as alert_expired_month_verbose, + date_format(alert_expired, '%d') as alert_expired_day, + date_format(alert_expired, '%a') as alert_expired_day_abbreviated, + date_format(alert_expired, '%W') as alert_expired_day_verbose, + date_format(alert_expired, '%Y-%m-%d') as alert_expired_date, + date_format(alert_expired, '%W, %M %D') as alert_expired_date_verbose, + date_format(alert_expired, '%H:%i') as alert_expired_time, + date_format(alert_expired, '%l:%i %p') as alert_expired_time_verbose, + date_format(alert_expired, '%Y-%m-%d %l:%i %p') as alert_expired_verbose + + from alerts + + where (alert_started < now() and alert_expired > now()) + + order by alert_expired"; + + $alerts = $this->getTable("alerts", $SQL); + + foreach ($alerts as $alert) { + $alert->alert_time_elapsed = $this->getTimeElapsed((string) $alert->alert_started); + } + + return $alerts; + } +} + +?> diff --git a/classes/Base.php b/classes/Base.php index 02a5efa..bcc3dd1 100644 --- a/classes/Base.php +++ b/classes/Base.php @@ -90,6 +90,8 @@ class Base { $XSLParms["RANDOM_NUMBER"] = rand(); $XSLParms["TODAY_YYYYMMDD"] = date("Y-m-d"); $XSLParms["TODAY_MMDDYYYY"] = date("m/d/Y"); + $XSLParms["TODAY_HHMM"] = date("Hi"); + $XSLParms["COPYRIGHT"] = date("Y"); $XML = new DOMDocument(); $XSL = new DOMDocument(); diff --git a/classes/Subscriptions.php b/classes/Subscriptions.php index 2eac4c2..f5f0f4d 100644 --- a/classes/Subscriptions.php +++ b/classes/Subscriptions.php @@ -577,9 +577,11 @@ class Subscriptions extends Base { public function userSubscriptions() { $subscriptions = $this->getUsersActiveSubscriptions($this->current_user_serial); + $alerts = (new Alerts())->getActiveAlerts(); $popovers = (new Popovers())->getPopovers(); $XML = $this->mergeXML($subscriptions, ""); + $XML = $this->mergeXML($alerts, $XML); $XML = $this->mergeXML($popovers, $XML); $content = $this->applyXSL($XML, $this->getXSL("userSubscriptions")); @@ -602,7 +604,7 @@ class Subscriptions extends Base { return $this->getTable("usersubscriptions", $SQL); } - + // ============================ // Return a Users Subscriptions // ============================ diff --git a/js/addAlert.js b/js/addAlert.js new file mode 100644 index 0000000..5c67e18 --- /dev/null +++ b/js/addAlert.js @@ -0,0 +1,255 @@ + +// ========= +// Add Alert +// ========= + +$(document).ready(function () { + + var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"), $CKEditor; + + // ---------------------- + // Initialize the Editor. + // ---------------------- + + ClassicEditor + .create(document.querySelector('#alert_message'), { + toolbar: { + items: [ + 'heading', + '|', + 'bold', + 'italic', + 'underline', + 'link', + 'bulletedList', + 'numberedList', + '|', + 'fontColor', + 'fontSize', + 'fontFamily', + '|', + 'indent', + 'outdent', + 'alignment', + '|', + 'horizontalLine', + 'insertTable', + '|', + 'undo', + 'redo', + '|' + ]}, + link: { + addTargetToExternalLinks: true, + defaultProtocol: "http://" + + } + }) + .then(editor => { + $CKEditor = editor; + }) + .catch(error => { + console.error('CK-Editor error...'); + console.error(error); + }); + + + // ------------ + // Date Pickers + // ------------ + + $("#alert_starts_date").datepicker({format: "yyyy-mm-dd", + container: "div.starts-date", + keyboardNavigation: false, + autoclose: true, + orientation: "bottom", + todayBtn: "linked", + todayHighlight: true}); + + $("#alert_expires_date").datepicker({format: "yyyy-mm-dd", + container: "div.expires-date", + keyboardNavigation: false, + autoclose: true, + orientation: "bottom", + todayBtn: "linked", + todayHighlight: true}); + + $("#alert_starts_time").inputmask({alias: "datetime", + placeholder: "HH:MM", + inputFormat: "HH:MM", + insertMode: false, + showMaskOnHover: false, + hourFormat: 24 + }); + + $("#alert_expires_time").inputmask({alias: "datetime", + placeholder: "HH:MM", + inputFormat: "HH:MM", + insertMode: false, + showMaskOnHover: false, + hourFormat: 24 + }); + + // --------------------- + // Show Calendar Buttons + // --------------------- + + $(".btnAlertStartDateCalendar").on("click", function (e) { + e.preventDefault(); + $("#alert_starts_date").focus().datepicker("show"); + }); + + $(".btnAlertExpiresDateCalendar").on("click", function (e) { + e.preventDefault(); + $("#alert_expires_date").focus().datepicker("show"); + }); + + + $("#alert_starts_date").on("blur", function () { + $("#alert_starts_time").focus(); + }); + + $("#alert_expires_date").on("blur", function () { + $("#alert_expires_time").focus(); + }); + + // ----------- + // Save Button + // ----------- + + $(".btnSave").on("click", function (e) { + + e.preventDefault(); + + $("#addAlert").submit(); + + }); + + // ------------- + // Cancel Button + // ------------- + + $(".btnCancel").on("click", function () { + + $sessionStorage.action = $sessionStorage.addAlert || ""; + + sessionStorage.setItem($application, JSON.stringify($sessionStorage)); + + formSubmit($sessionStorage); + + }); + + // --------------- + // Validate Inputs + // --------------- + + $("#addAlert").submit(function (e) { + + var alert_title = $("#alert_title"), + alert_starts_date = $("#alert_starts_date"), + alert_starts_time = $("#alert_starts_time"), + alert_expires_date = $("#alert_expires_date"), + alert_expires_time = $("#alert_expires_time"), + alert_message = $("#alert_message"); + + clearInputErrors(); + + alert_title.val(alert_title.val().replace(/\s+/g, " ").trim()); + + if (isBlank(alert_title)) { + createInputError(alert_title, "Title is required"); + return false; + } + + + if ((!isBlank(alert_starts_date)) && (!isDate(alert_starts_date))) { + createInputError(alert_starts_date, "Date is invalid"); + return false; + } + + if (isBlank(alert_starts_time)) { + createInputError(alert_starts_time, "Please enter a Time"); + return false; + } + + if (!alert_starts_time.inputmask("isComplete")) { + createInputError(alert_starts_time, "Please enter a Time"); + return false; + } + + if (isBlank(alert_expires_date)) { + createInputError(alert_expires_date, "Please enter a Date"); + return false; + } + + if ((!isBlank(alert_expires_date)) && (!isDate(alert_expires_date))) { + createInputError(alert_expires_date, "Date is invalid"); + return false; + } + + if (isBlank(alert_expires_time)) { + createInputError(alert_expires_time, "Please enter a Time"); + return false; + } + + if (!alert_expires_time.inputmask("isComplete")) { + createInputError(alert_expires_time, "Please enter a Time"); + return false; + } + +// if (isBlank(alert_message)) { +// createInputError(alert_message, "Please enter a Message"); +// return false; +// } + + if (!checkDateTime(alert_starts_date, alert_starts_time, alert_expires_date, alert_expires_time)) { + createInputError(alert_expires_time, "Cannot be prior to Start"); + return false; + } + + e.preventDefault(); + + $CKEditor.updateSourceElement(); + + $.post("./", $(this).serialize()) + + .done(function () { + + $sessionStorage.action = $sessionStorage.addAlert || ""; + + sessionStorage.setItem($application, JSON.stringify($sessionStorage)); + + formSubmit($sessionStorage); + + }); + + }); + +}); + +// ----------------------------------------------------- +// Expires date/time cannot be prior to Start date/time. +// ----------------------------------------------------- + +function checkDateTime(alert_starts_date, alert_starts_time, alert_expires_date, alert_expires_time) { + + var starts_date_parts = alert_starts_date.val().split("-"), + starts_time_parts = alert_starts_time.val().split(":"), + expires_date_parts = alert_expires_date.val().split("-"), + expires_time_parts = alert_expires_time.val().split(":"), + starts_date, + expires_date; + + starts_date = new Date(starts_date_parts[0], parseInt(starts_date_parts[1], 10) - 1, starts_date_parts[2]); + expires_date = new Date(expires_date_parts[0], parseInt(expires_date_parts[1], 10) - 1, expires_date_parts[2]); + + starts_date.setHours(starts_time_parts[0], starts_time_parts[1], 0, 0); + expires_date.setHours(expires_time_parts[0], expires_time_parts[1], 0, 0); + + if (expires_date.getTime() < starts_date.getTime()) { + return false; + } else { + return true; + } + +} \ No newline at end of file diff --git a/js/addDropdown.js b/js/addDropdown.js index d286dd2..965a912 100644 --- a/js/addDropdown.js +++ b/js/addDropdown.js @@ -3,66 +3,66 @@ // Add Dropdown // ============ -$(document).ready(function() { +$(document).ready(function () { - var $application = "ATLHOUSINGREPORT", - $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"); - - // ----------- - // Save Button - // ----------- - - $(".btnSave").on("click", function(e) { - e.preventDefault(); - $("#addDropdown").submit(); - }); + var $application = $("#APPLICATION_MNEMONIC").val(), + $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"); - // -------------- - // Cancel Button. - // -------------- + // ----------- + // Save Button + // ----------- - $(".btnCancel").on("click", function() { - formSubmit({ action : $sessionStorage.addDropdown }); - }); - - // --------------- - // Validate Inputs - // --------------- - - $("#addDropdown").submit( function(e) { - - var dropdowntype_serial = $("#dropdowntype_serial").val(), - dropdown_value = $("#dropdown_value"); - - clearInputErrors(); - - dropdown_value.val(trimString(dropdown_value.val())); - - if (isBlank(dropdown_value)) { - createInputError(dropdown_value, "Value is required"); - return false; - } - - if (formPost({ action : "Dropdowns.dropdownExists", dropdowntype_serial : dropdowntype_serial, dropdown_serial : 0, dropdown_value : dropdown_value.val() }) === true) { - createInputError(dropdown_value, "Value already exists"); - return false; - } - - e.preventDefault(); - - $.post("./", $(this).serialize()) - - .done(function() { - - $sessionStorage.action = $sessionStorage.addDropdown || ""; - $sessionStorage.toast = "Dropdown was Added"; - - sessionStorage.setItem($application, JSON.stringify($sessionStorage)); - - formSubmit($sessionStorage); - + $(".btnSave").on("click", function (e) { + e.preventDefault(); + $("#addDropdown").submit(); }); - - }); - + + // -------------- + // Cancel Button. + // -------------- + + $(".btnCancel").on("click", function () { + formSubmit({action: $sessionStorage.addDropdown}); + }); + + // --------------- + // Validate Inputs + // --------------- + + $("#addDropdown").submit(function (e) { + + var dropdowntype_serial = $("#dropdowntype_serial").val(), + dropdown_value = $("#dropdown_value"); + + clearInputErrors(); + + dropdown_value.val(trimString(dropdown_value.val())); + + if (isBlank(dropdown_value)) { + createInputError(dropdown_value, "Value is required"); + return false; + } + + if (formPost({action: "Dropdowns.dropdownExists", dropdowntype_serial: dropdowntype_serial, dropdown_serial: 0, dropdown_value: dropdown_value.val()}) === true) { + createInputError(dropdown_value, "Value already exists"); + return false; + } + + e.preventDefault(); + + $.post("./", $(this).serialize()) + + .done(function () { + + $sessionStorage.action = $sessionStorage.addDropdown || ""; + $sessionStorage.toast = "Dropdown was Added"; + + sessionStorage.setItem($application, JSON.stringify($sessionStorage)); + + formSubmit($sessionStorage); + + }); + + }); + }); \ No newline at end of file diff --git a/js/addDropdowntype.js b/js/addDropdowntype.js index 18dc9a7..637e6b8 100644 --- a/js/addDropdowntype.js +++ b/js/addDropdowntype.js @@ -5,7 +5,7 @@ $(document).ready(function() { - var $application = "ATLHOUSINGREPORT", + var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"); // ----------- diff --git a/js/addStatus.js b/js/addStatus.js index c9146eb..c76c772 100644 --- a/js/addStatus.js +++ b/js/addStatus.js @@ -5,7 +5,7 @@ $(document).ready(function() { - var $application = "ATLHOUSINGREPORT", + var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"); // ----------- diff --git a/js/content.js b/js/content.js index 4fb4db7..24500e4 100644 --- a/js/content.js +++ b/js/content.js @@ -263,6 +263,23 @@ $(document).ready(function () { }); + // -------------- + // Setup Alerts + // -------------- + + $(".setup-alerts").on("click", function () { + + $sessionStorage.action = "Alerts.setupAlerts"; + $sessionStorage.pagination = "first"; + $sessionStorage.find_alert = ""; + + sessionStorage.setItem($application, JSON.stringify($sessionStorage)); + + formSubmit($sessionStorage); + + }); + + // ------------- // Setup Reports // ------------- diff --git a/js/editAlert.js b/js/editAlert.js new file mode 100644 index 0000000..b088eaa --- /dev/null +++ b/js/editAlert.js @@ -0,0 +1,255 @@ + +// ========== +// Edit Alert +// ========== + +$(document).ready(function () { + + var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"), $CKEditor; + + // ---------------------- + // Initialize the Editor. + // ---------------------- + + ClassicEditor + .create(document.querySelector('#alert_message'), { + toolbar: { + items: [ + 'heading', + '|', + 'bold', + 'italic', + 'underline', + 'link', + 'bulletedList', + 'numberedList', + '|', + 'fontColor', + 'fontSize', + 'fontFamily', + '|', + 'indent', + 'outdent', + 'alignment', + '|', + 'horizontalLine', + 'insertTable', + '|', + 'undo', + 'redo', + '|' + ]}, + link: { + addTargetToExternalLinks: true, + defaultProtocol: "http://" + + } + }) + .then(editor => { + $CKEditor = editor; + }) + .catch(error => { + console.error('CK-Editor error...'); + console.error(error); + }); + + + // ------------ + // Date Pickers + // ------------ + + $("#alert_starts_date").datepicker({format: "yyyy-mm-dd", + container: "div.starts-date", + keyboardNavigation: false, + autoclose: true, + orientation: "bottom", + todayBtn: "linked", + todayHighlight: true}); + + $("#alert_expires_date").datepicker({format: "yyyy-mm-dd", + container: "div.expires-date", + keyboardNavigation: false, + autoclose: true, + orientation: "bottom", + todayBtn: "linked", + todayHighlight: true}); + + $("#alert_starts_time").inputmask({alias: "datetime", + placeholder: "HH:MM", + inputFormat: "HH:MM", + insertMode: false, + showMaskOnHover: false, + hourFormat: 24 + }); + + $("#alert_expires_time").inputmask({alias: "datetime", + placeholder: "HH:MM", + inputFormat: "HH:MM", + insertMode: false, + showMaskOnHover: false, + hourFormat: 24 + }); + + // --------------------- + // Show Calendar Buttons + // --------------------- + + $(".btnAlertStartDateCalendar").on("click", function (e) { + e.preventDefault(); + $("#alert_starts_date").focus().datepicker("show"); + }); + + $(".btnAlertExpiresDateCalendar").on("click", function (e) { + e.preventDefault(); + $("#alert_expires_date").focus().datepicker("show"); + }); + + + $("#alert_starts_date").on("blur", function () { + $("#alert_starts_time").focus(); + }); + + $("#alert_expires_date").on("blur", function () { + $("#alert_expires_time").focus(); + }); + + // ----------- + // Save Button + // ----------- + + $(".btnSave").on("click", function (e) { + + e.preventDefault(); + + $("#editAlert").submit(); + + }); + + // ------------- + // Cancel Button + // ------------- + + $(".btnCancel").on("click", function () { + + $sessionStorage.action = $sessionStorage.editAlert || ""; + + sessionStorage.setItem($application, JSON.stringify($sessionStorage)); + + formSubmit($sessionStorage); + + }); + + // --------------- + // Validate Inputs + // --------------- + + $("#editAlert").submit(function (e) { + + var alert_title = $("#alert_title"), + alert_starts_date = $("#alert_starts_date"), + alert_starts_time = $("#alert_starts_time"), + alert_expires_date = $("#alert_expires_date"), + alert_expires_time = $("#alert_expires_time"), + alert_message = $("#alert_message"); + + clearInputErrors(); + + alert_title.val(alert_title.val().replace(/\s+/g, " ").trim()); + + if (isBlank(alert_title)) { + createInputError(alert_title, "Title is required"); + return false; + } + + + if ((!isBlank(alert_starts_date)) && (!isDate(alert_starts_date))) { + createInputError(alert_starts_date, "Date is invalid"); + return false; + } + + if (isBlank(alert_starts_time)) { + createInputError(alert_starts_time, "Please enter a Time"); + return false; + } + + if (!alert_starts_time.inputmask("isComplete")) { + createInputError(alert_starts_time, "Please enter a Time"); + return false; + } + + if (isBlank(alert_expires_date)) { + createInputError(alert_expires_date, "Please enter a Date"); + return false; + } + + if ((!isBlank(alert_expires_date)) && (!isDate(alert_expires_date))) { + createInputError(alert_expires_date, "Date is invalid"); + return false; + } + + if (isBlank(alert_expires_time)) { + createInputError(alert_expires_time, "Please enter a Time"); + return false; + } + + if (!alert_expires_time.inputmask("isComplete")) { + createInputError(alert_expires_time, "Please enter a Time"); + return false; + } + +// if (isBlank(alert_message)) { +// createInputError(alert_message, "Please enter a Message"); +// return false; +// } + + if (!checkDateTime(alert_starts_date, alert_starts_time, alert_expires_date, alert_expires_time)) { + createInputError(alert_expires_time, "Cannot be prior to Start"); + return false; + } + + e.preventDefault(); + + $CKEditor.updateSourceElement(); + + $.post("./", $(this).serialize()) + + .done(function () { + + $sessionStorage.action = $sessionStorage.addAlert || ""; + + sessionStorage.setItem($application, JSON.stringify($sessionStorage)); + + formSubmit($sessionStorage); + + }); + + }); + +}); + +// ----------------------------------------------------- +// Expires date/time cannot be prior to Start date/time. +// ----------------------------------------------------- + +function checkDateTime(alert_starts_date, alert_starts_time, alert_expires_date, alert_expires_time) { + + var starts_date_parts = alert_starts_date.val().split("-"), + starts_time_parts = alert_starts_time.val().split(":"), + expires_date_parts = alert_expires_date.val().split("-"), + expires_time_parts = alert_expires_time.val().split(":"), + starts_date, + expires_date; + + starts_date = new Date(starts_date_parts[0], parseInt(starts_date_parts[1], 10) - 1, starts_date_parts[2]); + expires_date = new Date(expires_date_parts[0], parseInt(expires_date_parts[1], 10) - 1, expires_date_parts[2]); + + starts_date.setHours(starts_time_parts[0], starts_time_parts[1], 0, 0); + expires_date.setHours(expires_time_parts[0], expires_time_parts[1], 0, 0); + + if (expires_date.getTime() < starts_date.getTime()) { + return false; + } else { + return true; + } + +} \ No newline at end of file diff --git a/js/editDropdown.js b/js/editDropdown.js index 4977cb7..201eb20 100644 --- a/js/editDropdown.js +++ b/js/editDropdown.js @@ -5,7 +5,7 @@ $(document).ready(function() { - var $application = "ATLHOUSINGREPORT", + var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"); // ----------- diff --git a/js/editDropdowntype.js b/js/editDropdowntype.js index 6643f97..10693ef 100644 --- a/js/editDropdowntype.js +++ b/js/editDropdowntype.js @@ -5,7 +5,7 @@ $(document).ready(function() { - var $application = "ATLHOUSINGREPORT", + var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"); // ----------- diff --git a/js/editPopover.js b/js/editPopover.js index c05dcfb..bdd943b 100644 --- a/js/editPopover.js +++ b/js/editPopover.js @@ -3,160 +3,160 @@ // Edit Popover // ============ -$(document).ready(function() { +$(document).ready(function () { - var $application = "ATLHOUSINGREPORT", - $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"), - $CKEditor; + var $application = $("#APPLICATION_MNEMONIC").val(), + $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"), + $CKEditor; - // ---------------------- - // Initialize the Editor. - // ---------------------- + // ---------------------- + // Initialize the Editor. + // ---------------------- -ClassicEditor - .create( document.querySelector( '#popover_text' ), { - toolbar: { - items: [ - 'heading', - '|', - 'bold', - 'italic', - 'underline', - 'link', - 'bulletedList', - 'numberedList', - '|', - 'fontColor', - 'fontSize', - 'fontFamily', - '|', - 'indent', - 'outdent', - 'alignment', - '|', - 'horizontalLine', - 'insertTable', - '|', - 'undo', - 'redo', - '|' - ] }, - link: { - addTargetToExternalLinks : true, - defaultProtocol : "http://" - - } - }) - .then( editor => { - $CKEditor = editor; - }) - .catch( error => { - console.error( 'CK-Editor error...' ); - console.error( error ); - }); - - // ----------- - // Save Button - // ----------- - - $(".btnSave").on("click", function(e) { - - e.preventDefault(); - - $("#editPopover").submit(); - - }); + ClassicEditor + .create(document.querySelector('#popover_text'), { + toolbar: { + items: [ + 'heading', + '|', + 'bold', + 'italic', + 'underline', + 'link', + 'bulletedList', + 'numberedList', + '|', + 'fontColor', + 'fontSize', + 'fontFamily', + '|', + 'indent', + 'outdent', + 'alignment', + '|', + 'horizontalLine', + 'insertTable', + '|', + 'undo', + 'redo', + '|' + ]}, + link: { + addTargetToExternalLinks: true, + defaultProtocol: "http://" - // -------------- - // Cancel Button. - // -------------- + } + }) + .then(editor => { + $CKEditor = editor; + }) + .catch(error => { + console.error('CK-Editor error...'); + console.error(error); + }); - $(".btnCancel").on("click", function() { - - $sessionStorage.action = $sessionStorage.editPopover || ""; - - sessionStorage.setItem($application, JSON.stringify($sessionStorage)); + // ----------- + // Save Button + // ----------- - formSubmit($sessionStorage); - - }); + $(".btnSave").on("click", function (e) { - // ------------- - // Delete Button - // ------------- + e.preventDefault(); - $(".btnDelete").on("click", function() { + $("#editPopover").submit(); - $("#confirm-dialog").removeClass().addClass("modal confirm-delete-popover") - .find(".modal-title").html("Confirm Delete Popover").end() - .find(".modal-body").html("Are you sure you wish to delete this Popover?").end() - .modal("show"); - - }); - - $("body").on("click", ".confirm-delete-popover .btnConfirmDialogConfirm", function() { - - $.post("./", { action : "Popovers.deletePopover", popover_serial : $sessionStorage.popover_serial }) - - .done(function() { - - $sessionStorage.action = $sessionStorage.editPopover || ""; - - sessionStorage.setItem($application, JSON.stringify($sessionStorage)); - - formSubmit($sessionStorage); - }); - - }); - // --------------- - // Validate Inputs - // --------------- + // -------------- + // Cancel Button. + // -------------- - $("#editPopover").submit( function(e) { + $(".btnCancel").on("click", function () { - var popover_serial = $("#popover_serial"), - popover_name = $("#popover_name"), - popover_title = $("#popover_title"), - popover_text = $("#popover_text"); - - clearInputErrors(); - - popover_name.val(popover_name.val().replace(/\s+/g, " ").trim()); - popover_title.val(popover_title.val().replace(/\s+/g, " ").trim()); - - if (isBlank(popover_name)) { - createInputError(popover_name, "Name is required"); - return false; - } - - if (formPost({ action : "Popovers.popoverExists", popover_serial : popover_serial.val(), popover_name : popover_name.val() }) === true) { - createInputError(popover_name, "Name already exists"); - return false; - } - - if (isBlank(popover_title)) { - createInputError(popover_title, "Title is required"); - return false; - } - - e.preventDefault(); - - $CKEditor.updateSourceElement(); - - $.post("./", $(this).serialize()) - - .done(function() { - - $sessionStorage.action = $sessionStorage.editPopover || ""; + $sessionStorage.action = $sessionStorage.editPopover; sessionStorage.setItem($application, JSON.stringify($sessionStorage)); formSubmit($sessionStorage); - + }); - - }); - + + // ------------- + // Delete Button + // ------------- + + $(".btnDelete").on("click", function () { + + $("#confirm-dialog").removeClass().addClass("modal confirm-delete-popover") + .find(".modal-title").html("Confirm Delete Popover").end() + .find(".modal-body").html("Are you sure you wish to delete this Popover?").end() + .modal("show"); + + }); + + $("body").on("click", ".confirm-delete-popover .btnConfirmDialogConfirm", function () { + + $.post("./", {action: "Popovers.deletePopover", popover_serial: $sessionStorage.popover_serial}) + + .done(function () { + + $sessionStorage.action = $sessionStorage.editPopover || ""; + + sessionStorage.setItem($application, JSON.stringify($sessionStorage)); + + formSubmit($sessionStorage); + + }); + + }); + + // --------------- + // Validate Inputs + // --------------- + + $("#editPopover").submit(function (e) { + + var popover_serial = $("#popover_serial"), + popover_name = $("#popover_name"), + popover_title = $("#popover_title"), + popover_text = $("#popover_text"); + + clearInputErrors(); + + popover_name.val(popover_name.val().replace(/\s+/g, " ").trim()); + popover_title.val(popover_title.val().replace(/\s+/g, " ").trim()); + + if (isBlank(popover_name)) { + createInputError(popover_name, "Name is required"); + return false; + } + + if (formPost({action: "Popovers.popoverExists", popover_serial: popover_serial.val(), popover_name: popover_name.val()}) === true) { + createInputError(popover_name, "Name already exists"); + return false; + } + + if (isBlank(popover_title)) { + createInputError(popover_title, "Title is required"); + return false; + } + + e.preventDefault(); + + $CKEditor.updateSourceElement(); + + $.post("./", $(this).serialize()) + + .done(function () { + + $sessionStorage.action = $sessionStorage.editPopover; + + sessionStorage.setItem($application, JSON.stringify($sessionStorage)); + + formSubmit($sessionStorage); + + }); + + }); + }); \ No newline at end of file diff --git a/js/editStatus.js b/js/editStatus.js index 25f1b47..2fb7852 100644 --- a/js/editStatus.js +++ b/js/editStatus.js @@ -5,7 +5,7 @@ $(document).ready(function() { - var $application = "ATLHOUSINGREPORT", + var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"); // ----------- diff --git a/js/selectReport.js b/js/selectReport.js index f8dc677..2ddccbc 100644 --- a/js/selectReport.js +++ b/js/selectReport.js @@ -5,7 +5,7 @@ $(document).ready(function() { - var $application = "ATLHOUSINGREPORT", + var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"); // ----------- diff --git a/js/setupAlerts.js b/js/setupAlerts.js new file mode 100644 index 0000000..2ce38ab --- /dev/null +++ b/js/setupAlerts.js @@ -0,0 +1,205 @@ + +// ============== +// Setup Alerts +// ============== + +$(document).ready(function () { + + var $application = $("#APPLICATION_MNEMONIC").val(), + $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"); + + // ----------- + // Find Button + // ----------- + + $(".btnFind").on("click", function () { + + $sessionStorage.action = "Alerts.setupAlerts"; + $sessionStorage.pagination = "first"; + + sessionStorage.setItem($application, JSON.stringify($sessionStorage)); + + $("#spinner-dialog").modal("show"); + + formSubmit($sessionStorage); + + }); + + $("#find_alert").on("keyup", function (e) { + if (e.key === "Enter") { + $(".btnFind").trigger("click"); + } + }); + + // ----------------- + // Clear Find Button + // ----------------- + + $(".btnClearFind").on("click", function () { + + $("#find_alert").val("").trigger("change"); + + $sessionStorage.action = "Alerts.setupAlerts"; + $sessionStorage.pagination = "first"; + + sessionStorage.setItem($application, JSON.stringify($sessionStorage)); + + $("#spinner-dialog").modal("show"); + + formSubmit($sessionStorage); + + }); + + // ------------------ + // Pagination Buttons + // ------------------ + + $(".btnPagination").on("click", function () { + + $sessionStorage.action = "Alerts.setupAlerts"; + $sessionStorage.pagination = $(this).data("pagination"); + + sessionStorage.setItem($application, JSON.stringify($sessionStorage)); + + $("#spinner-dialog").modal("show"); + + formSubmit($sessionStorage); + + delete $sessionStorage.pagination; + + sessionStorage.setItem($application, JSON.stringify($sessionStorage)); + + }); + + // ---------- + // Add Button + // ---------- + + $(".btnAdd").on("click", function () { + + $sessionStorage.action = "Alerts.addAlert"; + $sessionStorage.addAlert = "Alerts.setupAlerts"; + + sessionStorage.setItem($application, JSON.stringify($sessionStorage)); + + formSubmit($sessionStorage); + + }); + + // ----------- + // Done Button + // ----------- + + $(".btnDone").on("click", function () { + + formSubmit({action: ""}); + + }); + + // ---- + // Edit + // ---- + + $("#alerts-table tbody").on("click touch", "tr", function (e) { + + e.preventDefault(); + + $sessionStorage.action = "Alerts.editAlert"; + $sessionStorage.alert_serial = $(this).data("alert-serial"); + $sessionStorage.editAlert = "Alerts.setupAlerts"; + + sessionStorage.setItem($application, JSON.stringify($sessionStorage)); + + formSubmit($sessionStorage); + + }); + + // ------------------- + // Save Changed Inputs + // ------------------- + + $(".autosave").on("change", function (e) { + + switch (e.target.type) { + + case "text" : + $sessionStorage[e.target.name] = $(this).val(); + break; + case "radio" : + $sessionStorage[e.target.name] = $(this).val(); + break; + case "checkbox" : + $sessionStorage[e.target.name] = $(this).prop("checked"); + break; + case "select-one" : + $sessionStorage[e.target.name] = $(this).val(); + break; + case "hidden" : + $sessionStorage[e.target.name] = $(this).val(); + break; + + default : + $sessionStorage[e.target.name] = $(this).val(); + break; + + } + + sessionStorage.setItem($application, JSON.stringify($sessionStorage)); + + }); + + // ---------------- + // Initalize Inputs + // ---------------- + + $.each($sessionStorage, function (name, value) { + + var $input = $(":input").filter("[name='" + name + "']"); + + if ($input.length > 0) { + + switch ($input.prop("type")) { + + case "text" : + $input.val(value); + break; + case "radio" : + $input.filter("[value=" + value + "]").prop("checked", true); + break; + case "checkbox" : + $input.prop("checked", value); + break; + case "select-one" : + $input.val(value); + break; + case "hidden" : + $input.val(value); + break; + + default : + $input.val(value); + break; + + } + + } + + }); + + // ------------------ + // Save preset Inputs + // ------------------ + + $("input[type=radio]:checked").trigger("change"); + + // ----------------- + // Per Page Dropdown + // ----------------- + + $("#alerts_per_page").on("change", function () { + + $(".btnFind").trigger("click"); + + }); + +}); \ No newline at end of file diff --git a/js/setupDropdowns.js b/js/setupDropdowns.js index e3fbdb7..02c6673 100644 --- a/js/setupDropdowns.js +++ b/js/setupDropdowns.js @@ -5,7 +5,7 @@ $(document).ready(function() { - var $application = "ATLHOUSINGREPORT", + var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"); // -------------------------------- diff --git a/js/setupDropdowntypes.js b/js/setupDropdowntypes.js index a9230ce..35a3d5c 100644 --- a/js/setupDropdowntypes.js +++ b/js/setupDropdowntypes.js @@ -5,7 +5,7 @@ $(document).ready(function() { - var $application = "ATLHOUSINGREPORT", + var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"); // ----------- diff --git a/js/setupPopovers.js b/js/setupPopovers.js index 65ec089..eb615f2 100644 --- a/js/setupPopovers.js +++ b/js/setupPopovers.js @@ -3,179 +3,203 @@ // Setup Popovers // ============== -$(document).ready(function() { +$(document).ready(function () { - var $application = "PARKS", - $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"); - - // ----------- - // Find Button - // ----------- - - $(".btnFind").on("click", function() { - - $sessionStorage.action = "Popovers.setupPopovers"; - $sessionStorage.pagination = "first"; - - sessionStorage.setItem($application, JSON.stringify($sessionStorage)); - - $("#spinner-dialog").modal("show"); - - formSubmit($sessionStorage); - - }); + var $application = $("#APPLICATION_MNEMONIC").val(), + $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"); - $("#find_popover").on("keyup", function(e) { - if (e.key === "Enter") { - $(".btnFind").trigger("click"); - } - }); - - // ----------------- - // Clear Find Button - // ----------------- - - $(".btnClearFind").on("click", function() { - - $("#find_popover").val("").trigger("change"); - - $sessionStorage.action = "Popovers.setupPopovers"; - $sessionStorage.pagination = "first"; - - sessionStorage.setItem($application, JSON.stringify($sessionStorage)); - - $("#spinner-dialog").modal("show"); - - formSubmit($sessionStorage); - - }); - - // ------------------ - // Pagination Buttons - // ------------------ - - $(".btnPagination").on("click", function() { - - $sessionStorage.action = "Popovers.setupPopovers"; - $sessionStorage.pagination = $(this).data("pagination"); - - sessionStorage.setItem($application, JSON.stringify($sessionStorage)); - - $("#spinner-dialog").modal("show"); - - formSubmit($sessionStorage); - - delete $sessionStorage.pagination; - - sessionStorage.setItem($application, JSON.stringify($sessionStorage)); - - }); - - // ---------- - // Add Button - // ---------- - - $(".btnAdd").on("click", function() { - - $sessionStorage.action = "Popovers.addPopover"; - $sessionStorage.addPopover = "Popovers.setupPopovers"; - - sessionStorage.setItem($application, JSON.stringify($sessionStorage)); - - formSubmit($sessionStorage); - - }); - - // ----------- - // Done Button - // ----------- - - $(".btnDone").on("click", function() { - - formSubmit({ action : "" }); - - }); + // ----------- + // Find Button + // ----------- - // ---- - // Edit - // ---- + $(".btnFind").on("click", function () { - $("#popovers-table tbody").on("click touch", "tr", function(e) { + $sessionStorage.action = "Popovers.setupPopovers"; + $sessionStorage.pagination = "first"; - e.preventDefault(); - - $sessionStorage.action = "Popovers.editPopover"; - $sessionStorage.popover_serial = $(this).data("popover-serial"); - $sessionStorage.editPopover = "Popovers.setupPopovers"; - - sessionStorage.setItem($application, JSON.stringify($sessionStorage)); - - formSubmit($sessionStorage); + sessionStorage.setItem($application, JSON.stringify($sessionStorage)); - }); + $("#spinner-dialog").modal("show"); - // ------------------- - // Save Changed Inputs - // ------------------- + formSubmit($sessionStorage); - $(".autosave").on("change", function(e) { + }); - switch (e.target.type) { + $("#find_popover").on("keyup", function (e) { + if (e.key === "Enter") { + $(".btnFind").trigger("click"); + } + }); - case "text" : $sessionStorage[e.target.name] = $(this).val(); break; - case "radio" : $sessionStorage[e.target.name] = $(this).val(); break; - case "checkbox" : $sessionStorage[e.target.name] = $(this).prop("checked"); break; - case "select-one" : $sessionStorage[e.target.name] = $(this).val(); break; - case "hidden" : $sessionStorage[e.target.name] = $(this).val(); break; + // ----------------- + // Clear Find Button + // ----------------- - default : $sessionStorage[e.target.name] = $(this).val(); break; + $(".btnClearFind").on("click", function () { - } + $("#find_popover").val("").trigger("change"); - sessionStorage.setItem($application, JSON.stringify($sessionStorage)); + $sessionStorage.action = "Popovers.setupPopovers"; + $sessionStorage.pagination = "first"; - }); + sessionStorage.setItem($application, JSON.stringify($sessionStorage)); - // ---------------- - // Initalize Inputs - // ---------------- + $("#spinner-dialog").modal("show"); - $.each($sessionStorage, function(name, value) { + formSubmit($sessionStorage); - var $input = $(":input").filter("[name='" + name + "']"); + }); - if ($input.length > 0) { + // ------------------ + // Pagination Buttons + // ------------------ - switch ($input.prop("type")) { + $(".btnPagination").on("click", function () { - case "text" : $input.val(value); break; - case "radio" : $input.filter("[value=" + value + "]").prop("checked", true); break; - case "checkbox" : $input.prop("checked", value); break; - case "select-one" : $input.val(value); break; - case "hidden" : $input.val(value); break; + $sessionStorage.action = "Popovers.setupPopovers"; + $sessionStorage.pagination = $(this).data("pagination"); - default : $input.val(value); break; + sessionStorage.setItem($application, JSON.stringify($sessionStorage)); - } + $("#spinner-dialog").modal("show"); - } + formSubmit($sessionStorage); - }); + delete $sessionStorage.pagination; - // ------------------ - // Save preset Inputs - // ------------------ + sessionStorage.setItem($application, JSON.stringify($sessionStorage)); - $("input[type=radio]:checked").trigger("change"); + }); - // ----------------- - // Per Page Dropdown - // ----------------- + // ---------- + // Add Button + // ---------- - $("#popovers_per_page").on("change", function() { + $(".btnAdd").on("click", function () { + + $sessionStorage.action = "Popovers.addPopover"; + $sessionStorage.addPopover = "Popovers.setupPopovers"; + + sessionStorage.setItem($application, JSON.stringify($sessionStorage)); + + formSubmit($sessionStorage); + + }); + + // ----------- + // Done Button + // ----------- + + $(".btnDone").on("click", function () { + + formSubmit({action: ""}); + + }); + + // ---- + // Edit + // ---- + + $("#popovers-table tbody").on("click touch", "tr", function (e) { + + e.preventDefault(); + + $sessionStorage.action = "Popovers.editPopover"; + $sessionStorage.popover_serial = $(this).data("popover-serial"); + $sessionStorage.editPopover = "Popovers.setupPopovers"; + + sessionStorage.setItem($application, JSON.stringify($sessionStorage)); + + formSubmit($sessionStorage); + + }); + + // ------------------- + // Save Changed Inputs + // ------------------- + + $(".autosave").on("change", function (e) { + + switch (e.target.type) { + + case "text" : + $sessionStorage[e.target.name] = $(this).val(); + break; + case "radio" : + $sessionStorage[e.target.name] = $(this).val(); + break; + case "checkbox" : + $sessionStorage[e.target.name] = $(this).prop("checked"); + break; + case "select-one" : + $sessionStorage[e.target.name] = $(this).val(); + break; + case "hidden" : + $sessionStorage[e.target.name] = $(this).val(); + break; + + default : + $sessionStorage[e.target.name] = $(this).val(); + break; + + } + + sessionStorage.setItem($application, JSON.stringify($sessionStorage)); + + }); + + // ---------------- + // Initalize Inputs + // ---------------- + + $.each($sessionStorage, function (name, value) { + + var $input = $(":input").filter("[name='" + name + "']"); + + if ($input.length > 0) { + + switch ($input.prop("type")) { + + case "text" : + $input.val(value); + break; + case "radio" : + $input.filter("[value=" + value + "]").prop("checked", true); + break; + case "checkbox" : + $input.prop("checked", value); + break; + case "select-one" : + $input.val(value); + break; + case "hidden" : + $input.val(value); + break; + + default : + $input.val(value); + break; + + } + + } + + }); + + // ------------------ + // Save preset Inputs + // ------------------ + + $("input[type=radio]:checked").trigger("change"); + + // ----------------- + // Per Page Dropdown + // ----------------- + + $("#popovers_per_page").on("change", function () { + + $(".btnFind").trigger("click"); + + }); - $(".btnFind").trigger("click"); - - }); - }); \ No newline at end of file diff --git a/js/setupReports.js b/js/setupReports.js index 96a1009..7759841 100644 --- a/js/setupReports.js +++ b/js/setupReports.js @@ -5,7 +5,7 @@ $(document).ready(function() { - var $application = "ATLHOUSINGREPORT", + var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"); // ----------- diff --git a/js/viewJournal.js b/js/viewJournal.js index d3eaa30..4173fdc 100644 --- a/js/viewJournal.js +++ b/js/viewJournal.js @@ -5,7 +5,7 @@ $(document).ready(function() { - var $application = "ATLHOUSINGREPORT", + var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"); // ----------- diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml index 447637e..6807a2b 100644 --- a/nbproject/private/private.xml +++ b/nbproject/private/private.xml @@ -2,10 +2,6 @@ - - file:/C:/Users/JamesRichie/OneDrive%20-%20OneSource%20IT%20Solutions%20LLC/Documents/NetBeansProjects/dec-international/atlhousingreport/classes/SupportTickets.php - file:/C:/Users/JamesRichie/OneDrive%20-%20OneSource%20IT%20Solutions%20LLC/Documents/NetBeansProjects/dec-international/atlhousingreport/xsl/viewSupportTickets.xsl - file:/C:/Users/JamesRichie/OneDrive%20-%20OneSource%20IT%20Solutions%20LLC/Documents/NetBeansProjects/dec-international/atlhousingreport/js/viewSupportTickets.js - + diff --git a/tables/alerts.php b/tables/alerts.php new file mode 100644 index 0000000..aeddf57 --- /dev/null +++ b/tables/alerts.php @@ -0,0 +1,23 @@ + diff --git a/views/view_alerts.php b/views/view_alerts.php new file mode 100644 index 0000000..46a6367 --- /dev/null +++ b/views/view_alerts.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/xsl/addAlert.xsl b/xsl/addAlert.xsl new file mode 100644 index 0000000..094b997 --- /dev/null +++ b/xsl/addAlert.xsl @@ -0,0 +1,137 @@ + + + + + + + + 1.0 + Add Alert + addAlert + + + +