Mark Crane преди 13 години
родител
ревизия
88ce91930e
променени са 36 файла, в които са добавени 4739 реда и са изтрити 0 реда
  1. 39 0
      fifo_agents/app_config.php
  2. 50 0
      fifo_agents/fifo_agent/root.php
  3. 186 0
      fifo_agents/fifo_agent/v_fifo_agent.php
  4. 412 0
      fifo_agents/fifo_agent/v_fifo_agent_edit.php
  5. 297 0
      fifo_agents/fifo_agent/v_fifo_agent_login.php
  6. 74 0
      fifo_agents/fifo_agent/v_fifo_agent_logout.php
  7. 52 0
      fifo_agents/fifo_agent/v_fifo_agent_remote.php
  8. 50 0
      fifo_agents/fifo_agent_call_logs/root.php
  9. 170 0
      fifo_agents/fifo_agent_call_logs/v_fifo_agent_call_logs.php
  10. 1 0
      fifo_agents/fifo_agent_call_logs/v_fifo_agent_call_logs.sql
  11. 61 0
      fifo_agents/fifo_agent_call_logs/v_fifo_agent_call_logs_delete.php
  12. 299 0
      fifo_agents/fifo_agent_call_logs/v_fifo_agent_call_logs_edit.php
  13. 50 0
      fifo_agents/fifo_agent_profiles/root.php
  14. 161 0
      fifo_agents/fifo_agent_profiles/v_fifo_agent_profile_members.php
  15. 1 0
      fifo_agents/fifo_agent_profiles/v_fifo_agent_profile_members.sql
  16. 62 0
      fifo_agents/fifo_agent_profiles/v_fifo_agent_profile_members_delete.php
  17. 359 0
      fifo_agents/fifo_agent_profiles/v_fifo_agent_profile_members_edit.php
  18. 156 0
      fifo_agents/fifo_agent_profiles/v_fifo_agent_profiles.php
  19. 1 0
      fifo_agents/fifo_agent_profiles/v_fifo_agent_profiles.sql
  20. 72 0
      fifo_agents/fifo_agent_profiles/v_fifo_agent_profiles_delete.php
  21. 222 0
      fifo_agents/fifo_agent_profiles/v_fifo_agent_profiles_edit.php
  22. 50 0
      fifo_agents/fifo_agent_status_logs/root.php
  23. 185 0
      fifo_agents/fifo_agent_status_logs/v_fifo_agent_status_logs.php
  24. 1 0
      fifo_agents/fifo_agent_status_logs/v_fifo_agent_status_logs.sql
  25. 60 0
      fifo_agents/fifo_agent_status_logs/v_fifo_agent_status_logs_delete.php
  26. 262 0
      fifo_agents/fifo_agent_status_logs/v_fifo_agent_status_logs_edit.php
  27. 50 0
      fifo_agents/fifo_languages/root.php
  28. 161 0
      fifo_agents/fifo_languages/v_fifo_agent_languages.php
  29. 1 0
      fifo_agents/fifo_languages/v_fifo_agent_languages.sql
  30. 60 0
      fifo_agents/fifo_languages/v_fifo_agent_languages_delete.php
  31. 337 0
      fifo_agents/fifo_languages/v_fifo_agent_languages_edit.php
  32. 50 0
      fifo_agents/root.php
  33. 206 0
      fifo_agents/v_fifo_agents.php
  34. 1 0
      fifo_agents/v_fifo_agents.sql
  35. 60 0
      fifo_agents/v_fifo_agents_delete.php
  36. 480 0
      fifo_agents/v_fifo_agents_edit.php

+ 39 - 0
fifo_agents/app_config.php

@@ -0,0 +1,39 @@
+<?php
+	/*
+	//application details
+		$apps[$x]['name'] = "FIFO Agents";
+		$apps[$x]['uuid'] = '3b1d4007-6eca-dbca-ee5c-df0263c10583';
+		$apps[$x]['category'] = 'Switch';;
+		$apps[$x]['subcategory'] = '';
+		$apps[$x]['version'] = '';
+		$apps[$x]['license'] = 'Mozilla Public License 1.1';
+		$apps[$x]['url'] = 'http://www.fusionpbx.com';
+		$apps[$x]['description']['en'] = '';
+
+	//menu details
+		$apps[$x]['menu'][0]['title']['en'] = 'Fifo Agents';
+		$apps[$x]['menu'][0]['uuid'] = 'zzz';
+		$apps[$x]['menu'][0]['parent_uuid'] = 'zzz';
+		$apps[$x]['menu'][0]['category'] = 'internal';
+		$apps[$x]['menu'][0]['path'] = '/app/zzz/zzz.php';
+		$apps[$x]['menu'][0]['groups'][] = 'admin';
+		$apps[$x]['menu'][0]['groups'][] = 'superadmin';
+
+	//permission details
+		$apps[$x]['permissions'][0]['name'] = 'zzz';
+		$apps[$x]['permissions'][0]['groups'][] = 'admin';
+		$apps[$x]['permissions'][0]['groups'][] = 'superadmin';
+
+		$apps[$x]['permissions'][1]['name'] = 'zzz';
+		$apps[$x]['permissions'][1]['groups'][] = 'admin';
+		$apps[$x]['permissions'][1]['groups'][] = 'superadmin';
+
+		$apps[$x]['permissions'][2]['name'] = 'zzz';
+		$apps[$x]['permissions'][2]['groups'][] = 'admin';
+		$apps[$x]['permissions'][2]['groups'][] = 'superadmin';
+
+		$apps[$x]['permissions'][3]['name'] = 'zzz';
+		$apps[$x]['permissions'][3]['groups'][] = 'admin';
+		$apps[$x]['permissions'][3]['groups'][] = 'superadmin';
+	*/
+?>

+ 50 - 0
fifo_agents/fifo_agent/root.php

@@ -0,0 +1,50 @@
+<?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 <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+
+// make sure the PATH_SEPARATOR is defined
+	if (!defined("PATH_SEPARATOR")) {
+		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
+	}
+
+// make sure the document_root is set
+	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
+	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
+	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
+	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
+
+// if the project directory exists then add it to the include path otherwise add the document root to the include path
+	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
+		if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); }
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
+	}
+	else {
+		if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); }
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
+	}
+
+?>

+ 186 - 0
fifo_agents/fifo_agent/v_fifo_agent.php

@@ -0,0 +1,186 @@
+<?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 <[email protected]>
+	Copyright (C) 2010
+	All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("agent") || if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+require_once "includes/header.php";
+require_once "includes/paging.php";
+
+
+$order_by = $_GET["order_by"];
+$order = $_GET["order"];
+	echo "<div align='center'>";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
+	echo "<tr class='border'>\n";
+	echo "	<td align=\"center\">\n";
+	echo "		<br>";
+
+
+	echo "<table width='100%' border='0'>\n";
+	echo "<tr>\n";
+	echo "<td width='50%' nowrap='nowrap' align='left'><b>Active Agents</b></td>\n";
+	echo "<td width='50%' align='right'>&nbsp;</td>\n";
+	echo "</tr>\n";
+	echo "<tr>\n";
+	echo "<td align='left'>\n";
+	echo "Shows the agents that are currently logged into the queues.<br /><br />\n";
+	echo "</td>\n";
+	echo "<td>\n";
+	echo "	<a href='".PROJECT_PATH."/app/fifo_agents/v_fifo_agent_login.php'>login</a>";
+	echo "	<a href='".PROJECT_PATH."/app/fifo_agents/v_fifo_agent_logout.php'>logout</a>";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "</tr></table>\n";
+
+
+	$sql = "";
+	$sql .= " select * from v_fifo_agents ";
+	$sql .= " where agent_username = '".$_SESSION["username"]."' ";
+	if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	$num_rows = count($result);
+	unset ($prep_statement, $result, $sql);
+	$rows_per_page = 10;
+	$param = "";
+	$page = $_GET['page'];
+	if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } 
+	list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); 
+	$offset = $rows_per_page * $page; 
+
+	$sql = "";
+	$sql .= " select * from v_fifo_agents ";
+	$sql .= " where agent_username = '".$_SESSION["username"]."' ";
+	if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
+	//$sql .= " limit $rows_per_page offset $offset ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	$result_count = count($result);
+	unset ($prep_statement, $sql);
+
+
+
+	$c = 0;
+	$row_style["0"] = "row_style0";
+	$row_style["1"] = "row_style1";
+
+	echo "<div align='center'>\n";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+
+	echo "<tr>\n";
+	echo th_order_by('fifo_name', 'Queue Name', $order_by, $order);
+	echo th_order_by('agent_username', 'Username', $order_by, $order);
+	echo th_order_by('agent_priority', 'Agent Priority', $order_by, $order);
+	echo th_order_by('agent_status', 'Status', $order_by, $order);
+	echo th_order_by('agent_last_call', 'Last Call', $order_by, $order);
+	echo th_order_by('agent_contact_number', 'Contact Number', $order_by, $order);
+	echo "<td align='right' width='42'>\n";
+	//echo "	<a href='v_fifo_agents_edit.php' alt='add'>$v_link_label_add</a>\n";
+	echo "</td>\n";
+	echo "<tr>\n";
+
+	if ($result_count == 0) { //no results
+	}
+	else { //received results
+		foreach($result as $row) {
+			//set the php variables
+				$agent_last_call = $row[agent_last_call];
+				date_default_timezone_set('America/Boise');
+
+			//format the last call time
+				$agent_last_call_desc = date("g:i:s a j M Y",$agent_last_call);
+
+			//get the agent status description
+				$x=1;
+				$agent_status_desc = '';
+				foreach($_SESSION["array_agent_status"] as $value) {
+					if ($row[agent_status] == $x) {
+						$agent_status_desc = $value;
+					}
+					$x++;
+				}
+			echo "<tr >\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[fifo_name]."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[agent_username]."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[agent_priority]."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$agent_status_desc."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$agent_last_call_desc."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[agent_contact_number]."</td>\n";
+			echo "	<td valign='top' align='right'>\n";
+			echo "		<a href='v_fifo_agent_edit.php?id=".$row[fifo_agent_id]."' alt='edit'>$v_link_label_edit</a>\n";
+			//echo "		<a href='v_fifo_agents_delete.php?id=".$row[fifo_agent_id]."' alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">$v_link_label_delete</a>\n";
+			echo "	</td>\n";
+			echo "</tr>\n";
+			if ($c==0) { $c=1; } else { $c=0; }
+		} //end foreach
+		unset($sql, $result, $row_count);
+	} //end if results
+
+
+	echo "<tr>\n";
+	echo "<td colspan='7' align='left'>\n";
+	echo "	<table width='100%' cellpadding='0' cellspacing='0'>\n";
+	echo "	<tr>\n";
+	echo "		<td width='33.3%' nowrap>&nbsp;</td>\n";
+	echo "		<td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
+	echo "		<td width='33.3%' align='right'>\n";
+	//echo "			<a href='v_fifo_agents_edit.php' alt='add'>$v_link_label_add</a>\n";
+	echo "		</td>\n";
+	echo "	</tr>\n";
+ 	echo "	</table>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+
+	echo "</table>";
+	echo "</div>";
+	echo "<br><br>";
+	echo "<br><br>";
+
+
+	echo "</td>";
+	echo "</tr>";
+	echo "</table>";
+	echo "</div>";
+	echo "<br><br>";
+
+
+require_once "includes/footer.php";
+unset ($result_count);
+unset ($result);
+unset ($key);
+unset ($val);
+unset ($c);
+?>

+ 412 - 0
fifo_agents/fifo_agent/v_fifo_agent_edit.php

