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.
114 lines
3.7 KiB
114 lines
3.7 KiB
<?php |
|
|
|
$tpLayout = 1; |
|
$dataIni = $_GET["dataIni"]; |
|
$dataFim = $_GET["dataFim"]; |
|
$dacs = $_GET["dacs"]; |
|
$listas = $_GET["listas"]; |
|
$agente = $_GET["agente"]; |
|
$cmpId = $_GET["cmpId"]; |
|
$listId = $_GET["listId"]; |
|
$matricula = $_GET["matricula"]; |
|
$totalPausa = $_GET["totalPausa"]; |
|
$erro = ''; |
|
|
|
$_SESSION["dataIni"] = $dataIni; |
|
$_SESSION["dataFim"] = $dataFim; |
|
$_SESSION["dac"] = $dacs; |
|
|
|
|
|
$templateName = 'discador/desempenhoDiscadorOperacoes.tpl'; |
|
|
|
$linha = ""; |
|
$linhas = ""; |
|
$rows = array(); |
|
$query = GetQuery($cmpId, $matricula); |
|
$result = pg_query($dbcon, $query); |
|
$qtPausa = 0; |
|
$somaTempo = 0; |
|
$imp = 0; |
|
$buffDados = array(); |
|
$soma_tempo = array(); |
|
$soma_quant = array(); |
|
while ($dados = pg_fetch_array($result)) { |
|
$inicio = FormataDBDataHora(substr($dados["inicio_operacao"], 0, 19)); |
|
$fim = $dados["final_operacao"] ? FormataDBDataHora(substr($dados["final_operacao"], 0, 19)) : FormataDBDataHora(substr($dados["inicio_operacao"], 0, 19)); |
|
$motivo = $dados["operacao"]; |
|
$tempo = $dados["tempo_operacao"]; |
|
|
|
$soma_tempo[$motivo] += $tempo; |
|
$soma_quant[$motivo] += 1; |
|
|
|
$somaTempo += $tempo; |
|
$qtPausa++; |
|
$imp++; |
|
$displayTempo = SecondToStrTime($tempo); |
|
$linha = "<tr> |
|
<td align=\"center\">$inicio</td> |
|
<td align=\"center\">$fim</td> |
|
<td align=\"center\"> $motivo</td> |
|
<td align=\"center\">$displayTempo</td> |
|
</tr>"; |
|
$buffDados[] = $linha; |
|
$linhas .= $linha; |
|
} |
|
|
|
$displayTempo = SecondToStrTime($somaTempo); |
|
$linha = "<tr> |
|
<th align=\"center\">Quantidade</th> |
|
<td align=\"center\">$qtPausa</td> |
|
<th align=\"center\"> Tempo</th> |
|
<td align=\"center\">$displayTempo</td> |
|
</tr>"; |
|
$buffDados[] = $linha; |
|
$linhas .= $linha; |
|
|
|
$_SESSION["SSlinhasPausasDiscador"] = $buffDados; |
|
|
|
|
|
//agrupado |
|
$linhaAgrup = ""; |
|
foreach ($soma_tempo as $key => $value) { |
|
$motivo = $key; |
|
$tempo = $value; |
|
$qtAgrup = $soma_quant[$key]; |
|
$displayTempoAgrup = SecondToStrTime($tempo); |
|
$tmpMed = !$qtAgrup ? 0 : round($tempo / $qtAgrup); |
|
$displayTempoMed = SecondToStrTime($tmpMed); |
|
$linhaAgrup .= "<tr> |
|
<td align=\"center\"> $motivo</td> |
|
<td align=\"center\"> $qtAgrup</td> |
|
<td align=\"center\">$displayTempoAgrup</td> |
|
<td align=\"center\">$displayTempoMed</td> |
|
</tr>"; |
|
} |
|
|
|
$_SESSION["SSlinhasPausasDiscadorAgp"] = $linhaAgrup; |
|
|
|
//Atualiza template |
|
$smarty->assign("dacs", $dacs); |
|
$smarty->assign("agente", $agente); |
|
$smarty->assign("listas", $listas); |
|
$smarty->assign('dataIni', $dataIni); |
|
$smarty->assign('dataFim', $dataFim); |
|
$smarty->assign("linha", $linhas); |
|
$smarty->assign("linhaAgrupado", $linhaAgrup); |
|
$smarty->assign("imp", $imp); |
|
|
|
//Seta o template |
|
GetTemplate($smarty, $templateName); |
|
|
|
function GetQuery($cmpId, $matricula) { |
|
$idSessao = session_id(); |
|
$ret = "select a.matricula, a.inicio_operacao, a.final_oepracao, c.apelido, a.operacao, case when(operacao = 'atendimento')then tempo_operacao else extract(epoch from ((a.final_oepracao - a.inicio_operacao))) end as tempo_operacao |
|
from pbx_desempenho_discador a, pbx_usuarios c |
|
where c.matricula = a.matricula |
|
and id_dac = '$cmpId' |
|
and a.id_sessao = '$idSessao' |
|
and a.matricula = case when('$matricula' = '0')then a.matricula else '$matricula' end |
|
and a.operacao <> 'livre' |
|
order by 1, 2"; |
|
return $ret; |
|
} |
|
|
|
?>
|
|
|