PABX da Simples IP
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.
 
 
 
 
 
 

69 lines
3.0 KiB

<?php
$tpLayout = 1;
$matricula = $_GET["matricula"];
$nomeTpl = 'relAgtMotivoPausa.tpl';
$linha = ' <tr align="center">
<td nowrap align="center" class="headData">%s</td>
<td nowrap align="center" class="headData">%s</td>
<td nowrap align="center" class="headData">%s</td>
<td nowrap align="center" class="headData">%s</td>
<td nowrap align="center" class="headData">%s</td>
<td align="left" class="headData">%s</td>
</tr>';
$query = "select a.entrada_pausa, a.saida_pausa, (coalesce(a.saida_pausa, now()) - a.entrada_pausa) as duracao, b.id, b.motivo,
extract(EPOCH FROM (a.saida_pausa - a.entrada_pausa)) as dura_segundos,
case when(
(a.id = (select max(id)
from pbx_eventos_agentes
where entrada_pausa::date = a.entrada_pausa::date
and matricula = a.matricula
and id_dac = a.id_dac
)) and ((select count(*) from pbx_supervisor_agentes where matricula = '$matricula' and status = 'PAUSA') > 0)
)then 1 else 0 end as em_pausa,
a.pausa_produtiva, a.pausa_produtiva_obs
from pbx_eventos_agentes a, pbx_motivos_pausas b
where b.id = a.id_motivo_pausa
and entrada_pausa::date = now()::date
and matricula = '$matricula' ";
//if(IsAdmin()) echo $query;
$result = pg_query($dbcon, $query);
$numrow = 0;
$linhas = "";
$duracaoTotal = 0;
$duraProd = 0;
$duraNormal = 0;
$numProd = 0;
$numNormal = 0;
while ($row = pg_fetch_array($result)) {
$linhas .= sprintf($linha, $row["entrada_pausa"], $row["saida_pausa"], $row["duracao"], ($row["em_pausa"] ? ('*' . $row["motivo"]) : $row["motivo"]), $row["pausa_produtiva"] ? 'Sim' : 'N<EFBFBD>o', $row["pausa_produtiva_obs"]);
$duracaoTotal += $row["dura_segundos"];
if ($row["pausa_produtiva"]) {
$duraProd += $row["dura_segundos"];
$numProd++;
} else {
$duraNormal += $row["dura_segundos"];
$numNormal++;
}
$numrow++;
}
$duracaoTotal = SecondToStrTime($duracaoTotal);
$duraProd = SecondToStrTime($duraProd);
$duraNormal = SecondToStrTime($duraNormal);
$linha = " <tr align=\"center\">
<th nowrap align=\"center\">Totaliza<EFBFBD><EFBFBD>o</th>
<th nowrap colspan=\"5\" align=\"center\">[ Produtiva: $duraProd ($numProd) ] [ N<EFBFBD>o Produtiva: $duraNormal ($numNormal) ] [ Total: $duracaoTotal ($numrow) ]</th>
</tr>
<tr align=\"center\">
<td nowrap align=\"left\" colspan=\"7\" >*Em pausa neste momento</td>
</tr>";
$linhas .= $linha;
$smarty->assign('linhas', $linhas);
GetTemplate($smarty, $nomeTpl);
?>