13 $monLibrary= dirname(__FILE__) .
"/../library";
14 require_once(
"$monLibrary/cu_top.i");
15 require_once(
"$monLibrary/ck_hticket.i");
18 if (!CheckPerm($link, $Hu,
'ivr_mntc_msg', $_SERVER[
'REMOTE_ADDR'])) {
21 header(
"Location: /hcuadm/hcu_noperm.prg");
46 $dms_ok = Array(
'action' =>
'string',
'msg_code' =>
'string',
'msg_desc' =>
'string',
47 'msg_filename' =>
'string',
'msg_level' =>
'string');
49 dms_import_v2($HB_ENV,
"HCUPOST", $dms_ok);
51 $retStatus_ary = Array(
53 'homecuErrors' => Array(),
59 $returnMsgData = Array();
60 switch ($HB_ENV[
'HCUPOST'][
'action']) {
62 $sql =
"SELECT trim(msg_code) as msg_code, 63 trim(msg_desc) as msg_desc, 64 trim(msg_filename) as msg_filename, 66 FROM ars_audio_message 68 $sqlRs = db_query($sql, $link);
70 while ($msgRecord = db_fetch_assoc($sqlRs, $sIdx)) {
71 $returnMsgData[] = $msgRecord;
75 $retStatus_ary[
'homecuData'] = $returnMsgData;
83 $sql =
"SELECT count(*) as count_msg 84 FROM ars_audio_message 85 WHERE msg_code = '" . prep_save($HB_ENV[
'HCUPOST'][
'msg_code'], 3) .
"' ";
86 $cntRs = db_query($sql, $link);
87 list($recordCount) = db_fetch_array($cntRs);
88 if ($HB_ENV[
'HCUPOST'][
'action'] ==
'new') {
90 if ($recordCount > 0) {
91 throw new Exception(
'Message code must be unique.');
95 if ($recordCount == 0) {
96 throw new Exception(
'Message code was not found.');
102 if ($HB_ENV[
'HCUPOST'][
'msg_code'] ==
'' ||
103 $HB_ENV[
'HCUPOST'][
'msg_desc'] ==
'' ||
104 $HB_ENV[
'HCUPOST'][
'msg_filename'] ==
'') {
105 throw new Exception(
'All fields must be entered to continue.');
109 if (!in_array($HB_ENV[
'HCUPOST'][
'msg_level'], array(
'1',
'2',
'3'))) {
110 $retStatus_ary[
'homecuInfo'][] = $HB_ENV[
'HCUPOST'];
111 $retStatus_ary[
'homecuInfo'][] = $HB_ENV[
'HCUPOST'][
'msg_level'];
112 $retStatus_ary[
'homecuInfo'][] = array(
'1',
'2',
'3');
113 throw new Exception(
'Message level was not valid.');
117 if ($HB_ENV[
'HCUPOST'][
'action'] ==
'new') {
118 $sql =
"INSERT INTO ars_audio_message 119 (msg_code, msg_desc, msg_filename, msg_level) 121 ('" . prep_save($HB_ENV[
'HCUPOST'][
'msg_code'], 3) .
"', 122 '" . prep_save($HB_ENV[
'HCUPOST'][
'msg_desc'], 50) .
"', 123 '" . prep_save($HB_ENV[
'HCUPOST'][
'msg_filename'], 20) .
"', 124 '" . intval($HB_ENV[
'HCUPOST'][
'msg_level']) .
"') ";
127 $sql =
"UPDATE ars_audio_message 128 SET msg_desc = '" . prep_save($HB_ENV[
'HCUPOST'][
'msg_desc'], 50) .
"', 129 msg_filename = '" . prep_save($HB_ENV[
'HCUPOST'][
'msg_filename'], 20) .
"', 130 msg_level = '" . intval($HB_ENV[
'HCUPOST'][
'msg_level']) .
"' 131 WHERE msg_code = '" . prep_save($HB_ENV[
'HCUPOST'][
'msg_code'], 3) .
"' ";
133 $updRs = db_query($sql, $link);
136 throw new Exception(
'A problem occurred saving your changes.');
139 $retStatus_ary[
'homecuInfo'][] =
"Change was successfully saved.";
143 $sql =
"SELECT count(*) as count_msg 144 FROM ars_audio_message 145 WHERE msg_code = '" . prep_save($HB_ENV[
'HCUPOST'][
'msg_code'], 3) .
"' ";
146 $cntRs = db_query($sql, $link);
147 list($recordCount) = db_fetch_array($cntRs);
149 if ($recordCount == 0) {
150 throw new Exception(
'Message code was not found.');
153 $sql =
"DELETE FROM ars_audio_message 154 WHERE msg_code = '" . prep_save($HB_ENV[
'HCUPOST'][
'msg_code'], 3) .
"' ";
156 $updRs = db_query($sql, $link);
159 throw new Exception(
'A problem occurred saving your changes.');
162 $retStatus_ary[
'homecuInfo'][] =
"Change was successfully saved.";
167 throw new Exception(
'Invalid parameter setting. Action cancelled.');
172 }
catch (Exception $ex) {
173 $retStatus_ary[
'homecuErrors'][] =
"Unexpected error while saving. <br/>" . $ex->getMessage();
176 header(
'Content-type: application/json');
178 print json_encode(Array(
"Results" => Array($retStatus_ary)));