public function doConfigPageInit($page) { //Reassign $_REQUEST as it will be immutable in the future. $request = $_REQUEST; global $amp_conf; if ($page == "advancedsettings") { $freepbx_conf = $this->config; $settings = $freepbx_conf->get_conf_settings(); foreach ($request as $key => $val) { if (isset($settings[$key])) { if ($key == 'CRONMAN_UPDATES_CHECK') { $cm = \cronmanager::create($db); if ($val == 'true') { $cm->enable_updates(); } else { $cm->disable_updates(); } } switch ($settings[$key]['type']) { case CONF_TYPE_BOOL: $val = $val == 'true' ? 1 : 0; break; default: $val = trim($val); break; } $freepbx_conf->set_conf_values(array($key => $val), true, $amp_conf['AS_OVERRIDE_READONLY']); $status = $freepbx_conf->get_last_update_status(); if ($status[$key]['saved']) { //debug(sprintf(_("Advanced Settings changed freepbx_conf setting: [$key] => [%s]"),$val)); needreload(); } } } } // $page == "advancedsettings" if ($page == "dahdichandids") { if (!isset($_REQUEST['action'])) { return; } $type = isset($request['type']) ? $request['type'] : 'setup'; $action = isset($request['action']) ? $request['action'] : ''; if (isset($request['delete'])) { $action = 'delete'; } $extdisplay = isset($request['extdisplay']) ? $request['extdisplay'] : ''; $channel = isset($request['channel']) ? $request['channel'] : false; $description = isset($request['description']) ? $request['description'] : ''; $did = isset($request['did']) ? $request['did'] : ''; switch ($action) { case 'add': if (core_dahdichandids_add($description, $channel, $did)) { needreload(); $_REQUEST['extdisplay'] = $channel; $this->freepbx->View->redirect_standard('extdisplay'); } break; case 'edit': if (core_dahdichandids_edit($description, $channel, $did)) { needreload(); } break; case 'delete': core_dahdichandids_delete($channel); needreload(); break; } } // $page == "dahdichandids" if ($page == "routing") { $display = 'routing'; $extdisplay = isset($request['extdisplay']) ? $request['extdisplay'] : ''; $action = isset($request['action']) ? $request['action'] : ''; if (isset($request['copyroute'])) { $action = 'copyroute'; } $repotrunkdirection = isset($request['repotrunkdirection']) ? $request['repotrunkdirection'] : ''; //this was effectively the sequence, now it becomes the route_id and the value past will have to change $repotrunkkey = isset($request['repotrunkkey']) ? $request['repotrunkkey'] : ''; // Check if they uploaded a CSV file for their route patterns // if (isset($_FILES['pattern_file']) && $_FILES['pattern_file']['tmp_name'] != '') { $fh = fopen($_FILES['pattern_file']['tmp_name'], 'r'); if ($fh !== false) { $csv_file = array(); $index = array(); // Check first row, ingoring empty rows and get indices setup // while (($row = fgetcsv($fh, 5000, ",", "\"")) !== false) { if (count($row) == 1 && $row[0] == '') { continue; } else { $count = count($row) > 4 ? 4 : count($row); for ($i = 0; $i < $count; $i++) { switch (strtolower($row[$i])) { case 'prepend': case 'prefix': case 'match pattern': case 'callerid': $index[strtolower($row[$i])] = $i; break; default: break; } } // If no headers then assume standard order if (count($index) == 0) { $index['prepend'] = 0; $index['prefix'] = 1; $index['match pattern'] = 2; $index['callerid'] = 3; if ($count == 4) { $csv_file[] = $row; } } break; } } $row_count = count($index); while (($row = fgetcsv($fh, 5000, ",", "\"")) !== false) { if (count($row) == $row_count) { $csv_file[] = $row; } } } } // If we have a CSV file it replaces any existing patterns // if (!empty($csv_file)) { foreach ($csv_file as $row) { $this_prepend = isset($index['prepend']) ? htmlspecialchars(trim($row[$index['prepend']])) : ''; $this_prefix = isset($index['prefix']) ? htmlspecialchars(trim($row[$index['prefix']])) : ''; $this_match_pattern = isset($index['match pattern']) ? htmlspecialchars(trim($row[$index['match pattern']])) : ''; $this_callerid = isset($index['callerid']) ? htmlspecialchars(trim($row[$index['callerid']])) : ''; if ($this_prepend != '' || $this_prefix != '' || $this_match_pattern != '' || $this_callerid != '') { $dialpattern_insert[] = array('prepend_digits' => $this_prepend, 'match_pattern_prefix' => $this_prefix, 'match_pattern_pass' => $this_match_pattern, 'match_cid' => $this_callerid); } } } else { if (isset($request["prepend_digit"])) { $prepend_digit = $request["prepend_digit"]; $pattern_prefix = $request["pattern_prefix"]; $pattern_pass = $request["pattern_pass"]; $match_cid = $request["match_cid"]; foreach (array_keys($prepend_digit) as $key) { if ($prepend_digit[$key] != '' || $pattern_prefix[$key] != '' || $pattern_pass[$key] != '' || $match_cid[$key] != '') { $dialpattern_insert[] = array('prepend_digits' => htmlspecialchars(trim($prepend_digit[$key])), 'match_pattern_prefix' => htmlspecialchars(trim($pattern_prefix[$key])), 'match_pattern_pass' => htmlspecialchars(trim($pattern_pass[$key])), 'match_cid' => htmlspecialchars(trim($match_cid[$key]))); } } } else { if (isset($request["bulk_patterns"])) { $prepend = '/^([^+]*)\\+/'; $prefix = '/^([^|]*)\\|/'; $match_pattern = '/([^/]*)/'; $callerid = '/\\/(.*)$/'; $data = explode("\n", $request['bulk_patterns']); foreach ($data as $list) { if (preg_match('/^\\s*$/', $list)) { continue; } $this_prepend = $this_prefix = $this_callerid = ''; if (preg_match($prepend, $list, $matches)) { $this_prepend = $matches[1]; $list = preg_replace($prepend, '', $list); } if (preg_match($prefix, $list, $matches)) { $this_prefix = $matches[1]; $list = preg_replace($prefix, '', $list); } if (preg_match($callerid, $list, $matches)) { $this_callerid = $matches[1]; $list = preg_replace($callerid, '', $list); } $dialpattern_insert[] = array('prepend_digits' => htmlspecialchars(trim($this_prepend)), 'match_pattern_prefix' => htmlspecialchars(trim($this_prefix)), 'match_pattern_pass' => htmlspecialchars(trim($list)), 'match_cid' => htmlspecialchars(trim($this_callerid))); $i++; } } } } if (isset($request['reporoutedirection']) && $request['reporoutedirection'] != '' && isset($request['reporoutekey']) && $request['reporoutekey'] != '') { $request['route_seq'] = core_routing_setrouteorder($request['reporoutekey'], $request['reporoutedirection']); } $trunkpriority = array(); if (isset($request["trunkpriority"])) { $trunkpriority = $request["trunkpriority"]; if (!$trunkpriority) { $trunkpriority = array(); } // delete blank entries and reorder foreach (array_keys($trunkpriority) as $key) { if ($trunkpriority[$key] == '') { // delete this empty unset($trunkpriority[$key]); } else { if ($key == $repotrunkkey - 1 && $repotrunkdirection == "up") { // swap this one with the one before (move up) $temptrunk = $trunkpriority[$key]; $trunkpriority[$key] = $trunkpriority[$key + 1]; $trunkpriority[$key + 1] = $temptrunk; } else { if ($key == $repotrunkkey && $repotrunkdirection == "down") { // swap this one with the one after (move down) $temptrunk = $trunkpriority[$key + 1]; $trunkpriority[$key + 1] = $trunkpriority[$key]; $trunkpriority[$key] = $temptrunk; } } } } unset($temptrunk); $trunkpriority = array_unique(array_values($trunkpriority)); // resequence our numbers if ($action == '') { $action = "updatetrunks"; } } $routename = isset($request['routename']) ? $request['routename'] : ''; $routepass = isset($request['routepass']) ? $request['routepass'] : ''; $emergency = isset($request['emergency']) ? $request['emergency'] : ''; $intracompany = isset($request['intracompany']) ? $request['intracompany'] : ''; $mohsilence = isset($request['mohsilence']) ? $request['mohsilence'] : ''; $outcid = isset($request['outcid']) ? $request['outcid'] : ''; $outcid_mode = isset($request['outcid_mode']) ? $request['outcid_mode'] : ''; $time_group_id = isset($request['time_group_id']) ? $request['time_group_id'] : ''; $route_seq = isset($request['route_seq']) ? $request['route_seq'] : ''; $goto = isset($request['goto0']) ? $request['goto0'] : ''; $dest = $goto ? $request[$goto . '0'] : ''; //if submitting form, update database switch ($action) { case 'ajaxroutepos': $ret = core_routing_setrouteorder($repotrunkkey, $repotrunkdirection); needreload(); header("Content-type: application/json"); echo json_encode(array('position' => $ret)); exit; break; case "copyroute": $routename .= "_copy_{$extdisplay}"; $extdisplay = ''; $route_seq++; // Fallthrough to addtrunk now... // // Fallthrough to addtrunk now... // case "addroute": $extdisplay = core_routing_addbyid($routename, $outcid, $outcid_mode, $routepass, $emergency, $intracompany, $mohsilence, $time_group_id, $dialpattern_insert, $trunkpriority, $route_seq, $dest); needreload(); break; case "editroute": $extdisplay = $_REQUEST['id']; core_routing_editbyid($extdisplay, $routename, $outcid, $outcid_mode, $routepass, $emergency, $intracompany, $mohsilence, $time_group_id, $dialpattern_insert, $trunkpriority, $route_seq, $dest); needreload(); break; case "delroute": if (!function_exists('core_routing_delbyid')) { if (file_exists(__DIR__ . "/functions.inc.php")) { include __DIR__ . "/functions.inc.php"; } } $ret = core_routing_delbyid($_REQUEST['id']); // re-order the routes to make sure that there are no skipped numbers. // example if we have 001-test1, 002-test2, and 003-test3 then delete 002-test2 // we do not want to have our routes as 001-test1, 003-test3 we need to reorder them // so we are left with 001-test1, 002-test3 needreload(); return $ret; break; case "updatetrunks": $ret = core_routing_updatetrunks($extdisplay, $trunkpriority, true); header("Content-type: application/json"); echo json_encode(array('result' => $ret)); needreload(); exit; break; case 'prioritizeroute': needreload(); break; case 'getnpanxxjson': try { $npa = $request['npa']; $nxx = $request['nxx']; $url = 'http://www.localcallingguide.com/xmllocalprefix.php?npa=602&nxx=930'; $request = new \Pest('http://www.localcallingguide.com/xmllocalprefix.php'); $data = $request->get('?npa=' . $npa . '&nxx=' . $nxx); $xml = new \SimpleXMLElement($data); $pfdata = $xml->xpath('//lca-data/prefix'); $retdata = array(); foreach ($pfdata as $item) { $inpa = (string) $item->npa; $inxx = (string) $item->nxx; $retdata[$inpa . $inxx] = array('npa' => $inpa, 'nxx' => $inxx); } $ret = json_encode($retdata); header("Content-type: application/json"); echo $ret; exit; } catch (Pest_NotFound $e) { header("Content-type: application/json"); echo json_encode(array('error' => $e)); exit; } break; case 'populatenpanxx': $dialpattern_array = $dialpattern_insert; if (preg_match("/^([2-9]\\d\\d)-?([2-9]\\d\\d)\$/", $_REQUEST["npanxx"], $matches)) { // first thing we do is grab the exch: $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, "http://www.localcallingguide.com/xmllocalprefix.php?npa=" . $matches[1] . "&nxx=" . $matches[2]); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Linux; Ringfree PBX Local Trunks Configuration)"); $str = curl_exec($ch); curl_close($ch); // quick 'n dirty - nabbed from PEAR global $amp_conf; require_once $amp_conf['AMPWEBROOT'] . '/admin/modules/core/XML_Parser.php'; require_once $amp_conf['AMPWEBROOT'] . '/admin/modules/core/XML_Unserializer.php'; $xml = new xml_unserializer(); $xml->unserialize($str); $xmldata = $xml->getUnserializedData(); $hash_filter = array(); //avoid duplicates if (isset($xmldata['lca-data']['prefix'])) { // we do the loops separately so patterns are grouped together // match 1+NPA+NXX (dropping 1) foreach ($xmldata['lca-data']['prefix'] as $prefix) { if (isset($hash_filter['1' . $prefix['npa'] . $prefix['nxx']])) { continue; } else { $hash_filter['1' . $prefix['npa'] . $prefix['nxx']] = true; } $dialpattern_array[] = array('prepend_digits' => '', 'match_pattern_prefix' => '1', 'match_pattern_pass' => htmlspecialchars($prefix['npa'] . $prefix['nxx']) . 'XXXX', 'match_cid' => ''); } // match NPA+NXX foreach ($xmldata['lca-data']['prefix'] as $prefix) { if (isset($hash_filter[$prefix['npa'] . $prefix['nxx']])) { continue; } else { $hash_filter[$prefix['npa'] . $prefix['nxx']] = true; } $dialpattern_array[] = array('prepend_digits' => '', 'match_pattern_prefix' => '', 'match_pattern_pass' => htmlspecialchars($prefix['npa'] . $prefix['nxx']) . 'XXXX', 'match_cid' => ''); } // match 7-digits foreach ($xmldata['lca-data']['prefix'] as $prefix) { if (isset($hash_filter[$prefix['nxx']])) { continue; } else { $hash_filter[$prefix['nxx']] = true; } $dialpattern_array[] = array('prepend_digits' => '', 'match_pattern_prefix' => '', 'match_pattern_pass' => htmlspecialchars($prefix['nxx']) . 'XXXX', 'match_cid' => ''); } unset($hash_filter); } else { $errormsg = _("Error fetching prefix list for: ") . $request["npanxx"]; } } else { // what a horrible error message... :p $errormsg = _("Invalid format for NPA-NXX code (must be format: NXXNXX)"); } if (isset($errormsg)) { echo "<script language=\"javascript\">alert('" . addslashes($errormsg) . "');</script>"; unset($errormsg); } break; } } // $page == "routing" if ($page == "did") { $extdisplay = htmlspecialchars(isset($request['extdisplay']) ? $request['extdisplay'] : ''); $old_extdisplay = $extdisplay; $dispnum = 'did'; //used for switch on config.php $account = isset($request['account']) ? $request['account'] : ''; $action = isset($request['action']) ? $request['action'] : ''; $goto = isset($request['goto0']) ? $request['goto0'] : ''; $ringing = isset($request['ringing']) ? $request['ringing'] : ''; $reversal = isset($request['reversal']) ? $request['reversal'] : ''; $description = htmlspecialchars(isset($request['description']) ? $request['description'] : ''); $privacyman = isset($request['privacyman']) ? $request['privacyman'] : '0'; $pmmaxretries = isset($request['pmmaxretries']) ? $request['pmmaxretries'] : ''; $pmminlength = isset($request['pmminlength']) ? $request['pmminlength'] : ''; $alertinfo = htmlspecialchars(isset($request['alertinfo']) ? $request['alertinfo'] : ''); $mohclass = isset($request['mohclass']) ? $request['mohclass'] : 'default'; $grppre = isset($request['grppre']) ? $request['grppre'] : ''; $delay_answer = isset($request['delay_answer']) && $request['delay_answer'] ? $request['delay_answer'] : '0'; $pricid = isset($request['pricid']) ? $request['pricid'] : ''; $rnavsort = isset($request['rnavsort']) ? $request['rnavsort'] : 'description'; $didfilter = isset($request['didfilter']) ? $request['didfilter'] : ''; if (isset($request['submitclear']) && isset($request['goto0'])) { $request[$request['goto0'] . '0'] = ''; } if (isset($request['extension']) && isset($request['cidnum'])) { $extdisplay = $request['extension'] . "/" . $request['cidnum']; } if (isset($request['old_extension']) && isset($request['old_cidnum'])) { $old_extdisplay = $request['old_extension'] . "/" . $request['old_cidnum']; } //update db if submiting form switch ($action) { case 'addIncoming': //create variables from request extract($request, EXTR_SKIP); //add details to the 'incoming' table if (core_did_add($request)) { needreload(); $_REQUEST['extdisplay'] = $_REQUEST['extension'] . "/" . $_REQUEST['cidnum']; $this->freepbx->View->redirect_standard('extdisplay', 'didfilter', 'rnavsort'); } break; case 'delIncoming': $extarray = explode('/', $extdisplay, 2); core_did_del($extarray[0], $extarray[1]); needreload(); break; case 'edtIncoming': $extarray = explode('/', $old_extdisplay, 2); if (core_did_edit($extarray[0], $extarray[1], $_REQUEST)) { needreload(); } break; } } // $page == "did" if ($page == "astmodules") { $action = !empty($request['action']) ? $request['action'] : ""; $section = !empty($request['section']) ? $request['section'] : ""; $module = !empty($request['module']) ? $request['module'] : ""; switch ($action) { case 'add': switch ($section) { case 'amodload': $this->ModulesConf->load($module); return true; break; case 'amodnoload': $this->ModulesConf->noload($module); return true; break; case 'amodpreload': $this->ModulesConf->preload($module); return true; break; default: return false; break; } break; case 'del': switch ($section) { case 'amodnoload': $this->ModulesConf->removenoload($module); return true; break; case 'amodpreload': $this->ModulesConf->removepreload($module); return true; break; default: return false; break; } break; default: return false; break; } } // $page == "astmodules" }
break; case "populatenpanxx7": case "populatenpanxx10": $dialpattern_array = $dialpattern_insert; if (preg_match("/^([2-9]\\d\\d)-?([2-9]\\d\\d)\$/", $_REQUEST["npanxx"], $matches)) { // first thing we do is grab the exch: $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, "http://www.localcallingguide.com/xmllocalprefix.php?npa=" . $matches[1] . "&nxx=" . $matches[2]); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Linux; FreePBX Local Trunks Configuration)"); $str = curl_exec($ch); curl_close($ch); // quick 'n dirty - nabbed from PEAR require_once $amp_conf['AMPWEBROOT'] . '/admin/modules/core/XML_Parser.php'; require_once $amp_conf['AMPWEBROOT'] . '/admin/modules/core/XML_Unserializer.php'; $xml = new xml_unserializer(); $xml->unserialize($str); $xmldata = $xml->getUnserializedData(); if (isset($xmldata['lca-data']['prefix'])) { $hash_filter = array(); //avoid duplicates if ($action == 'populatenpanxx10') { // 10 digit dialing // - add area code to 7 digits // - match local 10 digits // - add 1 to anything else $dialpattern_array[] = array('prepend_digits' => '', 'match_pattern_prefix' => '', 'match_pattern_pass' => htmlspecialchars($matches[1] . 'NXXXXXX')); // add NPA to 7-digits foreach ($xmldata['lca-data']['prefix'] as $prefix) { if (isset($hash_filter[$prefix['npa'] . '+' . $prefix['nxx']])) { continue;
function sak_hook_core($viewing_itemid, $target_menuid) { global $db; $sak_settings =& $db->getAssoc("SELECT var_name, value FROM sak_settings"); $html = ''; $new_dial_patterns_section = ''; $extdisplay=isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:''; $action = isset($_REQUEST['action'])?$_REQUEST['action']:''; if ($target_menuid == 'routing') { $html .= '<tr><td colspan="2"> </td></tr>'; if($sak_settings['dial_plan']) { //$html .= '<tr><td colspan="2"><h5>'; //$html .= _("Bulk Dial Patterns"); //$html .= '<hr></h5></td></tr>'; $dp_html .= '<tr>'; $dp_html .= '<td><a href="#" class="info">'; $dp_html .= _("Source").'<span>'._("Each Pattern Should Be Entered On A New Line").'.</span></a>:</td>'; $dp_html .= '<td><textarea name="bulk_patterns" id="bulk_patterns" rows="10" cols="40">'; $dialpattern_list = array(); if ($_REQUEST['bulk_patterns']) { $dialpattern_list = split("\n", trim($_REQUEST['bulk_patterns'])); } else if($extdisplay != '') { $dial_patterns = core_routing_getroutepatternsbyid($_REQUEST['extdisplay']); foreach ($dial_patterns as $row) { $prepend = ($row['prepend_digits'] != '') ? $row['prepend_digits'].'+' : ''; $match_pattern_prefix = ($row['match_pattern_prefix'] != '') ? $row['match_pattern_prefix'].'|' : ''; $match_cid = ($row['match_cid'] != '') ? '/'.$row['match_cid'] : ''; $dialpattern_list[] = $prepend . $match_pattern_prefix . $row['match_pattern_pass'] . $match_cid; } } // Duplicated from core/page.routing.php // Unfortunately those values are not obtainable here if ($action == 'populatenpanxx') { if (preg_match("/^([2-9]\d\d)-?([2-9]\d\d)$/", $_REQUEST["npanxx"], $matches)) { // first thing we do is grab the exch: $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, "http://www.localcallingguide.com/xmllocalprefix.php?npa=".$matches[1]."&nxx=".$matches[2]); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Linux; FreePBX Local Trunks Configuration)"); $str = curl_exec($ch); curl_close($ch); // quick 'n dirty - nabbed from PEAR require_once($GLOBALS['amp_conf']['AMPWEBROOT'] . '/admin/modules/core/XML_Parser.php'); require_once($GLOBALS['amp_conf']['AMPWEBROOT'] . '/admin/modules/core/XML_Unserializer.php'); $xml = new xml_unserializer; $xml->unserialize($str); $xmldata = $xml->getUnserializedData(); $hash_filter = array(); //avoid duplicates if (isset($xmldata['lca-data']['prefix'])) { // we do the loops separately so patterns are grouped together // match 1+NPA+NXX (dropping 1) foreach ($xmldata['lca-data']['prefix'] as $prefix) { if (isset($hash_filter['1'.$prefix['npa'].$prefix['nxx']])) { continue; } else { $hash_filter['1'.$prefix['npa'].$prefix['nxx']] = true; } $dialpattern_list[] = '1'.htmlspecialchars($prefix['npa'].$prefix['nxx']).'XXXX'; } // match NPA+NXX foreach ($xmldata['lca-data']['prefix'] as $prefix) { if (isset($hash_filter[$prefix['npa'].$prefix['nxx']])) { continue; } else { $hash_filter[$prefix['npa'].$prefix['nxx']] = true; } $dialpattern_list[] = htmlspecialchars($prefix['npa'].$prefix['nxx']).'XXXX'; } // match 7-digits foreach ($xmldata['lca-data']['prefix'] as $prefix) { if (isset($hash_filter[$prefix['nxx']])) { continue; } else { $hash_filter[$prefix['nxx']] = true; } $dialpattern_list[] = htmlspecialchars($prefix['nxx']).'XXXX'; } unset($hash_filter); } else { //$errormsg = _("Error fetching prefix list for: "). $_REQUEST["npanxx"]; } } else { // Will get caught the second time loaded // what a horrible error message... :p //$errormsg = _("Invalid format for NPA-NXX code (must be format: NXXNXX)"); } // Will get caught the second time loaded /*if (isset($errormsg)) { echo "<script language=\"javascript\">alert('".addslashes($errormsg)."');</script>"; unset($errormsg); }*/ } $dp_html .= implode("\n", $dialpattern_list)."\n"; $dp_html .= '</textarea></td></tr>'; $dp_html .= '<tr><td colspan="2"> </td></tr>'; $pat_local = _("NXXXXXX"); $pat_local10 = _("NXXXXXX,NXXNXXXXXX"); $pat_tollfree = _("1800NXXXXXX,1888NXXXXXX,1877NXXXXXX,1866NXXXXXX,1855NXXXXXX"); $pat_ld = _("1NXXNXXXXXX"); $pat_int = _("011."); $pat_info = _("411,311"); $pat_emerg = _("911"); //$html .= $dp_html; $new_dial_patterns_section .= '<tr><td><a href="#" class="info">Source<span>Each Pattern Should Be Entered On A New Line.</span></a>:</td><td><textarea name="bulk_patterns" id="bulk_patterns" rows="10" cols="40">'.implode("\\n", $dialpattern_list).'</textarea></td></tr><tr><td colspan="2"> </td></tr>'; $html .= <<<xENDx <script type="text/javascript"> function insertIntoBulkPatterns() { // Mostly copied from core/page.routing.php code = document.getElementById('inscode').value; insert = ''; switch(code) { case "local": insert = '{$pat_local}'; break; case "local10": insert = '{$pat_local10}'; break; case 'tollfree': insert = '{$pat_tollfree}'; break; case "ld": insert = '{$pat_ld}'; break; case "int": insert = '{$pat_int}'; break; case 'info': insert = '{$pat_info}'; break; case 'emerg': insert = '{$pat_emerg}'; break; case 'lookup': populateLookup(); insert = ''; break; case 'csv': $('#pattern_file').show().click(); return true; break; } $('#bulk_patterns').val($('#bulk_patterns').val()+insert.split(',').join("\\n")+"\\n"); } $(document).ready(function(){ addCustomField('X','X','X','X'); $('#dial-pattern-add').hide(); $('#inscode').attr('onChange', ''); $('#inscode').bind('change', function(){insertIntoBulkPatterns();}); }); //Hijack into submit to combine the old dial patterns with the new in the future. Could still technically do both with server-side $('#routeEdit').submit(function() { return true; }); </script> xENDx; } if(($sak_settings['dial_plan_exp']) && ($viewing_itemid != '')) { $new_dial_patterns_section .= '<tr><td colspan="2"> </td></tr><tr><td colspan="2"><a href="config.php?type=tool&display=sak_advanced_settings&quietmode=1&orid='.$viewing_itemid.'" target="_blank">Click Here to Export All Dial Patterns for this Route</a></td></tr>'; } } if($new_dial_patterns_section != '') { $type = $sak_settings['dial_plan'] ? 'replaceWith' : 'append'; $html .= "<script type=\"text/javascript\"> $(document).ready(function(){ $('.dialpatterns').".$type."('".$new_dial_patterns_section."'); }); </script>"; } return $html; }