| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
$action = isset($_REQUEST['action'])?$_REQUEST['action']:''; |
|---|
| 21 |
$id = isset($_REQUEST['id'])?$_REQUEST['id']:''; |
|---|
| 22 |
$dircontext = isset($_SESSION["AMP_user"]->_deptname)?$_SESSION["AMP_user"]->_deptname:''; |
|---|
| 23 |
$nbroptions = isset($_REQUEST['nbroptions'])?$_REQUEST['nbroptions']:'3'; |
|---|
| 24 |
|
|---|
| 25 |
if (empty($dircontext)) |
|---|
| 26 |
$dircontext = 'default'; |
|---|
| 27 |
|
|---|
| 28 |
ivr_init(); |
|---|
| 29 |
|
|---|
| 30 |
switch ($action) { |
|---|
| 31 |
case "add": |
|---|
| 32 |
$id = ivr_get_ivr_id('Unnamed'); |
|---|
| 33 |
|
|---|
| 34 |
$def['timeout'] = 5; |
|---|
| 35 |
$def['ena_directdial'] = 'CHECKED'; |
|---|
| 36 |
$def['ena_directory'] = 'CHECKED'; |
|---|
| 37 |
ivr_sidebar($id); |
|---|
| 38 |
ivr_show_edit($id, 3, $def); |
|---|
| 39 |
break; |
|---|
| 40 |
case "edit": |
|---|
| 41 |
ivr_sidebar($id); |
|---|
| 42 |
ivr_show_edit($id, $nbroptions, $_POST); |
|---|
| 43 |
break; |
|---|
| 44 |
case "edited": |
|---|
| 45 |
if (isset($_REQUEST['delete'])) { |
|---|
| 46 |
sql("DELETE from ivr where ivr_id='$id'"); |
|---|
| 47 |
sql("DELETE FROM ivr_dests where ivr_id='$id'"); |
|---|
| 48 |
needreload(); |
|---|
| 49 |
} else { |
|---|
| 50 |
ivr_do_edit($id, $_POST); |
|---|
| 51 |
ivr_sidebar($id); |
|---|
| 52 |
if (isset($_REQUEST['increase'])) |
|---|
| 53 |
$nbroptions++; |
|---|
| 54 |
if (isset($_REQUEST['decrease'])) { |
|---|
| 55 |
$nbroptions--; |
|---|
| 56 |
} |
|---|
| 57 |
if ($nbroptions < 1) |
|---|
| 58 |
$nbroptions = 1; |
|---|
| 59 |
|
|---|
| 60 |
$url = 'config.php?type=setup&display=ivr&action=edit&id='.$id.'&nbroptions='.$nbroptions; |
|---|
| 61 |
redirect($url); |
|---|
| 62 |
break; |
|---|
| 63 |
} |
|---|
| 64 |
default: |
|---|
| 65 |
ivr_sidebar($id); |
|---|
| 66 |
?> |
|---|
| 67 |
<div class="content"> |
|---|
| 68 |
<h2><?php echo _("Digital Receptionist"); ?></h2> |
|---|
| 69 |
<h3><?php |
|---|
| 70 |
echo _("Instructions")."</h3>"; |
|---|
| 71 |
echo _("You use the Digital Receptionist to make IVR's, Interactive Voice Responce systems.")."<br />\n"; |
|---|
| 72 |
echo _("When creating a menu option, apart from the standard options of 0-9,* and #, you can also use 'i' and 't' destinations.")."\n"; |
|---|
| 73 |
echo _("'i' is used when the caller pushes an invalid button, and 't' is used when there is no response.")."\n"; |
|---|
| 74 |
echo _("If those options aren't supplied, the default 't' is to replay the menu three times and then hang up,")."\n"; |
|---|
| 75 |
echo _("and the default 'i' is to say 'Invalid option, please try again' and replay the menu.")."\n"; |
|---|
| 76 |
echo _("After three invalid attempts, the line is hung up.")."\n"; ?> |
|---|
| 77 |
</div> |
|---|
| 78 |
|
|---|
| 79 |
<?php |
|---|
| 80 |
} |
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
function ivr_sidebar($id) { |
|---|
| 84 |
?> |
|---|
| 85 |
<div class="rnav"><ul> |
|---|
| 86 |
<li><a id="<?php echo empty($id)?'current':'nul' ?>" href="config.php?display=ivr&action=add"><?php echo _("Add IVR")?></a></li> |
|---|
| 87 |
<?php |
|---|
| 88 |
|
|---|
| 89 |
$tresults = ivr_list(); |
|---|
| 90 |
if (isset($tresults)){ |
|---|
| 91 |
foreach ($tresults as $tresult) { |
|---|
| 92 |
echo "<li><a id=\"".($id==$tresult['ivr_id'] ? 'current':'nul')."\" href=\"config.php?display=ivr"; |
|---|
| 93 |
echo "&action=edit&id={$tresult['ivr_id']}\">{$tresult['displayname']}</a></li>\n"; |
|---|
| 94 |
} |
|---|
| 95 |
} |
|---|
| 96 |
echo "</ul></div>\n"; |
|---|
| 97 |
} |
|---|
| 98 |
|
|---|
| 99 |
function ivr_show_edit($id, $nbroptions, $post) { |
|---|
| 100 |
global $db; |
|---|
| 101 |
|
|---|
| 102 |
$ivr_details = ivr_get_details($id); |
|---|
| 103 |
$ivr_dests = ivr_get_dests($id); |
|---|
| 104 |
?> |
|---|
| 105 |
<div class="content"> |
|---|
| 106 |
<h2><?php echo _("Digital Receptionist"); ?></h2> |
|---|
| 107 |
<h3><?php echo _("Edit Menu")." ".$ivr_details['displayname']; ?></h3> |
|---|
| 108 |
<?php |
|---|
| 109 |
?> |
|---|
| 110 |
<form name="prompt" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return prompt_onsubmit();"> |
|---|
| 111 |
<input type="hidden" name="action" value="edited" /> |
|---|
| 112 |
<input type="hidden" name="display" value="ivr" /> |
|---|
| 113 |
<input type="hidden" name="id" value="<?php echo $id ?>" /> |
|---|
| 114 |
<input name="Submit" type="submit" style="display:none;" value="save" /> |
|---|
| 115 |
<input name="delete" type="submit" value="<?php echo _("Delete")." "._("Digital Receptionist")." {$ivr_details['displayname']}"; ?>" /> |
|---|
| 116 |
<?php |
|---|
| 117 |
if ($id) { |
|---|
| 118 |
$usage_list = framework_display_destination_usage(ivr_getdest($id)); |
|---|
| 119 |
if (!empty($usage_list)) { |
|---|
| 120 |
?> |
|---|
| 121 |
<br /><a href="#" class="info"><?php echo $usage_list['text']?>:<span><?php echo $usage_list['tooltip']?></span></a> |
|---|
| 122 |
<?php |
|---|
| 123 |
} |
|---|
| 124 |
} |
|---|
| 125 |
?> |
|---|
| 126 |
<table> |
|---|
| 127 |
<tr><td colspan=2><hr /></td></tr> |
|---|
| 128 |
<tr> |
|---|
| 129 |
<td><a href="#" class="info"><?php echo _("Change Name"); ?><span><?php echo _("This changes the short name, visible on the right, of this IVR");?></span></a></td> |
|---|
| 130 |
<td><input type="text" name="displayname" value="<?php echo $ivr_details['displayname'] ?>"></td> |
|---|
| 131 |
</tr> |
|---|
| 132 |
<tr> |
|---|
| 133 |
<td><a href="#" class="info"><?php echo _("Timeout");?><span><?php echo _("The amount of time (in seconds) before the 't' option, if specified, is used");?></span></a></td> |
|---|
| 134 |
<td><input type="text" name="timeout" value="<?php echo $ivr_details['timeout'] ?>"></td> |
|---|
| 135 |
</tr> |
|---|
| 136 |
<?php if ( function_exists('voicemail_getVoicemail') ) { ?> |
|---|
| 137 |
<tr> |
|---|
| 138 |
<td><a href="#" class="info"><?php echo _("Enable Directory");?><span><?php echo _("Let callers into the IVR dial '#' to access the directory");?></span></a></td> |
|---|
| 139 |
<td><input type="checkbox" name="ena_directory" <?php echo $ivr_details['enable_directory'] ?>></td> |
|---|
| 140 |
</tr> |
|---|
| 141 |
<tr> |
|---|
| 142 |
<td><a href="#" class="info"><?php echo _("Directory Context");?><span><?php echo _("When # is selected, this is the voicemail directory context that is used");?></span></a></td> |
|---|
| 143 |
<td> |
|---|
| 144 |
<select name="dircontext"/> |
|---|
| 145 |
<?php |
|---|
| 146 |
$tresults = voicemail_getVoicemail(); |
|---|
| 147 |
$vmcontexts = array_keys($tresults); |
|---|
| 148 |
foreach ($vmcontexts as $vmc) { |
|---|
| 149 |
if ($vmc != 'general' ) |
|---|
| 150 |
echo '<option value="'.$vmc.'"'.($vmc == $ivr_details['dircontext'] ? ' SELECTED' : '').'>'.$vmc."</option>\n"; |
|---|
| 151 |
} |
|---|
| 152 |
?> |
|---|
| 153 |
</select> |
|---|
| 154 |
</td> |
|---|
| 155 |
</tr> |
|---|
| 156 |
<?php } ?> |
|---|
| 157 |
<tr> |
|---|
| 158 |
<td><a href="#" class="info"><?php echo _("Enable Direct Dial");?><span><?php echo _("Let callers into the IVR dial an extension directly");?></span></a></td> |
|---|
| 159 |
<td><input type="checkbox" name="ena_directdial" <?php echo $ivr_details['enable_directdial'] ?>></td> |
|---|
| 160 |
</tr> |
|---|
| 161 |
<?php |
|---|
| 162 |
$annmsg = isset($ivr_details['announcement'])?$ivr_details['announcement']:''; |
|---|
| 163 |
if(function_exists('recordings_list')) { ?> |
|---|
| 164 |
<tr> |
|---|
| 165 |
<td><a href="#" class="info"><?php echo _("Announcement")?><span><?php echo _("Message to be played to the caller. To add additional recordings please use the \"System Recordings\" MENU to the left")?></span></a></td> |
|---|
| 166 |
<td> |
|---|
| 167 |
<select name="annmsg"/> |
|---|
| 168 |
<?php |
|---|
| 169 |
$tresults = recordings_list(); |
|---|
| 170 |
echo '<option value="">'._("None")."</option>"; |
|---|
| 171 |
if (isset($tresults[0])) { |
|---|
| 172 |
foreach ($tresults as $tresult) { |
|---|
| 173 |
echo '<option value="'.$tresult[2].'"'.($tresult[2] == $annmsg ? ' SELECTED' : '').'>'.$tresult[1]."</option>\n"; |
|---|
| 174 |
} |
|---|
| 175 |
} |
|---|
| 176 |
?> |
|---|
| 177 |
</select> |
|---|
| 178 |
</td> |
|---|
| 179 |
</tr> |
|---|
| 180 |
|
|---|
| 181 |
<?php |
|---|
| 182 |
} else { |
|---|
| 183 |
?> |
|---|
| 184 |
<tr> |
|---|
| 185 |
<td><a href="#" class="info"><?php echo _("Announcement")?><span><?php echo _("Message to be played to the caller.<br><br>You must install and enable the \"Systems Recordings\" Module to edit this option")?></span></a></td> |
|---|
| 186 |
<td> |
|---|
| 187 |
<?php |
|---|
| 188 |
$default = (isset($annmsg) ? $annmsg : ''); |
|---|
| 189 |
?> |
|---|
| 190 |
<input type="hidden" name="annmsg" value="<?php echo $default; ?>"><?php echo ($default != '' ? $default : 'None'); ?> |
|---|
| 191 |
</td> |
|---|
| 192 |
</tr> |
|---|
| 193 |
<?php |
|---|
| 194 |
} |
|---|
| 195 |
?> |
|---|
| 196 |
|
|---|
| 197 |
|
|---|
| 198 |
<tr><td colspan=2><hr /></td></tr> |
|---|
| 199 |
<tr><td colspan=2> |
|---|
| 200 |
<input name="increase" type="submit" value="<?php echo _("Increase Options")?>"> |
|---|
| 201 |
|
|---|
| 202 |
<input name="Submit" type="submit" value="<?php echo _("Save")?>"> |
|---|
| 203 |
|
|---|
| 204 |
<?php if ($nbroptions > 1) { ?> |
|---|
| 205 |
<input name="decrease" type="submit" value="<?php echo _("Decrease Options")?>"> |
|---|
| 206 |
<?php } ?> |
|---|
| 207 |
</td> |
|---|
| 208 |
</tr> |
|---|
| 209 |
<tr><td colspan=2><hr /></td></tr> |
|---|
| 210 |
<?php |
|---|
| 211 |
|
|---|
| 212 |
$dests = ivr_get_dests($id); |
|---|
| 213 |
$count = 0; |
|---|
| 214 |
if (!empty($dests)) { |
|---|
| 215 |
foreach ($dests as $dest) { |
|---|
| 216 |
drawdestinations($count, $dest['selection'], $dest['dest'], $dest['ivr_ret']); |
|---|
| 217 |
$count++; |
|---|
| 218 |
} |
|---|
| 219 |
} |
|---|
| 220 |
while ($count < $nbroptions) { |
|---|
| 221 |
drawdestinations($count, null, null, 0); |
|---|
| 222 |
$count++; |
|---|
| 223 |
} |
|---|
| 224 |
?> |
|---|
| 225 |
|
|---|
| 226 |
</table> |
|---|
| 227 |
<?php |
|---|
| 228 |
if ($nbroptions < $count) { |
|---|
| 229 |
echo "<input type='hidden' name='nbroptions' value=$count />\n"; |
|---|
| 230 |
} else { |
|---|
| 231 |
echo "<input type='hidden' name='nbroptions' value=$nbroptions />\n"; |
|---|
| 232 |
} |
|---|
| 233 |
?> |
|---|
| 234 |
<input name="increase" type="submit" value="<?php echo _("Increase Options")?>"> |
|---|
| 235 |
|
|---|
| 236 |
<input name="Submit" type="submit" value="<?php echo _("Save")?>"> |
|---|
| 237 |
|
|---|
| 238 |
<?php if ($nbroptions > 1) { ?> |
|---|
| 239 |
<input name="decrease" type="submit" value="<?php echo _("Decrease Options")?>"> |
|---|
| 240 |
<?php } ?> |
|---|
| 241 |
|
|---|
| 242 |
<script language="javascript"> |
|---|
| 243 |
<!-- |
|---|
| 244 |
|
|---|
| 245 |
var theForm = document.prompt; |
|---|
| 246 |
|
|---|
| 247 |
function prompt_onsubmit() { |
|---|
| 248 |
var msgInvalidOption = "<?php echo _("Invalid option"); ?>"; |
|---|
| 249 |
|
|---|
| 250 |
defaultEmptyOK = true; |
|---|
| 251 |
|
|---|
| 252 |
// go thru the form looking for options |
|---|
| 253 |
// where the option isn't blank (as that will be removed) do the validation |
|---|
| 254 |
var allelems = theForm.elements; |
|---|
| 255 |
if (allelems != null) |
|---|
| 256 |
{ |
|---|
| 257 |
var i, elem; |
|---|
| 258 |
for (i = 0; elem = allelems[i]; i++) |
|---|
| 259 |
{ |
|---|
| 260 |
if (elem.type == 'text' && elem.name.indexOf('option') == 0) |
|---|
| 261 |
{ |
|---|
| 262 |
if (elem.value != '') { |
|---|
| 263 |
if (!isIVROption(elem.value)) |
|---|
| 264 |
return warnInvalid(elem, msgInvalidOption); |
|---|
| 265 |
|
|---|
| 266 |
var gotoNum = elem.name.charAt(6); |
|---|
| 267 |
var isok = validateSingleDestination(theForm,gotoNum,true); |
|---|
| 268 |
if (!isok) |
|---|
| 269 |
return false; |
|---|
| 270 |
} |
|---|
| 271 |
} |
|---|
| 272 |
} |
|---|
| 273 |
} |
|---|
| 274 |
|
|---|
| 275 |
return true; |
|---|
| 276 |
} |
|---|
| 277 |
|
|---|
| 278 |
//--> |
|---|
| 279 |
</script> |
|---|
| 280 |
</form> |
|---|
| 281 |
</div> |
|---|
| 282 |
|
|---|
| 283 |
|
|---|
| 284 |
<?php |
|---|
| 285 |
|
|---|
| 286 |
echo "</div>\n"; |
|---|
| 287 |
} |
|---|
| 288 |
|
|---|
| 289 |
function drawdestinations($count, $sel, $dest, $ivr_ret) { ?> |
|---|
| 290 |
<tr> <td style="text-align:right;"> |
|---|
| 291 |
|
|---|
| 292 |
<small><a href="#" class="info"><?php echo _("Return to IVR")?><span><?php echo _("Check this box to have this option return to a parent IVR if it was called from a parent IVR. If not, it will go to the chosen destination.<br><br>The return path will be to any IVR that was in the call path prior to this IVR which could lead to strange results if there was an IVR called in the call path but not immediately before this")?></span></a></small> |
|---|
| 293 |
<input type="checkbox" name="ivr_ret<?php echo $count ?>" value="ivr_ret" <?php echo $ivr_ret?'CHECKED':''; ?>><br><br /> |
|---|
| 294 |
<input size="2" type="text" name="option<?php echo $count ?>" value="<?php echo $sel ?>"><br /> |
|---|
| 295 |
<?php if (strlen($sel)) { ?> |
|---|
| 296 |
<i style='font-size: x-small'>Leave blank to remove</i> |
|---|
| 297 |
<?php } ?> |
|---|
| 298 |
</td> |
|---|
| 299 |
<td> <table> <?php echo drawselects($dest,$count); ?> </table> </td> |
|---|
| 300 |
</tr> |
|---|
| 301 |
<tr><td colspan=2><hr /></td></tr> |
|---|
| 302 |
<?php |
|---|
| 303 |
} |
|---|
| 304 |
|
|---|
| 305 |
|
|---|
| 306 |
|
|---|
| 307 |
|
|---|
| 308 |
|
|---|
| 309 |
function localrunModuleSQL($moddir,$type){ |
|---|
| 310 |
global $db; |
|---|
| 311 |
$data=''; |
|---|
| 312 |
if (is_file("modules/{$moddir}/{$type}.sql")) { |
|---|
| 313 |
|
|---|
| 314 |
$fd = fopen("modules/{$moddir}/{$type}.sql","r"); |
|---|
| 315 |
while (!feof($fd)) { |
|---|
| 316 |
$data .= fread($fd, 1024); |
|---|
| 317 |
} |
|---|
| 318 |
fclose($fd); |
|---|
| 319 |
|
|---|
| 320 |
preg_match_all("/((SELECT|INSERT|UPDATE|DELETE|CREATE|DROP).*);\s*\n/Us", $data, $matches); |
|---|
| 321 |
|
|---|
| 322 |
foreach ($matches[1] as $sql) { |
|---|
| 323 |
$result = $db->query($sql); |
|---|
| 324 |
if(DB::IsError($result)) { |
|---|
| 325 |
return false; |
|---|
| 326 |
} |
|---|
| 327 |
} |
|---|
| 328 |
return true; |
|---|
| 329 |
} |
|---|
| 330 |
return true; |
|---|
| 331 |
} |
|---|
| 332 |
|
|---|
| 333 |
?> |
|---|
| 334 |
|
|---|