Ir para conteúdo
Fórum Script Brasil

Eduardo Assis

Membros
  • Total de itens

    15
  • Registro em

  • Última visita

Posts postados por Eduardo Assis

  1. $data = "time between '$dataini $horaini' and '$datafim $horafim'";

    $sql="SELECT * FROM queue_log where $data and (event = 'COMPLETECALLER' or event = 'COMPLETEAGENT')";

    $query=mysql_query($sql,$conexao);

    while ($registro=mysql_fetch_array($query))

    {

    $sqlagente="SELECT * FROM queue_log WHERE $data and callid='$registro[2]' and event='ENTERQUEUE'";

    $queryagente=mysql_query($sqlagente,$conexao);

    while ($registroagente=mysql_fetch_array($queryagente))

    {

  2. Em um banco mysql tenho um campo varchar que pode conter "Entrou" e "Saiu" e um campo date time.

    Estou fazendo uma consulta com PHP que no primeiro Select ele procura pelo campo contendo "Entrou" e dentro dele tenho um que Select que procura pelo campo contendo "Saiu" pegando a primeira data/hora e subtraindo pela segunda data/hora para me mostrar quanto tempo essa pessoa ficou registra.

    Mas como tenho muitos registro, demora tanto que o navegador acha que está parado e Não Responde Mais.

    Teria alguma forma de melhorar ? com 1 Select só ?

    Araços.

  3. Tenho uns 400.000 mil registro e um campo date time, quando procuro com between por 2 datas, ele tem que percorrer a tabela inteira para achar os que se equivalem, teria alguma forma de ser mais rapida ?

    Pensei em usar o LIMIT , mas só resolveria no caso de datas proximas, as antigas ele não iria buscar.

    Abraços.

  4. Estrutura da tabela:

    CREATE TABLE IF NOT EXISTS `queue_log` (

    `id` int(11) NOT NULL auto_increment,

    `time` datetime NOT NULL default '0000-00-00 00:00:00',

    `callid` varchar(20) NOT NULL default '',

    `queuename` varchar(20) NOT NULL default '',

    `agent` varchar(20) NOT NULL default '',

    `event` varchar(20) NOT NULL default '',

    `arg1` varchar(100) NOT NULL default '',

    `arg2` varchar(100) NOT NULL default '',

    `arg3` varchar(100) NOT NULL default '',

    PRIMARY KEY (`id`)

    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=106389 ;

    Alguns Dados:

    id time callid queuename agent event arg1 arg2 arg3

    226 2008-11-26 17:19:33 1227727113.42 atendimento DGV/44 CONNECT 60 1227727158.47

    227 2008-11-26 17:19:33 1227727104.40 atendimento DGV/38 COMPLETECALLER 61 8 2

    228 2008-11-26 17:19:39 1227727113.42 atendimento DGV/44 COMPLETECALLER 60 6 4

    229 2008-11-26 17:19:42 1227727146.45 atendimento DGV/38 CONNECT 36 1227727177.49

    230 2008-11-26 17:19:47 1227727169.48 atendimento DGV/44 CONNECT 18 1227727183.50

    231 2008-11-26 17:19:48 1227727137.44 atendimento NONE ABANDON 1 5 51

    232 2008-11-26 17:19:53 1227727193.51 atendimento NONE ENTERQUEUE 1934651339

    233 2008-11-26 17:19:53 1227727169.48 atendimento DGV/44 COMPLETECALLER 18 6 4

    234 2008-11-26 17:19:54 1227727146.45 atendimento DGV/38 COMPLETECALLER 36 12 6

    235 2008-11-26 17:20:00 1227727200.53 atendimento NONE ENTERQUEUE 1934618470

    236 2008-11-26 17:20:09 1227727200.53 atendimento DGV/44 CONNECT 9 1227727200.54

    237 2008-11-26 17:20:13 1227727213.55 atendimento NONE ENTERQUEUE 1936014000

    238 2008-11-26 17:20:23 1227727193.51 atendimento DGV/38 CONNECT 30 1227727198.52

    239 2008-11-26 17:20:24 1227727213.55 atendimento NONE ABANDON 1 2 11

    240 2008-11-26 17:20:24 1227727224.56 atendimento NONE ENTERQUEUE 1930124000

    241 2008-11-26 17:20:29 1227727229.57 atendimento NONE ENTERQUEUE 1930120582

    242 2008-11-26 17:20:32 1227727193.51 atendimento DGV/38 COMPLETECALLER 30 9 1

  5. Tenho uma consulta no Mysql com php da seguinte maneira.

    Uma tabela registra a entrada e saida, tendo os campos time, o que tenho

    que fazer é na mesma tabela procurar pela entrada, e verificando que horas foi a saida.

    Tendo $horainicio e $horafim, estou convertendo as horas para segundos, e depois subtraindo $horainicio por $horafim

    tendo a diferença e convertendo novamente para formato em horas.

    Tudo funciona, mas está demorando muito, pois ele procura por uns 8Mil registros é um select dentro de outro select.

    Teriam alguma ideia de melhorar essa consulta ?

    Segue parte do codigo que tenho hj.

    $sql="SELECT time,callid,agent FROM queue_log where $data and (event = 'COMPLETECALLER' or event = 'COMPLETEAGENT')";

    $query=mysql_query($sql,$conexao);

    $atendidas = 0;

    while ($registro=mysql_fetch_array($query))

    {

    $sql1="SELECT time,callid,arg2 FROM queue_log where $data and callid = '". $registro["callid"] . "' and event=ENTERQUEUE'";

    $query1=mysql_query($sql1,$conexao);

    $registro1=mysql_fetch_array($query1);

    if (!empty($registro1[0]))

    {

    $horasini = explode(" ", $registro1["time]);

    $horasfim = explode(" ", $registro["time"]);

    $tempoini = explode(":",$horasini[1]);

    $horaini = $tempoini[0];

    $minutoini = $tempoini[1];

    $segundoini = $tempoini[2];

    $tempofim = explode(":",$horasfim[1]);

    $horafim = $tempofim[0];

    $minutofim = $tempofim[1];

    $segundofim = $tempofim[2];

    $convhoraini = ($horaini * 60) * 60;

    $convminutoini = $minutoini * 60;

    $convsegundoini = $segundoini;

    $totalconvini = $convhoraini + $convminutoini + $convsegundoini;

    $convhorafim = ($horafim * 60) * 60;

    $convminutofim = $minutofim * 60;

    $convsegundofim = $segundofim;

    $totalconvfim = $convhorafim + $convminutofim + $convsegundofim;

    $totalconv = $totalconvfim - $totalconvini;

    $tempo = $tempo + $totalconv;

    if ($maiortempo < $totalconv)

    $maiortempo = $totalconv;

    if (empty($menortempo))

    $menortempo = $maiortempo;

    if (($menortempo > $totalconv) && ($totalconv > 0))

    $menortempo = $totalconv;

    $atendidas++;

    }

  6. Agradeço sua ajuda, bem estou postando o codigo que tenho:

    <?

    $dataini = date("Y-m-d");
    $datafim = date("Y-m-d");

    $datahj = date("d/m/Y");
    $data = "and time between '$dataini 00:00:00' and '$datafim 23:59:59'";

    include('banco.php');

    // Fila
    $fila = 0;
    $sql="SELECT * FROM queue_log where event='ENTERQUEUE' $data ORDER BY time DESC LIMIT 50";
    $query=mysql_query($sql,$conexao);
    while ($registro=mysql_fetch_array($query))
    {
    $sql1="SELECT * FROM queue_log where callid='".$registro["callid"]."' and (event = 'ABANDON' or event = 'COMPLETECALLER' or event = 'CONNECT') $data order by time DESC Limit 1";
    $query1=mysql_query($sql1,$conexao);
    $registro1=mysql_fetch_array($query1);
    if ( empty($registro1[0]) )
    {
    //echo $contador . " - Aguardando: " . $registro["arg2"] . "<br>";
    $fila++;
    }
    }

    // Abandonado

    $sql="SELECT COUNT(id) FROM queue_log where event='ABANDON' $data and arg3 > 60";
    $query=mysql_query($sql,$conexao);
    $registro=mysql_fetch_array($query);
    $desistentes = $registro[0];

    //Completados

    $sql="SELECT COUNT(id) FROM queue_log where ( event='COMPLETECALLER' or event='COMPLETEAGENT' ) $data";
    $query=mysql_query($sql,$conexao);
    $registro=mysql_fetch_array($query);
    $atendidas = $registro[0];

    // Numero de Agentes

    $sql="SELECT * FROM agentes order by agente";
    $query=mysql_query($sql,$conexao);
    while ($registro=mysql_fetch_array($query))
    {
    $sql1="SELECT COUNT(*) FROM queue_log where arg1='".$registro["senha"]."' order by time DESC Limit 1";
    $query1=mysql_query($sql1,$conexao);
    $registro1=mysql_fetch_array($query1);
    $agentes = $registro1[0];
    }

    ?>

    <html>
    <head>
    <title> </title>
    <meta name="keywords" content="Asterisk - Pro Redes - Call Center">
    <STYLE type=text/css>
    A:link { text-decoration: none}
    A:visited { text-decoration: none}
    </STYLE>

    </head>
    <body>
    <center><font face=verdana size=3><b> Monitoramento </b></font></center>
    <div align=left>
    <table width="60%" border="0" cellpadding=0 cellspacing=0>
    <tr>
    <td width="50%" align=left><b><?echo$datahj;?></b></td>
    <td width="50%" align=left>&nbsp;</td>
    </tr>
    <tr>
    <td width="50%" align=left>&nbsp;</td>
    </tr>
    <tr>
    <td width="50%" align=left>Ligações Atendidas:</td>
    <td width="50%" align=left><?echo$atendidas;?></td>
    </tr>
    <tr>
    <td width="50%" align=left>Ligações Desistentes:</td>
    <td width="50%" align=left><?echo$desistentes;?></td>
    </tr>
    <tr>
    <td width="50%" align=left>Ligações na Fila:</td>
    <td width="50%" align=left><?echo$fila;?></td>
    </tr>
    </table>
    </div>
    <br>
    <table width=100% border="0" align=center cellpadding=0 cellspacing=0>
    <tr>
    <td><font face=arial size=2>
    <table width="100%" border="1" cellspacing="0">
    <tr>
    <td align=center bgcolor="#CCCCCC"> <strong> Ramal </strong></td>
    <td align=center bgcolor="#CCCCCC"> <strong> Agente </strong></td>
    <td align=center bgcolor="#CCCCCC"> <strong> Status </strong></td>
    <td align=center bgcolor="#CCCCCC"> <strong> Telefone </strong></td>
    </tr>
    <tr>
    <?
    $sql="SELECT * FROM agentes order by agente";
    $query=mysql_query($sql,$conexao);
    while ($registro=mysql_fetch_array($query))
    {
    $sql1="SELECT * FROM queue_log where arg1='".$registro["senha"]."' order by time DESC Limit 1";
    $query1=mysql_query($sql1,$conexao);
    $registro1=mysql_fetch_array($query1);

    if ( $registro1["event"] == "AgentePresente" || $registro1["event"] == "AgenteUnPausado" || $registro1["event"] == "AgentePausado" )
    {

    $sql4="SELECT COUNT(id) FROM queue_log where agent='".$registro1["agent"]."' and (event='COMPLETECALLER' or event='COMPLETEAGENT') $data";
    $query4=mysql_query($sql4,$conexao);
    $registro4=mysql_fetch_array($query4);
    $atendidaspagente = $registro4[0];

    $sql2="SELECT * FROM queue_log where event='CONNECT' and agent='".$registro1["agent"]."' order by time DESC Limit 1";
    $query2=mysql_query($sql2,$conexao);
    $registro2=mysql_fetch_array($query2);

    $sql3="SELECT * FROM queue_log where callid='".$registro2["callid"]."' and callid <> '' and (event='COMPLETECALLER' or event='COMPLETEAGENT') order by time DESC Limit 1";
    $query3=mysql_query($sql3,$conexao);
    $registro3=mysql_fetch_array($query3);

    $status = "";
    $telefone = "";

    if ( !empty($registro3[0]) )
    {
    $status = "Disponivel";
    $cor = "#FFFFFF";
    if ($registro1["event"] == "AgentePausado")
    {
    $status = "Agente Pausado";
    $cor = "red";
    }
    } else {
    $sql4="SELECT * FROM queue_log where callid='".$registro2["callid"]."' and event='ENTERQUEUE' order by time DESC Limit 1";
    $query4=mysql_query($sql4,$conexao);
    $registro4=mysql_fetch_array($query4);
    if ( empty($registro4[0]) )
    {
    $status = "Disponivel";
    $cor = "#FFFFFF";
    if ($registro1["event"] == "AgentePausado")
    {
    $status = "Agente Pausado";
    $cor = "red";
    }
    }
    else
    {
    $status = "Falando com ";
    $telefone = $registro4["arg2"];
    $cor = "#FFFF99";
    }
    }

    echo "<tr bgcolor=$cor>";
    echo "<td align=center>".$registro1["agent"],"</td>";
    echo "<td align=center><b>".$registro["agente"]."</b></td>";
    echo "<td align=center>$status</td>";
    echo "<td align=center>$telefone &nbsp;</td>";
    echo "</tr>";
    }
    }
    echo "<br>";
    ?>
    </table>
    </body>
    </html>[/codebox]

    Gostaria de atualizar as escritas das variaveis de 5 em 5 segundos.

    Abraços.

  7. Desculpa pela falta de conteudo.

    Na verdade seria assim:

    Tenho um Texto e quero alterar o valor de parte dele, mas estarei buscando esse valor de um banco de dados.

    Então, acho que teria que ter uma pagina rodando em background e atualizando o valor da pagina principal de X em X segundos.

    Então, ficaria:

    Contador X

    Em uma pagina rodando pegando o valor X do banco Mysql e escrevendo em X.

    Abraços.

  8. Estou procurando e não achei nada, na verdade vi muitos mas nada de entender o codigo.

    Queria algo para colocar um um formulario, que ao clicar em um botão apareça um calendario em pt_BR com navegação de mês e que quando clicar ele preencha o campo.

    E tb com opção de ao clicar ele me redirecionar para uma pagina com os valores da data escolhida para fazer algo como agenda de compromissos.

    Abraços.

×
×
  • Criar Novo...