Update FIFO to version 2.0

This commit is contained in:
FusionPBX 2024-06-13 11:46:34 -06:00 committed by GitHub
parent 30c8fe9a51
commit 9d7f95a7e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 1990 additions and 1486 deletions

View File

@ -1,13 +1,13 @@
<?php
//application details
$apps[$x]['name'] = "FIFO";
$apps[$x]['uuid'] = "16589224-c876-aeb3-f59f-523a1c0801f7";
$apps[$x]['category'] = "Switch";;
$apps[$x]['subcategory'] = "";
$apps[$x]['version'] = "1.0";
$apps[$x]['license'] = "Mozilla Public License 1.1";
$apps[$x]['url'] = "http://www.fusionpbx.com";
$apps[$x]['name'] = 'FIFO';
$apps[$x]['uuid'] = '16589224-c876-aeb3-f59f-523a1c0801f7';
$apps[$x]['category'] = 'Switch';
$apps[$x]['subcategory'] = '';
$apps[$x]['version'] = '2.0';
$apps[$x]['license'] = 'Mozilla Public License 1.1';
$apps[$x]['url'] = 'http://www.fusionpbx.com';
$apps[$x]['description']['en-us'] = "Queues are used to setup waiting lines for callers. Also known as FIFO Queues.";
$apps[$x]['description']['en-gb'] = "Queues are used to setup waiting lines for callers. Also known as FIFO Queues.";
$apps[$x]['description']['ar-eg'] = "";
@ -30,22 +30,195 @@
$apps[$x]['description']['uk-ua'] = "";
//permission details
$y = 0;
$apps[$x]['permissions'][$y]['name'] = 'fifo_view';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'fifo_add';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'fifo_edit';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'fifo_delete';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'fifo_all';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'fifo_member_view';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'fifo_member_add';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'fifo_member_edit';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'fifo_member_delete';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'fifo_member_all';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
//queues
$y=0;
$apps[$x]['permissions'][$y]['name'] = "fifo_view";
$apps[$x]['permissions'][$y]['menu']['uuid'] = "c535ac0b-1da1-0f9c-4653-7934c6f4732c";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "fifo_add";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "fifo_edit";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "fifo_delete";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['db'][$y]['table']['name'] = 'v_fifo';
$apps[$x]['db'][$y]['table']['parent'] = '';
$z=0;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fifo_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'primary';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'domain_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_domains';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'domain_uuid';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "dialplan_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_dialplans";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "dialplan_uuid";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fifo_name';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '1';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'The name the queue will be assigned.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fifo_extension';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '1';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'The number that will be assigned to the queue.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fifo_agent_queue';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'A queue for agents to wait for a caller, or pick up a call that is waiting in the queue.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fifo_agent_status';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'A feature code for the agent to login or logout of the Queue.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fifo_members';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fifo_music';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Select the hold music for those to hear while waiting in the Queue.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fifo_order';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Select the order.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fifo_enabled';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'boolean';
$apps[$x]['db'][$y]['fields'][$z]['toggle'] = ['true','false'];
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enable or disable this FIFO queue.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fifo_description';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '1';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the fifo description.';
$z++;
//members
$y = 10;
$apps[$x]['db'][$y]['table']['name'] = 'v_fifo_members';
$apps[$x]['db'][$y]['table']['parent'] = 'v_fifo';
$z = 0;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fifo_member_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'primary';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'domain_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_domains';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'domain_uuid';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fifo_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_fifo';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'fifo_uuid';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'member_contact';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the member contact.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'member_call_timeout';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the member call timeout.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'member_simultaneous';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the member simultaneous.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'member_wrap_up_time';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the member wrap up time.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'member_enabled';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'boolean';
$apps[$x]['db'][$y]['fields'][$z]['toggle'] = ['true','false'];
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'insert_date';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamptz';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'date';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'date';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'insert_user';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'update_date';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamptz';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'date';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'date';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'update_user';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
//cache details
$apps[$x]['cache']['key'] = "dialplan.\${domain_name}";

File diff suppressed because it is too large Load Diff

View File

@ -28,7 +28,7 @@
$apps[$x]['menu'][$y]['parent_uuid'] = "fd29e39c-c936-f5fc-8e2b-611681b266b5";
$apps[$x]['menu'][$y]['category'] = "internal";
$apps[$x]['menu'][$y]['icon'] = "";
$apps[$x]['menu'][$y]['path'] = "/app/dialplans/dialplans.php?app_uuid=16589224-c876-aeb3-f59f-523a1c0801f7";
$apps[$x]['menu'][$y]['path'] = "/app/fifo/fifo.php";
$apps[$x]['menu'][$y]['order'] = "";
$apps[$x]['menu'][$y]['groups'][] = "admin";
$apps[$x]['menu'][$y]['groups'][] = "superadmin";

342
app/fifo/fifo.php Normal file
View File

