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.
643 lines
26 KiB
643 lines
26 KiB
<?php |
|
|
|
include_once 'util/relatoriosBase.php'; |
|
|
|
class RelPausasDetalhado extends Relatorios { |
|
|
|
private $___agente; |
|
|
|
public function __construct($idProg, $dbcon, $incDac) { |
|
parent::__construct($idProg, $dbcon, $incDac); |
|
$this->___dac = isset($_POST['listaDacs']) ? $_POST['listaDacs'] : 0; |
|
$this->___agente = isset($_POST["listaAgente"]) ? $_POST["listaAgente"] : 0; |
|
} |
|
|
|
function ___ValidaForm() { |
|
parent::___ValidaForm(); |
|
if (!IsPostBack()) { |
|
return; |
|
} |
|
if ($this->GetIncDac() && !StrToIntDef($this->___dac)) { |
|
GeraExcept('Informe uma Fila!'); |
|
} |
|
} |
|
|
|
function ___FiltrosRelatorio() { |
|
if ($this->___media != MEDIA_PRINT_GRID) { |
|
/* |
|
* Recupera os filtros da sesssão do usuário. |
|
*/ |
|
list($this->___dac, $this->___dataIni, $this->___dataFim) = $_SESSION["SSstorageFiltros"]; |
|
|
|
if ($this->___media == MEDIA_PRINT_HTML) { |
|
$fila = $this->GetIncDac() ? 'Fila: ' . GetDacDesc($this->GetDbCon(), $this->GetIdProg() . ' ') : ''; |
|
return sprintf("%sData Inicial: %s Data Final: %s ", $fila, $this->___dataIni, $this->___dataFim); |
|
} |
|
|
|
$tipoRel = !$this->___tipoRelatorio ? '' : 'checked="checked"'; |
|
|
|
$fltCsv = array(); |
|
if ($this->GetIncDac()) { |
|
$fltCsv[] = 'Fila:' . GetDacDesc($this->GetDbCon(), $this->___dac); |
|
} |
|
$fltCsv[] = "Data Inicial:" . $this->___dataIni; |
|
$fltCsv[] = "Data Final:" . $this->___dataFim; |
|
$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); |
|
} |
|
|
|
if ($this->___dataIni && $this->___dataFim) { |
|
$agentes = $this->retornaAgente(); |
|
} |
|
|
|
$lkPrint = ""; |
|
if ($this->___dataCount) { |
|
$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'); |
|
} |
|
|
|
/* |
|
* Personalise esta função se necessitar de outras opções de filtro. |
|
*/ |
|
$filtro = '<table border="0" cellspacing="1" cellpadding="1">'; |
|
/* |
|
* Rotulos. |
|
*/ |
|
$filtro .= '<tr>'; |
|
if ($this->GetIncDac()) |
|
$filtro .= '<td>Fila</td>'; |
|
$filtro .= '<td>Data Inicial</td>'; |
|
$filtro .= '<td>Data Final </td>'; |
|
$filtro .= '<td>Agente </td>'; |
|
$filtro .= '<td align="center" valign="middle"> </td>'; |
|
$filtro .= '</tr>'; |
|
|
|
/* |
|
* Valores. |
|
*/ |
|
$filtro .= '<tr>'; |
|
if ($this->GetIncDac()) |
|
$filtro .= sprintf('<td>%s</td>', $dacs); |
|
$filtro .= sprintf('<td><input name="dataIni" id="dataIni" type="text" size="15" maxlength="10" value="%s" onkeyup="formataData(this)" title="dd/mm/aaaa"></td>', $this->___dataIni); |
|
$filtro .= sprintf('<td><input name="dataFim" id="dataFim" type="text" size="15" maxlength="10" value="%s" onkeyup="formataData(this)" title="dd/mm/aaaa"></td>', $this->___dataFim); |
|
$filtro .= "<td>$agentes</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ão dos relatórios para impressão. |
|
*/ |
|
$_SESSION["SSstorageFiltros"] = array($this->___dac, $this->___dataIni, $this->___dataFim); |
|
|
|
return sprintf($filtro, $lkPrint); |
|
} |
|
|
|
protected function ___GetDadosDb() { |
|
$dataIni = FormatDtMssql($this->___dataIni); |
|
$dataFim = FormatDtMssql($this->___dataFim); |
|
$dac = $this->___dac; |
|
$agente = $this->___agente ? $this->___agente : 0; |
|
|
|
$query = "SELECT a.id_dac, c.nome AS nome_dac, a.matricula, d.apelido, a.ramal, a.entrada_pausa, a.saida_pausa, b.id AS id_motivo, b.motivo, |
|
EXTRACT(EPOCH FROM (a.saida_pausa - a.entrada_pausa)) AS dura_segundos, b.produtiva AS pausa_produtiva, a.pausa_produtiva_obs |
|
FROM pbx_eventos_agentes a, pbx_motivos_pausas b, pbx_dacs c, pbx_usuarios d |
|
WHERE b.id = a.id_motivo_pausa |
|
AND c.id = a.id_dac |
|
AND d.matricula = a.matricula |
|
AND a.saida_pausa IS NOT NULL |
|
AND entrada_pausa::DATE >= '%s' |
|
AND entrada_pausa::DATE <= '%s' |
|
AND a.id_dac = %s"; |
|
if($agente){ |
|
$query .= "AND apelido = '$agente'"; |
|
} |
|
$query .= " ORDER BY 4,6"; |
|
$query = sprintf($query, $dataIni, $dataFim, $dac); |
|
|
|
$subQuery = "SELECT a.id_dac, c.nome AS nome_dac, a.matricula, d.apelido, b.id AS id_motivo, b.motivo,b.produtiva AS pausa_produtiva, |
|
COUNT(*) AS num_pausas, |
|
SUM(EXTRACT(EPOCH FROM (a.saida_pausa - a.entrada_pausa))) AS dura_segundos |
|
FROM pbx_eventos_agentes a, pbx_motivos_pausas b, pbx_dacs c, pbx_usuarios d |
|
WHERE b.id = a.id_motivo_pausa |
|
AND c.id = a.id_dac |
|
AND d.matricula = a.matricula |
|
AND a.saida_pausa IS NOT NULL |
|
AND entrada_pausa::DATE >= '%s' |
|
AND entrada_pausa::DATE <= '%s' |
|
AND a.id_dac = %s"; |
|
if($agente){ |
|
$subQuery .= "AND apelido = '$agente'"; |
|
} |
|
$subQuery .= "GROUP BY a.id_dac, c.nome, a.matricula, d.apelido, b.id, b.motivo, b.produtiva "; |
|
$subQuery .= "ORDER BY d.apelido, b.motivo"; |
|
$subQuery = sprintf($subQuery, $dataIni, $dataFim, $dac); |
|
|
|
$result = $this->___GetQuery($query); |
|
$row = pg_fetch_all($result); |
|
$this->SetData($row ? $row : array()); |
|
|
|
$subResult = $this->___GetQuery($subQuery); |
|
$subRow = pg_fetch_all($subResult); |
|
$this->SetData($subRow ? $subRow : array()); |
|
|
|
$this->SetData($this->___agente ? $this->___agente : 0); |
|
} |
|
|
|
protected function ___PreparaCsv() { |
|
$dataRel = array(); |
|
$filtro = $this->___FiltrosRelatorio(); |
|
|
|
/* |
|
* Inicia o relatório. |
|
*/ |
|
$dataRel[] = GenerateCsvFromArray($filtro); |
|
|
|
$dadosCabecalio = array( |
|
'DAC', |
|
'Agente', |
|
'Ramal' , |
|
'Inicio', |
|
'Fim', |
|
'Duracao', |
|
'Motivo', |
|
'Produtiva', |
|
'OBS' |
|
); |
|
$dadosField = array( |
|
'nome_dac', |
|
'apelido', |
|
'ramal', |
|
'entrada_pausa', |
|
'saida_pausa', |
|
'dura_segundos', |
|
'motivo', |
|
'pausa_produtiva', |
|
'pausa_produtiva_obs' |
|
); |
|
|
|
/* |
|
* Monta a linha de cabecalio. |
|
*/ |
|
$dataRel[] = GenerateCsvFromArray($dadosCabecalio); |
|
|
|
$somaReg = 0; |
|
$somaTempo = 0; |
|
|
|
/* |
|
* Linhas de dados. |
|
*/ |
|
foreach ($this->GetData()[0] as $row) { |
|
$somaReg ++; |
|
$somaTempo += $row["dura_segundos"]; |
|
$row["entrada_pausa"] = date('d/m/Y H:i:s',strtotime($row["entrada_pausa"])); |
|
$row["saida_pausa"] = date('d/m/Y H:i:s',strtotime($row["saida_pausa"])); |
|
$row["dura_segundos"] = SecondToStrTime($row['dura_segundos']); |
|
$row["pausa_produtiva"] = $row['pausa_produtiva'] ? 'Sim' : 'Nao'; |
|
$row["motivo"] = RemoveAcentos($row['motivo']); |
|
$row["pausa_produtiva_obs"] = $row['pausa_produtiva_obs'] ? $row['pausa_produtiva_obs'] : ' - '; |
|
// Formata linha de dados. |
|
$linha = array(); |
|
foreach ($dadosField as $value) { |
|
$linha[] = $row["$value"]; |
|
} |
|
|
|
$dataRel[] = GenerateCsvFromArray($linha); |
|
} |
|
$dataRel[] = GenerateCsvFromArray(array('','','','','','Duracao Total: ' . SecondToStrTime($somaTempo), '','', 'Quantidade: ' . $somaReg)); |
|
$dataRel[] = GenerateCsvFromArray(array('','','','','')); |
|
|
|
$dadosCabecalioTotal = array( |
|
'DAC', |
|
'Agente', |
|
'Duracao', |
|
'Motivo', |
|
'Produtiva' |
|
); |
|
$dadosFieldTotal = array( |
|
'nome_dac', |
|
'apelido', |
|
'dura_segundos', |
|
'motivo', |
|
'pausa_produtiva' |
|
); |
|
|
|
/* |
|
* Monta a linha de cabecalio. |
|
*/ |
|
$dataRel[] = GenerateCsvFromArray($dadosCabecalioTotal); |
|
|
|
/* |
|
* Linhas de dados. |
|
*/ |
|
foreach ($this->GetData()[1] as $row) { |
|
|
|
$row["dura_segundos"] = SecondToStrTime($row['dura_segundos']); |
|
$row["pausa_produtiva"] = $row['pausa_produtiva'] ? 'Sim' : 'Nao'; |
|
$row["motivo"] = RemoveAcentos($row['motivo']); |
|
|
|
// Formata linha de dados. |
|
$linha = array(); |
|
foreach ($dadosFieldTotal as $value) { |
|
$linha[] = $row["$value"]; |
|
} |
|
|
|
$dataRel[] = GenerateCsvFromArray($linha); |
|
} |
|
$dataRel[] = GenerateCsvFromArray(array('','Duracao Total: ',SecondToStrTime($somaTempo),'','')); |
|
$this->___dataRel[] = $dataRel; |
|
} |
|
|
|
protected function ___PreparaExcel() { |
|
$dataRel = array(); |
|
$filtro = $this->___FiltrosRelatorio(); |
|
|
|
/* |
|
* Inicia o relató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( |
|
'DAC', |
|
'Agente', |
|
'Ramal' , |
|
'Inicio', |
|
'Fim', |
|
'Duracao', |
|
'Motivo', |
|
'Produtiva', |
|
'OBS' |
|
); |
|
$dadosField = array( |
|
'nome_dac', |
|
'apelido', |
|
'ramal', |
|
'entrada_pausa', |
|
'saida_pausa', |
|
'dura_segundos', |
|
'motivo', |
|
'pausa_produtiva', |
|
'pausa_produtiva_obs' |
|
); |
|
|
|
/* |
|
* Monta a linha de cabecalio. |
|
*/ |
|
$linha = array('LABEL'); |
|
foreach ($dadosCabecalio as $value) { |
|
$linha[] = $value; |
|
} |
|
$dataRel[] = $linha; |
|
|
|
$somaReg = 0; |
|
$somaTempo = 0; |
|
/* |
|
* Linhas de dados. |
|
*/ |
|
foreach ($this->GetData()[0] as $row) { |
|
$somaReg ++; |
|
$somaTempo += $row["dura_segundos"]; |
|
$row["entrada_pausa"] = date('d/m/Y H:i:s',strtotime($row["entrada_pausa"])); |
|
$row["saida_pausa"] = date('d/m/Y H:i:s',strtotime($row["saida_pausa"])); |
|
$row["dura_segundos"] = SecondToStrTime($row['dura_segundos']); |
|
$row["pausa_produtiva"] = $row['pausa_produtiva'] ? 'Sim' : 'Nao'; |
|
$row["motivo"] = RemoveAcentos($row['motivo']); |
|
$row["pausa_produtiva_obs"] = $row['pausa_produtiva_obs'] ? $row['pausa_produtiva_obs'] : ' - '; |
|
|
|
// Formata linha de dados. |
|
$linha = array('DADOS'); |
|
foreach ($dadosField as $key) { |
|
$linha[] = $row["$key"]; |
|
} |
|
|
|
$dataRel[] = $linha; |
|
} |
|
|
|
$dataRel[] = array('LABEL', '','','','','','Duracao Total: ' . SecondToStrTime($somaTempo), '','', 'Quantidade: ' . $somaReg); |
|
$dataRel[] = array('LABEL', '','','','',''); |
|
|
|
$dadosCabecalioTotal = array('DAC','Agente','Duracao','Motivo','Produtiva'); |
|
$dadosFieldTotal = array('nome_dac','apelido','dura_segundos','motivo','pausa_produtiva'); |
|
|
|
$linha = array('LABEL'); |
|
foreach ($dadosCabecalioTotal as $value) {$linha[] = $value;} |
|
$dataRel[] = $linha; |
|
|
|
foreach ($this->GetData()[1] as $rowTotal) { |
|
|
|
$rowTotal["dura_segundos"] = SecondToStrTime($rowTotal['dura_segundos']); |
|
$rowTotal["pausa_produtiva"] = $rowTotal['pausa_produtiva'] ? 'Sim' : 'Nao'; |
|
$rowTotal["motivo"] = RemoveAcentos($rowTotal['motivo']); |
|
|
|
// Formata linha de dados. |
|
$linha = array('DADOS'); |
|
foreach ($dadosFieldTotal as $key) { |
|
$linha[] = $rowTotal["$key"]; |
|
} |
|
|
|
$dataRel[] = $linha; |
|
} |
|
$dataRel[] = array('LABEL', '','','','Duracao Total: ',SecondToStrTime($somaTempo)); |
|
$this->___dataRel[] = $dataRel; |
|
} |
|
|
|
protected function ___PreparaGrid() { |
|
$dataRel = array(); |
|
|
|
$dadosCabecalio = array( |
|
'DAC' => 'align="center"', |
|
'Agente' => 'align="left"', |
|
'Ramal' => 'align="center"', |
|
'Início' => 'align="center"', |
|
'Fim' => 'align="center"', |
|
'Duração' => 'align="center"', |
|
'Motivo' => 'align="left"', |
|
'Produtiva' => 'align="center"', |
|
'OBS' => 'align="center"' |
|
); |
|
$dadosField = array( |
|
'nome_dac' => 'align="center"', |
|
'apelido' => 'align="left"', |
|
'ramal' => 'align="center"', |
|
'entrada_pausa' => 'align="center"', |
|
'saida_pausa' => 'align="center"', |
|
'dura_segundos' => 'align="center"', |
|
'motivo' => 'align="left"', |
|
'pausa_produtiva' => 'align="center"', |
|
'pausa_produtiva_obs' => 'align="center"' |
|
); |
|
/* |
|
* Inicia o relatório. |
|
*/ |
|
$dataRel[] = '<table width="95%" 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; |
|
} |
|
|
|
$somaTempo = 0; |
|
$somaQuantidade = 0; |
|
/* |
|
* Linhas de dados. |
|
*/ |
|
foreach ($this->GetData()[0] as $row) { |
|
$somaQuantidade ++; |
|
$somaTempo += $row["dura_segundos"]; |
|
$row["entrada_pausa"] = date('d/m/Y H:i:s',strtotime($row["entrada_pausa"])); |
|
$row["saida_pausa"] = date('d/m/Y H:i:s',strtotime($row["saida_pausa"])); |
|
$row["dura_segundos"] = SecondToStrTime($row['dura_segundos']); |
|
$row["pausa_produtiva"] = $row['pausa_produtiva'] ? 'Sim' : 'Não'; |
|
$row["pausa_produtiva_obs"] = $row['pausa_produtiva_obs'] ? $row['pausa_produtiva_obs'] : ' - '; |
|
|
|
// Formata linha de dados. |
|
$linha = "<tr>"; |
|
foreach ($dadosField as $key => $value) { |
|
$linha .= sprintf("<td %s>%s</td>", $value, $row["$key"]); |
|
} |
|
$linha .= "</tr>"; |
|
$dataRel[] = $linha; |
|
} |
|
/* |
|
* Linha de totalizacao. |
|
*/ |
|
$linha = '<tr><th colspan="6" align="right">Duração Total: %s</th><th colspan="3" align="right">Quantidade: %s</th></tr>'; |
|
$dataRel[] = sprintf($linha, SecondToStrTime($somaTempo), $somaQuantidade); |
|
|
|
/* |
|
* Fecha relatorio. |
|
*/ |
|
$dataRel[] = '</table>'; |
|
$this->___dataRel[] = $dataRel; |
|
$dataRel = array(); |
|
|
|
/* |
|
* Agrupamento |
|
*/ |
|
unset($somaTempo); |
|
$linha = '<table width="50%" cellpadding="2" class="grid">'; |
|
$linha .= "<tr><th>DAC</th><th>Agente</th><th>Motivo</th><th>Duração</th><th>Produtiva</th></tr>"; |
|
|
|
foreach ($this->GetData()[1] as $row) { |
|
$somaTempo += $row['dura_segundos']; |
|
$linha .= "<tr>"; |
|
$linha .= sprintf("<td>%s</td>",$row['nome_dac']); |
|
$linha .= sprintf("<td>%s</td>",$row['apelido']); |
|
$linha .= sprintf("<td>%s</td>",$row['motivo']); |
|
$linha .= sprintf("<td>%s</td>", SecondToStrTime($row['dura_segundos'])); |
|
$linha .= sprintf("<td>%s</td>",$row['pausa_produtiva'] ? 'Sim' : 'Não'); |
|
$linha .= "</tr>"; |
|
} |
|
$linha .= sprintf("<tr><th colspan=\"4\">Duração Total: %s</th><th></th></tr>", SecondToStrTime($somaTempo)); |
|
$linha .= "</table>"; |
|
$dataRel[] = $linha; |
|
|
|
$this->___dataRel[] = $dataRel; |
|
} |
|
|
|
protected function ___PreparaHtml() { |
|
|
|
} |
|
|
|
protected function ___PreparaPdf() { |
|
list($this->___dac, $this->___dataIni, $this->___dataFim) = $_SESSION["SSstorageFiltros"]; |
|
/** |
|
* TABELA DADOS PRINCIPAIS |
|
*/ |
|
//HEADER DA TABELA DO PDF -> DADOS EM ARRAY |
|
$header = array( |
|
'DAC' => 'C', |
|
'Agente' => 'C', |
|
'Ramal' => 'C', |
|
'Início' => 'C', |
|
'Fim' => 'C', |
|
'Duração' => 'C', |
|
'Motivo' => 'C', |
|
'Produtiva' => 'C', |
|
'OBS' => 'C' |
|
); |
|
$dataHeader = array( |
|
'nome_dac' => 'C', |
|
'apelido' => 'C', |
|
'ramal' => 'C', |
|
'entrada_pausa' => 'C', |
|
'saida_pausa' => 'C', |
|
'dura_segundos' => 'C', |
|
'motivo' => 'C', |
|
'pausa_produtiva' => 'C', |
|
'pausa_produtiva_obs' => 'C' |
|
); |
|
|
|
$somaReg = 0; |
|
$somaTempo = 0; |
|
$dados = array(); |
|
$x = 0; |
|
|
|
foreach ($this->GetData()[0] as $row) { |
|
|
|
$somaReg ++; |
|
$somaTempo += $row["dura_segundos"]; |
|
$dados[$x]["entrada_pausa"] = date('d/m/Y H:i:s',strtotime($row["entrada_pausa"])); |
|
$dados[$x]["saida_pausa"] = date('d/m/Y H:i:s',strtotime($row["saida_pausa"])); |
|
$dados[$x]["dura_segundos"] = SecondToStrTime($row['dura_segundos']); |
|
$dados[$x]["pausa_produtiva"] = $row['pausa_produtiva'] ? 'Sim' : 'Não'; |
|
$dados[$x]["pausa_produtiva_obs"] = $row['pausa_produtiva_obs'] ? $row['pausa_produtiva_obs'] : ' - '; |
|
$dados[$x]["nome_dac"] = $row['nome_dac']; |
|
$dados[$x]["apelido"] = $row['apelido']; |
|
$dados[$x]["ramal"] = $row['ramal']; |
|
$dados[$x]["motivo"] = $row['motivo']; |
|
$x++; |
|
} |
|
|
|
$widthHeader = array(20, 15, 15, 27, 27, 20, 20, 20, 30); |
|
$totalizador = array('', '', '','','Duração Total: ' , SecondToStrTime($somaTempo),'','','Quantidade: ' . $somaReg); |
|
//Monta o array para passar para o prepara; Necessário passar 6 parametros |
|
$table = array($header, $dataHeader, $dados, $widthHeader, $totalizador, 0); |
|
|
|
$headerTotal = array( |
|
'DAC' => 'C', |
|
'Agente' => 'C', |
|
'Duração' => 'C', |
|
'Motivo' => 'C', |
|
'Produtiva' => 'C' |
|
); |
|
$dataHeaderTotal = array( |
|
'nome_dac' => 'C', |
|
'apelido' => 'C', |
|
'dura_segundos' => 'C', |
|
'motivo' => 'C', |
|
'pausa_produtiva' => 'C' |
|
); |
|
|
|
$dadosTotal = array(); |
|
foreach ($this->GetData()[1] as $row) { |
|
$dadosTotal[$x]["dura_segundos"] = SecondToStrTime($row['dura_segundos']); |
|
$dadosTotal[$x]["pausa_produtiva"] = $row['pausa_produtiva'] ? 'Sim' : 'Não'; |
|
$dadosTotal[$x]["nome_dac"] = $row['nome_dac']; |
|
$dadosTotal[$x]["apelido"] = $row['apelido']; |
|
$dadosTotal[$x]["motivo"] = $row['motivo']; |
|
$x++; |
|
} |
|
|
|
$widthTotal = array(40, 25, 25, 25, 25); |
|
$total = array('', 'Duração Total: ', SecondToStrTime($somaTempo),'',''); |
|
$table1 = array($headerTotal, $dataHeaderTotal, $dadosTotal, $widthTotal, $total, 0); |
|
|
|
$this->___dataRel = array($table,$table1); |
|
} |
|
|
|
protected function retornaAgente() { |
|
global $dbcon; |
|
|
|
$codSel = $this->GetData()[2] ? $this->GetData()[2] : ''; |
|
$agentes = "<select name=\"listaAgente\" id=\"listaAgente\" size=\"1\">"; |
|
$agentes .= "<option value=\"0\" $sel>Todos</option>"; |
|
|
|
$query = sprintf("SELECT apelido AS nome |
|
FROM pbx_usuarios u |
|
WHERE EXISTS(SELECT '' FROM pbx_eventos_agentes WHERE id_dac = %s |
|
AND matricula = u.matricula |
|
AND CAST(login as date) >= '%s' |
|
AND CAST(login as date) <= '%s') |
|
", $this->___dac, FormatDtMssql($this->___dataIni), FormatDtMssql($this->___dataFim)); |
|
|
|
$result = pg_query($dbcon, $query); |
|
|
|
if(!$result) { |
|
return '<select name=\"listaAgente\"><option value=\"0\"> ----- </option></select>'; |
|
} |
|
|
|
while ($dados = pg_fetch_row($result)) { |
|
if ($codSel == $dados[0]) { |
|
$sel = "selected"; |
|
$i = 1; |
|
} else { |
|
$sel = ""; |
|
} |
|
$agentes .= "<option value=\"$dados[0]\" $sel>$dados[0]</option>"; |
|
} |
|
$agentes .= "</select>"; |
|
return $agentes; |
|
} |
|
|
|
public function ExecutaRelatorio() { |
|
global $jsStartup, $jsJQuery, $smarty; |
|
try { |
|
/* |
|
* Use esta função para validar dados do formul�rio. |
|
*/ |
|
$this->___ValidaForm(); |
|
|
|
/* |
|
* Recupera os dados do banco. |
|
*/ |
|
$this->___ConteudoRelatorio(); |
|
|
|
/* |
|
* Imprime relató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á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'); |
|
} |
|
|
|
} |
|
|
|
$relPausasDtl = new RelPausasDetalhado($idProg, $dbcon, 1); |
|
$relPausasDtl->ExecutaRelatorio(); |
|
?>
|
|
|