diff --git a/cadastros/pesquisa/pesquisaRel.php b/cadastros/pesquisa/pesquisaRel.php
index 98bedbbe..ac7aa518 100644
--- a/cadastros/pesquisa/pesquisaRel.php
+++ b/cadastros/pesquisa/pesquisaRel.php
@@ -157,10 +157,11 @@
INNER JOIN pbx_eventos_dacs b ON a.uniqueid = b.uid2
LEFT JOIN pbx_pesquisa_regitra c ON a.uniqueid = c.uniqueid
LEFT JOIN pbx_usuarios d ON d.matricula = SUBSTRING(b.agente, 7, 4)
+ LEFT JOIN pbx_queues_grupos e ON e.nome = b.fila
WHERE calldate::DATE >= '$dataIni'
AND calldate::DATE <= '$dataFim'
AND b.evento IN('COMPLETEAGENT','COMPLETECALLER', 'TRANSFER','COMPLETEAGENTRAMAL','COMPLETECALLERRAMAL', 'COMPLETACALLER', 'COMPLETAAGENT')
- AND fila = 'SUPORTE_NIVEL1_ARAXA'
+ AND e.id = '$dac'
GROUP BY fila, d.matricula, apelido";
$result = $this->___GetQuery($query);
@@ -201,6 +202,7 @@
}
$dataRel[] = GenerateCsvFromArray($linha);
+ $dataRel[] = GenerateCsvFromArray($linha);
// Formata linha de dados.
foreach ($this->GetData()[$x] as $dataPsq) {
$linha = array();
@@ -209,7 +211,7 @@
if ($key == 'po_opcao') {
$linha[] = RemoveAcentos($dataPsq["$key"]);
} else if ($key == 'por_resp') {
- $dataPsq['por_resp'] = number_format(($dataPsq["num_resp"] / $somaResp) * 100.0, 2, ',', '.') . '%';
+ $dataPsq['por_resp'] = $dataPsq["num_resp"] ?? number_format(($dataPsq["num_resp"] / $somaResp) * 100.0, 2, ',', '.') . '%';
$linha[] = $dataPsq['por_resp'];
} else {
$linha[] = $dataPsq["$key"];
@@ -218,7 +220,7 @@
$dataRel[] = GenerateCsvFromArray($linha);
unset($linha);
}
- $dataRel[] = GenerateCsvFromArray(array('Total', '', 'Resp.: '.$somaResp,number_format(($somaResp / $somaResp) * 100.0, 2, ',', '.') . '%'));
+ $dataRel[] = GenerateCsvFromArray(array('Total', '', 'Resp.: '.$somaResp, $somaResp ?? number_format(($somaResp / $somaResp) * 100.0, 2, ',', '.') . '%'));
$x++;
}
@@ -275,17 +277,15 @@
}
$dataRel[] = $linha;
- //$row['po_opcao'] = RemoveAcentos($row['po_opcao']);
- // Formata linha de dados.
+ // Formata linha de dados.
foreach ($this->GetData()[$x] as $dataPsq) {
$linha = array('DADOS');
foreach ($dadosField as $key) {
-
if ($key == 'po_opcao') {
$linha[] = RemoveAcentos($dataPsq["$key"]);
} else if ($key == 'por_resp') {
- $dataPsq['por_resp'] = number_format(($dataPsq["num_resp"] / $somaResp) * 100.0, 2, ',', '.') . '%';
+ $dataPsq['por_resp'] = $dataPsq["num_resp"] ?? number_format(($dataPsq["num_resp"] / $somaResp) * 100.0, 2, ',', '.') . '%';
$linha[] = $dataPsq['por_resp'];
} else {
$linha[] = $dataPsq["$key"];
@@ -295,11 +295,30 @@
$dataRel[] = $linha;
unset($linha);
}
- $dataRel[] = array('LABEL', 'Total', '', 'Resp.: '.$somaResp,number_format(($somaResp / $somaResp) * 100.0, 2, ',', '.') . '%');
+ $dataRel[] = array('LABEL', 'Total', '', 'Resp.: '.$somaResp, $somaResp ?? number_format(($somaResp / $somaResp) * 100.0, 2, ',', '.') . '%');
$x++;
}
+ $dataRel[] = array('LABEL', '');
+
+ $dadosCabecalio = array('Fila', 'Agente', 'Direcionamento Pesquisa', 'Conclusao Pesquisa', 'Chamadas');
+ $linha = array('LABEL');
+ foreach ($dadosCabecalio as $value) {
+ $linha[] = $value;
+ }
+ $dataRel[] = $linha;
+
+ $dadosField = array('fila', 'apelido', 'envio_pesquisa', 'completou_pesquisa', 'chamadas_realizadas');
+ $linha = array('DADOS');
+ foreach ($this->GetData()[$x] as $stat) {
+ $linha = array('DADOS');
+ foreach ($dadosField as $key) {
+ $linha[] = $stat[$key];
+ }
+ }
+ $dataRel[] = $linha;
+
$this->___dataRel[] = $dataRel;
}
@@ -344,6 +363,7 @@
//print_r($this->GetData());
$x = 1;
$somaResp = 0;
+ $linhas = '';
/*
* Linhas de dados.
@@ -364,14 +384,14 @@
$linhas .= "
";
foreach ($dadosField as $k => $value) {
if ($k == 'por_resp') {
- $linhas .= sprintf("%s%% | ", $value, number_format(($dataPesquisa["num_resp"] / $somaResp) * 100.0, 2, ',', '.'));
+ $linhas .= sprintf("%s%% | ", $value, $dataPesquisa["num_resp"] ?? number_format(($dataPesquisa["num_resp"] / $somaResp) * 100.0, 2, ',', '.'));
} else {
$linhas .= sprintf("%s | ", $value, $dataPesquisa["$k"]);
}
}
$linhas .= "
";
}
- $linhas .= sprintf("Total | $somaResp | %s |
", number_format(($somaResp / $somaResp) * 100.0, 2, ',', '.').'%');
+ $linhas .= sprintf("Total | $somaResp | %s |
", $somaResp ?? number_format(($somaResp / $somaResp) * 100.0, 2, ',', '.').'%');
$x++;
$dataRel[] = $linhas;
unset($linhas);
@@ -454,14 +474,34 @@
$dataQst[$z]['po_opcao'] = $data['po_opcao'];
$dataQst[$z]['num_resp'] = $data['num_resp'];
$dataQst[$z]['po_tecla'] = $data['po_tecla'];
- $dataQst[$z]['por_resp'] = number_format(($data["num_resp"] / $somaTotalQtd) * 100.0, 2, ',', '.') . '%';
+ $dataQst[$z]['por_resp'] = $data["num_resp"] ?? number_format(($data["num_resp"] / $somaTotalQtd) * 100.0, 2, ',', '.') . '%';
$z++;
}
- $totalizador = array('Total: ', $row['pq_questao'], 'Resp.: '.$somaTotalQtd , number_format(($somaTotalQtd / $somaTotalQtd) * 100.0, 2, ',', '.') . '%');
+ $totalizador = array('Total: ', $row['pq_questao'], 'Resp.: '.$somaTotalQtd , $somaTotalQtd ?? number_format(($somaTotalQtd / $somaTotalQtd) * 100.0, 2, ',', '.') . '%');
$tables[] = array($dadosCabecalio, $dadosField, $dataQst, $widthHeader, $totalizador, 0);
$x++;
unset($dataQst);
}
+
+ $dadosCabecalio = array(
+ 'Fila' => 'C',
+ 'Agente' => 'C',
+ 'Direcionamento Pesquisa' => 'C',
+ 'Conclusao Pesquisa' => 'C',
+ 'Chamadas' => 'C'
+ );
+
+ $dadosField = array(
+ 'fila' => 'C',
+ 'apelido' => 'C',
+ 'envio_pesquisa' => 'C',
+ 'completou_pesquisa' => 'C',
+ 'chamadas_realizadas' => 'C'
+ );
+
+ $widthHeader = array(20, 20, 40, 40, 20);
+ $tables[] = array($dadosCabecalio, $dadosField, $this->GetData()[$x], $widthHeader, 0, 0);
+
$this->___dataRel = $tables;
}
@@ -510,10 +550,7 @@
$smarty->assign('msg', $this->GetMsg());
GetTemplate($smarty, 'relatoriosGrid.tpl');
}
-
}
$relPesquisa = new RelPesquisa($idProg, $dbcon, 1);
- $relPesquisa->ExecutaRelatorio();
-
-
\ No newline at end of file
+ $relPesquisa->ExecutaRelatorio();
\ No newline at end of file
diff --git a/cadastros/pesquisa/pesquisaRelAgente.php b/cadastros/pesquisa/pesquisaRelAgente.php
index 3aaf0880..e2f0a922 100644
--- a/cadastros/pesquisa/pesquisaRelAgente.php
+++ b/cadastros/pesquisa/pesquisaRelAgente.php
@@ -1,5 +1,4 @@
= '{$dataIni}' AND calldate::DATE <= '{$dataFim}'
AND b.evento IN('COMPLETEAGENT','COMPLETECALLER', 'TRANSFER','COMPLETEAGENTRAMAL','COMPLETECALLERRAMAL', 'COMPLETACALLER', 'COMPLETAAGENT')
AND e.id = {$dac}
@@ -208,18 +208,16 @@
$linha[] = $value;
}
- $dataRel[] = $linha;
- //$row['po_opcao'] = RemoveAcentos($row['po_opcao']);
+ $dataRel[] = GenerateCsvFromArray($linha);
+
// Formata linha de dados.
-
foreach ($this->GetData()[$x] as $dataPsq) {
$linha = array();
foreach ($dadosField as $key) {
-
if ($key == 'po_opcao') {
$linha[] = RemoveAcentos($dataPsq["$key"]);
} else if ($key == 'por_resp') {
- $dataPsq['por_resp'] = number_format(($dataPsq["num_resp"] / $somaResp) * 100.0, 2, ',', '.') . '%';
+ $dataPsq['por_resp'] = $dataPsq["num_resp"] ?? number_format(($dataPsq["num_resp"] / $somaResp) * 100.0, 2, ',', '.') . '%';
$linha[] = $dataPsq['por_resp'];
} else {
$linha[] = $dataPsq["$key"];
@@ -228,7 +226,7 @@
$dataRel[] = GenerateCsvFromArray($linha);
unset($linha);
}
- $dataRel[] = GenerateCsvFromArray(array('Total', '', 'Resp.: ' . $somaResp, number_format(($somaResp / $somaResp) * 100.0, 2, ',', '.') . '%'));
+ $dataRel[] = GenerateCsvFromArray(array('Total', '', 'Resp.: ' . $somaResp, $somaResp ?? number_format(($somaResp / $somaResp) * 100.0, 2, ',', '.') . '%'));
$x++;
}
@@ -300,17 +298,15 @@
}
$dataRel[] = $linha;
- //$row['po_opcao'] = RemoveAcentos($row['po_opcao']);
- // Formata linha de dados.
+ // Formata linha de dados.
foreach ($this->GetData()[$x] as $dataPsq) {
$linha = array('DADOS');
foreach ($dadosField as $key) {
-
if ($key == 'po_opcao') {
$linha[] = RemoveAcentos($dataPsq["$key"]);
} else if ($key == 'por_resp') {
- $dataPsq['por_resp'] = number_format(($dataPsq["num_resp"] / $somaResp) * 100.0, 2, ',', '.') . '%';
+ $dataPsq['por_resp'] = $dataPsq["num_resp"] ?? number_format(($dataPsq["num_resp"] / $somaResp) * 100.0, 2, ',', '.') . '%';
$linha[] = $dataPsq['por_resp'];
} else {
$linha[] = $dataPsq["$key"];
@@ -320,7 +316,7 @@
$dataRel[] = $linha;
unset($linha);
}
- $dataRel[] = array('LABEL', 'Total', '', 'Resp.: ' . $somaResp, number_format(($somaResp / $somaResp) * 100.0, 2, ',', '.') . '%');
+ $dataRel[] = array('LABEL', 'Total', '', 'Resp.: ' . $somaResp, $somaResp ?? number_format(($somaResp / $somaResp) * 100.0, 2, ',', '.') . '%');
$x++;
}
@@ -386,6 +382,7 @@
//print_r($this->GetData());
$x = 1;
$somaResp = 0;
+ $linhas = '';
/*
* Linhas de dados.
@@ -394,7 +391,6 @@
//Monta a Questão da Pergunta da pesquisa.
$linhas .= sprintf("%s |
", $row['pq_questao']);
-
$linhas .= "";
foreach ($dadosCabecalio as $key => $value) {
$linhas .= sprintf("%s | ", $value, $key);
@@ -409,14 +405,14 @@
$linhas .= "
";
foreach ($dadosField as $k => $value) {
if ($k == 'por_resp') {
- $linhas .= sprintf("%s%% | ", $value, number_format(($dataPesquisa["num_resp"] / $somaResp) * 100.0, 2, ',', '.'));
+ $linhas .= sprintf("%s%% | ", $value, $dataPesquisa["num_resp"] ?? number_format(($dataPesquisa["num_resp"] / $somaResp) * 100.0, 2, ',', '.'));
} else {
$linhas .= sprintf("%s | ", $value, $dataPesquisa["$k"]);
}
}
$linhas .= "
";
}
- $linhas .= sprintf("Total | $somaResp | %s |
", number_format(($somaResp / $somaResp) * 100.0, 2, ',', '.') . '%');
+ $linhas .= sprintf("Total | $somaResp | %s |
", $somaResp ?? number_format(($somaResp / $somaResp) * 100.0, 2, ',', '.') . '%');
$x++;
@@ -492,10 +488,10 @@
$dataQst[$z]['po_opcao'] = $data['po_opcao'];
$dataQst[$z]['num_resp'] = $data['num_resp'];
$dataQst[$z]['po_tecla'] = $data['po_tecla'];
- $dataQst[$z]['por_resp'] = number_format(($data["num_resp"] / $somaTotalQtd) * 100.0, 2, ',', '.') . '%';
+ $dataQst[$z]['por_resp'] = $data["num_resp"] ?? number_format(($data["num_resp"] / $somaTotalQtd) * 100.0, 2, ',', '.') . '%';
$z++;
}
- $totalizador = array('Total: ', $row['pq_questao'], 'Resp.: ' . $somaTotalQtd, number_format(($somaTotalQtd / $somaTotalQtd) * 100.0, 2, ',', '.') . '%');
+ $totalizador = array('Total: ', $row['pq_questao'], 'Resp.: ' . $somaTotalQtd, $somaTotalQtd ?? number_format(($somaTotalQtd / $somaTotalQtd) * 100.0, 2, ',', '.') . '%');
$tables[] = array($dadosCabecalio, $dadosField, $dataQst, $widthHeader, $totalizador, 0);
$x++;
unset($dataQst);
@@ -572,5 +568,4 @@
}
$relPesquisaAgt = new RelPesquisaAgente($idProg, $dbcon, 1);
- $relPesquisaAgt->ExecutaRelatorio();
-
\ No newline at end of file
+ $relPesquisaAgt->ExecutaRelatorio();
\ No newline at end of file
diff --git a/include/util/util.php b/include/util/util.php
index e1ffb643..128f2838 100644
--- a/include/util/util.php
+++ b/include/util/util.php
@@ -1639,6 +1639,7 @@ function TarifaChamada($tipoTarifa, $duracaoSegundos, $precoMinuto, $fator, $cad
* 3) Acima de 60 segundos a chamada dever� ser cobrada com o pre�o cheio (60s = tarifa) e a acrescida do valor da tarifa (Tarifa / 10) a cada 6 segundos.
*/
$MINUTO = 60;
+ $operatorModule = true;
/*
* Tarifa��o tipo 2 tem o preco definido por chamada.
*/
@@ -1651,47 +1652,55 @@ function TarifaChamada($tipoTarifa, $duracaoSegundos, $precoMinuto, $fator, $cad
if ($duracaoSegundos <= 3)
return 0;
- $fatorCalculo = (int) ($MINUTO / $fator);
- $fatorCadencia = (int) ($MINUTO / $cadencia);
+ $fatorCalculo = (int) Divide($MINUTO, $fator);
+ $fatorCadencia = (int) Divide($MINUTO, $cadencia);
if (($fatorCalculo == 1) && ($fatorCadencia == 1)) {
/*
* Tarifa��o cheia ou seja 61 segundos � tarifado como 120
*/
- $minutos = (int) ($duracaoSegundos / $MINUTO);
- $quebraMinuto = ($duracaoSegundos % $MINUTO) ? 1 : 0;
+ $minutos = (int) Divide($duracaoSegundos, $MINUTO);
+ $quebraMinuto = Divide($duracaoSegundos, $MINUTO, $operatorModule) ? 1 : 0;
return round((($precoMinuto * $minutos) + ($precoMinuto * $quebraMinuto)), 2);
- } else if (($duracaoSegundos) <= ($MINUTO / $fatorCalculo)) {
+ } else if (($duracaoSegundos) <= Divide($MINUTO, $fatorCalculo)) {
/*
* Aqui ser� tarifado por exemplo chamadas entre 3 e 30 segundos quando
* cadencia 30+6 ou entre 3 e 60 quando cadencia 60+6
*/
- return round(($precoMinuto / $fatorCalculo), 2);
- } else if ($duracaoSegundos < ($MINUTO)) {
+ return round(Divide($precoMinuto, $fatorCalculo), 2);
+ } else if ($duracaoSegundos < $MINUTO) {
/*
* Aqui sera tarifado chamada que estiver entre 31 e 59 segundos
* quando cadencia 30+6
*/
- $duracaoCadencia = $duracaoSegundos - ($MINUTO / $fatorCalculo);
- $precoCadencia = $precoMinuto / $fatorCalculo;
- $resto = ($duracaoCadencia % $cadencia);
- $numCadencia = (int) ($duracaoCadencia / $cadencia) + ($resto ? 1 : 0);
- $valorCadencia = $precoMinuto / $fatorCadencia;
-
+ $duracaoCadencia = $duracaoSegundos - Divide($MINUTO, $fatorCalculo);
+ $precoCadencia = Divide($precoMinuto, $fatorCalculo);
+ $resto = Divide($duracaoCadencia, $cadencia, $operatorModule);
+ $numCadencia = (int) Divide($duracaoCadencia, $cadencia) + ($resto ? 1 : 0);
+ $valorCadencia = Divide($precoMinuto, $fatorCadencia);
return round(($precoCadencia + ($numCadencia * $valorCadencia)), 2);
} else {
/*
* Chamada acima de um minuto.
*/
- $minutos = (int) ($duracaoSegundos / $MINUTO);
- $segundosCandencia = ($duracaoSegundos % $MINUTO);
- $numCadencia = (int) ($segundosCandencia / $cadencia) + (($segundosCandencia % $cadencia) ? 1 : 0);
- $valorCadencia = $precoMinuto / $fatorCadencia;
-
+ $minutos = (int) Divide($duracaoSegundos, $MINUTO);
+ $segundosCandencia = Divide($duracaoSegundos, $MINUTO, $operatorModule);
+ $numCadencia = (int) Divide($segundosCandencia, $cadencia) + (Divide($segundosCandencia, $cadencia, $operatorModule) ? 1 : 0);
+ $valorCadencia = Divide($precoMinuto, $fatorCadencia);
return round((($precoMinuto * $minutos) + ($valorCadencia * $numCadencia)), 2);
}
}
+/**
+ * Esta função é utilizada para verificar se o dividendo ou o divisor é igual a ZERO antes de realizar a divisão.
+ */
+function Divide($dividend, $divider, $operator = false){
+ if ($dividend && $divider){
+ return ($operator ? $dividend % $divider : $dividend / $divider);
+ }
+ return 0;
+}
+
function SaveVarToFile($var, $fileName) {
return file_put_contents($fileName, serialize($var));
}
diff --git a/relatorios/tarifador/tarifaRamal.php b/relatorios/tarifador/tarifaRamal.php
index f06ff309..fd0a1160 100644
--- a/relatorios/tarifador/tarifaRamal.php
+++ b/relatorios/tarifador/tarifaRamal.php
@@ -1,5 +1,4 @@
___dataIni);
$dataFim = FormatDtMssql($this->___dataFim);
@@ -236,6 +233,7 @@
/*
* FORMATA OS DADOS PARA SER APRESENTADOS
*/
+ $row['trr_destino'] = ocultarTelefone($row['trr_destino']);
$row['trr_data'] = date('d/m/Y', strtotime($row['trr_data']));
$row['trr_conta'] = $row['trr_conta'] ? $row['trr_conta'] : ' - ';
$row['trr_duracao'] = $row['trr_duracao'] ? SecondToStrTime($row['trr_duracao']) : '00:00:00';
@@ -372,6 +370,7 @@
/*
* FORMATA OS DADOS PARA SER APRESENTADOS
*/
+ $row['trr_destino'] = ocultarTelefone($row['trr_destino']);
$row['trr_data'] = date('d/m/Y', strtotime($row['trr_data']));
$row['trr_conta'] = $row['trr_conta'] ? $row['trr_conta'] : ' - ';
$row['trr_duracao'] = $row['trr_duracao'] ? SecondToStrTime($row['trr_duracao']) : '00:00:00';
@@ -636,6 +635,7 @@
/*
* FORMATA OS DADOS PARA SER APRESENTADOS
*/
+ $dados[$somaReg]['trr_destino'] = ocultarTelefone($row['trr_destino']);
$dados[$somaReg]['trr_data'] = date('d/m/Y', strtotime($row['trr_data']));
$dados[$somaReg]['trr_conta'] = $row['trr_conta'] ? $row['trr_conta'] : ' - ';
$dados[$somaReg]['trr_duracao'] = $row['trr_duracao'] ? SecondToStrTime($row['trr_duracao']) : '00:00:00';