@@ -0,0 +1,412 @@
+<?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 <[email protected]>
+	Copyright (C) 2010
+	All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("agent") || if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//save the uuid to a variable from the http GET 
+	$uuid = check_str($_GET["uuid"]);
+
+//POST to PHP variables
+	if (count($_POST)>0) {
+		//$domain_uuid = check_str($_POST["domain_uuid"]);
+		$resolution_code = check_str($_POST["resolution_code"]);
+		$transaction_id = check_str($_POST["transaction_id"]);
+		$action_item = check_str($_POST["action_item"]);
+		$uuid = check_str($_POST["uuid"]);
+		$notes = check_str($_POST["notes"]);
+		//$fifo_name = check_str($_POST["fifo_name"]);
+		//$agent_username = check_str($_POST["agent_username"]);
+		//$agent_priority = check_str($_POST["agent_priority"]);
+		$agent_status = check_str($_POST["agent_status"]);
+		//$agent_last_call = check_str($_POST["agent_last_call"]);
+		//$agent_contact_number = check_str($_POST["agent_contact_number"]);
+	}
+
+if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
+
+	$msg = '';
+	//check for all required data
+		if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid<br>\n"; }
+		//if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid<br>\n"; }
+		//if (strlen($resolution_code) == 0) { $msg .= "Please provide: Resolution Code<br>\n"; }
+		//if (strlen($transaction_id) == 0) { $msg .= "Please provide: Transaction ID<br>\n"; }
+		//if (strlen($action_item) == 0) { $msg .= "Please provide: Action Item<br>\n"; }
+		//if (strlen($uuid) == 0) { $msg .= "Please provide: UUID<br>\n"; }
+		//if (strlen($notes) == 0) { $msg .= "Please provide: Notes<br>\n"; }
+		//if (strlen($fifo_name) == 0) { $msg .= "Please provide: Queue Name<br>\n"; }
+		//if (strlen($agent_username) == 0) { $msg .= "Please provide: Username<br>\n"; }
+		//if (strlen($agent_priority) == 0) { $msg .= "Please provide: Agent Priority<br>\n"; }
+		if (strlen($agent_status) == 0) { $msg .= "Please provide: Status<br>\n"; }
+		//if (strlen($agent_last_call) == 0) { $msg .= "Please provide: Last Call<br>\n"; }
+		//if (strlen($agent_contact_number) == 0) { $msg .= "Please provide: Contact Number<br>\n"; }
+		if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+			require_once "includes/header.php";
+			require_once "includes/persistformvar.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 "includes/footer.php";
+			return;
+		}
+
+	//update the database
+		if ($_POST["persistformvar"] != "true") {
+			//do not insert {uuid} into the database
+				if ($uuid == "{uuid}") { $uuid = ''; }
+
+			//add to the agent call logs
+				if (strlen($uuid) > 0) {
+					$sql = "insert into v_fifo_agent_call_logs ";
+					$sql .= "(";
+					$sql .= "domain_uuid, ";
+					$sql .= "resolution_code, ";
+					$sql .= "transaction_id, ";
+					$sql .= "action_item, ";
+					$sql .= "uuid, ";
+					$sql .= "notes, ";
+					$sql .= "add_user, ";
+					$sql .= "add_date ";
+					$sql .= ")";
+					$sql .= "values ";
+					$sql .= "(";
+					$sql .= "'$domain_uuid', ";
+					$sql .= "'$resolution_code', ";
+					$sql .= "'$transaction_id', ";
+					$sql .= "'$action_item', ";
+					$sql .= "'$uuid', ";
+					$sql .= "'$notes', ";
+					$sql .= "'".$_SESSION["username"]."', ";
+					$sql .= "now() ";
+					$sql .= ")";
+					$db->exec(check_sql($sql));
+					unset($sql);
+				}
+
+			//update the status
+				$sql = "update v_fifo_agents set ";
+				$sql .= "domain_uuid = '$domain_uuid', ";
+				//$sql .= "fifo_name = '$fifo_name', ";
+				//$sql .= "agent_username = '$agent_username', ";
+				//$sql .= "agent_priority = '$agent_priority', ";
+				$sql .= "agent_status = '$agent_status', ";
+				$sql .= "agent_status_epoch = ".time()." ";
+				//$sql .= "agent_last_call = '$agent_last_call', ";
+				//$sql .= "agent_contact_number = '$agent_contact_number' ";
+				$sql .= " where agent_username = '".$_SESSION["username"]."' ";
+				$db->exec(check_sql($sql));
+				unset($sql);
+
+			//agent status log
+				if (strlen($agent_status) > 0) {
+					$sql = "insert into v_fifo_agent_status_logs ";
+					$sql .= "(";
+					$sql .= "domain_uuid, ";
+					$sql .= "username, ";
+					$sql .= "agent_status, ";
+					$sql .= "uuid, ";
+					$sql .= "add_date ";
+					$sql .= ")";
+					$sql .= "values ";
+					$sql .= "(";
+					$sql .= "'$domain_uuid', ";
+					$sql .= "'".$_SESSION["username"]."', ";
+					$sql .= "'$agent_status', ";
+					$sql .= "'$uuid', ";
+					$sql .= "now() ";
+					$sql .= ")";
+					$db->exec(check_sql($sql));
+					unset($sql);
+				}
+
+				require_once "includes/header.php";
+				echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agent_edit.php\">\n";
+				echo "<div align='center'>\n";
+				echo "Update Complete\n";
+				echo "</div>\n";
+				require_once "includes/footer.php";
+				return;
+		} //if ($_POST["persistformvar"] != "true") { 
+
+} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
+
+//pre-populate the form
+	if ($_POST["persistformvar"] != "true") {
+		$login_status = false;
+		$sql = "";
+		$sql .= "select * from v_fifo_agents ";
+		$sql .= " where agent_username = '".$_SESSION["username"]."' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		foreach ($result as &$row) {
+			$domain_uuid = $row["domain_uuid"];
+			//$fifo_name = $row["fifo_name"];
+			//$agent_username = $row["agent_username"];
+			//$agent_priority = $row["agent_priority"];
+			$agent_status = $row["agent_status"];
+			$agent_last_call = $row["agent_last_call"];
+			$agent_last_uuid = $row["agent_last_uuid"];
+			//$agent_contact_number = $row["agent_contact_number"];
+			$login_status = true;
+			break; //limit to 1 row
+		}
+		unset ($prep_statement);
+	}
+
+//format the last call time
+	if ($agent_last_call == 0) {
+		$agent_last_call_desc = '';
+	}
+	else {
+		$agent_last_call_desc = date("g:i:s a j M Y",$agent_last_call);
+	}
+
+//show the content
+	require_once "includes/header.php";
+
+//if the agent_status is available and the uuid has been supplied then refrsh the page 
+	//until the status changes or until a time out has been reached
+	if ($agent_status == '2' && strlen($uuid) > 0 && $uuid != "{uuid}") {
+		if (count($_GET["refresh"]) < 10) {
+			if (substr($_SERVER["SERVER_PROTOCOL"], 0,5) == "HTTP/") {
+				$meta_refresh_url = "http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]."&refresh[]=".count($_SERVER["refresh"]);
+			}
+			else {
+				$meta_refresh_url = "https://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]."&refresh[]=".count($_SERVER["refresh"]);
+			}
+			echo "<meta http-equiv=\"refresh\" content=\"1;URL=".$meta_refresh_url."\">\n";
+		}
+	}
+
+	echo "<div align='center'>";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing=''>\n";
+
+	echo "<tr class='border'>\n";
+	echo "	<td align=\"left\">\n";
+	//echo "	  <br>";
+
+
+	echo "<form method='post' name='frm' action=''>\n";
+
+	echo "<div align='center'>\n";
+	echo "<table width='100%'  border='0' cellpadding='6' cellspacing='0'>\n";
+
+	echo "<tr>\n";
+	echo "<td align='left' width='30%' nowrap='nowrap' align='left'><b>Agent</b></td>\n";
+	echo "<td width='70%' align='right'>\n";
+	if (!$login_status) {
+		echo "	<input type='button' class='btn' name='' alt='login' onclick=\"window.location='v_fifo_agent_login.php'\" value='Login'>\n";
+	}
+	if ($login_status) {
+		echo "	<input type='button' class='btn' name='' alt='logout' onclick=\"window.location='v_fifo_agent_logout.php'\" value='Logout'>\n";
+	}
+
+	//echo "	<input type='button' class='btn' name='' alt='back' onclick=\"window.location='v_fifo_agents.php'\" value='Back'>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "<tr>\n";
+	echo "<td align='left' colspan='2'>\n";
+	echo "Enables the agent to set their status.<br /><br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+
+		echo "<tr>\n";
+		echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+		echo "	<strong>Username:</strong>\n";
+		echo "</td>\n";
+		echo "<td class='vtable' align='left'>\n";
+		echo "	<strong>".$_SESSION["username"]."</strong>";
+		echo "<br />\n";
+		echo "\n";
+		echo "</td>\n";
+		echo "</tr>\n";
+
+		//echo "<tr>\n";
+		//echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+		//echo "	<strong>Last Call:</strong>\n";
+		//echo "</td>\n";
+		//echo "<td class='vtable' align='left'>\n";
+		//echo 	$agent_last_call_desc;
+		//echo "  <input class='formfld' type='text' name='agent_last_call' maxlength='255' value='$agent_last_call'>\n";
+		//echo "<br />\n";
+		//echo "\n";
+		//echo "</td>\n";
+		//echo "</tr>\n";
+
+		if ($login_status) {
+			echo "<tr>\n";
+			echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
+			echo "	Status:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			//generate the agent status select list
+				$sql = "SELECT var_name, var_value FROM v_vars ";
+				$sql .= "where domain_uuid = '$domain_uuid' ";
+				$sql .= "and var_cat = 'Queues Agent Status' ";
+				$sql .= "and var_name not like 'system%' ";
+				$prep_statement = $db->prepare(check_sql($sql));
+				$prep_statement->execute();
+				echo "<select name=\"agent_status\" class='formfld'>\n";
+				echo "<option value=\"\"></option>\n";
+				$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+				foreach($result as $field) {
+					if ($field[var_value] == $agent_status) {
+						echo "<option value='".$field[var_value]."' selected='selected'>".$field[var_name]."</option>\n";
+					}
+					else {
+						echo "<option value='".$field[var_value]."'>".$field[var_name]."</option>\n";
+					}
+				}
+				echo "</select>";
+				$_SESSION["array_agent_status"] = "";
+				if (!is_array($_SESSION["array_agent_status"])) {
+					foreach($result as $field) {
+						$_SESSION["array_agent_status"][$field[var_value]] = $field[var_name];
+					}
+				}
+				/*
+						foreach($result as $field) {
+							$_SESSION["array_agent_status"][$field[var_value]] = $field[var_name];
+						}
+
+						$x=1;
+						foreach($_SESSION["array_agent_status"] as $value) {
+							echo "$x $value<br />\n";
+							$x++;
+						}
+				*/
+				unset($sql, $result);
+
+			echo "<br />\n";
+			echo "Enter the status of the Agent.\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='' valign='top' align='left' nowrap>\n";
+			echo "	&nbsp;\n";
+			echo "</td>\n";
+			echo "<td class='' align='left'>\n";
+			echo "<br />\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+		}
+
+		/*
+		echo "<tr>\n";
+		echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+		echo "	Contact Number:\n";
+		echo "</td>\n";
+		echo "<td class='vtable' align='left'>\n";
+		echo 	$agent_contact_number;
+		//echo "  <input class='formfld' type='text' name='agent_contact_number' maxlength='255' value='$agent_contact_number'>\n";
+		echo "<br />\n";
+		//echo "Enter the agent contact number.\n";
+		echo "</td>\n";
+		echo "</tr>\n";
+		*/
+
+		if ($login_status && $agent_status == '9') {
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Resolution Code:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input class='formfld' type='text' name='resolution_code' maxlength='255' value=\"$resolution_code\">\n";
+			echo "<br />\n";
+			echo "Enter the resolution code.\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Transaction ID:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input class='formfld' type='text' name='transaction_id' maxlength='255' value=\"$transaction_id\">\n";
+			echo "<br />\n";
+			echo "Enter the Transaction ID.\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Action Item:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<input class='formfld' type='text' name='action_item' maxlength='255' value=\"$action_item\">\n";
+			echo "<br />\n";
+			echo "Enter the Action Item.\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "<tr>\n";
+			echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+			echo "	Notes:\n";
+			echo "</td>\n";
+			echo "<td class='vtable' align='left'>\n";
+			echo "	<textarea class='formfld' name='notes' rows='4'>$notes</textarea>\n";
+			echo "<br />\n";
+			echo "Enter the notes.\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+		}
+		if ($login_status) {
+			echo "	<tr>\n";
+			echo "		<td colspan='2' align='right'>\n";
+			if (strlen($uuid) == 0) {
+				$uuid = $agent_last_uuid;
+			}
+			echo "				<input type='hidden' name='uuid' value=\"$uuid\">\n";
+			echo "				<input type='submit' name='submit' class='btn' value='Save'>\n";
+			echo "		</td>\n";
+			echo "	</tr>";
+		}
+
+
+	echo "</table>";
+	echo "</form>";
+
+	echo "	</td>";
+	echo "	</tr>";
+	echo "</table>";
+	echo "</div>";
+
+
+require_once "includes/footer.php";
+?>

+ 297 - 0
fifo_agents/fifo_agent/v_fifo_agent_login.php

@@ -0,0 +1,297 @@
+<?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 <[email protected]>
+	Copyright (C) 2010
+	All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("agent") || if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//Action add or update
+if (isset($_REQUEST["id"])) {
+	$action = "update";
+	$fifo_agent_id = check_str($_REQUEST["id"]);
+}
+else {
+	$action = "add";
+}
+
+//POST to PHP variables
+if (count($_POST)>0) {
+	//$fifo_name = check_str($_POST["fifo_name"]);
+	$fifo_agent_profile_id = check_str($_POST["fifo_agent_profile_id"]);
+	$agent_username = $_SESSION["username"];
+	$agent_contact_number = check_str($_POST["agent_contact_number"]);
+}
+
+if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
+
+	$msg = '';
+
+	////recommend moving this to the config.php file
+	$uploadtempdir = $_ENV["TEMP"]."\\";
+	ini_set('upload_tmp_dir', $uploadtempdir);
+	////$imagedir = $_ENV["TEMP"]."\\";
+	////$filedir = $_ENV["TEMP"]."\\";
+
+	if ($action == "update") {
+		$fifo_agent_id = check_str($_POST["fifo_agent_id"]);
+	}
+
+	//check for all required data
+		if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid<br>\n"; }
+		if (strlen($fifo_agent_profile_id) == 0) { $msg .= "Please provide: profile<br>\n"; }
+		//if (strlen($fifo_name) == 0) { $msg .= "Please provide: Queue Name<br>\n"; }
+		//if (strlen($agent_username) == 0) { $msg .= "Please provide: Username<br>\n"; }
+		//if (strlen($agent_priority) == 0) { $msg .= "Please provide: Agent Priority<br>\n"; }
+		if (strlen($agent_contact_number) == 0) { $msg .= "Please provide: Contact Number<br>\n"; }
+		if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+			require_once "includes/header.php";
+			require_once "includes/persistformvar.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 "includes/footer.php";
+			return;
+		}
+
+	//add or update the database
+		if ($_POST["persistformvar"] != "true") {
+			if ($action == "add") {
+
+				$fifo_agent_profile_member_id = $_GET["id"];
+				$sql = "";
+				$sql .= "select * from v_fifo_agent_profile_members ";
+				$sql .= "where domain_uuid = '$domain_uuid' ";
+				$sql .= "and fifo_agent_profile_id = '$fifo_agent_profile_id' ";
+				$sql .= "and agent_username = '$agent_username' ";
+				$prep_statement = $db->prepare(check_sql($sql));
+				$prep_statement->execute();
+				$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+				foreach ($result as &$row) {
+					$fifo_agent_profile_member_id = $row["fifo_agent_profile_member_id"];
+					$fifo_agent_profile_id = $row["fifo_agent_profile_id"];
+					$fifo_name = $row["fifo_name"];
+					$agent_priority = $row["agent_priority"];
+					$agent_status = '2'; //available
+					$agent_last_call = 0;
+
+					$sql = "insert into v_fifo_agents ";
+					$sql .= "(";
+					$sql .= "domain_uuid, ";
+					$sql .= "fifo_name, ";
+					$sql .= "agent_username, ";
+					$sql .= "agent_priority, ";
+					$sql .= "agent_status, ";
+					$sql .= "agent_status_epoch, ";
+					$sql .= "agent_last_call, ";
+					$sql .= "agent_contact_number ";
+					$sql .= ")";
+					$sql .= "values ";
+					$sql .= "(";
+					$sql .= "'$domain_uuid', ";
+					$sql .= "'$fifo_name', ";
+					$sql .= "'$agent_username', ";
+					$sql .= "'$agent_priority', ";
+					$sql .= "'$agent_status', ";
+					$sql .= "'".time()."', ";
+					$sql .= "'$agent_last_call', ";
+					$sql .= "'$agent_contact_number' ";
+					$sql .= ")";
+					$db->exec(check_sql($sql));
+					unset($sql);
+
+					//agent status log login 
+						$agent_status = '1'; //login
+						$sql = "insert into v_fifo_agent_status_logs ";
+						$sql .= "(";
+						$sql .= "domain_uuid, ";
+						$sql .= "username, ";
+						$sql .= "agent_status, ";
+						$sql .= "add_date ";
+						$sql .= ")";
+						$sql .= "values ";
+						$sql .= "(";
+						$sql .= "'$domain_uuid', ";
+						$sql .= "'".$_SESSION["username"]."', ";
+						$sql .= "'$agent_status', ";
+						$sql .= "now() ";
+						$sql .= ")";
+						$db->exec(check_sql($sql));
+						unset($sql);
+
+				}
+				unset ($prep_statement);
+
+				require_once "includes/header.php";
+				echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agent_edit.php\">\n";
+				echo "<div align='center'>\n";
+				echo "Login Complete\n";
+				echo "</div>\n";
+				require_once "includes/footer.php";
+				return;
+			} //if ($action == "add")
+		/*
+			if ($action == "update") {
+				$sql = "update v_fifo_agents set ";
+				$sql .= "domain_uuid = '$domain_uuid', ";
+				$sql .= "fifo_name = '$fifo_name', ";
+				$sql .= "agent_username = '$agent_username', ";
+				$sql .= "agent_priority = '$agent_priority', ";
+				$sql .= "agent_contact_number = '$agent_contact_number' ";
+				$sql .= "where fifo_agent_id = '$fifo_agent_id'";
+				$db->exec(check_sql($sql));
+				unset($sql);
+
+				require_once "includes/header.php";
+				echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agents.php\">\n";
+				echo "<div align='center'>\n";
+				echo "Update Complete\n";
+				echo "</div>\n";
+				require_once "includes/footer.php";
+				return;
+			} //if ($action == "update")
+		*/
+		} //if ($_POST["persistformvar"] != "true")
+
+} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
+
+//pre-populate the form
+	/*
+	if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
+		$fifo_agent_id = $_GET["id"];
+		$sql = "";
+		$sql .= "select * from v_fifo_agents ";
+		$sql .= "where fifo_agent_id = '$fifo_agent_id' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		foreach ($result as &$row) {
+			$domain_uuid = $row["domain_uuid"];
+			$fifo_name = $row["fifo_name"];
+			$agent_username = $row["agent_username"];
+			$agent_priority = $row["agent_priority"];
+			$agent_contact_number = $row["agent_contact_number"];
+			break; //limit to 1 row
+		}
+		unset ($prep_statement);
+	}
+	*/
+
+//begin the content
+	require_once "includes/header.php";
+
+	echo "<div align='center'>";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing=''>\n";
+
+	echo "<tr class='border'>\n";
+	echo "	<td align=\"left\">\n";
+	echo "	  <br>";
+
+	echo "<form method='post' name='frm' action=''>\n";
+
+	echo "<div align='center'>\n";
+	echo "<table width='100%'  border='0' cellpadding='6' cellspacing='0'>\n";
+
+	echo "<tr>\n";
+	if ($action == "add") {
+		echo "<td align='left' width='30%' nowrap><b>Agent Login</b></td>\n";
+	}
+	//if ($action == "update") {
+	//	echo "<td align='left' width='30%' nowrap><b>Agent Login</b></td>\n";
+	//}
+	echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='back' onclick=\"window.location='v_fifo_agents.php'\" value='Back'></td>\n";
+	echo "</tr>\n";
+
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	Profile Name:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+
+	$sql = "";
+	$sql .= "select * from v_fifo_agent_profiles ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	//$sql .= "and fifo_agent_profile_id = '$fifo_agent_profile_id' ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$x = 0;
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	echo "<select name=\"fifo_agent_profile_id\" class='formfld'>\n";
+	echo "<option value=\"\"></option>\n";
+	foreach ($result as &$row) {
+		$domain_uuid = $row["domain_uuid"];
+		$profile_name = $row["profile_name"];
+		$profile_desc = $row["profile_desc"];
+		if ($row["fifo_agent_profile_id"] == $fifo_agent_profile_id) {
+			echo "	<option value='".$row["fifo_agent_profile_id"]."' selected='selected'>".$row["profile_name"]."</option>\n";
+		}
+		else {
+			echo "	<option value='".$row["fifo_agent_profile_id"]."'>".$row["profile_name"]."</option>\n";
+		}
+	}
+	echo "</select>\n";
+	unset ($prep_statement);
+
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	Contact Number:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='agent_contact_number' maxlength='255' value=\"$agent_contact_number\">\n";
+	echo "<br />\n";
+	echo "Enter the agent contact number.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	
+	echo "	<tr>\n";
+	echo "		<td colspan='2' align='right'>\n";
+	//if ($action == "update") {
+	//	echo "				<input type='hidden' name='fifo_agent_id' value='$fifo_agent_id'>\n";
+	//}
+	echo "				<input type='submit' name='submit' class='btn' value='Login'>\n";
+	echo "		</td>\n";
+	echo "	</tr>";
+	echo "</table>";
+	echo "</form>";
+
+	echo "	</td>";
+	echo "	</tr>";
+	echo "</table>";
+	echo "</div>";
+
+
+require_once "includes/footer.php";
+?>

