forked from SimplesIP/pabx-app
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
174 lines
5.3 KiB
174 lines
5.3 KiB
<?php |
|
include_once 'util/relatoriosBase.php'; |
|
$tpLayout = 1; |
|
|
|
class RelCampBloqueio extends Relatorios { |
|
|
|
private $___uid; |
|
|
|
public function __construct($idProg, $dbcon, $incDac) { |
|
parent::__construct($idProg, $dbcon, $incDac); |
|
$this->___uid = isset($_GET['uid']) ? $_GET['uid'] : ''; |
|
} |
|
|
|
function ___ValidaForm() { |
|
parent::___ValidaForm(); |
|
if (!IsPostBack()) { |
|
return; |
|
} |
|
if ($this->GetIncDac() && !StrToIntDef($this->___dac)) { |
|
GeraExcept('Informe uma Fila!'); |
|
} |
|
} |
|
|
|
function ___FiltrosRelatorio() { |
|
return ""; |
|
} |
|
|
|
protected function ___GetDadosDb() { |
|
$query = "SELECT numero_bloq, tipo_bloq, data_bloq |
|
FROM pbx_kingdialer_bloqueios |
|
WHERE id_camp_bloq = {$this->___uid}"; |
|
|
|
$result = $this->___GetQuery($query); |
|
$row = pg_fetch_all($result); |
|
|
|
$this->SetData($row ? $row : array()); |
|
} |
|
|
|
protected function ___PreparaGrid() { |
|
$dadosCabecalio = array( |
|
'Data' => 'align="center"', |
|
'Número' => 'align="center"', |
|
'Tipo' => 'align="center"' |
|
); |
|
$dadosField = array( |
|
'data_bloq' => 'align="center"', |
|
'numero_bloq' => 'align="center"', |
|
'tipo_bloq' => 'align="center"'); |
|
/* |
|
* Inicia o relatorio. |
|
*/ |
|
$dataRel[] = '<table width="100%" cellpadding="2" class="grid">'; |
|
|
|
/* |
|
* Monta a linha de cabecalio. |
|
*/ |
|
$linhaH = '<tr>'; |
|
foreach ($dadosCabecalio as $key => $value) { |
|
$linhaH .= sprintf("<th %s>%s</th>", $value, $key); |
|
} |
|
$linhaH .= "</tr>"; |
|
$dataRel[] = $linhaH; |
|
|
|
/* |
|
* Verifica se retornou dados |
|
*/ |
|
if (!count($this->GetData()[0])) { |
|
$dataRel[] = sprintf("<tr><td align=\"center\" colspan=\"%s\"><b>%s</b></td></tr></table>", count($dadosCabecalio), (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!')); |
|
$this->___dataRel[] = $dataRel; |
|
return; |
|
} |
|
|
|
/* |
|
* Linhas de dados. |
|
*/ |
|
|
|
foreach ($this->GetData()[0] as $row) { |
|
$row["data_bloq"] = date('d/m/Y H:i:s', strtotime($row["data_bloq"])); |
|
$tipo = "INVÁLIDO"; |
|
switch ($row["tipo_bloq"]){ |
|
case 1: |
|
$tipo = 'PENDENTE'; |
|
break; |
|
case 2: |
|
$tipo = 'DISCADO DIA'; |
|
break; |
|
case 3: |
|
$tipo = '15 DISCAGEM'; |
|
break; |
|
case 4: |
|
$tipo = 'NÚMERO INVÁLIDO'; |
|
break; |
|
|
|
} |
|
$row["tipo_bloq"] = $tipo; |
|
|
|
// Formata linha de dados. |
|
$linha = "<tr>"; |
|
foreach ($dadosField as $key => $value) { |
|
$linha .= sprintf("<td %s>%s</td>", $value, $row["$key"]); |
|
} |
|
$linha .= "</tr>"; |
|
$dataRel[] = $linha; |
|
} |
|
|
|
$dataRel[] = '</table>'; |
|
$this->___dataRel[] = $dataRel; |
|
|
|
|
|
/* |
|
* Fecha relatorio. |
|
*/ |
|
$dataRel1[] = '</table>'; |
|
$this->___dataRel[] = $dataRel1; |
|
} |
|
|
|
public function ExecutaRelatorio() { |
|
global $jsStartup, $jsJQuery, $smarty; |
|
try { |
|
/* |
|
* Use esta fun��o para validar dados do formul�rio. |
|
*/ |
|
$this->___ValidaForm(); |
|
|
|
/* |
|
* Recupera os dados do banco. |
|
*/ |
|
$this->___ConteudoRelatorio(); |
|
|
|
/* |
|
* Imprime relat�rio de acordo com a media passada. |
|
*/ |
|
$conteudoRelatorio = $this->___ImprimeRelatorio(); |
|
} catch (Exception $exc) { |
|
$this->SetMsg($exc->getMessage()); |
|
$jsStartup[] = sprintf("alert('%s');", $this->GetMsg()); |
|
$this->___GravaLog(); |
|
} |
|
|
|
/* |
|
* Inclua os scripts necess�rios aqui. |
|
*/ |
|
$jsJQuery[] = "\$('#dataIni').keypress(function(){formataDataHora(this);}) "; |
|
$jsJQuery[] = "\$('#dataFim').keypress(function(){formataDataHora(this);}) "; |
|
|
|
$smarty->assign('filtros', $this->___FiltrosRelatorio()); |
|
$smarty->assign('conteudo', $conteudoRelatorio); |
|
$smarty->assign('msg', $this->GetMsg()); |
|
GetTemplate($smarty, 'relatoriosGrid.tpl'); |
|
} |
|
|
|
|
|
|
|
protected function ___PreparaExcel() { |
|
|
|
} |
|
|
|
protected function ___PreparaHtml() { |
|
|
|
} |
|
|
|
protected function ___PreparaPdf() { |
|
|
|
} |
|
|
|
protected function ___PreparaCsv() { |
|
|
|
} |
|
|
|
} |
|
|
|
$relAbd = new RelCampBloqueio($idProg, $dbcon, 1); |
|
$relAbd->ExecutaRelatorio(); |
|
?>
|
|
|