Odyssey
monitor_notes.data
1 <?php
2 
3  /*
4  * NOTE: This is a little different from my main goal. The goal of this is to create ONE
5  * script that may be included in any script that has notes on them.
6  ie. cuview will display these notes. It will include this script to handle any
7  database update and to fetch the current data to display based on the sort/view options
8 
9 
10  * one difference from main goal is this script needs some includes handled for it.
11  * since this is in /hcuadm, the following need to be required before this script should be included
12 
13  // require("cu_top");
14 
15 
16  * Parts of this script
17 
18  * UPDATE / INSERT
19  * IF I know a note is being posted, then I want to UPDATE/INSERT that information into the database
20 
21  * SELECT
22  * Select the current result set based on the the View / Sort Order requested by the user
23 
24  * ERRORS
25  * Any errors need to be handled the same way, from the Database Update/Select
26  * this is to ensure when the data is displayed using either {monitor_notes.desktop OR monitor_notes.mobile} OR monitor_notes.display
27  * they can display the correct information
28 
29 
30 
31  * ** IDEALLY -- I think data should be put into a multi-dimension array, possibly a large serialized object to be
32  pulled apart later by the presentation layer
33  * DISPLAY ARRAY
34 
35 
36 
37  * Changes to the Way this works..
38  * This should ALWAYS return a JSON value of our standard return status codes
39  Format of the array
40  * [status]
41  * [code]
42  * 000 -- SUCCESSFUL result set
43  * 999 -- An error occurred - print the errors to the user
44  * [severity]
45  * (really these just og along with the code and are one to one
46  * SUCCESS - SUCCESSFUL
47  * FAILURE - Error occurred
48  * [errors]
49  * An array of error message to print to the user
50  * [messages]
51  * An array of informative messages to print to the user, commonly used
52  * for SUCCESSFUL NOTES entry
53  *
54  * [data]
55  * [users] (ONLY Returned in DEFAULT State)
56  * This is a numeric array of users to be used on the form
57  * [idx] => array([user_name] => value)
58  * [topics] (ONLY Returned in DEFAULT State)
59  * This is a numeric array of Topics to be used on the form
60  * [idx] => [value]
61  * [searchfields] (ONLY Returned in DEFAULT State)
62  * This is a numeric array of Search fields to be used on the form
63  * [idx] => array(field_dbname => value, field_display => value)
64  * when sending information back to the server, use the idx as the posted value
65  * and field_display as the value shown to user
66  * [notes]
67  * This is a numeric array of information for the notes, fields are
68  *
69 
70 
71  ChangeLog:
72  * CL1 - mws 4/26/13 - Made changes on how data is retrieved and eliminate any
73  * extended ascii characters from the messagetext
74  * 06/15/13 mbl - Added several new pre-determined topics.
75  * 09/24/15 SPB - removed issue and task notes from query.
76  */
77  $monLibrary= dirname(__FILE__) . "/../library";
78  $sharedLibrary= dirname(__FILE__) . "/../../shared/library";
79  require_once("$monLibrary/cu_top.i");
80  require_once("$monLibrary/ck_hticket.i");
81  require_once("$sharedLibrary/errormail.i"); // Be sure errormail is included
82 
83  // To prevent console errors.
84  $wc = "";
85  $frmPostComment = "";
86  $frmPostOrder = "";
87  $frmSearchFor = "";
88  $frmViewBy = "";
89  $frmViewOrder = "";
90  $sql_ORDER = "";
91 
92 try {
93  $retStatus_ary = Array(
94  'status' => Array('code'=>'000', 'severity'=>'SUCCESS', 'errors' => Array(), 'messages' => Array()),
95  'data' => ''
96  );
97 
98 
99  if (!CheckPerm($link, $Hu, 'monitor_notes', $_SERVER['REMOTE_ADDR'])) {
100  // ** Permissions failed
101  // ** redirect to new page
102  throw new Exception('Invalid permissions to view, update or add notes');
103  }
104 
105  $dms_ok=array('frmViewBy'=>'string', 'frmViewOrder'=>'string', 'frmViewRange'=>'string',
106  'frmPostComment'=>'string', 'frmParentId'=>'digits', 'frmSubmitBy'=>'string',
107  'frmNotify'=>'string', 'frmTopic'=>'string', 'frmComment'=>'string',
108  'frmNotifyNote'=>'string', 'frmHideNote'=>'string', 'frmSearchFor'=>'string',
109  'frmSearchType'=>'string', 'frmSearchIn'=>'string', 'cuid'=>'string',
110  'frmParentTopic'=>'string', 'frmNoteId'=>'digits', 'user_name' => 'string',
111  'frmPostOrder'=>'string');
112 
113  $frmParentId = isset($frmParentId) ? $frmParentId : 0;
114  $frmNoteId = isset($frmNoteId) ? $frmNoteId : 0;
115 
116  // ** Declare used variables
117  $data_notes_list = Array();
118 
119  $returnDefaults = true; // * By default be prepared to return ALL array segments
120 
121  // * Now evaluate for the function exists again, if it does NOT, then
122  // * we are on a legacy server which does not require the importing of variables
123  if (function_exists('dms_import')) {
124  dms_import($dms_ok);
125  }
126 
127 
128  $FORM_ERRORS = ""; // ** This is the list of ERRORS to display for the notes
129  $form_return_msgs = Array(); // ** THIS is a list of MESSAGES (NOT ERRORS) to display for the notes
130 
131  // ** GLOBAL VALUES FOR THESE SCRIPTS
132 
133  // * HomeCU PreDetermined Topics
134  $dataNoteTopics_ary = Array("Contract Notes",
135  "Android App Implementation",
136  "Appliance Settings",
137  "Billing",
138  "Check Images",
139  "Comments",
140  "Implementation Notes",
141  "iPhone App Implementation",
142  "Mobile Web Implementation",
143  "On-site IVR Settings",
144  "Support",
145  "Web Site"
146  );
147 
148 
149  // * HomeCU Create PreDetermine List of Searchable Fields
150  $dataSearchFields_ary = Array(0 => Array("field_dbname" => "cuinfo_notes.author", "field_display" => "Author"),
151  1 => Array("field_dbname" => "cuinfo_notes.subject", "field_display" => "Topic"),
152  2 => Array("field_dbname" => "cuinfo_notes.messagetext", "field_display" => "Note"));
153 
154  // ** for the script imp_main I used cuid instead of user_name -- WHAT was I thinking
155 
156  // ** THE BELOW CODE MAY NEED TO BE MOVED TO monitor_notes.desktop
157  if (basename($_SERVER['SCRIPT_NAME']) == 'imp_main.prg') {
158  $dataScriptName = $_SERVER['PHP_SELF'] . "?cuid=$cuid&wc=$wc";
159  $user_name = $cuid;
160  } else {
161  $dataScriptName = $_SERVER['PHP_SELF'] . "?user_name=$user_name&wc=$wc";
162  }
163 
164 
165 
166  // ** SQL UPDATE / INSERT
167  if ($frmPostComment != '') {
168  // * POSTED FORM --
169  $returnDefaults = false;
170  if ($frmPostComment != '') {
171  // ** VALIDATE FORM
172  // ** Submitted BY:
173  // ** Subject
174  // ** Notify
175  // ** Note
176  } else {
177  // ** Hide A NOTE
178  }
179 
180  if ($FORM_ERRORS == "") {
181  if(intval($frmHideNote) == 0) {
182  // * PASS VALIDATION
183  // ** CREATE SQL
184 
185  // ** ORIGINATION OF THE RECORD is determined by the master script,
186  // ** 1 - monitor
187  // ** 2 - implementation
188 
189  $db_set_origination = (basename($_SERVER['SCRIPT_NAME']) == 'imp_main.prg' ? 2 : 1);
190 
191  // ** Determine the Note Topic
192  // * If the ParentId is set, then the topic will be provided in frmParentTopic
193 
194  $save_subject = prep_save((intval($frmParentId) > 0 ? $frmParentTopic : $frmTopic), 5000);
195  if (intval($frmNoteId) == 0) {
196  // ** INSERT
197  $sql = "INSERT INTO cuinfo_notes
198  (parentid, author, assignee, createddate, origination, subject, messagetext, activitydate, cu)
199  VALUES
200  (" . ($frmParentId == '' ? 'NULL' : intval($frmParentId)) . ", '" . prep_save($frmSubmitBy, 12) . "',
201  '" . prep_save($frmNotify, 12) . "', now(), '$db_set_origination', '$save_subject',
202  '" . prep_save($frmComment, 5000) . "', now(), '" . prep_save($user_name, 10) . "'); ";
203 
204  if (intval($frmParentId) > 0) {
205  // ** UPDATE parentid ActivityDate
206  $sql .= "UPDATE cuinfo_notes
207  SET activitydate = now()
208  WHERE parentid = " . intval($frmParentId) . " ";
209  }
210  } else {
211  // ** UPDATE -- REALLY ONLY ALLOW THE NOTE TO BE UPDATED
212  $sql = "UPDATE cuinfo_notes
213  SET messagetext = '" . prep_save($frmComment, 5000) . "'
214  WHERE messageid = '" . intval($frmNoteId) . "'; ";
215 
216 
217  if (intval($frmParentId) > 0) {
218  // ** UPDATE parentid ActivityDate
219  $sql .= "UPDATE cuinfo_notes
220  SET activitydate = now()
221  WHERE messageid = '" . intval($frmParentId) . "'; ";
222  }
223  }
224  } elseif ($frmHideNote == 1) {
225  // * HIDE A NOTE
226  $sql = "UPDATE cuinfo_notes
227  SET dontshowafter = current_date
228  WHERE messageid = '" . intval($frmNoteId) . "'; ";
229 
230  }
231 
232  $notes_upd_rs = db_query($sql, $link);
233  // echo $sql;
234  if ($notes_upd_rs !== FALSE) {
235  // ** DATA UPDATE SUCCESSFUL
236  // ** PERFORM POST DATA ACTIONS
237 
238  $form_return_msgs[] = "Your request was successful.";
239 
240  if ($frmNotify != '') {
241  // ** NOTIFY USER if a user was selected to be notified
242  $sql = "SELECT *
243  FROM dmsmonitorusers
244  WHERE user_name = '" . prep_save($frmNotify, 12) . "' ";
245  $notify_rs = db_query($sql, $link);
246  if ($notify_rs !== FALSE) {
247  $notify_row = db_fetch_array($notify_rs);
248  if (trim($notify_row['notifyemail']) !== '') {
249  // The user to notify has an email -- SO.. NOTIFY THEM
250  // * Create Mail Message
251  $notify_SendTo = trim($notify_row['notifyemail']);
252 
253  // ** Determine the FROM -- Author Email
254  $sql = "SELECT *
255  FROM dmsmonitorusers
256  WHERE user_name = '$Hu' ";
257  $author_rs = db_query($sql, $link);
258  $author_row = db_fetch_array($author_rs);
259  if (trim($author_row['notifyemail']) != '') {
260  $notify_SendFrm = trim($author_row['notifyemail']);
261  } else {
262  $notify_SendFrm = "nobody@homecu.net";
263  }
264 
265  $notify_Subject = "There is a HomeCU note you should see.";
266 
267  $notify_Message = "";
268  if ($frmNotifyNote != '') {
269  // * A Special NOTE was added
270  $notify_Message .= "NOTE**: $frmNotifyNote";
271 
272  }
273  $notify_Message .= "\n\nCU - " . $user_name . "\n";
274  $notify_Message .= "Entered by " . $Hu;
275  $notify_Message .= "\n\n" . $frmComment;
276 
277  $notify = new ErrorMail;
278  $notify->mailto = $notify_SendTo;
279  $notify->replyto = $notify_SendFrm;
280  $notify->mailfrom = $notify_SendFrm;
281 
282  $notify->subject = $notify_Subject;
283  $notify->msgbody = $notify_Message;
284  $notify->file = __FILE__;
285  $notify->cu = $user_name;
286 
287  $notify->SendMail();
288 
289 
290  } else {
291  // The user does NOT have email setup
292  $form_return_msgs[] = "The user " . dms_disphtml($frmNotify) . " does not have an email setup for notification.";
293  }
294  }
295  }
296  } else {
297 
298  // ** UPDATE Date Error
299  $FORM_ERRORS = "Unable to update data at this time.";
300  }
301  }
302  } elseif ($frmPostOrder != '') {
303  // ** do NOT return any defaults if we are doing a search
304  $returnDefaults = false;
305  }
306 
307 
308 
309 
310  // ** POSTED FORM VALUES
311 
312  // ** If the form is posted I want to set the information on the form back to these values
313  // * I have a choice. I can set a value prefixed with {data} instead of {frm} and use that or
314  // * I can use a the jquery populate add-in. I would just have to create a JSON object of the values I want to
315  // * to set in this script..
316 
317 
318 
319 
320 
321  // ** SELECT data from the cuinfo_notes table
322  $sql = "";
323  $sql_WHERE = "WHERE cuinfo_notes.trackitem_id = 0 and cuinfo_notes.track_id = 0 ";
324 
325 
326  // ** FOR NOW -- I will put the WHERE CLAUSE CREATION HERE
327  /*
328  * Search For Rules
329  * Fields
330  * frmSearchIn - The search may look in one field at a time. Possibly later I can add a dynamic or list each field to have a separate where
331  * However, for now.. One field at a time. This is the field identifier. I will of course make sure the field exists.
332  * frmSearchType - This option will determine how we will be creating the query
333  * - (0) Search for the string frmSearchFor as typed in the field frmSearchIn
334  * - (1) Match any word, but it must be the WHOLE WORD.
335  * - (2) Match any word, anywhere in the frmSearchIn field
336  * - (3) Regular Expression. Evaluate Reg Ex on the field frmSearchIn
337 
338  * frmSearchWhole - Options here. This is to check if I want to match the WHOLE WORD. BY default my search should allow a search anywhere in string.
339  * - however when I check for a WHOLE WORD I will surround each word with spaces to ensure it finds words
340  * frmSearchRegEx - This is mutually exclusive from whole word. So I am thinking I may use radio.. BUT this will allow the user to enter some sort
341  * - of postgres regular expression. I am going to be useing pg_escape_string, need to make sure these still work.
342  * frmSearchFor - And that brings us to the search query.
343  * Regular Expressions, i am thinking just use what they enter.
344  * Everything else. I am going to replace white space with a | (pipe).. This will allow for each word to be searched for
345 
346  */
347 
348  $sql_WHERE_SEARCH = "";
349  if ($frmSearchFor != '') {
350  // * Be sure the fieldname is correct, if NOT found, then we skip
351  if ($dataSearchFields_ary[$frmSearchIn]['field_dbname'] != '') {
352  // ** SOMETHING IS ENTERED
353  switch (intval($frmSearchType)) {
354  case 0:
355  // Search for the string frmSearchFor in the field frmSearchin
356  $sql_WHERE_SEARCH = " LOWER(" . $dataSearchFields_ary[$frmSearchIn]['field_dbname'] . ") LIKE ('%" . strtolower(prep_save($frmSearchFor, 200)) . "%') ";
357  break;
358  case 1:
359  case 2:
360  // ** FIND A INSTANCE OF A WORD
361  // ** First we replace all white space with a |
362  $data_frmSearchFor = trim($frmSearchFor); // FIRST STRIP ALL BEGINNING AND END SPACES
363  $data_frmSearchFor = prep_save(preg_replace('/\s+/', '|', $data_frmSearchFor), 200);
364 
365  if (intval($frmSearchType) == 2) {
366  // * For matching whole word, I want to add some spaces
367  $data_frmSearchFor = " " . str_replace('|', ' | ', $data_frmSearchFor) . " ";
368  }
369  $sql_WHERE_SEARCH = " LOWER(" . $dataSearchFields_ary[$frmSearchIn]['field_dbname'] . ") SIMILAR TO '%(" . strtolower($data_frmSearchFor) . ")%' ";
370  break;
371  case 3:
372  // ** Match a Regular Expression
373  $sql_WHERE_SEARCH = " " . $dataSearchFields_ary[$frmSearchIn]['field_dbname'] . " ~* '" . prep_save($frmSearchFor, 200) . "' ";
374  break;
375  default:
376  // NOTHING
377  break;
378  }
379  }
380  }
381  // ** Also I will need to be adding the query to only search for the current credit union which is the current user_name field.
382  // * This will need to be altered when I make a script for ALL CU's
383  $sql_WHERE_SEARCH .= ($sql_WHERE_SEARCH != '' ? " AND " : " " ) . " cuinfo_notes.cu = '" . prep_save($user_name, 12) . "' ";
384 
385  // ** Apply the dont showafter date to the query
386  $sql_WHERE_SEARCH .= ($sql_WHERE_SEARCH != '' ? " AND " : " " ) . " (cuinfo_notes.dontshowafter is NULL OR cuinfo_notes.dontshowafter > current_date) ";
387 
388 /*
389 print "TEST : ";
390 print $data_frmSearchFor;
391 print "<br><Br><br>" . $sql_WHERE_SEARCH;
392 */
393 
394  switch (intval($frmViewBy)) {
395  case "1":
396  // ** Date Grouping
397  // * Decide the where clause
398  /*
399  * REMOVED frmViewRange as an option
400  */
401  /*
402  switch (intval($frmViewRange)) {
403  case "1":
404  // ** Less than 12 Months OLD
405  $sql_WHERE = "WHERE (current_date::date - createddate::date ) < 360 ";
406  break;
407  case "2":
408  // ** SHOW ALL MESSAGES
409  // ** NO real where clause...
410  break;
411  default:
412  // ** Less than 6 Months OLD
413  $sql_WHERE = "WHERE (current_date::date - createddate::date ) < 180 ";
414 
415  break;
416  }
417  * */
418  // ** ADD ANY OTHER WHERE STATEMENT
419  $sql_WHERE .= ($sql_WHERE_SEARCH == "" ? "" : ($sql_WHERE == '' ? " WHERE " : " AND ") . $sql_WHERE_SEARCH);
420  // ** Decide the Data Order
421  switch (intval($frmViewOrder)) {
422  case "1":
423  $sql_ORDER = " ORDER BY cuinfo_notes.activitydate ";
424  break;
425  default:
426  $sql_ORDER = " ORDER BY cuinfo_notes.activitydate DESC ";
427  break;
428  }
429  $sql = "SELECT messageid, parentid, author, assignee, to_char(createddate, 'MM/DD/YYYY HH24:MI:SS') as createddate,
430  unread, origination, subject, messagetext, to_char(dontshowafter, 'MM/DD/YYYY HH24:MI:SS') as dontshowafter,
431  to_char(activitydate, 'MM/DD/YYYY HH24:MI:SS') as activitydate
432  FROM cuinfo_notes
433  $sql_WHERE
434  $sql_ORDER ";
435  break;
436  case "2":
437  // ** Topic Grouping
438 
439  // * Decide the where clause
440  /*
441  * REMOVED frmViewRange as an option
442  */
443  /*
444  switch (intval($frmViewRange)) {
445  case "1":
446  // ** Less than 12 Months OLD
447  $sql_WHERE = "WHERE (current_date::date - createddate::date ) < 360 ";
448  break;
449  case "2":
450  // ** SHOW ALL MESSAGES
451  // ** NO real where clause...
452  break;
453  default:
454  // ** Less than 6 Months OLD
455  $sql_WHERE = "WHERE (current_date::date - createddate::date ) < 180 ";
456 
457  break;
458  }
459  *
460  */
461  $sql_WHERE .= ($sql_WHERE_SEARCH == "" ? "" : ($sql_WHERE == '' ? " WHERE " : " AND ") . $sql_WHERE_SEARCH);
462  // ** Decide the Data Order -- It is at least order by {subject}
463  $sql_ORDER = " ORDER BY subject ";
464  switch (intval($frmViewOrder)) {
465  case "1":
466  $sql_ORDER .= ", cuinfo_notes.createddate ";
467  break;
468  default:
469  $sql_ORDER .= ", cuinfo_notes.createddate DESC ";
470  break;
471  }
472  $sql = "SELECT messageid, parentid, author, assignee, to_char(createddate, 'MM/DD/YYYY HH24:MI:SS') as createddate,
473  unread, origination, subject, messagetext, to_char(dontshowafter, 'MM/DD/YYYY HH24:MI:SS') as dontshowafter,
474  to_char(activitydate, 'MM/DD/YYYY HH24:MI:SS') as activitydate
475  FROM cuinfo_notes
476  $sql_WHERE
477  $sql_ORDER ";
478  break;
479  default:
480  // ** Threaded Grouping
481  // ** A little more difficult -- I need the parent to be followed by its children. So I will create a nodeid column
482  // that will be the parentid if there is one or the messageid if this is not a parentid
483  // ** I may have to do a lookup back onto the table to decide if the field should still be included in the results
484  // ** the child
485 
486 
487  $frmViewBy = 0; // * Force all other values to be consistent
488  // * Decide the where clause
489  /*
490  * REMOVED frmViewRange as an option
491  */
492  /*
493  switch (intval($frmViewRange)) {
494  case "1":
495  // ** Less than 12 Months OLD
496  $sql_WHERE = "WHERE (current_date - COALESCE(parent_note.activitydate::date, cuinfo_notes.activitydate::date)) < 360 ";
497  break;
498  case "2":
499  // ** SHOW ALL MESSAGES
500  // ** NO real where clause...
501  break;
502  default:
503  // ** Less than 6 Months OLD
504  $sql_WHERE = "WHERE (current_date - COALESCE(parent_note.activitydate::date, cuinfo_notes.activitydate::date)) < 180 ";
505 
506  break;
507  }
508  *
509  */
510 
511  $sql_WHERE .= ($sql_WHERE_SEARCH == "" ? "" : ($sql_WHERE == '' ? " WHERE " : " AND ") . $sql_WHERE_SEARCH);
512  // ** Decide the Data Order -- It is at least order by {subject}
513  switch (intval($frmViewOrder)) {
514  case "1":
515  $sql_ORDER .= " ORDER BY 1, cuinfo_notes.messageid, 2 ";
516  break;
517  default:
518  $sql_ORDER .= " ORDER BY 1 DESC, cuinfo_notes.messageid, 2 DESC ";
519  break;
520  }
521  $sql = "SELECT COALESCE(cuinfo_notes.parentid, cuinfo_notes.messageid) as nodeid, COALESCE(parent_note.activitydate, cuinfo_notes.activitydate) as lastnodeactivity,
522  cuinfo_notes.messageid, cuinfo_notes.parentid, cuinfo_notes.author, cuinfo_notes.assignee,
523  TO_CHAR(cuinfo_notes.createddate, 'MM/DD/YYYY HH24:MI:SS') as createddate,
524  cuinfo_notes.unread, cuinfo_notes.origination, cuinfo_notes.subject, cuinfo_notes.messagetext, TO_CHAR(cuinfo_notes.dontshowafter, 'MM/DD/YYYY HH24:MI:SS') as dontshowafter,
525  TO_CHAR(cuinfo_notes.activitydate, 'MM/DD/YYYY HH24:MI:SS') as activitydate
526 
527  FROM cuinfo_notes
528  LEFT JOIN cuinfo_notes as parent_note on parent_note.messageid = cuinfo_notes.messageid
529  $sql_WHERE
530  $sql_ORDER ";
531  }
532 
533  if ($sql != '') {
534  // ** Query for the data
535  $notes_rs = db_query($sql, $link);
536  // ** CL1
537  // ** SEt the array to empty array, if it returns nothing
538 // if (!$data_notes_list = db_fetch_all($notes_rs)) {
539 // $data_notes_list = Array();
540 // }
541 //
542  $data_notes_idx = 0;
543  while ($notesRow = db_fetch_assoc($notes_rs, $data_notes_idx)) {
544  // * mws 4/26/13
545  // ** JSON Has some limitations escaping certain characters ie (extended ASCII Character >= 128)
546  // ** Need to remove these by using a preg_replace, that should put a space in place of any of these chracters
547  $notesRow['author'] = dms_disphtml($notesRow['author']);
548  $notesRow['subject'] = dms_disphtml($notesRow['subject']);
549  $notesRow['messagetext'] = nl2br(dms_disphtml(preg_replace('/[^(\x00-\x7F)]*/','', $notesRow['messagetext'])));
550  $data_notes_list[] = $notesRow;
551  $data_notes_idx++;
552  }
553  }
554  // ** Set the data for employees
555  $sql = "SELECT user_name
556  FROM dmsmonitorusers
557  ORDER BY upper(user_name) ";
558  $users_rs = db_query($sql, $link);
559  $data_users_list = db_fetch_all($users_rs);
560 
561  // print the information as JSON
562  header('Content-type: application/json');
563 
564  // ** Different time require different data results returned
565  if ($returnDefaults) {
566  $retStatus_ary['data'] = Array(
567  "users" => $data_users_list,
568  "notes" => $data_notes_list,
569  "topics" => $dataNoteTopics_ary,
570  "searchfields" => $dataSearchFields_ary
571  );
572  } else {
573  $retStatus_ary['data'] = Array(
574  "notes" => $data_notes_list
575  );
576  }
577  if (count($form_return_msgs) > 0) {
578  $retStatus_ary['status']['messages'] = $form_return_msgs;
579  }
580  print json_encode($retStatus_ary);
581 
582  }
583  catch(Exception $ex)
584  {
585  // ** Make sure the results being returned are empty
586  $retStatus_ary = array();
587  header('Content-type: application/json');
588  $retStatus_ary = Array(
589  'status' => Array('code'=>'999', 'severity'=>'FAILURE', 'errors' => Array(), 'action' => ''),
590  'data' => ''
591  );
592  $retStatus_ary['status']['errors'][] = $ex->getMessage();
593  print json_encode($retStatus_ary);
594 
595  }
596 
597 ?>