Odyssey
hcuDisclosures.prg
1 <?php
2  /*
3  * File: hcuDisclosures.prg
4  *
5  * Purpose: To allow the member to see any disclosures / terms in their home banking.
6  * The user will not be able to agree / unagree to any but can see the date they
7  * agreed to the document.
8  *
9  */
10 
11 
12  // ** SET SCRIPT LEVEL VARIABLES
13  $serviceShowInfo = true;
14  $serviceLoadMenu = true;
15  $serviceShowMenu = true;
16  $serviceAllowReadonly = true;
17 
18  // ** INCLUDE MAIN GLOBAL SCRIPT -- Handles security / global variable values
19  require_once(dirname(__FILE__) . '/../library/hcuService.i');
20 
21  /*
22  * ** CHECK USER FEATURE PERMISSIONS **
23  * NOTE: DOES NOT RETURN ON FAILURE
24  */
25  PermCheckFeatureScreen($dbh, $HB_ENV, $MC, FEATURE_BASIC);
26 
27 
28  // ** INSERT BUSINESS LOGIC FOR THIS FORM
29  $Cu = $HB_ENV["Cu"];
30  $Cn = $HB_ENV["Cn"];
31  $chome = $HB_ENV["chome"];
32  $Flang = $HB_ENV["Flang"];
33 
34  /*
35  * The document title and link name are retrieved from the cucmsdocs table.
36  */
37 
38  // ** SET VARIABLES FOR WEBSITE FLAGS
39 
40 
41  // ** INCLUDE PRE CONTENT SCRIPT
42  require_once(dirname(__FILE__) . '/../includes/hcuPreContent.i');
43 
44  /********* functions ************/
45  // get the list of disclosures/terms the user can see.
46  function GetDisclosures( $pDBH, $pHBEnv, $pMC ) {
47 
48  $sql = "SELECT docs.docsid, docs.docsname, docs.docstitle, docs.docsdisplaytext, resp.responseon, resp.accountnumber
49  FROM cucmsdocs docs
50  INNER JOIN cucmsfrags frags ON (frags.docsid = docs.docsid)
51  AND frags.cu = '{$pHBEnv["Cu"]}'
52  LEFT JOIN cucmsresponse resp ON (resp.docsid = docs.docsid)
53  AND resp.cu = '{$pHBEnv["Cu"]}'
54  AND resp.user_id = '{$pHBEnv["Uid"]}'
55  WHERE docs.docsresponsetype IN ('D', 'T'); ";
56 
57  $sth = db_query( $sql, $pDBH );
58  $disclosureList = array();
59  $trow = 0;
60  while ( $row = db_fetch_array( $sth, $trow++ ) ) {
61  // ** Get the translated value of the docstitle now, so we can sort later
62  $display_name = trim($pMC->msg($row['docstitle'], HCU_DISPLAY_AS_HTML));
63  $display_name = ($display_name == '' ? trim($row['docstitle']) : $display_name);
64  $row['display_name'] = $display_name;
65 
66  $disclosureNotice = Get_NoticeInfo($pDBH, $pHBEnv, $pMC, "D", $row["docsname"], false);
67 
68  $row["disclosure_link"] = $disclosureNotice["notice"][0]["notice_linktarget"];
69 
70  $disclosureList[] = $row;
71  }
72  db_free_result($sth);
73 
74  return $disclosureList;
75  } // end GetDisclosures
76 
77  // Sort based on the display name
78  function DiscSort( $a, $b ) {
79 
80  $sort = strcasecmp( $a["display_name"], $b["display_name"] );
81  $sort = $sort !== 0 ? $sort : strcasecmp ( $a["docsdisplaytext"], $b["docsdisplaytext"]); // For estatements, the title is "estatement" for both start and stop terms.
82  $sort = $sort !== 0 ? $sort : strcasecmp ( $a["accountnumber"], $b["accountnumber"]); // For estatements, also sort the accountnumber. Accounts of all other terms should be saved as blank.
83  return $sort;
84  }
85 
86  /********* end functions ********/
87 
88  try {
89  $Flang = (trim($Flang) == "" ? "en_US" : trim($Flang));
90 
91  if ( $HB_ENV['offline'] != "N" ) {
92  $thisPageErrors = $HB_ENV["offlinemsg"];
93  throw new Exception( HCU_JsonEncode( $thisPageErrors ) );
94  }
95 
96  /*
97  * Get the Addendum Notice for the Disclosure Page
98  */
99  $addendumName = "DisclosureAddendum";
100  $addendumAry = Get_NoticeInfo($dbh, $HB_ENV, $MC, "D", $addendumName, true);
101 
102 
103  // get the list of disclosures
104  $disclosureInfo = GetDisclosures($dbh, $HB_ENV, $MC);
105 
106  // sort the list based on the display name
107  usort( $disclosureInfo, "DiscSort" )
108 ?>
109  <div class="container-fluid" style='font-size:12px;'>
110  <div class="row">
111  <div class="col-xs-12 h3"><?php echo $MC->msg('Terms of Use', HCU_DISPLAY_AS_HTML); ?></div>
112  </div>
113  <div class="row">
114  <div class="col-xs-12" id="listViewDisclosures" style="border:0;"></div>
115  </div>
116 
117  <?php
118  /*
119  * Check to see if there is an addendum notice
120  */
121  if ( $addendumAry["status"]["code"] == "000" && $addendumAry["notice"][0]["notice_id"] ) {
122  print $addendumAry["notice"][0]["notice_text"];
123  }
124  ?>
125  </div>
126 
127 <?php
128 
129  $disclosureData = array();
130  if ( count( $disclosureInfo ) ) {
131 
132  // go through and make an object for the datasource
133  for ( $i = 0; $i < count( $disclosureInfo ); $i++ ) {
134  $disclosureLink = $disclosureInfo[$i]["disclosure_link"];
135 
136  $response = $disclosureInfo[$i]["responseon"];
137  if ( $response == "" ) {
138  $responseOn = "";
139  } else {
140 
141  // convert the date
142  $dateParts = explode( "-", $response );
143  $responseOn = "{$MC->msg('Accepted', HCU_DISPLAY_AS_RAW)}: " . sprintf( "%s/%s/%s", $dateParts[1], $dateParts[2], $dateParts[0] );
144 
145  // Estatement terms are dependent on the account as well so add the label.
146  if (in_array($disclosureInfo[$i]["docsname"], array("esTermsStop", "esTermsStart"))) {
147  $responseOn .= "<br>" . $MC->msg("For Account", HCU_DISPLAY_AS_RAW) . ": #" . $disclosureInfo[$i]["accountnumber"];
148  }
149  }
150  $linkText = $MC->msg( $disclosureInfo[$i]["docsdisplaytext"], HCU_DISPLAY_AS_HTML );
151  if ( !strlen( $linkText ) ) {
152  $linkText = "";
153  }
154  // NOTE: The document title must be in the dictionary
155  // * use the display_name that I created before, it will either be the docstitle or the dictionary docstitle
156  $title = $disclosureInfo[$i]["display_name"];
157  if ( !strlen( $title ) ) {
158  $title = "";
159  }
160  $disclosureData[] = array( "discloseName" => $title,
161  // NOTE: The link phrase must be in the dictionary
162  "linkText" => $linkText,
163  "responseOn" => $responseOn,
164  "disclosureLink" => $disclosureLink
165  );
166  }
167 
168  }
169 ?>
170  <style>
171  .k-listview:after {
172  content: ".";
173  display: block;
174  height: 0;
175  clear: both;
176  visibility: hidden;
177  }
178 
179  .disclosure {
180  float: left;
181  position: relative;
182  width: 270px;
183  height: 75px;
184  margin: 5px;
185  padding: 15px 0px 5px 15px;
186  cursor: pointer;
187  }
188  .disclosure span {
189  display: block;
190  float: left;
191  position: relative;
192  padding-left: 5px;
193  }
194  .disclosure h2 {
195  margin: 0;
196  padding: 3px 5px 0 0;
197  text-align: left;
198  max-width: 200px;
199  overflow: hidden;
200  line-height: 1.1em;
201  font-size: .9em;
202  font-weight: bold;
203  text-transform: uppercase;
204  }
205  .disclosure h3 {
206  margin: 0;
207  padding: 3px 5px 0 0;
208  text-align: left;
209  max-width: 200px;
210  overflow: hidden;
211  line-height: 1.1em;
212  font-size: 1em;
213  font-weight: bold;
214  font-style: italic;
215  }
216  .disclosure h4 {
217  margin: 0;
218  padding: 3px 5px 0 0;
219  text-align: left;
220  max-width: 200px;
221  overflow: hidden;
222  line-height: 1.1em;
223  font-size: .8em;
224  font-weight: normal;
225  }
226  .disclosure a {
227  text-decoration:none;
228  }
229  .disclosure p {
230  visibility: hidden;
231  }
232  .disclosure:hover p {
233  visibility: visible;
234  position: absolute;
235  width: 269px;
236  height: 74px;
237  top: -1px;
238  left: -1px;
239  margin: 0;
240  padding: 0;
241  line-height: 50px;
242  vertical-align: middle;
243  text-align: center;
244  color: #fff;
245  background-color: rgba(0,255,0,0.15);
246  border-radius: 4px;
247  -webkit-border-radius: 4px;
248  transition: background .2s linear, color .2s linear;
249  -moz-transition: background .2s linear, color .2s linear;
250  -webkit-transition: background .2s linear, color .2s linear;
251  -o-transition: background .2s linear, color .2s linear;
252  }
253  .k-state-hover {
254  background-color: #f0713a;
255  color: #fff;
256  }
257 
258  </style>
259  <script>
260 
261  $(document).ready(function() {
262  var disclosures = <?php echo HCU_JsonEncode($disclosureData); ?>;
263 
264  $("#listViewDisclosures").kendoListView({
265  dataSource: disclosures,
266  template: kendo.template($("#disclosureTemplate").html())
267  });
268 
269  $(document).on("click", ".k-overlay", function () {
270  // close the currently open window
271  var dialog = $("#disclosureWindow").data('kendoWindow');
272  if ( dialog ) {
273  dialog.close();
274  }
275  });
276  });
277  var printButton;
278 
279  function createWindow(title, stringToOpen) {
280  var contentString;
281  contentString = "<?php echo $HB_ENV['homebankingpath'] ?>/hcuDisclosures.prg?action=show&cu=<?php echo $Cu ?>&Flang=<?php echo $Flang ?>&" + stringToOpen;
282 
283  var windowWidth = parseInt($(window).width() * .75, 10);
284  var windowHeight = parseInt($(window).height() * .85, 10);
285 
286  // safety check
287  if ( windowWidth === 0 ) {
288  windowWidth = 320;
289  }
290  if ( windowHeight === 0 ) {
291  windowHeight = 450;
292  }
293 
294  $(document.body).append('<div id="disclosureWindow"></div>');
295  $('#disclosureWindow').kendoWindow({
296  title: title,
297  width: windowWidth,
298  height: windowHeight,
299  modal: true,
300  visible: false,
301  resizable: true,
302  actions: [ "Print", "Close" ],
303  content: stringToOpen,
304  close: function(e) {
305  var dialog = $("#disclosureWindow").data("kendoWindow");
306  dialog.destroy();
307  }
308  });
309  // doing it this way for IE8
310  var dialog = $("#disclosureWindow").data('kendoWindow');
311  dialog.center().open();
312 
313  printButton = dialog.wrapper.find(".k-i-print");
314  printButton.click(function (e) {
315  window.open( stringToOpen, "print_view" );
316  });
317 
318  homecuTooltip.reset(); // set to defaults, probably unnecessary but just in case
319  homecuTooltip.custom.content = "<?php echo $MC->msg("View/Print in new window", HCU_DISPLAY_AS_JS); ?>";
320  printButton.kendoTooltip(homecuTooltip.custom).data("kendoTooltip");
321  }
322  </script>
323  <script type="text/x-kendo-template" id="disclosureTemplate">
324  <div class="disclosure k-block k-shadow k-link" onClick='createWindow("#= linkText#", "#= disclosureLink#")'>
325  <span class="fa fa-file-text-o fa-3x" title="#= discloseName #" ></span>
326  <span>
327  <h2>#= discloseName#</h2>
328  <h3>#= linkText#</h3>
329  <h4>#= responseOn#</h4>
330  </span>
331  <p></p>
332  </div>
333  </script>
334  <style>
335  .k-i-expand {
336  background: url("/IMAGES/index.png");
337  background-position: 0px 0px;
338  background-size: contain;
339  background-repeat: no-repeat;
340  }
341  .k-link:not(.k-state-disabled):hover > .k-i-expand,
342  .k-state-hover .k-i-expand {
343  background-position: 0px 0px;
344  }
345  </style>
346 
347 <?php
348  /*
349  * ** END CONTENT
350  */
351  } catch (Exception $ex) {
352  //Return error message
353  $thisPageErrors = HCU_JsonDecode($ex->getMessage());
354 
355  // ** Handle Errors on this screen
356  // NOTE: the error(s) will be in a specific variable
357  $serviceErrorCode = '917';
358  $serviceErrorMsgs = $thisPageErrors;
359 
360  require_once(dirname(__FILE__) . '/../includes/hcuErrorPage.i');
361  // drop through to close the page
362  }
363 
364  // ** INCLUDE POST CONTENT SCRIPT
365  require_once(dirname(__FILE__) . '/../includes/hcuPostContent.i');
366 
367 
368  // Functions