root/modules/branches/2.9/announcement/page.announcement.php

Revision 8662, 8.3 kB (checked in by mickecarlsson, 3 years ago)

Fixed a couple of spelling errors, updated language files for announcements

Line 
1 <?php
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 //    Announcments module for FreePBX 2.2+
18 //    Copyright 2006 Greg MacLellan
19
20 $action = isset($_POST['action']) ? $_POST['action'] :  '';
21 if (isset($_POST['delete'])) $action = 'delete';
22
23 $tabindex = 0;
24
25
26 $announcement_id = isset($_POST['announcement_id']) ? $_POST['announcement_id'] :  false;
27 $description = isset($_POST['description']) ? $_POST['description'] :  '';
28 $recording_id = isset($_POST['recording_id']) ? $_POST['recording_id'] :  '';
29 $allow_skip = isset($_POST['allow_skip']) ? $_POST['allow_skip'] :  0;
30 $return_ivr = isset($_POST['return_ivr']) ? $_POST['return_ivr'] :  0;
31 $noanswer = isset($_POST['noanswer']) ? $_POST['noanswer'] :  0;
32 $post_dest = isset($_POST['post_dest']) ? $_POST['post_dest'] :  '';
33 $repeat_msg = isset($_POST['repeat_msg']) ? $_POST['repeat_msg'] :  '';
34
35 if (isset($_POST['goto0']) && $_POST['goto0']) {
36     // 'ringgroup_post_dest'  'ivr_post_dest' or whatever
37     $post_dest = $_POST[ $_POST['goto0'].'0' ];
38 }
39
40
41 switch ($action) {
42     case 'add':
43         announcement_add($description, $recording_id, $allow_skip, $post_dest, $return_ivr, $noanswer, $repeat_msg);
44         needreload();
45         redirect_standard();
46     break;
47     case 'edit':
48         announcement_edit($announcement_id, $description, $recording_id, $allow_skip, $post_dest, $return_ivr, $noanswer, $repeat_msg);
49         needreload();
50         redirect_standard('extdisplay');
51     break;
52     case 'delete':
53         announcement_delete($announcement_id);
54         needreload();
55         redirect_standard();
56     break;
57 }
58
59
60 ?> 
61 </div>
62
63 <div class="rnav"><ul>
64 <?php
65 // Eventually I recon the drawListMenu could be built into the new component class thus making
66 // the relevent page.php file unnessassary
67
68 echo '<li><a href="config.php?display=announcement&amp;type=setup">'._('Add Announcement').'</a></li>';
69
70 foreach (announcement_list() as $row) {
71     echo '<li><a href="config.php?display=announcement&amp;type=setup&amp;extdisplay='.$row[0].'" class="">'.$row[1].'</a></li>';
72 }
73
74 ?>
75 </ul></div>
76
77 <div class="content">
78
79 <?php
80 if ($extdisplay) {
81     // load
82     $row = announcement_get($extdisplay);
83     
84     $description = $row['description'];
85     $recording_id = $row['recording_id'];
86     $allow_skip = $row['allow_skip'];
87     $post_dest = $row['post_dest'];
88     $return_ivr = $row['return_ivr'];
89     $noanswer = $row['noanswer'];
90     $repeat_msg = $row['repeat_msg'];
91
92 }
93
94 ?>
95 <form name="editAnnouncement" action="<?php  $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return checkAnnouncement(editAnnouncement);">
96             <input type="hidden" name="extdisplay" value="<?php echo $extdisplay; ?>">
97             <input type="hidden" name="announcement_id" value="<?php echo $extdisplay; ?>">
98             <input type="hidden" name="action" value="<?php echo ($extdisplay ? 'edit' : 'add'); ?>">
99             <table>
100             <tr><td colspan="2"><h5><?php  echo ($extdisplay ? _("Edit Announcement") : _("Add Announcement")) ?><hr></h5></td></tr>
101             <tr>
102                 <td><a href="#" class="info"><?php echo _("Description")?>:<span><?php echo _("The name of this announcement")?></span></a></td>
103                 <td><input size="15" type="text" name="description" value="<?php  echo $description; ?>" tabindex="<?php echo ++$tabindex;?>"></td>
104             </tr>
105
106 <?php if(function_exists('recordings_list')) { //only include if recordings is enabled?>
107     <tr>
108         <td><a href="#" class="info"><?php echo _("Recording")?><span><?php echo _("Message to be played.<br>To add additional recordings use the \"System Recordings\" MENU to the left")?></span></a></td>
109         <td>
110             <select name="recording_id"  tabindex="<?php echo ++$tabindex;?>">
111             <?php
112                 $tresults = recordings_list();
113                 $default = (isset($recording_id) ? $recording_id : '');
114                 if (isset($tresults[0])) {
115                     echo '<option value="">'._("None")."</option>\n";
116                     foreach ($tresults as $tresult) {
117                         echo '<option value="'.$tresult['id'].'"'.($tresult['id'] == $default ? ' SELECTED' : '').'>'.$tresult['displayname']."</option>\n";
118                     }
119                 }
120             ?>
121             </select>
122         </td>
123     </tr>
124 <?php } ?>
125     <tr>
126         <td><a href="#" class="info"><?php echo _("Repeat")?><span><?php echo _("Key to press that will allow for the message to be replayed. If you choose this option there will be a short delay inserted after the message. If a longer delay is needed it should be incorporated into the recording.")?></span></a></td>
127         <td>
128             <select name="repeat_msg"  tabindex="<?php echo ++$tabindex;?>">
129             <?php
130                 $default = isset($repeat_msg) ? $repeat_msg : '';
131                 for ($i=0; $i<=9; $i++ ) {
132                     $digits[]="$i";
133                 }
134                 $digits[] = '*';
135                 $digits[] = '#';
136                 echo '<option value=""'.($default == '' ? ' SELECTED' : '').'>'._("Disable")."</option>";
137                 foreach ($digits as $digit) {
138                     echo '<option value="'.$digit.'"'.($digit == $default ? ' SELECTED' : '').'>'.$digit."</option>\n";
139                 }
140             ?>
141             </select>
142         </td>
143     </tr>
144     <tr>
145         <td><a href="#" class="info"><?php echo _("Allow Skip")?><span><?php echo _("If the caller is allowed to press a key to skip the message.")?></span></a></td>
146         <td><input type="checkbox" name="allow_skip" value="1" tabindex="<?php echo ++$tabindex;?>" <?php echo ($allow_skip ? 'CHECKED' : ''); ?> /></td>
147     </tr>
148     <tr>
149         <td><a href="#" class="info"><?php echo _("Return to IVR")?><span><?php echo _("If this announcement came from an IVR and this box is checked, the destination below will be ignored and instead it will return to the calling IVR. Otherwise, the destination below will be taken. Don't check if not using in this mode. <br>The IVR return location will be to the last IVR in the call chain that was called so be careful to only check when needed. For example, if an IVR directs a call to another destination which eventually calls this announcement and this box is checked, it will return to that IVR which may not be the expected behavior.")?></span></a></td>
150         <td><input type="checkbox" name="return_ivr" value="1" tabindex="<?php echo ++$tabindex;?>" <?php echo ($return_ivr ? 'CHECKED' : ''); ?> /></td>
151     </tr>
152     <tr>
153         <td><a href="#" class="info"><?php echo _("Don't Answer Channel")?><span><?php echo _("Check this to keep the channel from explicitly being answered. When checked, the message will be played and if the channel is not already answered it will be delivered as early media if the channel supports that. When not checked, the channel is answered followed by a 1 second delay. When using an announcement from an IVR or other sources that have already answered the channel, that 1 second delay may not be desired.")?></span></a></td>
154         <td><input type="checkbox" name="noanswer" value="1" tabindex="<?php echo ++$tabindex;?>" <?php echo ($noanswer ? 'CHECKED' : ''); ?> /></td>
155     </tr>
156    
157     <tr><td colspan="2"><br><h5><?php echo _("Destination after playback")?>:<hr></h5></td></tr>
158
159 <?php
160 //draw goto selects
161 echo drawselects($post_dest,0);
162 ?>
163            
164             <tr>
165             <td colspan="2"><br><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>" tabindex="<?php echo ++$tabindex;?>">
166             <?php if ($extdisplay) { echo '&nbsp;<input name="delete" type="submit" value="'._("Delete").'">'; } ?>
167             </td>       
168            
169             </tr>
170             <?php
171
172             if ($extdisplay) {
173                 $usage_list = framework_display_destination_usage(announcement_getdest($extdisplay));
174                 if (!empty($usage_list)) {
175                 ?>
176                     <tr><td colspan="2">
177                     <a href="#" class="info"><?php echo $usage_list['text']?>:<span><?php echo $usage_list['tooltip']?></span></a>
178                     </td></tr>
179                 <?php
180                 }
181             }
182             ?>
183             </table>
184             </form>
185            
186            
187 <script language="javascript">
188 <!--
189
190 function checkAnnouncement(theForm) {
191     var msgInvalidDescription = "<?php echo _('Invalid description specified'); ?>";
192
193     // set up the Destination stuff
194     setDestinations(theForm, '_post_dest');
195
196     // form validation
197     defaultEmptyOK = false;   
198     if (isEmpty(theForm.description.value))
199         return warnInvalid(theForm.description, msgInvalidDescription);
200
201     if (!validateDestinations(theForm, 1, true))
202         return false;
203
204     return true;
205 }
206 //-->
207 </script>
208
Note: See TracBrowser for help on using the browser.