|
|
|
@ -1,14 +1,16 @@
|
|
|
|
|
<?php |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
include_once 'util/relatoriosBase.php'; |
|
|
|
|
|
|
|
|
|
class RelForaHorario extends Relatorios { |
|
|
|
|
|
|
|
|
|
private $___tipoRelatorio; |
|
|
|
|
|
|
|
|
|
private $___atendimento; |
|
|
|
|
public function __construct($idProg, $dbcon, $incDac) { |
|
|
|
|
parent::__construct($idProg, $dbcon, $incDac); |
|
|
|
|
$this->___tipoRelatorio = isset($_REQUEST['relTipo']) ? $_REQUEST['relTipo'] : 0; |
|
|
|
|
$this->___atendimento = isset($_REQUEST['atendimento']) ? $_REQUEST['atendimento'] : 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function ___FiltrosRelatorio() { |
|
|
|
@ -61,6 +63,7 @@
|
|
|
|
|
$filtro .= '<tr>'; |
|
|
|
|
$filtro .= '<td>Data Inicial</td>'; |
|
|
|
|
$filtro .= '<td>Data Final </td>'; |
|
|
|
|
$filtro .= $this->___tipoRelatorio ? '<td>Opção</td>' : ''; |
|
|
|
|
$filtro .= '<td> <input name="relTipo" type="checkbox" id="relTipo" value="1" %s />Analítico</td>'; |
|
|
|
|
$filtro .= '<td align="center" valign="middle"> </td>'; |
|
|
|
|
$filtro .= '</tr>'; |
|
|
|
@ -71,6 +74,7 @@
|
|
|
|
|
$filtro .= '<tr>'; |
|
|
|
|
$filtro .= '<td><input name="dataIni" id="dataIni" type="text" size="15" maxlength="10" value="%s" onkeyup="formataData(this)" title="dd/mm/aaaa"></td>'; |
|
|
|
|
$filtro .= '<td><input name="dataFim" id="dataFim" type="text" size="15" maxlength="10" value="%s" onkeyup="formataData(this)" title="dd/mm/aaaa"></td>'; |
|
|
|
|
$filtro .= $this->___tipoRelatorio ? sprintf('<td>%s</td>', $this->getAtendimento()) : ''; |
|
|
|
|
$filtro .= '<td><input type="submit" name="btConsulta" id="btConsulta" value="Consultar"></td>'; |
|
|
|
|
$filtro .= '<td>%s</td>'; |
|
|
|
|
$filtro .= '</tr>'; |
|
|
|
@ -89,19 +93,20 @@
|
|
|
|
|
$tipoRel = $this->___tipoRelatorio; |
|
|
|
|
|
|
|
|
|
if ($tipoRel) { |
|
|
|
|
$query = sprintf("select b.calldate as data, b.src as origem, dest.destino as destino, |
|
|
|
|
$query = "select b.calldate as data, b.src as origem, dest.destino as destino, |
|
|
|
|
coalesce(opcs.name, RetornaOpcao(atend.direcao)) as servico, |
|
|
|
|
coalesce( opc.descricao || case when( opc.descricao = atend.destino)then '' else '-' || case when(RetornaOpcao(atend.direcao) = 'ura')then sonumero(atend.direcao) else atend.destino end end, atend.destino) as atendimento, |
|
|
|
|
b.duration as duracao |
|
|
|
|
b.duration as duracao, atend.destino as opcao |
|
|
|
|
from pbx_bilhetes b |
|
|
|
|
left outer join pbx_bilhetes_complemento dest on dest.id = (select min(id) from pbx_bilhetes_complemento where uniqueid2 = b.uniqueid) |
|
|
|
|
left outer join pbx_bilhetes_complemento atend on atend.id = (select max(id) from pbx_bilhetes_complemento where uniqueid2 = b.uniqueid) |
|
|
|
|
left outer join pbx_opcao_acao opc on opc.opcao = RetornaOpcao(atend.direcao) and opc.id::text = sonumero(case when(RetornaOpcao(atend.direcao) = 'ura')then atend.direcao else atend.destino end) |
|
|
|
|
left outer join pbx_opcoes opcs on opcs.value = RetornaOpcao(atend.direcao) |
|
|
|
|
where b.fora_horario = '1' |
|
|
|
|
and b.data_bilhete >= '%s' |
|
|
|
|
and b.data_bilhete <= '%s' |
|
|
|
|
order by b.calldate desc", $dataIni, $dataFim); |
|
|
|
|
and b.data_bilhete >= '$dataIni' |
|
|
|
|
and b.data_bilhete <= '$dataFim' "; |
|
|
|
|
$query .= $this->___atendimento ? " and atend.destino = '{$this->___atendimento}'" : ''; |
|
|
|
|
$query .= " order by b.calldate desc"; |
|
|
|
|
} else { |
|
|
|
|
$query = sprintf("select b.src as origem, data_bilhete as data,count(*) as qtde, |
|
|
|
|
sum(b.duration) as duracao |
|
|
|
@ -547,6 +552,33 @@
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getAtendimento(){ |
|
|
|
|
if($this->___tipoRelatorio){ |
|
|
|
|
|
|
|
|
|
if(!$this->___atendimento){ |
|
|
|
|
unset($_SESSION['SSOpcaoForaHor']); |
|
|
|
|
$_SESSION['SSOpcaoForaHor'] = $this->GetData()[0]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$vst = []; |
|
|
|
|
$select = "<select name='atendimento' id='atendimento' size='1'>"; |
|
|
|
|
$select .= "<option value='0'>-----------</option>"; |
|
|
|
|
foreach($_SESSION['SSOpcaoForaHor'] as $v){ |
|
|
|
|
$slc = null; |
|
|
|
|
|
|
|
|
|
if(!in_array($v['opcao'], $vst)){ |
|
|
|
|
if($this->___atendimento == $v['opcao']){ |
|
|
|
|
$slc = 'selected'; |
|
|
|
|
} |
|
|
|
|
$select .= "<option value='{$v['opcao']}' $slc>{$v['opcao']}</option>"; |
|
|
|
|
$vst[] = $v['opcao']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$select .= "</select>"; |
|
|
|
|
return $select; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function ExecutaRelatorio() { |
|
|
|
|
global $jsStartup, $jsJQuery, $smarty; |
|
|
|
|
try { |
|
|
|
|