@ -0,0 +1,342 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2018 - 2023
the Initial Developer. All Rights Reserved.
*/
//set the include path
$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
set_include_path(parse_ini_file($conf[0])['document.root']);
//includes files
require_once "resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/paging.php";
//check permissions
if (permission_exists('fifo_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//add the settings object
$settings = new settings(["domain_uuid" => $_SESSION['domain_uuid'], "user_uuid" => $_SESSION['user_uuid']]);
//set from session variables
$list_row_edit_button = $settings->get('theme', 'list_row_edit_button', 'false');
//get the http post data
if (!empty($_POST['fifo']) && is_array($_POST['fifo'])) {
$action = $_POST['action'];
$search = $_POST['search'];
$fifo = $_POST['fifo'];
}
//process the http post data by action
if (!empty($action) && !empty($fifo) && is_array($fifo) && @sizeof($fifo) != 0) {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: fifo.php');
exit;
}
//prepare the array
if (!empty($fifo)) {
foreach ($fifo as $row) {
$array['fifo'][$x]['checked'] = $row['checked'];
$array['fifo'][$x]['fifo_uuid'] = $row['fifo_uuid'];
$array['fifo'][$x]['fifo_enabled'] = $row['fifo_enabled'];
$x++;
}
}
//prepare the database object
$database = new database;
$database->app_name = 'fifo';
$database->app_uuid = '16589224-c876-aeb3-f59f-523a1c0801f7';
//send the array to the database class
switch ($action) {
case 'copy':
if (permission_exists('fifo_add')) {
$database->copy($array);
//$obj = new fifo;
//$obj->copy($fifo);
}
break;
case 'toggle':
if (permission_exists('fifo_edit')) {
$database->toggle($array);
//$obj = new fifo;
//$obj->toggle($fifo);
}
break;
case 'delete':
if (permission_exists('fifo_delete')) {
$database->delete($array);
//$obj = new fifo;
//$obj->delete($fifo);
}
break;
}
//redirect the user
header('Location: fifo.php'.($search != '' ? '?search='.urlencode($search) : null));
exit;
}
//get order and order by
$order_by = $_GET["order_by"] ?? null;
$order = $_GET["order"] ?? null;
//define the variables
$search = '';
$show = '';
$list_row_url = '';
//add the search variable
if (!empty($_GET["search"])) {
$search = strtolower($_GET["search"]);
}
//add the show variable
if (!empty($_GET["show"])) {
$show = $_GET["show"];
}
//get the count
$sql = "select count(fifo_uuid) ";
$sql .= "from v_fifo ";
if (permission_exists('fifo_all') && $show == 'all') {
$sql .= "where true ";
}
else {
$sql .= "where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
if (!empty($search)) {
$sql .= "and ( ";
$sql .= " lower(fifo_name) like :search ";
$sql .= " or lower(fifo_extension) like :search ";
$sql .= " or lower(fifo_description) like :search ";
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
$database = new database;
$num_rows = $database->select($sql, $parameters ?? null, 'column');
unset($sql, $parameters);
//prepare to page the results
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = !empty($search) ? "&search=".$search : null;
$param .= (!empty($_GET['page']) && $show == 'all' && permission_exists('fifo_all')) ? "&show=all" : null;
$page = !empty($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page'] : 0;
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true);
$offset = $rows_per_page * $page;
//get the list
$sql = "select ";
$sql .= "fifo_uuid, ";
$sql .= "fifo_name, ";
$sql .= "fifo_extension, ";
$sql .= "fifo_agent_queue, ";
$sql .= "fifo_agent_status, ";
$sql .= "fifo_music, ";
$sql .= "u.domain_uuid, ";
$sql .= "d.domain_name, ";
$sql .= "fifo_order, ";
$sql .= "cast(fifo_enabled as text), ";
$sql .= "fifo_description ";
$sql .= "from v_fifo as u, v_domains as d ";
if (permission_exists('fifo_all') && $show == 'all') {
$sql .= "where true ";
}
else {
$sql .= "where u.domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
if (!empty($search)) {
$sql .= "and ( ";
$sql .= " lower(fifo_name) like :search ";
$sql .= " or lower(fifo_extension) like :search ";
$sql .= " or lower(fifo_description) like :search ";
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
$sql .= "and u.domain_uuid = d.domain_uuid ";
$sql .= order_by($order_by, $order, '', '');
$sql .= limit_offset($rows_per_page, $offset);
$database = new database;
$fifo = $database->select($sql, $parameters ?? null, 'all');
unset($sql, $parameters);
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//additional includes
$document['title'] = $text['title-fifos'];
require_once "resources/header.php";
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-fifos']." (".$num_rows.")</b></div>\n";
echo " <div class='actions'>\n";
if (permission_exists('fifo_add')) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','name'=>'btn_add','link'=>'fifo_edit.php']);
}
if (permission_exists('fifo_add') && $fifo) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display:none;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
}
if (permission_exists('fifo_edit') && $fifo) {
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'id'=>'btn_toggle','name'=>'btn_toggle','style'=>'display:none;','onclick'=>"modal_open('modal-toggle','btn_toggle');"]);
}
if (permission_exists('fifo_delete') && $fifo) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display:none;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
echo "<form id='form_search' class='inline' method='get'>\n";
if (permission_exists('fifo_all')) {
if ($show == 'all') {
echo " <input type='hidden' name='show' value='all'>\n";
}
else {
echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?show=all&search='.$search]);
}
}
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown=''>";
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search']);
if ($paging_controls_mini != '') {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
}
echo " </form>\n";
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (permission_exists('fifo_add') && $fifo) {
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('copy'); list_form_submit('form_list');"])]);
}
if (permission_exists('fifo_edit') && $fifo) {
echo modal::create(['id'=>'modal-toggle','type'=>'toggle','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_toggle','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('toggle'); list_form_submit('form_list');"])]);
}
if (permission_exists('fifo_delete') && $fifo) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
}
echo $text['title_description-fifo']."\n";
echo "<br /><br />\n";
echo "<form id='form_list' method='post'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<input type='hidden' name='search' value=\"".escape($search ?? '')."\">\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('fifo_add') || permission_exists('fifo_edit') || permission_exists('fifo_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".empty($fifo ? "style='visibility: hidden;'" : null).">\n";
echo " </th>\n";
}
if ($show == 'all' && permission_exists('fifo_all')) {
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order);
}
echo th_order_by('fifo_name', $text['label-fifo_name'], $order_by, $order);
echo th_order_by('fifo_extension', $text['label-fifo_extension'], $order_by, $order);
echo th_order_by('fifo_agent_queue', $text['label-fifo_agent_queue'], $order_by, $order);
echo th_order_by('fifo_agent_status', $text['label-fifo_agent_status'], $order_by, $order);
echo th_order_by('fifo_order', $text['label-fifo_order'], $order_by, $order);
echo th_order_by('fifo_enabled', $text['label-enabled'], $order_by, $order, null, "class='center'");
echo " <th class='hide-sm-dn'>".$text['label-fifo_description']."</th>\n";
if (permission_exists('fifo_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
if (!empty($fifo) && is_array($fifo) && @sizeof($fifo) != 0) {
$x = 0;
foreach ($fifo as $row) {
if (permission_exists('fifo_edit')) {
$list_row_url = "fifo_edit.php?id=".urlencode($row['fifo_uuid']);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('fifo_add') || permission_exists('fifo_edit') || permission_exists('fifo_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='fifo[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='fifo[$x][fifo_uuid]' value='".escape($row['fifo_uuid'])."' />\n";
echo " </td>\n";
}
if ($show == 'all' && permission_exists('fifo_all')) {
echo " <td>".escape($row['domain_name'])."</td>\n";
}
echo " <td>\n";
if (permission_exists('fifo_edit')) {
echo " <a href='".$list_row_url."' title=\"".$text['button-edit']."\">".escape($row['fifo_name'])."</a>\n";
}
else {
echo " ".escape($row['fifo_name']);
}
echo " </td>\n";
echo " <td>".escape($row['fifo_extension'])."</td>\n";
echo " <td>".escape($row['fifo_agent_queue'])."</td>\n";
echo " <td>".escape($row['fifo_agent_status'])."</td>\n";
echo " <td>".escape($row['fifo_order'])."</td>\n";
if (permission_exists('fifo_edit')) {
echo " <td class='no-link center'>\n";
echo " <input type='hidden' name='number_translations[$x][fifo_enabled]' value='".escape($row['fifo_enabled'])."' />\n";
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['fifo_enabled']],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);
}
else {
echo " <td class='center'>\n";
echo $text['label-'.$row['fifo_enabled']];
}
echo " </td>\n";
echo " <td class='description overflow hide-sm-dn'>".escape($row['fifo_description'])."</td>\n";
if (permission_exists('fifo_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n";
$x++;
}
unset($fifo);
}
echo "</table>\n";
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//include the footer
require_once "resources/footer.php";
?>

View File

@ -1,556 +0,0 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Copyright (C) 2010 - 2023
All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/paging.php";
//check permissions
if (permission_exists('fifo_add')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//get http values and set them as variables
if (count($_POST)>0) {
$order_by = $_GET["order_by"] ?? null;
$order = $_GET["order"] ?? null;
$extension_name = $_POST["extension_name"];
$queue_extension_number = $_POST["queue_extension_number"];
$agent_queue_extension_number = $_POST["agent_queue_extension_number"];
$agent_login_logout_extension_number = $_POST["agent_login_logout_extension_number"];
$dialplan_order = $_POST["dialplan_order"];
$pin_number = $_POST["pin_number"] ?? null;
$profile = $_POST["profile"] ?? null;
$flags = $_POST["flags"] ?? null;
$dialplan_enabled = $_POST["dialplan_enabled"];
$dialplan_description = $_POST["dialplan_description"];
if (empty($dialplan_enabled)) { $dialplan_enabled = "true"; } //set default to enabled
}
//process the HTTP POST
if (count($_POST) > 0 && empty($_POST["persistformvar"])) {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: dialplans.php');
exit;
}
//check for all required data
if (empty($domain_uuid)) { $msg .= $text['message-required']."domain_uuid<br>\n"; }
if (empty($extension_name)) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; }
if (empty($queue_extension_number)) { $msg .= $text['message-required'].$text['label-extension']."<br>\n"; }
if (!empty($msg) && empty($_POST["persistformvar"])) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "<div align='center'>\n";
echo "<table><tr><td>\n";
echo $msg."<br />";
echo "</td></tr></table>\n";
persistformvar($_POST);
echo "</div>\n";
require_once "resources/footer.php";
return;
}
if (!empty($queue_extension_number)) {
//--------------------------------------------------------
//Caller Queue [FIFO in]
//<extension name="Queue_Call_In">
// <condition field="destination_number" expression="^7011\$">
// <action application="set" data="fifo_music=$${hold_music}"/>
// <action application="answer"/>
// <action application="fifo" data="myq in"/>
// </condition>
//</extension>
//--------------------------------------------------------
$queue_name = $extension_name."@\${domain_name}";
$app_uuid = '16589224-c876-aeb3-f59f-523a1c0801f7';
$dialplan_uuid = uuid();
$dialplan_context = $_SESSION['domain_name'];
$domain_uuid = $_SESSION['domain_uuid'];
$dialplan_detail_order = 0;
//start building the dialplan array
$y=0;
$array["dialplans"][$y]["domain_uuid"] = $domain_uuid;
$array["dialplans"][$y]["dialplan_uuid"] = $dialplan_uuid;
$array["dialplans"][$y]["app_uuid"] = $app_uuid;
$array["dialplans"][$y]["dialplan_name"] = $extension_name;
$array["dialplans"][$y]["dialplan_order"] = "$dialplan_order";
$array["dialplans"][$y]["dialplan_context"] = $dialplan_context;
$array["dialplans"][$y]["dialplan_enabled"] = $dialplan_enabled;
$array["dialplans"][$y]["dialplan_order"] = $dialplan_order;
$array["dialplans"][$y]["dialplan_description"] = $dialplan_description;
$y++;
if (is_uuid($dialplan_uuid)) {
//set the destination number
$array["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$array["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
$array["dialplan_details"][$y]["dialplan_detail_tag"] = "condition";
$array["dialplan_details"][$y]["dialplan_detail_type"] = "destination_number";
$array["dialplan_details"][$y]["dialplan_detail_data"] = '^'.$queue_extension_number.'$';
$array["dialplan_details"][$y]["dialplan_detail_inline"] = "";
$array["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
if ((strlen($agent_queue_extension_number) > 0) || (!empty($agent_login_logout_extension_number))) {
$array["dialplan_details"][$y]["dialplan_detail_break"] = 'on-true';
}
$array["dialplan_details"][$y]["dialplan_detail_group"] = '1';
$y++;
//increment the dialplan detial order
$dialplan_detail_order = $dialplan_detail_order + 10;
//set the hold music
$array["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$array["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
$array["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
$array["dialplan_details"][$y]["dialplan_detail_type"] = "set";
$array["dialplan_details"][$y]["dialplan_detail_data"] = "fifo_music=\$\${hold_music}";
$array["dialplan_details"][$y]["dialplan_detail_inline"] = "true";
$array["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
$array["dialplan_details"][$y]["dialplan_detail_group"] = '1';
$y++;
//increment the dialplan detial order
$dialplan_detail_order = $dialplan_detail_order + 10;
//action answer
$array["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$array["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
$array["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
$array["dialplan_details"][$y]["dialplan_detail_type"] = "answer";
$array["dialplan_details"][$y]["dialplan_detail_data"] = "";
$array["dialplan_details"][$y]["dialplan_detail_inline"] = "";
$array["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
$array["dialplan_details"][$y]["dialplan_detail_group"] = '1';
$y++;
//increment the dialplan detial order
$dialplan_detail_order = $dialplan_detail_order + 10;
//action fifo
$queue_action_data = $queue_name." in";
$array["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$array["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
$array["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
$array["dialplan_details"][$y]["dialplan_detail_type"] = "fifo";
$array["dialplan_details"][$y]["dialplan_detail_data"] = $queue_action_data;
$array["dialplan_details"][$y]["dialplan_detail_inline"] = "";
$array["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
$array["dialplan_details"][$y]["dialplan_detail_group"] = '1';
$y++;
}
}
// Caller Queue / Agent Queue
if (!empty($agent_queue_extension_number)) {
//--------------------------------------------------------
// Agent Queue [FIFO out]
//<extension name="Agent_Wait">
// <condition field="destination_number" expression="^7010\$">
// <action application="set" data="fifo_music=$${hold_music}"/>
// <action application="answer"/>
// <action application="fifo" data="myq out wait"/>
// </condition>
//</extension>
//--------------------------------------------------------
$queue_name = $extension_name."@\${domain_name}";
if (is_uuid($dialplan_uuid)) {
//set the dialplan detial order to zero
$dialplan_detail_order = 0;
//set the destination number
$array["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$array["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
$array["dialplan_details"][$y]["dialplan_detail_tag"] = "condition";
$array["dialplan_details"][$y]["dialplan_detail_type"] = "destination_number";
$array["dialplan_details"][$y]["dialplan_detail_data"] = '^'.$agent_queue_extension_number.'$';
$array["dialplan_details"][$y]["dialplan_detail_inline"] = "";
if (!empty($agent_login_logout_extension_number)) {
$array["dialplan_details"][$y]["dialplan_detail_break"] = 'on-true';
}
$array["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
$array["dialplan_details"][$y]["dialplan_detail_group"] = '2';
$y++;
//increment the dialplan detial order
$dialplan_detail_order = $dialplan_detail_order + 10;
//set the hold music
$array["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$array["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
$array["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
$array["dialplan_details"][$y]["dialplan_detail_type"] = "set";
$array["dialplan_details"][$y]["dialplan_detail_data"] = "fifo_music=\$\${hold_music}";
$array["dialplan_details"][$y]["dialplan_detail_inline"] = "true";
$array["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
$array["dialplan_details"][$y]["dialplan_detail_group"] = '2';
$y++;
//increment the dialplan detial order
$dialplan_detail_order = $dialplan_detail_order + 10;
//action answer
$array["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$array["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
$array["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
$array["dialplan_details"][$y]["dialplan_detail_type"] = "answer";
$array["dialplan_details"][$y]["dialplan_detail_data"] = "";
$array["dialplan_details"][$y]["dialplan_detail_inline"] = "";
$array["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
$array["dialplan_details"][$y]["dialplan_detail_group"] = '2';
$y++;
//increment the dialplan detial order
$dialplan_detail_order = $dialplan_detail_order + 10;
//action fifo
$queue_action_data = $queue_name." out wait";
$array["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$array["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
$array["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
$array["dialplan_details"][$y]["dialplan_detail_type"] = "fifo";
$array["dialplan_details"][$y]["dialplan_detail_data"] = $queue_action_data;
$array["dialplan_details"][$y]["dialplan_detail_inline"] = "";
$array["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
$array["dialplan_details"][$y]["dialplan_detail_group"] = '2';
$y++;
}
}
// agent or member login / logout
if (!empty($agent_login_logout_extension_number)) {
//--------------------------------------------------------
// Agent Queue [FIFO login logout]
//<extension name="Agent_login_logout">
// <condition field="destination_number" expression="^7012\$">
// <action application="set" data="queue_name=myq" inline="true"/>
// <action application="set" data="user_name=${caller_id_number}@${domain_name}" inline="true"/>
// <action application="set" data="fifo_simo=1" inline="true"/>
// <action application="set" data="fifo_timeout=10" inline="true"/>
// <action application="set" data="fifo_lag=10" inline="true"/>
// <action application="set" data="pin_number=" inline="true"/>
// <action application="lua" data="fifo_member.lua"/>
// </condition>
//</extension>
//--------------------------------------------------------
$queue_name = $extension_name."@\${domain_name}";
if (is_uuid($dialplan_uuid)) {
//set the dialplan detial order to zero
$dialplan_detail_order = 0;
//set the destination number
$array["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$array["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
$array["dialplan_details"][$y]["dialplan_detail_tag"] = "condition";
$array["dialplan_details"][$y]["dialplan_detail_type"] = "destination_number";
$array["dialplan_details"][$y]["dialplan_detail_data"] = '^'.$agent_login_logout_extension_number.'$';
$array["dialplan_details"][$y]["dialplan_detail_inline"] = "";
$array["dialplan_details"][$y]["dialplan_detail_break"] = 'on-true';
$array["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
$array["dialplan_details"][$y]["dialplan_detail_group"] = '3';
$y++;
//increment the dialplan detial order
$dialplan_detail_order = $dialplan_detail_order + 10;
//set the queue_name
$array["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$array["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
$array["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
$array["dialplan_details"][$y]["dialplan_detail_type"] = "set";
$array["dialplan_details"][$y]["dialplan_detail_data"] = 'queue_name='.$queue_name;
$array["dialplan_details"][$y]["dialplan_detail_inline"] = "true";
$array["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
$array["dialplan_details"][$y]["dialplan_detail_group"] = '3';
$y++;
//increment the dialplan detial order
$dialplan_detail_order = $dialplan_detail_order + 10;
//set the user_name
$array["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$array["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
$array["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
$array["dialplan_details"][$y]["dialplan_detail_type"] = "set";
$array["dialplan_details"][$y]["dialplan_detail_data"] = 'user_name=${caller_id_number}@${domain_name}';
$array["dialplan_details"][$y]["dialplan_detail_inline"] = "true";
$array["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
$array["dialplan_details"][$y]["dialplan_detail_group"] = '3';
$y++;
//increment the dialplan detial order
$dialplan_detail_order = $dialplan_detail_order + 10;
//set the fifo_simo
$array["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$array["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
$array["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
$array["dialplan_details"][$y]["dialplan_detail_type"] = "set";
$array["dialplan_details"][$y]["dialplan_detail_data"] = 'fifo_simo=1';
$array["dialplan_details"][$y]["dialplan_detail_inline"] = "true";
$array["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
$array["dialplan_details"][$y]["dialplan_detail_group"] = '3';
$y++;
//increment the dialplan detial order
$dialplan_detail_order = $dialplan_detail_order + 10;
//set the fifo_timeout
$array["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$array["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
$array["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
$array["dialplan_details"][$y]["dialplan_detail_type"] = "set";
$array["dialplan_details"][$y]["dialplan_detail_data"] = 'fifo_timeout=10';
$array["dialplan_details"][$y]["dialplan_detail_inline"] = "true";
$array["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
$array["dialplan_details"][$y]["dialplan_detail_group"] = '3';
$y++;
//increment the dialplan detial order
$dialplan_detail_order = $dialplan_detail_order + 10;
//set the fifo_lag
$array["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$array["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
$array["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
$array["dialplan_details"][$y]["dialplan_detail_type"] = "set";
$array["dialplan_details"][$y]["dialplan_detail_data"] = 'fifo_lag=10';
$array["dialplan_details"][$y]["dialplan_detail_inline"] = "true";
$array["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
$array["dialplan_details"][$y]["dialplan_detail_group"] = '3';
$y++;
//increment the dialplan detial order
$dialplan_detail_order = $dialplan_detail_order + 10;
//set the pin_number
$array["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$array["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
$array["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
$array["dialplan_details"][$y]["dialplan_detail_type"] = "set";
$array["dialplan_details"][$y]["dialplan_detail_data"] = 'pin_number=';
$array["dialplan_details"][$y]["dialplan_detail_inline"] = "true";
$array["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
$array["dialplan_details"][$y]["dialplan_detail_group"] = '3';
$y++;
//increment the dialplan detial order
$dialplan_detail_order = $dialplan_detail_order + 10;
//action lua
$array["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$array["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
$array["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
$array["dialplan_details"][$y]["dialplan_detail_type"] = "lua";
$array["dialplan_details"][$y]["dialplan_detail_data"] = "fifo_member.lua";
$array["dialplan_details"][$y]["dialplan_detail_inline"] = "";
$array["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
$array["dialplan_details"][$y]["dialplan_detail_group"] = '3';
$y++;
}
}
//add the dialplan permission
$p = new permissions;
$p->add("dialplan_add", "temp");
$p->add("dialplan_edit", "temp");
//save to the data
$database = new database;
$database->app_name = 'fifo';
$database->app_uuid = '16589224-c876-aeb3-f59f-523a1c0801f7';
$database->save($array);
//$message = $database->message;
//remove the temporary permission
$p->delete("dialplan_add", "temp");
$p->delete("dialplan_edit", "temp");
//clear the cache
$cache = new cache;
$cache->delete("dialplan:".$_SESSION["domain_name"]);
//redirect the user
message::add($text['message-add']);
header("Location: ".PROJECT_PATH."/app/dialplans/dialplans.php?app_uuid=16589224-c876-aeb3-f59f-523a1c0801f7");
return;
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//includes and title
require_once "resources/header.php";
$document['title'] = $text['title-queue_add'];
//show the content
echo "<form method='post' name='frm' id='frm'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-queue_add']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>PROJECT_PATH.'/app/dialplans/dialplans.php?app_uuid=16589224-c876-aeb3-f59f-523a1c0801f7']);
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['description-queue_add']."\n";
echo "<br /><br />\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td width='30%' class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-name']."\n";
echo " </td>\n";
echo " <td width='70%' class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='extension_name' maxlength='255' value=\"".($extension_name ?? null)."\" required='required'>\n";
echo " <br />\n";
echo " ".$text['description-name']."\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-extension']."\n";
echo " </td>\n";
echo " <td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='queue_extension_number' maxlength='255' min='0' step='1' value=\"".($queue_extension_number ?? null)."\" required='required'>\n";
echo " <br />\n";
echo " ".($text['description-extension'] ?? null)."\n";
echo " </td>\n";
echo " </tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-order']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select name='dialplan_order' class='formfld'>\n";
for ($i = 300; $i <= 999; $i++) {
$selected = !empty($dialplan_order) && $dialplan_order == $i ? "selected" : null;
echo "<option value='".$i."' ".$selected.">".$i."</option>\n";
}
echo " </select>\n";
echo " <br />\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-enabled']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') {
echo " <label class='switch'>\n";
echo " <input type='checkbox' id='dialplan_enabled' name='dialplan_enabled' value='true' checked='checked'>\n";
echo " <span class='slider'></span>\n";
echo " </label>\n";
}
else {
echo " <select class='formfld' id='dialplan_enabled' name='dialplan_enabled'>\n";
echo " <option value='true' ".($dialplan_enabled == 'true' ? "selected='selected'" : null).">".$text['option-true']."</option>\n";
echo " <option value='false' ".($dialplan_enabled == 'false' ? "selected='selected'" : null).">".$text['option-false']."</option>\n";
echo " </select>\n";
}
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-description']."\n";
echo "</td>\n";
echo "<td colspan='4' class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='dialplan_description' maxlength='255' value=\"".($dialplan_description ?? null)."\">\n";
echo "<br />\n";
echo "\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br><br>\n";
echo "<b>".$text['header-agent_details']."</b>\n";
echo "<br /><br />\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-agent_queue_extension']."\n";
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='agent_queue_extension_number' maxlength='255' min='0' step='1' value=\"".($agent_queue_extension_number ?? null)."\">\n";
echo "<br />\n";
echo $text['description-agent_queue_extension']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-agent_loginout_extension']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='agent_login_logout_extension_number' maxlength='255' min='0' step='1' value=\"".($agent_login_logout_extension_number ?? null)."\">\n";
echo "<br />\n";
echo $text['description-agent_loginout_extension']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br><br>\n";
if (!empty($action) && $action == "update") {
echo "<input type='hidden' name='dialplan_uuid' value='".($dialplan_uuid ?? null)."'>\n";
}
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//show the footer
require_once "resources/footer.php";
?>

639
app/fifo/fifo_edit.php Normal file
View File

@ -0,0 +1,639 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2024
the Initial Developer. All Rights Reserved.
*/
//set the include path
$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
set_include_path(parse_ini_file($conf[0])['document.root']);
//includes files
require_once "resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('fifo_add') || permission_exists('fifo_edit')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//add the settings object
$settings = new settings(["domain_uuid" => $_SESSION['domain_uuid'], "user_uuid" => $_SESSION['user_uuid']]);
//set from session variables
$button_icon_back = $settings->get('theme', 'button_icon_back', '');
$button_icon_copy = $settings->get('theme', 'button_icon_copy', '');
$button_icon_delete = $settings->get('theme', 'button_icon_delete', '');
$button_icon_save = $settings->get('theme', 'button_icon_save', '');
$input_toggle_style = $settings->get('theme', 'input_toggle_style', 'switch round');
//action add or update
if (is_uuid($_REQUEST["id"])) {
$action = "update";
$fifo_uuid = $_REQUEST["id"];
$id = $_REQUEST["id"];
}
else {
$action = "add";
}
//get http post variables and set them to php variables
if (!empty($_POST)) {
$dialplan_uuid = $_POST["dialplan_uuid"];
$fifo_name = $_POST["fifo_name"];
$fifo_extension = $_POST["fifo_extension"];
$fifo_agent_status = $_POST["fifo_agent_status"];
$fifo_agent_queue = $_POST["fifo_agent_queue"];
$fifo_members = $_POST["fifo_members"];
$fifo_music = $_POST["fifo_music"];
$domain_uuid = $_POST["domain_uuid"];
$fifo_order = $_POST["fifo_order"];
$fifo_enabled = $_POST["fifo_enabled"];
$fifo_description = $_POST["fifo_description"];
}
//process the data and save it to the database
if (!empty($_POST) && empty($_POST["persistformvar"])) {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: fifo.php');
exit;
}
//process the http post data by submitted action
if ($_POST['action'] != '' && strlen($_POST['action']) > 0) {
//prepare the array(s)
$x = 0;
if (is_array($_POST['fifo_members'])) {
foreach ($_POST['fifo_members'] as $row) {
if (is_uuid($row['fifo_member_uuid']) && $row['checked'] === 'true') {
$array['fifo'][$x]['checked'] = $row['checked'];
$array['fifo'][$x]['fifo_members'][]['fifo_member_uuid'] = $row['fifo_member_uuid'];
$x++;
}
}
}
//send the array to the database class
switch ($_POST['action']) {
case 'copy':
if (permission_exists('fifo_add')) {
$obj = new database;
$obj->copy($array);
}
break;
case 'delete':
if (permission_exists('fifo_delete')) {
$obj = new database;
$obj->delete($array);
}
break;
case 'toggle':
if (permission_exists('fifo_update')) {
$obj = new database;
$obj->toggle($array);
}
break;
}
//redirect the user
if (in_array($_POST['action'], array('copy', 'delete', 'toggle'))) {
header('Location: fifo_edit.php?id='.$id);
exit;
}
}
//check for all required data
$msg = '';
if (strlen($fifo_name) == 0) { $msg .= $text['message-required']." ".$text['label-fifo_name']."<br>\n"; }
if (strlen($fifo_extension) == 0) { $msg .= $text['message-required']." ".$text['label-fifo_extension']."<br>\n"; }
//if (strlen($fifo_agent_status) == 0) { $msg .= $text['message-required']." ".$text['label-fifo_agent_status']."<br>\n"; }
//if (strlen($fifo_agent_queue) == 0) { $msg .= $text['message-required']." ".$text['label-fifo_agent_queue']."<br>\n"; }
//if (strlen($fifo_members) == 0) { $msg .= $text['message-required']." ".$text['label-fifo_members']."<br>\n"; }
//if (strlen($fifo_music) == 0) { $msg .= $text['message-required']." ".$text['label-fifo_music']."<br>\n"; }
if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."<br>\n"; }
if (strlen($fifo_order) == 0) { $msg .= $text['message-required']." ".$text['label-fifo_order']."<br>\n"; }
//if (strlen($fifo_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-fifo_enabled']."<br>\n"; }
//if (strlen($fifo_description) == 0) { $msg .= $text['message-required']." ".$text['label-fifo_description']."<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "<div align='center'>\n";
echo "<table><tr><td>\n";
echo $msg."<br />";
echo "</td></tr></table>\n";
persistformvar($_POST);
echo "</div>\n";
require_once "resources/footer.php";
return;
}
//add the fifo_uuid
if (!is_uuid($_POST["fifo_uuid"])) {
$fifo_uuid = uuid();
}
//add a uuid to dialplan_uuid if it is empty
if (empty($dialplan_uuid) && !is_uuid($dialplan_uuid)) {
$dialplan_uuid = uuid();
}
//prepare the variables
$queue_name = $fifo_extension."@".$_SESSION['domain_name'];
$app_uuid = '16589224-c876-aeb3-f59f-523a1c0801f7';
$dialplan_context = $_SESSION['domain_name'];
$domain_uuid = $_SESSION['domain_uuid'];
$dialplan_detail_order = 0;
//prepare the array
$array['fifo'][0]['fifo_uuid'] = $fifo_uuid;
$array['fifo'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
$array['fifo'][0]['dialplan_uuid'] = $dialplan_uuid;
$array['fifo'][0]['fifo_name'] = $fifo_name;
$array['fifo'][0]['fifo_extension'] = $fifo_extension;
$array['fifo'][0]['fifo_agent_status'] = $fifo_agent_status;
$array['fifo'][0]['fifo_agent_queue'] = $fifo_agent_queue;
$array['fifo'][0]['fifo_music'] = $fifo_music;
$array['fifo'][0]['fifo_order'] = $fifo_order;
$array['fifo'][0]['fifo_enabled'] = $fifo_enabled;
$array['fifo'][0]['fifo_description'] = $fifo_description;
$y = 0;
if (is_array($fifo_members)) {
foreach ($fifo_members as $row) {
if (strlen($row['member_contact']) > 0) {
$array['fifo'][0]['fifo_members'][$y]['fifo_member_uuid'] = $row["fifo_member_uuid"];
$array['fifo'][0]['fifo_members'][$y]['member_contact'] = $row["member_contact"];
$array['fifo'][0]['fifo_members'][$y]['member_call_timeout'] = $row["member_call_timeout"];
//$array['fifo'][0]['fifo_members'][$y]['member_simultaneous'] = $row["member_simultaneous"];
$array['fifo'][0]['fifo_members'][$y]['member_wrap_up_time'] = $row["member_wrap_up_time"];
$array['fifo'][0]['fifo_members'][$y]['member_enabled'] = $row["member_enabled"];
$y++;
}
}
}
//add the fifo dialplan
if (!empty($fifo_extension)) {
//escape the * symbol
$fifo_agent_status_xml = str_replace("*", "\*", $fifo_agent_status);
$fifo_agent_queue_xml = str_replace("*", "\*", $fifo_agent_queue);
//build the xml dialplan
$dialplan_xml = "<extension name=\"".xml::sanitize($fifo_name)."\" continue=\"false\" uuid=\"".xml::sanitize($dialplan_uuid)."\">\n";
$dialplan_xml .= " <condition field=\"destination_number\" expression=\"^".xml::sanitize($fifo_extension)."\$\" break=\"on-true\">\n";
$dialplan_xml .= " <action application=\"set\" data=\"fifo_music=".$fifo_music."\" inline=\"true\"/>\n";
$dialplan_xml .= " <action application=\"answer\" data=\"\"/>\n";
$dialplan_xml .= " <action application=\"fifo\" data=\"$queue_name in\"/>\n";
$dialplan_xml .= " </condition>\n";
$dialplan_xml .= " <condition field=\"destination_number\" expression=\"^".$fifo_agent_status_xml."\$\" break=\"on-true\">\n";
$dialplan_xml .= " <action application=\"set\" data=\"queue_name=$queue_name\" inline=\"true\"/>\n";
$dialplan_xml .= " <action application=\"set\" data=\"user_name=\${caller_id_number}@\${domain_name}\" inline=\"true\"/>\n";
$dialplan_xml .= " <action application=\"set\" data=\"pin_number=\" inline=\"true\"/>\n";
$dialplan_xml .= " <action application=\"lua\" data=\"fifo_member.lua\"/>\n";
$dialplan_xml .= " </condition>\n";
$dialplan_xml .= " <condition field=\"destination_number\" expression=\"^".$fifo_agent_queue_xml."\$\" break=\"on-true\">\n";
$dialplan_xml .= " <action application=\"set\" data=\"fifo_music=".$fifo_music."\" inline=\"true\"/>\n";
$dialplan_xml .= " <action application=\"answer\" data=\"\"/>\n";
$dialplan_xml .= " <action application=\"fifo\" data=\"$queue_name out wait\"/>\n";
$dialplan_xml .= " </condition>\n";
$dialplan_xml .= "</extension>\n";
//start building the dialplan array
$y=0;
$array["dialplans"][$y]["domain_uuid"] = $domain_uuid;
$array["dialplans"][$y]["dialplan_uuid"] = $dialplan_uuid;
$array["dialplans"][$y]["app_uuid"] = $app_uuid;
$array["dialplans"][$y]["dialplan_name"] = $fifo_name;
$array["dialplans"][$y]["dialplan_number"] = $fifo_extension;
$array["dialplans"][$y]["dialplan_xml"] = $dialplan_xml;
$array["dialplans"][$y]["dialplan_order"] = $fifo_order;
$array["dialplans"][$y]["dialplan_context"] = $_SESSION['domain_name'];
$array["dialplans"][$y]["dialplan_enabled"] = $fifo_enabled;
$array["dialplans"][$y]["dialplan_description"] = $fifo_description;
$y++;
}
//add the dialplan permission
$p = new permissions;
$p->add("dialplan_add", "temp");
$p->add("dialplan_edit", "temp");
//save the data
$database = new database;
$database->app_name = 'fifo';
$database->app_uuid = '16589224-c876-aeb3-f59f-523a1c0801f7';
$result = $database->save($array);
//remove the temporary permission
$p->delete("dialplan_add", "temp");
$p->delete("dialplan_edit", "temp");
//redirect the user
if (isset($action)) {
if ($action == "add") {
$_SESSION["message"] = $text['message-add'];
}
if ($action == "update") {
$_SESSION["message"] = $text['message-update'];
}
//header('Location: fifo.php');
header('Location: fifo_edit.php?id='.urlencode($fifo_uuid));
return;
}
}
//pre-populate the form
if (is_array($_GET) && $_POST["persistformvar"] != "true") {
$sql = "select ";
$sql .= " dialplan_uuid, ";
$sql .= " fifo_uuid, ";
$sql .= " fifo_name, ";
$sql .= " fifo_extension, ";
$sql .= " fifo_agent_status, ";
$sql .= " fifo_agent_queue, ";
$sql .= " fifo_music, ";
$sql .= " domain_uuid, ";
$sql .= " fifo_order, ";
$sql .= " cast(fifo_enabled as text), ";
$sql .= " fifo_description ";
$sql .= "from v_fifo ";
$sql .= "where fifo_uuid = :fifo_uuid ";
//$sql .= "and domain_uuid = :domain_uuid ";
//$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['fifo_uuid'] = $fifo_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row) && @sizeof($row) != 0) {
$dialplan_uuid = $row["dialplan_uuid"];
$fifo_name = $row["fifo_name"];
$fifo_extension = $row["fifo_extension"];
$fifo_agent_status = $row["fifo_agent_status"];
$fifo_agent_queue = $row["fifo_agent_queue"];
$fifo_music = $row["fifo_music"];
$domain_uuid = $row["domain_uuid"];
$fifo_order = $row["fifo_order"];
$fifo_enabled = $row["fifo_enabled"];
$fifo_description = $row["fifo_description"];
}
unset($sql, $parameters, $row);
}
//get the child data
if (is_uuid($fifo_uuid)) {
$sql = "select ";
$sql .= " fifo_member_uuid, ";
$sql .= " member_contact, ";
$sql .= " member_call_timeout, ";
//$sql .= " member_simultaneous, ";
$sql .= " member_wrap_up_time, ";
$sql .= " cast(member_enabled as text) ";
$sql .= "from v_fifo_members ";
$sql .= "where fifo_uuid = :fifo_uuid ";
//$sql .= "and domain_uuid = '".$domain_uuid."' ";
//$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['fifo_uuid'] = $fifo_uuid;
$database = new database;
$fifo_members = $database->select($sql, $parameters, 'all');
unset ($sql, $parameters);
}
//add a uuid to dialplan_uuid if it is empty
if (empty($dialplan_uuid) && !is_uuid($dialplan_uuid)) {
$dialplan_uuid = uuid();
}
//add the $fifo_member_uuid
if (!is_uuid($fifo_member_uuid)) {
$fifo_member_uuid = uuid();
}
//add an empty row
$x = is_array($fifo_members) ? count($fifo_members) : 0;
$fifo_members[$x]['domain_uuid'] = $_SESSION['domain_uuid'];
$fifo_members[$x]['fifo_uuid'] = $fifo_uuid;
$fifo_members[$x]['fifo_member_uuid'] = uuid();
$fifo_members[$x]['member_contact'] = '';
$fifo_members[$x]['member_call_timeout'] = '';
//$fifo_members[$x]['member_simultaneous'] = '';
$fifo_members[$x]['member_wrap_up_time'] = '';
$fifo_members[$x]['member_enabled'] = '';
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//initialize the destinations object
$destination = new destinations;
//set the defaults
if (empty($fifo_order)) {
$fifo_order = 50;
}
if (!isset($fifo_enabled)) {
// $fifo_enabled = true;
}
//show the header
$document['title'] = $text['title-fifo'];
require_once "resources/header.php";
//show the content
echo "<form name='frm' id='frm' method='post' action=''>\n";
echo "<input class='formfld' type='hidden' name='fifo_uuid' value='".escape($fifo_uuid)."'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-fifo']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$button_icon_back,'id'=>'btn_back','collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'fifo.php']);
if ($action == 'update') {
if (permission_exists('fifo_member_add')) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$button_icon_copy,'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
}
if (permission_exists('fifo_member_delete')) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$button_icon_delete,'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; margin-right: 15px;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
}
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$button_icon_save,'id'=>'btn_save','collapse'=>'hide-xs']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['title_description-fifo']."\n";
echo "<br /><br />\n";
if ($action == 'update') {
if (permission_exists('fifo_add')) {
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'copy','onclick'=>"modal_close();"])]);
}
if (permission_exists('fifo_delete')) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'delete','onclick'=>"modal_close();"])]);
}
}
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-fifo_name']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='fifo_name' maxlength='255' value='".escape($fifo_name)."'>\n";
echo "<br />\n";
echo $text['description-fifo_name']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-fifo_extension']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='fifo_extension' maxlength='255' value='".escape($fifo_extension)."'>\n";
echo "<br />\n";
echo $text['description-fifo_extension']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-fifo_agent_status']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='fifo_agent_status' maxlength='255' value='".escape($fifo_agent_status)."'>\n";
echo "<br />\n";
echo $text['description-fifo_agent_status']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-fifo_agent_queue']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='fifo_agent_queue' maxlength='255' value='".escape($fifo_agent_queue)."'>\n";
echo "<br />\n";
echo $text['description-fifo_agent_queue']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-fifo_members']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <table>\n";
echo " <tr>\n";
echo " <th class='vtablereq'>".$text['label-member_contact']."</th>\n";
echo " <th class='vtablereq'>".$text['label-member_call_timeout']."</th>\n";
//echo " <th class='vtablereq'>".$text['label-member_simultaneous']."</th>\n";
echo " <th class='vtablereq'>".$text['label-member_wrap_up_time']."</th>\n";
echo " <th class='vtablereq'>".$text['label-member_enabled']."</th>\n";
if (is_array($fifo_members) && @sizeof($fifo_members) > 1 && permission_exists('fifo_member_delete')) {
echo " <td class='vtable edit_delete_checkbox_all' onmouseover=\"swap_display('delete_label_details', 'delete_toggle_details');\" onmouseout=\"swap_display('delete_label_details', 'delete_toggle_details');\">\n";
echo " <span id='delete_label_details'>".$text['label-action']."</span>\n";
echo " <span id='delete_toggle_details'><input type='checkbox' id='checkbox_all_details' name='checkbox_all' onclick=\"edit_all_toggle('details'); checkbox_on_change(this);\"></span>\n";
echo " </td>\n";
}
echo " </tr>\n";
$x = 0;
if (permission_exists('fifo_member_edit')) {
foreach($fifo_members as $row) {
$member_contact = $destination->select('user_contact', 'fifo_members['.$x.'][member_contact]', $row['member_contact'] ?? null);
if (empty($row["member_call_timeout"])) { $row["member_call_timeout"] = '20'; }
//if (empty($row["member_simultaneous"])) { $row["member_simultaneous"] = '3'; }
if (empty($row["member_wrap_up_time"])) { $row["member_wrap_up_time"] = '10'; }
echo " <tr>\n";
echo " <input type='hidden' name='fifo_members[$x][domain_uuid]' value=\"".escape($row["domain_uuid"])."\">\n";
echo " <input type='hidden' name='fifo_members[$x][fifo_uuid]' value=\"".escape($row["fifo_uuid"])."\">\n";
echo " <input type='hidden' name='fifo_members[$x][fifo_member_uuid]' value=\"".escape($row["fifo_member_uuid"])."\">\n";
echo " <td class='formfld'>\n";
echo " $member_contact\n";
echo " </td>\n";
echo " <td class='formfld'>\n";
echo " <input class='formfld' type='text' name='fifo_members[$x][member_call_timeout]' maxlength='255' style='width:55px;' value=\"".escape($row["member_call_timeout"])."\">\n";
echo " </td>\n";
//echo " <td class='formfld'>\n";
//echo " <input class='formfld' type='text' name='fifo_members[$x][member_simultaneous]' maxlength='255' style='width:55px;' value=\"".escape($row["member_simultaneous"])."\">\n";
//echo " </td>\n";
echo " <td class='formfld'>\n";
echo " <input class='formfld' type='text' name='fifo_members[$x][member_wrap_up_time]' maxlength='255' style='width:55px;' value=\"".escape($row["member_wrap_up_time"])."\">\n";
echo " </td>\n";
echo " <td class='formfld'>\n";
if (substr($input_toggle_style, 0, 6) == 'switch') {
echo " <label class='switch'>\n";
echo " <input type='checkbox' id='member_enabled' name='fifo_members[$x][member_enabled]' value='true' ".($row['member_enabled'] == 'true' ? "checked='checked'" : null).">\n";
echo " <span class='slider'></span>\n";
echo " </label>\n";
}
else {
echo " <select class='formfld' id='member_enabled' name='fifo_members[$x][member_enabled]'>\n";
echo " <option value='true' ".($row['member_enabled'] == 'true' ? "selected='selected'" : null).">".$text['option-true']."</option>\n";
echo " <option value='false' ".($row['$member_enabled'] == 'false' ? "selected='selected'" : null).">".$text['option-false']."</option>\n";
echo " </select>\n";
}
echo " </td>\n";
if (is_array($fifo_members) && @sizeof($fifo_members) > 1 && permission_exists('fifo_member_delete')) {
if (is_uuid($row['fifo_member_uuid'])) {
echo " <td class='vtable' style='text-align: center; padding-bottom: 3px;'>\n";
echo " <input type='checkbox' name='fifo_members[".$x."][checked]' value='true' class='chk_delete checkbox_details' onclick=\"checkbox_on_change(this);\">\n";
echo " </td>\n";
}
else {
echo " <td></td>\n";
}
}
echo " </tr>\n";
$x++;
}
}
echo " </table>\n";
echo "<br />\n";
echo $text['description-member_enabled']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-fifo_music']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
//echo " <input class='formfld' type='text' name='fifo_music' maxlength='255' value='".escape($fifo_music)."'>\n";
$ringbacks = new ringbacks;
echo $ringbacks->select('fifo_music', $fifo_music);
echo "<br />\n";
echo $text['description-fifo_music']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-domain_uuid']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <select class='formfld' name='domain_uuid'>\n";
if (strlen($domain_uuid) == 0) {
echo " <option value='' selected='selected'>".$text['select-global']."</option>\n";
}
else {
echo " <option value=''>".$text['label-global']."</option>\n";
}
foreach ($_SESSION['domains'] as $row) {
if ($row['domain_uuid'] == $domain_uuid) {
echo " <option value='".$row['domain_uuid']."' selected='selected'>".escape($row['domain_name'])."</option>\n";
}
else {
echo " <option value='".$row['domain_uuid']."'>".$row['domain_name']."</option>\n";
}
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-domain_uuid']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-fifo_order']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <select name='fifo_order' class='formfld'>\n";
$i=0;
while ($i<=999) {
$selected = ($i == $fifo_order) ? "selected" : null;
if (strlen($i) == 1) {
echo " <option value='00$i' ".$selected.">00$i</option>\n";
}
if (strlen($i) == 2) {
echo " <option value='0$i' ".$selected.">0$i</option>\n";
}
if (strlen($i) == 3) {
echo " <option value='$i' ".$selected.">$i</option>\n";
}
$i++;
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-fifo_order']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-fifo_enabled']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
if (substr($input_toggle_style, 0, 6) == 'switch') {
echo " <label class='switch'>\n";
echo " <input type='checkbox' id='fifo_enabled' name='fifo_enabled' value='true' ".($fifo_enabled == 'true' ? "checked='checked'" : null).">\n";
echo " <span class='slider'></span>\n";
echo " </label>\n";
}
else {
echo " <select class='formfld' id='fifo_enabled' name='fifo_enabled'>\n";
echo " <option value='true' ".($fifo_enabled == 'true' ? "selected='selected'" : null).">".$text['option-true']."</option>\n";
echo " <option value='false' ".($fifo_enabled == 'false' ? "selected='selected'" : null).">".$text['option-false']."</option>\n";
echo " </select>\n";
}
echo "<br />\n";
echo $text['description-fifo_enabled']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-fifo_description']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <textarea class='formfld' name='fifo_description' style='width: 185px; height: 80px;'>".$fifo_description."</textarea>\n";
echo "<br />\n";
echo $text['description-fifo_description']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "<br /><br />";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "<input type='hidden' name='dialplan_uuid' value='".escape($dialplan_uuid)."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>

242
app/fifo/resources/fifo.php Normal file
View File

@ -0,0 +1,242 @@
<?php
/**
* fifo class
*
* @method null delete
* @method null toggle
* @method null copy
*/
if (!class_exists('fifo')) {
class fifo {
/**
* declare the variables
*/
private $app_name;
private $app_uuid;
private $name;
private $table;
private $toggle_field;
private $toggle_values;
private $description_field;
private $location;
/**
* called when the object is created
*/
public function __construct() {
//assign the variables
$this->app_name = 'fifo';
$this->app_uuid = '16589224-c876-aeb3-f59f-523a1c0801f7';
$this->name = 'fifo';
$this->table = 'fifo';
$this->toggle_field = 'fifo_enabled';
$this->toggle_values = ['true','false'];
$this->description_field = 'fifo_description';
$this->location = 'fifo.php';
}
/**
* called when there are no references to a particular object
* unset the variables used in the class
*/
public function __destruct() {
foreach ($this as $key => $value) {
unset($this->$key);
}
}
/**
* delete rows from the database
*/
public function delete($records) {
if (permission_exists($this->name.'_delete')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->location);
exit;
}
//delete multiple records
if (is_array($records) && @sizeof($records) != 0) {
//build the delete array
$x = 0;
foreach ($records as $record) {
//add to the array
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
$array[$this->table][$x][$this->name.'_uuid'] = $record['uuid'];
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
}
//increment the id
$x++;
}
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
unset($array);
//set message
message::add($text['message-delete']);
}
unset($records);
}
}
}
/**
* toggle a field between two values
*/
public function toggle($records) {
if (permission_exists($this->name.'_edit')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->location);
exit;
}
//toggle the checked records
if (is_array($records) && @sizeof($records) != 0) {
//get current toggle state
foreach($records as $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
$uuids[] = "'".$record['uuid']."'";
}
}
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
}
}
unset($sql, $parameters, $rows, $row);
}
//build update array
$x = 0;
foreach($states as $uuid => $state) {
//create the array
$array[$this->table][$x][$this->name.'_uuid'] = $uuid;
$array[$this->table][$x][$this->toggle_field] = $state == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0];
//increment the id
$x++;
}
//save the changes
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
unset($array);
//set message
message::add($text['message-toggle']);
}
unset($records, $states);
}
}
}
/**
* copy rows from the database
*/
public function copy($records) {
if (permission_exists($this->name.'_add')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->location);
exit;
}
//copy the checked records
if (is_array($records) && @sizeof($records) != 0) {
//get checked records
foreach($records as $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
$uuids[] = "'".$record['uuid']."'";
}
}
//create the array from existing data
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select * from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$x = 0;
foreach ($rows as $row) {
//copy data
$array[$this->table][$x] = $row;
//add copy to the description
$array[$this->table][$x][$this->name.'_uuid'] = uuid();
$array[$this->table][$x][$this->description_field] = trim($row[$this->description_field]).' ('.$text['label-copy'].')';
//increment the id
$x++;
}
}
unset($sql, $parameters, $rows, $row);
}
//save the changes and set the message
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
unset($array);
//set message
message::add($text['message-copy']);
}
unset($records);
}
}
}
}
}
?>