root/modules/branches/2.10/core/page.zapchandids.php

Revision 12852, 6.3 kB (checked in by p_lindheimer, 2 years ago)

update for publish

Line 
1 <?php
2 // Zap Channel DIDs display for FreePBX
3 // This file is part of FreePBX.
4 //
5 //    FreePBX is free software: you can redistribute it and/or modify
6 //    it under the terms of the GNU General Public License as published by
7 //    the Free Software Foundation, either version 2 of the License, or
8 //    (at your option) any later version.
9 //
10 //    FreePBX is distributed in the hope that it will be useful,
11 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //    GNU General Public License for more details.
14 //
15 //    You should have received a copy of the GNU General Public License
16 //    along with FreePBX.  If not, see <http://www.gnu.org/licenses/>.
17 // Copyright 2006 Philippe Lindheimer - Astrogen LLC
18 if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); }
19
20 $display = 'zapchandids';
21 $type = isset($_REQUEST['type']) ? $_REQUEST['type'] :  'setup';
22 $action = isset($_REQUEST['action']) ? $_REQUEST['action'] :  '';
23 if (isset($_REQUEST['delete'])) $action = 'delete';
24
25
26 $extdisplay  = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : '';
27 $channel     = isset($_REQUEST['channel']) ? $_REQUEST['channel'] :  false;
28 $description = isset($_REQUEST['description']) ? $_REQUEST['description'] :  '';
29 $did         = isset($_REQUEST['did']) ? $_REQUEST['did'] :  '';
30
31 switch ($action) {
32     case 'add':
33         if (core_zapchandids_add($description, $channel, $did)) {
34             needreload();
35             redirect_standard();
36         }
37     break;
38     case 'edit':
39         if (core_zapchandids_edit($description, $channel, $did)) {
40             needreload();
41             redirect_standard('extdisplay');
42         }
43     break;
44     case 'delete':
45         core_zapchandids_delete($channel);
46         needreload();
47         redirect_standard();
48     break;
49 }
50
51
52 ?> 
53
54 <div class="rnav"><ul>
55 <?php
56
57 echo '<li><a href="config.php?display='.$display.'&type='.$type.'">'._('Add Channel').'</a></li>';
58
59 foreach (core_zapchandids_list() as $row) {
60     echo '<li><a href="config.php?display='.$display.'&type='.$type.'&extdisplay='.$row['channel'].'" class="">'.$row['channel'].': '.$row['description'].'</a></li>';
61 }
62
63 ?>
64 </ul></div>
65
66 <?php
67
68 if ($extdisplay != '') {
69     // load
70     $row = core_zapchandids_get($extdisplay);
71     
72     $description = $row['description'];
73     $channel     = $row['channel'];
74     $did         = $row['did'];
75
76     echo "<h2>"._("Edit Zap Channel: ").$channel."</h2>";
77 } else {
78     echo "<h2>"._("Add Zap Channel")."</h2>";
79 }
80
81 $helptext = _("Zap Channel DIDs allow you to assign a DID to specific Zap Channels. You can supply the same DID to multiple channels. This would be a common scenario if you have multiple POTS lines that are on a hunt group from your provider. You MUST assign the channel's context to from-zaptel for these settings to have effect. It will be a line that looks like:<br /><br />context = from-zaptel<br /><br />in your zapata.conf configuration effecting the specified channel(s). Once you have assigned DIDs you can use standard Inbound Routes with the specified DIDs to route your calls.");
82 echo "<p>".$helptext."</p>\n";
83 ?>
84 <form name="editZapchandid" action="<?php  $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return checkZapchandid(editZapchandid);">
85     <input type="hidden" name="extdisplay" value="<?php echo $extdisplay; ?>">
86     <input type="hidden" name="channel" value="<?php echo $extdisplay; ?>">
87     <input type="hidden" name="action" value="<?php echo ($extdisplay != '' ? 'edit' : 'add'); ?>">
88     <table>
89     <tr><td colspan="2"><h5><?php  echo ($extdisplay != '' ? _("Edit Channel").": ".$extdisplay : _("Add Channel")) ?><hr></h5></td></tr>
90 <?php
91     if ($extdisplay == '') {
92 ?>
93     <tr>
94         <td><a href="#" class="info"><?php echo _("Channel")?>:<span><?php echo _("The Zap Channel number to map to a DID")?></span></a></td>
95         <td><input size="5" type="text" name="channel" value="<?php  echo $channel; ?>" tabindex="<?php echo ++$tabindex;?>"></td>
96     </tr>
97 <?php
98     }
99 ?>
100     <tr>
101         <td><a href="#" class="info"><?php echo _("Description")?>:<span><?php echo _("A useful description describing this channel")?></span></a></td>
102         <td><input size="40" type="text" name="description" value="<?php  echo $description; ?>" tabindex="<?php echo ++$tabindex;?>"></td>
103     </tr>
104     <tr>
105         <td><a href="#" class="info"><?php echo _("DID")?>:<span><?php echo _("The DID that this channel represents. The incoming call on this channel will be treated as if it came in with this DID and can be managed with Inbound Routing on DIDs")?></span></a></td>
106         <td><input size="40" type="text" name="did" value="<?php echo $did; ?>"  tabindex="<?php echo ++$tabindex;?>"/></td>
107     </tr>
108
109     <tr>
110         <td colspan="2"><br><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>" tabindex="<?php echo ++$tabindex;?>">
111             <?php if ($extdisplay != '') { echo '&nbsp;<input name="delete" type="submit" onclick="actionDelete=true;" value="'._("Delete").'">'; } ?>
112         </td>       
113
114     </tr>
115     </table>
116 </form>
117            
118            
119 <script language="javascript">
120 <!--
121
122 var actionDelete = false;
123
124 function checkZapchandid(theForm) {
125     var msgInvalidChannel = "<?php echo _('Invalid Channel Number, must be numeric and not blank'); ?>";
126     var msgInvalidDID = "<?php echo _('Invalid DID, must be a non-blank DID'); ?>";
127     var msgConfirmDIDNonStd = "<?php echo _('DID information is normally just an incoming telephone number.\n\nYou have entered a non standard DID pattern.\n\nAre you sure this is correct?'); ?>";
128     var msgConfirmConvertDID = "<?php echo _('You appear to be using a converted DID in the form of zapchanNN that was automatically generated during an upgrade. You should consider assigning the DID that is normally associated with this channel to take full advantage of the inbound routing abilities. Changing the DID here will require you to make changes in the Inbound Routes tab. Do you want to continue?'); ?>";
129
130
131     // If deleting we don't care what is in the elements
132     if (actionDelete) {
133         actionDelete = false;
134         return true;
135     }
136     // form validation
137
138     defaultEmptyOK = false;
139     if (!isInteger(theForm.channel.value)) {
140         return warnInvalid(theForm.channel, msgInvalidChannel);
141     }
142     if (isEmpty(theForm.did.value)) {
143         return warnInvalid(theForm.did, msgInvalidDID);
144     }
145     if (theForm.did.value.substring(0,7) == "zapchan") {
146         if (!confirm(msgConfirmConvertDID)) {
147             return false;
148         }
149
150     } else if (!isDialpattern(theForm.did.value)) {
151         if (!confirm(msgConfirmDIDNonStd)) {
152             return false;
153         }
154     }
155
156     return true;
157 }
158 //-->
159 </script>
160
Note: See TracBrowser for help on using the browser.