root/modules/branches/2.9/core/page.routing.php

Revision 13452, 42.4 kB (checked in by p_lindheimer, 3 months ago)

Merged revisions 12193 via svnmerge from
http://www.freepbx.org/v2/svn/modules/branches/2.10

........

r12193 | mickecarlsson | 2011-05-25 12:16:45 -0700 (Wed, 25 May 2011) | 1 line


Closes #5181 adds 1855 as toll free number in outbound routes

........

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php /* $Id$ */
2 // This file is part of FreePBX.
3 //
4 //    FreePBX is free software: you can redistribute it and/or modify
5 //    it under the terms of the GNU General Public License as published by
6 //    the Free Software Foundation, either version 2 of the License, or
7 //    (at your option) any later version.
8 //
9 //    FreePBX is distributed in the hope that it will be useful,
10 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //    GNU General Public License for more details.
13 //
14 //    You should have received a copy of the GNU General Public License
15 //    along with FreePBX.  If not, see <http://www.gnu.org/licenses/>.
16 //
17 //    Copyright (C) 2004 Greg MacLellan (greg@mtechsolutions.ca)
18 //    Copyright (C) 2005 Ron Hartmann (rhartmann@vercomsystems.com)
19 //    Copyright (C) 2004 Coalescent Systems Inc. (info@coalescentsystems.ca)
20 //
21 $display='routing'; 
22 $extdisplay=isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:'';
23 $action = isset($_REQUEST['action'])?$_REQUEST['action']:'';
24 // Now check if the Copy Route submit button was pressed, in which case we duplicate the route
25 //
26 if (isset($_REQUEST['copyroute'])) {
27   $action = 'copyroute';
28 }
29
30 $tabindex = 0;
31
32 $repotrunkdirection = isset($_REQUEST['repotrunkdirection'])?$_REQUEST['repotrunkdirection']:'';
33
34 //this was effectively the sequence, now it becomes the route_id and the value past will have to change
35 $repotrunkkey = isset($_REQUEST['repotrunkkey'])?$_REQUEST['repotrunkkey']:'';
36
37 // Check if they uploaded a CSV file for their route patterns
38 //
39 if (isset($_FILES['pattern_file']) && $_FILES['pattern_file']['tmp_name'] != '') {
40   $fh = fopen($_FILES['pattern_file']['tmp_name'], 'r');
41   if ($fh !== false) {
42     $csv_file = array();
43     $index = array();
44
45     // Check first row, ingoring empty rows and get indices setup
46     //
47     while (($row = fgetcsv($fh, 5000, ",", "\"")) !== false) {
48       if (count($row) == 1 && $row[0] == '') {
49         continue;
50       } else {
51         $count = count($row) > 4 ? 4 : count($row);
52         for ($i=0;$i<$count;$i++) {
53           switch (strtolower($row[$i])) {
54           case 'prepend':
55           case 'prefix':
56           case 'match pattern':
57           case 'callerid':
58             $index[strtolower($row[$i])] = $i;
59           break;
60           default:
61           break;
62           }
63         }
64         // If no headers then assume standard order
65         if (count($index) == 0) {
66           $index['prepend'] = 0;
67           $index['prefix'] = 1;
68           $index['match pattern'] = 2;
69           $index['callerid'] = 3;
70           if ($count == 4) {
71             $csv_file[] = $row;
72           }
73         }
74         break;
75       }
76     }
77     $row_count = count($index);
78     while (($row = fgetcsv($fh, 5000, ",", "\"")) !== false) {
79       if (count($row) == $row_count) {
80         $csv_file[] = $row;
81       }
82     }
83   }
84 }
85
86 //
87 // Use a hash of the value inserted to get rid of duplicates
88 $dialpattern_insert = array();
89 $p_idx = 0;
90 $n_idx = 0;
91
92 // If we have a CSV file it replaces any existing patterns
93 //
94 if (!empty($csv_file)) {
95   foreach ($csv_file as $row) {
96     $this_prepend = isset($index['prepend']) ? htmlspecialchars(trim($row[$index['prepend']])) : '';
97     $this_prefix = isset($index['prefix']) ? htmlspecialchars(trim($row[$index['prefix']])) : '';
98     $this_match_pattern = isset($index['match pattern']) ? htmlspecialchars(trim($row[$index['match pattern']])) : '';
99     $this_callerid = isset($index['callerid']) ? htmlspecialchars(trim($row[$index['callerid']])) : '';
100
101     if ($this_prepend != '' || $this_prefix  != '' || $this_match_pattern != '' || $this_callerid != '') {
102       $dialpattern_insert[] = array(
103         'prepend_digits' => $this_prepend,
104         'match_pattern_prefix' => $this_prefix,
105         'match_pattern_pass' => $this_match_pattern,
106         'match_cid' => $this_callerid,
107       );
108     }
109   }
110 } else if (isset($_POST["prepend_digit"])) {
111   $prepend_digit = $_POST["prepend_digit"];
112   $pattern_prefix = $_POST["pattern_prefix"];
113   $pattern_pass = $_POST["pattern_pass"];
114   $match_cid = $_POST["match_cid"];
115
116   foreach (array_keys($prepend_digit) as $key) {
117     if ($prepend_digit[$key]!='' || $pattern_prefix[$key]!='' || $pattern_pass[$key]!='' || $match_cid[$key]!='') {
118
119       $dialpattern_insert[] = array(
120         'prepend_digits' => htmlspecialchars(trim($prepend_digit[$key])),
121         'match_pattern_prefix' => htmlspecialchars(trim($pattern_prefix[$key])),
122         'match_pattern_pass' => htmlspecialchars(trim($pattern_pass[$key])),
123         'match_cid' => htmlspecialchars(trim($match_cid[$key])),
124       );
125     }
126   }
127 }
128
129 if ( isset($_REQUEST['reporoutedirection']) && $_REQUEST['reporoutedirection'] != '' && isset($_REQUEST['reporoutekey']) && $_REQUEST['reporoutekey'] != '') {
130   $_REQUEST['route_seq'] = core_routing_setrouteorder($_REQUEST['reporoutekey'], $_REQUEST['reporoutedirection']);
131 }
132
133 $trunkpriority = array();
134 if (isset($_REQUEST["trunkpriority"])) {
135   $trunkpriority = $_REQUEST["trunkpriority"];
136
137   if (!$trunkpriority) {
138     $trunkpriority = array();
139   }
140  
141   // delete blank entries and reorder
142   foreach (array_keys($trunkpriority) as $key) {
143     if ($trunkpriority[$key] == '') {
144       // delete this empty
145       unset($trunkpriority[$key]);
146      
147     } else if (($key==($repotrunkkey-1)) && ($repotrunkdirection=="up")) {
148       // swap this one with the one before (move up)
149       $temptrunk = $trunkpriority[$key];
150       $trunkpriority[ $key ] = $trunkpriority[ $key+1 ];
151       $trunkpriority[ $key+1 ] = $temptrunk;
152      
153     } else if (($key==($repotrunkkey)) && ($repotrunkdirection=="down")) {
154       // swap this one with the one after (move down)
155       $temptrunk = $trunkpriority[ $key+1 ];
156       $trunkpriority[ $key+1 ] = $trunkpriority[ $key ];
157       $trunkpriority[ $key ] = $temptrunk;
158     }
159   }
160   unset($temptrunk);
161   $trunkpriority = array_unique(array_values($trunkpriority)); // resequence our numbers
162   if ($action == '') {
163     $action = "updatetrunks";
164   }
165
166 }
167
168 $routename = isset($_REQUEST['routename']) ? $_REQUEST['routename'] : '';
169 $routepass = isset($_REQUEST['routepass']) ? $_REQUEST['routepass'] : '';
170 $emergency = isset($_REQUEST['emergency']) ? $_REQUEST['emergency'] : '';
171 $intracompany = isset($_REQUEST['intracompany']) ? $_REQUEST['intracompany'] : '';
172 $mohsilence = isset($_REQUEST['mohsilence']) ? $_REQUEST['mohsilence'] : '';
173 $outcid = isset($_REQUEST['outcid']) ? $_REQUEST['outcid'] : '';
174 $outcid_mode = isset($_REQUEST['outcid_mode']) ? $_REQUEST['outcid_mode'] : '';
175 $time_group_id = isset($_REQUEST['time_group_id']) ? $_REQUEST['time_group_id'] : '';
176 $route_seq = isset($_REQUEST['route_seq']) ? $_REQUEST['route_seq'] : '';
177
178 //if submitting form, update database
179 switch ($action) {
180   case 'ajaxroutepos':
181     core_routing_setrouteorder($repotrunkkey, $repotrunkdirection);
182     needreload();
183     include_once("common/json.inc.php");
184     if ($_POST['send_reload'] == 'yes') {
185       ob_start();
186       include ('views/freepbx_reloadbar.php');
187       $json_array['reload_bar'] = ob_get_clean();
188
189       ob_start();
190       include ('views/freepbx_reload.php');
191       $json_array['reload_header'] = ob_get_clean();
192     }
193     $json_array['show_reload'] = 'yes';
194     $json = new Services_JSON();
195     header("Content-type: application/json");
196     echo $json->encode($json_array);
197     exit;
198
199   break;
200   case "copyroute":
201     $routename .= "_copy_$extdisplay";
202     $extdisplay='';
203     $route_seq++;
204   // Fallthrough to addtrunk now...
205   //
206   case "addroute":
207     $extdisplay = core_routing_addbyid($routename, $outcid, $outcid_mode, $routepass, $emergency, $intracompany, $mohsilence, $time_group_id, $dialpattern_insert, $trunkpriority, $route_seq);
208     $_REQUEST['extdisplay'] = $extdisplay; //have not idea if this is needed or useful
209     needreload();
210     redirect_standard('extdisplay');
211   break;
212   case "editroute":
213     core_routing_editbyid($extdisplay, $routename, $outcid, $outcid_mode, $routepass, $emergency, $intracompany, $mohsilence, $time_group_id, $dialpattern_insert, $trunkpriority, $route_seq);
214     needreload();
215     redirect_standard('extdisplay');
216   break;
217   case "updatetrunks":
218     core_routing_updatetrunks($extdisplay, $trunkpriority, true);
219     needreload();
220   break;
221   case "delroute":
222     core_routing_delbyid($extdisplay);
223     // re-order the routes to make sure that there are no skipped numbers.
224     // example if we have 001-test1, 002-test2, and 003-test3 then delete 002-test2
225     // we do not want to have our routes as 001-test1, 003-test3 we need to reorder them
226     // so we are left with 001-test1, 002-test3
227     needreload();
228     redirect_standard();
229   break;
230   case 'prioritizeroute':
231     needreload();
232   break;
233   case 'populatenpanxx':
234     $dialpattern_array = $dialpattern_insert;
235     if (preg_match("/^([2-9]\d\d)-?([2-9]\d\d)$/", $_REQUEST["npanxx"], $matches)) {
236       // first thing we do is grab the exch:
237       $ch = curl_init();
238       curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
239       curl_setopt($ch, CURLOPT_URL, "http://www.localcallingguide.com/xmllocalprefix.php?npa=".$matches[1]."&nxx=".$matches[2]);
240       curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Linux; FreePBX Local Trunks Configuration)");
241       $str = curl_exec($ch);
242       curl_close($ch);
243
244       // quick 'n dirty - nabbed from PEAR
245       require_once($amp_conf['AMPWEBROOT'] . '/admin/modules/core/XML_Parser.php');
246       require_once($amp_conf['AMPWEBROOT'] . '/admin/modules/core/XML_Unserializer.php');
247
248       $xml = new xml_unserializer;
249       $xml->unserialize($str);
250       $xmldata = $xml->getUnserializedData();
251
252       $hash_filter = array(); //avoid duplicates
253       if (isset($xmldata['lca-data']['prefix'])) {
254         // we do the loops separately so patterns are grouped together
255        
256         // match 1+NPA+NXX (dropping 1)
257         foreach ($xmldata['lca-data']['prefix'] as $prefix) {
258           if (isset($hash_filter['1'.$prefix['npa'].$prefix['nxx']])) {
259             continue;
260           } else {
261             $hash_filter['1'.$prefix['npa'].$prefix['nxx']] = true;
262           }
263           $dialpattern_array[] = array(
264             'prepend_digits' => '',
265             'match_pattern_prefix' => '1',
266             'match_pattern_pass' => htmlspecialchars($prefix['npa'].$prefix['nxx']).'XXXX',
267             'match_cid' => '',
268           );
269         }
270         // match NPA+NXX
271         foreach ($xmldata['lca-data']['prefix'] as $prefix) {
272           if (isset($hash_filter[$prefix['npa'].$prefix['nxx']])) {
273             continue;
274           } else {
275             $hash_filter[$prefix['npa'].$prefix['nxx']] = true;
276           }
277           $dialpattern_array[] = array(
278             'prepend_digits' => '',
279             'match_pattern_prefix' => '',
280             'match_pattern_pass' => htmlspecialchars($prefix['npa'].$prefix['nxx']).'XXXX',
281             'match_cid' => '',
282           );
283         }
284         // match 7-digits
285         foreach ($xmldata['lca-data']['prefix'] as $prefix) {
286           if (isset($hash_filter[$prefix['nxx']])) {
287             continue;
288           } else {
289             $hash_filter[$prefix['nxx']] = true;
290           }
291           $dialpattern_array[] = array(
292             'prepend_digits' => '',
293             'match_pattern_prefix' => '',
294             'match_pattern_pass' => htmlspecialchars($prefix['nxx']).'XXXX',
295             'match_cid' => '',
296           );
297         }
298         unset($hash_filter);
299       } else {
300         $errormsg = _("Error fetching prefix list for: "). $_REQUEST["npanxx"];
301       }
302      
303     } else {
304       // what a horrible error message... :p
305       $errormsg = _("Invalid format for NPA-NXX code (must be format: NXXNXX)");
306     }
307    
308     if (isset($errormsg)) {
309       echo "<script language=\"javascript\">alert('".addslashes($errormsg)."');</script>";
310       unset($errormsg);
311     }
312   break;
313 }
314
315 ?>
316 </div>
317 <script type="text/javascript">
318 $(document).ready(function(){
319   $("#routelist").sortable({
320     items: 'li:gt(0)',
321     cursor: 'move',
322     update: function(event, ui){
323       var repotrunkkey=+ui.item.attr('id').replace('routelist','');
324       var repotrunkdirection=ui.item.index();repotrunkdirection--;
325       var send_reload = '&send_reload='+($('#need_reload_block').size() == 0 ? 'yes':'no');
326       $.ajax({
327         type: 'POST',
328         url: location.href,
329         data: "action=ajaxroutepos&quietmode=1&skip_astman=1&restrictmods=core&repotrunkkey="+repotrunkkey+"&repotrunkdirection="+repotrunkdirection+send_reload,
330         dataType: 'json',
331         success: function(data) {
332           /* if the reload_block is not there, we blindly insert the info we think we got because we told
333              it in the ajax call to send it to use, should wo double check?
334           */
335           if ((data.show_reload == 'yes') && !$('#need_reload_block').fadeIn().size()) {
336             $('#logo').after(data.reload_bar).fadeIn();
337             $('#moduleBox').before(data.reload_header);
338           }
339           if (data.show_reload == 'yes') {
340             $('#need_reload_block').fadeIn();
341           }
342         },
343         error: function(data) {
344           alert("<?php _("An unknown error occurred repositioning routes, refresh your browser to see the current correct route positions") ?>");
345         }
346       });
347     }
348   }).disableSelection();
349 });
350 </script>
351 <div class="rnav">
352 <ul id="routelist">
353   <li><a <?php  echo ($extdisplay=='' ? 'class="current"':'') ?> href="config.php?display=<?php echo urlencode($display)?>"><?php echo _("Add Route")?></a></li>
354 <?php 
355 $reporoutedirection = isset($_REQUEST['reporoutedirection'])?$_REQUEST['reporoutedirection']:'';
356 $reporoutekey = isset($_REQUEST['reporoutekey'])?$_REQUEST['reporoutekey']:'';
357 $routepriority = core_routing_list();
358 $positions=count($routepriority);
359 $drag_title = _("Drag up or down to reposition, click to choose");
360 foreach ($routepriority as $key => $tresult) {
361   echo "\t<li id=\"routelist".$tresult['route_id'] ."\">\n\t\t<a " . ($extdisplay==$tresult['route_id'] ? 'class="current"':'') .
362     " href=\"config.php?display=" .
363     urlencode($display)."&amp;extdisplay=" .
364     urlencode($tresult['route_id']) . "\" title=\"$drag_title\"><img src=\"images/arrow_up_down.png\" height=\"16\" width=\"16\" border=\"0\" alt=\"move\" style=\"float:none; margin-left:-6px; margin-bottom:-3px;cursor:move\" /> " . $tresult['name']."</a>\n";
365     echo "\t</li>\n";
366 } // foreach
367 ?>
368 </ul>
369 </div>
370
371 <div class="content">
372
373 <?php 
374 $last_seq = count($routepriority)-1;
375 if ($action == 'populatenpanxx') {
376   echo "<h2>"._("Edit Route")."</h2>";
377 } else if ($extdisplay != '') {
378  
379   // load from db
380   $route_info = core_routing_get($extdisplay);
381   $dialpattern_array = core_routing_getroutepatternsbyid($extdisplay);
382   $trunkpriority = core_routing_getroutetrunksbyid($extdisplay);
383  
384   $routepass = $route_info['password'];
385   $emergency = $route_info['emergency_route'];
386   $intracompany = $route_info['intracompany_route'];
387   $mohsilence = $route_info['mohclass'];
388   $outcid = $route_info['outcid'];
389   $outcid_mode = $route_info['outcid_mode'];
390   $time_group_id = $route_info['time_group_id'];
391   $route_seq = $route_info['seq'];
392   $routename = $route_info['name'];
393   echo "<h2>"._("Edit Route")."</h2>";
394 } else { 
395   $route_seq = $last_seq+1;
396   if (!isset($dialpattern_array)) {
397     $dialpattern_array = array();
398   }
399   echo "<h2>"._("Add Route")."</h2>";
400 }
401 //
402 // build trunks associative array
403 foreach (core_trunks_listbyid() as $temp) {
404   $trunks[$temp['trunkid']] = $temp['name'];
405   $trunkstate[$temp['trunkid']] = $temp['disabled'];
406 }
407
408 if ($extdisplay) { // editing
409   $tlabel = sprintf(_("Delete Route %s"),$route_info['name']);
410   $label = '<span><img width="16" height="16" border="0" title="'.$tlabel.'" alt="" src="images/core_delete.png"/>&nbsp;'.$tlabel.'</span>';
411 ?>
412   <p><a href="config.php?display=<?php echo urlencode($display) ?>&extdisplay=<?php echo urlencode($extdisplay) ?>&action=delroute"><?php echo $label ?></a></p>
413 <?php 
414 } 
415 ?>
416   <form enctype="multipart/form-data" autocomplete="off" id="routeEdit" name="routeEdit" action="config.php" method="POST" onsubmit="return routeEdit_onsubmit('<?php echo ($extdisplay != '' ? "editroute" : "addroute") ?>');">
417     <input type="hidden" name="display" value="<?php echo $display?>"/>
418     <input type="hidden" name="extdisplay" value="<?php echo $extdisplay ?>"/>
419     <input type="hidden" id="action" name="action" value=""/>
420
421     <input type="hidden" id="repotrunkdirection" name="repotrunkdirection" value="">
422     <input type="hidden" id="repotrunkkey" name="repotrunkkey" value="">
423     <input type="hidden" id="reporoutedirection" name="reporoutedirection" value="">
424     <input type="hidden" id="reporoutekey" name="reporoutekey" value="">
425     <table>
426     <tr>
427       <td colspan="2"><h5><?php echo _("Route Settings") ?><hr></h5></td>
428     </tr>
429
430     <tr>
431       <td>
432         <a href=# class="info"><?php echo _("Route Name")?><span><br><?php echo _("Name of this route. Should be used to describe what type of calls this route matches (for example, 'local' or 'longdistance').")?><br></span></a>:
433       </td>
434       <td>
435         <input type="text" size="20" name="routename" value="<?php echo htmlspecialchars($routename);?>" tabindex="<?php echo ++$tabindex;?>"/>
436       </td>
437     </tr>
438
439     <tr>
440       <td><a href=# class="info"><?php echo _("Route CID")?>:<span><?php echo _("Optional Route CID to be used for this route. If set, this will override all CIDS specified except:<ul><li>extension/device EMERGENCY CIDs if this route is checked as an EMERGENCY Route</li><li>trunk CID if trunk is set to force it's CID</li><li>Forwarded call CIDs (CF, Follow Me, Ring Groups, etc)</li><li>Extension/User CIDs if checked</li></ul>")?></span></a></td>
441       <td>
442         <input type="text" size="20" name="outcid" value="<?php echo htmlspecialchars($outcid)?>" tabindex="<?php echo ++$tabindex;?>"/>
443         <input type='checkbox' tabindex="<?php echo ++$tabindex;?>" name='outcid_mode' id="outcid_mode" value='override_extension' <?php if ($outcid_mode == 'override_extension') { echo 'CHECKED'; }?>><a href=# class="info"><small><?php echo _("Override Extension")?></small><span><?php echo _("If checked the extension's Outbound CID will be ignored in favor of this CID. The extension's Emergency CID will still be used if the route is an Emergency Route and the Extension has a defined Emergency CID.")?></span></a>
444       </td>
445     </tr>
446
447     <tr>
448       <td><a href=# class="info"><?php echo _("Route Password")?>:<span><?php echo _("Optional: A route can prompt users for a password before allowing calls to progress.  This is useful for restricting calls to international destinations or 1-900 numbers.<br><br>A numerical password, or the path to an Authenticate password file can be used.<br><br>Leave this field blank to not prompt for password.")?></span></a></td>
449       <td><input type="text" size="20" name="routepass" value="<?php echo $routepass;?>" tabindex="<?php echo ++$tabindex;?>"/></td>
450     </tr>
451
452     <tr>
453       <td><a href=# class="info"><?php echo _("Route Type")?>:<span><?php echo _("Optional: Selecting Emergency will enforce the use of a device's Emergency CID setting (if set).  Select this option if this route is used for emergency dialing (ie: 911).").'<br />'._("Optional: Selecting Intra-Company will treat this route as an intra-company connection, preserving the internal CallerID information instead of the outbound CID of either the extension or trunk.")?></span></a></td>
454       <td>
455         <input type="checkbox" name="emergency" value="YES" <?php echo ($emergency ? "CHECKED" : "") ?>  tabindex="<?php echo ++$tabindex;?>"/><small><?php echo _("Emergency") ?></small>
456         <input type="checkbox" name="intracompany" value="YES" <?php echo ($intracompany ? "CHECKED" : "") ?>  tabindex="<?php echo ++$tabindex;?>"/><small><?php echo _("Intra-Company") ?></small>
457       </td>
458     </tr>
459
460 <?php   if (function_exists('music_list')) { ?>
461     <tr>
462       <td><a href="#" class="info"><?php echo _("Music On Hold?")?><span><?php echo _("You can choose which music category to use. For example, choose a type appropriate for a destination country which may have announcements in the appropriate language.")?></span></a></td>
463       <td>
464         <select name="mohsilence" tabindex="<?php echo ++$tabindex;?>">
465         <?php
466           $tresults = music_list();
467           $cur = (isset($mohsilence) && $mohsilence != "" ? $mohsilence : 'default');
468           if (isset($tresults[0])) {
469             foreach ($tresults as $tresult) {
470               $ttext = $tresult;
471               if($tresult == 'none') $ttext = _("none");
472               if($tresult == 'default') $ttext = _("default");
473               echo '<option value="'.$tresult.'"'.($tresult == $cur ? ' SELECTED' : '').'>'.$ttext."</option>\n";
474             }
475           }
476         ?>   
477         </select>   
478       </td>
479     </tr>
480 <?php } ?>
481
482 <?php if (function_exists('timeconditions_timegroups_drawgroupselect')) { ?>
483     <tr>
484       <td><a href="#" class="info"><?php echo _("Time Group:")?><span><?php echo _("If this route should only be available during certain times then Select a Time Group created under Time Groups. The route will be ignored outside of times specified in that Time Group. If left as default of Permanent Route then it will always be available.")?></span></a></td>
485       <td><?php echo timeconditions_timegroups_drawgroupselect('time_group_id', $time_group_id, true, '', _('---Permanent Route---')); ?></td>
486     </tr>
487     <tr>
488 <?php } ?>
489
490     <tr>
491       <td><a href="#" class="info"><?php echo _("Route Position")?><span><?php echo _("Where to insert this route or relocate it relative to the other routes.")?></span></a></td>
492       <td>
493         <select name="route_seq" tabindex="<?php echo ++$tabindex;?>">
494         <?php
495           if ($route_seq != 0) {
496             echo '<option value="0"'.($route_seq == 0 ? ' SELECTED' : '').'>'.sprintf(_('First before %s'),$routepriority[0]['name'])."</option>\n";
497           }
498           foreach ($routepriority as $key => $route) {
499             if ($key == 0 && $route_seq != 0) continue;
500             if ($key == ($route_seq+1)) continue;
501             if ($route_seq == $key) {
502               echo '<option value="'.$key.'" SELECTED>'._('---No Change---')."</option>\n";
503             } else {
504               echo '<option value="'.$key.'">'.sprintf(_('Before %s'),$route['name'])."</option>\n";
505             }
506           }
507           if ($extdisplay == '' | $route_seq != $last_seq) {
508             echo '<option value="bottom"'.($route_seq == count($routepriority) ? ' SELECTED' : '').'>'.sprintf(_('Last after %s'),$routepriority[$last_seq]['name'])."</option>\n";
509           }
510         ?>   
511         </select>   
512       </td>
513     </tr>
514 <?php
515   if (!empty($module_hook->hookHtml)) {
516 ?>
517     <tr>
518       <td colspan="2"><h5><?php echo _("Additional Settings") ?><hr></h5></td>
519     </tr>
520 <?php
521     echo $module_hook->hookHtml;
522   }
523 ?>
524     <tr>
525       <td colspan="2"><h5>
526       <a href=# class="info"><?php echo _("Dial Patterns that will use this Route")?><span>
527       <?php echo _("A Dial Pattern is a unique set of digits that will select this route and send the call to the designated trunks. If a dialed pattern matches this route, no subsequent routes will be tried. If Time Groups are enabled, subsequent routes will be checked for matches outside of the designated time(s).")?><br /><br /><b><?php echo _("Rules:")?></b><br />
528       <b>X</b>&nbsp;&nbsp;&nbsp; <?php echo _("matches any digit from 0-9")?><br />
529       <b>Z</b>&nbsp;&nbsp;&nbsp; <?php echo _("matches any digit from 1-9")?><br />
530       <b>N</b>&nbsp;&nbsp;&nbsp; <?php echo _("matches any digit from 2-9")?><br />
531       <b>[1237-9]</b>&nbsp;   <?php echo _("matches any digit in the brackets (example: 1,2,3,7,8,9)")?><br />
532       <b>.</b>&nbsp;&nbsp;&nbsp; <?php echo _("wildcard, matches one or more dialed digits")?> <br />
533       <b><?php echo _("prepend:")?></b>&nbsp;&nbsp;&nbsp; <?php echo _("Digits to prepend to a successful match. If the dialed number matches the patterns specified by the subsequent columns, then this will be prepended before sending to the trunks.")?><br />
534       <b><?php echo _("prefix:")?></b>&nbsp;&nbsp;&nbsp; <?php echo _("Prefix to remove on a successful match. The dialed number is compared to this and the subsequent columns for a match. Upon a match, this prefix is removed from the dialed number before sending it to the trunks.")?><br />
535       <b><?php echo _("match pattern:")?></b>&nbsp;&nbsp;&nbsp; <?php echo _("The dialed number will be compared against the  prefix + this match pattern. Upon a match, the match pattern portion of the dialed number will be sent to the trunks")?><br />
536       <b><?php echo _("CallerID:")?></b>&nbsp;&nbsp;&nbsp; <?php echo _("If CallerID is supplied, the dialed number will only match the prefix + match pattern if the CallerID being transmitted matches this. When extensions make outbound calls, the CallerID will be their extension number and NOT their Outbound CID. The above special matching sequences can be used for CallerID matching similar to other number matches.")?><br />
537       </span></a>
538       <hr></h5></td>
539     </tr>
540
541     <tr><td colspan="2"><div class="dialpatterns"><table>
542 <?php
543   $pp_tit = _("prepend");
544   $pf_tit = _("prefix");
545   $mp_tit = _("match pattern");
546   $ci_tit = _("CallerID");
547
548   $dpt_title_class = 'dpt-title dpt-display';
549   foreach ($dialpattern_array as $idx => $pattern) {
550     $tabindex++;
551     if ($idx == 50) {
552       $dpt_title_class = 'dpt-title dpt-nodisplay';
553     }
554     $dpt_class = $pattern['prepend_digits'] == '' ? $dpt_title_class : 'dpt-value';
555     echo <<< END
556     <tr>
557       <td colspan="2">
558         (<input title="$pp_tit" type="text" size="8" id="prepend_digit_$idx" name="prepend_digit[$idx]" class="dial-pattern $dpt_class" value="{$pattern['prepend_digits']}" tabindex="$tabindex">) +
559 END;
560     $tabindex++;
561     $dpt_class = $pattern['match_pattern_prefix'] == '' ? $dpt_title_class : 'dpt-value';
562     echo <<< END
563         <input title="$pf_tit" type="text" size="6" id="pattern_prefix_$idx" name="pattern_prefix[$idx]" class="$dpt_class" value="{$pattern['match_pattern_prefix']}" tabindex="$tabindex"> |
564 END;
565     $tabindex++;
566     $dpt_class = $pattern['match_pattern_pass'] == '' ? $dpt_title_class : 'dpt-value';
567     echo <<< END
568         [<input title="$mp_tit" type="text" size="16" id="pattern_pass_$idx" name="pattern_pass[$idx]" class="$dpt_class" value="{$pattern['match_pattern_pass']}" tabindex="$tabindex"> /
569 END;
570     $tabindex++;
571     $dpt_class = $pattern['match_cid'] == '' ? $dpt_title_class : 'dpt-value';
572     echo <<< END
573         <input title="$ci_tit" type="text" size="10" id="match_cid_$idx" name="match_cid[$idx]" class="$dpt_class" value="{$pattern['match_cid']}" tabindex="$tabindex">]
574 END;
575 ?>
576         <img src="images/trash.png" style="float:none; margin-left:0px; margin-bottom:-3px; cursor:pointer;" alt="<?php echo _("remove")?>" title="<?php echo _('Click here to remove this pattern')?>" onclick="patternsRemove(<?php echo _("$idx") ?>)">
577       </td>
578     </tr>
579 <?php
580   }
581   $next_idx = count($dialpattern_array);
582 ?>
583     <tr>
584       <td colspan="2">
585         (<input title="<?php echo $pp_tit?>" type="text" size="8" id="prepend_digit_<?php echo $next_idx?>" name="prepend_digit[<?php echo $next_idx?>]" class="dial-pattern dpt-title dpt-display" value="" tabindex="<?php echo ++$tabindex;?>">) +
586         <input title="<?php echo $pf_tit?>" type="text" size="6" id="pattern_prefix_<?php echo $next_idx?>" name="pattern_prefix[<?php echo $next_idx?>]" class="dpt-title dpt-display" value="" tabindex="<?php echo ++$tabindex;?>"> |
587         [<input title="<?php echo $mp_tit?>" type="text" size="16" id="pattern_pass_<?php echo $next_idx?>" name="pattern_pass[<?php echo $next_idx?>]" class="dpt-title dpt-display" value="" tabindex="<?php echo ++$tabindex;?>"> /
588         <input title="<?php echo $ci_tit?>" type="text" size="10" id="match_cid_<?php echo $next_idx?>" name="match_cid[<?php echo $next_idx?>]" class="dpt-title dpt-display" value="" tabindex="<?php echo ++$tabindex;?>">]
589         <img src="images/trash.png" style="float:none; margin-left:0px; margin-bottom:-3px;cursor:pointer;" alt="<?php echo _("remove")?>" title="<?php echo _("Click here to remove this pattern")?>" onclick="patternsRemove(<?php echo _("$next_idx") ?>)">
590
591       </td>
592     </tr>
593     <tr id="last_row"></tr>
594     </table></div></tr>
595     <tr><td colspan="2">
596       <input type="button" id="dial-pattern-add"  value="<?php echo _("+ Add More Dial Pattern Fields")?>" />
597     </td></tr>
598 <?php
599   $tabindex += 2000; // make room for dynamic insertion of new fields
600 ?>
601     <tr>
602       <td>
603       <a href=# class="info"><?php echo _("Dial patterns wizards")?><span>
604           <?php echo _("These options provide a quick way to add outbound dialing rules. Follow the prompts for each.")?><br>
605           <strong><?php echo _("Lookup local prefixes")?></strong> <?php echo _("This looks up your local number on www.localcallingguide.com (NA-only), and sets up so you can dial either 7, 10 or 11 digits (5551234, 6135551234, 16135551234) to access this route.")?><br>
606           <strong><?php echo _("Upload from CSV")?></strong> <?php echo sprintf(_("Upload patterns from a CSV file replacing existing entries. If there are no headers then the file must have 4 columns of patterns in the same order as in the GUI. You can also supply headers: %s, %s, %s and %s in the first row. If there are less then 4 recognized headers then the remaining columns will be blank"),'<strong>prepend</strong>','<strong>prefix</strong>','<strong>match pattern</strong>','<strong>callerid</strong>')?><br>
607           </span></a>:
608       <input id="npanxx" name="npanxx" type="hidden" />
609       <script language="javascript">
610       
611       function populateLookup() {
612 <?php 
613   if (function_exists("curl_init")) { // curl is installed
614 ?>        
615         //var npanxx = prompt("What is your areacode + prefix (NPA-NXX)?", document.getElementById('areacode').value);
616         do {
617           var npanxx = <?php echo 'prompt("'._("What is your areacode + prefix (NPA-NXX)?\\n\\n(Note: this database contains North American numbers only, and is not guaranteed to be 100% accurate. You will still have the option of modifying results.)\\n\\nThis may take a few seconds.").'")' ?>;
618           if (npanxx == null) return;
619         } while (!npanxx.match("^[2-9][0-9][0-9][-]?[2-9][0-9][0-9]$") && <?php echo '!alert("'._("Invalid NPA-NXX. Must be of the format \'NXX-NXX\'").'")'?>);
620         
621         document.getElementById('npanxx').value = npanxx;
622         document.getElementById('routeEdit').action.value = "populatenpanxx";
623         clearPatterns();
624         document.getElementById('routeEdit').submit();
625 <?php 
626   } else { // curl is not installed
627 ?>
628         <?php echo "alert('"._("Error: Cannot continue!\\n\\nPrefix lookup requires cURL support in PHP on the server. Please install or enable cURL support in your PHP installation to use this function. See http://www.php.net/curl for more information.")."')"?>;
629 <?php 
630   }
631 ?>
632       }
633
634       function insertCode() {
635         // hide the file box if nothing was set
636         if ($('#pattern_file').val() == '') {
637           $('#pattern_file').hide();
638         }
639         code = document.getElementById('inscode').value;
640         insert = '';
641         switch(code) {
642           case "local":
643             insert = '<?php echo _("NXXXXXX") ?>';
644           break;
645           case "local10":
646             insert = '<?php echo _("NXXXXXX,NXXNXXXXXX") ?>';
647           break;
648           case 'tollfree':
649             insert = '<?php echo _("1800NXXXXXX,1888NXXXXXX,1877NXXXXXX,1866NXXXXXX,1855NXXXXXX") ?>';
650           break;
651           case "ld":
652             insert = '<?php echo _("1NXXNXXXXXX") ?>';
653           break;
654           case "int":
655             insert = '<?php echo _("011.") ?>';
656           break;
657           case 'info':
658             insert = '<?php echo _("411,311") ?>';
659           break;
660           case 'emerg':
661             insert = '<?php echo _("911") ?>';
662           break;
663           case 'lookup':
664             populateLookup();
665             insert = '';
666           break;
667           case 'csv':
668             $('#pattern_file').show().click();
669             return true;
670           break;
671         }
672
673         patterns = insert.split(',')
674         for (var i in patterns) {
675           addCustomField("","",patterns[i],"");
676         }
677
678         // reset element
679         document.getElementById('inscode').value = '';
680       }
681       
682       --></script>
683       <td>
684         <select onChange="insertCode();" id="inscode">
685       <option value=""><?php echo _("(pick one)")?></option>
686       <option value="local"><?php echo _("Local 7 digit")?></option>
687       <option value="local10"><?php echo _("Local 7/10 digit")?></option>
688       <option value="tollfree"><?php echo _("Toll-free")?></option>
689       <option value="ld"><?php echo _("Long-distance")?></option>
690       <option value="int"><?php echo _("International")?></option>
691       <option value="info"><?php echo _("Information")?></option>
692       <option value="emerg"><?php echo _("Emergency")?></option>
693       <option value="lookup"><?php echo _("Lookup local prefixes")?></option>
694       <option value="csv"><?php echo _("Upload from CSV")?></option>
695         </select>
696         <input type="file" name="pattern_file" id="pattern_file" tabindex="<?php echo ++$tabindex;?>"/>
697       </td>
698     </tr>
699
700     <tr>
701       <td colspan="2"><h5><a href=# class="info"><?php echo _("Trunk Sequence for Matched Routes")?><span><?php echo _("The Trunk Sequence controls the order of trunks that will be used when the above Dial Patterns are matched. <br><br>For Dial Patterns that match long distance numbers, for example, you'd want to pick the cheapest routes for long distance (ie, VoIP trunks first) followed by more expensive routes (POTS lines).")?><br></span></a><hr></h5></td>
702     </tr>
703 <?php 
704 $key = -1;
705 $positions=count($trunkpriority);
706 foreach ($trunkpriority as $key=>$trunk) {
707 ?>
708     <tr>
709       <td><?php echo $key; ?>&nbsp;&nbsp;
710         <select id='trunkpri<?php echo $key ?>' name="trunkpriority[<?php echo $key ?>]" style="background: <?php echo $trunkstate[$trunk]=="off"?"#FFF":"#DDD" ?> ;" onChange="showDisable(<?php echo $key ?>); return true;">
711         <option value="" style="background: #FFF;"></option>
712         <?php
713         foreach ($trunks as $name=>$display_description) {
714           if ($trunkstate[$name] == 'off') {
715             echo "<option id=\"trunk".$key."\" name=\"trunk".$key."\" value=\"".$name."\" style=\"background: #FFF;\" ".($name == $trunk ? "selected" : "").">".str_replace('AMP:', '', $display_description)."</option>";
716           } else {
717             echo "<option id=\"trunk".$key."\" name=\"trunk".$key."\" value=\"".$name."\" style=\"background: #DDD;\" ".($name == $trunk ? "selected" : "").">".str_replace('AMP:', '', $display_description)."</option>";
718           }
719         }
720         ?>
721         </select>
722         
723         <img src="images/trash.png" style="cursor:pointer; float:none; margin-left:0px; margin-bottom:-3px;" title="Click here to remove this trunk" onclick="deleteTrunk(<?php echo $key ?>)">
724       <?php   // move up
725       if ($key > 0) {?>
726         <img src="images/resultset_up.png" onclick="repositionTrunk('<?php echo $key ?>','up')" alt="<?php echo _("Move Up")?>" style="cursor:pointer; float:none; margin-left:0px; margin-bottom:0px;" width="12px" height="12px">
727       <?php  } else { ?>
728         <img src="images/blank.gif" style="float:none; margin-left:0px; margin-bottom:0px;" width="9" height="11">
729       <?php  }
730      
731       // move down
732      
733       if ($key < ($positions-1)) {?>
734         <img src="images/resultset_down.png" onclick="repositionTrunk('<?php echo $key ?>','down')" alt="<?php echo _("Move Down")?>"  style="cursor:pointer; float:none; margin-left:0px; margin-bottom:0px;" width="12px" height="12px">
735       <?php  } else { ?>
736         <img src="images/blank.gif" style="float:none; margin-left:0px; margin-bottom:0px;" width="9" height="11">
737       <?php  } ?>
738       </td>
739     </tr>
740 <?php 
741 } // foreach
742
743 $key += 1; // this will be the next key value
744 $name = "";
745
746 // display 1 additional box if editing, or one for each trunk (to a max of 3)
747 $num_new_boxes = ($extdisplay ? 1 : ((count($trunks) > 3) ? 3 : count($trunks)));
748
749 for ($i=0; $i < $num_new_boxes; $i++) {
750 ?>
751     <tr>
752       <td><?php echo $key; ?>&nbsp;&nbsp;
753         <select id='trunkpri<?php echo $key ?>' name="trunkpriority[<?php echo $key ?>]">
754         <option value="" SELECTED></option>
755         <?php
756         foreach ($trunks as $name=>$display_description) {
757           if ($trunkstate[$name] == 'off') {
758           echo "<option value=\"".$name."\">".str_replace('AMP:', '', $display_description)."</option>";
759           } else {
760           echo "<option value=\"".$name."\" style=\"background: #DDD;\" >*".ltrim($display_description,"AMP:")."*</option>";
761           }
762         }
763         ?>
764         </select>
765       </td>
766     </tr>
767 <?php 
768   $key++;
769 } //for 0..$num_new_boxes ?>
770
771 <?php if ($extdisplay != ''): // editing ?>
772     <tr>
773       <td colspan="2">
774         <input type="submit" value="<?php echo _("Add Trunk")?>">
775       </td>
776     </tr>
777 <?php endif; // if $extdisplay ?>
778
779     <tr>
780       <td colspan="2">
781         <h6>
782           <input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>">
783           <input name="copyroute" type="submit" value="<?php echo _("Duplicate Route");?>"/>
784         </h6>
785       </td>
786     </tr>
787     </table>
788  
789 <script language="javascript">
790 <!--
791
792 $(document).ready(function(){
793   /* Add a Custom Var / Val textbox */
794   $("#dial-pattern-add").click(function(){
795     addCustomField('','','','');
796   });
797   $('#pattern_file').hide();
798   $(".dpt-display").toggleVal({
799     populateFrom: "title",
800     changedClass: "text-normal",
801     focusClass: "text-normal"
802   });
803   $(".dpt-nodisplay").mouseover(function(){
804     $(this).toggleVal({
805       populateFrom: "title",
806       changedClass: "text-normal",
807       focusClass: "text-normal"
808     }).removeClass('dpt-nodisplay').addClass('dpt-display').unbind('mouseover');
809   });
810 }); 
811
812 function patternsRemove(idx) {
813   $("#prepend_digit_"+idx).parent().parent().remove();
814 }
815
816 function addCustomField(prepend_digit, pattern_prefix, pattern_pass, match_cid) {
817   var idx = $(".dial-pattern").size();
818   var idxp = idx - 1;
819   var tabindex = parseInt($("#match_cid_"+idxp).attr('tabindex')) + 1;
820   var tabindex1 = tabindex + 2;
821   var tabindex2 = tabindex + 3;
822   var tabindex3 = tabindex + 4;
823   var dpt_title = 'dpt-title dpt-display';
824   var dpt_prepend_digit = prepend_digit == '' ? dpt_title : 'dpt-value';
825   var dpt_pattern_prefix = pattern_prefix == '' ? dpt_title : 'dpt-value';
826   var dpt_pattern_pass = pattern_pass == '' ? dpt_title : 'dpt-value';
827   var dpt_match_cid = match_cid == '' ? dpt_title : 'dpt-value';
828
829   var new_insert = $("#last_row").before('\
830   <tr>\
831     <td colspan="2">\
832     (<input title="<?php echo $pp_tit?>" type="text" size="8" id="prepend_digit_'+idx+'" name="prepend_digit['+idx+']" class="dial-pattern '+dpt_prepend_digit+'" value="'+prepend_digit+'" tabindex="'+tabindex+'">) +\
833     <input title="<?php echo $pf_tit?>" type="text" size="6" id="pattern_prefix_'+idx+'" name="pattern_prefix['+idx+']" class="'+dpt_pattern_prefix+'" value="'+pattern_prefix+'" tabindex="'+tabindex1+'"> |\
834     [<input title="<?php echo $mp_tit?>" type="text" size="16" id="pattern_pass_'+idx+'" name="pattern_pass['+idx+']" class="'+dpt_pattern_pass+'" value="'+pattern_pass+'" tabindex="'+tabindex2+'"> /\
835     <input title="<?php echo $ci_tit?>" type="text" size="10" id="match_cid_'+idx+'" name="match_cid['+idx+']" class="'+dpt_match_cid+'" value="'+match_cid+'" tabindex="'+tabindex3+'">]\
836       <img src="images/trash.png" style="cursor:pointer; float:none; margin-left:0px; margin-bottom:-3px;" alt="<?php echo _("remove")?>" title="<?php echo _("Click here to remove this pattern")?>" onclick="patternsRemove('+idx+')">\
837     </td>\
838   </tr>\
839   ').prev();
840
841   new_insert.find(".dpt-title").toggleVal({
842     populateFrom: "title",
843     changedClass: "text-normal",
844     focusClass: "text-normal"
845   });
846
847   return idx;
848 }
849
850 var theForm = document.routeEdit;
851
852 if (theForm.routename.value == "") {
853   theForm.routename.focus();
854 } else {
855   theForm.outcid.focus();
856 }
857
858 function showDisable(key) {
859 <?php
860   $bgmap = 'bgc = {';
861   foreach ($trunks as $name=>$display_description) {
862     $bgmap .= " \"$name\":";
863     $bgmap .= ($trunkstate[$name] == 'off')?'"#FFF",':'"#DDD",';
864   }
865   echo rtrim($bgmap,',')." };\n";
866 ?>
867   if (document.getElementById('trunkpri'+key).value =='') {
868     document.getElementById('trunkpri'+key).style.background = '#FFF';
869   } else {
870     document.getElementById('trunkpri'+key).style.background = bgc[document.getElementById('trunkpri'+key).value];
871   }
872 }
873
874 function routeEdit_onsubmit(act) {
875   var msgInvalidRouteName = "<?php echo _('Route name is invalid, please try again'); ?>";
876   var msgInvalidRoutePwd = "<?php echo _('Route password must be numeric or leave blank to disable'); ?>";
877   var msgInvalidTrunkSelection = "<?php echo _('At least one trunk must be picked'); ?>";
878   var msgInvalidOutboundCID = "<?php echo _('Invalid Outbound CallerID'); ?>";
879  
880   var rname = theForm.routename.value;
881   if (!rname.match('^[a-zA-Z0-9][a-zA-Z0-9_\-]+$'))
882     return warnInvalid(theForm.routename, msgInvalidRouteName);
883  
884   defaultEmptyOK = true;
885   if (!isInteger(theForm.routepass.value))
886     return warnInvalid(theForm.routepass, msgInvalidRoutePwd);
887   if (!isCallerID(theForm.outcid.value))
888     return warnInvalid(theForm.outcid, msgInvalidOutboundCID);
889  
890   defaultEmptyOK = false;
891   /* TODO: get some sort of check in for dialpatterns
892   if (!isDialpattern(theForm.dialpattern.value))
893     return warnInvalid(theForm.dialpattern, msgInvalidDialPattern);
894     */
895     
896   if (theForm.trunkpri0.value == "") { // should they all be checked ?
897     theForm.trunkpri0.focus();
898     alert(msgInvalidTrunkSelection);
899     return false;
900   }
901  
902   theForm.action.value = act;
903
904   clearPatterns();
905   return validatePatterns();
906 }
907
908 function clearPatterns() {
909   $(".dpt-display").each(function() {
910     if($(this).val() == $(this).data("defText")) {
911       $(this).val("");
912     }
913   });
914   return true;
915 }
916
917 function validatePatterns() {
918   var one_good = false;
919   var culprit;
920   var msgInvalidDialPattern;
921   defaultEmptyOK = false;
922
923   $(".dpt-display, .dpt-value").each(function() {
924     if ($.trim($(this).val()) == '') {
925     } else if (!isDialpattern($(this).val())) {
926       culprit = this;
927       return false;
928     } else {
929       one_good = true;
930     }
931   });
932
933   if (culprit == undefined && !one_good) {
934     if ($('#inscode').val() == 'csv') {
935       return true;
936     }
937     culprit = $('.toggleval:visible').get(0);
938     msgInvalidDialPattern = "<?php echo _('No dial pattern, there must be at least one'); ?>";
939   } else {
940     msgInvalidDialPattern = "<?php echo _('Dial pattern is invalid'); ?>";
941   }
942   if (culprit != undefined) {
943     // now we have to put it back...
944     // do I have to turn it off first though?
945     $(".dpt-display").each(function() {
946       if ($.trim($(this).val()) == '') {
947         $(this).toggleVal({
948           populateFrom: "title",
949           changedClass: "text-normal",
950           focusClass: "text-normal"
951         });
952       }
953     });
954     return warnInvalid(culprit, msgInvalidDialPattern);
955   } else {
956     return true;
957   }
958 }
959
960 //TODO: maybe add action vs. it being blank and assumed above?
961 function repositionTrunk(key,direction) {
962   switch (direction) {
963   case 'up':
964   case 'down':
965     document.getElementById('repotrunkdirection').value=direction;
966     document.getElementById('repotrunkkey').value=key;
967     clearPatterns();
968     document.getElementById('routeEdit').submit();
969     break;
970   }
971 }
972
973 function deleteTrunk(key) {
974   document.getElementById('trunkpri'+key).value = '';
975   clearPatterns();
976   document.getElementById('routeEdit').submit();
977 }
978
979 function repositionRoute(key,direction){
980   switch (direction) {
981   case 'up':
982   case 'down':
983   case 'top':
984   case 'bottom':
985     document.getElementById('reporoutedirection').value=direction;
986     document.getElementById('reporoutekey').value=key;
987     document.getElementById('action').value='prioritizeroute';
988     clearPatterns();
989     document.getElementById('routeEdit').submit();
990     break;
991   }
992 }
993
994 //-->
995 </script>
996
997 </form>
Note: See TracBrowser for help on using the browser.