|
|
|
|
<?php
|
|
|
|
|
/***************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* Metricas Diaria Anual
|
|
|
|
|
* Autor
|
|
|
|
|
* Lucas Awade
|
|
|
|
|
*
|
|
|
|
|
* *************************************************************************
|
|
|
|
|
Defini<EFBFBD><EFBFBD>es do Projeto
|
|
|
|
|
Nome: RelMetricasDiariaAneel
|
|
|
|
|
Data in<EFBFBD>cio: 21/08/2018
|
|
|
|
|
Equipe: Amarildo Pereira
|
|
|
|
|
Descri<EFBFBD><EFBFBD>o:
|
|
|
|
|
Este relat<EFBFBD>rio tem a finalidade de agregar valores e gerar resultados
|
|
|
|
|
em outros afins, com isso s<EFBFBD>o utilizadas formulas para a constru<EFBFBD><EFBFBD>o dos
|
|
|
|
|
mesmos. Al<EFBFBD>m disso, conta com dados utilizados no dia de acordo com os ho-
|
|
|
|
|
r<EFBFBD>rios registrados, ainda possui inform<EFBFBD><EFBFBD>es de TIPICO e ATIPICO conforme
|
|
|
|
|
em dados j<EFBFBD> registrados.
|
|
|
|
|
|
|
|
|
|
Formulas:
|
|
|
|
|
-> <EFBFBD>ndice N<EFBFBD>vel de servi<EFBFBD>o [INS]:
|
|
|
|
|
<EFBFBD> calculado pela rela<EFBFBD><EFBFBD>o entre chamadas atendidas at<EFBFBD> 30s pela soma
|
|
|
|
|
total das chamadas atendidas no pa + o total de abandonadas.
|
|
|
|
|
atendidas_30 / (atendidas-pa + abandonadas) * 100.0;
|
|
|
|
|
|
|
|
|
|
$atendida30Total = $atendidas30;
|
|
|
|
|
$atdPaAbd = $atendidas + $abandonadas;
|
|
|
|
|
$ins = $atdPaAbd > 0 ? ($atendida30Total / $atdPaAbd) * 100.0 : 0;
|
|
|
|
|
$ins = round($ins, 2); //NS
|
|
|
|
|
|
|
|
|
|
REPRESENTADA POR:
|
|
|
|
|
$row['ins'] = $cr == 0 ? 0 : round((($row["atendidas_30"] / $cr) * 100.0), 2);
|
|
|
|
|
|
|
|
|
|
-> Indice de abandono [IAB]:
|
|
|
|
|
<EFBFBD> o simples percentual de chamadas abandonadas em relacao as ofereciadas.
|
|
|
|
|
|
|
|
|
|
$iab = $oferTotal > 0 ? ($abdTotal / $oferTotal) * 100.0 : 0;
|
|
|
|
|
$iab = round($iab, 2);
|
|
|
|
|
*
|
|
|
|
|
REPRESENTADA POR:
|
|
|
|
|
$row['iab'] = ($row["atendidas_30"] + $row["abandonadas31"]) == 0 ? 0 : round((($row["abandonadas31"] / ($row["atendidas_30"] + $row["abandonadas31"])) * 100.0), 2);
|
|
|
|
|
|
|
|
|
|
-> Indice de Chamadas Oferecidas [ICO]:
|
|
|
|
|
Foi representado por 0.
|
|
|
|
|
|
|
|
|
|
* *************************************************************************
|
|
|
|
|
* Copyright (c) 2018, Simples IP
|
|
|
|
|
* *************************************************************************/
|
|
|
|
|
|
|
|
|
|
include_once 'util/relatoriosBase.php';
|
|
|
|
|
require_once("desvioPadrao.php");
|
|
|
|
|
|
|
|
|
|
class RelMetricasDiariaAneel extends Relatorios {
|
|
|
|
|
|
|
|
|
|
public function __construct($idProg, $dbcon, $incDac) {
|
|
|
|
|
parent::__construct($idProg, $dbcon, $incDac);
|
|
|
|
|
$this->___dac = isset($_POST['listaDacs']) ? $_POST['listaDacs'] : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ___ValidaForm() {
|
|
|
|
|
|
|
|
|
|
if (!IsPostBack()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ($this->GetIncDac() && !StrToIntDef($this->___dac)) {
|
|
|
|
|
GeraExcept('Informe uma Fila!');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!is_date($this->___dataIni)) {
|
|
|
|
|
GeraExcept('A "Data" informada <EFBFBD> inv<EFBFBD>lida!');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ___FiltrosRelatorio() {
|
|
|
|
|
|
|
|
|
|
if ($this->___media != MEDIA_PRINT_GRID) {
|
|
|
|
|
/*
|
|
|
|
|
* Recupera os filtros da sess<EFBFBD>o do usu<EFBFBD>rio.
|
|
|
|
|
*/
|
|
|
|
|
list($this->___dac, $this->___dataIni) = $_SESSION["SSstorageFiltros"];
|
|
|
|
|
|
|
|
|
|
$fltCsv = array();
|
|
|
|
|
if ($this->GetIncDac()) {
|
|
|
|
|
$fltCsv[] = 'Fila:' . GetDacDesc($this->GetDbCon(), $this->___dac);
|
|
|
|
|
}
|
|
|
|
|
$fltCsv[] = "Data Inicial:" . $this->___dataIni;
|
|
|
|
|
$fltCsv[] = "Data Final:" . $this->___dataIni;
|
|
|
|
|
$fltCsv[] = "Data Emissao:" . date('d/m/Y H:i:s');
|
|
|
|
|
$fltCsv[] = "Emitido Por:" . GetLogin();
|
|
|
|
|
return $fltCsv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($this->GetIncDac()) {
|
|
|
|
|
$dacs = GetDac($this->GetDbCon(), $this->___dac, "", 0, 1, 0, 0, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$lkPrint = "";
|
|
|
|
|
if ($this->___dac > 0) {
|
|
|
|
|
$prt = '<a href="index.php?idProg=%s&media=%s&tipoRelatorio=%s"><img src="imgSite/%s" alt="Clique aqui para imprimir!" width="24" height="24" border="0"></a>';
|
|
|
|
|
$prtHtml = "<a href=\"javaScript:NovaJanela('index.php?idProg=%s&media=%s&tipoRelatorio=%s', '%s', '720', '700', 'scrollbars=YES');\"><img src=\"imgSite/%s\" alt=\"Clique aqui para imprimir!\" width=\"24\" height=\"24\" border=\"0\"></a>";
|
|
|
|
|
$lkPrint .= sprintf($prtHtml, $this->GetidProg(), MEDIA_PRINT_HTML, $this->___tipoRelatorio, substr(LimpaString(GetDispProgSel($this->GetIdProg())), 0, 20), 'print.gif');
|
|
|
|
|
$lkPrint .= sprintf($prt, $this->GetidProg(), MEDIA_PRINT_EXCEL, $this->___tipoRelatorio, 'prt-xls.png');
|
|
|
|
|
$lkPrint .= sprintf($prt, $this->GetidProg(), MEDIA_PRINT_PDF, $this->___tipoRelatorio, 'prt-pdf.png');
|
|
|
|
|
$lkPrint .= sprintf($prt, $this->GetidProg(), MEDIA_PRINT_CSV, $this->___tipoRelatorio, 'prt-csv.png');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$tipoRel = !$this->___tipoRelatorio ? '' : 'checked="checked"';
|
|
|
|
|
/*
|
|
|
|
|
* Personalise esta fun<EFBFBD><EFBFBD>o se necessitar de outras op<EFBFBD><EFBFBD>es de filtro.
|
|
|
|
|
*/
|
|
|
|
|
$filtro = '<table border="0" cellspacing="1" cellpadding="1">';
|
|
|
|
|
/*
|
|
|
|
|
* Rotulos.
|
|
|
|
|
*/
|
|
|
|
|
$filtro .= '<tr>';
|
|
|
|
|
if ($this->GetIncDac())
|
|
|
|
|
$filtro .= '<td>Fila</td>';
|
|
|
|
|
$filtro .= '<td>Data </td>';
|
|
|
|
|
$filtro .= '<td align="center" valign="middle"> </td>';
|
|
|
|
|
$filtro .= '</tr>';
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Valores.
|
|
|
|
|
*/
|
|
|
|
|
$filtro .= '<tr>';
|
|
|
|
|
if ($this->GetIncDac())
|
|
|
|
|
$filtro .= sprintf('<td>%s</td>', $dacs);
|
|
|
|
|
$filtro .= '<td><input name="dataIni" id="dataIni" type="text" size="15" maxlength="10" value="%s" onkeyup="formataData(this)" title="dd/mm/aaaa"></td>';
|
|
|
|
|
$filtro .= '<td><input type="submit" name="btConsulta" id="btConsulta" value="Consultar"></td>';
|
|
|
|
|
$filtro .= '<td>%s</td>';
|
|
|
|
|
$filtro .= '</tr>';
|
|
|
|
|
$filtro .= '</table>';
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Guarda os filtros passados para recuperar na emiss<EFBFBD>o dos relat?ios para impress<EFBFBD>o.
|
|
|
|
|
*/
|
|
|
|
|
$_SESSION["SSstorageFiltros"] = array($this->___dac, $this->___dataIni);
|
|
|
|
|
|
|
|
|
|
return sprintf($filtro, $this->___dataIni, $lkPrint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___GetDadosDb() {
|
|
|
|
|
|
|
|
|
|
$data = FormatDtMssql($this->___dataIni);
|
|
|
|
|
$dac = $this->___dac;
|
|
|
|
|
|
|
|
|
|
$query = "SELECT coalesce(I.data,'$data') as data
|
|
|
|
|
,h.hora_ini
|
|
|
|
|
,case when(h.hora_fim = '23:59:59')then '00:00:00' else h.hora_fim end as hora_fim
|
|
|
|
|
,h.periodo
|
|
|
|
|
,COALESCE(I.OFERECIDAS,0) AS OFERECIDAS
|
|
|
|
|
,COALESCE(I.ATENDIDAS_URA,0) AS ATENDIDAS_URA
|
|
|
|
|
,COALESCE(I.ABANDONADAS,0) AS ABANDONADAS
|
|
|
|
|
,COALESCE(I.ABANDONADAS30,0) AS ABANDONADAS30
|
|
|
|
|
,COALESCE(I.ABANDONADAS31,0) AS ABANDONADAS31
|
|
|
|
|
,COALESCE(I.ATENDIDAS_PA,0) AS ATENDIDAS_PA
|
|
|
|
|
,COALESCE(I.ATENDIDAS_30,0) AS ATENDIDAS_30
|
|
|
|
|
,COALESCE(I.ATENDIDAS_31,0) AS ATENDIDAS_31
|
|
|
|
|
,COALESCE(I.TRANSFERIDAS,0) AS TRANSFERIDAS
|
|
|
|
|
,COALESCE(I.ESPERA,0) AS ESPERA
|
|
|
|
|
,COALESCE(round( CASE WHEN(I.ATENDIDAS_PA = 0)THEN 0 ELSE (I.TEMPO_ATENDIMENTO / I.ATENDIDAS_PA)END),0) * INTERVAL '1 SECOND' AS TMA
|
|
|
|
|
,0 AS OCUPADAS
|
|
|
|
|
,0 AS RECEBIDAS_PESSOALMENTE
|
|
|
|
|
,0 AS ATENDIMENTO_URA
|
|
|
|
|
,0 AS ICO
|
|
|
|
|
,COALESCE(I.TEMPO_ESPERA,0) AS TEMPO_ESPERA
|
|
|
|
|
,COALESCE(I.TEMPO_ATENDIMENTO,0) AS TEMPO_ATENDIMENTO
|
|
|
|
|
,COALESCE(I.TEMPO_ABANDONO,0) AS TEMPO_ABANDONO
|
|
|
|
|
,COALESCE(I.num_agente,0) AS num_agente
|
|
|
|
|
FROM pbx_hora_dia h
|
|
|
|
|
left outer join (
|
|
|
|
|
SELECT
|
|
|
|
|
calldate as data,
|
|
|
|
|
hora_ini
|
|
|
|
|
,hora_fim
|
|
|
|
|
,periodo
|
|
|
|
|
,SUM (CASE WHEN EVENTO = 'ENTERQUEUE' THEN 1 ELSE 0 END) AS OFERECIDAS
|
|
|
|
|
,SUM (CASE WHEN EVENTO = 'ENTERQUEUE' THEN 1 ELSE 0 END) AS ATENDIDAS_URA
|
|
|
|
|
,SUM (CASE WHEN((EVENTO = 'ABANDON'))THEN 1 ELSE 0 END) AS ABANDONADAS
|
|
|
|
|
,SUM (CASE WHEN((EVENTO = 'ABANDON') AND (param3::int <= 30) )THEN 1 ELSE 0 END) AS ABANDONADAS30
|
|
|
|
|
,SUM (CASE WHEN((EVENTO = 'ABANDON') AND (param3::int > 30) )THEN 1 ELSE 0 END) AS ABANDONADAS31
|
|
|
|
|
,SUM (CASE WHEN EVENTO IN ('COMPLETEAGENT','COMPLETECALLER') THEN 1 ELSE 0 END) AS ATENDIDAS_PA
|
|
|
|
|
,SUM (CASE WHEN EVENTO IN ('COMPLETEAGENT','COMPLETECALLER') AND to_number(param1,'999999999') <= '30' THEN 1 ELSE 0 END) AS ATENDIDAS_30
|
|
|
|
|
,SUM (CASE WHEN EVENTO IN ('COMPLETEAGENT','COMPLETECALLER') AND to_number(param1,'999999999') > '30' THEN 1 ELSE 0 END) AS ATENDIDAS_31
|
|
|
|
|
,SUM (CASE WHEN EVENTO IN ('TRANSFER') THEN 1 ELSE 0 END) AS TRANSFERIDAS
|
|
|
|
|
,SUM (CASE WHEN EVENTO IN ('CONNECT') AND to_number(param1,'999999999') > '3' THEN 1 ELSE 0 END) AS ESPERA
|
|
|
|
|
,SUM (CASE WHEN EVENTO IN ('CONNECT') AND to_number(param1,'999999999') > '1' THEN to_number(param1,'999999999') ELSE 0 END) AS TEMPO_ESPERA
|
|
|
|
|
,SUM (CASE WHEN EVENTO IN ('COMPLETEAGENT','COMPLETECALLER') AND to_number(param2,'999999999') > '1' THEN to_number(param2,'999999999') ELSE 0 END) AS TEMPO_ATENDIMENTO
|
|
|
|
|
,SUM (CASE WHEN( (EVENTO = 'ABANDON') ) THEN to_number(param3,'999999999') ELSE 0 END) AS TEMPO_ABANDONO
|
|
|
|
|
,count(distinct agente) as num_agente
|
|
|
|
|
FROM (
|
|
|
|
|
SELECT
|
|
|
|
|
c.hora_ini, c.hora_fim, c.periodo, a.calldate,b.fila,b.evento,b.param1,b.param2,b.param3,b.param4, case when(b.agente = 'NONE')THEN NULL ELSE b.agente END AS agente
|
|
|
|
|
FROM pbx_hora_dia c
|
|
|
|
|
INNER JOIN pbx_bilhetes a on cast(a.calldate as time) >= c.hora_ini and cast(a.calldate as time) < c.hora_fim and a.lastapp <> 'Transferred Call'
|
|
|
|
|
INNER JOIN pbx_eventos_dacs b on b.uid2 = a.uniqueid
|
|
|
|
|
INNER JOIN pbx_dacs d on d.nome = b.fila
|
|
|
|
|
WHERE b.evento in ('ABANDON','COMPLETEAGENT','COMPLETECALLER', 'CONNECT','ENTERQUEUE','TRANSFER')
|
|
|
|
|
AND a.data_bilhete = '$data'
|
|
|
|
|
AND d.id = $dac
|
|
|
|
|
) AS DADOS
|
|
|
|
|
GROUP BY calldate, hora_ini, hora_fim, periodo
|
|
|
|
|
) AS I on I.periodo = h.periodo ORDER BY 4";
|
|
|
|
|
|
|
|
|
|
$result = $this->___GetQuery($query);
|
|
|
|
|
$row = pg_fetch_all($result);
|
|
|
|
|
$this->SetData($row ? $row : array());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaCsv() {
|
|
|
|
|
global $dbcon;
|
|
|
|
|
$dataRel = array();
|
|
|
|
|
$filtro = $this->___FiltrosRelatorio();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Inicia o relat<EFBFBD>rio.
|
|
|
|
|
*/
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($filtro);
|
|
|
|
|
|
|
|
|
|
$dadosCabecalio = array(
|
|
|
|
|
$this->___dataIni,
|
|
|
|
|
'TIP' ,'CA <= 30','CA > 30','AB <= 30','AB > 30','CO','COF','INS',
|
|
|
|
|
'IAB','ICO','TMA','AT'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$dadosField = array(
|
|
|
|
|
'data','tip','atendidas_30','atendidas_31','abandonadas30',
|
|
|
|
|
'abandonadas31','co','oferecidas','ins','iab','ico','tma','num_agente'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Monta a linha de cabecalio.
|
|
|
|
|
*/
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($dadosCabecalio);
|
|
|
|
|
|
|
|
|
|
$ca30 = 0;
|
|
|
|
|
$ca31 = 0;
|
|
|
|
|
$ab30 = 0;
|
|
|
|
|
$ab31 = 0;
|
|
|
|
|
$cof = 0;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Linhas de dados.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
$row['co'] = 0;
|
|
|
|
|
$cr = $row["atendidas_pa"] + $row["abandonadas"];
|
|
|
|
|
|
|
|
|
|
$row['ins'] = $cr == 0 ? 0 : round((($row["atendidas_30"] / $cr) * 100.0), 2);
|
|
|
|
|
$row['iab'] = ($row["atendidas_30"] + $row["abandonadas31"]) == 0 ? 0 : round((($row["abandonadas31"] / ($row["atendidas_30"] + $row["abandonadas31"])) * 100.0), 2);
|
|
|
|
|
$row['ico'] = $row['oferecidas'] == 0 ? 0 : round(((0 / $row['oferecidas']) * 100.0), 2);
|
|
|
|
|
$mediaCalc = 0;
|
|
|
|
|
$desvio = round(GetDesvio(GetDadosDia($dbcon, $this->___dac, $row["data"], $row['periodo']), $mediaCalc));
|
|
|
|
|
$mediaCalc = round($mediaCalc);
|
|
|
|
|
|
|
|
|
|
$row['tip'] = "-";
|
|
|
|
|
if ($row['oferecidas'] > 0) {
|
|
|
|
|
$diaTipico = 1;
|
|
|
|
|
if (($row['oferecidas'] > ($mediaCalc + ($desvio * 2)))) {
|
|
|
|
|
$diaTipico = 0;
|
|
|
|
|
$row['tip'] = 'ATIPICO';
|
|
|
|
|
} else if (($row['oferecidas'] < ($mediaCalc - ($desvio * 2)))) {
|
|
|
|
|
$diaTipico = 0;
|
|
|
|
|
$row['tip'] = 'ATIPICO';
|
|
|
|
|
} else {
|
|
|
|
|
$row['tip'] = 'TIPICO';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($diaTipico) {
|
|
|
|
|
$mediaIns += ($cr * $row['ins']);
|
|
|
|
|
$pesoIns += $cr;
|
|
|
|
|
}
|
|
|
|
|
if ($diaTipico) {
|
|
|
|
|
$mediaIab += ($cr * $row['iab']);
|
|
|
|
|
$pesoIab += $cr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($row['data']){
|
|
|
|
|
$row['data'] = $row['hora_ini'].' as '.$row['hora_fim'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$tins = $pesoIns == 0 ? 0 : round($mediaIns / $pesoIns, 2);
|
|
|
|
|
$tiab = $pesoIab == 0 ? 0 : round($mediaIab / $pesoIab, 2);
|
|
|
|
|
$tico = 0;
|
|
|
|
|
$ca30 += $row['atendidas_30'];
|
|
|
|
|
$ca31 += $row['atendidas_31'];
|
|
|
|
|
$ab30 += $row['abandonadas30'];
|
|
|
|
|
$ab31 += $row['abandonadas31'];
|
|
|
|
|
$cof += $row['oferecidas'];
|
|
|
|
|
// Formata linha de dados.
|
|
|
|
|
$linha = array();
|
|
|
|
|
foreach ($dadosField as $value) {
|
|
|
|
|
$linha[] = $row["$value"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($linha);
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array('Total ','-' ,$ca30, $ca31, $ab30, $ab31, 0,$cof,'INS','IAB','ICO','-','-'));
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array('Media Ponderada ', '-', '-', '-', '-', '-','-','-',$tins, $tiab, $tico,'-','-'));
|
|
|
|
|
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array(''));
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array('INS', 'IAB', 'ICO','CO','COF'));
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array('Indice de Nivel de Servico', 'Indice Abandonadas', 'Indice de Chamadas Oferecidas','Oferecidas','Oferecidas na Fila'));
|
|
|
|
|
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaExcel() {
|
|
|
|
|
global $dbcon;
|
|
|
|
|
$dataRel = array();
|
|
|
|
|
$filtro = $this->___FiltrosRelatorio();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Inicia o relat<EFBFBD>rio.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Cria os filtros
|
|
|
|
|
*/
|
|
|
|
|
$linha = array('LABEL');
|
|
|
|
|
foreach ($filtro as $values) {
|
|
|
|
|
list($label, $value) = explode(":", $values);
|
|
|
|
|
$linha[] = $label;
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
|
|
|
|
|
$linha = array('DADOS');
|
|
|
|
|
foreach ($filtro as $values) {
|
|
|
|
|
list($label, $value) = explode(":", $values);
|
|
|
|
|
$linha[] = $value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
|
|
|
|
|
$dadosCabecalio = array(
|
|
|
|
|
$this->___dataIni,
|
|
|
|
|
'TIP' ,'CA <= 30','CA > 30','AB <= 30','AB > 30','CO','COF','INS',
|
|
|
|
|
'IAB','ICO','TMA','AT'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$dadosField = array(
|
|
|
|
|
'data','tip','atendidas_30','atendidas_31','abandonadas30',
|
|
|
|
|
'abandonadas31','co','oferecidas','ins','iab','ico','tma','num_agente'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Monta a linha de cabecalio.
|
|
|
|
|
*/
|
|
|
|
|
$linha = array('LABEL');
|
|
|
|
|
foreach ($dadosCabecalio as $value) {
|
|
|
|
|
$linha[] = $value;
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
|
|
|
|
|
$ca30 = 0;
|
|
|
|
|
$ca31 = 0;
|
|
|
|
|
$ab30 = 0;
|
|
|
|
|
$ab31 = 0;
|
|
|
|
|
$cof = 0;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Linhas de dados.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
|
|
|
|
|
$row['co'] = 0;
|
|
|
|
|
$cr = $row["atendidas_pa"] + $row["abandonadas"];
|
|
|
|
|
|
|
|
|
|
$row['ins'] = $cr == 0 ? 0 : round((($row["atendidas_30"] / $cr) * 100.0), 2);
|
|
|
|
|
$row['iab'] = ($row["atendidas_30"] + $row["abandonadas31"]) == 0 ? 0 : round((($row["abandonadas31"] / ($row["atendidas_30"] + $row["abandonadas31"])) * 100.0), 2);
|
|
|
|
|
$row['ico'] = $row['oferecidas'] == 0 ? 0 : round(((0 / $row['oferecidas']) * 100.0), 2);
|
|
|
|
|
$mediaCalc = 0;
|
|
|
|
|
$desvio = round(GetDesvio(GetDadosDia($dbcon, $this->___dac, $row["data"], $row['periodo']), $mediaCalc));
|
|
|
|
|
$mediaCalc = round($mediaCalc);
|
|
|
|
|
|
|
|
|
|
$row['tip'] = "-";
|
|
|
|
|
if ($row['oferecidas'] > 0) {
|
|
|
|
|
$diaTipico = 1;
|
|
|
|
|
if (($row['oferecidas'] > ($mediaCalc + ($desvio * 2)))) {
|
|
|
|
|
$diaTipico = 0;
|
|
|
|
|
$row['tip'] = 'ATIPICO';
|
|
|
|
|
} else if (($row['oferecidas'] < ($mediaCalc - ($desvio * 2)))) {
|
|
|
|
|
$diaTipico = 0;
|
|
|
|
|
$row['tip'] = 'ATIPICO';
|
|
|
|
|
} else {
|
|
|
|
|
$row['tip'] = 'TIPICO';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($diaTipico) {
|
|
|
|
|
$mediaIns += ($cr * $row['ins']);
|
|
|
|
|
$pesoIns += $cr;
|
|
|
|
|
}
|
|
|
|
|
if ($diaTipico) {
|
|
|
|
|
$mediaIab += ($cr * $row['iab']);
|
|
|
|
|
$pesoIab += $cr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($row['data']){
|
|
|
|
|
$row['data'] = $row['hora_ini'].' as '.$row['hora_fim'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$tins = $pesoIns == 0 ? 0 : round($mediaIns / $pesoIns, 2);
|
|
|
|
|
$tiab = $pesoIab == 0 ? 0 : round($mediaIab / $pesoIab, 2);
|
|
|
|
|
$tico = 0;
|
|
|
|
|
$ca30 += $row['atendidas_30'];
|
|
|
|
|
$ca31 += $row['atendidas_31'];
|
|
|
|
|
$ab30 += $row['abandonadas30'];
|
|
|
|
|
$ab31 += $row['abandonadas31'];
|
|
|
|
|
$cof += $row['oferecidas'];
|
|
|
|
|
|
|
|
|
|
// Formata linha de dados.
|
|
|
|
|
$linha = array('DADOS');
|
|
|
|
|
foreach ($dadosField as $key) {
|
|
|
|
|
$linha[] = $row["$key"];
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dataRel[] = array('LABEL', 'Total ','-' ,$ca30, $ca31, $ab30, $ab31, 0,$cof,'INS','IAB','ICO','-','-');
|
|
|
|
|
$dataRel[] = array('LABEL', 'Media Ponderada ', '-', '-', '-', '-', '-','-','-',$tins, $tiab, $tico,'-','-');
|
|
|
|
|
|
|
|
|
|
$dataRel[] = array('DADOS', '');
|
|
|
|
|
$dataRel[] = array('LABEL', 'INS', 'IAB', 'ICO','CO','COF');
|
|
|
|
|
$dataRel[] = array('DADOS', 'Indice de Nivel de Servico', 'Indice Abandonadas', 'Indice de Chamadas Oferecidas','Oferecidas','Oferecidas na Fila');
|
|
|
|
|
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaGrid() {
|
|
|
|
|
$dataRel = array();
|
|
|
|
|
global $dbcon;
|
|
|
|
|
|
|
|
|
|
$dadosCabecalio = array(
|
|
|
|
|
$this->___dataIni => 'align="center"',
|
|
|
|
|
'TIP' => 'align="center"',
|
|
|
|
|
'CA <= 30' => 'align="center"',
|
|
|
|
|
'CA > 30' => 'align="center"',
|
|
|
|
|
'AB <= 30' => 'align="center"',
|
|
|
|
|
'AB > 30' => 'align="center"',
|
|
|
|
|
'CO' => 'align="center"',
|
|
|
|
|
'COF' => 'align="center"',
|
|
|
|
|
'INS' => 'align="center"',
|
|
|
|
|
'IAB' => 'align="center"',
|
|
|
|
|
'ICO' => 'align="center"',
|
|
|
|
|
'TMA' => 'align="center"',
|
|
|
|
|
'AT' => 'align="center"'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$dadosField = array(
|
|
|
|
|
'data' => 'align="center"',
|
|
|
|
|
'tip' => 'align="center"',
|
|
|
|
|
'atendidas_30' => 'align="center"',
|
|
|
|
|
'atendidas_31' => 'align="center"',
|
|
|
|
|
'abandonadas30' => 'align="center"',
|
|
|
|
|
'abandonadas31' => 'align="center"',
|
|
|
|
|
'co' => 'align="center"',
|
|
|
|
|
'oferecidas' => 'align="center"',
|
|
|
|
|
'ins' => 'align="center"',
|
|
|
|
|
'iab' => 'align="center"',
|
|
|
|
|
'ico' => 'align="center"',
|
|
|
|
|
'tma' => 'align="center"',
|
|
|
|
|
'num_agente' => 'align="center"'
|
|
|
|
|
);
|
|
|
|
|
/*
|
|
|
|
|
* Inicia o relat<EFBFBD>rio.
|
|
|
|
|
*/
|
|
|
|
|
$dataRel[] = '<table width="100%" cellpadding="2" class="grid">';
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Monta a linha de cabecalio.
|
|
|
|
|
*/
|
|
|
|
|
$linha = '<tr>';
|
|
|
|
|
foreach ($dadosCabecalio as $key => $value) {
|
|
|
|
|
$linha .= sprintf("<th %s>%s</th>", $value, $key);
|
|
|
|
|
}
|
|
|
|
|
$linha .= "</tr>";
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Verifica se retornou dados
|
|
|
|
|
*/
|
|
|
|
|
if (!IsPostBack() || !count($this->GetData()[0])) {
|
|
|
|
|
$dataRel[] = sprintf("<tr><td align=\"center\" colspan=\"%s\">%s<td></tr></table>", count($dadosCabecalio) - 1, (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!'));
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$ca30 = 0;
|
|
|
|
|
$ca31 = 0;
|
|
|
|
|
$ab30 = 0;
|
|
|
|
|
$ab31 = 0;
|
|
|
|
|
$cof = 0;
|
|
|
|
|
|
|
|
|
|
$mediaIns = 0;
|
|
|
|
|
$pesoIns = 0;
|
|
|
|
|
$mediaIab = 0;
|
|
|
|
|
$pesoIab = 0;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Linhas de dados.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
|
|
|
|
|
$row['co'] = 0;
|
|
|
|
|
$cr = $row["atendidas_pa"] + $row["abandonadas"];
|
|
|
|
|
|
|
|
|
|
$row['ins'] = $cr == 0 ? 0 : round((($row["atendidas_30"] / $cr) * 100.0), 2);
|
|
|
|
|
$row['iab'] = ($row["atendidas_30"] + $row["abandonadas31"]) == 0 ? 0 : round((($row["abandonadas31"] / ($row["atendidas_30"] + $row["abandonadas31"])) * 100.0), 2);
|
|
|
|
|
$row['ico'] = $row['oferecidas'] == 0 ? 0 : round(((0 / $row['oferecidas']) * 100.0), 2);
|
|
|
|
|
$mediaCalc = 0;
|
|
|
|
|
$desvio = round(GetDesvio(GetDadosDia($dbcon, $this->___dac, $row["data"], $row['periodo']), $mediaCalc));
|
|
|
|
|
$mediaCalc = round($mediaCalc);
|
|
|
|
|
|
|
|
|
|
$row['tip'] = "-";
|
|
|
|
|
if ($row['oferecidas'] > 0) {
|
|
|
|
|
$diaTipico = 1;
|
|
|
|
|
if (($row['oferecidas'] > ($mediaCalc + ($desvio * 2)))) {
|
|
|
|
|
$diaTipico = 0;
|
|
|
|
|
$row['tip'] = sprintf("<span class=\"atipicoMaior\" title=\"Recebidas: %s M<EFBFBD>dia: $mediaCalc Desvio: $desvio\"><strong>AT<EFBFBD>PICO</strong></span>", $row['oferecidas']);
|
|
|
|
|
} else if (($row['oferecidas'] < ($mediaCalc - ($desvio * 2)))) {
|
|
|
|
|
$diaTipico = 0;
|
|
|
|
|
$row['tip'] = sprintf("<span class=\"atipicoMenor\" title=\"Recebidas: %s M<EFBFBD>dia: $mediaCalc Desvio: $desvio\"><strong>AT<EFBFBD>PICO</strong></span>", $row['oferecidas']);
|
|
|
|
|
} else {
|
|
|
|
|
$row['tip'] = sprintf("<span class=\"tipico\" title=\"Recebidas: %s M<EFBFBD>dia: $mediaCalc Desvio: $desvio\"><strong>T<EFBFBD>PICO</strong></span>", $row['oferecidas']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($diaTipico) {
|
|
|
|
|
$mediaIns += ($cr * $row['ins']);
|
|
|
|
|
$pesoIns += $cr;
|
|
|
|
|
}
|
|
|
|
|
if ($diaTipico) {
|
|
|
|
|
$mediaIab += ($cr * $row['iab']);
|
|
|
|
|
$pesoIab += $cr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$tins = $pesoIns == 0 ? 0 : round($mediaIns / $pesoIns, 2);
|
|
|
|
|
$tiab = $pesoIab == 0 ? 0 : round($mediaIab / $pesoIab, 2);
|
|
|
|
|
$tico = 0;
|
|
|
|
|
$ca30 += $row['atendidas_30'];
|
|
|
|
|
$ca31 += $row['atendidas_31'];
|
|
|
|
|
$ab30 += $row['abandonadas30'];
|
|
|
|
|
$ab31 += $row['abandonadas31'];
|
|
|
|
|
$cof += $row['oferecidas'];
|
|
|
|
|
|
|
|
|
|
// Formata linha de dados.
|
|
|
|
|
$linha = "<tr>";
|
|
|
|
|
foreach ($dadosField as $key => $value) {
|
|
|
|
|
if ($key == 'data') {
|
|
|
|
|
$linha .= sprintf("<td %s>%s</td>", $value, $row['hora_ini'] . ' <EFBFBD>s ' . $row['hora_fim']);
|
|
|
|
|
} else {
|
|
|
|
|
$linha .= sprintf("<td %s>%s</td>", $value, $row["$key"]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$linha .= "</tr>";
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* Linha de totalizacao.
|
|
|
|
|
*/
|
|
|
|
|
$linha = '<tr><th align="left" colspan="2">Total</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>INS</th><th>IAB</th><th>ICO</th><th colspan="2"></th></tr>';
|
|
|
|
|
$dataRel[] = sprintf($linha, $ca30, $ca31, $ab30, $ab31, 0, $cof);
|
|
|
|
|
|
|
|
|
|
$linha = '<tr><th colspan="8">M<EFBFBD>dia Ponderada</th><th>%s</th><th>%s</th><th>%s</th><th colspan="2"></th></tr>';
|
|
|
|
|
$linha .= "</table>";
|
|
|
|
|
$dataRel[] = sprintf($linha, $tins, $tiab, $tico);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Fecha relatorio.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
$linha = '<br><table width="30%" cellpadding="2" class="grid">';
|
|
|
|
|
$linha .= "<tr><th colspan=\"2\">Legenda</th></tr>";
|
|
|
|
|
$linha .= "<tr>"
|
|
|
|
|
. "<th>CO</th>"
|
|
|
|
|
. "<td>Oferecidas</td>"
|
|
|
|
|
. "<tr><th>COF</th>"
|
|
|
|
|
. "<td>Oferecidas na Fila</td></tr>"
|
|
|
|
|
. "<tr><th>INS</th>"
|
|
|
|
|
. "<td><EFBFBD>ndice de N<EFBFBD>vel de Servi<EFBFBD>o</td></tr></tr>"
|
|
|
|
|
. "<tr><th>IAB</th>"
|
|
|
|
|
. "<td><EFBFBD>ndice de Abandono</td></tr></tr>"
|
|
|
|
|
. "<tr><th>ICO</th>"
|
|
|
|
|
. "<td><EFBFBD>ndice de Chamadas Oferecidas</td></tr></tr>";
|
|
|
|
|
$linha .= '</table>';
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaHtml() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaPdf() {
|
|
|
|
|
list($this->___dac, $this->___dataIni) = $_SESSION["SSstorageFiltros"];
|
|
|
|
|
$this->___dataFim = $this->___dataIni;
|
|
|
|
|
$dataRel = array();
|
|
|
|
|
$dados = $this->GetData()[0];
|
|
|
|
|
global $dbcon;
|
|
|
|
|
|
|
|
|
|
$dadosCabecalio = array(
|
|
|
|
|
$this->___dataIni => 'C',
|
|
|
|
|
'TIP' => 'C',
|
|
|
|
|
'CA <= 30' => 'C',
|
|
|
|
|
'CA > 30' => 'C',
|
|
|
|
|
'AB <= 30' => 'C',
|
|
|
|
|
'AB > 30' => 'C',
|
|
|
|
|
'CO' => 'C',
|
|
|
|
|
'COF' => 'C',
|
|
|
|
|
'INS' => 'C',
|
|
|
|
|
'IAB' => 'C',
|
|
|
|
|
'ICO' => 'C',
|
|
|
|
|
'TMA' => 'C',
|
|
|
|
|
'AT' => 'C'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$dadosField = array(
|
|
|
|
|
'data' => 'C',
|
|
|
|
|
'tip' => 'C',
|
|
|
|
|
'atendidas_30' => 'C',
|
|
|
|
|
'atendidas_31' => 'C',
|
|
|
|
|
'abandonadas30' => 'C',
|
|
|
|
|
'abandonadas31' => 'C',
|
|
|
|
|
'co' => 'C',
|
|
|
|
|
'oferecidas' => 'C',
|
|
|
|
|
'ins' => 'C',
|
|
|
|
|
'iab' => 'C',
|
|
|
|
|
'ico' => 'C',
|
|
|
|
|
'tma' => 'C',
|
|
|
|
|
'num_agente' => 'C'
|
|
|
|
|
);
|
|
|
|
|
$x = 0;
|
|
|
|
|
foreach ($dados as $row) {
|
|
|
|
|
$dados[$x]['co'] = 0;
|
|
|
|
|
$cr = $row["atendidas_pa"] + $row["abandonadas"];
|
|
|
|
|
|
|
|
|
|
$dados[$x]['ins'] = $cr == 0 ? 0 : round((($row["atendidas_30"] / $cr) * 100.0), 2);
|
|
|
|
|
$dados[$x]['iab'] = ($row["atendidas_30"] + $row["abandonadas31"]) == 0 ? 0 : round((($row["abandonadas31"] / ($row["atendidas_30"] + $row["abandonadas31"])) * 100.0), 2);
|
|
|
|
|
$dados[$x]['ico'] = $row['oferecidas'] == 0 ? 0 : round(((0 / $row['oferecidas']) * 100.0), 2);
|
|
|
|
|
$mediaCalc = 0;
|
|
|
|
|
$desvio = round(GetDesvio(GetDadosDia($dbcon, $this->___dac, $row["data"], $row['periodo']), $mediaCalc));
|
|
|
|
|
$mediaCalc = round($mediaCalc);
|
|
|
|
|
|
|
|
|
|
$dados[$x]['tip'] = "-";
|
|
|
|
|
if ($row['oferecidas'] > 0) {
|
|
|
|
|
$diaTipico = 1;
|
|
|
|
|
if (($row['oferecidas'] > ($mediaCalc + ($desvio * 2)))) {
|
|
|
|
|
$diaTipico = 0;
|
|
|
|
|
$dados[$x]['tip'] = "AT<EFBFBD>PICO";
|
|
|
|
|
} else if (($row['oferecidas'] < ($mediaCalc - ($desvio * 2)))) {
|
|
|
|
|
$diaTipico = 0;
|
|
|
|
|
$dados[$x]['tip'] = "AT<EFBFBD>PICO";
|
|
|
|
|
} else {
|
|
|
|
|
$dados[$x]['tip'] = "T<EFBFBD>PICO";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($diaTipico) {
|
|
|
|
|
$mediaIns += ($cr * $dados[$x]['ins']);
|
|
|
|
|
$pesoIns += $cr;
|
|
|
|
|
}
|
|
|
|
|
if ($diaTipico) {
|
|
|
|
|
$mediaIab += ($cr * $dados[$x]['iab']);
|
|
|
|
|
$pesoIab += $cr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($row['data']){
|
|
|
|
|
$dados[$x]['data'] = $row['hora_ini'].' <EFBFBD>s '.$row['hora_fim'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$tins = $pesoIns == 0 ? 0 : round($mediaIns / $pesoIns, 2);
|
|
|
|
|
$tiab = $pesoIab == 0 ? 0 : round($mediaIab / $pesoIab, 2);
|
|
|
|
|
$tico = 0;
|
|
|
|
|
$ca30 += $row['atendidas_30'];
|
|
|
|
|
$ca31 += $row['atendidas_31'];
|
|
|
|
|
$ab30 += $row['abandonadas30'];
|
|
|
|
|
$ab31 += $row['abandonadas31'];
|
|
|
|
|
$cof += $row['oferecidas'];
|
|
|
|
|
|
|
|
|
|
$x++;
|
|
|
|
|
}
|
|
|
|
|
$widthHeader = array(30, 15, 15, 15, 15, 15, 12, 12, 12, 12, 12, 15, 12);
|
|
|
|
|
$totaliza = array('Total', '-', $ca30, $ca31, $ab30, $ab31, 0, $cof, 'INS', 'IAB', 'ICO', '-', '-');
|
|
|
|
|
|
|
|
|
|
//Monta o array para passar para o prepara; Necess<EFBFBD>rio passar 6 parametros
|
|
|
|
|
$table = array($dadosCabecalio, $dadosField, $dados, $widthHeader, $totaliza, 0);
|
|
|
|
|
|
|
|
|
|
$total = array('M<EFBFBD>dia Ponderada', '-', '-', '-', '-', '-', '-', '-', $tins, $tiab,$tico, '-', '-');
|
|
|
|
|
|
|
|
|
|
$totalHeader = array(30, 15, 15, 15, 15, 15, 12, 12, 12, 12, 12, 15, 12);
|
|
|
|
|
$table1 = array('', '', '', $totalHeader, $total, 0);
|
|
|
|
|
|
|
|
|
|
$legendaCabecalio = array(
|
|
|
|
|
"INS" => 'C',
|
|
|
|
|
"IAB" => 'C',
|
|
|
|
|
'ICO' => 'C',
|
|
|
|
|
'CO' => 'C',
|
|
|
|
|
'COF' => 'C'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$legendaField = array(
|
|
|
|
|
1 => 'C',
|
|
|
|
|
2 => 'C',
|
|
|
|
|
3 => 'C',
|
|
|
|
|
4 => 'C',
|
|
|
|
|
5 => 'C'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$legDadosField = array(array(
|
|
|
|
|
1 => 'N<EFBFBD>vel de Servi<EFBFBD>o',
|
|
|
|
|
2 => '<EFBFBD>ndice de Abandono',
|
|
|
|
|
3 => '<EFBFBD>ndice de Chamadas Oferecidas',
|
|
|
|
|
4 => 'Oferecidas',
|
|
|
|
|
5 => 'Oferecidas na Fila'
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$legendaHeader = array(30,30,40,30,30);
|
|
|
|
|
$table2 = array($legendaCabecalio, $legendaField, $legDadosField, $legendaHeader, 0, 1);
|
|
|
|
|
|
|
|
|
|
$this->___dataRel = array($table,$table1,$table2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function ExecutaRelatorio() {
|
|
|
|
|
global $jsStartup, $jsJQuery, $smarty;
|
|
|
|
|
try {
|
|
|
|
|
/*
|
|
|
|
|
* Formata as linha da fun<EFBFBD><EFBFBD>o date
|
|
|
|
|
*/
|
|
|
|
|
//setlocale(LC_ALL, "pt_BR", "pt_BR.iso-8859-1", "pt_BR.utf-8", "portuguese");
|
|
|
|
|
/*
|
|
|
|
|
* Use esta fun<EFBFBD><EFBFBD>o para validar dados do formul<EFBFBD>rio.
|
|
|
|
|
*/
|
|
|
|
|
$this->___ValidaForm();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Recupera os dados do banco.
|
|
|
|
|
*/
|
|
|
|
|
$this->___ConteudoRelatorio();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Imprime relat<EFBFBD>rio de acordo com a media passada.
|
|
|
|
|
*/
|
|
|
|
|
$conteudoRelatorio = $this->___ImprimeRelatorio();
|
|
|
|
|
} catch (Exception $exc) {
|
|
|
|
|
$this->SetMsg($exc->getMessage());
|
|
|
|
|
$jsStartup[] = sprintf("alert('%s');", $this->GetMsg());
|
|
|
|
|
$this->___GravaLog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Inclua os scripts necess<EFBFBD>rios aqui.
|
|
|
|
|
*/
|
|
|
|
|
$jsJQuery[] = "\$('#dataIni').keypress(function(){formataDataHora(this);}) ";
|
|
|
|
|
$jsJQuery[] = "\$('#dataFim').keypress(function(){formataDataHora(this);}) ";
|
|
|
|
|
|
|
|
|
|
$smarty->assign('filtros', $this->___FiltrosRelatorio());
|
|
|
|
|
$smarty->assign('conteudo', $conteudoRelatorio);
|
|
|
|
|
$smarty->assign('msg', $this->GetMsg());
|
|
|
|
|
GetTemplate($smarty, 'relatoriosGrid.tpl');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$relMetricasDiariaAneel = new RelMetricasDiariaAneel($idProg, $dbcon, 1);
|
|
|
|
|
$relMetricasDiariaAneel->ExecutaRelatorio();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
require_once("bd.php");
|
|
|
|
|
require_once("desvioPadrao.php");
|
|
|
|
|
|
|
|
|
|
$isValid = 1;
|
|
|
|
|
$msg = '';
|
|
|
|
|
|
|
|
|
|
//variaveis para manter o estado
|
|
|
|
|
$_SESSION["listaDacs"] = isset($_POST["listaDacs"]) ? $_POST["listaDacs"] : GetIdDacPadrao($dbcon, $_SESSION["SSidUser"]);
|
|
|
|
|
$_SESSION["data"] = isset($_POST["dataIni"]) ? $_POST["dataIni"] : date('d/m/Y');
|
|
|
|
|
|
|
|
|
|
//carrega dacs
|
|
|
|
|
$dacs = GetDac($dbcon, $_SESSION["listaDacs"]);
|
|
|
|
|
$_SESSION[SSdacDesc] = GetDacDesc($dbcon, $_SESSION["listaDacs"]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//sumarização do relatorio
|
|
|
|
|
$dac = $_SESSION["listaDacs"];
|
|
|
|
|
$codMes = FormatDtMssql($_SESSION["data"]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (IsPostBack()) {
|
|
|
|
|
if (!$_SESSION["listaDacs"]) {
|
|
|
|
|
$jsStartup[] = "alert('Selecione um Dispositivo!');";
|
|
|
|
|
$msg = "Selecione um Dispositivo!";
|
|
|
|
|
} else {
|
|
|
|
|
//importa dados para calcular o desvio padrao
|
|
|
|
|
ImportaDadosDesvioDia($dbcon);
|
|
|
|
|
|
|
|
|
|
//print GetDesvio('2009-09-17', $dbcon) . "<br>";
|
|
|
|
|
$linhas = "";
|
|
|
|
|
$linhaTmp = "";
|
|
|
|
|
$result = @pg_query($dbcon, GetQuery($dac, $codMes));
|
|
|
|
|
$i = 0;
|
|
|
|
|
$dados = array();
|
|
|
|
|
|
|
|
|
|
while ($row = @pg_fetch_array($result)) {
|
|
|
|
|
$dia = substr($row["hora_ini"], 0, 5) . " <EFBFBD>s " . substr($row["hora_fim"], 0, 5);
|
|
|
|
|
$data = $row["data"];
|
|
|
|
|
$atendidas30 = $row["atendidas_30"];
|
|
|
|
|
$atendidasM = $row["atendidas_31"];
|
|
|
|
|
$abandonadas = $row["abandonadas"];
|
|
|
|
|
$abandonadas30 = $row["abandonadas30"];
|
|
|
|
|
$abandonadasM = $row["abandonadas31"];
|
|
|
|
|
$atendidas = $row["atendidas_pa"];
|
|
|
|
|
$recebidas = $row["oferecidas"];
|
|
|
|
|
$tma = $row["tma"];
|
|
|
|
|
$agt = $row["num_agente"];
|
|
|
|
|
$periodo = $row["periodo"];
|
|
|
|
|
$caIab = $atendidas; // + $abandonadasM;
|
|
|
|
|
|
|
|
|
|
$co = 0;
|
|
|
|
|
$cr = $atendidas + $abandonadas;
|
|
|
|
|
|
|
|
|
|
$tca += $atendidas30;
|
|
|
|
|
$tcam += $atendidasM;
|
|
|
|
|
$tab += $abandonadas30;
|
|
|
|
|
$tabm += $abandonadasM;
|
|
|
|
|
$tco += 0;
|
|
|
|
|
$tcof += $recebidas;
|
|
|
|
|
|
|
|
|
|
$ins = $cr == 0 ? 0 : round((($atendidas30 / $cr) * 100.0), 2);
|
|
|
|
|
$iab = ($atendidas + $abandonadasM) == 0 ? 0 : round((($abandonadasM / ($atendidas + $abandonadasM)) * 100.0), 2);
|
|
|
|
|
$ico = $recebidas == 0 ? 0 : round((($co / $recebidas) * 100.0), 2);
|
|
|
|
|
//print "rec " . $recebidas . " desvio " . $desvio . " media " . $mediaCalc . " media x desvio " . ($mediaCalc + ($desvio * 2)) . "<br>" ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$mediaCalc = 0;
|
|
|
|
|
|
|
|
|
|
$desvio = round(GetDesvio(GetDadosDia($dbcon, $dac, $data, $periodo), $mediaCalc));
|
|
|
|
|
$mediaCalc = round($mediaCalc);
|
|
|
|
|
//print "rec " . $recebidas . " desvio " . $desvio . " media " . $mediaCalc . " media x desvio " . ($mediaCalc + ($desvio * 2)) . "<br>" ;
|
|
|
|
|
$tipico = "-";
|
|
|
|
|
if ($recebidas > 0) {
|
|
|
|
|
$diaTipico = 1;
|
|
|
|
|
if (($recebidas > ($mediaCalc + ($desvio * 2)))) {
|
|
|
|
|
$diaTipico = 0;
|
|
|
|
|
$tipico = "<span class=\"atipicoMaior\" title=\"Recebidas: $recebidas M<EFBFBD>dia: $mediaCalc Desvio: $desvio\"> AT<EFBFBD>PICO </SPAN> ";
|
|
|
|
|
} else if (($recebidas < ($mediaCalc - ($desvio * 2)))) {
|
|
|
|
|
$diaTipico = 0;
|
|
|
|
|
$tipico = "<span class=\"atipicoMenor\" title=\"Recebidas: $recebidas M<EFBFBD>dia: $mediaCalc Desvio: $desvio\"> AT<EFBFBD>PICO </SPAN> ";
|
|
|
|
|
} else {
|
|
|
|
|
$tipico = "<span class=\"tipico\" title=\"Recebidas: $recebidas M<EFBFBD>dia: $mediaCalc Desvio: $desvio\"> T<EFBFBD>PICO </SPAN> ";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($diaTipico) {
|
|
|
|
|
$mediaIns += ($cr * $ins);
|
|
|
|
|
$pesoIns += $cr;
|
|
|
|
|
}
|
|
|
|
|
if ($diaTipico) {
|
|
|
|
|
$mediaIab += ($cr * $iab);
|
|
|
|
|
$pesoIab += $cr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$linhaTmp = "<tr class=\"headColun\" align=\"center\">
|
|
|
|
|
<td>$dia</td>
|
|
|
|
|
<td>$tipico</td>
|
|
|
|
|
<td align=\"right\">$atendidas30 </td>
|
|
|
|
|
<td align=\"right\">$atendidasM </td>
|
|
|
|
|
<td align=\"right\">$abandonadas30 </td>
|
|
|
|
|
<td align=\"right\">$abandonadasM </td>
|
|
|
|
|
<td align=\"right\">0</td>
|
|
|
|
|
<td align=\"right\">$recebidas</td>
|
|
|
|
|
<td align=\"right\">$ins</td>
|
|
|
|
|
<td align=\"right\">$iab</td>
|
|
|
|
|
<td align=\"right\">$ico</td>
|
|
|
|
|
<td>$tma</td>
|
|
|
|
|
<td align=\"right\">$agt</td>
|
|
|
|
|
</tr>";
|
|
|
|
|
$dados[$i] = $linhaTmp;
|
|
|
|
|
$linhas .= $linhaTmp;
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$_SESSION["SSdadosRd"] = $dados;
|
|
|
|
|
$_SESSION["totalRegMd"] = $i;
|
|
|
|
|
$tins = $pesoIns == 0 ? 0 : round($mediaIns / $pesoIns, 2);
|
|
|
|
|
$tiab = $pesoIab == 0 ? 0 : round($mediaIab / $pesoIab, 2);
|
|
|
|
|
$tico = 0;
|
|
|
|
|
$linhaTotal = "<tr align=\"center\" bgcolor=\"#FFFFFF\">
|
|
|
|
|
<th align=\"right\">Total</th>
|
|
|
|
|
<th align=\"right\"> </th>
|
|
|
|
|
<th align=\"right\">$tca</th>
|
|
|
|
|
<th align=\"right\">$tcam</th>
|
|
|
|
|
<th align=\"right\">$tab</th>
|
|
|
|
|
<th align=\"right\">$tabm</th>
|
|
|
|
|
<th align=\"right\">$tco</th>
|
|
|
|
|
<th align=\"right\">$tcof</th>
|
|
|
|
|
<th align=\"center\">INS</th>
|
|
|
|
|
<th align=\"center\">IAB</th>
|
|
|
|
|
<th align=\"center\">ICO</th>
|
|
|
|
|
<th align=\"right\"> </th>
|
|
|
|
|
<th> </th>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr align=\"center\" bgcolor=\"#FFFFFF\">
|
|
|
|
|
<th colspan=\"8\" align=\"center\">M<EFBFBD>dia Poderada</th>
|
|
|
|
|
<th align=\"right\">$tins</th>
|
|
|
|
|
<th align=\"right\">$tiab</th>
|
|
|
|
|
<th align=\"right\">$tico</th>
|
|
|
|
|
<th align=\"right\"> </th>
|
|
|
|
|
<th> </th>
|
|
|
|
|
</tr>";
|
|
|
|
|
$_SESSION["linhaTotalMd"] = "<tr class=\"headColun\" align=\"center\" >
|
|
|
|
|
<td align=\"right\">Total</td>
|
|
|
|
|
<td align=\"right\"> </td>
|
|
|
|
|
<td align=\"right\">$tca</td>
|
|
|
|
|
<td align=\"right\">$tcam</td>
|
|
|
|
|
<td align=\"right\">$tab</td>
|
|
|
|
|
<td align=\"right\">$tabm</td>
|
|
|
|
|
<td align=\"right\">$tco</td>
|
|
|
|
|
<td align=\"right\">$tcof</td>
|
|
|
|
|
<td align=\"center\">INS</td>
|
|
|
|
|
<td align=\"center\">IAB</td>
|
|
|
|
|
<td align=\"center\">ICO</td>
|
|
|
|
|
<td align=\"right\"> </td>
|
|
|
|
|
<td> </td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class=\"headColun\" align=\"center\" >
|
|
|
|
|
<td colspan=\"8\" align=\"center\">M<EFBFBD>dia Ponderada</td>
|
|
|
|
|
<td align=\"right\">$tins</td>
|
|
|
|
|
<td align=\"right\">$tiab</td>
|
|
|
|
|
<td align=\"right\">$tico</td>
|
|
|
|
|
<td align=\"right\"> </td>
|
|
|
|
|
<td> </td>
|
|
|
|
|
</tr>";
|
|
|
|
|
|
|
|
|
|
if (IsPostBack()) {
|
|
|
|
|
$erro = "";
|
|
|
|
|
if (($msg == '') && pg_last_error($dbcon))
|
|
|
|
|
$erro = "Ocorreram erros durante a opera<EFBFBD><EFBFBD>o. Erro: " . pg_last_error($dbcon);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$smarty->assign('imp', $i);
|
|
|
|
|
$smarty->assign('ano', $ano);
|
|
|
|
|
$smarty->assign('dacs', $dacs);
|
|
|
|
|
$smarty->assign('data', $_SESSION["data"]);
|
|
|
|
|
$smarty->assign('linhas', $linhas);
|
|
|
|
|
$smarty->assign('linhaTotal', $linhaTotal);
|
|
|
|
|
$smarty->assign('erro', $erro);
|
|
|
|
|
|
|
|
|
|
GetTemplate($smarty, 'callcenter/relatorios/metas/relMetricaAneelDia.tpl');
|
|
|
|
|
|
|
|
|
|
function GetQuery($dac, $codMes) {
|
|
|
|
|
// listaDacs=6&listaAgente=1000&dataIni=&dataFim=&btConsulta=Consultar
|
|
|
|
|
$query = "SELECT coalesce(I.data,'$codMes') as data
|
|
|
|
|
,h.hora_ini
|
|
|
|
|
,case when(h.hora_fim = '23:59:59')then '00:00:00' else h.hora_fim end as hora_fim
|
|
|
|
|
,h.periodo
|
|
|
|
|
,COALESCE(I.OFERECIDAS,0) AS OFERECIDAS
|
|
|
|
|
,COALESCE(I.ATENDIDAS_URA,0) AS ATENDIDAS_URA
|
|
|
|
|
,COALESCE(I.ABANDONADAS,0) AS ABANDONADAS
|
|
|
|
|
,COALESCE(I.ABANDONADAS30,0) AS ABANDONADAS30
|
|
|
|
|
,COALESCE(I.ABANDONADAS31,0) AS ABANDONADAS31
|
|
|
|
|
,COALESCE(I.ATENDIDAS_PA,0) AS ATENDIDAS_PA
|
|
|
|
|
,COALESCE(I.ATENDIDAS_30,0) AS ATENDIDAS_30
|
|
|
|
|
,COALESCE(I.ATENDIDAS_31,0) AS ATENDIDAS_31
|
|
|
|
|
,COALESCE(I.TRANSFERIDAS,0) AS TRANSFERIDAS
|
|
|
|
|
,COALESCE(I.ESPERA,0) AS ESPERA
|
|
|
|
|
,COALESCE(round( CASE WHEN(I.ATENDIDAS_PA = 0)THEN 0 ELSE (I.TEMPO_ATENDIMENTO / I.ATENDIDAS_PA)END),0) * INTERVAL '1 SECOND' AS TMA
|
|
|
|
|
,0 AS OCUPADAS
|
|
|
|
|
,0 AS RECEBIDAS_PESSOALMENTE
|
|
|
|
|
,0 AS ATENDIMENTO_URA
|
|
|
|
|
,0 AS ICO
|
|
|
|
|
,COALESCE(I.TEMPO_ESPERA,0) AS TEMPO_ESPERA
|
|
|
|
|
,COALESCE(I.TEMPO_ATENDIMENTO,0) AS TEMPO_ATENDIMENTO
|
|
|
|
|
,COALESCE(I.TEMPO_ABANDONO,0) AS TEMPO_ABANDONO
|
|
|
|
|
,COALESCE(I.num_agente,0) AS num_agente
|
|
|
|
|
FROM pbx_hora_dia h
|
|
|
|
|
left outer join (
|
|
|
|
|
SELECT
|
|
|
|
|
calldate as data,
|
|
|
|
|
hora_ini
|
|
|
|
|
,hora_fim
|
|
|
|
|
,periodo
|
|
|
|
|
,SUM (CASE WHEN EVENTO = 'ENTERQUEUE' THEN 1 ELSE 0 END) AS OFERECIDAS
|
|
|
|
|
,SUM (CASE WHEN EVENTO = 'ENTERQUEUE' THEN 1 ELSE 0 END) AS ATENDIDAS_URA
|
|
|
|
|
,SUM (CASE WHEN((EVENTO = 'ABANDON'))THEN 1 ELSE 0 END) AS ABANDONADAS
|
|
|
|
|
,SUM (CASE WHEN((EVENTO = 'ABANDON') AND (param3::int <= 30) )THEN 1 ELSE 0 END) AS ABANDONADAS30
|
|
|
|
|
,SUM (CASE WHEN((EVENTO = 'ABANDON') AND (param3::int > 30) )THEN 1 ELSE 0 END) AS ABANDONADAS31
|
|
|
|
|
,SUM (CASE WHEN EVENTO IN ('COMPLETEAGENT','COMPLETECALLER') THEN 1 ELSE 0 END) AS ATENDIDAS_PA
|
|
|
|
|
,SUM (CASE WHEN EVENTO IN ('COMPLETEAGENT','COMPLETECALLER') AND to_number(param1,'999999999') <= '30' THEN 1 ELSE 0 END) AS ATENDIDAS_30
|
|
|
|
|
,SUM (CASE WHEN EVENTO IN ('COMPLETEAGENT','COMPLETECALLER') AND to_number(param1,'999999999') > '30' THEN 1 ELSE 0 END) AS ATENDIDAS_31
|
|
|
|
|
,SUM (CASE WHEN EVENTO IN ('TRANSFER') THEN 1 ELSE 0 END) AS TRANSFERIDAS
|
|
|
|
|
,SUM (CASE WHEN EVENTO IN ('CONNECT') AND to_number(param1,'999999999') > '3' THEN 1 ELSE 0 END) AS ESPERA
|
|
|
|
|
,SUM (CASE WHEN EVENTO IN ('CONNECT') AND to_number(param1,'999999999') > '1' THEN to_number(param1,'999999999') ELSE 0 END) AS TEMPO_ESPERA
|
|
|
|
|
,SUM (CASE WHEN EVENTO IN ('COMPLETEAGENT','COMPLETECALLER') AND to_number(param2,'999999999') > '1' THEN to_number(param2,'999999999') ELSE 0 END) AS TEMPO_ATENDIMENTO
|
|
|
|
|
,SUM (CASE WHEN( (EVENTO = 'ABANDON') ) THEN to_number(param3,'999999999') ELSE 0 END) AS TEMPO_ABANDONO
|
|
|
|
|
,count(distinct agente) as num_agente
|
|
|
|
|
FROM (
|
|
|
|
|
SELECT
|
|
|
|
|
c.hora_ini, c.hora_fim, c.periodo, a.calldate,b.fila,b.evento,b.param1,b.param2,b.param3,b.param4, case when(b.agente = 'NONE')THEN NULL ELSE b.agente END AS agente
|
|
|
|
|
FROM pbx_hora_dia c
|
|
|
|
|
INNER JOIN pbx_bilhetes a on cast(a.calldate as time) >= c.hora_ini and cast(a.calldate as time) < c.hora_fim and a.lastapp <> 'Transferred Call'
|
|
|
|
|
INNER JOIN pbx_eventos_dacs b on b.uid2 = a.uniqueid
|
|
|
|
|
INNER JOIN pbx_dacs d on d.nome = b.fila
|
|
|
|
|
WHERE b.evento in ('ABANDON','COMPLETEAGENT','COMPLETECALLER', 'CONNECT','ENTERQUEUE','TRANSFER')
|
|
|
|
|
AND a.data_bilhete = '$codMes'
|
|
|
|
|
AND d.id = '$dac'
|
|
|
|
|
) AS DADOS
|
|
|
|
|
GROUP BY calldate, hora_ini, hora_fim, periodo
|
|
|
|
|
) AS I on I.periodo = h.periodo ORDER BY 4";
|
|
|
|
|
//se adicionado bate os resultados com o relatorio enviado pelo
|
|
|
|
|
//pablo para conferencia
|
|
|
|
|
//AND date_part( 'dow', a.calldate) not in(0,6)
|
|
|
|
|
// if(IsAdmin()) print $query;
|
|
|
|
|
return $query;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
?>
|