+ 74 - 0
fifo_agents/fifo_agent/v_fifo_agent_logout.php

@@ -0,0 +1,74 @@
+<?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 <[email protected]>
+	Copyright (C) 2010
+	All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("agent") || if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//agent logout
+	$sql = "";
+	$sql .= "delete from v_fifo_agents ";
+	$sql .= "where agent_username = '".$_SESSION["username"]."' ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	unset($sql);
+
+//agent status log login 
+	$agent_status = '0'; //login
+	$sql = "insert into v_fifo_agent_status_logs ";
+	$sql .= "(";
+	$sql .= "domain_uuid, ";
+	$sql .= "username, ";
+	$sql .= "agent_status, ";
+	$sql .= "add_date ";
+	$sql .= ")";
+	$sql .= "values ";
+	$sql .= "(";
+	$sql .= "'$domain_uuid', ";
+	$sql .= "'".$_SESSION["username"]."', ";
+	$sql .= "'$agent_status', ";
+	$sql .= "now() ";
+	$sql .= ")";
+	$db->exec(check_sql($sql));
+	unset($sql);
+
+//redirect
+	require_once "includes/header.php";
+	echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agent_edit.php\">\n";
+	echo "<div align='center'>\n";
+	echo "Logout Complete\n";
+	echo "</div>\n";
+
+require_once "includes/footer.php";
+return;
+
+?>

+ 52 - 0
fifo_agents/fifo_agent/v_fifo_agent_remote.php

@@ -0,0 +1,52 @@
+<?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 <[email protected]>
+	Copyright (C) 2010
+	All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("agent") || if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//show the header
+	require_once "includes/header.php";
+
+echo "<div align='right'>\n";
+echo "	<input type='button' class='btn' name='' alt='reload' onclick=\"var f = document.getElementById('iframe1');f.src = f.src;\" value='Reload'>\n";
+echo "	&nbsp;&nbsp;\n";
+echo "</div>\n";
+
+//show the iframe
+	echo "<iframe src ='http://phone-1.viagogo.corp/mod/fifo_agents/fifo_agent/v_fifo_agent_edit.php' width='100%' id='iframe1' height='750px' frameborder=0>\n";
+	echo "	<p>Your browser does not support iframes.</p>\n";
+	echo "</iframe>\n";
+
+//show the footer
+	require_once "includes/footer.php";
+?>

+ 50 - 0
fifo_agents/fifo_agent_call_logs/root.php

@@ -0,0 +1,50 @@
+<?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 <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+
+// make sure the PATH_SEPARATOR is defined
+	if (!defined("PATH_SEPARATOR")) {
+		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
+	}
+
+// make sure the document_root is set
+	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
+	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
+	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
+	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
+
+// if the project directory exists then add it to the include path otherwise add the document root to the include path
+	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
+		if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); }
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
+	}
+	else {
+		if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); }
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
+	}
+
+?>

+ 170 - 0
fifo_agents/fifo_agent_call_logs/v_fifo_agent_call_logs.php

@@ -0,0 +1,170 @@
+<?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 <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+require_once "includes/header.php";
+require_once "includes/paging.php";
+
+$order_by = $_GET["order_by"];
+$order = $_GET["order"];
+	echo "<div align='center'>";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
+	echo "<tr class='border'>\n";
+	echo "	<td align=\"center\">\n";
+	echo "		<br>";
+
+
+	echo "<table width='100%' border='0'>\n";
+	echo "<tr>\n";
+	echo "<td width='50%' nowrap='nowrap' align='left'><b>Fifo Agent Call Data</b></td>\n";
+	echo "<td width='50%' align='right'>&nbsp;</td>\n";
+	echo "</tr>\n";
+	echo "<tr>\n";
+	echo "<td colspan='2' align='left'>\n";
+	echo "The agent call data show a list of call calls agents have received.<br /><br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "</tr></table>\n";
+
+
+	$sql = "";
+	$sql .= " select * from v_fifo_agent_call_logs ";
+	if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	$num_rows = count($result);
+	unset ($prep_statement, $result, $sql);
+	$rows_per_page = 10;
+	$param = "";
+	$page = $_GET['page'];
+	if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } 
+	list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); 
+	$offset = $rows_per_page * $page; 
+
+	$sql = "";
+	//$sql .= " select * from v_fifo_agent_call_logs ";
+	$sql .= " select * from v_fifo_agent_call_data ";
+	if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
+	$sql .= " limit $rows_per_page offset $offset ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	$result_count = count($result);
+	unset ($prep_statement, $sql);
+
+
+	$c = 0;
+	$row_style["0"] = "row_style0";
+	$row_style["1"] = "row_style1";
+
+	echo "<div align='center'>\n";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+
+	echo "<tr>\n";
+	echo th_order_by('call_uuid', 'Call UUID', $order_by, $order);
+	echo th_order_by('resolution_code', 'Resolution Code', $order_by, $order);
+	echo th_order_by('transaction_id', 'Transaction ID', $order_by, $order);
+	echo th_order_by('action_item', 'Action Item', $order_by, $order);
+	echo th_order_by('notes', 'Notes', $order_by, $order);
+	echo th_order_by('add_user', 'Add User', $order_by, $order);
+	echo th_order_by('add_date', 'Add Date', $order_by, $order);
+	echo "<td align='right' width='42'>\n";
+	echo "	<a href='v_fifo_agent_call_logs_edit.php' alt='add'>$v_link_label_add</a>\n";
+	//echo "	<input type='button' class='btn' name='' alt='add' onclick=\"window.location='v_fifo_agent_call_logs_edit.php'\" value='+'>\n";
+	echo "</td>\n";
+	echo "<tr>\n";
+
+	if ($result_count == 0) { //no results
+	}
+	else { //received results
+		foreach($result as $row) {
+			//print_r( $row );
+			echo "<tr >\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[call_uuid]."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[resolution_code]."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[transaction_id]."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[action_item]."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[notes]."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[add_user]."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[add_date]."</td>\n";
+			echo "	<td valign='top' align='right'>\n";
+			echo "		<a href='v_fifo_agent_call_logs_edit.php?id=".$row[fifo_agent_call_log_id]."' alt='edit'>$v_link_label_edit</a>\n";
+			echo "		<a href='v_fifo_agent_call_logs_delete.php?id=".$row[fifo_agent_call_log_id]."' alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">$v_link_label_delete</a>\n";
+			//echo "		<input type='button' class='btn' name='' alt='edit' onclick=\"window.location='v_fifo_agent_call_logs_edit.php?id=".$row[fifo_agent_call_log_id]."'\" value='e'>\n";
+			//echo "		<input type='button' class='btn' name='' alt='delete' onclick=\"if (confirm('Are you sure you want to delete this?')) { window.location='v_fifo_agent_call_logs_delete.php?id=".$row[fifo_agent_call_log_id]."' }\" value='x'>\n";
+			echo "	</td>\n";
+			echo "</tr>\n";
+			if ($c==0) { $c=1; } else { $c=0; }
+		} //end foreach
+		unset($sql, $result, $row_count);
+	} //end if results
+
+
+	echo "<tr>\n";
+	echo "<td colspan='8' align='left'>\n";
+	echo "	<table width='100%' cellpadding='0' cellspacing='0'>\n";
+	echo "	<tr>\n";
+	echo "		<td width='33.3%' nowrap>&nbsp;</td>\n";
+	echo "		<td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
+	echo "		<td width='33.3%' align='right'>\n";
+	echo "			<a href='v_fifo_agent_call_logs_edit.php' alt='add'>$v_link_label_add</a>\n";
+	//echo "		<input type='button' class='btn' name='' alt='add' onclick=\"window.location='v_fifo_agent_call_logs_edit.php'\" value='+'>\n";
+	echo "		</td>\n";
+	echo "	</tr>\n";
+ 	echo "	</table>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+
+	echo "</table>";
+	echo "</div>";
+	echo "<br><br>";
+	echo "<br><br>";
+
+
+	echo "</td>";
+	echo "</tr>";
+	echo "</table>";
+	echo "</div>";
+	echo "<br><br>";
+
+
+require_once "includes/footer.php";
+unset ($result_count);
+unset ($result);
+unset ($key);
+unset ($val);
+unset ($c);
+?>

+ 1 - 0
fifo_agents/fifo_agent_call_logs/v_fifo_agent_call_logs.sql

@@ -0,0 +1 @@
+CREATE TABLE v_fifo_agent_call_logs ( fifo_agent_call_log_id INTEGER PRIMARY KEY, v_id TEXT, resolution_code TEXT, transaction_id TEXT, action_item TEXT, uuid TEXT, notes TEXT, add_user TEXT, add_date TEXT );

+ 61 - 0
fifo_agents/fifo_agent_call_logs/v_fifo_agent_call_logs_delete.php

@@ -0,0 +1,61 @@
+<?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 <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+if (count($_GET)>0) {
+	$id = check_str($_GET["id"]);
+}
+
+if (strlen($id)>0) {
+	$sql = "";
+	$sql .= "delete from v_fifo_agent_call_logs ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$sql .= "and fifo_agent_call_log_id = '$id' ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	unset($sql);
+}
+
+require_once "includes/header.php";
+echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agent_call_logs.php\">\n";
+echo "<div align='center'>\n";
+echo "Delete Complete\n";
+echo "</div>\n";
+
+require_once "includes/footer.php";
+return;
+
+?>
+

+ 299 - 0
fifo_agents/fifo_agent_call_logs/v_fifo_agent_call_logs_edit.php

@@ -0,0 +1,299 @@
+<?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 <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//Action add or update
+if (isset($_REQUEST["id"])) {
+	$action = "update";
+	$fifo_agent_call_log_id = check_str($_REQUEST["id"]);
+}
+else {
+	$action = "add";
+}
+
+//POST to PHP variables
+if (count($_POST)>0) {
+	$resolution_code = check_str($_POST["resolution_code"]);
+	$transaction_id = check_str($_POST["transaction_id"]);
+	$action_item = check_str($_POST["action_item"]);
+	$uuid = check_str($_POST["uuid"]);
+	$notes = check_str($_POST["notes"]);
+	$add_user = check_str($_POST["add_user"]);
+	$add_date = check_str($_POST["add_date"]);
+}
+
+if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
+
+	$msg = '';
+
+	if ($action == "update") {
+		$fifo_agent_call_log_id = check_str($_POST["fifo_agent_call_log_id"]);
+	}
+
+	//check for all required data
+		//if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid<br>\n"; }
+		//if (strlen($resolution_code) == 0) { $msg .= "Please provide: Resolution Code<br>\n"; }
+		//if (strlen($transaction_id) == 0) { $msg .= "Please provide: Transaction ID<br>\n"; }
+		//if (strlen($action_item) == 0) { $msg .= "Please provide: Action Item<br>\n"; }
+		//if (strlen($uuid) == 0) { $msg .= "Please provide: UUID<br>\n"; }
+		//if (strlen($notes) == 0) { $msg .= "Please provide: Notes<br>\n"; }
+		//if (strlen($add_user) == 0) { $msg .= "Please provide: Add User<br>\n"; }
+		//if (strlen($add_date) == 0) { $msg .= "Please provide: Add Date<br>\n"; }
+		if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+			require_once "includes/header.php";
+			require_once "includes/persistformvar.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 "includes/footer.php";
+			return;
+		}
+
+	//add or update the database
+	if ($_POST["persistformvar"] != "true") {
+		if ($action == "add") {
+			$sql = "insert into v_fifo_agent_call_logs ";
+			$sql .= "(";
+			$sql .= "domain_uuid, ";
+			$sql .= "resolution_code, ";
+			$sql .= "transaction_id, ";
+			$sql .= "action_item, ";
+			$sql .= "uuid, ";
+			$sql .= "notes, ";
+			$sql .= "add_user, ";
+			$sql .= "add_date ";
+			$sql .= ")";
+			$sql .= "values ";
+			$sql .= "(";
+			$sql .= "'$domain_uuid', ";
+			$sql .= "'$resolution_code', ";
+			$sql .= "'$transaction_id', ";
+			$sql .= "'$action_item', ";
+			$sql .= "'$uuid', ";
+			$sql .= "'$notes', ";
+			$sql .= "'$add_user', ";
+			$sql .= "'$add_date' ";
+			$sql .= ")";
+			$db->exec(check_sql($sql));
+			unset($sql);
+
+			require_once "includes/header.php";
+			echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agent_call_logs.php\">\n";
+			echo "<div align='center'>\n";
+			echo "Add Complete\n";
+			echo "</div>\n";
+			require_once "includes/footer.php";
+			return;
+		} //if ($action == "add")
+
+		if ($action == "update") {
+			$sql = "update v_fifo_agent_call_logs set ";
+			$sql .= "resolution_code = '$resolution_code', ";
+			$sql .= "transaction_id = '$transaction_id', ";
+			$sql .= "action_item = '$action_item', ";
+			$sql .= "uuid = '$uuid', ";
+			$sql .= "notes = '$notes', ";
+			$sql .= "add_user = '$add_user', ";
+			$sql .= "add_date = '$add_date' ";
+			$sql .= "where domain_uuid = '$domain_uuid'";
+			$sql .= "and fifo_agent_call_log_id = '$fifo_agent_call_log_id'";
+			$db->exec(check_sql($sql));
+			unset($sql);
+
+			require_once "includes/header.php";
+			echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agent_call_logs.php\">\n";
+			echo "<div align='center'>\n";
+			echo "Update Complete\n";
+			echo "</div>\n";
+			require_once "includes/footer.php";
+			return;
+		} //if ($action == "update")
+	} //if ($_POST["persistformvar"] != "true") 
+
+} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
+
+//pre-populate the form
+if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
+	$fifo_agent_call_log_id = $_GET["id"];
+	$sql = "";
+	$sql .= "select * from v_fifo_agent_call_logs ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$sql .= "and fifo_agent_call_log_id = '$fifo_agent_call_log_id' ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	foreach ($result as &$row) {
+		$resolution_code = $row["resolution_code"];
+		$transaction_id = $row["transaction_id"];
+		$action_item = $row["action_item"];
+		$uuid = $row["uuid"];
+		$notes = $row["notes"];
+		$add_user = $row["add_user"];
+		$add_date = $row["add_date"];
+		break; //limit to 1 row
+	}
+	unset ($prep_statement);
+}
+
+//begin the content
+	require_once "includes/header.php";
+
+
+	echo "<div align='center'>";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing=''>\n";
+
+	echo "<tr class='border'>\n";
+	echo "	<td align=\"left\">\n";
+	echo "	  <br>";
+
+
+	echo "<form method='post' name='frm' action=''>\n";
+
+	echo "<div align='center'>\n";
+	echo "<table width='100%'  border='0' cellpadding='6' cellspacing='0'>\n";
+
+	echo "<tr>\n";
+	if ($action == "add") {
+		echo "<td align='left' width='30%' nowrap='nowrap' align='left'><b>Fifo Agent Call Log Add</b></td>\n";
+	}
+	if ($action == "update") {
+		echo "<td align='left' width='30%' nowrap='nowrap' align='left'><b>Fifo Agent Call Log Edit</b></td>\n";
+	}
+	echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='back' onclick=\"window.location='v_fifo_agent_call_logs.php'\" value='Back'></td>\n";
+	echo "</tr>\n";
+	echo "<tr>\n";
+	echo "<td colspan='2' align='left'>\n";
+	echo "The agent call logs show a list of call calls agents have received.<br /><br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	Resolution Code:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='resolution_code' maxlength='255' value=\"$resolution_code\">\n";
+	echo "<br />\n";
+	echo "Enter the resolution code.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	Transaction ID:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='transaction_id' maxlength='255' value=\"$transaction_id\">\n";
+	echo "<br />\n";
+	echo "Enter the Transaction ID.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	Action Item:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='action_item' maxlength='255' value=\"$action_item\">\n";
+	echo "<br />\n";
+	echo "Enter the Action Item.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	UUID:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='uuid' maxlength='255' value=\"$uuid\">\n";
+	echo "<br />\n";
+	echo "Enter the UUID.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	Notes:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<textarea class='formfld' name='notes' rows='4'>$notes</textarea>\n";
+	echo "<br />\n";
+	echo "Enter the notes.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	Add User:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='add_user' maxlength='255' value=\"$add_user\">\n";
+	echo "<br />\n";
+	echo "\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	Add Date:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='add_user' maxlength='255' value=\"$add_date\">\n";
+	echo "<br />\n";
+	echo "\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "	<tr>\n";
+	echo "		<td colspan='2' align='right'>\n";
+	if ($action == "update") {
+		echo "				<input type='hidden' name='fifo_agent_call_log_id' value='$fifo_agent_call_log_id'>\n";
+	}
+	echo "				<input type='submit' name='submit' class='btn' value='Save'>\n";
+	echo "		</td>\n";
+	echo "	</tr>";
+	echo "</table>";
+	echo "</form>";
+
+	echo "	</td>";
+	echo "	</tr>";
+	echo "</table>";
+	echo "</div>";
+
+
+require_once "includes/footer.php";
+?>

