| 1 |
<?php /* $Id */ |
|---|
| 2 |
//Copyright (C) Rob Thomas <xrobau@gmail.com> - |
|---|
| 3 |
// Why Pay More 4 Less Pty Ltd (Australia) 2008 |
|---|
| 4 |
// |
|---|
| 5 |
// THIS IS NOT OPEN SOURCE SOFTWARE. |
|---|
| 6 |
// |
|---|
| 7 |
// Whilst the source is available for you to look at, you |
|---|
| 8 |
// do NOT have a licence to change or re-distribute this |
|---|
| 9 |
// software. |
|---|
| 10 |
|
|---|
| 11 |
// This specific document, all other associated files, any |
|---|
| 12 |
// databases, and the database designs that accompany it |
|---|
| 13 |
// are Copyright 2008, and are licenced for the SOLE USE of |
|---|
| 14 |
// Astrogen LLC, otherwise known as FreePBX, to be |
|---|
| 15 |
// distributed SOLEY with the FreePBX software package. |
|---|
| 16 |
|
|---|
| 17 |
// If you wish to licence the redistribution of these |
|---|
| 18 |
// copyrighted documents, database, and database designs, |
|---|
| 19 |
// the ONLY company that is able to do so is: |
|---|
| 20 |
|
|---|
| 21 |
// Why Pay More 4 Less Pty Ltd, |
|---|
| 22 |
// 1 Grayson st, |
|---|
| 23 |
// Gladstone, QLD, 4680, AUSTRALIA |
|---|
| 24 |
// |
|---|
| 25 |
// PHYSICAL MAIL only (Electronic mail is not acceptable) |
|---|
| 26 |
|
|---|
| 27 |
// If you do not have written permission from this company to |
|---|
| 28 |
// redistribute this copyrighted package and do so, you are |
|---|
| 29 |
// violating international copyright laws, and will be |
|---|
| 30 |
// prosecuted to the FULL EXTENT of the law. |
|---|
| 31 |
|
|---|
| 32 |
// You may be asking why this licence is so strict? At the time |
|---|
| 33 |
// this was written, the Author believed that Fonality was |
|---|
| 34 |
// involved in numerous GPL Violations with their Trixbox |
|---|
| 35 |
// product. If and when that is ever resolved, this document |
|---|
| 36 |
// will be re-licenced under v2 of the GPL. |
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
$tabindex = 0; |
|---|
| 40 |
// What are we doing.. |
|---|
| 41 |
isset($_REQUEST['action'])?$action = $_REQUEST['action']:$action=''; |
|---|
| 42 |
//the item we are currently displaying |
|---|
| 43 |
isset($_REQUEST['itemid'])?$itemid=$_REQUEST['itemid']:$itemid=''; |
|---|
| 44 |
|
|---|
| 45 |
// Where we are |
|---|
| 46 |
$dispnum = "cidroute"; //used for switch on config.php |
|---|
| 47 |
|
|---|
| 48 |
$cidmaps = cidroute_list(); |
|---|
| 49 |
|
|---|
| 50 |
//if submitting form, update database |
|---|
| 51 |
if(isset($_REQUEST['action'])) { |
|---|
| 52 |
switch ($action) { |
|---|
| 53 |
case "add": |
|---|
| 54 |
cidroute_add($_REQUEST); |
|---|
| 55 |
redirect_standard(); |
|---|
| 56 |
break; |
|---|
| 57 |
case "alter": |
|---|
| 58 |
cidroute_alter($_REQUEST); |
|---|
| 59 |
showEdit($itemid,$cidmaps); |
|---|
| 60 |
break; |
|---|
| 61 |
case "delmaps": |
|---|
| 62 |
cidroute_delmaps($_REQUEST); |
|---|
| 63 |
showEdit($itemid,$cidmaps); |
|---|
| 64 |
break; |
|---|
| 65 |
case "edit": |
|---|
| 66 |
showEdit($itemid,$cidmaps); |
|---|
| 67 |
break; |
|---|
| 68 |
case "override": |
|---|
| 69 |
showOverride(); |
|---|
| 70 |
break; |
|---|
| 71 |
case "delete": |
|---|
| 72 |
cidroute_del($_REQUEST); |
|---|
| 73 |
$oldname = $cidmaps[$_REQUEST['itemid']]['name']; |
|---|
| 74 |
$cidmaps = cidroute_list(); |
|---|
| 75 |
showHeader(); |
|---|
| 76 |
echo "<h3>Route ".urlencode($_REQUEST['itemid'])." ($oldname) deleted.</h3>"; |
|---|
| 77 |
showNew(); |
|---|
| 78 |
case "*": |
|---|
| 79 |
showHeader(); |
|---|
| 80 |
showNew(); |
|---|
| 81 |
break; |
|---|
| 82 |
} |
|---|
| 83 |
} else { |
|---|
| 84 |
showHeader(); |
|---|
| 85 |
showNew(); |
|---|
| 86 |
} |
|---|
| 87 |
|
|---|
| 88 |
//get list of callerid lookup sources |
|---|
| 89 |
|
|---|
| 90 |
function showHeader() { |
|---|
| 91 |
global $itemid, $dispnum, $cidmaps; |
|---|
| 92 |
?> |
|---|
| 93 |
|
|---|
| 94 |
</div> <!-- end content div so we can display rnav properly--> |
|---|
| 95 |
|
|---|
| 96 |
<!-- right side menu --> |
|---|
| 97 |
<div class="rnav"><ul> |
|---|
| 98 |
<li><a id="<?php echo ($itemid=='' ? 'current':'') ?>" href="config.php?display=<?php echo urlencode($dispnum)?>"><?php echo _("Add Route Map")?></a></li> |
|---|
| 99 |
<?php |
|---|
| 100 |
if (isset($cidmaps)) { |
|---|
| 101 |
foreach ($cidmaps as $cidsource) { |
|---|
| 102 |
if ($cidsource['destid'] != 0) { |
|---|
| 103 |
echo "<li><a id=\"".($itemid==$cidsource['destid'] ? 'current':'')."\" href=\"config.php?display="; |
|---|
| 104 |
echo urlencode($dispnum)."&action=edit&itemid=".$cidsource['destid']."\">{$cidsource['name']}</a></li>"; |
|---|
| 105 |
} |
|---|
| 106 |
} |
|---|
| 107 |
} |
|---|
| 108 |
?> |
|---|
| 109 |
<li><a href="config.php?display=<?php echo urlencode($dispnum); ?>&action=override">Manage Overrides</a></li> |
|---|
| 110 |
</ul></div> |
|---|
| 111 |
|
|---|
| 112 |
<div class="content"> |
|---|
| 113 |
<?php |
|---|
| 114 |
} |
|---|
| 115 |
|
|---|
| 116 |
function showNew() { |
|---|
| 117 |
global $dispnum; |
|---|
| 118 |
?> |
|---|
| 119 |
<h2 id='title'><?php echo _("Caller Location Based Routing") ?></h2></td> |
|---|
| 120 |
<tr><td colspan=2><span id="instructions"> |
|---|
| 121 |
<?php |
|---|
| 122 |
echo "<p><h3>"._("Overview"); echo "</h3></p> "; |
|---|
| 123 |
echo "<p>"._("Caller Location Based Routing"); echo " "; |
|---|
| 124 |
echo _("lets you set the desination of the call based on the CallerID of the Caller."); echo " "; |
|---|
| 125 |
echo _(" This is used to provide caller-location-dependent services, such as may be used in a franchise of multiple stores that want to provide the one public phone number, and route calls dependant on the callers location."); echo "</p>"; |
|---|
| 126 |
echo "<p><em>"._("Note that this module, unlike most others, requires the database to be available AT ALL TIMES."); echo "</em></p>"; |
|---|
| 127 |
|
|---|
| 128 |
// Yes, this isn't translated. There's no use translating it yet, because Australia only speaks English. |
|---|
| 129 |
// I've deliberately NOT left this translateable because I need Phone/Exchange details for YOUR COUNTRY. |
|---|
| 130 |
// You, the person who is translating this. Go dig up something that looks like this: |
|---|
| 131 |
|
|---|
| 132 |
// State (if you have states) |
|---|
| 133 |
|
|---|
| 134 |
// Regions (eg, 'London', 'South East', 'East', 'East Midlands') |
|---|
| 135 |
// -- Taken from http://en.wikipedia.org/wiki/Regions_of_England |
|---|
| 136 |
|
|---|
| 137 |
// Local Areas ('City of London', 'City of Westminister', 'Kensington and Chelsea') etc. |
|---|
| 138 |
// -- Taken from http://en.wikipedia.org/wiki/Greater_London |
|---|
| 139 |
|
|---|
| 140 |
// Feel free to fudge those around - you have three 'Sorting' groups. Maybe, something |
|---|
| 141 |
// like Region->County->Exchange - however you want to do it, you can change the names in |
|---|
| 142 |
// the translation. Note that you don't NEED to use all 3. You can use just one, if that's |
|---|
| 143 |
// the best you can do. (eg, Sweden, apparently, has huge areas with portable numbers) |
|---|
| 144 |
|
|---|
| 145 |
// When you have the exchanges, I need a number RANGE for them. This maybe something like |
|---|
| 146 |
// 6120000 - 6199999 and 61200000 - 61999999 for an exchange in areacode 61 with 5 |
|---|
| 147 |
// _and_ 6 digit numbers, where the first digit of the phone number can't start with a 1. |
|---|
| 148 |
|
|---|
| 149 |
// Package that all up, and send it to xrobau@gmail.com and keep harassing me about it until |
|---|
| 150 |
// it appears in a module update. |
|---|
| 151 |
|
|---|
| 152 |
echo "<p>This module currently only supports AUSTRALIA. Other countries will follow as soon as the exchange mappings are provided</p>"; |
|---|
| 153 |
echo "<p>"._("You enable or disable the Caller Location Based Routing on the Inbound Routes page.")." "; |
|---|
| 154 |
echo _("When that is enabled, calls are first checked against the list of CallerID Ranges here.")." "; |
|---|
| 155 |
echo _("If the Caller ID matches any one of the ranges, the destination of the call is changed to what is specified on each group.")." "; |
|---|
| 156 |
echo _("If the Caller ID of the call does not match any of the selected ones here, the call proceeds to the desination selected in Inbound Routes."); ?> |
|---|
| 157 |
</p> |
|---|
| 158 |
|
|---|
| 159 |
<form name="cidroutemap" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post"> |
|---|
| 160 |
<input type="hidden" name="action" value="add"> |
|---|
| 161 |
<input type="hidden" name="display" value="<?php echo $dispnum; ?>"> |
|---|
| 162 |
<table> |
|---|
| 163 |
<tr><td style="width:30%"></td><td style="width:70%"></td> |
|---|
| 164 |
<tr><td colspan="2"><h5><?php echo ($extdisplay ? _("Edit Route Destination") : _("Add Route Destination")) ?><hr></h5></td></tr> |
|---|
| 165 |
<tr> |
|---|
| 166 |
<td><a href="#" class="info"><?php echo _("Description")?>:<span><?php echo _("The name of this route map")?></span></a></td> |
|---|
| 167 |
<td><input size="15" type="text" name="name" value="<?php echo $description; ?>" tabindex="<?php echo ++$tabindex;?>"></td> |
|---|
| 168 |
</tr> |
|---|
| 169 |
|
|---|
| 170 |
<tr><td colspan="2"><br><h5><?php echo _("Destination")?>:<hr></h5></td></tr> |
|---|
| 171 |
</table> |
|---|
| 172 |
|
|---|
| 173 |
<?php |
|---|
| 174 |
//draw goto selects |
|---|
| 175 |
echo drawselects(0,0); |
|---|
| 176 |
?> |
|---|
| 177 |
|
|---|
| 178 |
<input name="Submit" type="submit" value="<?php echo _("Go"); ?>" tabindex="<?php echo ++$tabindex;?>"> |
|---|
| 179 |
</form> |
|---|
| 180 |
|
|---|
| 181 |
<?php |
|---|
| 182 |
} |
|---|
| 183 |
|
|---|
| 184 |
|
|---|
| 185 |
function showEdit($itemid,$cidmaps) |
|---|
| 186 |
{ |
|---|
| 187 |
|
|---|
| 188 |
global $db; |
|---|
| 189 |
showHeader(); |
|---|
| 190 |
$delButton = "<form name=delete action=\"{$_SERVER['PHP_SELF']}\" method=POST> |
|---|
| 191 |
<input type=\"hidden\" name=\"display\" value=\"cidroute\"> |
|---|
| 192 |
<input type=\"hidden\" name=\"itemid\" value=\"{$itemid}\"> |
|---|
| 193 |
<input type=\"hidden\" name=\"action\" value=\"delete\"> |
|---|
| 194 |
<input type=submit value=\""._("Delete this Route")."\"> |
|---|
| 195 |
</form>"; |
|---|
| 196 |
?> |
|---|
| 197 |
<style> |
|---|
| 198 |
#loading |
|---|
| 199 |
{ |
|---|
| 200 |
position:absolute; |
|---|
| 201 |
top:0px; |
|---|
| 202 |
right:0px; |
|---|
| 203 |
background:#ff0000; |
|---|
| 204 |
color:#fff; |
|---|
| 205 |
font-size:14px; |
|---|
| 206 |
font-familly:Arial; |
|---|
| 207 |
padding:2px; |
|---|
| 208 |
display:none; |
|---|
| 209 |
} |
|---|
| 210 |
</style> |
|---|
| 211 |
|
|---|
| 212 |
<div id="loading">Loading ...</div> |
|---|
| 213 |
<table> |
|---|
| 214 |
<tr><td style="width:10%"></td><td style="width:90%"></td> |
|---|
| 215 |
<tr><td colspan=2><h2 id="title"><?php echo _("Caller Location Based Routing"); ?></h2></td></tr> |
|---|
| 216 |
|
|---|
| 217 |
<tr><td colspan=2> |
|---|
| 218 |
<?php |
|---|
| 219 |
print "<h3 id='title'>"._("Route")." ". $cidmaps[$itemid]['name'].":</h2></td>"; |
|---|
| 220 |
|
|---|
| 221 |
?> |
|---|
| 222 |
<tr><td colspan=2><span id="instructions"><?php |
|---|
| 223 |
echo _("Select the destination for the CID Groups below, and update the CallerID Groups to suit."); |
|---|
| 224 |
echo _("Note that changes to the routing happen as soon as you submit the form."); |
|---|
| 225 |
echo _(" There is no need for a standard reload."); |
|---|
| 226 |
?></span></td></tr> |
|---|
| 227 |
<tr><td><?php echo $delButton; ?></td></tr> |
|---|
| 228 |
<tr><td colspan=2><h5><?php echo _("Destination")?>:<hr></h5> |
|---|
| 229 |
<input type="hidden" name="itemid" value="<? echo $itemid ?>"> |
|---|
| 230 |
<input type="hidden" name="action" value="alter"> |
|---|
| 231 |
<input type="hidden" name="display" value="cidroute"> |
|---|
| 232 |
|
|---|
| 233 |
<form method="post" action="<? echo $_SERVER['PHP_SELF'] ?>" class="asholder"> |
|---|
| 234 |
<?php |
|---|
| 235 |
//draw goto selects |
|---|
| 236 |
$dest=sql("select dest from cidroute_dests where destid='".$db->escapeSimple($itemid)."'", "getRow"); |
|---|
| 237 |
if (isset($dest[0])) { |
|---|
| 238 |
echo drawselects($dest[0],0); |
|---|
| 239 |
} else { |
|---|
| 240 |
echo drawselects(0,0); |
|---|
| 241 |
} |
|---|
| 242 |
|
|---|
| 243 |
?> |
|---|
| 244 |
</td></tr> |
|---|
| 245 |
<tr><td><input type="submit" name="updatedest" value="Change Destination" /></td></tr> |
|---|
| 246 |
<tr><td colspan=2><hr> |
|---|
| 247 |
<script type="text/javascript" src="modules/cidroute/js/comboselect.js" charset="utf-8"></script> |
|---|
| 248 |
<script type="text/javascript" src="modules/cidroute/js/chainedSelects.js" charset="utf-8"></script> |
|---|
| 249 |
<script type="text/javascript" src="modules/cidroute/js/autosuggest.js" charset="utf-8"></script> |
|---|
| 250 |
|
|---|
| 251 |
|
|---|
| 252 |
<link rel="stylesheet" href="modules/cidroute/js/autosuggest.css" type="text/css" media="screen" charset="utf-8" /> |
|---|
| 253 |
<link rel="stylesheet" href="modules/cidroute/js/comboselect.css" type="text/css" media="screen" charset="utf-8" /> |
|---|
| 254 |
|
|---|
| 255 |
|
|---|
| 256 |
<script language="JavaScript" type="text/javascript"> |
|---|
| 257 |
$(function() |
|---|
| 258 |
{ |
|---|
| 259 |
$('#state').chainSelect('#region','modules/cidroute/js/ajax.php', |
|---|
| 260 |
{ |
|---|
| 261 |
before:function (target) //before request hide the target combobox and display the loading message |
|---|
| 262 |
{ |
|---|
| 263 |
$("#loading").css("display","block"); |
|---|
| 264 |
$(target).css("display","none"); |
|---|
| 265 |
}, |
|---|
| 266 |
after:function (target) //after request show the target combobox and hide the loading message |
|---|
| 267 |
{ |
|---|
| 268 |
$("#loading").css("display","none"); |
|---|
| 269 |
$(target).css("display","inline"); |
|---|
| 270 |
} |
|---|
| 271 |
}); |
|---|
| 272 |
$('#region').chainSelect('#area','modules/cidroute/js/ajax.php', |
|---|
| 273 |
{ |
|---|
| 274 |
before:function (target) |
|---|
| 275 |
{ |
|---|
| 276 |
$("#loading").css("display","block"); |
|---|
| 277 |
$(target).css("display","none"); |
|---|
| 278 |
}, |
|---|
| 279 |
after:function (target) |
|---|
| 280 |
{ |
|---|
| 281 |
$("#loading").css("display","none"); |
|---|
| 282 |
$(target).css("display","inline"); |
|---|
| 283 |
} |
|---|
| 284 |
}); |
|---|
| 285 |
$(document).ready(function() { |
|---|
| 286 |
$('#myselect').comboselect({ sort: 'both', addbtn: '>>', rembtn: '<<' }); |
|---|
| 287 |
}); |
|---|
| 288 |
|
|---|
| 289 |
}); |
|---|
| 290 |
</script> |
|---|
| 291 |
<div> |
|---|
| 292 |
<form method="post" action="<? echo $_SERVER['PHP_SELF'] ?>" class="asholder"> |
|---|
| 293 |
<? |
|---|
| 294 |
global $itemid; |
|---|
| 295 |
global $dispnum; |
|---|
| 296 |
global $db; |
|---|
| 297 |
?> |
|---|
| 298 |
<form method="post" action="<? echo $_SERVER['PHP_SELF'] ?>" class="asholder"> |
|---|
| 299 |
<input type="hidden" name="itemid" value="<? echo $itemid ?>"> |
|---|
| 300 |
<input type="hidden" name="action" value="alter"> |
|---|
| 301 |
<input type="hidden" name="display" value="<? echo $dispnum; ?>"> |
|---|
| 302 |
</td></tr> |
|---|
| 303 |
<tr><td>Quick Select:</td><td> |
|---|
| 304 |
<input style="width: 200px" type="text" id="quick" name="quick" value="" /> <input type="submit" name="addquick" value="Add" /></td></tr> |
|---|
| 305 |
<tr><td>State:</td><td> <select id="state" name="state"> |
|---|
| 306 |
<option id="0">Select State</option> |
|---|
| 307 |
<? |
|---|
| 308 |
$res = sql("select distinct(state) from cidroute_cidlist order by state", "getAll", DB_FETCHMODE_ASSOC); |
|---|
| 309 |
$tmp = 0; |
|---|
| 310 |
if(is_array($res)){ |
|---|
| 311 |
foreach($res as $result){ |
|---|
| 312 |
print "<option value='".$tmp++."'>{$result['state']}</option>\n"; |
|---|
| 313 |
} |
|---|
| 314 |
} |
|---|
| 315 |
?> |
|---|
| 316 |
</select></td></tr> |
|---|
| 317 |
<tr><td>Region:</td><td> |
|---|
| 318 |
<!-- region is chained by state combobox--> |
|---|
| 319 |
<select name="region" id="region"><option value="0">--</option></select></td></tr> |
|---|
| 320 |
<!-- area is chained by region combobox--> |
|---|
| 321 |
<tr><td>Area:</td><td> |
|---|
| 322 |
<select name="area" id="area"><option value="0">--</option></select></td></tr> |
|---|
| 323 |
<tr><td><input type="submit" name="addselect" value="Submit" /></td></tr> |
|---|
| 324 |
<tr><td><?php echo _('Currently Selected Areas'); ?></td> |
|---|
| 325 |
<td style="text-align: right"><i>Move areas to right hand side to remove</i></td></tr> |
|---|
| 326 |
|
|---|
| 327 |
<tr><td colspan=2> |
|---|
| 328 |
</form> |
|---|
| 329 |
|
|---|
| 330 |
|
|---|
| 331 |
<form method="post" action="<? echo $_SERVER['PHP_SELF'] ?>" class="removestuff"> |
|---|
| 332 |
<input type="hidden" name="itemid" value="<? echo $itemid ?>"> |
|---|
| 333 |
<input type="hidden" name="action" value="delmaps"> |
|---|
| 334 |
<input type="hidden" name="display" value="<? echo $dispnum; ?>"> |
|---|
| 335 |
<select id="myselect" name="myselect[]" multiple="multiple"> |
|---|
| 336 |
<? |
|---|
| 337 |
$q = "select state, region, localarea, cidroute_cidlist.areacode, cidroute_matches.min_numb, cidroute_matches.max_numb "; |
|---|
| 338 |
$q .= "from cidroute_cidlist right join cidroute_matches using (min_numb,max_numb) where cidroute_matches.dest='"; |
|---|
| 339 |
$q .= $db->escapeSimple($itemid)."'"; |
|---|
| 340 |
$result = sql($q, "getAll", DB_FETCHMODE_ASSOC); |
|---|
| 341 |
if(is_array($result)){ |
|---|
| 342 |
foreach($result as $res){ |
|---|
| 343 |
$var = $res['min_numb']."|".$res['max_numb']; |
|---|
| 344 |
$desc = $res['state']."/".$res['region']."/".$res['localarea']." (".$res['min_numb']."-".$res['max_numb'].")"; |
|---|
| 345 |
print "<option value='".$var."'>$desc</option>\n"; |
|---|
| 346 |
} |
|---|
| 347 |
} |
|---|
| 348 |
?> |
|---|
| 349 |
|
|---|
| 350 |
|
|---|
| 351 |
</select> |
|---|
| 352 |
</tr></td> |
|---|
| 353 |
<tr><td colspan=2 style="text-align: right"><input type="submit" name="delselect" value="Remove Selected" /></td></tr> |
|---|
| 354 |
</form> |
|---|
| 355 |
|
|---|
| 356 |
|
|---|
| 357 |
</table> |
|---|
| 358 |
</div> |
|---|
| 359 |
<script type="text/javascript"> |
|---|
| 360 |
var options = { script: "modules/cidroute/js/ajax.php?type=global&limit=10&", |
|---|
| 361 |
varname:"input", json: true, shownowresults:true, maxresults:10 }; |
|---|
| 362 |
var as = new bsn.AutoSuggest('quick', options); |
|---|
| 363 |
</script> |
|---|
| 364 |
|
|---|
| 365 |
|
|---|
| 366 |
<?php |
|---|
| 367 |
} |
|---|
| 368 |
|
|---|
| 369 |
|
|---|
| 370 |
|
|---|
| 371 |
function showOverride() { |
|---|
| 372 |
global $dispnum; |
|---|
| 373 |
showHeader(); |
|---|
| 374 |
|
|---|
| 375 |
print "<h2>Not implemented yet</h2>"; |
|---|
| 376 |
|
|---|
| 377 |
} |
|---|
| 378 |
?> |
|---|