Changeset 10159
- Timestamp:
- 07/15/10 18:31:36 (3 years ago)
- Files:
-
- modules/branches/2.9/core/core.css (modified) (1 diff)
- modules/branches/2.9/core/page.routing.php (modified) (7 diffs)
- modules/branches/2.9/core/page.trunks.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.9/core/core.css
r9653 r10159 11 11 max-height: 15em; 12 12 max-width: 100%; 13 width: 500px; 13 14 overflow: auto; 14 15 border: 1px solid #CCCCCC; 15 16 } 16 17 #pattern_file { 18 display: none; 19 } modules/branches/2.9/core/page.routing.php
r9965 r10159 30 30 $repotrunkkey = isset($_REQUEST['repotrunkkey'])?$_REQUEST['repotrunkkey']:''; 31 31 32 // Check if they uploaded a CSV file for their route patterns 33 // 34 if (isset($_FILES['pattern_file']) && $_FILES['pattern_file']['tmp_name'] != '') { 35 $fh = fopen($_FILES['pattern_file']['tmp_name'], 'r'); 36 if ($fh !== false) { 37 $csv_file = array(); 38 $index = array(); 39 40 // Check first row, ingoring empty rows and get indices setup 41 // 42 while (($row = fgetcsv($fh, 5000, ",", "\"")) !== false) { 43 if (count($row) == 1 && $row[0] == '') { 44 continue; 45 } else { 46 $count = count($row) > 4 ? 4 : count($row); 47 for ($i=0;$i<$count;$i++) { 48 switch (strtolower($row[$i])) { 49 case 'prepend': 50 case 'prefix': 51 case 'match pattern': 52 case 'callerid': 53 $index[strtolower($row[$i])] = $i; 54 break; 55 default: 56 break; 57 } 58 } 59 // If no headers then assume standard order 60 if (count($index) == 0) { 61 $index['prepend'] = 0; 62 $index['prefix'] = 1; 63 $index['match pattern'] = 2; 64 $index['callerid'] = 3; 65 if ($count == 4) { 66 $csv_file[] = $row; 67 } 68 } 69 break; 70 } 71 } 72 $row_count = count($index); 73 while (($row = fgetcsv($fh, 5000, ",", "\"")) !== false) { 74 if (count($row) == $row_count) { 75 $csv_file[] = $row; 76 } 77 } 78 } 79 } 80 32 81 // 33 82 // Use a hash of the value inserted to get rid of duplicates … … 36 85 $n_idx = 0; 37 86 38 if (isset($_POST["prepend_digit"])) { 87 // If we have a CSV file it replaces any existing patterns 88 // 89 if (!empty($csv_file)) { 90 foreach ($csv_file as $row) { 91 $this_prepend = isset($index['prepend']) ? htmlspecialchars(trim($row[$index['prepend']])) : ''; 92 $this_prefix = isset($index['prefix']) ? htmlspecialchars(trim($row[$index['prefix']])) : ''; 93 $this_match_pattern = isset($index['match pattern']) ? htmlspecialchars(trim($row[$index['match pattern']])) : ''; 94 $this_callerid = isset($index['callerid']) ? htmlspecialchars(trim($row[$index['callerid']])) : ''; 95 96 if ($this_prepend != '' || $this_prefix != '' || $this_match_pattern != '' || $this_callerid != '') { 97 $dialpattern_insert[] = array( 98 'prepend_digits' => $this_prepend, 99 'match_pattern_prefix' => $this_prefix, 100 'match_pattern_pass' => $this_match_pattern, 101 'match_cid' => $this_callerid, 102 ); 103 } 104 } 105 } else if (isset($_POST["prepend_digit"])) { 39 106 $prepend_digit = $_POST["prepend_digit"]; 40 107 $pattern_prefix = $_POST["pattern_prefix"]; … … 336 403 } 337 404 ?> 338 <form autocomplete="off" id="routeEdit" name="routeEdit" action="config.php" method="POST" onsubmit="return routeEdit_onsubmit('<?php echo ($extdisplay != '' ? "editroute" : "addroute") ?>');">405 <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") ?>');"> 339 406 <input type="hidden" name="display" value="<?php echo $display?>"/> 340 407 <input type="hidden" name="extdisplay" value="<?php echo $extdisplay ?>"/> … … 521 588 <?php echo _("These options provide a quick way to add outbound dialing rules. Follow the prompts for each.")?><br> 522 589 <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> 590 <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> 523 591 </span></a>: 524 592 <input id="npanxx" name="npanxx" type="hidden" /> … … 549 617 550 618 function insertCode() { 619 // hide the file box if nothing was set 620 if ($('#pattern_file').val() == '') { 621 $('#pattern_file').hide(); 622 } 551 623 code = document.getElementById('inscode').value; 552 624 insert = ''; … … 577 649 insert = ''; 578 650 break; 651 case 'csv': 652 $('#pattern_file').show().click(); 653 return true; 654 break; 579 655 } 580 656 … … 600 676 <option value="emerg"><?php echo _("Emergency")?></option> 601 677 <option value="lookup"><?php echo _("Lookup local prefixes")?></option> 678 <option value="csv"><?php echo _("Upload from CSV")?></option> 602 679 </select> 680 <input type="file" name="pattern_file" id="pattern_file" tabindex="<?php echo ++$tabindex;?>"/> 603 681 </td> 604 682 </tr> modules/branches/2.9/core/page.trunks.php
r9975 r10159 42 42 $failtrunk_enable = ($failtrunk == "")?'':'CHECKED'; 43 43 44 // Check if they uploaded a CSV file for their route patterns 45 // 46 if (isset($_FILES['pattern_file']) && $_FILES['pattern_file']['tmp_name'] != '') { 47 $fh = fopen($_FILES['pattern_file']['tmp_name'], 'r'); 48 if ($fh !== false) { 49 $csv_file = array(); 50 $index = array(); 51 52 // Check first row, ingoring empty rows and get indices setup 53 // 54 while (($row = fgetcsv($fh, 5000, ",", "\"")) !== false) { 55 if (count($row) == 1 && $row[0] == '') { 56 continue; 57 } else { 58 $count = count($row) > 3 ? 3 : count($row); 59 for ($i=0;$i<$count;$i++) { 60 switch (strtolower($row[$i])) { 61 case 'prepend': 62 case 'prefix': 63 case 'match pattern': 64 $index[strtolower($row[$i])] = $i; 65 break; 66 default: 67 break; 68 } 69 } 70 // If no headers then assume standard order 71 if (count($index) == 0) { 72 $index['prepend'] = 0; 73 $index['prefix'] = 1; 74 $index['match pattern'] = 2; 75 if ($count == 3) { 76 $csv_file[] = $row; 77 } 78 } 79 break; 80 } 81 } 82 $row_count = count($index); 83 while (($row = fgetcsv($fh, 5000, ",", "\"")) !== false) { 84 if (count($row) == $row_count) { 85 $csv_file[] = $row; 86 } 87 } 88 } 89 freepbx_debug($index); 90 freepbx_debug($csv_file); 91 } 92 44 93 // 45 94 // Use a hash of the value inserted to get rid of duplicates … … 48 97 $n_idx = 0; 49 98 50 if (isset($_POST["prepend_digit"])) { 99 // If we have a CSV file it replaces any existing patterns 100 // 101 if (!empty($csv_file)) { 102 foreach ($csv_file as $row) { 103 $this_prepend = isset($index['prepend']) ? htmlspecialchars(trim($row[$index['prepend']])) : ''; 104 $this_prefix = isset($index['prefix']) ? htmlspecialchars(trim($row[$index['prefix']])) : ''; 105 $this_match_pattern = isset($index['match pattern']) ? htmlspecialchars(trim($row[$index['match pattern']])) : ''; 106 107 if ($this_prepend != '' || $this_prefix != '' || $this_match_pattern != '') { 108 $dialpattern_insert[] = array( 109 'prepend_digits' => $this_prepend, 110 'match_pattern_prefix' => $this_prefix, 111 'match_pattern_pass' => $this_match_pattern, 112 ); 113 } 114 } 115 } else if (isset($_POST["prepend_digit"])) { 51 116 $prepend_digit = $_POST["prepend_digit"]; 52 117 $pattern_prefix = $_POST["pattern_prefix"]; … … 403 468 ?> 404 469 405 <form name="trunkEdit" action="config.php" method="post" onsubmit="return trunkEdit_onsubmit('<?php echo ($extdisplay ? "edittrunk" : "addtrunk") ?>');">470 <form enctype="multipart/form-data" name="trunkEdit" action="config.php" method="post" onsubmit="return trunkEdit_onsubmit('<?php echo ($extdisplay ? "edittrunk" : "addtrunk") ?>');"> 406 471 <input type="hidden" name="display" value="<?php echo $display?>"/> 407 472 <input type="hidden" name="extdisplay" value="<?php echo $extdisplay ?>"/> … … 557 622 <strong><?php echo _("Setup Google for directory assistance")?></strong> <?php echo _("is useful to translate a call to directory assistance (default: 411) to Google's toll free directory (default: 18004664411) or any other number of your choosing")?><br> 558 623 <strong><?php echo _("Lookup numbers for local trunk")?></strong> <?php echo _("This looks up your local number on www.localcallingguide.com (NA-only), and sets up so you can dial either 7 or 10 digits (regardless of what your PSTN is) on a local trunk (where you have to dial 1+area code for long distance, but only 5551234 (7-digit dialing) or 6135551234 (10-digit dialing) for local calls")?><br> 624 <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 3 columns of patterns in the same order as in the GUI. You can also supply headers: %s, %s and %s in the first row. If there are less then 3 recognized headers then the remaining columns will be blank"),'<strong>prepend</strong>','<strong>prefix</strong>','<strong>match pattern</strong>')?><br> 559 625 </span></a>: 560 626 </td><td valign="top"><select id="autopop" tabindex="<?php echo ++$tabindex;?>" name="autopop" onChange="changeAutoPop(); "> … … 565 631 <option value="lookup7"><?php echo _("Lookup numbers for local trunk (7-digit dialing)")?></option> 566 632 <option value="lookup10"><?php echo _("Lookup numbers for local trunk (10-digit dialing)")?></option> 633 <option value="csv"><?php echo _("Upload from CSV")?></option> 567 634 </select> 635 <input type="file" name="pattern_file" id="pattern_file" tabindex="<?php echo ++$tabindex;?>"/> 568 636 </td> 569 637 </tr> … … 663 731 function changeAutoPop() { 664 732 var idx = false; 733 // hide the file box if nothing was set 734 if ($('#pattern_file').val() == '') { 735 $('#pattern_file').hide(); 736 } 665 737 switch(document.getElementById('autopop').value) { 666 738 case "always": … … 688 760 populateLookup(10); 689 761 break; 762 case 'csv': 763 $('#pattern_file').show().click(); 764 return true; 765 break; 690 766 } 691 767 document.getElementById('autopop').value = '';
