forked from SimplesIP/pabx-app
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
4.0 KiB
124 lines
4.0 KiB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
|
"http://www.w3.org/TR/html4/loose.dtd"> |
|
<html> |
|
<head> |
|
<title>Untitled Document</title> |
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
|
<style type="text/css"> |
|
<!-- |
|
body { |
|
background-color: #00FF00; |
|
} |
|
--> |
|
</style></head> |
|
|
|
<body> |
|
<?php |
|
/** |
|
* Description of agenteMonitor |
|
* |
|
* @author apereira |
|
*/ |
|
require_once('bd.php'); |
|
require_once('constantes.php'); |
|
require_once('contacteFunc.php'); |
|
|
|
class agenteMonitor { |
|
|
|
//put your code here |
|
|
|
public function __construct() { |
|
$this->endScrp = false; |
|
} |
|
|
|
function __destruct() { |
|
$this->LogoffAgente(); |
|
} |
|
|
|
function LogoffAgente() { |
|
$matricula = GetMatricula(); |
|
$ramal = GetRamal(); |
|
$login = GetLogin(); |
|
$dac = $_SESSION[AGT_DAC_CONECT]; |
|
|
|
//se tpatend manual remove agente da fila |
|
if ($_SESSION[AGT_TP_ATEND] == 0) |
|
@GetUrl(AST_REM_FILA); |
|
|
|
$result = GetUrl(AST_LOGOFF_AGENTE); |
|
|
|
if ($result) { |
|
$result = pg_query("begin"); |
|
//atualiza dados do supervisor |
|
|
|
$query = "delete |
|
from pbx_supervisor_agentes |
|
where matricula = '$matricula'"; |
|
$result = pg_query($query); |
|
$result = pg_affected_rows($result); |
|
|
|
//registra o login do usuario |
|
if ($result) { |
|
$idLogoff = $_SESSION[AGT_ID_LOGIN]; |
|
$query = "update pbx_eventos_agentes |
|
set logoff = now() |
|
where id = $idLogoff"; |
|
$result = pg_query($query); |
|
$result = pg_affected_rows($result); |
|
} |
|
} |
|
if ($result) { |
|
pg_query("commit"); |
|
$_SESSION[AGT_CONECT] = 0; |
|
$_SESSION[AGT_TP_ATEND] = 0; |
|
$_SESSION[AGT_DAC_CONECT] = 0; |
|
return true; |
|
} else { |
|
pg_query("rollback"); |
|
} |
|
} |
|
|
|
function VerificaAgenteLogado() { |
|
$matricula = GetMatricula(); |
|
$query = "select count(*) from pbx_supervisor_agentes where matricula = '$matricula'"; |
|
$result = pg_query($query); |
|
$row = pg_fetch_row($result); |
|
return $row[0]; |
|
} |
|
|
|
function RemoveAgenteFila() { |
|
GetUrl(AST_REM_FILA); |
|
} |
|
|
|
function GetEndScrp() { |
|
return $this->endScrp; |
|
} |
|
|
|
private $endScrp; |
|
|
|
} |
|
|
|
define("SEG", 1000000); |
|
define("CENT_SEG", 10000); |
|
define("TIME_SLEEP", 5); |
|
$monitor = new agenteMonitor(); |
|
|
|
$seg = SEG * TIME_SLEEP; |
|
print "Monitorando -> "; |
|
flush(); |
|
while (true) { |
|
if (AgenteAtendeManual()) { |
|
if ($monitor->VerificaAgenteLogado()) { |
|
$monitor->RemoveAgenteFila(); |
|
} |
|
} |
|
$disp .= "."; |
|
print $disp; |
|
flush(); |
|
if ($monitor->GetEndScrp()) |
|
break; |
|
//tempo de espera |
|
//usleep($seg); |
|
sleep(5); |
|
} |
|
?>
|
|
|