17 $serviceShowInfo =
true;
18 $serviceLoadMenu =
true;
19 $serviceShowMenu =
true;
23 require_once(dirname(__FILE__) .
'/../library/hcuService.i');
25 $logger= $HB_ENV[
"SYSENV"][
"logger"];
28 $string= array(
"filter" => FILTER_SANITIZE_STRING);
29 $string_special = array(
"filter" => FILTER_SANITIZE_SPECIAL_CHARS);
30 $digits= array(
"filter" => FILTER_SANITIZE_NUMBER_INT);
31 $dms_ok=array(
'action'=>$string,
"mbr_account" => $string,
32 'type'=>$string,
'id'=>$string,
'chome'=>$string,
33 'selacct'=>$string,
'emailtype'=>$string,
35 'notifymsg'=>$string_special,
'incbal'=>$string,
'notifyamt'=>$string,
36 'useavailbal'=>$string,
'desc_amtmin'=>$string,
'desc_amtmax'=>$string,
37 'userange'=>$string,
'transtype'=>$string,
38 'notifydesc'=>$string_special,
'days_prior'=>$string,
39 'chknum'=>$string,
'incamt'=>$string,
'inctransdesc'=>$digits);
41 HCU_ImportVars($HB_ENV,
'HCUPOST', $dms_ok);
43 header(
'Content-Type: application/json');
59 $parseRefer = parse_url($_SERVER[
'HTTP_REFERER']);
60 $referScript = basename($parseRefer[
'path']);
61 if (!in_array($referScript, array(
'hcuAlerts.prg'))) {
63 $aryErrors[] = $MC->msg(
'Feature Unavailable', HCU_DISPLAY_AS_RAW);
64 throw new Exception (HCU_JsonEncode($aryErrors));
71 if (!PermCheckFeatureScreen($dbh, $HB_ENV, $MC, FEATURE_ALERTS,
'',
false)) {
72 throw new Exception (HCU_JsonEncode(Array($MC->msg(
'Rights not set', HCU_DISPLAY_AS_HTML))));
75 $alertsEnabled = Check_AlertsEnabled( $dbh, $HB_ENV );
76 if ( $alertsEnabled ===
false ) {
77 $aryErrors[] = $MC->msg(
'Feature Not Set', HCU_DISPLAY_AS_RAW);
78 throw new Exception (HCU_JsonEncode($aryErrors));
82 switch ( $HB_ENV[
"HCUPOST"][
"action"] ) {
88 $HB_ENV[
"HCUPOST"][
"notifymsg"] = ConvertFromUTF8( $HB_ENV[
"HCUPOST"][
"notifymsg"] );
90 $HB_ENV[
"HCUPOST"][
"notifydesc"] = HCU_array_key_exists(
"notifydesc", $HB_ENV[
"HCUPOST"]) ?
91 ConvertFromUTF8( $HB_ENV[
"HCUPOST"][
"notifydesc"] ) :
"";
95 $HB_ENV[
"HCUPOST"][
"notifymsg"] = html_entity_decode( $HB_ENV[
"HCUPOST"][
"notifymsg"], ENT_QUOTES,
"UTF-8" );
97 $HB_ENV[
"HCUPOST"][
"notifydesc"] = HCU_array_key_exists(
"notifydesc", $HB_ENV[
"HCUPOST"]) ?
98 html_entity_decode( $HB_ENV[
"HCUPOST"][
"notifydesc"], ENT_QUOTES,
"UTF-8" ) :
"";
101 $aryUpdate = Validate_Alert( $dbh, $HB_ENV, $MC );
103 if ($aryUpdate[
'code'] ==
'000') {
104 $aryUpdate = Update_Alert( $dbh, $HB_ENV, $MC );
107 if ($aryUpdate[
'code'] !=
'000') {
109 $aryErrors = array();
110 for ( $e = 0; $e < count( $aryUpdate[
"errors"] ); $e++ ) {
111 $aryErrors[] = $aryUpdate[
"errors"][$e];
114 throw new Exception (HCU_JsonEncode($aryErrors));
117 if ( $HB_ENV[
"HCUPOST"][
"id"] > 0 ) {
118 $aryInfo[] = $MC->msg(
'Alert Updated', HCU_DISPLAY_AS_RAW);
120 $aryInfo[] = $MC->msg(
'Alert Saved', HCU_DISPLAY_AS_RAW);
126 $return = Get_AlertsDetailed( $dbh, $HB_ENV[
"Cu"], $HB_ENV[
"Uid"], $HB_ENV[
"Fset3"]);
128 $aryResult = $return[
"data"];
129 for ( $i = 0; $i < count( $aryResult ); $i++ ) {
131 $aryResult[$i][
"notifymsg"] = html_entity_decode( $aryResult[$i][
"notifymsg"], ENT_QUOTES,
"UTF-8" );
132 $aryResult[$i][
"notifydisplaymsg"] = html_entity_decode( $aryResult[$i][
"notifymsg"], ENT_QUOTES,
"UTF-8" );
133 if ( isset( $aryResult[$i][
"lastalert"] ) && strlen( $aryResult[$i][
"lastalert"] ) > 0 ) {
134 $aryResult[$i][
"lastalert"] = date(
"M j, Y g:ia", strtotime( $aryResult[$i][
"lastalert"] ) );
138 case "read_alert_accounts":
139 $return = Get_AlertAccountList( $dbh, $HB_ENV );
141 $aryResult = $return[
"data"];
144 $aryDelete = Delete_Alert( $dbh, $HB_ENV, $MC );
146 if ($aryDelete[
'code'] !=
'000') {
148 $aryErrors = array();
149 for ( $e = 0; $e < count( $aryDelete[
"errors"] ); $e++ ) {
150 $aryErrors[] = $aryDelete[
"errors"][$e];
153 throw new Exception (HCU_JsonEncode($aryErrors));
155 $aryInfo[] = $MC->msg(
'Alert Deleted', HCU_DISPLAY_AS_RAW);
161 $oneAlert = Read_OneAlert( $dbh, $HB_ENV );
162 $aryResult[] = $oneAlert[
"data"];
164 $aryResult[0][
"notifymsg"] = html_entity_decode( $aryResult[0][
"notifymsg"], ENT_COMPAT | ENT_HTML401,
"UTF-8" );
168 $aryErrors[] =
"Unexpected action: {$HB_ENV["HCUPOST
"]["action
"]}";
169 throw new Exception (HCU_JsonEncode($aryErrors));
175 $aryReply[
"homecuErrors"] = HCU_JsonDecode( $ex->getMessage() );
178 $aryResult = array();
184 if ( count( $aryInfo ) ) {
185 $aryReply[
"homecuInfo"] = $aryInfo;
188 if ( count( $aryResult ) ) {
189 $aryReply[
"homecuData"] = $aryResult;
192 print HCU_JsonEncode($aryReply);