+ 50 - 0
fifo_agents/fifo_agent_profiles/root.php

@@ -0,0 +1,50 @@
+<?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 <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+
+// make sure the PATH_SEPARATOR is defined
+	if (!defined("PATH_SEPARATOR")) {
+		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
+	}
+
+// make sure the document_root is set
+	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
+	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
+	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
+	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
+
+// if the project directory exists then add it to the include path otherwise add the document root to the include path
+	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
+		if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); }
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
+	}
+	else {
+		if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); }
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
+	}
+
+?>

+ 161 - 0
fifo_agents/fifo_agent_profiles/v_fifo_agent_profile_members.php

@@ -0,0 +1,161 @@
+<?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 <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+require_once "includes/header.php";
+require_once "includes/paging.php";
+
+$order_by = $_GET["order_by"];
+$order = $_GET["order"];
+
+	echo "<div align='center'>";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
+	echo "<tr class='border'>\n";
+	echo "	<td align=\"center\">\n";
+	echo "		<br>";
+
+
+	echo "<table width='100%' border='0'>\n";
+	echo "<tr>\n";
+	echo "<td width='50%' nowrap='nowrap' align='left'><b>Agent Member List</b></td>\n";
+	echo "<td width='50%' align='right'>&nbsp;</td>\n";
+	echo "</tr>\n";
+	echo "</tr></table>\n";
+
+
+	$sql = "";
+	$sql .= " select * from v_fifo_agent_profile_members ";
+	$sql .= " where domain_uuid = '$domain_uuid' ";
+	$sql .= " and fifo_agent_profile_id = '$fifo_agent_profile_id' ";
+	if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	$num_rows = count($result);
+	unset ($prep_statement, $result, $sql);
+	$rows_per_page = 100;
+	$param = "&id=".$_GET['id'];
+	$page = $_GET['page'];
+	if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } 
+	list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); 
+	$offset = $rows_per_page * $page; 
+
+	$sql = "";
+	$sql .= " select * from v_fifo_agent_profile_members ";
+	$sql .= " where domain_uuid = '$domain_uuid' ";
+	$sql .= " and fifo_agent_profile_id = '$fifo_agent_profile_id' ";
+	if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
+	$sql .= " limit $rows_per_page offset $offset ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	$result_count = count($result);
+	unset ($prep_statement, $sql);
+
+
+	$c = 0;
+	$row_style["0"] = "row_style0";
+	$row_style["1"] = "row_style1";
+
+	echo "<div align='center'>\n";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+
+	echo "<tr>\n";
+	echo th_order_by('fifo_name', 'FIFO Name', $order_by, $order);
+	echo th_order_by('agent_username', 'Agent', $order_by, $order);
+	echo th_order_by('agent_priority', 'Agent Priority', $order_by, $order);
+	echo "<td align='right' width='42'>\n";
+	echo "	<a href='v_fifo_agent_profile_members_edit.php?fifo_agent_profile_id=".$row[fifo_agent_profile_id]."' alt='add'>$v_link_label_add</a>\n";
+	//echo "	<input type='button' class='btn' name='' alt='add' onclick=\"window.location='v_fifo_agent_profile_members_edit.php'\" value='+'>\n";
+	echo "</td>\n";
+	echo "<tr>\n";
+
+	if ($result_count == 0) { //no results
+	}
+	else { //received results
+		foreach($result as $row) {
+			//print_r( $row );
+			echo "<tr >\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[fifo_name]."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[agent_username]."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[agent_priority]."</td>\n";
+			echo "	<td valign='top' align='right'>\n";
+			echo "		<a href='v_fifo_agent_profile_members_edit.php?fifo_agent_profile_id=".$row[fifo_agent_profile_id]."&id=".$row[fifo_agent_profile_member_id]."' alt='edit'>$v_link_label_edit</a>\n";
+			echo "		<a href='v_fifo_agent_profile_members_delete.php?fifo_agent_profile_id=".$row[fifo_agent_profile_id]."&id=".$row[fifo_agent_profile_member_id]."' alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">$v_link_label_delete</a>\n";
+			//echo "		<input type='button' class='btn' name='' alt='edit' onclick=\"window.location='v_fifo_agent_profile_members_edit.php?id=".$row[fifo_agent_profile_member_id]."'\" value='e'>\n";
+			//echo "		<input type='button' class='btn' name='' alt='delete' onclick=\"if (confirm('Are you sure you want to delete this?')) { window.location='v_fifo_agent_profile_members_delete.php?id=".$row[fifo_agent_profile_member_id]."' }\" value='x'>\n";
+			echo "	</td>\n";
+			echo "</tr>\n";
+			if ($c==0) { $c=1; } else { $c=0; }
+		} //end foreach
+		unset($sql, $result, $row_count);
+	} //end if results
+
+
+	echo "<tr>\n";
+	echo "<td colspan='4' align='left'>\n";
+	echo "	<table width='100%' cellpadding='0' cellspacing='0'>\n";
+	echo "	<tr>\n";
+	echo "		<td width='33.3%' nowrap>&nbsp;</td>\n";
+	echo "		<td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
+	echo "		<td width='33.3%' align='right'>\n";
+	echo "			<a href='v_fifo_agent_profile_members_edit.php?fifo_agent_profile_id=".$row[fifo_agent_profile_id]."' alt='add'>$v_link_label_add</a>\n";
+	//echo "		<input type='button' class='btn' name='' alt='add' onclick=\"window.location='v_fifo_agent_profile_members_edit.php'\" value='+'>\n";
+	echo "		</td>\n";
+	echo "	</tr>\n";
+ 	echo "	</table>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+
+	echo "</table>";
+	echo "</div>";
+	echo "<br><br>";
+	echo "<br><br>";
+
+
+	echo "</td>";
+	echo "</tr>";
+	echo "</table>";
+	echo "</div>";
+	echo "<br><br>";
+
+
+require_once "includes/footer.php";
+unset ($result_count);
+unset ($result);
+unset ($key);
+unset ($val);
+unset ($c);
+?>

+ 1 - 0
fifo_agents/fifo_agent_profiles/v_fifo_agent_profile_members.sql

@@ -0,0 +1 @@
+CREATE TABLE v_fifo_agent_profile_members (fifo_agent_profile_member_id INTEGER PRIMARY KEY, v_id NUMBER, fifo_agent_profile_id NUMBER, fifo_name TEXT, agent_priority TEXT, agent_username TEXT);

+ 62 - 0
fifo_agents/fifo_agent_profiles/v_fifo_agent_profile_members_delete.php

@@ -0,0 +1,62 @@
+<?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 <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+if (count($_GET)>0) {
+	$id = check_str($_GET["id"]);
+	$fifo_agent_profile_id = check_str($_GET["fifo_agent_profile_id"]);
+}
+
+if (strlen($id)>0) {
+	$sql = "";
+	$sql .= "delete from v_fifo_agent_profile_members ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$sql .= "and fifo_agent_profile_member_id = '$id' ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	unset($sql);
+}
+
+require_once "includes/header.php";
+echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agent_profiles_edit.php?id=$fifo_agent_profile_id\">\n";
+echo "<div align='center'>\n";
+echo "Delete Complete\n";
+echo "</div>\n";
+
+require_once "includes/footer.php";
+return;
+
+?>
+

+ 359 - 0
fifo_agents/fifo_agent_profiles/v_fifo_agent_profile_members_edit.php

@@ -0,0 +1,359 @@
+<?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 <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//Action add or update
+if (isset($_REQUEST["id"])) {
+	$action = "update";
+	$fifo_agent_profile_member_id = check_str($_REQUEST["id"]);
+}
+else {
+	$action = "add";
+}
+
+if (strlen($_GET["fifo_agent_profile_id"]) > 0) {
+	$fifo_agent_profile_id = check_str($_GET["fifo_agent_profile_id"]);
+}
+
+//POST to PHP variables
+if (count($_POST)>0) {
+	//$domain_uuid = check_str($_POST["domain_uuid"]);
+	$fifo_agent_profile_id = check_str($_POST["fifo_agent_profile_id"]);
+	$fifo_name = check_str($_POST["fifo_name"]);
+	$agent_priority = check_str($_POST["agent_priority"]);
+	$agent_username = check_str($_POST["agent_username"]);
+}
+
+if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
+
+	$msg = '';
+
+	////recommend moving this to the config.php file
+	$uploadtempdir = $_ENV["TEMP"]."\\";
+	ini_set('upload_tmp_dir', $uploadtempdir);
+	////$imagedir = $_ENV["TEMP"]."\\";
+	////$filedir = $_ENV["TEMP"]."\\";
+
+	if ($action == "update") {
+		$fifo_agent_profile_member_id = check_str($_POST["fifo_agent_profile_member_id"]);
+	}
+
+	//check for all required data
+		if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid<br>\n"; }
+		if (strlen($fifo_agent_profile_id) == 0) { $msg .= "Please provide: fifo_agent_profile_id<br>\n"; }
+		//if (strlen($fifo_name) == 0) { $msg .= "Please provide: FIFO Name<br>\n"; }
+		//if (strlen($agent_priority) == 0) { $msg .= "Please provide: Agent Priority<br>\n"; }
+		//if (strlen($agent_username) == 0) { $msg .= "Please provide: Agent<br>\n"; }
+		if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+			require_once "includes/header.php";
+			require_once "includes/persistformvar.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 "includes/footer.php";
+			return;
+		}
+
+//add or update the database
+if ($_POST["persistformvar"] != "true") {
+	if ($action == "add") {
+		$sql = "insert into v_fifo_agent_profile_members ";
+		$sql .= "(";
+		$sql .= "domain_uuid, ";
+		$sql .= "fifo_agent_profile_id, ";
+		$sql .= "fifo_name, ";
+		$sql .= "agent_priority, ";
+		$sql .= "agent_username ";
+		$sql .= ")";
+		$sql .= "values ";
+		$sql .= "(";
+		$sql .= "'$domain_uuid', ";
+		$sql .= "'$fifo_agent_profile_id', ";
+		$sql .= "'$fifo_name', ";
+		$sql .= "'$agent_priority', ";
+		$sql .= "'$agent_username' ";
+		$sql .= ")";
+		$db->exec(check_sql($sql));
+		unset($sql);
+
+		require_once "includes/header.php";
+		echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agent_profiles_edit.php?id=$fifo_agent_profile_id\">\n";
+		echo "<div align='center'>\n";
+		echo "Add Complete\n";
+		echo "</div>\n";
+		require_once "includes/footer.php";
+		return;
+	} //if ($action == "add")
+
+	if ($action == "update") {
+		$sql = "update v_fifo_agent_profile_members set ";
+		$sql .= "fifo_agent_profile_id = '$fifo_agent_profile_id', ";
+		$sql .= "fifo_name = '$fifo_name', ";
+		$sql .= "agent_priority = '$agent_priority', ";
+		$sql .= "agent_username = '$agent_username' ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and fifo_agent_profile_member_id = '$fifo_agent_profile_member_id'";
+		$db->exec(check_sql($sql));
+		unset($sql);
+
+		require_once "includes/header.php";
+		echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agent_profiles_edit.php?id=$fifo_agent_profile_id\">\n";
+		echo "<div align='center'>\n";
+		echo "Update Complete\n";
+		echo "</div>\n";
+		require_once "includes/footer.php";
+		return;
+	} //if ($action == "update")
+} //if ($_POST["persistformvar"] != "true") { 
+
+} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
+
+//pre-populate the form
+if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
+	$fifo_agent_profile_member_id = $_GET["id"];
+	$sql = "";
+	$sql .= "select * from v_fifo_agent_profile_members ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$sql .= "and fifo_agent_profile_member_id = '$fifo_agent_profile_member_id' ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	foreach ($result as &$row) {
+		$fifo_agent_profile_id = $row["fifo_agent_profile_id"];
+		$fifo_name = $row["fifo_name"];
+		$agent_priority = $row["agent_priority"];
+		$agent_username = $row["agent_username"];
+		break; //limit to 1 row
+	}
+	unset ($prep_statement);
+}
+
+
+	require_once "includes/header.php";
+
+
+	echo "<div align='center'>";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing=''>\n";
+
+	echo "<tr class='border'>\n";
+	echo "	<td align=\"left\">\n";
+	echo "	  <br>";
+
+
+
+
+	echo "<form method='post' name='frm' action=''>\n";
+
+	echo "<div align='center'>\n";
+	echo "<table width='100%'  border='0' cellpadding='6' cellspacing='0'>\n";
+
+	echo "<tr>\n";
+	if ($action == "add") {
+		echo "<td align='left' width='30%' nowrap><b>Agent Member List Add</b></td>\n";
+	}
+	if ($action == "update") {
+		echo "<td align='left' width='30%' nowrap><b>Agent Member List Edit</b></td>\n";
+	}
+	echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='back' onclick=\"window.location='v_fifo_agent_profiles_edit.php?id=$fifo_agent_profile_id'\" value='Back'></td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	Queue Name:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	//echo "	<input class='formfld' type='text' name='fifo_name' maxlength='255' value=\"$fifo_name\">\n";
+
+	//generate the fifo name select list
+	$sql = "";
+	$sql .= "select * from v_dialplan_details ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$x = 0;
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	echo "<select name=\"fifo_name\" class='formfld'>\n";
+	echo "<option value=\"\"></option>\n";
+	foreach ($result as &$row) {
+		if ($row["dialplan_detail_type"] == "fifo") {
+			//if (strpos($row["dialplan_detail_data"], '@${domain_name} in') !== false) {
+				//echo "rtrim(".$row["dialplan_detail_data"].", ' in') == ".$fifo_name."<br />";
+				if (rtrim($row["dialplan_detail_data"], " in") == $fifo_name) {
+					echo "		<option value='".rtrim($row["dialplan_detail_data"], " in")."' selected='selected'>".rtrim($row["dialplan_detail_data"], " in")."</option>\n";
+				}
+				else {
+					echo "		<option value='".rtrim($row["dialplan_detail_data"], " in")."'>".rtrim($row["dialplan_detail_data"], " in")."</option>\n";
+				}
+			//}
+		}
+	}
+	echo "</select>\n";
+	unset ($prep_statement);
+
+
+	echo "<br />\n";
+	echo "Select the queue name.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	Agent:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	//echo "	<input class='formfld' type='text' name='agent_username' maxlength='255' value=\"$agent_username\">\n";
+
+	//generate the user list
+		$sql = "SELECT * FROM v_users ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and user_enabled = 'true' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+
+		echo "<select name=\"agent_username\" class='formfld'>\n";
+		echo "<option value=\"\"></option>\n";
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		foreach($result as $field) {
+			if ($agent_username == $field[username]) {
+				echo "<option value='".$field[username]."' selected='selected'>".$field[username]."</option>\n";
+			}
+			else {
+				echo "<option value='".$field[username]."'>".$field[username]."</option>\n";
+			}
+		}
+		echo "</select>";
+		unset($sql, $result);
+
+	echo "<br />\n";
+	echo "Select the agent.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	Agent Priority:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<select class='formfld' name='agent_priority'>\n";
+	echo "	<option value=''></option>\n";
+	if ($agent_priority == "1") { 
+		echo "	<option value='1' SELECTED >1</option>\n";
+	}
+	else {
+		echo "	<option value='1'>1</option>\n";
+	}
+	if ($agent_priority == "2") { 
+		echo "	<option value='2' SELECTED >2</option>\n";
+	}
+	else {
+		echo "	<option value='2'>2</option>\n";
+	}
+	if ($agent_priority == "3") { 
+		echo "	<option value='3' SELECTED >3</option>\n";
+	}
+	else {
+		echo "	<option value='3'>3</option>\n";
+	}
+	if ($agent_priority == "4") { 
+		echo "	<option value='4' SELECTED >4</option>\n";
+	}
+	else {
+		echo "	<option value='4'>4</option>\n";
+	}
+	if ($agent_priority == "5") { 
+		echo "	<option value='5' SELECTED >5</option>\n";
+	}
+	else {
+		echo "	<option value='5'>5</option>\n";
+	}
+	if ($agent_priority == "6") { 
+		echo "	<option value='6' SELECTED >6</option>\n";
+	}
+	else {
+		echo "	<option value='6'>6</option>\n";
+	}
+	if ($agent_priority == "7") { 
+		echo "	<option value='7' SELECTED >7</option>\n";
+	}
+	else {
+		echo "	<option value='7'>7</option>\n";
+	}
+	if ($agent_priority == "8") { 
+		echo "	<option value='8' SELECTED >8</option>\n";
+	}
+	else {
+		echo "	<option value='8'>8</option>\n";
+	}
+	if ($agent_priority == "9") { 
+		echo "	<option value='9' SELECTED >9</option>\n";
+	}
+	else {
+		echo "	<option value='9'>9</option>\n";
+	}
+	if ($agent_priority == "10") { 
+		echo "	<option value='10' SELECTED >10</option>\n";
+	}
+	else {
+		echo "	<option value='10'>10</option>\n";
+	}
+	echo "	</select>\n";
+	echo "<br />\n";
+	echo "Select the agent priority.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "	<tr>\n";
+	echo "		<td colspan='2' align='right'>\n";
+	echo "				<input type='hidden' name='fifo_agent_profile_id' value='$fifo_agent_profile_id'>\n";
+	if ($action == "update") {
+		echo "				<input type='hidden' name='fifo_agent_profile_member_id' value='$fifo_agent_profile_member_id'>\n";
+	}
+	echo "				<input type='submit' name='submit' class='btn' value='Save'>\n";
+	echo "		</td>\n";
+	echo "	</tr>";
+	echo "</table>";
+	echo "</form>";
+
+	echo "	</td>";
+	echo "	</tr>";
+	echo "</table>";
+	echo "</div>";
+
+
+require_once "includes/footer.php";
+?>

