| 1 |
<?php |
|---|
| 2 |
/* |
|---|
| 3 |
* Copyright 2008 by Moshe Brevda mbrevda=>gmail[com] |
|---|
| 4 |
* |
|---|
| 5 |
* based on work by Philippe Lindheimer |
|---|
| 6 |
* |
|---|
| 7 |
* This program is free software; you can redistribute it and/or |
|---|
| 8 |
* modify it under the terms of the GNU General Public License |
|---|
| 9 |
* as published by the Free Software Foundation; either version 2 |
|---|
| 10 |
* of the License, or (at your option) any later version. |
|---|
| 11 |
* |
|---|
| 12 |
* This program is distributed in the hope that it will be useful, |
|---|
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 |
* GNU General Public License for more details. |
|---|
| 16 |
*/ |
|---|
| 17 |
|
|---|
| 18 |
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'setup'; |
|---|
| 19 |
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
|---|
| 20 |
if (isset($_REQUEST['delete'])) $action = 'delete'; |
|---|
| 21 |
|
|---|
| 22 |
$cid_id = isset($_REQUEST['cid_id']) ? $_REQUEST['cid_id'] : false; |
|---|
| 23 |
$description = isset($_REQUEST['description']) ? $_REQUEST['description'] : ''; |
|---|
| 24 |
$cid_name = isset($_REQUEST['cid_name']) ? $_REQUEST['cid_name'] : ''; |
|---|
| 25 |
$cid_num = isset($_REQUEST['cid_num']) ? $_REQUEST['cid_num'] : ''; |
|---|
| 26 |
$dest = isset($_REQUEST['dest']) ? $_REQUEST['dest'] : ''; |
|---|
| 27 |
|
|---|
| 28 |
if (isset($_REQUEST['goto0']) && $_REQUEST['goto0']) { |
|---|
| 29 |
$dest = $_REQUEST[ $_REQUEST['goto0'].'0' ]; |
|---|
| 30 |
} |
|---|
| 31 |
|
|---|
| 32 |
switch ($action) { |
|---|
| 33 |
case 'add': |
|---|
| 34 |
setcid_add($description, $cid_name, $cid_num, $dest); |
|---|
| 35 |
needreload(); |
|---|
| 36 |
redirect_standard(); |
|---|
| 37 |
break; |
|---|
| 38 |
case 'edit': |
|---|
| 39 |
setcid_edit($cid_id, $description, $cid_name, $cid_num, $dest); |
|---|
| 40 |
needreload(); |
|---|
| 41 |
redirect_standard('extdisplay'); |
|---|
| 42 |
break; |
|---|
| 43 |
case 'delete': |
|---|
| 44 |
setcid_delete($cid_id); |
|---|
| 45 |
needreload(); |
|---|
| 46 |
redirect_standard(); |
|---|
| 47 |
break; |
|---|
| 48 |
} |
|---|
| 49 |
|
|---|
| 50 |
?> |
|---|
| 51 |
</div> |
|---|
| 52 |
|
|---|
| 53 |
<div class="rnav"><ul> |
|---|
| 54 |
<?php |
|---|
| 55 |
|
|---|
| 56 |
echo '<li><a href="config.php?display=setcid&type='.$type.'">'._('Add CallerID').'</a></li>'; |
|---|
| 57 |
|
|---|
| 58 |
foreach (setcid_list() as $row) { |
|---|
| 59 |
echo '<li><a href="config.php?display=setcid&type='.$type.'&extdisplay='.$row['cid_id'].'" class="rnavdata" rnavdata="'.$row['description'].','.$row['cid_name'].','.$row['cid_num'].','.$row['dest'].'">'.$row['description'].'</a></li>'; |
|---|
| 60 |
|
|---|
| 61 |
} |
|---|
| 62 |
|
|---|
| 63 |
?> |
|---|
| 64 |
</ul></div> |
|---|
| 65 |
|
|---|
| 66 |
<div class="content"> |
|---|
| 67 |
|
|---|
| 68 |
<?php |
|---|
| 69 |
|
|---|
| 70 |
if ($extdisplay) { |
|---|
| 71 |
// load |
|---|
| 72 |
$row = setcid_get($extdisplay); |
|---|
| 73 |
|
|---|
| 74 |
$description = $row['description']; |
|---|
| 75 |
$cid_name = $row['cid_name']; |
|---|
| 76 |
$cid_num = $row['cid_num']; |
|---|
| 77 |
$dest = $row['dest']; |
|---|
| 78 |
|
|---|
| 79 |
echo "<h2>"._("Edit: ")."$description ($cid_name)"."</h2>"; |
|---|
| 80 |
|
|---|
| 81 |
$usage_list = framework_display_destination_usage(setcid_getdest($extdisplay)); |
|---|
| 82 |
if (!empty($usage_list)) { |
|---|
| 83 |
?> |
|---|
| 84 |
<tr><td colspan="2"> |
|---|
| 85 |
<a href="#" class="info"><?php echo $usage_list['text']?>:<span><?php echo $usage_list['tooltip']?></span></a> |
|---|
| 86 |
</td></tr><br /><br /> |
|---|
| 87 |
<?php |
|---|
| 88 |
} |
|---|
| 89 |
|
|---|
| 90 |
} else { |
|---|
| 91 |
echo "<h2>"._("Add CallerID")."</h2>"; |
|---|
| 92 |
} |
|---|
| 93 |
|
|---|
| 94 |
$helptext = _("Set CallerID allows you to change the caller id of the call and then continue on to the desired destination. For example, you may want to change the caller id form \"John Doe\" to \"Sales: John Doe\". Please note, the text you enter is what the callerid is changed to. To append to the current callerid, use the proper asterisk variables, such as \"\${CALLERID(name)}\" for the currently set callerid name and \"\${CALLERID(num)}\" for the currently set callerid number."); |
|---|
| 95 |
echo $helptext; |
|---|
| 96 |
echo $row['dest']; |
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
?> |
|---|
| 101 |
|
|---|
| 102 |
<form name="editSetcid" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return checkSetcid(editSetcid);"> |
|---|
| 103 |
<input type="hidden" name="extdisplay" value="<?php echo $extdisplay; ?>"> |
|---|
| 104 |
<input type="hidden" name="cid_id" value="<?php echo $extdisplay; ?>"> |
|---|
| 105 |
<input type="hidden" name="action" value="<?php echo ($extdisplay ? 'edit' : 'add'); ?>"> |
|---|
| 106 |
<table> |
|---|
| 107 |
<tr><td colspan="2"><h5><?php echo ($extdisplay ? _("Edit CallerID Instance") : _("Add CallerID Instance")) ?><hr></h5></td></tr> |
|---|
| 108 |
<tr> |
|---|
| 109 |
<td><a href="#" class="info"><?php echo _("Description")?>:<span><?php echo _("The descriptive name of this CallerID instance. For example \"new name here\"");?></span></a></td> |
|---|
| 110 |
<td><input size="30" type="text" name="description" value="<?php echo $description; ?>" tabindex="<?php echo ++$tabindex;?>"></td> |
|---|
| 111 |
</tr> |
|---|
| 112 |
<tr> |
|---|
| 113 |
<td><a href="#" class="info"><?php echo _("CallerID Name")?>:<span><?php echo _("The CallerID Name that you want to change to. If you are appending to the current callerid, dont forget to include the appropriate asterisk variables. If you leave this box blank, the CallerID name will be blanked");?></span></a></td> |
|---|
| 114 |
<td><input size="30" type="text" name="cid_name" value="<?php echo $cid_name; ?>" tabindex="<?php echo ++$tabindex;?>"/></td> </tr> |
|---|
| 115 |
<td><a href="#" class="info"><?php echo _("CallerID Number")?>:<span><?php echo _("The CallerID Number that you want to change to. If you are appending to the current callerid, dont forget to include the appropriate asterisk variables. If you leave this box blank, the CallerID number will be blanked");?></span></a></td> |
|---|
| 116 |
<td><input size="30" type="text" name="cid_num" value="<?php echo $cid_num; ?>" tabindex="<?php echo ++$tabindex;?>"/></td> </tr> |
|---|
| 117 |
<tr><td colspan="2"><br><h5><?php echo _("Destination")?>:<hr></h5></td></tr> |
|---|
| 118 |
|
|---|
| 119 |
<?php |
|---|
| 120 |
//draw goto selects |
|---|
| 121 |
echo drawselects($dest,0); |
|---|
| 122 |
?> |
|---|
| 123 |
|
|---|
| 124 |
<tr> |
|---|
| 125 |
<td colspan="2"><br><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>" tabindex="<?php echo ++$tabindex;?>"> |
|---|
| 126 |
<?php if ($extdisplay) { echo ' <input name="delete" type="submit" value="'._("Delete").'">'; } ?> |
|---|
| 127 |
</td> |
|---|
| 128 |
|
|---|
| 129 |
</tr> |
|---|
| 130 |
</table> |
|---|
| 131 |
</form> |
|---|
| 132 |
|
|---|
| 133 |
<script language="javascript"> |
|---|
| 134 |
<!-- |
|---|
| 135 |
$(document).ready(function () { |
|---|
| 136 |
|
|---|
| 137 |
if (!$('[name=description]').attr("value")) { |
|---|
| 138 |
$('[name=cid_name]').attr({value: "${CALLERID(name)}"}); |
|---|
| 139 |
$('[name=cid_num]').attr({value: "${CALLERID(num)}"}); |
|---|
| 140 |
} |
|---|
| 141 |
|
|---|
| 142 |
// select rnav options - fake type = edit |
|---|
| 143 |
/* |
|---|
| 144 |
$("a.rnavdata").click(function(event){ |
|---|
| 145 |
event.preventDefault(); |
|---|
| 146 |
linktext = $(this).text(); |
|---|
| 147 |
rnavdata = $(this).attr("rnavdata"); |
|---|
| 148 |
arr = rnavdata.split(","); |
|---|
| 149 |
$('h2').text("<?php echo _("Edit") ?>: " + arr[0]); |
|---|
| 150 |
$('[name=description]').attr({value: arr[0]}); |
|---|
| 151 |
$('[name=cid_name]').attr({value: arr[1]}); |
|---|
| 152 |
$('[name=cid_num]').attr({value: arr[2]}); |
|---|
| 153 |
}); |
|---|
| 154 |
*/ |
|---|
| 155 |
}); |
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 |
function checkSetcid(theForm) { |
|---|
| 159 |
var msgInvalidDescription = "<?php echo _('Invalid description specified'); ?>"; |
|---|
| 160 |
|
|---|
| 161 |
// set up the Destination stuff |
|---|
| 162 |
setDestinations(theForm, '_post_dest'); |
|---|
| 163 |
|
|---|
| 164 |
// form validation |
|---|
| 165 |
defaultEmptyOK = false; |
|---|
| 166 |
if (isEmpty(theForm.description.value)) |
|---|
| 167 |
return warnInvalid(theForm.description, msgInvalidDescription); |
|---|
| 168 |
|
|---|
| 169 |
if (!validateDestinations(theForm, 1, true)) |
|---|
| 170 |
return false; |
|---|
| 171 |
|
|---|
| 172 |
return true; |
|---|
| 173 |
} |
|---|
| 174 |
//--> |
|---|
| 175 |
</script> |
|---|