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

Revision 11884, 56.0 kB (checked in by mickecarlsson, 2 years ago)

Standardize on CallerID

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php /* $Id$ */
2 //Copyright (C) 2004 Coalescent Systems Inc. (info@coalescentsystems.ca)
3 //
4 //This program is free software; you can redistribute it and/or
5 //modify it under the terms of the GNU General Public License
6 //as published by the Free Software Foundation; either version 2
7 //of the License, or (at your option) any later version.
8 //
9 //This program 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 //used for switch on config.php
15 $dispnum = 'queues';
16
17 isset($_REQUEST['action'])?$action = $_REQUEST['action']:$action='';
18 //the extension we are currently displaying
19 isset($_REQUEST['extdisplay'])?$extdisplay=$_REQUEST['extdisplay']:$extdisplay='';
20 isset($_REQUEST['account'])?$account = $_REQUEST['account']:$account='';
21 isset($_REQUEST['name'])?$name = $_REQUEST['name']:$name='';
22 isset($_REQUEST['password'])?$password = $_REQUEST['password']:$password='';
23 isset($_REQUEST['agentannounce_id'])?$agentannounce_id = $_REQUEST['agentannounce_id']:$agentannounce_id='';
24 isset($_REQUEST['prefix'])?$prefix = $_REQUEST['prefix']:$prefix='';
25 isset($_REQUEST['alertinfo'])?$alertinfo = $_REQUEST['alertinfo']:$alertinfo='';
26 isset($_REQUEST['joinannounce_id'])?$joinannounce_id = $_REQUEST['joinannounce_id']:$joinannounce_id='';
27 $maxwait = isset($_REQUEST['maxwait'])?$_REQUEST['maxwait']:'';
28 $cwignore = isset($_REQUEST['cwignore'])?$_REQUEST['cwignore']:'0';
29 $queuewait = isset($_REQUEST['queuewait'])?$_REQUEST['queuewait']:'0';
30 $rtone = isset($_REQUEST['rtone'])?$_REQUEST['rtone']:'0';
31 $qregex = isset($_REQUEST['qregex'])?$_REQUEST['qregex']:'';
32 $weight = isset($_REQUEST['weight'])?$_REQUEST['weight']:'0';
33 $autofill = isset($_REQUEST['autofill'])?$_REQUEST['autofill']:'no';
34 $togglehint = isset($_REQUEST['togglehint'])?$_REQUEST['togglehint']:'0';
35 $dynmemberonly = isset($_REQUEST['dynmemberonly'])?$_REQUEST['dynmemberonly']:'no';
36 $use_queue_context = isset($_REQUEST['use_queue_context'])?$_REQUEST['use_queue_context']:'0';
37 $exten_context = "from-queue";
38 $qnoanswer = isset($_REQUEST['qnoanswer'])?$_REQUEST['qnoanswer']:'0';
39 $callconfirm = isset($_REQUEST['callconfirm'])?$_REQUEST['callconfirm']:'0';
40 $callconfirm_id = isset($_REQUEST['callconfirm_id'])?$_REQUEST['callconfirm_id']:'';
41 $monitor_type = isset($_REQUEST['monitor_type'])?$_REQUEST['monitor_type']:'';
42 $monitor_heard = isset($_REQUEST['monitor_heard'])?$_REQUEST['monitor_heard']:'0';
43 $monitor_spoken = isset($_REQUEST['monitor_spoken'])?$_REQUEST['monitor_spoken']:'0';
44
45 $engineinfo = engine_getinfo();
46 $astver $engineinfo['version'];
47 $ast_ge_16 = version_compare($astver, '1.6', 'ge');
48 $ast_ge_162 = version_compare($astver, '1.6.2', 'ge');
49 $ast_ge_18 = version_compare($astver, '1.8', 'ge');
50
51 if (isset($_REQUEST['goto0']) && isset($_REQUEST[$_REQUEST['goto0']."0"])) {
52     $goto = $_REQUEST[$_REQUEST['goto0']."0"];
53 } else {
54     $goto = '';
55 }
56 if (isset($_REQUEST["members"])) {
57     $members = explode("\n",$_REQUEST["members"]);
58
59     if (!$members) {
60         $members = null;
61     }
62     
63     foreach (array_keys($members) as $key) {
64         //trim it
65         $members[$key] = trim($members[$key]);
66
67         // check if an agent (starts with a or A)
68
69     $exten_prefix = strtoupper(substr($members[$key],0,1));
70         $this_member = preg_replace("/[^0-9#\,*]/", "", $members[$key]);
71     switch ($exten_prefix) {
72     case 'A':
73       $exten_type = 'Agent';
74       break;
75     case 'S':
76       $exten_type = 'SIP';
77       break;
78     case 'X':
79       $exten_type = 'IAX2';
80       break;
81     case 'Z':
82       $exten_type = 'ZAP';
83       break;
84     case 'D':
85       $exten_type = 'DAHDI';
86       break;
87     default;
88       $exten_type = 'Local';
89     }
90
91         $penalty_pos = strrpos($this_member, ",");
92         if ( $penalty_pos === false ) {
93                 $penalty_val = 0;
94         } else {
95                 $penalty_val = substr($this_member, $penalty_pos+1); // get penalty
96                 $this_member = substr($this_member,0,$penalty_pos); // clean up ext
97                 $this_member = preg_replace("/[^0-9#*]/", "", $this_member); //clean out other ,'s
98                 $penalty_val = preg_replace("/[^0-9*]/", "", $penalty_val); // get rid of #'s if there
99                 $penalty_val = ($penalty_val == "") ? 0 : $penalty_val;
100         }
101
102         // remove blanks // prefix with the channel
103         if (empty($this_member)) 
104             unset($members[$key]);
105         else {
106       switch($exten_type) {
107         case 'Agent':
108         case 'SIP':
109         case 'IAX2':
110         case 'ZAP':
111         case 'DAHDI':
112                 $members[$key] = "$exten_type/$this_member,$penalty_val";
113           break;
114         case 'Local':
115                 $members[$key] = "$exten_type/$this_member@$exten_context/n,$penalty_val";
116       }
117         }
118     }
119     // check for duplicates, and re-sequence
120     // $members = array_values(array_unique($members));
121 }
122
123 if (isset($_REQUEST["dynmembers"])) {
124     $dynmembers=explode("\n",$_REQUEST["dynmembers"]);
125     if (!$dynmembers) {
126         $dynmembers = null;
127     }
128 }
129
130
131 // do if we are submitting a form
132 if(isset($_POST['action'])){
133     //check if the extension is within range for this user
134     if (isset($account) && !checkRange($account)){
135         echo "<script>javascript:alert('"._("Warning! Extension")." $account "._("is not allowed for your account.")."');</script>";
136     } else {
137         
138         //if submitting form, update database
139         switch ($action) {
140             case "add":
141                 $conflict_url = array();
142                 $usage_arr = framework_check_extension_usage($account);
143                 if (!empty($usage_arr)) {
144                     $conflict_url = framework_display_extension_usage_alert($usage_arr);
145                 } else {
146                     queues_add($account,$name,$password,$prefix,$goto,$agentannounce_id,$members,$joinannounce_id,$maxwait,$alertinfo,$cwignore,$qregex,$queuewait,$use_queue_context,$dynmembers,$dynmemberonly,$togglehint,$qnoanswer, $callconfirm, $callconfirm_id, $monitor_type, $monitor_heard, $monitor_spoken);
147                     needreload();
148           $_REQUEST['extdisplay'] = $account;
149                     redirect_standard('extdisplay');
150                 }
151             break;
152             case "delete":
153                 queues_del($account);
154                 needreload();
155                 redirect_standard();
156             break;
157             case "edit"//just delete and re-add
158                 queues_del($account);
159                 queues_add($account,$name,$password,$prefix,$goto,$agentannounce_id,$members,$joinannounce_id,$maxwait,$alertinfo,$cwignore,$qregex,$queuewait,$use_queue_context,$dynmembers,$dynmemberonly,$togglehint,$qnoanswer, $callconfirm, $callconfirm_id, $monitor_type, $monitor_heard, $monitor_spoken);
160                 needreload();
161                 redirect_standard('extdisplay');
162             break;
163         }
164     }
165 }
166
167 //get unique queues
168 $queues = queues_list();
169     
170 ?>
171 </div>
172
173 <div class="rnav"><ul>
174     <li><a id="<?php echo ($extdisplay=='' ? 'current':'') ?>" href="config.php?display=<?php echo urlencode($dispnum)?>"><?php echo _("Add Queue")?></a></li>
175 <?php
176 if (isset($queues)) {
177     foreach ($queues as $queue) {
178         echo "<li><a id=\"".($extdisplay==$queue[0] ? 'current':'')."\" href=\"config.php?display=".urlencode($dispnum)."&extdisplay=".urlencode($queue[0])."\">{$queue[0]}:{$queue[1]}</a></li>";
179     }
180 }
181 ?>
182 </ul>
183 </div>
184
185 <div class="content">
186 <?php
187 if ($action == 'delete') {
188     echo '<br><h3>'._("Queue").' '.$account.' '._("deleted").'!</h3><br><br><br><br><br><br><br><br>';
189 } else {
190     $member = array();
191     //get members in this queue
192     $thisQ = queues_get($extdisplay);
193     //create variables
194     extract($thisQ);
195
196   $mem_array = array();
197   foreach ($member as $mem) {
198     if (preg_match("/^(Local|Agent|SIP|DAHDI|ZAP|IAX2)\/([\d]+).*,([\d]+)$/",$mem,$matches)) {
199       switch ($matches[1]) {
200         case 'Agent':
201           $exten_prefix = 'A';
202           break;
203         case 'SIP':
204           $exten_prefix = 'S';
205           break;
206         case 'IAX2':
207           $exten_prefix = 'X';
208           break;
209         case 'ZAP':
210           $exten_prefix = 'Z';
211           break;
212         case 'DAHDI':
213           $exten_prefix = 'D';
214           break;
215         case 'Local':
216           $exten_prefix = '';
217           break;
218       }
219       $mem_array[] = $exten_prefix.$matches[2].','.$matches[3];
220     }
221   }
222     
223     $delButton = "
224                 <form name=delete action=\"{$_SERVER['PHP_SELF']}\" method=POST>
225                     <input type=\"hidden\" name=\"display\" value=\"{$dispnum}\">
226                     <input type=\"hidden\" name=\"account\" value=\"{$extdisplay}\">
227                     <input type=\"hidden\" name=\"action\" value=\"delete\">
228                     <input type=submit value=\""._("Delete Queue")."\">
229                 </form>";
230 ?>
231
232 <?php if (!empty($conflict_url)) {
233           echo "<h5>"._("Conflicting Extensions")."</h5>";
234           echo implode('<br .>',$conflict_url);
235       }
236 ?>
237 <?php if ($extdisplay != '') { ?>
238     <h2><?php echo _("Queue:")." ". $extdisplay; ?></h2>
239 <?php } else { ?>
240     <h2><?php echo _("Add Queue"); ?></h2>
241 <?php } ?>
242
243 <?php        if ($extdisplay != '') {
244                     echo $delButton;
245                     $usage_list = framework_display_destination_usage(queues_getdest($extdisplay));
246                     if (!empty($usage_list)) {
247 ?>
248                         <a href="#" class="info"><?php echo $usage_list['text']?>:<span><?php echo $usage_list['tooltip']?></span></a>
249 <?php
250                     }
251                 }
252 ?>
253     <form autocomplete="off" name="editQ" action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
254     <input type="hidden" name="display" value="<?php echo $dispnum?>">
255     <input type="hidden" name="action" value="<?php echo (($extdisplay != '') ? 'edit' : 'add') ?>">
256     <table>
257     <tr><td colspan="2"><h5><?php echo ($extdisplay ? _("Edit Queue") : _("Add Queue")) ?><hr></h5></td></tr>
258     <tr>
259 <?php        if ($extdisplay != ''){ ?>
260         <input type="hidden" name="account" value="<?php echo $extdisplay; ?>">
261 <?php        } else { ?>
262         <td><a href="#" class="info"><?php echo _("Queue Number:")?><span><?php echo _("Use this number to dial into the queue, or transfer callers to this number to put them into the queue.<br><br>Agents will dial this queue number plus * to log onto the queue, and this queue number plus ** to log out of the queue.<br><br>For example, if the queue number is 123:<br><br><b>123* = log in<br>123** = log out</b>")?></span></a></td>
263         <td><input type="text" name="account" value="" tabindex="<?php echo ++$tabindex;?>"></td>
264 <?php        } ?>
265     </tr>
266
267     <tr>
268         <td><a href="#" class="info"><?php echo _("Queue Name:")?><span><?php echo _("Give this queue a brief name to help you identify it.")?></span></a></td>
269         <td><input type="text" name="name" value="<?php echo (isset($name) ? $name : ''); ?>" tabindex="<?php echo ++$tabindex;?>"></td>
270     </tr>
271
272     <tr>
273         <td><a href="#" class="info"><?php echo _("Queue Password:")?><span><?php echo _("You can require agents to enter a password before they can log in to this queue.<br><br>This setting is optional.")?></span></a></td>
274         <td><input type="text" name="password" value="<?php echo (isset($password) ? $password : ''); ?>" tabindex="<?php echo ++$tabindex;?>"></td>
275     </tr>
276
277 <?php
278   // show it if checked so they know:
279   //
280   if ($qnoanswer || !$amp_conf['QUEUES_HIDE_NOANSWER']) {
281 ?>
282     <tr>
283     <td><a href="#" class="info"><?php echo _("Queue No Answer:")?><span><?php echo _("If checked, the queue will not answer the call. Under most circumstance you should always have the queue answering calls. If not, then it's possible that recordings and MoH will not be heard by the waiting callers since early media capabilities vary and are inconsistent. Some cases where it may be desired to not answer a call is when using Strict Join Empty queue policies where the caller will not be admitted to the queue unless there is a queue member immediately available to take the call.")?></span></a></td>
284     <td>
285       <input name="qnoanswer" type="checkbox" value="1" <?php echo (isset($qnoanswer) && $qnoanswer == '1' ? 'checked' : ''); ?>  tabindex="<?php echo ++$tabindex;?>"/>
286     </td>
287   </tr>
288 <?php
289   }
290 ?>
291
292 <?php if ($ast_ge_18 || $amp_conf['USEDEVSTATE']) { ?>
293     <tr>
294   <td><a href="#" class="info"><?php echo _("Generate Device Hints:")?><span><?php echo _("If checked, individual hints and dialplan will be generated for each SIP and IAX2 device that could be part of this queue. These are used in conjunction with programmable BLF phone buttons to log into and out of a queue and generate BLF status as to the current state. The format of the hints is<br /><br />*45ddd*qqq<br /><br />where *45 is the currently defined toggle feature code, ddd is the device number (typically the same as the extension number) and qqq is this queue's number.")?></span></a></td>
295         <td>
296             <input name="togglehint" type="checkbox" value="1" <?php echo (isset($togglehint) && $togglehint == '1' ? 'checked' : ''); ?>  tabindex="<?php echo ++$tabindex;?>"/>
297         </td>
298     </tr>
299 <?php } ?>
300
301     <tr>
302             <td><a href="#" class="info"><?php echo _("Call Confirm:")?><span><?php echo _("If checked, any queue member that is actually an outside telephone number, or any extension Follow-Mes or call forwarding that are pursued and leave the PBX will be forced into Call Confirmation mode where the member must acknowledge the call before it is answered and delivered..")?></span></a></td>
303             <td>
304                   <input name="callconfirm" type="checkbox" value="1" <?php echo (isset($callconfirm) && $callconfirm == '1' ? 'checked' : ''); ?>  tabindex="<?php echo ++$tabindex;?>"/>
305             </td>
306       </tr>
307 <?php
308     if(function_exists('recordings_list')) { //only include if recordings is enabled ?>
309         <tr>
310                 <td><a href="#" class="info"><?php echo _("Call Confirm Announce:")?><span><?php echo _("Announcement played to the Queue Memeber announcing the Queue call and requesting confirmation prior to answering. If set to default, the standard call confirmation default message will be played unless the member is reached through a Follow-Me and there is an alternate message provided in the Follow-Me. This message will override any other message specified..<br><br>To add additional recordings please use the \"System Recordings\" MENU.")?></span></a></td>
311                 <td>
312                         <select name="callconfirm_id" tabindex="<?php echo ++$tabindex;?>">
313                         <?php
314                                 $tresults = recordings_list();
315                                 $default = (isset($callconfirm_id) ? $callconfirm_id : '');
316                                 echo '<option value="None">'._("Default");
317                                 if (isset($tresults[0])) {
318                                         foreach ($tresults as $tresult) {
319                                                 echo '<option value="'.$tresult['id'].'"'.($tresult['id'] == $default ? ' SELECTED' : '').'>'.$tresult['displayname']."</option>\n";
320                                         }
321                                 }
322                         ?>
323                         </select>
324                 </td>
325         </tr>
326 <?php } else { ?>
327         <tr>
328                 <td><a href="#" class="info"><?php echo _("Call Confirm Announcement:")?><span><?php echo _("Announcement played to anyone using an external follow-me to receive the queue call.<br><br>You must install and enable the \"Systems Recordings\" Module to edit this option")?></span></a></td>
329                 <td>
330                         <?php
331                                 $default = (isset($callconfirm_id) ? $callconfirm_id : '');
332                         ?>
333                         <input type="hidden" name="callconfirm_id" value="<?php echo $default; ?>"><?php echo ($default != '' ? $default : ''); ?>
334                 </td>
335         </tr>
336 <?php
337 }
338 ?>
339
340     <tr>
341         <td><a href="#" class="info"><?php echo _("CID Name Prefix:")?><span><?php echo _("You can optionally prefix the CallerID name of callers to the queue. ie: If you prefix with \"Sales:\", a call from John Doe would display as \"Sales:John Doe\" on the extensions that ring.")?></span></a></td>
342         <td><input size="4" type="text" name="prefix" value="<?php echo (isset($prefix) ? $prefix : ''); ?>" tabindex="<?php echo ++$tabindex;?>"></td>
343     </tr>
344
345     <tr>
346         <td><a href="#" class="info"><?php echo _("Wait Time Prefix:")?><span><?php echo _("When set to Yes, the CID Name will be prefixed with the total wait time in the queue so the answering agent is aware how long they have waited. It will be rounded to the nearest minute, in the form of Mnn: where nn is the number of minutes.").'<br />'._("If the call is subsequently transferred, the wait time will reflect the time since it first entered the queue or reset if the call is transferred to another queue with this feature set.")?></span></a></td>
347         <td>
348             <select name="queuewait" tabindex="<?php echo ++$tabindex;?>">
349             <?php
350                 $default = (isset($queuewait) ? $queuewait : '0');
351                 $items = array('1'=>_("Yes"),'0'=>_("No"));
352                 foreach ($items as $item=>$val) {
353                     echo '<option value="'.$item.'" '. ($default == $item ? 'SELECTED' : '').'>'.$val;
354                 }
355             ?>
356             </select>
357         </td>
358     </tr>
359
360     <tr>
361         <td><a href="#" class="info"><?php echo _("Alert Info")?><span><?php echo _('ALERT_INFO can be used for distinctive ring with SIP devices.')?></span></a>:</td>
362         <td><input type="text" name="alertinfo" size="30" value="<?php echo (isset($alertinfo)?$alertinfo:'') ?>" tabindex="<?php echo ++$tabindex;?>"></td>
363     </tr>
364
365     <tr>
366     <td valign="top"><a href="#" class="info"><?php echo _("Static Agents") ?>:<span><br><?php echo _("Static agents are extensions that are assumed to always be on the queue.  Static agents do not need to 'log in' to the queue, and cannot 'log out' of the queue.<br><br>List extensions to ring, one per line.<br><br>You can include an extension on a remote system, or an external number (Outbound Routing must contain a valid route for external numbers). You can put a \",\" after the agent followed by a penalty value, see Asterisk documentation concerning penalties.<br /><br /> An advanced mode has been added which allows you to prefix an agent number with S, X, Z, D or A. This will force the agent number to be dialed as an Asterisk device of type SIP, IAX2, ZAP, DAHDI or Agent respectively. This mode is for advanced users and can cause known issues in FreePBX as you are by-passing the normal dialplan. If your 'Agent Restrictions' are not set to 'Extension Only' you will have problems with subsequent transfers to voicemail and other issues may also exist. (Channel Agent is deprecated starting with Asterisk 1.4 and gone in 1.6+.)") ?><br><br></span></a></td>
367         <td valign="top">
368             <textarea id="members" cols="15" rows="<?php  $rows = count($mem_array)+1; echo (($rows < 5) ? 5 : (($rows > 20) ? 20 : $rows) ); ?>" name="members" tabindex="<?php echo ++$tabindex;?>"><?php echo implode("\n",$mem_array) ?></textarea>
369         </td>
370     </tr>
371
372     <tr>
373         <td>
374         <a href=# class="info"><?php echo _("Extension Quick Pick")?>
375             <span>
376                 <?php echo _("Choose an extension to append to the end of the static agents list above.")?>
377             </span>
378         </a>
379         </td>
380         <td>
381             <select onChange="insertExten('');" id="insexten" tabindex="<?php echo ++$tabindex;?>">
382                 <option value=""><?php echo _("(pick extension)")?></option>
383     <?php
384                 $results = core_users_list();
385                 foreach ($results as $result) {
386                     echo "<option value='".$result[0]."'>".$result[0]." (".$result[1].")</option>\n";
387                 }
388     ?>
389             </select>
390         </td>
391     </tr>
392
393     <tr>
394         <td valign="top"><a href="#" class="info"><?php echo _('Dynamic Members') ?>:<span><br><?php echo _("Dynamic Members are extensions or callback numbers that can log in and out of the queue. When a member logs in to a queue, their penalty in the queue will be as specified here. Extensions included here will NOT automatically be logged in to the queue.") ?><br><br></span></a></td>
395         <td valign="top">
396             <textarea id="dynmembers" cols="15" rows="<?php  $rows = count($dynmembers)+1; echo (($rows < 5) ? 5 : (($rows > 20) ? 20 : $rows) ); ?>" name="dynmembers" tabindex="<?php echo ++$tabindex;?>"><?php echo $dynmembers; ?></textarea>
397         </td>
398     </tr>
399
400     <tr>
401         <td>
402         <a href=# class="info"><?php echo _("Extension Quick Pick")?>
403             <span>
404                 <?php echo _("Choose an extension to append to the end of the dynamic member list above.")?>
405             </span>
406         </a>
407         </td>
408         <td>
409             <select onChange="insertExten('dyn');" id="dyninsexten" tabindex="<?php echo ++$tabindex;?>">
410                 <option value=""><?php echo _("(pick extension)")?></option>
411     <?php
412                 $results = core_users_list();
413                 foreach ($results as $result) {
414                     echo "<option value='".$result[0]."'>".$result[0]." (".$result[1].")</option>\n";
415                 }
416     ?>
417             </select>
418         </td>
419     </tr>
420
421     <tr>
422       <td><a href="#" class="info"><?php echo _("Restrict Dynamic Agents")?><span><?php echo _('Restrict dynamic queue member logins to only those listed in the Dynamic Members list above. When set to Yes, members not listed will be DENIED ACCESS to the queue.')?></span></a></td>
423     <td><input type="radio" name="dynmemberonly" value="yes" <?php echo ($dynmemberonly=='yes'?'checked':'');?>><?php echo _('Yes')?><input type="radio" name="dynmemberonly" value="no" <?php echo ($dynmemberonly!='yes'?'checked':'');?> ><?php echo _('No')?>
424         </td>
425     </tr>
426
427     <tr>
428     <td><a href="#" class="info"><?php echo _("Agent Restrictions")?><span><?php echo _("When set to 'Call as Dialed' the queue will call an extension just as if the queue were another user. Any Follow-Me or Call Forward states active on the extension will result in the queue call following these call paths. This behavior has been the standard queue behavior on past FreePBX versions. <br />When set to 'No Follow-Me or Call Forward', all agents that are extensions on the system will be limited to ringing their extensions only. Follow-Me and Call Forward settings will be ignored. Any other agent will be called as dialed. This behavior is similar to how extensions are dialed in ringgroups. <br />When set to 'Extensions Only' the queue will dial Extensions as described for 'No Follow-Me or Call Forward'. Any other number entered for an agent that is NOT a valid extension will be ignored. No error checking is provided when entering a static agent or when logging on as a dynamic agent, the call will simply be blocked when the queue tries to call it. For dynamic agents, see the 'Agent Regex Filter' to provide some validation.")?></span></a></td>
429         <td>
430             <select name="use_queue_context" tabindex="<?php echo ++$tabindex;?>">
431             <?php
432                 $default = (isset($use_queue_context) ? $use_queue_context : '0');
433                 echo '<option value="0"'. ($default == '0' ? ' SELECTED' : '').'>'._("Call as Dialed")."\n";
434                 echo '<option value="1"'. ($default == '1' ? ' SELECTED' : '').'>'._("No Follow-Me or Call Forward")."\n";
435                 echo '<option value="2"'. ($default == '2' ? ' SELECTED' : '').'>'._("Extensions Only")."\n";
436             ?>
437             </select>
438         </td>
439     </tr>
440
441     <tr><td colspan="2"><br><h5><?php echo _("General Queue Options")?><hr></h5></td></tr>
442
443     <tr>
444         <td>
445             <a href="#" class="info"><?php echo _("Ring Strategy:")?>
446                 <span>
447                     <b><?php echo _("ringall")?></b>:  <?php echo _("ring all available agents until one answers (default)")?><br>
448 <?php
449         if (!$ast_ge_16) {
450 ?>
451                     <b><?php echo _("roundrobin")?></b>: <?php echo _("take turns ringing each available agent")?><br>
452 <?php
453         }
454 ?>
455                     <b><?php echo _("leastrecent")?></b>: <?php echo _("ring agent which was least recently called by this queue")?><br>
456                     <b><?php echo _("fewestcalls")?></b>: <?php echo _("ring the agent with fewest completed calls from this queue")?><br>
457                     <b><?php echo _("random")?></b>: <?php echo _("ring random agent")?><br>
458                     <b><?php echo _("rrmemory")?></b>: <?php echo _("round robin with memory, remember where we left off last ring pass")?><br>
459                     <b><?php echo _("rrordered")?></b>: <?php echo _("same as rrmemory, except the queue member order from config file is preserved")?><br>
460 <?php
461         if ($ast_ge_16) {
462 ?>
463                     <b><?php echo _("linear")?></b>: <?php echo _("rings agents in the order specified, for dynamic agents in the order they logged in")?><br>
464                     <b><?php echo _("wrandom")?></b>: <?php echo _("random using the member's penalty as a weighting factor, see asterisk documentation for specifics")?><br>
465 <?php
466         }
467 ?>
468                 </span>
469             </a>
470         </td>
471
472         <td>
473             <select name="strategy" tabindex="<?php echo ++$tabindex;?>">
474             <?php
475                 $default = (isset($strategy) ? $strategy : 'ringall');
476                 $items = array('ringall','roundrobin','leastrecent','fewestcalls','random','rrmemory','rrordered');
477         if ($ast_ge_16) {
478                   $items[] = 'linear';
479                   $items[] = 'wrandom';
480           unset($items[array_search('roundrobin',$items)]);
481         }
482                 foreach ($items as $item) {
483                     echo '<option value="'.$item.'" '.($default == $item ? 'SELECTED' : '').'>'._($item);
484                 }
485             ?>       
486             </select>
487         </td>
488     </tr>
489
490     <tr>
491         <td><a href="#" class="info"><?php echo _("Autofill:")?><span><?php echo _("Starting with Asterisk 1.4, if this is checked, and multiple agents are available, Asterisk will send one call to each waiting agent (depending on the ring strategy). Otherwise, it will hold all calls while it tries to find an agent for the top call in the queue making other calls wait. This was the behavior in Asterisk 1.2 and has no effect in 1.2. See Asterisk documentation for more details of this feature.")?></span></a></td>
492         <td>
493             <input name="autofill" type="checkbox" value="1" <?php echo (isset($autofill) && $autofill == 'yes' ? 'checked' : ''); ?>  tabindex="<?php echo ++$tabindex;?>"/>
494         </td>
495     </tr>
496
497     <tr>
498     <td><a href="#" class="info"><?php echo _("Skip Busy Agents:")?><span><?php echo _("When set to 'Yes' agents who are on an occupied phone will be skipped as if the line were returning busy. This means that Call Waiting or multi-line phones will not be presented with the call and in the various hunt style ring strategies, the next agent will be attempted. <br />When set to 'Yes + (ringinuse=no)' the queue configuration flag 'ringinuse=no' is set for this queue in addition to the phone's device status being monitored. This results in the queue tracking remote agents (agents who are a remote PSTN phone, called through Follow-Me, and other means) as well as PBX connected agents, so the queue will not attempt to send another call if they are already on a call from any queue. <br />When set to 'Queue calls only (ringinuse=no)' the queue configuration flag 'ringinuse=no' is set for this queue also but the device status of locally connected agents is not monitored. The behavior is to limit an agent belonging to one or more queues to a single queue call. If they are occupied from other calls, such as outbound calls they initiated, the queue will consider them available and ring them since the device state is not monitored with this option. <br /><br />WARNING: When using the settings that set the 'ringinuse=no' flag, there is a NEGATIVE side effect. An agent who transfers a queue call will remain unavailable by any queue until that call is terminated as the call still appears as 'inuse' to the queue UNLESS 'Agent Restrictions' is set to 'Extensions Only'.")?></span></a></td>
499         <td>
500             <select name="cwignore" tabindex="<?php echo ++$tabindex;?>">
501 <?php
502                 $default = (isset($cwignore) ? $cwignore : 'no');
503                 $items = array('0' => _("No"),
504                                '1'=>_("Yes"),
505                                              '2'=>_("Yes + (ringinuse=no)"),
506                                              '3'=>_("Queue calls only (ringinuse=no)"),
507                                          );
508                 foreach ($items as $item=>$val) {
509                     echo '<option value="'.$item.'" '. ($default == $item ? 'SELECTED' : '').'>'.$val;
510                 }
511 ?>
512             </select>
513         </td>
514     </tr>
515
516     <tr>
517         <td><a href="#" class="info"><?php echo _("Queue Weight")?>:<span><?php echo _("Gives queues a 'weight' option, to ensure calls waiting in a higher priority queue will deliver its calls first if there are agents common to both queues.")?></span></a></td>
518         <td>
519             <select name="weight" tabindex="<?php echo ++$tabindex;?>">
520 <?php
521                 $default = (isset($weight) ? $weight : 0);
522                 for ($i=0; $i <= 10; $i++) {
523                     echo '<option value="'.$i.'" '.($i == $default ? 'SELECTED' : '').'>'.$i.'</option>';
524                 }
525 ?>        
526             </select>       
527         </td>
528     </tr>
529
530 <?php       
531 if(function_exists('music_list')) { //only include if music module is enabled?>
532     <tr>
533         <td><a href="#" class="info"><?php echo _("Music on Hold Class:")?><span><?php echo _("Music (or Commercial) played to the caller while they wait in line for an available agent. Choose \"inherit\" if you want the MoH class to be what is currently selected, such as by the inbound route.<br><br>  This music is defined in the \"Music on Hold\" Menu.")?></span></a></td>
534         <td>
535             <select name="music" tabindex="<?php echo ++$tabindex;?>">
536             <?php
537                 $tresults = music_list();
538                 array_unshift($tresults,'inherit');
539                 $default = (isset($music) ? $music : 'inherit');
540                 if (isset($tresults)) {
541                     foreach ($tresults as $tresult) {
542                         $searchvalue="$tresult";
543                         $ttext = $tresult;
544                         if($tresult == 'inherit') $ttext = _("inherit");
545                         if($tresult == 'none') $ttext = _("none");
546                         if($tresult == 'default') $ttext = _("default");                       
547                         echo '<option value="'.$tresult.'" '.($searchvalue == $default ? 'SELECTED' : '').'>'.$ttext;
548                     }
549                 }
550             ?>       
551             </select>       
552         </td>
553     </tr>
554 <?php } ?>
555
556     <tr>
557         <td><a href="#" class="info"><?php echo _("Ringing Instead of MoH:")?><span><?php echo _("Enabling this option make callers hear a ringing tone instead of Music on Hold.<br/>Enabling this ignores any Music on Hold Class selected as well as ignoring any configured periodic announcements configured.")?></span></a></td>
558         <td>
559             <input name="rtone" type="checkbox" value="1" <?php echo (isset($rtone) && $rtone == 1 ? 'checked' : ''); ?>  tabindex="<?php echo ++$tabindex;?>"/>
560         </td>
561     </tr>
562 <?php
563 if(function_exists('recordings_list')) { //only include if recordings is enabled ?>
564     <tr>
565         <td><a href="#" class="info"><?php echo _("Join Announcement:")?><span><?php echo _("Announcement played to callers once prior to joining the queue.<br><br>To add additional recordings please use the \"System Recordings\" MENU")?></span></a></td>
566         <td>
567             <select name="joinannounce_id" tabindex="<?php echo ++$tabindex;?>">
568             <?php
569                 $tresults = recordings_list();
570                 $default = (isset($joinannounce_id) ? $joinannounce_id : '');
571                 echo '<option value="None">'._("None");
572                 if (isset($tresults[0])) {
573                     foreach ($tresults as $tresult) {
574                         echo '<option value="'.$tresult['id'].'"'.($tresult['id'] == $default ? ' SELECTED' : '').'>'.$tresult['displayname']."</option>\n";
575                     }
576                 }
577             ?>       
578             </select>       
579         </td>
580     </tr>
581 <?php } else { ?>
582     <tr>
583         <td><a href="#" class="info"><?php echo _("Join Announcement:")?><span><?php echo _("Announcement played to callers once prior to joining the queue.<br><br>You must install and enable the \"Systems Recordings\" Module to edit this option")?></span></a></td>
584         <td>
585             <?php
586                 $default = (isset($joinannounce_id) ? $joinannounce_id : '');
587             ?>
588             <input type="hidden" name="joinannounce_id" value="<?php echo $default; ?>"><?php echo ($default != '' ? $default : ''); ?>
589         </td>
590     </tr>
591 <?php } ?>
592
593     <tr>
594         <td><a href="#" class="info"><?php echo _("Call Recording:")?><span><?php echo _("Incoming calls to agents can be recorded. (saved to /var/spool/asterisk/monitor)")?></span></a></td>
595         <td>
596             <select name="monitor-format" tabindex="<?php echo ++$tabindex;?>">
597             <?php
598                 $default = (empty($thisQ['monitor-format']) ? "no" : $thisQ['monitor-format']); 
599                 echo '<option value="wav49" '.($default == "wav49" ? 'SELECTED' : '').'>'._("wav49").'</option>';
600                 echo '<option value="wav" '.($default == "wav" ? 'SELECTED' : '').'>'._("wav").'</option>';
601                 echo '<option value="gsm" '.($default == "gsm" ? 'SELECTED' : '').'>'._("gsm").'</option>';
602                 echo '<option value="" '.($default == "no" ? 'SELECTED' : '').'>'._("No").'</option>';
603             ?>   
604             </select>       
605         </td>
606     </tr>
607
608     <tr>
609   <td><a href="#" class="info"><?php echo _("Recording Mode:")?><span><?php echo _("Choose to 'Include Hold Time' in the recording so it starts as soon as they enter the queue, or to defer recording until 'After Answered' and the call is bridged with a queue member.")?></span></a></td>
610   <td>
611     <select name="monitor_type" tabindex="<?php echo ++$tabindex;?>">
612     <?php
613     echo '<option value="" '.($monitor_type == "" ? 'SELECTED' : '').'>'._("Include Hold Time").'</option>';
614     echo '<option value="b" '.($monitor_type == "b" ? 'SELECTED' : '').'>'._("After Answered").'</option>';
615     ?>
616     </select>
617   </td>
618   </tr>
619
620     <tr>
621   <td><a href="#" class="info"><?php echo _("Caller Volume Adjustment:")?><span><?php echo _("Adjust the recording volume of the caller.")?></span></a></td>
622   <td>
623     <select name="monitor_heard" tabindex="<?php echo ++$tabindex;?>">
624     <?php
625     for($i=-4;$i<=-1;$i++) {
626       echo '<option value="'.$i.'" '.($monitor_heard == "$i" ? 'SELECTED' : '').'>'."$i".'</option>';
627     }
628     echo '<option value="0" '.(!$monitor_heard ? 'SELECTED' : '').'>'._("No Adjustment").'</option>';
629     for($i=1;$i<=4;$i++) {
630       echo '<option value="'.$i.'" '.($monitor_heard == "$i" ? 'SELECTED' : '').'>'."+$i".'</option>';
631     }
632     ?>
633     </select>
634   </td>
635   </tr>
636
637     <tr>
638   <td><a href="#" class="info"><?php echo _("Agent Volume Adjustment:")?><span><?php echo _("Adjust the recording volume of the queue member (Agent).")?></span></a></td>
639   <td>
640     <select name="monitor_spoken" tabindex="<?php echo ++$tabindex;?>">
641     <?php
642     for($i=-4;$i<=-1;$i++) {
643       echo '<option value="'.$i.'" '.($monitor_spoken == "$i" ? 'SELECTED' : '').'>'."$i".'</option>';
644     }
645     echo '<option value="0" '.(!$monitor_spoken ? 'SELECTED' : '').'>'._("No Adjustment").'</option>';
646     for($i=1;$i<=4;$i++) {
647       echo '<option value="'.$i.'" '.($monitor_spoken == "$i" ? 'SELECTED' : '').'>'."+$i".'</option>';
648     }
649     ?>
650     </select>
651   </td>
652   </tr>
653
654     <tr><td colspan="2"><br><h5><?php echo _("Timing & Agent Options")?><hr></h5></td></tr>
655
656     <tr>
657         <td><a href="#" class="info"><?php echo _("Max Wait Time:")?><span><?php echo _("The maximum number of seconds a caller can wait in a queue before being pulled out.  (0 for unlimited).")?></span></a></td>
658         <td>
659             <select name="maxwait" tabindex="<?php echo ++$tabindex;?>">
660             <?php
661                 $default = (isset($maxwait) ? $maxwait : 0);
662                 for ($i=0; $i < 60; $i+=10) {
663                     if ($i == 0)
664                         echo '<option value="">'._("Unlimited").'</option>';
665                     else
666                         echo '<option value="'.$i.'"'.($i == $maxwait ? ' SELECTED' : '').'>'.$i.' '._("seconds").'</option>';
667                 }
668                 for ($i=60; $i < 300; $i+=30) {
669                     echo '<option value="'.$i.'"'.($i == $maxwait ? ' SELECTED' : '').'>'.queues_timeString($i,true).'</option>';
670                 }
671                 for ($i=300; $i < 1200; $i+=60) {
672                     echo '<option value="'.$i.'"'.($i == $maxwait ? ' SELECTED' : '').'>'.queues_timeString($i,true).'</option>';
673                 }
674                 for ($i=1200; $i <= 3600; $i+=300) {
675                     echo '<option value="'.$i.'"'.($i == $maxwait ? ' SELECTED' : '').'>'.queues_timeString($i,true).'</option>';
676                 }
677             ?>       
678             </select>       
679         </td>
680     </tr>
681 <?php
682 if ($ast_ge_16) {
683 ?>
684   <tr>
685     <td><a href="#" class="info"><?php echo _("Max Wait Time Mode:")?><span><?php echo _("Asterisk timeoutpriority. In 'Strict' mode, when the 'Max Wait Time' of a caller is hit, they will be pulled out of the queue immediately. In 'Loose' mode, if a queue member is currently ringing with this call, then we will wait until the queue stops ringing this queue member or otherwise the call is rejected by the queue member before taking the caller out of the queue. This means that the 'Max Wait Time' could be as long as 'Max Wait Time' + 'Agent Timeout' combined.")?></span></a></td>
686     <td>
687       <select name="timeoutpriority" tabindex="<?php echo ++$tabindex;?>">
688 <?php
689         $default = (isset($timeoutpriority) ? $timeoutpriority : "app");
690         echo '<option value="app" '.($default == "app" ? 'SELECTED' : '').'>'._("Strict").'</option>';
691         echo '<option value="conf" '.($default == "conf" ? 'SELECTED' : '').'>'._("Loose").'</option>';
692 ?>
693       </select>
694     </td>
695   </tr>
696 <?php
697 }
698 ?>
699     <tr>
700         <td><a href="#" class="info"><?php echo _("Agent Timeout:")?><span><?php echo _("The number of seconds an agent's phone can ring before we consider it a timeout. Unlimited or other timeout values may still be limited by system ringtime or individual extension defaults.")?></span></a></td>
701         <td>
702             <select name="timeout" tabindex="<?php echo ++$tabindex;?>">
703             <?php
704                 $default = (isset($timeout) ? $timeout : 15);
705                 echo '<option value="0" '.(0 == $default ? 'SELECTED' : '').'>'._("Unlimited").'</option>';
706                 for ($i=1; $i <= 60; $i++) {
707                     echo '<option value="'.$i.'" '.($i == $default ? 'SELECTED' : '').'>'.$i.' '._("seconds").'</option>';
708                 }
709             ?>       
710             </select>       
711         </td>
712     </tr>
713
714     <tr>
715     <td><a href="#" class="info"><?php echo _("Agent Timeout Restart:")?><span><?php echo _("If timeoutrestart is set to yes, then the time out for an agent to answer is reset if a BUSY or CONGESTION is received. This can be useful if agents are able to cancel a call with reject or similar.")?></span></a></td>
716     <td>
717       <select name="timeoutrestart" tabindex="<?php echo ++$tabindex;?>">
718 <?php
719       $default = (isset($timeoutrestart) ? $timeoutrestart : "no");
720       echo '<option value=yes '.($default == "yes" ? 'SELECTED' : '').'>'._("Yes").'</option>';
721       echo '<option value=no '.($default == "no" ? 'SELECTED' : '').'>'._("No").'</option>';
722 ?>
723       </select>
724     </td>
725   </tr>
726
727     <tr>
728         <td><a href="#" class="info"><?php echo _("Retry:")?><span><?php echo _("The number of seconds we wait before trying all the phones again. Choosing \"No Retry\" will exit the Queue and go to the fail-over destination as soon as the first attempted agent times-out, additional agents will not be attempted.")?></span></a></td>
729         <td>
730             <select name="retry" tabindex="<?php echo ++$tabindex;?>">
731       <?php
732                 $default = (isset($retry) ? $retry : 5);
733                 echo '<option value="none" '.(($default == "none") ? 'SELECTED' : '').'>'._("No Retry").'</option>';
734                 for ($i=0; $i <= 20; $i++) {
735                     echo '<option value="'.$i.'" '.(("$i" == "$default") ? 'SELECTED' : '').'>'.$i.' '._("seconds").'</option>';
736                 }
737             ?>       
738             </select>       
739         </td>
740     </tr>
741
742     <tr>
743         <td><a href="#" class="info"><?php echo _("Wrap-Up-Time:")?><span><?php echo _("After a successful call, how many seconds to wait before sending a potentially free agent another call (default is 0, or no delay) If using Asterisk 1.6+, you can also set the 'Honor Wrapup Time Across Queues' setting (Asterisk: shared_lastcall) on the Advanced Settings page so that this is honored across queues for members logged on to multiple queues.")?></span></a></td>
744         <td>
745             <select name="wrapuptime" tabindex="<?php echo ++$tabindex;?>">
746             <?php
747                 $default = (isset($wrapuptime) ? $wrapuptime : 0);
748                 for ($i=0; $i <= 60; $i++) {
749                     echo '<option value="'.$i.'" '.($i == $default ? 'SELECTED' : '').'>'.$i.' '._("seconds").'</option>';
750                 }
751             ?>       
752             </select>       
753         </td>
754     </tr>
755
756     <tr>
757     <td><a href="#" class="info"><?php echo _("Member Delay:")?><span><?php echo _("If you wish to have a delay before the member is connected to the caller (or before the member hears any announcement messages), set this to the number of seconds to delay.")?></span></a></td>
758     <td>
759       <select name="memberdelay" tabindex="<?php echo ++$tabindex;?>">
760 <?php
761       $default = (isset($memberdelay) ? $memberdelay : 0);
762       for ($i=0; $i <= 60; $i++) {
763         echo '<option value="'.$i.'" '.($i == $default ? 'SELECTED' : '').'>'.$i.' '._("seconds").'</option>';
764       }
765 ?>
766       </select>
767     </td>
768   </tr>
769
770 <?php if(function_exists('recordings_list')) { //only include if recordings is enabled?>
771     <tr>
772         <td><a href="#" class="info"><?php echo _("Agent Announcement:")?><span><?php echo _("Announcement played to the Agent prior to bridging in the caller <br><br> Example: \"the Following call is from the Sales Queue\" or \"This call is from the Technical Support Queue\".<br><br>To add additional recordings please use the \"System Recordings\" MENU. Compound recordings composed of 2 or more sound files are not displayed as options since this feature can not accept such recordings.")?></span></a></td>
773         <td>
774             <select name="agentannounce_id" tabindex="<?php echo ++$tabindex;?>">
775             <?php
776                 $tresults = recordings_list(false);
777                 $default = (isset($agentannounce_id) ? $agentannounce_id : '');
778
779                 echo '<option value="">'._("None").'</option>';
780                 if (isset($tresults[0])) {
781                     foreach ($tresults as $tresult) {
782                         echo '<option value="'.$tresult['id'].'"'.($tresult['id'] == $default ? ' SELECTED' : '').'>'.$tresult['displayname']."</option>\n";
783                     }
784                 }
785             ?>       
786             </select>       
787         </td>
788     </tr>
789 <?php } else { ?>
790     <tr>
791         <td><a href="#" class="info"><?php echo _("Agent Announcement:")?><span><?php echo _("Announcement played to the Agent prior to bridging in the caller <br><br> Example: \"the Following call is from the Sales Queue\" or \"This call is from the Technical Support Queue\".<br><br>You must install and enable the \"Systems Recordings\" Module to edit this option")?></span></a></td>
792         <td>
793             <?php
794                 $default = (isset($agentannounce_id) ? $agentannounce_id : '');
795             ?>
796             <input type="hidden" name="agentannounce_id" value="<?php echo $default; ?>"><?php echo ($default != '' ? $default : ''); ?>
797         </td>
798     </tr>
799 <?php } ?>
800
801     <tr>
802         <td><a href="#" class="info"><?php echo _("Report Hold Time:")?><span><?php echo _("If you wish to report the caller's hold time to the member before they are connected to the caller, set this to yes.")?></span></a></td>
803         <td>
804             <select name="reportholdtime" tabindex="<?php echo ++$tabindex;?>">
805             <?php
806                 $default = (isset($reportholdtime) ? $reportholdtime : 'no');
807                 $items = array('yes'=>_("Yes"),'no'=>_("No"));
808                 foreach ($items as $item=>$val) {
809                     echo '<option value="'.$item.'" '. ($default == $item ? 'SELECTED' : '').'>'.$val;
810                 }
811             ?>       
812             </select>       
813         </td>
814     </tr>
815
816     <tr><td colspan="2"><br><h5><?php echo _("Capacity Options")?><hr></h5></td></tr>
817
818     <tr>
819         <td><a href="#" class="info"><?php echo _("Max Callers:")?><span><?php echo _("Maximum number of people waiting in the queue (0 for unlimited)")?></span></a></td>
820         <td>
821             <select name="maxlen" tabindex="<?php echo ++$tabindex;?>">
822             <?php
823                 $default = (isset($maxlen) ? $maxlen : 0);
824                 echo '<option value="0" '.(!$default ? 'SELECTED' : '').'>'._("No Max").'</option>';
825                 for ($i=0; $i <= 50; $i++) {
826                     echo '<option value="'.$i.'" '.($i == $default ? 'SELECTED' : '').'>'.$i.'</option>';
827                 }
828             ?>       
829             </select>       
830         </td>
831     </tr>
832
833 <?php
834         $tt = _("Determines if new callers will be admitted to the Queue, if not, the failover destination will be immediately pursued. The options include:");
835         $tt .= '<ul>';
836         $tt .= '<li><b>'._("Yes").'</b> '._("Always allows the caller to join the Queue.").'</li>';
837         $tt .= '<li><b>'._("Strict").'</b> '._("Same as Yes but more strict.  Simply speaking, if no agent could answer the phone then don't admit them. If agents are inuse or ringing someone else, caller will still be admitted.").'</li>';
838         if ($ast_ge_162) {
839           $tt .= '<li><b>'._("Ultra Strict").'</b> '._("Same as Strict plus a queue member must be able to answer the phone 'now' to let them in. Simply speaking, any 'available' agents that could answer but are currently on the phone or ringing on behalf of another caller will be considered unavailable.").'</li>';
840         }
841         $tt .= '<li><b>'._("No").'</b> '._("Callers will not be admitted if all agents are paused, show an invalid state for their device, or have penalty values less then QUEUE_MAX_PENALTY (not currently set in FreePBX dialplan).").'</li>';
842         if ($ast_ge_16) {
843           $tt .= '<li><b>'._("Loose").'</b> '._("Same as No except Callers will be admitted if their are paused agents who could become available.").'</li>';
844         }
845         $tt .= '</ul>';
846 ?>
847     <tr>
848         <td><a href="#" class="info"><?php echo _("Join Empty:")?><span><?php echo $tt?></span></a></td>
849         <td>
850             <select name="joinempty" tabindex="<?php echo ++$tabindex;?>">
851             <?php
852                 $default = (isset($joinempty) ? $joinempty : 'yes');
853
854         $items['yes'] = _("Yes");
855         $items['strict'] = _("Strict");
856         if ($ast_ge_162) {
857           $items['penalty,paused,invalid,unavailable,inuse,ringing'] = _("Ultra Strict");
858         }
859         $items['no'] = _("No");
860         if ($ast_ge_16) {
861           $items['loose'] = _("Loose");
862         }
863
864                 foreach ($items as $item=>$val) {
865                     echo '<option value="'.$item.'" '. ($default == $item ? 'SELECTED' : '').'>'.$val;
866                 }
867             ?>       
868             </select>       
869         </td>
870     </tr>
871
872 <?php
873         $tt = _("Determines if callers should be exited prematurely from the queue in situations where it appears no one is currently available to take the call. The options include:");
874         $tt .= '<ul>';
875         $tt .= '<li><b>'._("Yes").'</b> '._("Callers will exit if all agents are paused, show an invalid state for their device or have penalty values less then QUEUE_MAX_PENALTY (not currently set in FreePBX dialplan)..").'</li>';
876         $tt .= '<li><b>'._("Strict").'</b> '._("Same as Yes but more strict.  Simply speaking, if no agent could answer the phone then have them leave the queue. If agents are inuse or ringing someone else, caller will still be held.").'</li>';
877         if ($ast_ge_162) {
878           $tt .= '<li><b>'._("Ultra Strict").'</b> '._("Same as Strict plus a queue member must be able to answer the phone 'now' to let them remain. Simply speaking, any 'available' agents that could answer but are currently on the phone or ringing on behalf of another caller will be considered unavailable.").'</li>';
879         }
880         if ($ast_ge_16) {
881           $tt .= '<li><b>'._("Loose").'</b> '._("Same as Yes except Callers will remain in the Queue if their are paused agents who could become available.").'</li>';
882         }
883         $tt .= '<li><b>'._("No").'</b> '._("Never have a caller leave the Queue until the Max Wait Time has expired.").'</li>';
884         $tt .= '</ul>';
885 ?>
886     <tr>
887         <td><a href="#" class="info"><?php echo _("Leave Empty:")?><span><?php echo $tt?></span></a></td>
888         <td>
889             <select name="leavewhenempty" tabindex="<?php echo ++$tabindex;?>">
890             <?php
891                 $default = (isset($leavewhenempty) ? $leavewhenempty : 'no');
892
893         $items['yes'] = _("Yes");
894         $items['strict'] = _("Strict");
895         if ($ast_ge_162) {
896           $items['penalty,paused,invalid,unavailable,inuse,ringing'] = _("Ultra Strict");
897         }
898         if ($ast_ge_16) {
899           $items['loose'] = _("Loose");
900         }
901         $items['no'] = _("No");
902
903                 foreach ($items as $item=>$val) {
904                     echo '<option value="'.$item.'" '. ($default == $item ? 'SELECTED' : '').'>'.$val;
905                 }
906             ?>       
907             </select>       
908         </td>
909     </tr>
910 <?php
911 if ($ast_ge_16) {
912 ?>
913     <tr>
914     <td><a href="#" class="info"><?php echo _("Penalty Members Limit:")?><span><?php echo _("Asterisk: penaltymemberslimit. A limit can be set to disregard penalty settings, allowing all members to be tried, when the queue has too few members.  No penalty will be weighed in if there are only X or fewer queue members.")?></span></a></td>
915     <td>
916       <select name="penaltymemberslimit" tabindex="<?php echo ++$tabindex;?>">
917 <?php
918       $default = (isset($penaltymemberslimit) ? $penaltymemberslimit : 0);
919       echo '<option value="0" '.(!$default ? 'SELECTED' : '').'>'._("Honor Penalties").'</option>';
920       for ($i=1; $i <= 20; $i++) {
921         echo '<option value="'.$i.'" '.($i == $default ? 'SELECTED' : '').'>'.$i.'</option>';
922       }
923 ?>
924       </select>
925     </td>
926   </tr>
927 <?php
928 }
929 ?>
930
931     <tr><td colspan="2"><br><h5><?php echo _("Caller Position Announcements")?><hr></h5></td></tr>
932
933     <tr>
934         <td><a href="#" class="info"><?php echo _("Frequency:")?><span><?php echo _("How often to announce queue position and estimated holdtime (0 to Disable Announcements).")?></span></a></td>
935         <td>
936             <select name="announcefreq" tabindex="<?php echo ++$tabindex;?>">
937             <?php
938                 $default = (isset($thisQ['announce-frequency']) ? $thisQ['announce-frequency'] : 0);
939                 for ($i=0; $i <= 1200; $i+=15) {
940                     echo '<option value="'.$i.'" '.($i == $default ? 'SELECTED' : '').'>'.queues_timeString($i,true).'</option>';
941                 }
942             ?>       
943             </select>       
944         </td>
945     </tr>
946
947     <tr>
948         <td><a href="#" class="info"><?php echo _("Announce Position:")?><span><?php echo _("Announce position of caller in the queue?")?></span></a></td>
949         <td>
950             <select name="announceposition" tabindex="<?php echo ++$tabindex;?>">
951             <?php //setting to "no" will override sounds queue-youarenext, queue-thereare, queue-callswaitingÊ
952                 $default = (isset($thisQ['announce-position']) ? $thisQ['announce-position'] : "no"); 
953                     echo '<option value=yes '.($default == "yes" ? 'SELECTED' : '').'>'._("Yes").'</option>';
954                     echo '<option value=no '.($default == "no" ? 'SELECTED' : '').'>'._("No").'</option>';
955             ?>       
956             </select>       
957         </td>
958     </tr>
959
960     <tr>
961         <td><a href="#" class="info"><?php echo _("Announce Hold Time:")?><span><?php echo _("Should we include estimated hold time in position announcements?  Either yes, no, or only once; hold time will not be announced if <1 minute")?> </span></a></td>
962         <td>
963             <select name="announceholdtime" tabindex="<?php echo ++$tabindex;?>">
964             <?php
965                 $default = (isset($thisQ['announce-holdtime']) ? $thisQ['announce-holdtime'] : "no");
966                 echo '<option value=yes '.($default == "yes" ? 'SELECTED' : '').'>'._("Yes").'</option>';
967                 echo '<option value=no '.($default == "no" ? 'SELECTED' : '').'>'._("No").'</option>';
968                 echo '<option value=once '.($default == "once" ? 'SELECTED' : '').'>'._("Once").'</option>';
969             ?>       
970             </select>       
971         </td>
972     </tr>
973
974     <tr><td colspan="2"><br><h5><?php echo _("Periodic Announcements")?><hr></h5></td></tr>
975    
976 <?php if(function_exists('ivr_list')) { //only include if IVR module is enabled ?>
977     <tr>
978         <td><a href="#" class="info"><?php echo _("IVR Break Out Menu:")?><span> <?php echo _("You can optionally present an existing IVR as a 'break out' menu.<br><br>This IVR must only contain single-digit 'dialed options'. The Recording set for the IVR will be played at intervals specified in 'Repeat Frequency', below.")?></span></a></td>
979         <td>
980             <select name="announcemenu" tabindex="<?php echo ++$tabindex;?>">
981             <?php // setting this will set the context= option
982             $default = (isset($announcemenu) ? $announcemenu : "none");
983             
984             echo '<option value=none '.($default == "none" ? 'SELECTED' : '').'>'._("None").'</option>';
985             
986             //query for exisiting aa_N contexts
987             //
988             // If a previous bogus IVR was listed, we will leave it in with an error but will no longer show such IVRs as valid options.
989             $unique_aas = ivr_list();       
990             
991             $compound_recordings = false;
992             $is_error = false;
993             if (isset($unique_aas)) {
994                 foreach ($unique_aas as $unique_aa) {
995                     $menu_id = $unique_aa['ivr_id'];
996                     $menu_name = $unique_aa['displayname'];
997
998                     $unique_aa['announcement'] = recordings_get_file($unique_aa['announcement_id']);
999                     if (strpos($unique_aa['announcement'],"&") === false) {
1000                         echo '<option value="'.$menu_id.'" '.($default == $menu_id ? 'SELECTED' : '').'>'.($menu_name ? $menu_name : _("Menu ID ").$menu_id)."</option>\n";
1001                     }
1002                     else {
1003                         $compound_recordings = true;
1004                         if ($menu_id == $default) {
1005                             echo '<option style="color:red" value="'.$menu_id.'" '.($default == $menu_id ? 'SELECTED' : '').'>'.($menu_name ? $menu_name : _("Menu ID ").$menu_id)." (**)</option>\n";
1006                             $is_error = true;
1007                         }
1008                     }
1009                 }
1010             }
1011             ?>
1012             </select>
1013             <?php
1014             if ($is_error) {
1015             ?>
1016                 <small><a style="color:red"  href="#" class="info"><?php echo ($is_error ? _("(**) ERRORS") : _("(**) Warning Potential Errors"))?>
1017                     <span>
1018                         <?php
1019                             if ($is_error) {
1020                                 echo _("ERROR: You have selected an IVR's that use Announcements created from compound sound files. The Queue is not able to play these announcements. This IVR's recording will be truncated to use only the first sound file. You can correct the problem by selecting a different announcement for this IVR that is not from a compound sound file. The IVR itself can play such files, but the Queue subsystem can not").'<br />'._("Earlier versions of this module allowed such queues to be chosen, once changing this setting, it will no longer appear as an option");
1021                             }
1022                         ?>
1023                     </span></small>
1024                 </a>
1025             <?php
1026             }
1027             ?>
1028
1029         </td>
1030     </tr>
1031    
1032     <tr>
1033         <td><a href="#" class="info"><?php echo _("Repeat Frequency:")?><span><?php echo _("How often to announce a voice menu to the caller (0 to Disable Announcements).")?></span></a></td>
1034         <td>
1035             <select name="pannouncefreq" tabindex="<?php echo ++$tabindex;?>">
1036             <?php
1037                 $default = (isset($thisQ['periodic-announce-frequency']) ? $thisQ['periodic-announce-frequency'] : 0);
1038                 for ($i=0; $i <= 1200; $i+=15) {
1039                     echo '<option value="'.$i.'" '.($i == $default ? 'SELECTED' : '').'>'.queues_timeString($i,true).'</option>';
1040                 }
1041             ?>       
1042             </select>       
1043         </td>
1044     </tr>
1045
1046 <?php } else {
1047     echo "<input type=\"hidden\" name=\"announcemenu\" value=\"none\">";
1048     }
1049 ?>
1050
1051     <tr><td colspan="2"><br><h5><?php echo _("Events, Stats and Advanced")?><hr></h5></td></tr>
1052
1053     <tr>
1054         <td><a href="#" class="info"><?php echo _("Event When Called:")?><span><?php echo _("When this option is set to YES, the following manager events will be generated: AgentCalled, AgentDump, AgentConnect and AgentComplete.")?></span></a></td>
1055         <td>
1056             <select name="eventwhencalled" tabindex="<?php echo ++$tabindex;?>">
1057             <?php
1058                 $default = (isset($eventwhencalled) ? $eventwhencalled : 'no');
1059                 $items = array('yes'=>_("Yes"),'no'=>_("No"));
1060                 foreach ($items as $item=>$val) {
1061                     echo '<option value="'.$item.'" '. ($default == $item ? 'SELECTED' : '').'>'.$val;
1062                 }
1063             ?>
1064             </select>
1065         </td>
1066     </tr>
1067
1068     <tr>
1069         <td><a href="#" class="info"><?php echo _("Member Status Event:")?><span><?php echo _("When set to YES, the following manager event will be generated: QueueMemberStatus")?></span></a></td>
1070         <td>
1071             <select name="eventmemberstatus" tabindex="<?php echo ++$tabindex;?>">
1072             <?php
1073                 $default = (isset($eventmemberstatus) ? $eventmemberstatus : 'no');
1074                 $items = array('yes'=>_("Yes"),'no'=>_("No"));
1075                 foreach ($items as $item=>$val) {
1076                     echo '<option value="'.$item.'" '. ($default == $item ? 'SELECTED' : '').'>'.$val;
1077                 }
1078             ?>
1079             </select>
1080         </td>
1081     </tr>
1082
1083     <tr>
1084         <td><a href="#" class="info"><?php echo _("Service Level:")?><span><?php echo _("Used for service level statistics (calls answered within service level time frame)")?></span></a></td>
1085         <td>
1086             <select name="servicelevel" tabindex="<?php echo ++$tabindex;?>">
1087             <?php
1088                 $default = (isset($servicelevel) ? $servicelevel : 60);
1089                 for ($i=15; $i <= 300; $i+=15) {
1090                     echo '<option value="'.$i.'" '.($i == $default ? 'SELECTED' : '').'>'.$i.' '._("seconds").'</option>';
1091                 }
1092             ?>       
1093             </select>       
1094         </td>
1095     </tr>
1096
1097     <tr>
1098         <td><a href="#" class="info"><?php echo _("Agent Regex Filter")?><span><?php echo _("Provides an optional regex expression that will be applied against the agent callback number. If the callback number does not pass the regex filter then it will be treated as invalid. This can be used to restrict agents to extensions within a range, not allow callbacks to include keys like *, or any other use that may be appropriate. An example input might be:<br />^([2-4][0-9]{3})$<br />This would restrict agents to extensions 2000-4999. Or <br />^([0-9]+)$ would allow any number of any length, but restrict the * key.<br />WARNING: make sure you understand what you are doing or otherwise leave this blank!")?></span></a></td>
1099         <td><input type="text" name="qregex" value="<?php echo (isset($qregex) ? $qregex : ''); ?>"></td>
1100     </tr>
1101 <?php   
1102     // implementation of module hook
1103     // object was initialized in config.php
1104     echo $module_hook->hookHtml;
1105 ?>
1106
1107     <tr><td colspan="2"><br><h5><?php echo _("Fail Over Destination")?><hr></h5></td></tr>
1108     <?php
1109     echo drawselects($goto,0);
1110     ?>
1111    
1112     <tr>
1113         <td colspan="2"><br><h6><input name="Submit" type="button" value="<?php echo _("Submit Changes")?>" onclick="checkQ(editQ);" tabindex="<?php echo ++$tabindex;?>"></h6></td>       
1114     </tr>
1115     </table>
1116
1117 <script language="javascript">
1118 <!--
1119
1120 function insertExten(type) {
1121     exten = document.getElementById(type+'insexten').value;
1122
1123     grpList=document.getElementById(type+'members');
1124     if (grpList.value[ grpList.value.length - 1 ] == "\n") {
1125         grpList.value = grpList.value + exten + ',0';
1126     } else {
1127         grpList.value = grpList.value + '\n' + exten + ',0';
1128     }
1129
1130     // reset element
1131     document.getElementById(type+'insexten').value = '';
1132 }
1133
1134 function checkQ(theForm) {
1135     var bad = "false";
1136     var msgWarnRegex = "<?php echo _("Using a Regex filter is fairly advanced, please confirm you know what you are doing or leave this blank"); ?>";
1137
1138     var whichitem = 0;
1139     while (whichitem < theForm.goto0.length) {
1140         if (theForm.goto0[whichitem].checked) {
1141             theForm.goto0.value=theForm.goto0[whichitem].value;
1142         }
1143         whichitem++;
1144     }
1145
1146     if (!isInteger(theForm.account.value)) {
1147         <?php echo "alert('"._("Queue Number must not be blank")."')"?>;
1148         bad="true";
1149     }
1150
1151     defaultEmptyOK = false;   
1152     if (!isAlphanumeric(theForm.name.value)) {
1153         <?php echo "alert('"._("Queue name must not be blank and must contain only alpha-numeric characters")."')"?>;
1154         bad="true";
1155     }
1156     if (!isEmpty(theForm.qregex.value)) {
1157         if (!confirm(msgWarnRegex)) {
1158             bad="true";
1159         }
1160     }
1161
1162     if (bad == "false") {
1163         theForm.submit();
1164     }
1165 }
1166
1167 //-->
1168 </script>
1169
1170     </form>
1171 <?php       
1172 } //end if action == delGRP
1173 ?>
1174
Note: See TracBrowser for help on using the browser.