+ 156 - 0
fifo_agents/fifo_agent_profiles/v_fifo_agent_profiles.php

@@ -0,0 +1,156 @@
+<?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 <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+require_once "includes/header.php";
+require_once "includes/paging.php";
+
+$order_by = $_GET["order_by"];
+$order = $_GET["order"];
+	echo "<div align='center'>";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
+	echo "<tr class='border'>\n";
+	echo "	<td align=\"center\">\n";
+	echo "		<br>";
+
+
+	echo "<table width='100%' border='0'>\n";
+	echo "<tr>\n";
+	echo "<td width='50%' nowrap='nowrap' align='left'><b>Agent Profile List</b></td>\n";
+	echo "<td width='50%' align='right'>&nbsp;</td>\n";
+	echo "</tr>\n";
+	echo "</tr></table>\n";
+
+
+	$sql = "";
+	$sql .= "select * from v_fifo_agent_profiles ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	$num_rows = count($result);
+	unset ($prep_statement, $result, $sql);
+	$rows_per_page = 10;
+	$param = "";
+	$page = $_GET['page'];
+	if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } 
+	list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); 
+	$offset = $rows_per_page * $page; 
+
+	$sql = "";
+	$sql .= "select * from v_fifo_agent_profiles ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
+	$sql .= " limit $rows_per_page offset $offset ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	$result_count = count($result);
+	unset ($prep_statement, $sql);
+
+
+	$c = 0;
+	$row_style["0"] = "row_style0";
+	$row_style["1"] = "row_style1";
+
+	echo "<div align='center'>\n";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+
+	echo "<tr>\n";
+	echo th_order_by('profile_name', 'Profile Name', $order_by, $order);
+	echo th_order_by('profile_desc', 'Description', $order_by, $order);
+	echo "<td align='right' width='42'>\n";
+	echo "	<a href='v_fifo_agent_profiles_edit.php' alt='add'>$v_link_label_add</a>\n";
+	//echo "	<input type='button' class='btn' name='' alt='add' onclick=\"window.location='v_fifo_agent_profiles_edit.php'\" value='+'>\n";
+	echo "</td>\n";
+	echo "<tr>\n";
+
+	if ($result_count == 0) { //no results
+	}
+	else { //received results
+		foreach($result as $row) {
+			//print_r( $row );
+			echo "<tr >\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[profile_name]."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[profile_desc]."</td>\n";
+			echo "	<td valign='top' align='right'>\n";
+			echo "		<a href='v_fifo_agent_profiles_edit.php?id=".$row[fifo_agent_profile_id]."' alt='edit'>$v_link_label_edit</a>\n";
+			echo "		<a href='v_fifo_agent_profiles_delete.php?id=".$row[fifo_agent_profile_id]."' alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">$v_link_label_delete</a>\n";
+			//echo "		<input type='button' class='btn' name='' alt='edit' onclick=\"window.location='v_fifo_agent_profiles_edit.php?id=".$row[fifo_agent_profile_id]."'\" value='e'>\n";
+			//echo "		<input type='button' class='btn' name='' alt='delete' onclick=\"if (confirm('Are you sure you want to delete this?')) { window.location='v_fifo_agent_profiles_delete.php?id=".$row[fifo_agent_profile_id]."' }\" value='x'>\n";
+			echo "	</td>\n";
+			echo "</tr>\n";
+			if ($c==0) { $c=1; } else { $c=0; }
+		} //end foreach
+		unset($sql, $result, $row_count);
+	} //end if results
+
+
+	echo "<tr>\n";
+	echo "<td colspan='3' align='left'>\n";
+	echo "	<table width='100%' cellpadding='0' cellspacing='0'>\n";
+	echo "	<tr>\n";
+	echo "		<td width='33.3%' nowrap>&nbsp;</td>\n";
+	echo "		<td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
+	echo "		<td width='33.3%' align='right'>\n";
+	echo "			<a href='v_fifo_agent_profiles_edit.php' alt='add'>$v_link_label_add</a>\n";
+	//echo "		<input type='button' class='btn' name='' alt='add' onclick=\"window.location='v_fifo_agent_profiles_edit.php'\" value='+'>\n";
+	echo "		</td>\n";
+	echo "	</tr>\n";
+ 	echo "	</table>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+
+	echo "</table>";
+	echo "</div>";
+	echo "<br><br>";
+	echo "<br><br>";
+
+
+	echo "</td>";
+	echo "</tr>";
+	echo "</table>";
+	echo "</div>";
+	echo "<br><br>";
+
+
+require_once "includes/footer.php";
+unset ($result_count);
+unset ($result);
+unset ($key);
+unset ($val);
+unset ($c);
+?>

+ 1 - 0
fifo_agents/fifo_agent_profiles/v_fifo_agent_profiles.sql

@@ -0,0 +1 @@
+CREATE TABLE v_fifo_agent_profiles (fifo_agent_profile_id INTEGER PRIMARY KEY, v_id NUMBER, profile_name TEXT, profile_desc TEXT);

+ 72 - 0
fifo_agents/fifo_agent_profiles/v_fifo_agent_profiles_delete.php

@@ -0,0 +1,72 @@
+<?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 <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+if (count($_GET)>0) {
+	$id = check_str($_GET["id"]);
+}
+
+if (strlen($id)>0) {
+
+	//delete child data
+		$sql = "";
+		$sql .= "delete from v_fifo_agent_profile_members ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and fifo_agent_profile_id = '$id' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		unset($sql, $prep_statement);
+
+	//delete parent data
+		$sql = "";
+		$sql .= "delete from v_fifo_agent_profiles ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and fifo_agent_profile_id = '$id' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		unset($sql, $prep_statement);
+}
+
+require_once "includes/header.php";
+echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agent_profiles.php\">\n";
+echo "<div align='center'>\n";
+echo "Delete Complete\n";
+echo "</div>\n";
+
+require_once "includes/footer.php";
+return;
+
+?>
+

+ 222 - 0
fifo_agents/fifo_agent_profiles/v_fifo_agent_profiles_edit.php

@@ -0,0 +1,222 @@
+<?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 <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//Action add or update
+if (isset($_REQUEST["id"])) {
+	$action = "update";
+	$fifo_agent_profile_id = check_str($_REQUEST["id"]);
+}
+else {
+	$action = "add";
+}
+
+//POST to PHP variables
+if (count($_POST)>0) {
+	//$domain_uuid = check_str($_POST["domain_uuid"]);
+	$profile_name = check_str($_POST["profile_name"]);
+	$profile_desc = check_str($_POST["profile_desc"]);
+}
+
+if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
+
+	$msg = '';
+
+	////recommend moving this to the config.php file
+	$uploadtempdir = $_ENV["TEMP"]."\\";
+	ini_set('upload_tmp_dir', $uploadtempdir);
+	////$imagedir = $_ENV["TEMP"]."\\";
+	////$filedir = $_ENV["TEMP"]."\\";
+
+	if ($action == "update") {
+		$fifo_agent_profile_id = check_str($_POST["fifo_agent_profile_id"]);
+	}
+
+	//check for all required data
+		if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid<br>\n"; }
+		if (strlen($profile_name) == 0) { $msg .= "Please provide: Profile Name<br>\n"; }
+		if (strlen($profile_desc) == 0) { $msg .= "Please provide: Description<br>\n"; }
+		if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+			require_once "includes/header.php";
+			require_once "includes/persistformvar.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 "includes/footer.php";
+			return;
+		}
+
+
+	//add or update the database
+	if ($_POST["persistformvar"] != "true") {
+		if ($action == "add") {
+			$sql = "insert into v_fifo_agent_profiles ";
+			$sql .= "(";
+			$sql .= "domain_uuid, ";
+			$sql .= "profile_name, ";
+			$sql .= "profile_desc ";
+			$sql .= ")";
+			$sql .= "values ";
+			$sql .= "(";
+			$sql .= "'$domain_uuid', ";
+			$sql .= "'$profile_name', ";
+			$sql .= "'$profile_desc' ";
+			$sql .= ")";
+			$db->exec(check_sql($sql));
+			unset($sql);
+
+			require_once "includes/header.php";
+			echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agent_profiles.php\">\n";
+			echo "<div align='center'>\n";
+			echo "Add Complete\n";
+			echo "</div>\n";
+			require_once "includes/footer.php";
+			return;
+		} //if ($action == "add")
+
+		if ($action == "update") {
+			$sql = "update v_fifo_agent_profiles set ";
+			$sql .= "domain_uuid = '$domain_uuid', ";
+			$sql .= "profile_name = '$profile_name', ";
+			$sql .= "profile_desc = '$profile_desc' ";
+			$sql .= "where domain_uuid = '$domain_uuid' ";
+			$sql .= "and fifo_agent_profile_id = '$fifo_agent_profile_id'";
+			$db->exec(check_sql($sql));
+			unset($sql);
+
+			require_once "includes/header.php";
+			echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agent_profiles.php\">\n";
+			echo "<div align='center'>\n";
+			echo "Update Complete\n";
+			echo "</div>\n";
+			require_once "includes/footer.php";
+			return;
+		} //if ($action == "update")
+	} //if ($_POST["persistformvar"] != "true")
+
+} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
+
+//pre-populate the form
+if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
+	$fifo_agent_profile_id = $_GET["id"];
+	$sql = "";
+	$sql .= "select * from v_fifo_agent_profiles ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$sql .= "and fifo_agent_profile_id = '$fifo_agent_profile_id' ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	foreach ($result as &$row) {
+		$domain_uuid = $row["domain_uuid"];
+		$profile_name = $row["profile_name"];
+		$profile_desc = $row["profile_desc"];
+		break; //limit to 1 row
+	}
+	unset ($prep_statement);
+}
+
+
+	require_once "includes/header.php";
+
+	echo "<div align='center'>";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing=''>\n";
+
+	echo "<tr class='border'>\n";
+	echo "	<td align=\"left\">\n";
+	echo "	  <br>";
+
+
+	echo "<form method='post' name='frm' action=''>\n";
+
+	echo "<div align='center'>\n";
+	echo "<table width='100%'  border='0' cellpadding='6' cellspacing='0'>\n";
+
+	echo "<tr>\n";
+	if ($action == "add") {
+		echo "<td align='left' width='30%' nowrap='nowrap' align='left'><b>Agent Profile Add</b></td>\n";
+	}
+	if ($action == "update") {
+		echo "<td align='left' width='30%' nowrap='nowrap' align='left'><b>Agent Profile Edit</b></td>\n";
+	}
+	echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='back' onclick=\"window.location='v_fifo_agent_profiles.php'\" value='Back'></td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
+	echo "	Profile Name:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='profile_name' maxlength='255' value=\"$profile_name\">\n";
+	echo "<br />\n";
+	echo "Enter the profile name.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
+	echo "	Description:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='profile_desc' maxlength='255' value=\"$profile_desc\">\n";
+	echo "<br />\n";
+	echo "Enter the description.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "	<tr>\n";
+	echo "		<td colspan='2' align='right'>\n";
+	if ($action == "update") {
+		echo "				<input type='hidden' name='fifo_agent_profile_id' value='$fifo_agent_profile_id'>\n";
+	}
+	echo "				<input type='submit' name='submit' class='btn' value='Save'>\n";
+	echo "		</td>\n";
+	echo "	</tr>";
+	echo "</table>";
+	echo "</form>";
+
+	if ($action == "update") {
+		require "v_fifo_agent_profile_members.php";
+	}
+
+	echo "	</td>";
+	echo "	</tr>";
+	echo "</table>";
+	echo "</div>";
+
+
+require_once "includes/footer.php";
+?>

+ 50 - 0
fifo_agents/fifo_agent_status_logs/root.php

@@ -0,0 +1,50 @@
+<?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 <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+
+// make sure the PATH_SEPARATOR is defined
+	if (!defined("PATH_SEPARATOR")) {
+		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
+	}
+
+// make sure the document_root is set
+	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
+	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
+	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
+	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
+
+// if the project directory exists then add it to the include path otherwise add the document root to the include path
+	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
+		if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); }
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
+	}
+	else {
+		if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); }
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
+	}
+
+?>

+ 185 - 0
fifo_agents/fifo_agent_status_logs/v_fifo_agent_status_logs.php

