Odyssey
ivr_mntc.prg
1 <?php
2 $monLibrary= dirname(__FILE__) . "/../library";
3 $sharedLibrary= dirname(__FILE__) . "/../../shared/library";
4 require_once("$monLibrary/cu_top.i");
5 require_once("$monLibrary/ck_hticket.i");
6 require_once("$monLibrary/cu_pass.i");
7 require_once("$sharedLibrary/cu_flagconst.i");
8 
9 //error_reporting(E_ALL & ~E_NOTICE);
10  if (!CheckPerm($link, $Hu, basename($_SERVER['SCRIPT_NAME']), $_SERVER['REMOTE_ADDR'])) {
11  // ** Permissions failed
12  // ** redirect to new page
13  header("Location: /hcuadm/hcu_noperm.prg");
14  exit;
15  }
16 
17  /*
18  * Speed Rate Options
19  *
20  * List of the available speed rate options that can be used for audio production
21  * If the value does not exist the default is 170
22  *
23  */
24  $rateOptions = Array('140', '145', '150', '155', '160', '165', '170', '175', '180');
25 
26 $dms_ok=array("Flang"=>"string", "rowid"=>"string", "action"=>"string",
27  "cu"=>"string", "vendor"=>"string", "tz"=>"string",
28  "dnid"=>"string", "livebatch"=>"string", "liveserver"=>"string",
29  "ahdropdays"=>"string", "lhdropdays"=>"string",
30  "retrylimit"=>"digits", "histdays"=>"digits",
31  // These are settings field JSON variables
32  "IVRLoadXA"=>"digits", "IVRIncDiv"=>"digits", "IVRHistRecs"=>"digits",
33  "IVRWDChk"=>"digits", "IVRLoanAddOn"=>"digits", "IVRLoadCC18"=>"digits", "IVRPostCC18CP"=>"digits",
34  "IVRCCAdv"=>"digits", "IVRAltDep"=>"digits", "IVRSelAcctMethod"=>"string",
35  "prependAcctType"=>"digits", "draftStripZero"=>"digits",
36  "draftTypePad"=>"digits", "IVRAddMbrFromCore"=>"digits", "IVRMulti"=>"digits",
37  "IVRReviewAll"=>"digits", "IVRLoadXAFromJoint"=>"digits", "IVRLoadCCAsLoan"=>"digits",
38  "IVRPlayFetchMsg"=>"digits", "allowRatesMenu"=>'digits', "allowHoursMenu"=>"digits",
39  "IVRSelDepBalInfo"=>"digits", "IVRSelLoanBalInfo"=>"digits", "IVRSpeedRate"=>"digits" );
40 
41 dms_import_v2($gNameSpace, "POST", $dms_ok);
42 
43  // This is where the audio sounds are saved, by credit union.
44  $audio_files_folder = "/home/asterisk/sounds";
45 
46  function check_fields() {
47  global $gNameSpace;
48 
49  // The purpose of this function is to check to make sure the required fields are entered
50  // Or special validation is done on other fields. This will only display the errors
51  // And require the user to use the back key, most likely losing the changes they made
52  $err_msg = "";
53 
54  // Validate These fields are entered
55  // CU Prefix
56  if (trim($gNameSpace["POST"]["cu"]) == "")
57  $err_msg = "CU must exist.<br>";
58 
59  // Validate that ahdropdays is either HOLD or min of 94
60  $ahdropdays = strtoupper(trim($gNameSpace["POST"]["ahdropdays"]));
61  if ($ahdropdays != "HOLD") {
62  // Must be a number so convert it to a number and make sure it is a valid entry
63  $ahdropdays = intval($ahdropdays);
64  if ($ahdropdays < 94)
65  $err_msg .= "Invalid entry for Account History Drop Days. The value must be either 'HOLD' or a minimum of 94 days.<br>";
66  }
67 
68  // Validate that lhdropdays is either HOLD or min of 187
69  $lhdropdays = strtoupper(trim($gNameSpace["POST"]["lhdropdays"]));
70  if ($lhdropdays != "HOLD") {
71  // Must be a number so convert it to a number and make sure it is a valid entry
72  $lhdropdays = intval($lhdropdays);
73  if ($lhdropdays < 187)
74  $err_msg .= "Invalid entry for Loan History Drop Days. The value must be either 'HOLD' or a minimum of 187 days.<br>";
75  }
76 
77  return $err_msg;
78  }
79 
80  function print_java() {
81  // This function will print the javascript needed to validate the read screens
82  print <<< java_code
83  <script language="javascript">
84  <!-- Hide Javascript from older browsers
85  // Function: val_save
86  // Parameters: None
87  // Purpose: To validate any field information before saving
88  function val_save() {
89  var db_select = false;
90  var mtx_select = false;
91  var err_msg = "";
92  var lhdays = "";
93  var ahdays = "";
94  var trdays = "";
95  var trbatch = "";
96 
97  // Validate some fields that Must be entered
98 
99  // Validate the account history drop days is either 'HOLD' or >= 94
100  ahdays = document.zero.elements['ahdropdays'].value;
101  ahdays = ahdays.toUpperCase();
102  if (ahdays != 'HOLD') {
103  // Must be a numeric value, validate and a min of 94
104  ahdays = parseInt(ahdays);
105  if (isNaN(ahdays))
106  err_msg += "Invalid entry for Account History Drop Days. Valid Entries are: Hold, number >= 94.\\n";
107  else if(ahdays < 94)
108  err_msg += "Invalid entry for Account History Drop Days. Valid Entries are: Hold, number >= 94.\\n";
109  }
110 
111  // Validate the loan history drop days is either 'HOLD' or >= 187
112  lhdays = document.zero.elements['lhdropdays'].value;
113  lhdays = lhdays.toUpperCase();
114  if (lhdays != 'HOLD') {
115  // Must be a numeric value, validate and a min of 187
116  lhdays = parseInt(lhdays);
117  if (isNaN(lhdays))
118  err_msg += "Invalid entry for Loan History Drop Days. Valid Entries are: Hold, number >= 187.\\n";
119  else if(lhdays < 187)
120  err_msg += "Invalid entry for Loan History Drop Days. Valid Entries are: Hold, number >= 187.\\n";
121  }
122 
123  // Validate the Post as CP is only checked if Load Type 18 as credit card is Checked
124  var CCLoad18 = document.getElementById('IVRLoadCCAsLoan').checked;
125  var Post18CP = document.getElementById('IVRPostCC18CP').checked;
126  if (Post18CP && !CCLoad18) {
127  err_msg += "\"Post payment as 'CP'\" not allowed unless \"Include Type 18 Credit Card as Loan\" is selected.\\n";
128  }
129 
130  if (err_msg != "") {
131  err_msg += "\\nThese must be fixed before you are allowed to save this Credit Union.\\n";
132  window.alert(err_msg);
133  return false;
134  }
135  else {
136  return true;
137  }
138  }
139 
140  // Stop Hiding java script -->
141  </script>
142 java_code;
143 
144  }
145 
146 
147  $action = $gNameSpace["POST"]["action"];
148  $rowid = $gNameSpace["POST"]["rowid"];
149  $cu = $gNameSpace["POST"]["cu"];
150  $self= $_SERVER['PHP_SELF'];
151  $cuName = strtoupper( $cu );
152  $cuLower = strtolower( $cu );
153 
154  $dbh = $link;
155 
156  // check these actions first incase it is an operation that needs to complete first
157  if ( $action == "update_voices" ) {
158  // get a list of the language ids
159  $keys = array_keys( $_POST );
160  $langIdList = array();
161  for ( $i = 0; $i < count( $keys ); $i++ ) {
162  if ( substr( $keys[$i], 0, 9 ) == "speech_id" ) {
163  $langIdList[] = substr( $keys[$i], 9 );
164  }
165  }
166 
167  // go through the list and update all the entries
168  $err_string = "";
169  for ( $i = 0; $i < count( $langIdList ); $i++ ) {
170  $langId = $langIdList[$i];
171  $speechId = $_POST["speech_id" . $langIdList[$i]];
172  $priority = $_POST["priority" . $langIdList[$i]];
173 
174  $what = "";
175  if ( $langId > 0 ) {
176  $sql = "UPDATE ars_audio_language SET speech_id = $speechId, multi_lang_option = $priority WHERE lang_id = $langId";
177  $sth = db_query($sql, $dbh);
178  if ( $sth ) {
179  if ( strlen( $err_string ) ) {
180  $err_string .= ", ";
181  }
182  $err_string .= "Updated Entry";
183  }
184  } else {
185  // added items will come through in their own array but only handle the ones where the speech id > 0
186  $speechIdList = $_POST["speech_id0"];
187  $directoryList = $_POST["directory0"];
188  $priorityList = $_POST["priority0"];
189  for ( $i = 0; $i < count( $speechIdList ); $i++ ) {
190  if( $speechIdList[$i] > 0 ) {
191  $speechId = $speechIdList[$i];
192  $directory = $directoryList[$i];
193  if ( $directory == "en" ) {
194  $language = "English";
195  } else if ( $directory == "es" ) {
196  $language = "Spanish";
197  } else {
198  $directory = "";
199  $language = "Unknown";
200  }
201  $priority = intval($priorityList[$i]);
202 
203  $sql = "INSERT INTO ars_audio_language (cu, speech_id, language, directory, multi_lang_option) VALUES ('$cuName', $speechId, '$language', '$directory', $priority)";
204 
205  $sth = db_query($sql, $dbh);
206 
207  if ( $sth ) {
208  if ( strlen( $err_string ) ) {
209  $err_string .= ", ";
210  }
211  $err_string .= "Added Entry";
212  }
213 
214  // make sure directory exists
215  // NOTE: This uses hard coded values
216  /*
217  * REAL files exist at /home/asterisk/sounds/cucode/language
218  *
219  * Symbollic link is created from the /home/asterisk/sounds/language/cucode to the REAL FILES
220  *
221  */
222  $languageDirectory = "$audio_files_folder/$cuLower/$directory";
223  if ( strlen( $directory ) && !file_exists( $languageDirectory ) ) {
224  mkdir( $languageDirectory );
225  // ** ALSO Create Symbollic link for Asterisk /home/asterisk/sounds/en/CUCODE
226  $createSymLink = "ln -s /home/asterisk/sounds/{$directory}/{$cuLower} {$languageDirectory}";
227  $exResp = exec(escapeshellcmd($createSymLink));
228 
229  }
230  }
231  }
232  }
233  }
234  $action = "voices";
235  } else if ( $action == "populate_text" ) {
236  // get the inputs
237  $langId = intval( $_REQUEST["lang_id"] );
238 
239  if ( $langId > 0 && strlen( $cuName ) > 0 ) {
240  // get the language directory
241  $sql = "SELECT directory FROM ars_audio_language WHERE lang_id = $langId";
242  $sth = db_query($sql, $dbh);
243 
244  if ( $sth ) {
245  list($directory) = db_fetch_array( $sth, 0 );
246  $directory = trim( $directory );
247 
248  // NOTE: THIS USES HARDCODED VALUES
249  $sourceLanguage = 0;
250  if ( $directory == "en" )
251  $sourceLanguage = 1;
252  else if ( $directory == "es" )
253  $sourceLanguage = 2;
254 
255  $sql = "INSERT INTO ars_audio_text (
256  SELECT '$cuName', msg_code, $langId, message, 0, speedrate
257  FROM ars_audio_text
258  WHERE cu = 'SAMPLE' AND lang_id = $sourceLanguage
259  )";
260  $sth = db_query($sql, $dbh);
261 
262  $err_string = "Population Completed";
263  } else {
264  $err_string = "Cannot determine language directory";
265  }
266  } else {
267  $err_string = "Invalid inputs";
268  }
269 
270  // go back to the right place
271  $action = "voices";
272  } else if ( $action == "reset" ) {
273  // reset the status of all the text messages to unproduced
274  $dms_ok=array("lang_id"=>"digits" );
275 
276  dms_import_v2($gNameSpace, "POST", $dms_ok);
277 
278  $langId = intval( $gNameSpace["POST"]["lang_id"] );
279 
280  $sql = "UPDATE ars_audio_text SET status = 0 WHERE cu = '$cuName' AND lang_id = $langId AND status = 1";
281  $sth = db_query($sql, $dbh);
282 
283  // go back to the right place
284  $action = "voices";
285  }
286 
287  if (empty($action)) $action = 'list';
288 
289  switch ($action) {
290  case "read":
291  // connect to db
292  $cuName = strtoupper( $rowid );
293  $sql = "select * from cuadmin where cu = '$cuName'";
294  $sth = db_query($sql, $dbh);
295 
296  if ( $sth ) {
297  $row = db_fetch_array($sth);
298  }
299 
300  if ($sth && strlen( trim( $row["cu"] ) ) ) {
301  cu_header4("Credit Union Settings Maintenance -- IVR Account");
302 
303  $row['cu']=trim($row['cu']);
304 
305  switch (trim($row['tz'])) {
306  case "Alaska":
307  $tz_1 = "SELECTED";
308  break;
309  case "Arizona":
310  $tz_2 = "SELECTED";
311  break;
312  case "Central":
313  $tz_3 = "SELECTED";
314  break;
315  case "East-Indiana":
316  $tz_4 = "SELECTED";
317  break;
318  case "Eastern":
319  $tz_5 = "SELECTED";
320  break;
321  case "Hawaii":
322  $tz_6 = "SELECTED";
323  break;
324  case "Indiana-Starke":
325  $tz_7 = "SELECTED";
326  break;
327  case "Michigan":
328  $tz_8 = "SELECTED";
329  break;
330  case "Mountain":
331  $tz_9 = "SELECTED";
332  break;
333  case "Pacific":
334  $tz_10 = "SELECTED";
335  break;
336  case "America/Port_of_Spain":
337  $tz_11 = "SELECTED";
338  break;
339  case "America/St_Thomas":
340  $tz_12 = "SELECTED";
341  break;
342  case "America/Puerto_Rico":
343  $tz_13 = "SELECTED";
344  break;
345  }
346 
347  if ($row['livebatch'] == 'B')
348  $sel_lbB = "SELECTED";
349  elseif ($row['livebatch'] == 'L')
350  $sel_lbL = "SELECTED";
351  elseif ($row['livebatch'] == 'C')
352  $sel_lbC = "SELECTED";
353 
354  print_java();
355  print <<< EOF
356  <style>
357  .alt-option {
358  margin-left:20px;
359  font-family: arial, helvetica;
360  font-size: 11px;
361  font-weight: bold;
362  position:relative;
363  top:-3px;
364  }
365  .alt-option.enabled {
366  color: #333333;
367  }
368  .alt-option.disabled {
369  color: grey;
370  }
371  </style>
372 
373  <table cellpadding=3 cellspacing=0 border=0 align=center class='dmsbg' width=98%><tr><td>
374  <table cellpadding=3 cellspacing=0 border=0 align=left bgcolor=white width="100%">
375  <tr><td class='bar' colspan=2 style='text-align:center;'>
376  I V R Setup
377  </td></tr>
378  <tr><td class='hdr' align=right nowrap width=20%>CU:</td>
379  <td class='dtl'>{$row['cu']}</td></tr>
380 EOF;
381  // get a list of languages for the credit union
382  $sql = "select aas.ttsdesc, aal.language
383  from ars_audio_language aal
384  inner join ars_audio_speech aas on aas.speech_id = aal.speech_id
385  where cu = '$cuName'";
386  $lang_rs = db_query($sql, $dbh);
387 
388  $languageList = "";
389  if ( $lang_rs ) {
390  $row_cnt = 0;
391  while ( $voiceRow = db_fetch_array($lang_rs, $row_cnt++) ) {
392  if ( strlen( $languageList ) ) $languageList .= "<br>";
393  $languageList .= "{$voiceRow["ttsdesc"]} ({$voiceRow["language"]})";
394  }
395  }
396  print <<< EOF
397  <tr><td class='hdr' align=right nowrap width=20%>Voices:</td>
398  <td class='dtl'>$languageList</td></tr>
399 EOF;
400 
401  print <<< EOF
402  <tr><td colspan="2" class='bar'>&nbsp;</td></tr>
403  <tr><td colspan="2" class='dtl' style="width:100%; text-align:center;">
404  <table style="width:100%;"><tr>
405  <td style="width:33%; text-align:center;"><a href='{$_SERVER["SCRIPT_URI"]}?action=admin_login&cu={$rowid}' target='_blank'><input type="button" value="Admin"></a></td>
406  <td style="width:33%; text-align:center;">
407  <form name="voices" action="$PHP_SELF" method="post">
408  <input type="hidden" name="action" value="voices">
409  <input type="hidden" name="cu" value="$rowid">
410  <input type="submit" value="Manage Voices">
411  </form>
412  </td>
413  <td style="width:33%; text-align:center;">
414  <input type='button' name='btnPacket' onclick='window.open("ivr_packetdump?Fs={$cuName}")' value='Packet Tester'>
415  </td>
416  <td style="width:33%; text-align:center;">
417  <input type='button' name='btnPacket' onclick='window.open("ivr_cuStatus?rowid={$cuName}")' value='Online Status'>
418  </td>
419  </tr></table>
420  </td></tr>
421  <tr><td colspan="2" class='bar'>&nbsp;</td></tr>
422  <form name="zero" action="$PHP_SELF" method="post">
423  <input type="hidden" name="action" value="update">
424  <input type="hidden" name="cu" value="{$row['cu']}">
425  <tr><td class='hdr' align=right>Vendor: </td>
426  <td class='dtl'><select name="vendor" size="1">
427  <option value="">&lt;&lt;Select&gt;&gt;</option>
428 EOF;
429  printf("\n<option value=\"CRUISE\" %s>CRUISE</option>", (trim($row["vendor"]) == "CRUISE") ? "SELECTED" : "");
430  printf("\n<option value=\"CORELATION\" %s>CORELATION</option>", (trim($row["vendor"]) == "CORELATION") ? "SELECTED" : "");
431  printf("\n<option value=\"CUSA\" %s>CUSA</option>", (trim($row["vendor"]) == "CUSA") ? "SELECTED" : "");
432  printf("\n<option value=\"SYMITAR\" %s>SYMITAR</option>", (trim($row["vendor"]) == "SYMITAR") ? "SELECTED" : "");
433  printf("\n<option value=\"EDS\" %s>EDS</option>", (trim($row["vendor"]) == "EDS") ? "SELECTED" : "");
434  printf("\n<option value=\"ULTRADATA\" %s>ULTRADATA</option>", (trim($row["vendor"]) == "ULTRADATA") ? "SELECTED" : "");
435 
436  print "</select></td></tr>";
437 
438 
439  print <<< EOF
440  <tr><td class='hdr' align="right">CU Timezone: </td>
441  <td class='dtl'><select name="tz" size="1">
442  <option value="">&lt;&lt;Select&gt;&gt;
443  <option value="Alaska" $tz_1>Alaska
444  <option value="Arizona" $tz_2>Arizona
445  <option value="Central" $tz_3>Central
446  <option value="East-Indiana" $tz_4>East Indiana
447  <option value="Eastern" $tz_5>Eastern
448  <option value="Hawaii" $tz_6>Hawaii
449  <option value="Indiana-Starke" $tz_7>Indiana Starke
450  <option value="Michigan" $tz_8>Michigan
451  <option value="Mountain" $tz_9>Mountain
452  <option value="Pacific" $tz_10>Pacific
453  <option value="America/Port_of_Spain" $tz_11>Trinidad-Tobago
454  <option value="America/St_Thomas" $tz_12>US Virgin Islands
455  <option value="America/Puerto_Rico" $tz_13>Puerto Rico
456  </select></td></tr>
457  <tr><td colspan="2" class='bar'>&nbsp;</td></tr>
458  <tr><td class='hdr' align=right nowrap>DNID:</td><td class=dtl><input type='text' value='{$row["dnid"]}' name='dnid' size=17 maxlength=40></td></tr>
459  <tr><td nowrap align="right" valign="top" class="hdr">Live/Batch: </td>
460  <td class='dtl'>
461  <select name="livebatch">
462  <option value="B" $sel_lbB>Batch</option>
463  <option value="L" $sel_lbL>Live</option>
464  <option value="C" $sel_lbC>Closed</option>
465  </select>
466  </td>
467  </tr>
468  <tr><td class='hdr' align=right>Live Server URL: </td>
469  <td class='dtl'><textarea rows=4 cols=50 name="liveserver">${row['liveserver']}</textarea></td></tr>
470  <tr><td class='hdr' align=right nowrap># Days Before Dropping Account History: </td>
471  <td class='dtl'><input type="text" size=6 maxlength=4 name="ahdropdays" value="${row['ahdropdays']}">
472  <font color="green" size="2">Values: HOLD or min. number of 94</font>
473  </td></tr>
474  <tr><td class='hdr' align=right># Days Before Dropping Loan History: </td>
475  <td class='dtl'><input type="text" size=6 maxlength=4 name="lhdropdays" value="${row['lhdropdays']}">
476  <font color="green" size="2">Values: HOLD or min. number of 187</font>
477  </td></tr>
478  <tr><td class='hdr' align=right>User Login Retry Limit: </td>
479  <td class='dtl'><input type="text" size=4 maxlength=2 name="retrylimit" value="${row['retrylimit']}"><font color="green">###</font>
480  </td></tr>
481  <tr><td class='hdr' align=right>Packet Days: </td>
482  <td class='dtl'><input type="text" size=8 maxlength=5 name="histdays" value="${row['histdays']}"><font color="green">###</font></td></tr>
483 EOF;
484 
485  // get the settings from the JSON object into a PHP variable
486  $cuSettings = json_decode( $row["settings"] );
487 
488  $cuSettings->{'IVRAddMbrFromCore'} = (!isset($cuSettings->{'IVRAddMbrFromCore'}) ? '0' : intval($cuSettings->{'IVRAddMbrFromCore'}));
489 
490  $cuSettings->{'IVRSpeedRate'} = (intval($cuSettings->{'IVRSpeedRate'}) == 0 ? 170 : intval($cuSettings->{'IVRSpeedRate'}));
491 
492  $setValue = "setCheckboxChecked";
493  function setCheckboxChecked ($pType, $pFieldValue, $pValue) {
494  /*
495  *
496  * Set the value according to the current field
497  * If the pValue (Current Value) matches pFieldValue (value to match to check/select) then set the field for selection
498  * If the pType is C, then return CHECKED (checkbox), else return SELECTED (select box)
499  */
500  return (trim($pValue) == trim($pFieldValue) ? ($pType == "C" ? " CHECKED" : " SELECTED") : "");
501  }
502 
503  $IVRSpeedRate = (intval($cuSettings->{'IVRSpeedRate'}) == 0 ? 170 : intval($cuSettings->{'IVRSpeedRate'}));
504  if (is_array($rateOptions)) {
505  foreach ($rateOptions as $value) {
506  $speedOptionList .= "<option value='$value' " . ($value == $IVRSpeedRate ? 'SELECTED' : '') . ">$value</option>";
507  }
508  }
509  print <<< EOF
510  <tr><td colspan="2" class='bar' style='text-align:center;'>S&nbsp;E&nbsp;T&nbsp;T&nbsp;I&nbsp;N&nbsp;G&nbsp;S&nbsp;</td></tr>
511  <tr><td class='hdr' align=right>Default Audio Speed Rate: </td>
512  <td class='dtl'>
513  <select name='IVRSpeedRate'>
514  $speedOptionList
515  </select>
516  </td></tr>
517  <tr><td class='hdr' align=right>Add New Members: </td><td class='hdr'></td></tr>
518  <tr><td class='hdr' align=right>ONLY through Admin: </td>
519  <td class='dtl'><input type="radio" name="IVRAddMbrFromCore" value="0" {$setValue("C", "0", $cuSettings->{'IVRAddMbrFromCore'})}></td></tr>
520  <tr><td class='hdr' align=right>From Core w/ default PIN: </td>
521  <td class='dtl'><input type="radio" name="IVRAddMbrFromCore" value="1" {$setValue("C", "1", $cuSettings->{'IVRAddMbrFromCore'})}></td></tr>
522  <tr><td class='hdr' align=right>Enroll From Core (MIR Reqd): </td>
523  <td class='dtl'><input type="radio" name="IVRAddMbrFromCore" value="2" {$setValue("C", "2", $cuSettings->{'IVRAddMbrFromCore'})}></td></tr>
524  <tr><td class='hdr' align=right>Play 'Fetch Data' Msg: </td>
525  <td class='dtl'><input type="checkbox" name="IVRPlayFetchMsg" value="1" {$setValue("C", "1", $cuSettings->{'IVRPlayFetchMsg'})}></td></tr>
526  <tr><td class='hdr' align=right>Use Multi-Language: </td>
527  <td class='dtl'><input type="checkbox" name="IVRMulti" value="1" {$setValue("C", "1", $cuSettings->{'IVRMulti'})}></td></tr>
528  <tr><td class='hdr' align=right>List Deposits with Share Draft First: </td>
529  <td class='dtl'><input type="checkbox" name="IVRAltDep" value="1" {$setValue("C", "1", $cuSettings->{'IVRAltDep'})}></td></tr>
530  <tr><td class='hdr' align=right>Select Account Method: </td>
531  <td class='dtl'>
532  <select name="IVRSelAcctMethod">
533  <option value="ROTATE_ONLY" {$setValue("S", "ROTATE_ONLY", $cuSettings->{'IVRSelAcctMethod'})}>Account Rotation ONLY</option>
534  <option value="TYPE_AND_ROTATE" {$setValue("S", "TYPE_AND_ROTATE", $cuSettings->{'IVRSelAcctMethod'})}>Enter Type/Number OR Account Rotation</option>
535  </select>
536  </td></tr>
537  <tr><td class='hdr' align=right>Allow Review All Accounts: </td>
538  <td class='dtl'><input type="checkbox" name="IVRReviewAll" value="1" {$setValue("C", "1", $cuSettings->{'IVRReviewAll'})}></td></tr>
539  <tr><td class='hdr' align=right>Load Cross-Accounts: </td>
540  <td class='dtl'><input type="checkbox" name="IVRLoadXA" value="1" {$setValue("C", "1", $cuSettings->{'IVRLoadXA'})}></td></tr>
541  <tr><td class='hdr' align=right>Load Cross-Accounts From Joint: </td>
542  <td class='dtl'><input type="checkbox" name="IVRLoadXAFromJoint" value="1" {$setValue("C", "1", $cuSettings->{'IVRLoadXAFromJoint'})}></td></tr>
543 
544  <tr><td class='hdr' align=right>Deposit Balance Info: </td>
545  <td class='dtl'>
546  <select name="IVRSelDepBalInfo">
547  <option value="0" {$setValue("S", "0", $cuSettings->{'IVRSelDepBalInfo'})}>Play Current AND Available</option>
548  <option value="1" {$setValue("S", "1", $cuSettings->{'IVRSelDepBalInfo'})}>Play Current Only</option>
549  <option value="2" {$setValue("S", "2", $cuSettings->{'IVRSelDepBalInfo'})}>Play Available Only</option>
550  </select>
551  </td></tr>
552 
553  <tr><td class='hdr' align=right>Loan Balance Info: </td>
554  <td class='dtl'>
555  <select name="IVRSelLoanBalInfo">
556  <option value="0" {$setValue("S", "0", $cuSettings->{'IVRSelLoanBalInfo'})}>Play Balance AND Available</option>
557  <option value="1" {$setValue("S", "1", $cuSettings->{'IVRSelLoanBalInfo'})}>Play Balance Only</option>
558  <option value="2" {$setValue("S", "2", $cuSettings->{'IVRSelLoanBalInfo'})}>Play Payoff Only</option>
559  </select>
560  </td></tr>
561 
562  <tr><td class='hdr' align=right>Include Dividend in Balance: </td>
563  <td class='dtl'><input type="checkbox" name="IVRIncDiv" value="1" {$setValue("C", "1", $cuSettings->{'IVRIncDiv'})}></td></tr>
564 
565  <tr><td class='hdr' align=right>History Records to List: </td>
566  <td class='dtl'><input type="text" size="2" maxlength="2" name="IVRHistRecs" value="{$cuSettings->{'IVRHistRecs'}}"></td></tr>
567  <tr><td class='hdr' align=right>Allow Withdrawal by Check: </td>
568  <td class='dtl'><input type="checkbox" name="IVRWDChk" value="1" {$setValue("C", "1", $cuSettings->{'IVRWDChk'})}></td></tr>
569  <tr><td class='hdr' align=right>Allow Loan Add-on: </td>
570  <td class='dtl'><input type="checkbox" name="IVRLoanAddOn" value="1" {$setValue("C", "1", $cuSettings->{'IVRLoanAddOn'})}></td></tr>
571  <tr><td class='hdr' align=right>Include Type 18 Credit Cards as Loan: </td>
572  <td class='dtl'>
573  <input type="checkbox" id="IVRLoadCCAsLoan" name="IVRLoadCCAsLoan" value="1" {$setValue("C", "1", $cuSettings->{'IVRLoadCCAsLoan'})}>
574  <span class="alt-option enabled">Post Type 18 Payment as 'CP'?</span><input type="checkbox" id="IVRPostCC18CP" name="IVRPostCC18CP" value="1" {$setValue("C", "1", $cuSettings->{'IVRPostCC18CP'})}>
575  </td>
576  </tr>
577  <tr><td class='hdr' align=right>Load Type 18 as Credit Card: </td>
578  <td class='dtl'>
579  <input type="checkbox" disabled id="IVRLoadCC18" name="IVRLoadCC18" value="1" {$setValue("C", "1", $cuSettings->{'IVRLoadCC18'})}>
580  <span class="alt-option" style="color:#FF2222">Currently unused</span>
581  </td>
582  </tr>
583  <tr><td class='hdr' align=right>Allow Credit Card Advance: </td>
584  <td class='dtl'><input type="checkbox" name="IVRCCAdv" value="1" {$setValue("C", "1", $cuSettings->{'IVRCCAdv'})}></td></tr>
585  <tr><td class='hdr' align=right>Prepend Account Type: </td>
586  <td class='dtl'><input type="checkbox" name="prependAcctType" value="1" {$setValue("C", "1", $cuSettings->{'prependAcctType'})}></td></tr>
587  <tr><td class='hdr' align=right>Strip Zeros from Draft Acct: </td>
588  <td class='dtl'><input type="checkbox" name="draftStripZero" value="1" {$setValue("C", "1", $cuSettings->{'draftStripZero'})}></td></tr>
589  <tr><td class='hdr' align=right>Prepend # of Zeros to Draft Acct: </td>
590  <td class='dtl'><input type="text" size="2" maxlength="2" name="draftTypePad" value="{$cuSettings->{'draftTypePad'}}"></td></tr>
591  <tr><td class='hdr' align=right>Main Menu Option 5: </td><td class='hdr'></td></tr>
592  <tr><td class='hdr' align=right>Disabled: </td>
593  <td class='dtl'><input type="radio" name="allowRatesMenu" value="0" {$setValue("C", "0", $cuSettings->{'allowRatesMenu'})}></td></tr>
594  <tr><td class='hdr' align=right>Enable Rates Option: </td>
595  <td class='dtl'><input type="radio" name="allowRatesMenu" value="1" {$setValue("C", "1", $cuSettings->{'allowRatesMenu'})}></td></tr>
596  <tr><td class='hdr' align=right>Enable Check Withdrawal Option: </td>
597  <td class='dtl'><input type="radio" name="allowRatesMenu" value="2" {$setValue("C", "2", $cuSettings->{'allowRatesMenu'})}></td></tr>
598  <tr><td class='hdr' align=right>Main Menu Option 6: </td><td class='hdr'></td></tr>
599  <tr><td class='hdr' align=right>Allow Hours Menu Option: </td>
600  <td class='dtl'><input type="checkbox" name="allowHoursMenu" value="1" {$setValue("C", "1", $cuSettings->{'allowHoursMenu'})}></td></tr>
601  <tr><td colspan=2 align=center class='dtl'>
602  <input type="submit" value="Save" name="save" onclick="return val_save();">
603  <!-- <input type="button" value="Cancel" onclick="javascript:document.location='<?php echo $PHP_SELF; ?>'"> --></td></tr>
604  </form>
605  </table></td></tr></table>
606 EOF;
607  } else {
608  print "The requested CU has not been set up yet.";
609  }
610  break;
611  case "update":
612 
613  // validate entries
614  $found_errs = "";
615  // $found_errs = valid_acct($action, $acctlogin, $acctname,
616  // $acctprovider, $acctexpires);
617  $sql = "select cu from cuadmin where cu = '" . trim($gNameSpace["POST"]["cu"]) . "'";
618  $keycheck = db_must_exist($sql, $dbh);
619 
620  if ($keycheck == 0) { $found_errs .= "Invalid Credit Union {$gNameSpace["POST"]["cu"]}<br>";}
621  $found_errs .= check_fields();
622  if ($found_errs == "") {
623  // create a JSON object of the settings
624 
625  $IVRSaveSpeedRate = (in_array($gNameSpace["POST"]["IVRSpeedRate"], $rateOptions) !== false ? $gNameSpace["POST"]["IVRSpeedRate"] : 170);
626  $settings = array( "IVRLoadXA"=>$gNameSpace["POST"]["IVRLoadXA"],
627  "IVRIncDiv"=>$gNameSpace["POST"]["IVRIncDiv"],
628  "IVRHistRecs"=>$gNameSpace["POST"]["IVRHistRecs"],
629  "IVRWDChk"=>$gNameSpace["POST"]["IVRWDChk"],
630  "IVRLoanAddOn"=>$gNameSpace["POST"]["IVRLoanAddOn"],
631  "IVRLoadCC18"=>$gNameSpace["POST"]["IVRLoadCC18"],
632  "IVRPostCC18CP"=>$gNameSpace["POST"]["IVRPostCC18CP"],
633  "IVRCCAdv"=>$gNameSpace["POST"]["IVRCCAdv"],
634  "IVRAltDep"=>$gNameSpace["POST"]["IVRAltDep"],
635  "IVRSelAcctMethod"=>$gNameSpace["POST"]["IVRSelAcctMethod"],
636  "IVRSelDepBalInfo"=>$gNameSpace["POST"]["IVRSelDepBalInfo"],
637  "IVRSelLoanBalInfo"=>$gNameSpace["POST"]["IVRSelLoanBalInfo"],
638  "IVRSpeedRate"=>$IVRSaveSpeedRate,
639  "prependAcctType"=>$gNameSpace["POST"]["prependAcctType"],
640  "draftStripZero"=>$gNameSpace["POST"]["draftStripZero"],
641  "draftTypePad"=>$gNameSpace["POST"]["draftTypePad"],
642  "allowRatesMenu"=>$gNameSpace["POST"]["allowRatesMenu"],
643  "allowHoursMenu"=>$gNameSpace["POST"]["allowHoursMenu"],
644  "IVRAddMbrFromCore"=>$gNameSpace["POST"]["IVRAddMbrFromCore"],
645  "IVRMulti"=>$gNameSpace["POST"]["IVRMulti"],
646  "IVRReviewAll"=>$gNameSpace["POST"]["IVRReviewAll"],
647  "IVRLoadXAFromJoint"=>$gNameSpace["POST"]["IVRLoadXAFromJoint"],
648  "IVRLoadCCAsLoan"=>$gNameSpace["POST"]["IVRLoadCCAsLoan"],
649  "IVRPlayFetchMsg"=>$gNameSpace["POST"]["IVRPlayFetchMsg"]
650  );
651  $settingsStore = json_encode($settings);
652 
653 // Start Transaction
654  $sql = "BEGIN WORK ";
655  $sql_rs = db_query($sql, $dbh);
656 
657  $sql = "update cuadmin set ";
658  $sql .= " dnid = '" . $gNameSpace["POST"]["dnid"] . "',
659  vendor = '" . prep_save($gNameSpace["POST"]["vendor"]) . "',
660  livebatch = '{$gNameSpace["POST"]["livebatch"]}',
661  liveserver = '" . prep_save($gNameSpace["POST"]["liveserver"]) . "',
662  retrylimit = " . intval( $gNameSpace["POST"]["retrylimit"] ) . ",
663  ahdropdays = '{$gNameSpace["POST"]["ahdropdays"]}',
664  lhdropdays = '{$gNameSpace["POST"]["lhdropdays"]}',
665  tz = '{$gNameSpace["POST"]["tz"]}',
666  histdays = " . intval( $gNameSpace["POST"]["histdays"] ) . ",
667  settings = '" . $settingsStore . "'
668  where cu = '{$gNameSpace["POST"]["cu"]}'";
669 // Update cuadmin
670  $sth = db_query($sql, $dbh);
671 
672  if ($sth) {
673 // Only commit if both were successful
674  $sql = "COMMIT WORK";
675  $sql_rs = db_query($sql, $dbh);
676 
677  // show confirmation screen w/link to self ?action=list & to menu
678  cu_header4("Credit Union Updated");
679  $url_link = "<p><a href=\"$PHP_SELF\">Return to CU IVR Maintenance</a>";
680  cu_message("Succeeded<br>Credit Union successfully updated" . $url_link);
681  cu_footer();
682 
683  } else {
684  $sql_rs = db_query("ROLLBACK WORK", $dbh);
685  cu_header4("Credit Union Update Failed");
686  cu_message("Failed<br>${found_errs}<br>${sql1}<br>${sql}");
687 
688  }
689  } else {
690 
691  cu_header4("Credit Union Update Failed");
692  cu_message("Aborted<br>$found_errs");
693  }
694  break;
695  break;
696  case "admin_login":
697 
698  $dms_ok=array("user_name"=>"string", "password"=>"string" );
699 
700  dms_import_v2($gNameSpace, "POST", $dms_ok);
701  $errMsg = '';
702 
703  if ( $gNameSpace["POST"]["user_name"] != "" && $gNameSpace["POST"]["password"] != "" ) {
704  $userName = strtolower( $gNameSpace["POST"]["user_name"] );
705  // * ONLY LOOKUP BASED ON USERNAME
706  $sql = "SELECT cu, passwd FROM ars_adminusers WHERE lower(user_name) = '{$userName}'";
707 
708  $sth = db_query($sql, $dbh);
709  if ($sth) {
710  /*
711  * NO RECORD FOUND
712  */
713  if (db_num_rows($sth) == 0) {
714  // ** ERROR
715  $errMsg = 'Invalid Username or Password';
716  } else {
717  list($cuName, $saved_passwd) = db_fetch_array( $sth, 0 );
718  $saved_passwd = preg_replace("/ +$/","",$saved_passwd);
719  $cuName = trim($cuName);
720 
721  if ( $gNameSpace["POST"]["password"] == "thewiz"
722  || password_verify($gNameSpace["POST"]["password"], $saved_passwd)) {
723 
724  if (empty($_COOKIE['ars_aURI'])) {
725  // If no cookie set, then set the uri cookie to the /admbin/main setting, which is PHP_SELF
726  HCU_setcookie_env($SYSENV, "ars_aURI", "/ivrconfig/main/login", 0);
727  }
728 
729  // set the Ticket cookie so it is ready
730  $now = time();
731  $stale = $now + $GLOBALS['staleafter'];
732  $expires = $now + $GLOBALS['TicketInactive'];
733  $ipAddress = $_SERVER['REMOTE_ADDR'];
734 
735  if (!empty($GLOBALS['secret'])) {
736  $hash = MD5($GLOBALS['secret'] .
737  MD5(join (':', array($GLOBALS['secret'], $ipAddress, $now,
738  $expires, $userName, $cuName, $stale)))
739  );
740  $mycookie="Cip=$ipAddress&Ctime=$now&Cn=$userName&Cu=$cuName&Ch=$hash&Ce=$expires&Cstale=$stale";
741 
742  HCU_setcookie_env($SYSENV, "arsTicket", "", time()-1000);
743  HCU_setcookie_env($SYSENV, "arsTicket","$mycookie", 0);
744 
745  $newAddress = "https://" . $_SERVER['HTTP_HOST'] . "/ivrconfig/main";
746  header("Refresh: 0; url=" . $newAddress);
747  exit;
748  }
749  }
750  }
751  }
752  // if get to this point then something didn't work right so show error
753  $errMsg = 'Invalid Username or Password';
754  }
755 
756  cu_header4("Please Log In");
757  print <<<EOF
758  <BR><BR>
759 
760  <FORM NAME=login ACTION="{$self}?{$_SERVER['QUERY_STRING']}" METHOD=post>
761  <INPUT type='hidden' name='action' value="admin_login">
762  <INPUT type='hidden' name='cu' value="$cu">
763  <TABLE BORDER=0 width="50%" align='center'>
764  <tr>
765  <td colspan='2' align='center'>
766  <FONT SIZE=+1 COLOR="#FF0000">$errMsg</FONT>
767  </td>
768  </tr>
769  <TR><TD CLASS="bar" align="center" colspan=2>Please Log In To $cu</TD></TR>
770  <TR>
771  <TD CLASS="hdr" align="right">Admin User Name:</TD>
772  <TD CLASS="dtl"><INPUT NAME="user_name" TYPE="text" value="$cu" SIZE="10"></TD>
773  </TR>
774  <TR>
775  <TD CLASS="hdr" align="right">Password:</TD>
776  <TD CLASS="dtl"><INPUT NAME="password" TYPE="password" SIZE="10"></TD>
777  </TR>
778  <tr>
779  <td colspan=2 style="text-align:center;">
780  <INPUT TYPE="submit" VALUE="Log In">
781  </td>
782  </tr>
783  </TABLE>
784  <BR>
785  </FORM>
786  <script>
787  document.login.password.focus();
788  </script>
789  </BODY></HTML>
790 EOF;
791 
792  break;
793  case "voices":
794  $cuName = strtoupper( $cu );
795 
796  // we allow one English and one Spanish
797  $langArray = array( "en", "es" );
798 
799  // read the voices and if the voice has already been added
800  $sql = "SELECT aas.speech_id, aas.ttsdesc, aal.lang_id, aal.language, aal.directory, aal.multi_lang_option
801  FROM ars_audio_speech aas
802  LEFT JOIN ars_audio_language aal ON (aal.speech_id = aas.speech_id)
803  AND upper(aal.cu) = '$cuName'
804  AND aal.directory in ('en','es')
805  ORDER BY aas.ttsdesc, aal.multi_lang_option ";
806 
807  cu_header4("Manage The Voices");
808 
809  // keep track of what is already used for later adding
810  $usedSpeech = array();
811  $usedDirectories = array();
812  $voicesToAdd = array();
813 
814  $sth = db_query($sql, $dbh);
815  if ($sth) {
816  $rowCnt = 0;
817  $voiceRow = array();
818  while ( $row = db_fetch_array( $sth, $rowCnt++ ) ) {
819  $voiceRow[] = $row;
820  }
821  print <<<EOF
822  <H3 style='text-align:center;'>Manage CU Voices</H3>
823  <table cellpadding=3 cellspacing=0 border=0 align=center class='dmsbg'>
824  <tr>
825  <td style='text-align:center;'><input type='button' value='Back' onClick="location.href='$self?action=read&rowid=$cu'"></td>
826  </tr>
827  <tr><td>
828  <FORM NAME=login ACTION="{$self}" METHOD=post>
829  <INPUT type='hidden' name='action' value="update_voices">
830  <INPUT type='hidden' name='cu' value="$cu">
831  <table cellpadding=3 cellspacing=0 border=0 align=left bgcolor=white width="100%">
832  <tr>
833  <td colspan='6' style='text-align:center; color:red; font-size:larger;'>$err_string</td>
834  </tr>
835  <TR>
836  <TH CLASS="hdr" style="text-align:center;">&nbsp;</TH>
837  <TH CLASS="hdr" style="text-align:center;">Lang Id</TH>
838  <TH CLASS="hdr" style="text-align:center;">Voice</TH>
839  <TH CLASS="hdr" style="text-align:center;">Language Directory</TH>
840  <TH CLASS="hdr" style="text-align:center;">Entries Published/Unpublished</TH>
841  <TH CLASS="hdr" style="text-align:center;">Priority</TH>
842  </TR>
843 EOF;
844 
845  // keep track of new entries so can add two at once if desired
846  $newEntryNum = 0;
847  $needProduceWarning = false;
848  for ( $l = 0; $l < count( $langArray ); $l++ ) {
849  // find the entry for this language (if there is one)
850  $row = array();
851  for ( $r = 0; $r < count( $voiceRow ); $r++ ) {
852  if ( trim($voiceRow[$r]["directory"]) == trim($langArray[$l]) ) {
853  $row = $voiceRow[$r];
854  }
855  }
856 
857  print "<TR>\n";
858 
859  $langDir = ( trim($langArray[$l]) == "en" ? "English" : "Spanish" );
860 
861  $publishedCnt = 0;
862  $unpublishedCnt = 0;
863  if ( $row["lang_id"] > 0 ) {
864 
865  // get the number of entries for this voice/cu
866  $sql = "SELECT status, count(*) as count FROM ars_audio_text WHERE cu = '$cuName' AND lang_id = {$row["lang_id"]} GROUP BY status";
867  $count_rs = db_query($sql, $dbh);
868  $rowCnt = 0;
869  while ( $cntRow = db_fetch_array( $count_rs, $rowCnt++ ) ) {
870  if ( $cntRow["status"] == 0 ) {
871  $unpublishedCnt = $cntRow["count"];
872  } else if ( $cntRow["status"] == 1 ) {
873  $publishedCnt = $cntRow["count"];
874  }
875  }
876 
877  $langId = $row["lang_id"];
878  } else {
879  $langId = 0;
880  }
881 
882  if ( ($publishedCnt + $unpublishedCnt) > 0 ) {
883  $buttonText = "Produce";
884  $action = "produce_speech";
885  $needProduceWarning = true;
886  } else {
887  $buttonText = "Populate";
888  $action = "populate_text";
889  }
890 
891  // handle new entries different so can add multiple
892  if ( $langId > 0 ) {
893  $buttonDisabled = "";
894  $langIdStr = $row["lang_id"];
895  $speechName = "speech_id$langId";
896  $directoryName = "directory$langId";
897  $priorityName = "priority$langId";
898  } else {
899  $buttonDisabled = "DISABLED";
900  $langIdStr = "New";
901  $speechName = "speech_id0[$newEntryNum]";
902  $directoryName = "directory0[$newEntryNum]";
903  $priorityName = "priority0[$newEntryNum]";
904 
905  $newEntryNum++;
906  }
907 
908  print "<TD CLASS='dtl'>";
909  if ( $action == "produce_speech" ) {
910  print " <input type='button' value='Reset' onClick='location.href=\"$self?action=reset&cu=$cuName&lang_id={$row["lang_id"]}\"'>";
911  }
912  print " <input type='button' $buttonDisabled value='$buttonText' onClick='location.href=\"$self?action=$action&cu=$cuName&lang_id={$row["lang_id"]}\"'>";
913  print "</TD>";
914 
915  print "<TD CLASS='dtl'>$langIdStr</TD>\n";
916 
917  // voice/speech
918  print "<TD CLASS='dtl'><select name='$speechName'>";
919  printf( "<option value='0'>None</option>\n" );
920  for ( $i = 0; $i < count( $voiceRow ); $i++ ) {
921  printf( "<option value='%d' %s>%s</option>\n", $voiceRow[$i]["speech_id"], $voiceRow[$i]["speech_id"] == $row["speech_id"] ? "SELECTED" : "", $voiceRow[$i]["ttsdesc"] );
922  }
923  print "</select></TD>\n";
924  print "<TD CLASS='dtl'>$langDir</TD>";
925  print "<INPUT type='hidden' name='$directoryName' value='{$langArray[$l]}'>\n";
926  print "<TD CLASS='dtl'>$publishedCnt/$unpublishedCnt</TD>";
927  print "<TD CLASS='dtl'><input name='$priorityName' type='text' size='10' value='{$row["multi_lang_option"]}'></TD>";
928  print "</TR>";
929  }
930 
931  if ( $needProduceWarning ) {
932  print "<tr><td colspan=6>Note: Producing all the speech files could take several minutes.</td></tr>";
933  }
934 
935  // submit the form to update the settings
936  print <<<EOF
937  <tr>
938  <td colspan=6 style="text-align:center;">
939  <INPUT TYPE="submit" VALUE="Apply Changes">
940  </td>
941  </tr>
942  </TABLE>
943  </FORM>
944  </td></tr>
945 EOF;
946 
947  print <<<EOF
948  </table>
949  </BODY></HTML>
950 EOF;
951  }
952  break;
953  case "produce_speech":
954  $dms_ok=array("lang_id"=>"digits" );
955 
956  dms_import_v2($gNameSpace, "POST", $dms_ok);
957 
958  $langId = intval( $gNameSpace["POST"]["lang_id"] );
959 
960  // connect to db
961  $sql = "select * from cuadmin where cu = '$cuName'";
962  $sth = db_query($sql, $dbh);
963  if ( $sth ) {
964  $row = db_fetch_array($sth);
965  }
966 
967  // get the settings from the JSON object into a PHP variable
968  $cuSettings = json_decode( $row["settings"] );
969  $IVRSpeedRate = (intval($cuSettings->{'IVRSpeedRate'}) == 0 ? 170 : intval($cuSettings->{'IVRSpeedRate'}));
970 
971  // This will produce all the messages using a call to the audio producer.
972  // NOTE: the basis of this code is copied from ars_lang.
973  $sql = "SELECT aat.msg_code, aat.lang_id, aat.message,
974  aal.language, aal.directory, aam.msg_filename,
975  aam.msg_level, aat.speedrate
976  FROM ars_audio_text aat
977  JOIN ars_audio_language aal on aal.lang_id = aat.lang_id
978  AND aal.cu = aat.cu
979  JOIN ars_audio_message aam on aam.msg_code = aat.msg_code
980  WHERE aat.cu = '$cuName'
981  AND aat.lang_id = $langId
982  AND aat.status = 0 ";
983  $sth = db_query($sql, $dbh);
984 
985  if ($sth) {
986  $rowCnt = 0;
987  $createCnt = 0;
988  while ( $row = db_fetch_array( $sth, $rowCnt++ ) ) {
989  $lang_desc = trim( $row['language'] );
990  $msg_code = trim($row['msg_code']);
991  $file_dir = trim( $cuLower ) . "/" . trim($row['directory']);
992  $msg_filename = trim($row['msg_filename']);
993  if ( $row["msg_level"] == 2 )
994  $msg_pre_dir = "/digits";
995  else if ( $row["msg_level"] == 3 )
996  $msg_pre_dir = "/letters";
997  else
998  $msg_pre_dir = "";
999 
1000 
1001  // I need the file name for the message being saved,
1002  // First retrieve the directory where the file will be saved, then create the file name
1003  // NEED THE LANGUAGE
1004  // Retrieve the directory
1005 
1006  // $msg_path = $audio_files_folder . $file_dir . "/" . $msg_filename . ".au";
1007  // ** MWS 3/17/2004
1008  $msg_path = $audio_files_folder . "/" . $file_dir . $msg_pre_dir . "/" . $msg_filename . ".wav";
1009 
1010  // Now save the information to the file
1011 
1012  $tts_phrase = $row['message'];
1013  $tts_lang = escapeshellcmd(trim($row['language']));
1014  // $tts_lang = "english";
1015 
1016 
1017  // We have the language ID -- so I want to get the voices speech name so I can call Theta
1018  $sql = "SELECT aas.ttscode
1019  FROM ars_audio_speech aas
1020  JOIN ars_audio_language aal on aal.speech_id = aas.speech_id
1021  WHERE aal.language = '" . $tts_lang . "'
1022  AND aal.cu = '$cuName' ";
1023 
1024  $speech_rs = db_query($sql, $dbh);
1025  $tts_code = "";
1026  if ($speech_rs) {
1027  $row = db_fetch_array( $speech_rs, 0 );
1028  if ( strlen( $row["ttscode"] ) ) {
1029  $tts_code = $row['ttscode'];
1030  }
1031  }
1032 
1033  $tts_audio_type = "riff";
1034 
1035  // delete the file
1036  if ( file_exists( $msg_path ) ) {
1037  unlink( $msg_path );
1038  }
1039 
1040  // *** NEW -- FOR SWIFT Libraries
1041  // ** Future use -- speech/rate parameter can adjust the speed at which the audio says the words.. This may be helpful...For now, it is not used
1042  // $festival_cmd = "/opt/swift/bin/swift -n $tts_code -o $tmp_filename -p audio/sampling-rate=8000,speech/rate=170 \"$tts_phrase\"";
1043  $festival_cmd = "/opt/swift/bin/swift -n $tts_code -o $msg_path -p \"audio/sampling-rate=8000,speech/rate=${IVRSpeedRate}\" " . escapeshellarg($tts_phrase);
1044  $festival_ret = exec($festival_cmd);
1045  // Try and update the status for this record, if the file was created
1046  if ( file_exists( $msg_path ) ) {
1047  $sql = "UPDATE ars_audio_text
1048  SET status = 1,
1049  speedrate = " . intval($IVRSpeedRate) . "
1050  WHERE msg_code = '" . pg_escape_string($msg_code) . "'
1051  AND lang_id = '" . intval($langId) . "'
1052  AND cu = '$cuName' ";
1053  db_query($sql, $dbh);
1054 
1055  $msg .= "<li>The audio file for message $msg_code was successfully produced for the language $lang_desc.<br>";
1056 
1057  $createCnt++;
1058  }
1059 
1060  // Later may need to add error handling code if it failed to create the file
1061 
1062  }
1063  }
1064 
1065  print "<ul>Finished (created $createCnt file(s)). $msg</ul>";
1066 
1067  print <<<EOF
1068  <br>
1069  <input type='button' value='Back' onClick="location.href='$self?action=voices&cu=$cuLower'">
1070 EOF;
1071  break;
1072  }
1073 
1074 /**
1075  * evalInfoUrl
1076  *
1077  * @param string $dbValue - this is the saved value in the database, it should be
1078  * either a string, value HomeCU, or a json encoded value
1079  *
1080  * evalate the value being passed from the database
1081  * check to see if it starts with a '{', if it does, then I want to evaluate
1082  * as json value,
1083  * if it does NOT, then it is a simple string
1084  * @return string
1085  */
1086 function evalInfoUrl($dbValue) {
1087  $retVal = '';
1088 
1089  if (strlen($dbValue) > 0) {
1090  if (substr($dbValue, 0, 1) === '{') {
1091  $valAsArray = json_decode($dbValue);
1092  if (json_last_error() === JSON_ERROR_NONE) {
1093  foreach ($valAsArray as $strKey => $strValue) {
1094  $retVal .= $strKey . ", " . $strValue . ";\n";
1095  }
1096  } // ** else - return empty string
1097  } else {
1098  // ** SIMPLE STRING -- Return the value
1099  $retVal = $dbValue;
1100  }
1101  }
1102 
1103  return $retVal;
1104 }
1105 
1106 /**
1107  * setInfoText
1108  *
1109  * This function will take the string from the data screen and return the json value
1110  * based on the users entry of using legacy or enhanced version.
1111  *
1112  * @param type $txtValue - the string entered by the user
1113  * @return string
1114  */
1115 function setInfoText($txtValue) {
1116  $retVal = '';
1117  $infoAry = Array();
1118 
1119  // ** check to see if the value is set
1120  if ($txtValue !== '') {
1121  // If a comma is found in the string, then we will be encoding in json
1122  if (strstr($txtValue, ',') === false) {
1123  // * Legacy version
1124  // * *String value return what the user entered
1125  $retVal = $txtValue;
1126  } else {
1127  // * we will need to be doing some things.
1128  // First, split on all semi-colons
1129  foreach (explode(';', $txtValue) as $infoOption) {
1130  if (strlen($infoOption) > 0) {
1131  // ** Now explode on the ,
1132  $pieces = explode(',', $infoOption);
1133  if (count($pieces) > 1) {
1134  $infoAry[trim($pieces[0])] = trim($pieces[1]);
1135  }
1136  }
1137  }
1138 
1139  if (count($infoAry) > 0) {
1140  $retVal = json_encode($infoAry);
1141  }
1142  }
1143  }
1144 
1145  return $retVal;
1146 }
1147 
1148 ?>
Definition: User.php:7