From aa878bd83dfaf12d6a1cfc5fd5a4fe418b302084 Mon Sep 17 00:00:00 2001 From: "douglas.strappasson" Date: Fri, 10 Nov 2023 06:50:20 -0400 Subject: [PATCH] =?UTF-8?q?Corre=C3=A7=C3=B5es=20nos=20relat=C3=B3rios=20C?= =?UTF-8?q?hamadas=20Saintes=20Geral=20e=20Chamadas=20Saintes/Ramal=20(#14?= =?UTF-8?q?6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: http://192.168.115.233:3000/SimplesIP/pabx-app/pulls/146 Co-authored-by: douglas.strappasson Co-committed-by: douglas.strappasson --- .../pbx/chamadasSaintes/saintesGeral.php | 65 ++++++++++++++----- .../pbx/chamadasSaintes/saintesRamal.php | 8 +-- 2 files changed, 54 insertions(+), 19 deletions(-) diff --git a/relatorios/pbx/chamadasSaintes/saintesGeral.php b/relatorios/pbx/chamadasSaintes/saintesGeral.php index ea98a7ef..9e915114 100644 --- a/relatorios/pbx/chamadasSaintes/saintesGeral.php +++ b/relatorios/pbx/chamadasSaintes/saintesGeral.php @@ -130,19 +130,45 @@ $tipoAtendimento = $this->___tipoAtendimento; $fonePesquisa = $this->___tipoRecepcao; - $query = sprintf("select a.uniqueid, a.calldate, a.src, a.dst, case when(d.evento = 'ABANDON')then strtoint(d.param3) else a.billsec end as tempo_atendimento, coalesce(d.fila, '-') as fila, coalesce(e.apelido, '-') as agente, - d.evento, case when(tplg_codigo in(33,34))then 'MÓVEL' else c.nome_municipio end as nome_municipio, c.uf, b.tplg_descricao, - case when((d.evento in('COMPLETAAGENT','COMPLETACALLER') and (billsec > 3) ) or ((d.evento is null) and (billsec > 3)))then 'ATENDIDA' else 'N ATENDIDA' end as status - from pbx_bilhetes a - inner join pbx_tipo_ligacao b on b.tplg_codigo = a.tipo_chamada - inner join pbx_municipios c on c.id = a.id_municipio - left join pbx_eventos_dacs d on d.uid2 = a.uniqueid and d.evento in('COMPLETAAGENT','COMPLETACALLER','ABANDON') - left join pbx_usuarios e on e.matricula = substring(d.agente,7,4) - where b.tplg_tipo = 3 - AND a.calldate = (SELECT MAX(calldate) FROM pbx_bilhetes WHERE uniqueid = a.uniqueid) - and a.calldate::timestamp >= '%s' - and a.calldate::timestamp <= '%s' - and a.lastapp <> 'Transferred Call'", $dataIni, $dataFim); + $query = sprintf( + "SELECT + a.uniqueid, + a.calldate, + a.src, + a.dst, + CASE + WHEN (d.evento = 'ABANDON') THEN STRTOINT(d.param3) + ELSE a.billsec + END AS tempo_atendimento, + COALESCE(d.fila, '-') AS fila, + COALESCE(e.apelido, '-') AS agente, + d.evento, + CASE + WHEN (tplg_codigo IN (33, 34)) THEN 'MÓVEL' + ELSE c.nome_municipio + END AS nome_municipio, + c.uf, + b.tplg_descricao, + CASE + WHEN ((d.evento IN ('COMPLETAAGENT', 'COMPLETACALLER') AND (billsec > 3)) + OR ((d.evento IS NULL) AND (billsec > 3))) THEN 'ATENDIDA' + ELSE 'N ATENDIDA' + END AS status + FROM pbx_bilhetes a + INNER JOIN pbx_tipo_ligacao b ON b.tplg_codigo = a.tipo_chamada + LEFT JOIN pbx_municipios c ON c.id = a.id_municipio + LEFT JOIN pbx_eventos_dacs d ON d.uid2 = a.uniqueid + AND d.evento IN ('COMPLETAAGENT', 'COMPLETACALLER', 'ABANDON') + LEFT JOIN pbx_usuarios e ON e.matricula = SUBSTRING(d.agente, 7, 4) + WHERE + b.tplg_tipo = 3 + AND a.calldate = (SELECT MAX(calldate) FROM pbx_bilhetes WHERE uniqueid = a.uniqueid) + AND a.calldate::TIMESTAMP >= '%s' + AND a.calldate::TIMESTAMP <= '%s' + AND a.lastapp <> 'Transferred Call'", + $dataIni, + $dataFim + ); if (!empty($telefone) && ($fonePesquisa == 1)) $query .= sprintf(" AND a.src LIKE '%s' ", PreparaLike($telefone)); @@ -221,6 +247,8 @@ $somaTempo += $row["tempo_atendimento"]; $row["tempo_atendimento"] = SecondToStrTime($row["tempo_atendimento"]); $row["nome_municipio"] = $row['nome_municipio'] == "CHAMADAS NAO IDENTIFICADAS" ? 'NI' : RemoveAcentos($row['nome_municipio']); + $row["nome_municipio"] = $row['nome_municipio'] ?? 'NI'; + $row["uf"] = $row['uf'] ?? 'NI'; $somaQuantidade ++; $linha = array(); @@ -289,6 +317,8 @@ $somaTempo += $row["tempo_atendimento"]; $row["tempo_atendimento"] = SecondToStrTime($row["tempo_atendimento"]); $row["nome_municipio"] = $row['nome_municipio'] == "CHAMADAS NAO IDENTIFICADAS" ? 'NI' : RemoveAcentos($row['nome_municipio']); + $row["nome_municipio"] = $row['nome_municipio'] ?? 'NI'; + $row["uf"] = $row['uf'] ?? 'NI'; $somaQuantidade ++; // Formata linha de dados. @@ -368,6 +398,8 @@ $row["status"] = $row["status"] == 'ATENDIDA' ? 'S' : 'N'; $somaTempo += $row["tempo_atendimento"]; $row["tempo_atendimento"] = SecondToStrTime($row["tempo_atendimento"]); + $row["nome_municipio"] = $row['nome_municipio'] ?? 'NI'; + $row["uf"] = $row['uf'] ?? 'NI'; $somaQuantidade ++; // Formata linha de dados. @@ -390,7 +422,8 @@ $dataRel[] = ''; $dataRel[] = ''; - $dataRel[] = ''; + $dataRel[] = '
'; + $dataRel[] = ''; $dataRel[] = '
* CHAMADAS ABANDONADAS OU NÃO ATENDIDAS, NO CAMPO DESTINO SERÁ APRESENTADO O NÚMERO DA FILA!
* CHAMADAS ABANDONADAS OU NÃO ATENDIDAS, NO CAMPO DESTINO SERÁ APRESENTADO O NÚMERO DA FILA!
* NI: NÃO IDENTIFICADO
'; $this->___dataRel[] = $dataRel; } @@ -405,6 +438,7 @@ $dados = array(); $x = 0; $somaQtd = 0; + $somaTempo = 0; foreach ($this->GetData()[0] as $row) { $dados[$x]["calldate"] = date('d/m/Y H', strtotime($row["calldate"])); $dados[$x]["src"] = $row['src']; @@ -416,7 +450,8 @@ $dados[$x]["fila"] = $row["fila"]; $dados[$x]["agente"] = $row["agente"]; $dados[$x]["nome_municipio"] = $row['nome_municipio'] == "CHAMADAS NAO IDENTIFICADAS" ? 'NI' : $row['nome_municipio']; - $dados[$x]["uf"] = $row['uf']; + $dados[$x]["nome_municipio"] = $row['nome_municipio'] ?? 'NI'; + $dados[$x]["uf"] = $row['uf'] ?? 'NI'; $somaQtd ++; $x++; } diff --git a/relatorios/pbx/chamadasSaintes/saintesRamal.php b/relatorios/pbx/chamadasSaintes/saintesRamal.php index b3e58293..fe688da1 100644 --- a/relatorios/pbx/chamadasSaintes/saintesRamal.php +++ b/relatorios/pbx/chamadasSaintes/saintesRamal.php @@ -160,7 +160,7 @@ $row["calldate"] = date('d/m/Y', strtotime($row["calldate"])); $somaTempo += $row["billsec"]; $row["billsec"] = SecondToStrTime($row["billsec"]); - $somaQuantidade ++; + $somaQuantidade += $row['qt_chamadas']; $linha = array(); foreach ($dadosField as $value) { @@ -225,7 +225,7 @@ $row["calldate"] = date('d/m/Y', strtotime($row["calldate"])); $somaTempo += $row["billsec"]; $row["billsec"] = SecondToStrTime($row["billsec"]); - $somaQuantidade ++; + $somaQuantidade += $row['qt_chamadas']; // Formata linha de dados. $linha = array('DADOS'); @@ -292,7 +292,7 @@ $row["calldate"] = date('d/m/Y', strtotime($row["calldate"])); $somaTempo += $row["billsec"]; $row["billsec"] = SecondToStrTime($row["billsec"]); - $somaQuantidade ++; + $somaQuantidade += $row['qt_chamadas']; // Formata linha de dados. @@ -333,7 +333,7 @@ $dados[$x]["calldate"] = date('d/m/Y', strtotime($row["calldate"])); $somaTempo += $row["billsec"]; $dados[$x]["billsec"] = SecondToStrTime($row["billsec"]); - $somaQtd ++; + $somaQtd += $row['qt_chamadas']; $x++; }