@@ -0,0 +1,185 @@
+<?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 <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+require_once "includes/header.php";
+require_once "includes/paging.php";
+
+$order_by = $_GET["order_by"];
+$order = $_GET["order"];
+
+//get the agent status session array
+	//unset($_SESSION["array_agent_status"]);
+	if (!is_array($_SESSION["array_agent_status"])) {
+		$sql = "SELECT var_name, var_value FROM v_vars ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and var_cat = 'Queues Agent Status' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		foreach($result as $field) {
+			$_SESSION["array_agent_status"][$field[var_value]] = $field[var_name];
+		}
+	}
+
+//send the content to the browser
+	echo "<div align='center'>";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
+	echo "<tr class='border'>\n";
+	echo "	<td align=\"center\">\n";
+	echo "		<br>";
+
+
+	echo "<table width='100%' border='0'>\n";
+	echo "<tr>\n";
+	echo "<td width='50%' nowrap='nowrap' align='left'><b>Fifo Agent Status Log List</b></td>\n";
+	echo "<td width='50%' align='right'>&nbsp;</td>\n";
+	echo "</tr>\n";
+	echo "<tr>\n";
+	echo "<td colspan='2' align='left'>\n";
+	echo "Agent Status History<br /><br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "</tr></table>\n";
+
+
+	$sql = "";
+	$sql .= " select * from v_fifo_agent_status_logs ";
+	if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	$num_rows = count($result);
+	unset ($prep_statement, $result, $sql);
+	$rows_per_page = 100;
+	$param = "";
+	$page = $_GET['page'];
+	if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } 
+	list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); 
+	$offset = $rows_per_page * $page; 
+
+	$sql = "";
+	$sql .= " select * from v_fifo_agent_status_logs ";
+	if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
+	$sql .= " limit $rows_per_page offset $offset ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	$result_count = count($result);
+	unset ($prep_statement, $sql);
+
+
+	$c = 0;
+	$row_style["0"] = "row_style0";
+	$row_style["1"] = "row_style1";
+
+	echo "<div align='center'>\n";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+
+	echo "<tr>\n";
+	echo th_order_by('username', 'Username', $order_by, $order);
+	echo th_order_by('agent_status', 'Status', $order_by, $order);
+	echo th_order_by('uuid', 'UUID', $order_by, $order);
+	echo th_order_by('add_date', 'Add Date', $order_by, $order);
+	echo "<td align='right' width='42'>\n";
+	echo "	<a href='v_fifo_agent_status_logs_edit.php' alt='add'>$v_link_label_add</a>\n";
+	//echo "	<input type='button' class='btn' name='' alt='add' onclick=\"window.location='v_fifo_agent_status_logs_edit.php'\" value='+'>\n";
+	echo "</td>\n";
+	echo "<tr>\n";
+
+	if ($result_count == 0) { //no results
+	}
+	else { //received results
+		foreach($result as $row) {
+			//print_r( $row );
+			//set the php variables
+				$agent_status = $row[agent_status];
+
+			//get the agent description
+				$agent_status_desc = $_SESSION["array_agent_status"][$agent_status];
+
+			echo "<tr >\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[username]."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$agent_status_desc."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[uuid]."&nbsp;</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[add_date]."</td>\n";
+			echo "	<td valign='top' align='right'>\n";
+			echo "		<a href='v_fifo_agent_status_logs_edit.php?id=".$row[fifo_agent_status_log_id]."' alt='edit'>$v_link_label_edit</a>\n";
+			echo "		<a href='v_fifo_agent_status_logs_delete.php?id=".$row[fifo_agent_status_log_id]."' alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">$v_link_label_delete</a>\n";
+			//echo "		<input type='button' class='btn' name='' alt='edit' onclick=\"window.location='v_fifo_agent_status_logs_edit.php?id=".$row[fifo_agent_status_log_id]."'\" value='e'>\n";
+			//echo "		<input type='button' class='btn' name='' alt='delete' onclick=\"if (confirm('Are you sure you want to delete this?')) { window.location='v_fifo_agent_status_logs_delete.php?id=".$row[fifo_agent_status_log_id]."' }\" value='x'>\n";
+			echo "	</td>\n";
+			echo "</tr>\n";
+			if ($c==0) { $c=1; } else { $c=0; }
+		} //end foreach
+		unset($sql, $result, $row_count);
+	} //end if results
+
+
+	echo "<tr>\n";
+	echo "<td colspan='5' align='left'>\n";
+	echo "	<table width='100%' cellpadding='0' cellspacing='0'>\n";
+	echo "	<tr>\n";
+	echo "		<td width='33.3%' nowrap>&nbsp;</td>\n";
+	echo "		<td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
+	echo "		<td width='33.3%' align='right'>\n";
+	echo "			<a href='v_fifo_agent_status_logs_edit.php' alt='add'>$v_link_label_add</a>\n";
+	//echo "		<input type='button' class='btn' name='' alt='add' onclick=\"window.location='v_fifo_agent_status_logs_edit.php'\" value='+'>\n";
+	echo "		</td>\n";
+	echo "	</tr>\n";
+ 	echo "	</table>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+
+	echo "</table>";
+	echo "</div>";
+	echo "<br><br>";
+	echo "<br><br>";
+
+
+	echo "</td>";
+	echo "</tr>";
+	echo "</table>";
+	echo "</div>";
+	echo "<br><br>";
+
+
+require_once "includes/footer.php";
+unset ($result_count);
+unset ($result);
+unset ($key);
+unset ($val);
+unset ($c);
+?>

+ 1 - 0
fifo_agents/fifo_agent_status_logs/v_fifo_agent_status_logs.sql

@@ -0,0 +1 @@
+CREATE TABLE v_fifo_agent_status_logs (fifo_agent_status_log_id INTEGER PRIMARY KEY, v_id NUMBER, username TEXT, agent_status TEXT, uuid TEXT, add_date TEXT)

+ 60 - 0
fifo_agents/fifo_agent_status_logs/v_fifo_agent_status_logs_delete.php

@@ -0,0 +1,60 @@
+<?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 <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+if (count($_GET)>0) {
+	$id = check_str($_GET["id"]);
+}
+
+if (strlen($id)>0) {
+	$sql = "";
+	$sql .= "delete from v_fifo_agent_status_logs ";
+	$sql .= "where fifo_agent_status_log_id = '$id' ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	unset($sql);
+}
+
+require_once "includes/header.php";
+echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agent_status_logs.php\">\n";
+echo "<div align='center'>\n";
+echo "Delete Complete\n";
+echo "</div>\n";
+
+require_once "includes/footer.php";
+return;
+
+?>
+

+ 262 - 0
fifo_agents/fifo_agent_status_logs/v_fifo_agent_status_logs_edit.php

@@ -0,0 +1,262 @@
+<?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 <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//action add or update
+	if (isset($_REQUEST["id"])) {
+		$action = "update";
+		$fifo_agent_status_log_id = check_str($_REQUEST["id"]);
+	}
+	else {
+		$action = "add";
+	}
+
+//POST to PHP variables
+	if (count($_POST)>0) {
+		$username = check_str($_POST["username"]);
+		$agent_status = check_str($_POST["agent_status"]);
+		$uuid = check_str($_POST["uuid"]);
+		$add_date = check_str($_POST["add_date"]);
+	}
+
+if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
+
+	$msg = '';
+	if ($action == "update") {
+		$fifo_agent_status_log_id = check_str($_POST["fifo_agent_status_log_id"]);
+	}
+
+	//check for all required data
+		//if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid<br>\n"; }
+		//if (strlen($username) == 0) { $msg .= "Please provide: Username<br>\n"; }
+		//if (strlen($agent_status) == 0) { $msg .= "Please provide: Status<br>\n"; }
+		//if (strlen($uuid) == 0) { $msg .= "Please provide: UUID<br>\n"; }
+		//if (strlen($add_date) == 0) { $msg .= "Please provide: Add Date<br>\n"; }
+		if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+			require_once "includes/header.php";
+			require_once "includes/persistformvar.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 "includes/footer.php";
+			return;
+		}
+
+
+	//add or update the database
+		if ($_POST["persistformvar"] != "true") {
+			if ($action == "add") {
+				$sql = "insert into v_fifo_agent_status_logs ";
+				$sql .= "(";
+				$sql .= "domain_uuid, ";
+				$sql .= "username, ";
+				$sql .= "agent_status, ";
+				$sql .= "uuid, ";
+				$sql .= "add_date ";
+				$sql .= ")";
+				$sql .= "values ";
+				$sql .= "(";
+				$sql .= "'$domain_uuid', ";
+				$sql .= "'$username', ";
+				$sql .= "'$agent_status', ";
+				$sql .= "'$uuid', ";
+				$sql .= "now() ";
+				$sql .= ")";
+				$db->exec(check_sql($sql));
+				unset($sql);
+
+				require_once "includes/header.php";
+				echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agent_logs.php\">\n";
+				echo "<div align='center'>\n";
+				echo "Add Complete\n";
+				echo "</div>\n";
+				require_once "includes/footer.php";
+				return;
+			} //if ($action == "add")
+
+			if ($action == "update") {
+				$sql = "update v_fifo_agent_status_logs set ";
+				$sql .= "domain_uuid = '$domain_uuid', ";
+				$sql .= "username = '$username', ";
+				$sql .= "agent_status = '$agent_status', ";
+				$sql .= "uuid = '$uuid', ";
+				$sql .= "add_date = '$add_date' ";
+				$sql .= "where domain_uuid = '$domain_uuid' ";
+				$sql .= "and fifo_agent_status_log_id = '$fifo_agent_status_log_id'";
+				$db->exec(check_sql($sql));
+				unset($sql);
+
+				require_once "includes/header.php";
+				echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agent_logs.php\">\n";
+				echo "<div align='center'>\n";
+				echo "Update Complete\n";
+				echo "</div>\n";
+				require_once "includes/footer.php";
+				return;
+			} //if ($action == "update")
+		} //if ($_POST["persistformvar"] != "true")
+
+} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
+
+
+//pre-populate the form
+	if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
+		$fifo_agent_status_log_id = $_GET["id"];
+		$sql = "";
+		$sql .= "select * from v_fifo_agent_status_logs ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and fifo_agent_status_log_id = '$fifo_agent_status_log_id' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		foreach ($result as &$row) {
+			$domain_uuid = $row["domain_uuid"];
+			$username = $row["username"];
+			$agent_status = $row["agent_status"];
+			$uuid = $row["uuid"];
+			$add_date = $row["add_date"];
+			break; //limit to 1 row
+		}
+		unset ($prep_statement);
+	}
+
+
+//send the content
+	require_once "includes/header.php";
+
+	echo "<div align='center'>";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing=''>\n";
+
+	echo "<tr class='border'>\n";
+	echo "	<td align=\"left\">\n";
+	echo "		<br>";
+
+
+	echo "<form method='post' name='frm' action=''>\n";
+
+	echo "<div align='center'>\n";
+	echo "<table width='100%'  border='0' cellpadding='6' cellspacing='0'>\n";
+
+	echo "<tr>\n";
+	if ($action == "add") {
+		echo "<td align='left' width='30%' nowrap='nowrap' align='left'><b>Fifo Agent Status Log Add</b></td>\n";
+	}
+	if ($action == "update") {
+		echo "<td align='left' width='30%' nowrap='nowrap' align='left'><b>Fifo Agent Status Log Edit</b></td>\n";
+	}
+	echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='back' onclick=\"window.location='v_fifo_agent_status_logs.php'\" value='Back'></td>\n";
+	echo "</tr>\n";
+	echo "<tr>\n";
+	echo "<td colspan='2' align='left'>\n";
+	echo "Agent Status History<br /><br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	domain_uuid:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "  <input class='formfld' type='text' name='domain_uuid' maxlength='255' value='$domain_uuid'>\n";
+	echo "<br />\n";
+	echo "\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	Username:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='username' maxlength='255' value=\"$username\">\n";
+	echo "<br />\n";
+	echo "Enter the Username.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	Status:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='agent_status' maxlength='255' value=\"$agent_status\">\n";
+	echo "<br />\n";
+	echo "Enter the agent status.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	UUID:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='uuid' maxlength='255' value=\"$uuid\">\n";
+	echo "<br />\n";
+	echo "Enter the UUID.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	Add Date:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='add_date' maxlength='255' value=\"$add_date\">\n";
+	echo "	<br />\n";
+	echo "	Enter the date.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "	<tr>\n";
+	echo "		<td colspan='2' align='right'>\n";
+	if ($action == "update") {
+		echo "				<input type='hidden' name='fifo_agent_status_log_id' value='$fifo_agent_status_log_id'>\n";
+	}
+	echo "				<input type='submit' name='submit' class='btn' value='Save'>\n";
+	echo "		</td>\n";
+	echo "	</tr>";
+	echo "</table>";
+	echo "</form>";
+
+	echo "	</td>";
+	echo "	</tr>";
+	echo "</table>";
+	echo "</div>";
+
+
+require_once "includes/footer.php";
+?>

+ 50 - 0
fifo_agents/fifo_languages/root.php

@@ -0,0 +1,50 @@
+<?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 <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+
+// make sure the PATH_SEPARATOR is defined
+	if (!defined("PATH_SEPARATOR")) {
+		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
+	}
+
+// make sure the document_root is set
+	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
+	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
+	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
+	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
+
+// if the project directory exists then add it to the include path otherwise add the document root to the include path
+	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
+		if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); }
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
+	}
+	else {
+		if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); }
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
+	}
+
+?>

+ 161 - 0
fifo_agents/fifo_languages/v_fifo_agent_languages.php

@@ -0,0 +1,161 @@
+<?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 <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+require_once "includes/header.php";
+require_once "includes/paging.php";
+
+$order_by = $_GET["order_by"];
+$order = $_GET["order"];
+	echo "<div align='center'>";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
+	echo "<tr class='border'>\n";
+	echo "	<td align=\"center\">\n";
+	echo "		<br>";
+
+
+	echo "<table width='100%' border='0'>\n";
+	echo "<tr>\n";
+	echo "<td width='50%' nowrap='nowrap' align='left'><b>Fifo Agent Language List</b></td>\n";
+	echo "<td width='50%' align='right'>&nbsp;</td>\n";
+	echo "</tr>\n";
+	echo "<tr>\n";
+	echo "<td colspan='2' align='left'>\n";
+	echo "Matches the Agent with languages they can speak with their proficiency level.<br /><br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "</tr></table>\n";
+
+
+	$sql = "";
+	$sql .= " select * from v_fifo_agent_languages ";
+	if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	$num_rows = count($result);
+	unset ($prep_statement, $result, $sql);
+	$rows_per_page = 10;
+	$param = "";
+	$page = $_GET['page'];
+	if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } 
+	list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); 
+	$offset = $rows_per_page * $page; 
+
+	$sql = "";
+	$sql .= " select * from v_fifo_agent_languages ";
+	if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
+	$sql .= " limit $rows_per_page offset $offset ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	$result_count = count($result);
+	unset ($prep_statement, $sql);
+
+
+	$c = 0;
+	$row_style["0"] = "row_style0";
+	$row_style["1"] = "row_style1";
+
+	echo "<div align='center'>\n";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+
+	echo "<tr>\n";
+	echo th_order_by('username', 'Username', $order_by, $order);
+	echo th_order_by('language', 'Language', $order_by, $order);
+	echo th_order_by('proficiency', 'Proficiency', $order_by, $order);
+	echo "<td align='right' width='42'>\n";
+	echo "	<a href='v_fifo_agent_languages_edit.php' alt='add'>$v_link_label_add</a>\n";
+	//echo "	<input type='button' class='btn' name='' alt='add' onclick=\"window.location='v_fifo_agent_languages_edit.php'\" value='+'>\n";
+	echo "</td>\n";
+	echo "<tr>\n";
+
+	if ($result_count == 0) { //no results
+	}
+	else { //received results
+		foreach($result as $row) {
+			//print_r( $row );
+			echo "<tr >\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[username]."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[language]."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[proficiency]."</td>\n";
+			echo "	<td valign='top' align='right'>\n";
+			echo "		<a href='v_fifo_agent_languages_edit.php?id=".$row[fifo_agent_language_id]."' alt='edit'>$v_link_label_edit</a>\n";
+			echo "		<a href='v_fifo_agent_languages_delete.php?id=".$row[fifo_agent_language_id]."' alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">$v_link_label_delete</a>\n";
+			//echo "		<input type='button' class='btn' name='' alt='edit' onclick=\"window.location='v_fifo_agent_languages_edit.php?id=".$row[fifo_agent_language_id]."'\" value='e'>\n";
+			//echo "		<input type='button' class='btn' name='' alt='delete' onclick=\"if (confirm('Are you sure you want to delete this?')) { window.location='v_fifo_agent_languages_delete.php?id=".$row[fifo_agent_language_id]."' }\" value='x'>\n";
+			echo "	</td>\n";
+			echo "</tr>\n";
+			if ($c==0) { $c=1; } else { $c=0; }
+		} //end foreach
+		unset($sql, $result, $row_count);
+	} //end if results
+
+
+	echo "<tr>\n";
+	echo "<td colspan='4' align='left'>\n";
+	echo "	<table width='100%' cellpadding='0' cellspacing='0'>\n";
+	echo "	<tr>\n";
+	echo "		<td width='33.3%' nowrap>&nbsp;</td>\n";
+	echo "		<td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
+	echo "		<td width='33.3%' align='right'>\n";
+	echo "			<a href='v_fifo_agent_languages_edit.php' alt='add'>$v_link_label_add</a>\n";
+	//echo "		<input type='button' class='btn' name='' alt='add' onclick=\"window.location='v_fifo_agent_languages_edit.php'\" value='+'>\n";
+	echo "		</td>\n";
+	echo "	</tr>\n";
+ 	echo "	</table>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+
+	echo "</table>";
+	echo "</div>";
+	echo "<br><br>";
+	echo "<br><br>";
+
+
+	echo "</td>";
+	echo "</tr>";
+	echo "</table>";
+	echo "</div>";
+	echo "<br><br>";
+
+
+require_once "includes/footer.php";
+unset ($result_count);
+unset ($result);
+unset ($key);
+unset ($val);
+unset ($c);
+?>

