@media print { .headSite, #rodapeSite, .filtro { display: none; } } "; $linkGraph = ''; $printGraph = isset($_REQUEST['printGraph']) ? 1 : 0; if ($printGraph) { ob_clean(); $query = GetQuery($dataIni, $dataFim, $listaDacs, $listaServico); $result = pg_query($query); $abandonadas = array(0, 0, 0, 0, 0, 0, 0, 0); $atendidas = array(0, 0, 0, 0, 0, 0, 0, 0); $espera = array(0, 0, 0, 0, 0, 0, 0, 0); $arLabel = array('TE<=10', '10SetMargin(40, 20, 40, 40); $graph->SetScale("textint"); $graph->img->SetAntiAliasing(false); $graph->title->Set(sprintf("%s De: %s Até: %s\nDac: %s Serviço: %s Emitido: %s Usuário: %s", "Período", $dataIni, $dataFim, GetNomeDac($listaDacs), (!$listaServico ? 'Todos' : $listaServico), date("d/m/Y H:i:s"), GetLogin())); $graph->SetBox(false); $graph->img->SetAntiAliasing(); $graph->yaxis->HideZeroLabel(); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false, false); $graph->yaxis->title->Set('Percentual'); $graph->xgrid->Show(); $graph->xgrid->SetLineStyle("solid"); $graph->xaxis->SetTickLabels($arLabel); $graph->xgrid->SetColor('#E3E3E3'); $graph->xaxis->title->Set(sprintf("\nTotal Atendidas [ %s ] Total Abandonadas [ %s ] Total Espera [ %s ] ", FormataValor($totalAtd, 0), FormataValor($totalAbd, 0), FormataValor($totalEsp, 0))); /* * Construção das linhas. */ $atdPlot = new LinePlot($atendidas); $graph->Add($atdPlot); $atdPlot->SetColor("green"); $atdPlot->SetLegend('Chamadas Atendidas'); $abdPlot = new LinePlot($abandonadas); $graph->Add($abdPlot); $abdPlot->SetColor("red"); $abdPlot->SetLegend('Chamadas Abandonadas'); $espPlot = new LinePlot($espera); $graph->Add($espPlot); $espPlot->SetColor("orange"); $espPlot->SetLegend('Chamadas em Espera'); $graph->legend->SetFrameWeight(1); $graph->Stroke(); exit; } else if (IsPostBack()) { if (!is_date($dataIni)) { $jsStartup[] = "alert('Data inicial inválida!');"; } else if (!is_date($dataFim)) { $jsStartup[] = "alert('Data final inválida!');"; } else { $linkGraph = sprintf('', $dataIni, $dataFim, $listaDacs, $listaServico); } //echo GetQuery($dataIni, $dataFim, $listaDacs, $listaServico); } // Carrega servicos. $listaServico = GetIdentRota($dbcon, $listaServico); //carrega dacs $dacs = GetDac($dbcon, $listaDacs, '', 1); $smarty->assign('imp', $i); $smarty->assign('dacs', $dacs); $smarty->assign('dataIni', $dataIni); $smarty->assign('dataFim', $dataFim); $smarty->assign('erro', $erro); $smarty->assign('tipoChamada', $tipoChamada); $smarty->assign('linkGraph', $linkGraph); $smarty->assign('listaServico', $listaServico); GetTemplate($smarty, 'analise/desempenhoServico.tpl'); function GetQuery($dataIni, $dataFim, $dac, $serv) { $dataIni = FormatDtMssql($dataIni); $dataFim = FormatDtMssql($dataFim); $query = "SELECT 'ab' as tipo ,SUM (CASE WHEN( (strtoint(param3) <= 10)) THEN 1 ELSE 0 END) as ate_10 ,SUM (CASE WHEN( (strtoint(param3) > 10) AND (strtoint(param3) <= 20) ) THEN 1 ELSE 0 END) as ate_20 ,SUM (CASE WHEN( (strtoint(param3) > 20) AND (strtoint(param3) <= 30) ) THEN 1 ELSE 0 END) as ate_30 ,SUM (CASE WHEN( (strtoint(param3) > 30) AND (strtoint(param3) <= 60) ) THEN 1 ELSE 0 END) as ate_60 ,SUM (CASE WHEN( (strtoint(param3) > 60) AND (strtoint(param3) <= 120) ) THEN 1 ELSE 0 END) as ate_120 ,SUM (CASE WHEN( (strtoint(param3) > 120) AND (strtoint(param3) <= 180) ) THEN 1 ELSE 0 END) as ate_180 ,SUM (CASE WHEN( (strtoint(param3) > 180) AND (strtoint(param3) <= 300) ) THEN 1 ELSE 0 END) as ate_300 ,SUM (CASE WHEN( (strtoint(param3) > 300) ) THEN 1 ELSE 0 END) as ate_MAIOR FROM ( SELECT to_char(a.calldate,'YYYY-MM-DD') AS DATA ,a.calldate ,b.fila ,b.evento ,b.param1 ,b.param2 ,b.param3 ,b.param4 FROM pbx_eventos_dacs b, pbx_bilhetes a, pbx_dacs c, pbx_servicos_registra d where a.uniqueid = b.uid2 and c.nome = b.fila and d.uniqueid = b.uid2 and a.lastapp <> 'Transferred Call' and b.evento = 'ABANDON' and a.data_bilhete >= '$dataIni' and a.data_bilhete <= '$dataFim'\n"; if ($dac) $query .= " AND c.id = '$dac'\n"; if ($serv) $query .= " AND d.serv_id = '$serv'\n"; $query .= " ) AS DADOS UNION ALL SELECT 'at' as tipo ,SUM (CASE WHEN( (strtoint(param1) <= 10)) THEN 1 ELSE 0 END) as ate_10 ,SUM (CASE WHEN( (strtoint(param1) > 10) AND (strtoint(param1) <= 20) ) THEN 1 ELSE 0 END) as ate_20 ,SUM (CASE WHEN( (strtoint(param1) > 20) AND (strtoint(param1) <= 30) ) THEN 1 ELSE 0 END) as ate_30 ,SUM (CASE WHEN( (strtoint(param1) > 30) AND (strtoint(param1) <= 60) ) THEN 1 ELSE 0 END) as ate_60 ,SUM (CASE WHEN( (strtoint(param1) > 60) AND (strtoint(param1) <= 120) ) THEN 1 ELSE 0 END) as ate_120 ,SUM (CASE WHEN( (strtoint(param1) > 120) AND (strtoint(param1) <= 180) ) THEN 1 ELSE 0 END) as ate_180 ,SUM (CASE WHEN( (strtoint(param1) > 180) AND (strtoint(param1) <= 300) ) THEN 1 ELSE 0 END) as ate_300 ,SUM (CASE WHEN( (strtoint(param1) > 300) ) THEN 1 ELSE 0 END) as ate_MAIOR FROM ( SELECT to_char(a.calldate,'YYYY-MM-DD') AS DATA, a.calldate,b.fila, b.evento,b.param1,b.param2,b.param3,b.param4 FROM pbx_eventos_dacs b, pbx_bilhetes a, pbx_dacs c, pbx_servicos_registra d WHERE a.uniqueid = b.uid2 and c.nome = b.fila and d.uniqueid = b.uid2 and a.lastapp <> 'Transferred Call' AND b.evento IN ('COMPLETEAGENT','COMPLETECALLER','TRANSFER') AND a.data_bilhete >= '$dataIni' AND a.data_bilhete <= '$dataFim'\n"; if ($dac) $query .= " AND c.id = '$dac'\n"; if ($serv) $query .= " AND d.serv_id = '$serv'\n"; $query .= " ) AS DADOS UNION ALL SELECT 'ie' as tipo ,SUM (CASE WHEN( (strtoint(param1) <= 10)) THEN 1 ELSE 0 END) as ate_10 ,SUM (CASE WHEN( (strtoint(param1) > 10) AND (strtoint(param1) <= 20) ) THEN 1 ELSE 0 END) as ate_20 ,SUM (CASE WHEN( (strtoint(param1) > 20) AND (strtoint(param1) <= 30) ) THEN 1 ELSE 0 END) as ate_30 ,SUM (CASE WHEN( (strtoint(param1) > 30) AND (strtoint(param1) <= 60) ) THEN 1 ELSE 0 END) as ate_60 ,SUM (CASE WHEN( (strtoint(param1) > 60) AND (strtoint(param1) <= 120) ) THEN 1 ELSE 0 END) as ate_120 ,SUM (CASE WHEN( (strtoint(param1) > 120) AND (strtoint(param1) <= 180) ) THEN 1 ELSE 0 END) as ate_180 ,SUM (CASE WHEN( (strtoint(param1) > 180) AND (strtoint(param1) <= 300) ) THEN 1 ELSE 0 END) as ate_300 ,SUM (CASE WHEN( (strtoint(param1) > 300) ) THEN 1 ELSE 0 END) as ate_MAIOR FROM ( SELECT to_char(a.calldate,'YYYY-MM-DD') AS DATA, a.calldate,b.fila, b.evento,b.param1,b.param2,b.param3,b.param4 FROM pbx_eventos_dacs b, pbx_bilhetes a, pbx_dacs c, pbx_servicos_registra d WHERE a.uniqueid = b.uid2 and c.nome = b.fila and d.uniqueid = b.uid2 and a.lastapp <> 'Transferred Call' and b.evento = 'CONNECT' AND strtoint(param1) > 3 AND a.data_bilhete >= '$dataIni' AND a.data_bilhete <= '$dataFim'"; if ($dac) $query .= " AND c.id = '$dac'\n"; if ($serv) $query .= " AND d.serv_id = '$serv'\n"; $query .= " ) AS DADOS ORDER BY 1 "; //if(IsAdmin()){ echo $query; exit; } return $query; }