diff --git a/relatorios/callcenter/geral/desempenhoOperacao.php b/relatorios/callcenter/geral/desempenhoOperacao.php index f39b96af..e66cdc56 100644 --- a/relatorios/callcenter/geral/desempenhoOperacao.php +++ b/relatorios/callcenter/geral/desempenhoOperacao.php @@ -251,13 +251,15 @@ $agt_duracaoseg = $data[$row['data']]['tempo_login']; $agt_pausa = $data[$row['data']]['tempo_pausa']; - $livre = $agt_duracaoseg - ($agt_pausa + $tempo_calc); - + $livre = $agt_duracaoseg - ($agt_pausa + $tempo_calc); $row['conexoes'] = ($data[$row['data']]['conexoes'] ? $data[$row['data']]['conexoes'] : 0); - $row['agtAtend'] = $agt_duracaoseg ? round($tempo_calc / ($agt_duracaoseg / 100), 2) : 0; $row['agtLivre'] = $agt_duracaoseg ? round($livre / ($agt_duracaoseg / 100), 2) : 0; $row['agtPausa'] = $agt_duracaoseg ? round($agt_pausa / ($agt_duracaoseg / 100), 2) : 0; + + $residualPercentage = ($row['agtAtend'] + $row['agtLivre'] + $row['agtPausa']) - 100; + $row['agtLivre'] = $this->adjustPercentageResidual($residualPercentage, $row['agtLivre']); + $x++; $linha = array(); foreach ($dadosField as $key) { @@ -357,6 +359,9 @@ $row['agtLivre'] = $agt_duracaoseg ? round($livre / ($agt_duracaoseg / 100), 2) : 0; $row['agtPausa'] = $agt_duracaoseg ? round($agt_pausa / ($agt_duracaoseg / 100), 2) : 0; + $residualPercentage = ($row['agtAtend'] + $row['agtLivre'] + $row['agtPausa']) - 100; + $row['agtLivre'] = $this->adjustPercentageResidual($residualPercentage, $row['agtLivre']); + // Formata linha de dados. $linha = array('DADOS'); foreach ($dadosField as $key) { @@ -511,6 +516,9 @@ $row['agtLivre'] = $agt_duracaoseg ? round($livre / ($agt_duracaoseg / 100), 2) : 0; $row['agtPausa'] = $agt_duracaoseg ? round($agt_pausa / ($agt_duracaoseg / 100), 2) : 0; + $residualPercentage = ($row['agtAtend'] + $row['agtLivre'] + $row['agtPausa']) - 100; + $row['agtLivre'] = $this->adjustPercentageResidual($residualPercentage, $row['agtLivre']); + $linha = ""; foreach ($dadosField as $key => $value) { $linha .= sprintf("%s", $value, $row["$key"]); @@ -584,6 +592,10 @@ $dados[$x]['agtAtend'] = $agt_duracaoseg ? round($tempo_calc / ($agt_duracaoseg / 100), 2) : 0; $dados[$x]['agtLivre'] = $agt_duracaoseg ? round($livre / ($agt_duracaoseg / 100), 2) : 0; $dados[$x]['agtPausa'] = $agt_duracaoseg ? round($agt_pausa / ($agt_duracaoseg / 100), 2) : 0; + + $residualPercentage = ($dados[$x]['agtAtend'] + $dados[$x]['agtLivre'] + $dados[$x]['agtPausa']) - 100; + $dados[$x]['agtLivre'] = $this->adjustPercentageResidual($residualPercentage, $dados[$x]['agtLivre']); + $dados[$x]["data"] = $row["data"]; $dados[$x]["conexoes"] = $row["conexoes"]; $dados[$x]["oferecidas"] = $row["oferecidas"]; @@ -662,6 +674,19 @@ $this->___dataRel = array($table1, $table2); } + private function adjustPercentageResidual($residualPercentage, $percentForAdjustment) + { + if ($residualPercentage > 0){ + $adjustedPercentage = $percentForAdjustment - $residualPercentage; + } else if ($residualPercentage < 0) { + $adjustedPercentage = $percentForAdjustment + ($residualPercentage * -1); + } else { + $adjustedPercentage = $percentForAdjustment; + } + + return $adjustedPercentage; + } + public function ExecutaRelatorio() { global $jsStartup, $jsJQuery, $smarty; try {