+ 1 - 0
fifo_agents/fifo_languages/v_fifo_agent_languages.sql

@@ -0,0 +1 @@
+CREATE TABLE v_fifo_agent_languages (fifo_agent_language_id INTEGER PRIMARY KEY, v_id TEXT, username TEXT, language TEXT, proficiency TEXT);

+ 60 - 0
fifo_agents/fifo_languages/v_fifo_agent_languages_delete.php

@@ -0,0 +1,60 @@
+<?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 <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+if (count($_GET)>0) {
+	$id = check_str($_GET["id"]);
+}
+
+if (strlen($id)>0) {
+	$sql = "";
+	$sql .= "delete from v_fifo_agent_languages ";
+	$sql .= "where fifo_agent_language_id = '$id' ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	unset($sql);
+}
+
+require_once "includes/header.php";
+echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agent_languages.php\">\n";
+echo "<div align='center'>\n";
+echo "Delete Complete\n";
+echo "</div>\n";
+
+require_once "includes/footer.php";
+return;
+
+?>
+

+ 337 - 0
fifo_agents/fifo_languages/v_fifo_agent_languages_edit.php

@@ -0,0 +1,337 @@
+<?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 <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//Action add or update
+if (isset($_REQUEST["id"])) {
+	$action = "update";
+	$fifo_agent_language_id = check_str($_REQUEST["id"]);
+}
+else {
+	$action = "add";
+}
+
+//POST to PHP variables
+	if (count($_POST)>0) {
+		$username = check_str($_POST["username"]);
+		$language = check_str($_POST["language"]);
+		$proficiency = check_str($_POST["proficiency"]);
+	}
+
+if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
+
+	$msg = '';
+
+	if ($action == "update") {
+		$fifo_agent_language_id = check_str($_POST["fifo_agent_language_id"]);
+	}
+
+	//check for all required data
+		//if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid<br>\n"; }
+		//if (strlen($username) == 0) { $msg .= "Please provide: Username<br>\n"; }
+		//if (strlen($language) == 0) { $msg .= "Please provide: Language<br>\n"; }
+		//if (strlen($proficiency) == 0) { $msg .= "Please provide: Proficiency<br>\n"; }
+		if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+			require_once "includes/header.php";
+			require_once "includes/persistformvar.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 "includes/footer.php";
+			return;
+		}
+
+
+	//Add or update the database
+	if ($_POST["persistformvar"] != "true") {
+		if ($action == "add") {
+			$sql = "insert into v_fifo_agent_languages ";
+			$sql .= "(";
+			$sql .= "domain_uuid, ";
+			$sql .= "username, ";
+			$sql .= "language, ";
+			$sql .= "proficiency ";
+			$sql .= ")";
+			$sql .= "values ";
+			$sql .= "(";
+			$sql .= "'$domain_uuid', ";
+			$sql .= "'$username', ";
+			$sql .= "'$language', ";
+			$sql .= "'$proficiency' ";
+			$sql .= ")";
+			$db->exec(check_sql($sql));
+			unset($sql);
+
+			require_once "includes/header.php";
+			echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agent_languages.php\">\n";
+			echo "<div align='center'>\n";
+			echo "Add Complete\n";
+			echo "</div>\n";
+			require_once "includes/footer.php";
+			return;
+		} //if ($action == "add")
+
+		if ($action == "update") {
+			$sql = "update v_fifo_agent_languages set ";
+			$sql .= "domain_uuid = '$domain_uuid', ";
+			$sql .= "username = '$username', ";
+			$sql .= "language = '$language', ";
+			$sql .= "proficiency = '$proficiency' ";
+			$sql .= "where domain_uuid = '$domain_uuid' ";
+			$sql .= "and fifo_agent_language_id = '$fifo_agent_language_id'";
+			$db->exec(check_sql($sql));
+			unset($sql);
+
+			require_once "includes/header.php";
+			echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agent_languages.php\">\n";
+			echo "<div align='center'>\n";
+			echo "Update Complete\n";
+			echo "</div>\n";
+			require_once "includes/footer.php";
+			return;
+		} //if ($action == "update")
+	} //if ($_POST["persistformvar"] != "true")
+
+} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
+
+//pre-populate the form
+	if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
+		$fifo_agent_language_id = $_GET["id"];
+		$sql = "";
+		$sql .= "select * from v_fifo_agent_languages ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and fifo_agent_language_id = '$fifo_agent_language_id' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		foreach ($result as &$row) {
+			$domain_uuid = $row["domain_uuid"];
+			$username = $row["username"];
+			$language = $row["language"];
+			$proficiency = $row["proficiency"];
+			break; //limit to 1 row
+		}
+		unset ($prep_statement);
+	}
+
+//begin the content
+	require_once "includes/header.php";
+
+
+	echo "<div align='center'>";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing=''>\n";
+
+	echo "<tr class='border'>\n";
+	echo "	<td align=\"left\">\n";
+	echo "	  <br>";
+
+
+	echo "<form method='post' name='frm' action=''>\n";
+
+	echo "<div align='center'>\n";
+	echo "<table width='100%'  border='0' cellpadding='6' cellspacing='0'>\n";
+
+	echo "<tr>\n";
+	if ($action == "add") {
+		echo "<td align='left' width='30%' nowrap='nowrap' align='left'><b>Fifo Agent Language Add</b></td>\n";
+	}
+	if ($action == "update") {
+		echo "<td align='left' width='30%' nowrap='nowrap' align='left'><b>Fifo Agent Language Edit</b></td>\n";
+	}
+	echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='back' onclick=\"window.location='v_fifo_agent_languages.php'\" value='Back'></td>\n";
+	echo "</tr>\n";
+	echo "<tr>\n";
+	echo "<td colspan='2' align='left'>\n";
+	echo "Matches the Agent with languages they can speak with their proficiency level.<br /><br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	Username:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+
+	//generate the user list
+		$sql = "SELECT * FROM v_users ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and user_enabled = 'true' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+
+		echo "<select name=\"username\" class='formfld'>\n";
+		echo "<option value=\"\"></option>\n";
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		foreach($result as $field) {
+			if ($username == $field[username]) {
+				echo "<option value='".$field[username]."' selected='selected'>".$field[username]."</option>\n";
+			}
+			else {
+				echo "<option value='".$field[username]."'>".$field[username]."</option>\n";
+			}
+		}
+		echo "</select>";
+		unset($sql, $result);
+
+	echo "<br />\n";
+	echo "Select the Username from the list.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	Language:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+
+	//generate the language select list
+		$sql = "SELECT var_name, var_value FROM v_vars ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and var_cat = 'Languages' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		echo "<select name=\"language\" class='formfld'>\n";
+		echo "<option value=\"\"></option>\n";
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		foreach($result as $field) {
+			if ($field[var_value] == $agent_status) {
+				echo "<option value='".$field[var_value]."' selected='selected'>".$field[var_name]."</option>\n";
+			}
+			else {
+				echo "<option value='".$field[var_value]."'>".$field[var_name]."</option>\n";
+			}
+		}
+		echo "</select>";
+
+	echo "<br />\n";
+	echo "Enter the two letter language code.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	Proficiency:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+
+	echo "	<select class='formfld' name='proficiency'>\n";
+	echo "	<option value=''></option>\n";
+	if ($agent_priority == "1") { 
+		echo "	<option value='1' SELECTED >1</option>\n";
+	}
+	else {
+		echo "	<option value='1'>1</option>\n";
+	}
+	if ($agent_priority == "2") { 
+		echo "	<option value='2' SELECTED >2</option>\n";
+	}
+	else {
+		echo "	<option value='2'>2</option>\n";
+	}
+	if ($agent_priority == "3") { 
+		echo "	<option value='3' SELECTED >3</option>\n";
+	}
+	else {
+		echo "	<option value='3'>3</option>\n";
+	}
+	if ($agent_priority == "4") { 
+		echo "	<option value='4' SELECTED >4</option>\n";
+	}
+	else {
+		echo "	<option value='4'>4</option>\n";
+	}
+	if ($agent_priority == "5") { 
+		echo "	<option value='5' SELECTED >5</option>\n";
+	}
+	else {
+		echo "	<option value='5'>5</option>\n";
+	}
+	if ($agent_priority == "6") { 
+		echo "	<option value='6' SELECTED >6</option>\n";
+	}
+	else {
+		echo "	<option value='6'>6</option>\n";
+	}
+	if ($agent_priority == "7") { 
+		echo "	<option value='7' SELECTED >7</option>\n";
+	}
+	else {
+		echo "	<option value='7'>7</option>\n";
+	}
+	if ($agent_priority == "8") { 
+		echo "	<option value='8' SELECTED >8</option>\n";
+	}
+	else {
+		echo "	<option value='8'>8</option>\n";
+	}
+	if ($agent_priority == "9") { 
+		echo "	<option value='9' SELECTED >9</option>\n";
+	}
+	else {
+		echo "	<option value='9'>9</option>\n";
+	}
+	if ($agent_priority == "10") { 
+		echo "	<option value='10' SELECTED >10</option>\n";
+	}
+	else {
+		echo "	<option value='10'>10</option>\n";
+	}
+	echo "	</select>\n";
+	echo "<br />\n";
+	echo "Select the language proficiency level.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "	<tr>\n";
+	echo "		<td colspan='2' align='right'>\n";
+	if ($action == "update") {
+		echo "				<input type='hidden' name='fifo_agent_language_id' value='$fifo_agent_language_id'>\n";
+	}
+	echo "				<input type='submit' name='submit' class='btn' value='Save'>\n";
+	echo "		</td>\n";
+	echo "	</tr>";
+	echo "</table>";
+	echo "</form>";
+
+	echo "	</td>";
+	echo "	</tr>";
+	echo "</table>";
+	echo "</div>";
+
+
+require_once "includes/footer.php";
+?>

+ 50 - 0
fifo_agents/root.php

@@ -0,0 +1,50 @@
+<?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 <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+
+// make sure the PATH_SEPARATOR is defined
+	if (!defined("PATH_SEPARATOR")) {
+		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
+	}
+
+// make sure the document_root is set
+	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
+	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
+	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
+	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
+
+// if the project directory exists then add it to the include path otherwise add the document root to the include path
+	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
+		if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); }
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
+	}
+	else {
+		if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); }
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
+	}
+
+?>

+ 206 - 0
fifo_agents/v_fifo_agents.php

@@ -0,0 +1,206 @@
+<?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 <[email protected]>
+	Copyright (C) 2010
+	All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+require_once "includes/header.php";
+require_once "includes/paging.php";
+
+
+//$time_start = microtime(true);
+//sleep for a while
+//usleep(1000000);
+
+
+$order_by = $_GET["order_by"];
+$order = $_GET["order"];
+
+
+	echo "<div align='center'>";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
+	echo "<tr class='border'>\n";
+	echo "	<td align=\"center\">\n";
+	echo "		<br>";
+
+
+	echo "<table width='100%' border='0'>\n";
+	echo "<tr>\n";
+	echo "<td width='50%' nowrap='nowrap' align='left'><b>Active Agents</b></td>\n";
+	echo "<td width='50%' align='right'>&nbsp;</td>\n";
+	echo "</tr>\n";
+	echo "<tr>\n";
+	echo "<td colspan='2' align='left'>\n";
+	echo "Shows the agents that are currently logged into the queues.<br /><br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "</tr></table>\n";
+
+	//set the default order by and order asc, desc
+		if (strlen($order_by) == 0) { 
+			$order_by  = 'fifo_name';
+			$order = 'asc';
+		}
+
+	//run the sql queries
+		$sql = "";
+		$sql .= " select * from v_fifo_agents ";
+		if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
+		//$sql .= " limit $rows_per_page offset $offset ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		$result_count = count($result);
+		unset ($prep_statement, $sql);
+
+
+	$c = 0;
+	$row_style["0"] = "row_style0";
+	$row_style["1"] = "row_style1";
+
+	echo "<div align='center'>\n";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+
+	echo "<tr>\n";
+	echo th_order_by('fifo_name', 'Queue Name', $order_by, $order);
+	echo th_order_by('agent_username', 'Username', $order_by, $order);
+	echo th_order_by('agent_priority', 'Agent Priority', $order_by, $order);
+	echo th_order_by('agent_status', 'Status', $order_by, $order);
+	echo th_order_by('agent_last_call', 'Last Call', $order_by, $order);
+	echo th_order_by('agent_last_uuid', 'Last UUID', $order_by, $order);
+	echo th_order_by('agent_contact_number', 'Contact Number', $order_by, $order);
+	echo "<td align='right' width='42'>\n";
+	echo "	<a href='v_fifo_agents_edit.php' alt='add'>$v_link_label_add</a>\n";
+	//echo "	<input type='button' class='btn' name='' alt='add' onclick=\"window.location='v_fifo_agents_edit.php'\" value='+'>\n";
+	echo "</td>\n";
+	echo "<tr>\n";
+
+	if ($result_count == 0) { //no results
+	}
+	else { //received results
+		foreach($result as $row) {
+			//set the php variables
+				$agent_last_call = $row[agent_last_call];
+				$agent_status = $row[agent_status];
+
+			//format the last call time
+				if ($agent_last_call == 0) {
+					$agent_last_call_desc = '';
+				}
+				else {
+					$agent_last_call_desc = date("g:i:s a j M Y",$agent_last_call);
+				}
+
+			//get the agent status session array
+				//unset($_SESSION["array_agent_status"]);
+				if (!is_array($_SESSION["array_agent_status"])) {
+					$sql = "SELECT var_name, var_value FROM v_vars ";
+					$sql .= "where domain_uuid = '$domain_uuid' ";
+					$sql .= "and var_cat = 'Queues Agent Status' ";
+					$prep_statement = $db->prepare(check_sql($sql));
+					$prep_statement->execute();
+					$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+					foreach($result as $field) {
+						$_SESSION["array_agent_status"][$field[var_value]] = $field[var_name];
+					}
+				}
+
+			//get the agent description
+				$agent_status_desc = $_SESSION["array_agent_status"][$agent_status];
+
+			echo "<tr >\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[fifo_name]."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[agent_username]."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[agent_priority]."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$agent_status_desc."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$agent_last_call_desc."&nbsp;</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[agent_last_uuid]."&nbsp;</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[agent_contact_number]."</td>\n";
+			echo "	<td valign='top' align='right'>\n";
+			echo "		<a href='v_fifo_agents_edit.php?id=".$row[fifo_agent_id]."' alt='edit'>$v_link_label_edit</a>\n";
+			echo "		<a href='v_fifo_agents_delete.php?id=".$row[fifo_agent_id]."' alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">$v_link_label_delete</a>\n";
+			//echo "		<input type='button' class='btn' name='' alt='edit' onclick=\"window.location='v_fifo_agents_edit.php?id=".$row[fifo_agent_id]."'\" value='e'>\n";
+			//echo "		<input type='button' class='btn' name='' alt='delete' onclick=\"if (confirm('Are you sure you want to delete this?')) { window.location='v_fifo_agents_delete.php?id=".$row[fifo_agent_id]."' }\" value='x'>\n";
+			echo "	</td>\n";
+			echo "</tr>\n";
+			if ($c==0) { $c=1; } else { $c=0; }
+		} //end foreach
+		unset($sql, $result, $row_count);
+	} //end if results
+
+
+	echo "<tr>\n";
+	echo "<td colspan='8' align='left'>\n";
+	echo "	<table width='100%' cellpadding='0' cellspacing='0'>\n";
+	echo "	<tr>\n";
+	echo "		<td width='33.3%' nowrap>&nbsp;</td>\n";
+	//echo "		<td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
+	echo "		<td width='33.3%' align='right'>\n";
+	echo "			<a href='v_fifo_agents_edit.php' alt='add'>$v_link_label_add</a>\n";
+	//echo "		<input type='button' class='btn' name='' alt='add' onclick=\"window.location='v_fifo_agents_edit.php'\" value='+'>\n";
+	echo "		</td>\n";
+	echo "	</tr>\n";
+ 	echo "	</table>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+
+	echo "</table>";
+	echo "</div>";
+	echo "<br><br>";
+	echo "<br><br>";
+
+//sleep(1);
+//$time_end = microtime(true);
+//$time = $time_end - $time_start;
+//if ($time < 2) {
+//	echo "use cache ";
+//}
+//else {
+//	echo "expired the cache ";
+//}
+//echo "load time $time seconds\n";
+
+	echo "</td>";
+	echo "</tr>";
+	echo "</table>";
+	echo "</div>";
+	echo "<br><br>";
+
+
+require_once "includes/footer.php";
+unset ($result_count);
+unset ($result);
+unset ($key);
+unset ($val);
+unset ($c);
+?>

