•  
     

php

O que faz esse codigo?
<?php
/**Relatio de horas de suporte telefonico
*
* */
require_once("../valida_session.php");
require_once("../includes/funcoes.php");

if(!isset($_SESSION)){
session_start();
}

if(isset($_GET["d1"])){
$dat1 = $_GET["d1"];
$dataimpressao1 = $dat1;
$dat1 = converte_data_com_barra($dat1);

}
if(isset($_GET["d2"])){
$dat2 = $_GET["d2"];
$dataimpressao2 = $dat2;
$dat2 = converte_data_com_barra($dat2);
}

if(isset($_GET["t"])){
if($_GET["t"]==""){
die("Selecione um tipo de pesquisa");
}
$filial = $_GET["t"];
}
if(isset($_GET["r"])){
if($_GET["r"]==""){
exit("<center>Selecione um Ranking</center>");
}
$rank = $_GET["r"];
}

$conexao = new ConexaoPg();
if($dat1>$dat2){
exit("<center><font size='2' face='Verdana'>Per&iacute;odo Inv&aacute;lido</font></center>");
}
if($filial==0){
$clientes = $conexao->consultas("SELECT numcli,nomecli FROM CADCLI WHERE INATIVO='N' AND FILIAL ISNULL");
}else{
$clientes = $conexao->consultas("SELECT numcli,nomecli FROM CADCLI WHERE INATIVO='N' AND FILIAL='$filial'");
}
$totalRows = pg_num_rows($clientes);
if($totalRows<=0){
exit("<center><font size='2' face='Verdana'>Nenhum Registro Encontrado</font></center>");
}

?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../css/estilo.css">
</head>
<center><a href="imprHorasLigacoes.php?<?php echo "dat1=$dat1&dat2=$dat2&t=$filial&dataimpressao2=$dataimpressao2&dataimpressao1=$dataimpressao1"?>" target='_blank' class='pop' rel='height:525,width:780,scrollbars:1,status:0,resizable:0,center=1'>Impress&atilde;o</a></center><br>

<center><fieldset style='width:60%';><legend><font size='1' face='Verdana'><strong>Relat&oacute;rio de Liga&ccedil;&otilde;es</strong></font></legend>
<table border='1' width='75%'>

<thead><th>Nome Cliente</th><th>Total Tempo (min)</th><th>Total Liga&ccedil;&otilde;es</th></thead>
<?php
while($cli = pg_fetch_array($clientes)) {
$count = 0;
$totais = 0;
$horas = 0;
$min = 0;
$seg = 0;
switch($cli[0]){
case $cli[0]<=9:
$cli[0] = "00$cli[0]";
break;
case $cli[0]<=99:
$cli[0] = "0$cli[0]";
break;
}

$duraLig = $conexao->consultas("SELECT duralig,dtinilig,numcli FROM ligpabx WHERE TO_CHAR(dtinilig,'YYYY-MM') BETWEEN '$dat1' AND '$dat2' and numcli='$cli[0]'");
while($lig = pg_fetch_array($duraLig)){
$count++;
$tempo = explode(":",$lig['duralig']);
$horas +=$tempo[0];
$min +=$tempo[1];
$seg +=$tempo[2];
}
$totalDuraLigCli = converteHoraMinSeg($horas,$min,$seg,"M");
$totais += $totalDuraLigCli;

echo "<tr><td id='tds'>".($cli[1])."</td>";
echo "<td width='25%'>".($totais)."</td>";
echo "<td width='25%'>".($count)."</td></fieldset>";

}