7 $self =
"$menu_link?ft=$ft";
9 $parameters = array(
"a" => array(
"email" =>
""));
10 $string = array(
"filter" => FILTER_DEFAULT);
11 HCU_ImportVars($parameters,
"a", array(
"email" => $string));
12 extract($parameters[
"a"]);
14 require_once(
"$sharedLibrary/sFeatureMnu.i");
15 require_once(dirname(__FILE__) .
"/cu_notify.data");
17 if ($operation !=
"") {
20 $returnArray = readWelcome($dbh, $Cu, $live);
22 case "updateSpecialNotification":
23 $returnArray = UpdateEmailNotify($dbh, $Cu, $Cn,
"hcunotice", $email,
true);
25 default: $returnArray = array(
"sql" => array(),
"error" => array(
"Operation not recognized: $operation."),
"record" => array());
29 header(
'Content-type: application/json');
30 print HCU_JsonEncode($returnArray);
32 printWelcomePage($self, $main, $live);
49 function readWelcome ($dbh, $Cu, $live) {
50 $returnArray = array();
53 $sql =
"select cu, email from cuadmnotify where role = 'hcunotice' and cu = '$Cu' limit 1";
54 $sth = db_query($sql, $dbh);
56 throw new exception(
"Special notification email query failed.", 1);
58 $row = db_fetch_assoc($sth, 0);
59 $specialNotificationEmail = trim($row[
"email"]);
61 $liveSQL = isset($live) ? ($live ==
"Y" ?
"L" :
"B") :
"";
62 $liveSQL = $liveSQL ==
"" ?
"" :
" and (livebatch = 'A' or livebatch = '$liveSQL') ";
63 $sql =
"select id as mid, active_date, message, subject, active_date >= now() - interval '30 days' as important from cuadmin_message where (expires_on is null or now() < expires_on) 64 $liveSQL and active_date <= now() order by active_date desc, id desc, subject";
65 $sth = db_query($sql, $dbh);
67 throw new exception(
"cuadmin message query failed.", 2);
70 for($i = 0; $row = db_fetch_assoc($sth, $i); $i++) {
71 $row[
"important"] = trim($row[
"important"]) ==
"t";
72 $row[
"subject"] = strtr(hcu_displayHtml($row[
'subject'], ENT_QUOTES), array(
"\\r" =>
"\r",
"\\n" =>
"\n"));
73 $row[
"message"] = strtr(trim($row[
'message']), array(
"\\r" =>
"\r",
"\\n" =>
"\n"));
77 $afterHoursSupport = readAfterHours($dbh, $Cu,
false);
80 $results = ReadEmailNotify($dbh, $Cu);
81 if ($results [
"status"] !=
"000") {
82 throw new exception (
"Read email notify failed.", 3);
85 foreach($results[
"data"][
"gridData"] as $record) {
88 if (!$record[
"single"]) {
92 if (trim(strtolower($record[
"email"])) == GetTemporaryEmail()) {
99 }
catch(exception $e) {
100 return array(
"error" => array($e->getMessage()),
"messages" => array(),
"afterHoursSupport" => array(),
"specialNotificationEmail" =>
"",
"nagPlease" =>
false);
102 return array(
"error" => array(),
"messages" => $messages,
"afterHoursSupport" => $afterHoursSupport,
"specialNotificationEmail" => $specialNotificationEmail,
"nagPlease" => $nagPlease);
116 function readAfterHours($dbh, $Cu, $editable) {
117 $sql =
"select contactid, priority, name, phone, comments from cucontact where user_name = '" . strtolower($Cu) .
"' order by user_name, priority";
118 $sth = db_query($sql, $dbh);
120 throw new exception(
"After Hours Support query failed.", 3);
122 $afterHoursSupport = array();
123 for($i = 0; $row = db_fetch_assoc($sth, $i); $i++) {
124 $row[
"phone"] = preg_replace(
'/[^0-9]*/',
"", $row[
"phone"]);
126 $row[
"pid"] = $i + 1;
128 $length = strlen($row[
"phone"]);
129 $row[
"phone"] = $length == 10 ?
"(" . substr($row[
"phone"], 0, 3) .
") " . substr($row[
"phone"], 3, 3) .
"-" . substr($row[
"phone"], 6)
130 : ($length == 7 ? substr($row[
"phone"], 0, 3) .
"-" . substr($row[
"phone"], 3) :
"");
132 if (trim($row[
"phone"]) ==
"") {
133 throw new exception(
"Phone is invalid.", 4);
135 $row[
"name"] = trim($row[
"name"]);
136 $row[
"comments"] = trim($row[
"comments"]);
137 $afterHoursSupport[] = $row;
139 return $afterHoursSupport;
150 function printWelcomePage($self, $main, $live) {
153 <style type=
"text/css">
154 <?php printTopCenterCss(300); ?>
157 <script type=
"text/javascript">
158 <?php getShowWaitFunctions(); ?>
160 var live =
"<?php echo $live; ?>";
161 var activeWindows = [];
164 var admDataSource =
null;
165 var admDataWelcomeAHS =
null;
166 var admDataWelcomeMSG =
null;
167 var admDataWelcomeSNE =
null;
169 var admActionAddSpecialEmail =
null;
170 var admActionEditSpecialEmail =
null;
171 var admActionSaveSpecialEmail =
null;
172 var admActionCancelSpecialEmail =
null;
173 var admInputSpecialEmail =
null;
175 var admViewWhatsNew =
null;
176 var admViewSpecialEmail =
null;
177 var admViewSpecialEmailPopup =
null;
178 var admViewSpecialEmailValidator =
null;
179 var admViewAfterHours =
null;
180 var admViewMessagesDialog =
null;
182 var admTemplateWhatsNew =
null;
183 var admTemplateSpecialEmail =
null;
184 var admTemplateSpecialEmailPopup =
null;
185 var admTemplateMessagesPopup =
null;
187 function SaveSpecialEmail(e) {
188 var emailValue = admDataWelcomeSNE.email;
189 var emailNew = admInputSpecialEmail.val();
191 if (emailValue != emailNew) {
192 if ($.homecuValidator.validate()) {
193 var updateEmailRequest = {
194 operation:
"updateSpecialNotification",
198 admDataSource.transport.options.read.type =
"POST";
199 admDataSource.read(updateEmailRequest);
200 admViewSpecialEmailPopup.close();
203 admViewSpecialEmailPopup.close();
207 function OpenSpecialEmailPopup() {
208 admViewSpecialEmailPopup.center();
209 admViewSpecialEmailPopup.open();
218 function BuildViewNagPlease() {
219 var address =
"main.prg?ft=46";
221 template +=
"<p>There are emails that have not been verified. Please go to the <a href='" + address +
"'>CU Email Notifications</a> screen ";
222 template +=
"and verify the email(s) you would like to use for sending Digital Banking emails to users.</p>";
223 template +=
"<p>Once the email is verified, select the email form the list where you see <?php echo GetTemporaryEmail(); ?>.";
225 var nagPleaseDialog = $(
"<div id='nagPleaseDialog'></div>").appendTo(
"body").kendoDialog({
226 title:
"Unverified Feature Emails",
229 {text:
"Okay", primary:
true}
234 }).data(
"kendoDialog");
236 nagPleaseDialog.open().center();
239 function BuildViewAfterHours() {
240 admViewAfterHours = $(
"#viewAfterHours").kendoGrid({
242 data: admDataWelcomeAHS,
247 priority: {type:
"number"},
248 name: {type:
"string"},
249 phone: {type:
"string"},
250 comments: {type:
"string"}
254 filter: {field:
"priority",
operator:
"le", value: 3} <?php
257 {field:
"priority", title:
"Priority"},
258 {field:
"name", title:
"Name"},
259 {field:
"phone", title:
"Phone"},
260 {field:
"comments", title:
"Comments"}
262 }).data(
"kendoGrid");
265 function BuildViewSpecialEmailPopup() {
267 admViewSpecialEmailPopup = $(
"#viewSpecialEmailPopup").kendoWindow({
268 title:
"Special Email Notification",
274 template: admTemplateSpecialEmailPopup
278 $.homecuValidator.setup({
279 formStatusField:
'viewSpecialEmailStatus',
280 formValidate:
'viewSpecialEmailPopup' 283 this.wrapper.css({ top: 100 });
284 admInputSpecialEmail.val(admDataWelcomeSNE.email);
285 activeWindows.push(
this);
290 $.homecuValidator.setup({
291 formStatusField:
'admInfoBar',
292 formValidate:
'welcomeDiv' 295 admInputSpecialEmail.val(
"");
298 }).data(
"kendoWindow");
299 admActionSaveSpecialEmail = $(
"#viewSpecialEmailPopup #btnSpecialEmailSave");
300 admInputSpecialEmail = $(
"#viewSpecialEmailPopup #inpSpecialEmail");
303 function BuildViewWhatsNew() {
304 for (var i = 0; i < admDataWelcomeMSG.length; i++) {
305 var templateData = admDataWelcomeMSG[i];
306 var templateResult = admTemplateWhatsNew(templateData);
307 admViewWhatsNew.append(templateResult);
311 function BuildViewSpecialEmail() {
313 admViewSpecialEmail.empty();
314 var templateData = admDataWelcomeSNE;
315 var templateResult = admTemplateSpecialEmail(templateData);
316 admViewSpecialEmail.append(templateResult);
317 admActionAddSpecialEmail = $(
"#btnSpecialEmailAdd");
318 admActionEditSpecialEmail = $(
"#btnSpecialEmailEdit");
319 admActionAddSpecialEmail.on(
"click", OpenSpecialEmailPopup);
320 admActionEditSpecialEmail.on(
"click", OpenSpecialEmailPopup);
323 function InitDataActions() {
324 $(
".specialEmailBtn").on(
"click", OpenSpecialEmailPopup);
325 admActionSaveSpecialEmail.on(
"click", SaveSpecialEmail);
328 var grid = $(
"#viewAfterHours").data(
"kendoGrid");
329 if (grid && grid.dataSource.data().length <= 3) {
330 $(
"#expandAfterHoursBtn").
remove();
331 }
else if (grid && $(
"#expandAfterHoursBtn:visible").length > 0) {
332 $(
"#expandAfterHoursBtn").on(
"click",
function() {
333 var filter = $(
this).text().trim() ==
"Show All" ? null : {field:
"priority",
operator:
"le", value: 3};
334 grid.dataSource.filter(filter);
335 $(
this).text($(
this).text() ==
"Show All" ?
"Show Top 3" :
"Show All");
341 function InitDataViews(nagPlease) {
342 var templateData =
null;
343 var templateResult =
null;
345 admViewWhatsNew = $(
"#viewWhatsNew");
346 admTemplateWhatsNew = kendo.template($(
"#templateWhatsNew").html());
349 admViewSpecialEmail = $(
"#viewSpecialEmail");
350 admTemplateSpecialEmail = kendo.template($(
"#templateSpecialEmail").html());
351 BuildViewSpecialEmail();
353 admTemplateSpecialEmailPopup = $(
"#templateSpecialEmailPopup").html();
354 BuildViewSpecialEmailPopup();
356 admTemplateMessagesPopup = kendo.template($(
"#templateMessagesPopup").html());
359 BuildViewAfterHours();
363 BuildViewNagPlease();
367 function InitDataSources() {
368 admDataWelcomeAHS = [];
369 admDataWelcomeMSG = [];
370 admDataWelcomeSNE = {};
372 admDataSource =
new kendo.data.DataSource({
375 url:
"<?php echo $self; ?>&operation=readWelcome",
377 contentType:
"application/x-www-form-urlencoded",
381 requestStart:
function(request) {
384 requestEnd:
function(response) {
386 $.homecuValidator.setup({formValidate:
'welcomeDiv', formStatusField:
'admInfoBar'});
387 if (response.hasOwnProperty(
"response")) {
389 var results = response.response;
390 if (results.error.length > 0) {
391 throw response.response.error;
393 $.homecuValidator.displayMessage(results.info, $.homecuValidator.settings.statusInfo );
396 throw "Error Parsing Server";
399 $.homecuValidator.displayMessage(error, $.homecuValidator.settings.statusError);
403 parse:
function(response) {
405 if (response.error.length == 0) {
406 if (response.hasOwnProperty(
"record")) {
407 admDataWelcomeSNE.email = response.record[0].email;
408 BuildViewSpecialEmail();
410 admDataWelcomeAHS = response.afterHoursSupport;
411 admDataWelcomeMSG = response.messages;
412 admDataWelcomeSNE = { email: response.specialNotificationEmail };
413 InitDataViews(response.nagPlease);
419 setTimeout(
function() {
420 if (admViewMessagesDialog) {
421 admViewMessagesDialog.open();
430 $(document).ready(
function() {
431 admInfoBar = $(
"#admInfoBar");
434 admDataSource.read();
436 <?php printClickOverlayEvent(); ?>
450 <div
class=
"container-fluid" style=
"margin-bottom: 50px;" id=
"welcomeDiv">
453 <div
class=
"well well-sm col-sm-12" id=
"admInfoBar" style=
"display: none;"></div>
455 <?php
if ($live ==
"Y") { ?>
456 <div
class=
"well well-sm col-sm-12">
457 <h3
class=
"local-h3">After Hours Support</h3> <a href=
"<?php echo $main; ?>?ft=28">Edit</a>
458 <div
class=
"col-sm-12">
460 <div
id=
"viewAfterHours"></div>
461 <a href=
"#" id=
"expandAfterHoursBtn">Show All</a>
467 <div
class=
"well well-sm col-sm-12">
469 <h3
class=
"local-h3">Special Notification Email</h3> <a
class=
"specialEmailBtn" href=
"#">Edit</a>
470 <div
id=
"viewSpecialEmail"></div>
473 <div
class=
"well well-sm col-sm-12">
475 <h2>What
's New at HomeCU?</h2> 476 <div id="viewWhatsNew"></div> 480 <div id="viewSpecialEmailPopup" style="display: none;"></div> 481 <div id="viewMessagesDialog"></div> 483 <script type="text/x-kendo-template" id="templateMessagesPopup"> 484 <div class="well well-sm col-sm-12 k-success-colored"> 485 <span>#= subject #</span> 489 <script type="text/x-kendo-template" id="templateSpecialEmailPopup"> 490 <div id="viewSpecialEmailStatus"></div> 491 <div class="col-sm-12 hcu-container-margin"> 492 <div class="hcu-secondary"> 493 <div class="small vsgSecondary"> 494 <span>To enter a list of addresses, use a semi-colon (;) to separate multiple addresses.</span> 498 <label>Email:</label> 499 <input type="text" class="k-textbox hcu-full-width" id="inpSpecialEmail" name="inpSpecialEmail" 500 homecu-match-plus="email" 501 data-homecuCustomMatchPlus-msg="One of the emails is invalid." 502 data-required-msg="Special Email is required" 506 <div class="col-sm-4 hcu-container-margin"></div> 507 <div class="col-sm-4 hcu-container-margin"> 508 <button id="btnSpecialEmailSave" class="k-button k-primary hcu-full-width"> 509 <span class="fa fa-check"></span> 513 <div class="col-sm-4 hcu-container-margin"></div> 516 <script type="text/x-kendo-template" id="templateSpecialEmail"> 519 <div class="col-sm-12"> 520 # if (email == "") { # 521 <span>Special email notifications will not be sent. </span> 523 <span>Special email notifications will be sent to: </span> 524 <span id="emailText"><strong>#= email #</strong></span> 530 <script type="text/x-kendo-template" id="templateWhatsNew"> 533 <div class="col-sm-12" id="msg#= mid #"> 535 <div class="hcu-blog-post hcu-blog-post-important col-sm-12"> 537 <div class="hcu-blog-post col-sm-12"> 539 <h4 class="hcu-blog-title">#= subject #</h4> 540 <p class="hcu-blog-date">#= kendo.toString(active_date, "MMMM dd, yyyy") #</p>