+ 1 - 0
fifo_agents/v_fifo_agents.sql

@@ -0,0 +1 @@
+CREATE TABLE v_fifo_agents (fifo_agent_id INTEGER PRIMARY KEY, v_id NUMBER, fifo_name TEXT, agent_username TEXT, agent_priority TEXT, agent_status TEXT, agent_status_epoch NUMBER, agent_last_call NUMBER, agent_last_uuid TEXT, agent_contact_number NUMBER)

+ 60 - 0
fifo_agents/v_fifo_agents_delete.php

@@ -0,0 +1,60 @@
+<?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 <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+if (count($_GET)>0) {
+	$id = check_str($_GET["id"]);
+}
+
+if (strlen($id)>0) {
+	$sql = "";
+	$sql .= "delete from v_fifo_agents ";
+	$sql .= "where fifo_agent_id = '$id' ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	unset($sql);
+}
+
+require_once "includes/header.php";
+echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agents.php\">\n";
+echo "<div align='center'>\n";
+echo "Delete Complete\n";
+echo "</div>\n";
+
+require_once "includes/footer.php";
+return;
+
+?>
+

+ 480 - 0
fifo_agents/v_fifo_agents_edit.php

@@ -0,0 +1,480 @@
+<?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 <[email protected]>
+	Copyright (C) 2010
+	All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "includes/require.php";
+require_once "includes/checkauth.php";
+if (if_group("admin") || if_group("superadmin")) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//action add or update
+	if (isset($_REQUEST["id"])) {
+		$action = "update";
+		$fifo_agent_id = check_str($_REQUEST["id"]);
+	}
+	else {
+		$action = "add";
+	}
+
+//get http post variables and set them to php variables
+	if (count($_POST)>0) {
+		$fifo_name = check_str($_POST["fifo_name"]);
+		$agent_username = check_str($_POST["agent_username"]);
+		$agent_priority = check_str($_POST["agent_priority"]);
+		$agent_status = check_str($_POST["agent_status"]);
+		$agent_last_call = check_str($_POST["agent_last_call"]);
+		$agent_last_uuid = check_str($_POST["agent_last_uuid"]);
+		$agent_contact_number = check_str($_POST["agent_contact_number"]);
+	}
+
+if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
+
+	$msg = '';
+
+	////recommend moving this to the config.php file
+	$uploadtempdir = $_ENV["TEMP"]."\\";
+	ini_set('upload_tmp_dir', $uploadtempdir);
+	////$imagedir = $_ENV["TEMP"]."\\";
+	////$filedir = $_ENV["TEMP"]."\\";
+
+	if ($action == "update") {
+		$fifo_agent_id = check_str($_POST["fifo_agent_id"]);
+	}
+
+	//check for all required data
+		if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid<br>\n"; }
+		if (strlen($fifo_name) == 0) { $msg .= "Please provide: Queue Name<br>\n"; }
+		if (strlen($agent_username) == 0) { $msg .= "Please provide: Username<br>\n"; }
+		if (strlen($agent_priority) == 0) { $msg .= "Please provide: Agent Priority<br>\n"; }
+		if (strlen($agent_status) == 0) { $msg .= "Please provide: Status<br>\n"; }
+		//if (strlen($agent_last_call) == 0) { $msg .= "Please provide: Last Call<br>\n"; }
+		//if (strlen($agent_last_uuid) == 0) { $msg .= "Please provide: Last UUID<br>\n"; }
+		//if (strlen($agent_contact_number) == 0) { $msg .= "Please provide: Contact Number<br>\n"; }
+		if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+			require_once "includes/header.php";
+			require_once "includes/persistformvar.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 "includes/footer.php";
+			return;
+		}
+
+	//Add or update the database
+	if ($_POST["persistformvar"] != "true") {
+		if ($action == "add") {
+			$sql = "insert into v_fifo_agents ";
+			$sql .= "(";
+			$sql .= "domain_uuid, ";
+			$sql .= "fifo_name, ";
+			$sql .= "agent_username, ";
+			$sql .= "agent_priority, ";
+			$sql .= "agent_status, ";
+			$sql .= "agent_last_call, ";
+			$sql .= "agent_last_uuid, ";
+			$sql .= "agent_contact_number ";
+			$sql .= ")";
+			$sql .= "values ";
+			$sql .= "(";
+			$sql .= "'$domain_uuid', ";
+			$sql .= "'$fifo_name', ";
+			$sql .= "'$agent_username', ";
+			$sql .= "'$agent_priority', ";
+			$sql .= "'$agent_status', ";
+			$sql .= "'$agent_last_call', ";
+			$sql .= "'$agent_last_uuid', ";
+			$sql .= "'$agent_contact_number' ";
+			$sql .= ")";
+			$db->exec(check_sql($sql));
+			unset($sql);
+
+			require_once "includes/header.php";
+			echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agents.php\">\n";
+			echo "<div align='center'>\n";
+			echo "Add Complete\n";
+			echo "</div>\n";
+			require_once "includes/footer.php";
+			return;
+		} //if ($action == "add")
+
+		if ($action == "update") {
+			$sql = "update v_fifo_agents set ";
+			$sql .= "domain_uuid = '$domain_uuid', ";
+			$sql .= "fifo_name = '$fifo_name', ";
+			$sql .= "agent_username = '$agent_username', ";
+			$sql .= "agent_priority = '$agent_priority', ";
+			$sql .= "agent_status = '$agent_status', ";
+			$sql .= "agent_status_epoch = ".time()." ";
+			$sql .= "agent_last_call = '$agent_last_call', ";
+			$sql .= "agent_last_uuid = '$agent_last_uuid', ";
+			$sql .= "agent_contact_number = '$agent_contact_number' ";
+			$sql .= "where fifo_agent_id = '$fifo_agent_id'";
+			$db->exec(check_sql($sql));
+			unset($sql);
+
+			require_once "includes/header.php";
+			echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agents.php\">\n";
+			echo "<div align='center'>\n";
+			echo "Update Complete\n";
+			echo "</div>\n";
+			require_once "includes/footer.php";
+			return;
+		} //if ($action == "update")
+	} //if ($_POST["persistformvar"] != "true")
+
+} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
+
+//pre-populate the form
+	if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
+		$fifo_agent_id = $_GET["id"];
+		$sql = "";
+		$sql .= "select * from v_fifo_agents ";
+		$sql .= "where fifo_agent_id = '$fifo_agent_id' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		foreach ($result as &$row) {
+			$fifo_name = $row["fifo_name"];
+			$agent_username = $row["agent_username"];
+			$agent_priority = $row["agent_priority"];
+			$agent_status = $row["agent_status"];
+			$agent_last_call = $row["agent_last_call"];
+			$agent_last_uuid = $row["agent_last_uuid"];
+			$agent_contact_number = $row["agent_contact_number"];
+			break; //limit to 1 row
+		}
+		unset ($prep_statement);
+	}
+
+//send the content to the browser
+	require_once "includes/header.php";
+
+
+	echo "<div align='center'>";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing=''>\n";
+
+	echo "<tr class='border'>\n";
+	echo "	<td align=\"left\">\n";
+	echo "	  <br>";
+
+
+	echo "<form method='post' name='frm' action=''>\n";
+
+	echo "<div align='center'>\n";
+	echo "<table width='100%'  border='0' cellpadding='6' cellspacing='0'>\n";
+
+	echo "<tr>\n";
+	if ($action == "add") {
+		echo "<td align='left' width='30%' nowrap='nowrap' align='left'><b>Agent Login</b></td>\n";
+	}
+	if ($action == "update") {
+		echo "<td align='left' width='30%' nowrap='nowrap' align='left'><b>Fifo Agent Edit</b></td>\n";
+	}
+	echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='back' onclick=\"window.location='v_fifo_agents.php'\" value='Back'></td>\n";
+	echo "</tr>\n";
+	echo "<tr>\n";
+	echo "<td colspan='2' align='left'>\n";
+	echo "List the agents assigned to a Queue.<br /><br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
+	echo "	Queue Name:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	//echo "	<input class='formfld' type='text' name='fifo_name' maxlength='255' value=\"$fifo_name\">\n";
+
+		//generate the fifo name select list
+		$sql = "";
+		$sql .= "select * from v_dialplan_details ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		$x = 0;
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		echo "<select name=\"fifo_name\" class='formfld'>\n";
+		echo "<option value=\"\"></option>\n";
+		foreach ($result as &$row) {
+			if ($row["dialplan_detail_type"] == "fifo") {
+				//if (strpos($row["dialplan_detail_data"], '@${domain_name} in') !== false) {
+					//echo "rtrim(".$row["dialplan_detail_data"].", ' in') == ".$fifo_name."<br />";
+					if (rtrim($row["dialplan_detail_data"], " in") == $fifo_name) {
+						echo "		<option value='".rtrim($row["dialplan_detail_data"], " in")."' selected='selected'>".rtrim($row["dialplan_detail_data"], " in")."</option>\n";
+					}
+					else {
+						echo "		<option value='".rtrim($row["dialplan_detail_data"], " in")."'>".rtrim($row["dialplan_detail_data"], " in")."</option>\n";
+					}
+				//}
+			}
+		}
+		echo "</select>\n";
+		unset ($prep_statement);
+
+	echo "<br />\n";
+	echo "Select the queue name.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
+	echo "	Username:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	//echo "	<input class='formfld' type='text' name='agent_username' maxlength='255' value=\"$agent_username\">\n";
+
+	//generate the user list
+		$sql = "SELECT * FROM v_users ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and user_enabled = 'true' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+
+		echo "<select name=\"agent_username\" class='formfld'>\n";
+		echo "<option value=\"\"></option>\n";
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		foreach($result as $field) {
+			if ($agent_username == $field[username]) {
+				echo "<option value='".$field[username]."' selected='selected'>".$field[username]."</option>\n";
+			}
+			else {
+				echo "<option value='".$field[username]."'>".$field[username]."</option>\n";
+			}
+		}
+		echo "</select>";
+		unset($sql, $result);
+
+	echo "<br />\n";
+	echo "Select the username.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
+	echo "	Agent Priority:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<select class='formfld' name='agent_priority'>\n";
+	echo "	<option value=''></option>\n";
+	if ($agent_priority == "0") { 
+		echo "	<option value='0' SELECTED >0</option>\n";
+	}
+	else {
+		echo "	<option value='0'>0</option>\n";
+	}
+	if ($agent_priority == "1") { 
+		echo "	<option value='1' SELECTED >1</option>\n";
+	}
+	else {
+		echo "	<option value='1'>1</option>\n";
+	}
+	if ($agent_priority == "2") { 
+		echo "	<option value='2' SELECTED >2</option>\n";
+	}
+	else {
+		echo "	<option value='2'>2</option>\n";
+	}
+	if ($agent_priority == "3") { 
+		echo "	<option value='3' SELECTED >3</option>\n";
+	}
+	else {
+		echo "	<option value='3'>3</option>\n";
+	}
+	if ($agent_priority == "4") { 
+		echo "	<option value='4' SELECTED >4</option>\n";
+	}
+	else {
+		echo "	<option value='4'>4</option>\n";
+	}
+	if ($agent_priority == "5") { 
+		echo "	<option value='5' SELECTED >5</option>\n";
+	}
+	else {
+		echo "	<option value='5'>5</option>\n";
+	}
+	if ($agent_priority == "6") { 
+		echo "	<option value='6' SELECTED >6</option>\n";
+	}
+	else {
+		echo "	<option value='6'>6</option>\n";
+	}
+	if ($agent_priority == "7") { 
+		echo "	<option value='7' SELECTED >7</option>\n";
+	}
+	else {
+		echo "	<option value='7'>7</option>\n";
+	}
+	if ($agent_priority == "8") { 
+		echo "	<option value='8' SELECTED >8</option>\n";
+	}
+	else {
+		echo "	<option value='8'>8</option>\n";
+	}
+	if ($agent_priority == "9") { 
+		echo "	<option value='9' SELECTED >9</option>\n";
+	}
+	else {
+		echo "	<option value='9'>9</option>\n";
+	}
+	echo "	</select>\n";
+	echo "<br />\n";
+	echo "Select a priority.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
+	echo "	Status:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	//generate the agent status select list
+		$sql = "SELECT var_name, var_value FROM v_vars ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and var_cat = 'Queues Agent Status' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		echo "<select name=\"agent_status\" class='formfld'>\n";
+		echo "<option value=\"\"></option>\n";
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		foreach($result as $field) {
+			if ($field[var_value] == $agent_status) {
+				echo "<option value='".$field[var_value]."' selected='selected'>".$field[var_name]."</option>\n";
+			}
+			else {
+				echo "<option value='".$field[var_value]."'>".$field[var_name]."</option>\n";
+			}
+		}
+		echo "</select>";
+		/*
+				foreach($result as $field) {
+					$_SESSION["array_agent_status"][$field[var_value]] = $field[var_name];
+				}
+
+				$x=1;
+				foreach($_SESSION["array_agent_status"] as $value) {
+					echo "$x $value<br />\n";
+					$x++;
+				}
+		*/
+
+		if (!is_array($_SESSION["array_agent_status"])) {
+			echo "not an array";
+			foreach($result as $field) {
+				$_SESSION["array_agent_status"][$field[var_value]] = $field[var_name];
+			}
+		}
+		else {
+			//echo "is an array";
+			//unset($_SESSION["array_agent_status"]);
+		}
+		unset($sql, $result);
+
+	/*
+	echo "	<select class='formfld' name='agent_status'>\n";
+	echo "	<option value=''></option>\n";
+	if ($agent_status == "busy") { 
+		echo "	<option value='busy' SELECTED >busy</option>\n";
+	}
+	else {
+		echo "	<option value='busy'>busy</option>\n";
+	}
+	if ($agent_status == "break") { 
+		echo "	<option value='break' SELECTED >break</option>\n";
+	}
+	else {
+		echo "	<option value='break'>break</option>\n";
+	}
+	if ($agent_status == "waiting") { 
+		echo "	<option value='waiting' SELECTED >waiting</option>\n";
+	}
+	else {
+		echo "	<option value='waiting'>waiting</option>\n";
+	}
+	echo "	</select>\n";
+	*/
+	echo "<br />\n";
+	echo "Enter the status of the Agent.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	Last Call:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "  <input class='formfld' type='text' name='agent_last_call' maxlength='255' value='$agent_last_call'>\n";
+	echo "<br />\n";
+	echo "\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	Last UUID:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='agent_last_uuid' maxlength='255' value=\"$agent_last_uuid\">\n";
+	echo "<br />\n";
+	echo "Enter the UUID for the last call.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap>\n";
+	echo "	Contact Number:\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "  <input class='formfld' type='text' name='agent_contact_number' maxlength='255' value='$agent_contact_number'>\n";
+	echo "<br />\n";
+	echo "Enter the agent contact number.\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "	<tr>\n";
+	echo "		<td colspan='2' align='right'>\n";
+	if ($action == "update") {
+		echo "				<input type='hidden' name='fifo_agent_id' value='$fifo_agent_id'>\n";
+	}
+	echo "				<input type='submit' name='submit' class='btn' value='Save'>\n";
+	echo "		</td>\n";
+	echo "	</tr>";
+	echo "</table>";
+	echo "</form>";
+
+	echo "	</td>";
+	echo "	</tr>";
+	echo "</table>";
+	echo "</div>";
+
+
+require_once "includes/footer.php";
+?>