forked from SimplesIP/monitorar_simplesip
Compare commits
1 Commits
master
...
teste_moni
Author | SHA1 | Date |
---|---|---|
Rodgger | a555952447 | 4 months ago |
89 changed files with 4639 additions and 28172 deletions
@ -0,0 +1,48 @@
|
||||
{ |
||||
// Use o IntelliSense para saber mais sobre os atributos possíveis. |
||||
// Focalizar para exibir as descrições dos atributos existentes. |
||||
// Para obter mais informações, acesse: https://go.microsoft.com/fwlink/?linkid=830387 |
||||
"version": "0.2.0", |
||||
"configurations": [ |
||||
{ |
||||
"name": "Listen for Xdebug", |
||||
"type": "php", |
||||
"request": "launch", |
||||
"port": 9010 |
||||
}, |
||||
{ |
||||
"name": "Launch currently open script", |
||||
"type": "php", |
||||
"request": "launch", |
||||
"program": "${file}", |
||||
"cwd": "${fileDirname}", |
||||
"port": 0, |
||||
"runtimeArgs": [ |
||||
"-dxdebug.start_with_request=yes" |
||||
], |
||||
"env": { |
||||
"XDEBUG_MODE": "debug,develop", |
||||
"XDEBUG_CONFIG": "client_port=${port}" |
||||
} |
||||
}, |
||||
{ |
||||
"name": "Launch Built-in web server", |
||||
"type": "php", |
||||
"request": "launch", |
||||
"runtimeArgs": [ |
||||
"-dxdebug.mode=debug", |
||||
"-dxdebug.start_with_request=yes", |
||||
"-S", |
||||
"localhost:0" |
||||
], |
||||
"program": "", |
||||
"cwd": "${workspaceRoot}", |
||||
"port": 9003, |
||||
"serverReadyAction": { |
||||
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started", |
||||
"uriFormat": "http://localhost:%s", |
||||
"action": "openExternally" |
||||
} |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,81 @@
|
||||
.date { |
||||
font-weight: bold; |
||||
color: #066bb6; |
||||
} |
||||
|
||||
.info { |
||||
font-size: .95em; |
||||
margin: 0px 0 0px !important; |
||||
color: #148d04; |
||||
} |
||||
|
||||
.tabela { |
||||
border: 1px dashed #066bb6; |
||||
background-position: center center; |
||||
background-color: #EAEAEA; |
||||
} |
||||
|
||||
.cabecalho { |
||||
font-family: Arial, Helvetica, sans-serif; |
||||
font-size: 14px; |
||||
font-weight: bold; |
||||
text-transform: capitalize; |
||||
color: #066BB6; |
||||
background-image: url(../img/button03.gif); |
||||
border: none; |
||||
background-color: #EAEAEA; |
||||
} |
||||
|
||||
.labels { |
||||
font-family: Arial, Helvetica, sans-serif; |
||||
font-size: 10px; |
||||
font-weight: bold; |
||||
color: #006633; |
||||
} |
||||
|
||||
.caixas { |
||||
font-family: Arial, Helvetica, sans-serif; |
||||
font-size: 10px; |
||||
font-style: normal; |
||||
line-height: normal; |
||||
font-weight: bold; |
||||
font-variant: normal; |
||||
text-transform: none; |
||||
color: #333333; |
||||
border: 1px solid #666666; |
||||
} |
||||
|
||||
.fr { |
||||
float: right !important; |
||||
} |
||||
|
||||
.fl { |
||||
float: left !important; |
||||
} |
||||
|
||||
.hidden { |
||||
display: none; |
||||
} |
||||
|
||||
.headColun { |
||||
font-family: Arial, Helvetica, sans-serif; |
||||
font-size: 11px; |
||||
font-weight: bold; |
||||
border-top: 1px solid #000; |
||||
border-bottom: 1px solid #000; |
||||
} |
||||
|
||||
.dados { |
||||
border: 1px solid #CCCCCC; |
||||
font-size: 11px; |
||||
font-weight: bold; |
||||
background-color: #F90; |
||||
border: 1px solid #CCCCCC; |
||||
color: #FFFFFF; |
||||
} |
||||
|
||||
.dadosResult { |
||||
font-family: Arial, Helvetica, sans-serif; |
||||
font-size: 9px; |
||||
border: 1px solid #000000; |
||||
} |
@ -0,0 +1,111 @@
|
||||
.agente |
||||
{ |
||||
border-collapse: collapse; |
||||
border: 1px solid #CCCCCC; |
||||
background-color:#FFFFFF; |
||||
font-family:Arial, Helvetica, sans-serif; |
||||
text-align:center; |
||||
} |
||||
|
||||
.agente th |
||||
{ |
||||
border: 1px solid #CCCCCC; |
||||
font-size:11px; |
||||
font-weight:bold; |
||||
background-color:#F90; |
||||
color:#FFFFFF; |
||||
margin:0; |
||||
padding:0; |
||||
} |
||||
|
||||
.agente td |
||||
{ |
||||
font-size:10px; |
||||
} |
||||
|
||||
.agente a:link, a:visited |
||||
{ |
||||
font-size:11px; |
||||
color:#999999; |
||||
} |
||||
|
||||
#mask-modal { |
||||
position:absolute; |
||||
left:0; |
||||
top:0; |
||||
z-index:9000; |
||||
background-color:#000; |
||||
border: 0; |
||||
display:none; |
||||
padding:0; |
||||
} |
||||
|
||||
#boxes-modal .window-modal { |
||||
position:absolute; |
||||
left:0; |
||||
top:0; |
||||
width:440px; |
||||
height:200px; |
||||
display:none; |
||||
z-index:9999; |
||||
padding:0; |
||||
border: 0; |
||||
} |
||||
|
||||
#boxes-modal #dialog { |
||||
width:550px; |
||||
height:300px; |
||||
padding:0; |
||||
background-color:#f0f0f0; |
||||
border: 3px solid #ccc; |
||||
} |
||||
|
||||
#dadosDiscador |
||||
{ |
||||
border-collapse: collapse; |
||||
background-color:#f0f0f0; |
||||
color: #000; |
||||
} |
||||
|
||||
|
||||
#dadosDiscador th |
||||
{ |
||||
background-color: #F90; |
||||
font-size: small; |
||||
font-weight: bold; |
||||
color: #fff; |
||||
} |
||||
|
||||
#dadosDiscador td |
||||
{ |
||||
font-size: small; |
||||
font-weight: bold; |
||||
color: #000; |
||||
} |
||||
|
||||
#dadosClienteDiscador |
||||
{ |
||||
border-collapse: collapse; |
||||
font-size: small; |
||||
border: 1px solid #999999; |
||||
} |
||||
|
||||
#dadosClienteDiscador th |
||||
{ |
||||
background-color:#CCCCCC; |
||||
font-size: small; |
||||
font-weight: bold; |
||||
color: #000; |
||||
border: 1px solid #999999; |
||||
width: 20%; |
||||
} |
||||
|
||||
#dadosClienteDiscador td |
||||
{ |
||||
font-size: small; |
||||
background-color:#fff; |
||||
font-weight: normal; |
||||
color: #000; |
||||
border: 1px solid #999999; |
||||
width: 20%; |
||||
} |
@ -1,108 +0,0 @@
|
||||
<?php |
||||
|
||||
$tpLayout = 1; |
||||
$template = "cadastros/cliente/clienteAnotacoes.tpl"; |
||||
|
||||
$paramPesquisa = trim(isset($_REQUEST['paramPesquisa']) ? $_REQUEST['paramPesquisa'] : ""); |
||||
$clientAnotacao = trim(isset($_REQUEST['clientAnotacao']) ? $_REQUEST['clientAnotacao'] : ""); |
||||
$dataIni = isset($_REQUEST['dataIni']) ? $_REQUEST['dataIni'] : ""; |
||||
$dataFim = isset($_REQUEST['dataFim']) ? $_REQUEST['dataFim'] : ""; |
||||
$clientId = isset($_REQUEST['client_id']) ? $_REQUEST['client_id'] : ""; |
||||
$clientOutId = isset($_REQUEST['client_out_id']) ? $_REQUEST['client_out_id'] : "0"; |
||||
$ClientRazao = isset($_REQUEST['client_razao']) ? $_REQUEST['client_razao'] : ""; |
||||
$msg = ''; |
||||
|
||||
/* |
||||
* Inserção de uma nova anotacao. |
||||
*/ |
||||
if (isset($_POST["btGravar"]) && $clientAnotacao) { |
||||
$msg = "Erro ao inserir anotação!"; |
||||
$query = sprintf("insert into pbx_cliente_anotacoes(client_id, cla_anotacao, user_reg)values('%s', %s, %s); ", $clientId, QuotedStr($clientAnotacao), GetMatricula()); |
||||
$query .= sprintf("update pbx_cliente set user_reg = %s where client_id = %s; ", GetIdUser(), $clientId); |
||||
$result = pg_query($dbcon, $query); |
||||
|
||||
if ($result && pg_affected_rows($result)) { |
||||
$msg = "Anotação inserida com sucesso!"; |
||||
} |
||||
|
||||
$jsStartup[] = sprintf("alert('%s');", $msg); |
||||
} |
||||
|
||||
/* |
||||
* Pesquisa por palavra chave. |
||||
*/ |
||||
|
||||
$compl = ''; |
||||
if ($paramPesquisa) { |
||||
$compl = PreparaLike($paramPesquisa, true); |
||||
$compl = sprintf("and cla_anotacao ilike %s\n", $compl); |
||||
} |
||||
|
||||
/* |
||||
* Verifica se as datas foram informadas |
||||
*/ |
||||
|
||||
if (is_date($dataIni) && is_date($dataFim)) { |
||||
$compl .= sprintf(" and data_reg::date >= '%s' and data_reg::date <= '%s'\n", FormatDtMssql($dataIni), FormatDtMssql($dataFim)); |
||||
} else if (is_date($dataIni)) { |
||||
$compl .= sprintf(" and data_reg::date >= '%s'\n", FormatDtMssql($dataIni)); |
||||
} else if (is_date($dataFim)) { |
||||
$compl .= sprintf(" and data_reg::date <= '%s'\n", FormatDtMssql($dataFim)); |
||||
} |
||||
|
||||
$query = "SELECT cla_id, cla_anotacao, apelido, data_reg " |
||||
. "FROM pbx_cliente_anotacoes a " |
||||
. "LEFT JOIN pbx_usuarios b ON a.user_reg = b.matricula::INT " |
||||
. "WHERE client_id = '{$clientId}' $compl " |
||||
. "ORDER BY data_reg::timestamp DESC"; |
||||
|
||||
$sql = GetTotalRegistro($dbcon, $query); |
||||
|
||||
$params = sprintf("&client_id=%s&client_razao=%s", $clientId, $ClientRazao); |
||||
$links = PaginaDados($idProg, $sql, $params, $regPagina, $offSet, $pagMostra, true); |
||||
$query .= " limit $regPagina offset $offSet"; |
||||
$result = pg_query($dbcon, $query); |
||||
$dadosCliente = pg_fetch_all($result); |
||||
|
||||
/* |
||||
* Captura os dados relacionados ao venda+. |
||||
*/ |
||||
GetClientVendaMais($clientOutId, $dadosCliente); |
||||
|
||||
$linhas = ""; |
||||
foreach ($dadosCliente as $dados) { |
||||
$claId = $dados["cla_id"]; |
||||
$claAnotacao = $dados["cla_anotacao"]; |
||||
$dataReg = $dados["data_reg"]; |
||||
$getAnotaId = ("anota_" . $claId); |
||||
|
||||
$linhas .= sprintf('<tr> |
||||
<td>%s</td> |
||||
<td align="left" width="120px">%s</td> |
||||
<td align="left"><span id="%s">%s</span></td> |
||||
<td align="left" width="90px"><span>%s</span></td> |
||||
<td align="center"><img src="imgSite/anotacoes.png" width="16" heigth="16" title="Mostrar" border="0" onclick="GetAnotacaoCliente(\'%s\');"></td> |
||||
</tr>', $claId, date('d/m/Y H:i:s',strtotime($dataReg)), $getAnotaId, $claAnotacao, $dados['apelido'], $getAnotaId); |
||||
} |
||||
|
||||
$smarty->assign('erro', $erro); |
||||
$smarty->assign('clientId', $clientId); |
||||
$smarty->assign('ClientRazao', $ClientRazao); |
||||
$smarty->assign('dataIni', $dataIni); |
||||
$smarty->assign('dataFim', $dataFim); |
||||
$smarty->assign("linhas", $linhas); |
||||
$smarty->assign("paramPesquisa", $paramPesquisa); |
||||
$smarty->assign("imgNovo", $imgNovo); |
||||
$smarty->assign("links", $links); |
||||
$smarty->assign("pagMostra", $pagMostra); |
||||
$smarty->assign("totalReg", $totalReg); |
||||
$smarty->assign("status", $statusAtivo); |
||||
$smarty->assign("pgn", $_REQUEST["pgn"]); |
||||
$smarty->assign("bloco", $_REQUEST["bloco"]); |
||||
$smarty->assign("pg", $_REQUEST["pg"]); |
||||
GetTemplate($smarty, $template); |
||||
|
||||
function GetClientVendaMais($clientOutId, $dadosCliente) { |
||||
return; |
||||
} |
||||
|
@ -1,76 +0,0 @@
|
||||
<?php |
||||
|
||||
$client = isset($_REQUEST['client_id']) ? $_REQUEST['client_id'] : ''; |
||||
$nome_cliente = isset($_REQUEST['n']) ? base64_decode($_REQUEST['n']) : ''; |
||||
$tpLayout = 1; |
||||
|
||||
try { |
||||
$cliente = GetAudioCliente($dbcon, $client); |
||||
foreach ($cliente as $value) { |
||||
$url = "http://{$_SERVER['SERVER_ADDR']}/integracao?method=GetAudio&login=user.api&senha=0000&uniqueid={$value["uniqueid"]}&tipo=mp3&tipoRetorno=JSON/STREAM"; |
||||
$audio = "<audio controls preload='none' controlsList=\"download\" reconnect src=\"$url\"></audio>"; |
||||
|
||||
$data_reg = date('d/m/Y H:i:s', strtotime($value['data_reg'])); |
||||
$linha .= sprintf("<tr> |
||||
<td align='center'>%s</td> |
||||
<td align='center'>{$value['src']}</td> |
||||
<td align='center'>{$value['dst']}</td> |
||||
<td align='center'>%s</td> |
||||
<td align='center'>{$value['apelido']}</td> |
||||
<td align='center'>{$value['userfield']}</td> |
||||
<td align='center'>%s</td> |
||||
<td align='center'>{$audio}</td> |
||||
</tr>", date('d/m/Y H:i:s', strtotime($value['calldate'])), SecondToStrTime($value['billsec']), tipoEncerramento($value['evento'])); |
||||
$numReg++; |
||||
} |
||||
|
||||
$color = 'green'; |
||||
} catch (Exception $ex) { |
||||
$message = $ex->getMessage(); |
||||
$color = 'red'; |
||||
} |
||||
|
||||
$smarty->assign("linhas", $linha ? $linha : "<td colspan='15' align='center'><b>Nenhum registro encontrado!</b></td>"); |
||||
$smarty->assign("nome_cliente", $nome_cliente); |
||||
$smarty->assign("client_id", $cliente['client_id']); |
||||
$smarty->assign("contato", ($action == 'edit' ? GetContatoPorId($dbcon, $contato) : '')); |
||||
$smarty->assign("color", $color); |
||||
$smarty->assign("msgErro", $message); |
||||
GetTemplate($smarty, 'cadastros/cliente/clienteAudio.tpl'); |
||||
|
||||
/** |
||||
* Busca o cliente pelo seu ID. |
||||
* @param type $dbcon |
||||
* @param type $cliente |
||||
* @return type |
||||
*/ |
||||
function GetAudioCliente($dbcon, $cliente) { |
||||
$query = "SELECT uniqueid, client_id, calldate, src, dst, apelido, userfield, billsec, evento, data_reg |
||||
FROM pbx_bilhetes a |
||||
INNER JOIN pbx_cliente_audio b ON a.uniqueid = b.uid |
||||
INNER JOIN pbx_eventos_dacs c ON c.uid2 = a.uniqueid |
||||
INNER JOIN pbx_usuarios d ON d.matricula = SUBSTRING(c.agente,7,4) |
||||
WHERE b.client_id = '{$cliente}' |
||||
AND evento IN('COMPLETAAGENT','COMPLETACALLER', 'TRANSFERORIG','BUSYS','NOANSWERS') |
||||
ORDER BY calldate;"; |
||||
|
||||
$result = pg_query($dbcon, $query); |
||||
$rows = pg_fetch_all($result); |
||||
return $rows; |
||||
} |
||||
|
||||
function tipoEncerramento($evento) { |
||||
switch ($evento) { |
||||
case 'COMPLETAAGENT': |
||||
case 'COMPLETACALLER': |
||||
return "ATENDIDA"; |
||||
case 'TRANSFERORIG': |
||||
return "TRANSFERIDA"; |
||||
case 'BUSYS': |
||||
return "OCUPADA"; |
||||
case 'NOANSWERS': |
||||
return "NÃO ATENDIDA"; |
||||
} |
||||
} |
||||
|
||||
?> |
@ -1,252 +0,0 @@
|
||||
<?php |
||||
|
||||
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
||||
$client = isset($_REQUEST['client_id']) ? $_REQUEST['client_id'] : ''; |
||||
$contato = isset($_REQUEST['clc_id']) ? $_REQUEST['clc_id'] : $_SESSION['SSclc_id']; |
||||
|
||||
/** ARMAZENA O REGISTRO BUSCADO * */ |
||||
$_SESSION['SSclc_id'] = ($action == 'edit' ? $contato : ''); |
||||
|
||||
/** COLETA OS DADOS DO POST * */ |
||||
$fieldspost = filter_input_array(INPUT_POST, FILTER_SANITIZE_SPECIAL_CHARS); |
||||
|
||||
/** ADICIONA A MATRICULA DE MODIFICACAO * */ |
||||
$fieldspost['user_reg'] = GetMatricula(); |
||||
$tpLayout = 1; |
||||
|
||||
try { |
||||
|
||||
if (isset($fieldspost['formAcaoDesc']) && $action != 'delete') { |
||||
$data = verifyDataPost($fieldspost); |
||||
if ($data) { |
||||
SetClienteContato($dbcon, $data, $contato); |
||||
flash("O cadastro foi realizado com sucesso!"); |
||||
} |
||||
} |
||||
|
||||
if ($contato && $action == 'delete') { |
||||
deleteContato($dbcon, $contato); |
||||
flash("O contato removido com sucesso!"); |
||||
} |
||||
|
||||
$contatos = GetContatoPorCliente($dbcon, $client); |
||||
$cliente = GetCliente($dbcon, $client); |
||||
|
||||
foreach ($contatos as $value) { |
||||
$clc = "<a href=\"javaScript:NovaJanela('index.php?idProg=346&client_id={$value["client_id"]}&clc_id={$value["clc_id"]}&action=edit', 'contatosCliente', '900', '250', 'jhTela')\"><img src=\"imgSite/editaUser.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"Contatos do cliente ID: $nomeDisp\" title=\"Contatos do cliente ID: $nomeDisp\"></a>"; |
||||
$delete = "<a href=\"javaScript:NovaJanela('index.php?idProg=346&client_id={$value["client_id"]}&clc_id={$value["clc_id"]}&action=delete', 'contatosCliente', '900', '250', 'jhTela')\"><img src=\"imgSite/deletaUser.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"Contatos do cliente ID: $nomeDisp\" title=\"Contatos do cliente ID: $nomeDisp\"></a>"; |
||||
$data_reg = date('d/m/Y H:i:s', strtotime($value['data_reg'])); |
||||
$linha .= sprintf("<tr> |
||||
<td align='center'>{$value['clc_id']}</td> |
||||
<td align='center'>{$value['clc_nome']}</td> |
||||
<td align='center'>{$value['clc_email']}</td> |
||||
<td align='center'>{$value['clc_fone']}</td> |
||||
<td align='center'>{$value['clc_sms']}</td> |
||||
<td align='center'>{$value['clc_whatsapp']}</td> |
||||
<td align='center'>{$value['clc_telegram']}</td> |
||||
<td align='center'>%s</td> |
||||
<td align='center'>%s</td> |
||||
<td align='center'>{$data_reg}</td> |
||||
<td align='center'>{$clc} {$delete}</td> |
||||
</tr>", ($value['clc_contato_principal'] ? '<img src="imgSite/Yes.png">' : '<img src="imgSite/Delete.png">'), GetUsuario($dbcon, $value['user_reg'])['apelido']); |
||||
$numReg++; |
||||
} |
||||
} catch (Exception $ex) { |
||||
flash($ex->getMessage(),'red'); |
||||
} |
||||
|
||||
$flash = flash(); |
||||
$smarty->assign("linhas", $linha ? $linha : "<td colspan='15' align='center'><b>Nenhum registro encontrado!</b></td>"); |
||||
$smarty->assign("nome_cliente", $cliente['client_nome_fantasia']); |
||||
$smarty->assign("client_id", $cliente['client_id']); |
||||
$smarty->assign("contato", ($action == 'edit' ? GetContatoPorId($dbcon, $contato) : '')); |
||||
$smarty->assign("color", $flash[1]); |
||||
$smarty->assign("msgErro", $flash[0]); |
||||
GetTemplate($smarty, 'cadastros/cliente/clienteContatos.tpl'); |
||||
|
||||
/** |
||||
* Funcao para atualizar ou cadastrar um novo contato e alterar seu registro principal. |
||||
* |
||||
* Para a atualização do registro é importante passar o clc_id no parametro $id. |
||||
* |
||||
* O valor do parametro $data é o retorno da funcao verifyDataPost() |
||||
* @param type $dbcon |
||||
* @param type $data |
||||
* @param type $id |
||||
* @throws Exception |
||||
*/ |
||||
function SetClienteContato($dbcon, $data, $id = null) { |
||||
if ($id) { |
||||
$campos = implode(',', array_map(function ($a, $b) { |
||||
return $a . " = " . QuotedStr($b); |
||||
}, array_keys($data), array_values($data))); |
||||
|
||||
$query = " UPDATE pbx_cliente_contato SET $campos WHERE clc_id = '{$id}';"; |
||||
} else { |
||||
$campos = implode(',', array_keys($data)); |
||||
$values = implode(',', array_map(function ($a, $b) { |
||||
return QuotedStr($b); |
||||
}, array_keys($data), array_values($data))); |
||||
|
||||
$query = " INSERT INTO pbx_cliente_contato ($campos) VALUES($values);"; |
||||
} |
||||
|
||||
if (array_key_exists('clc_contato_principal', $data)) { |
||||
$query1 .= " UPDATE pbx_cliente_contato SET clc_contato_principal = 0 WHERE client_id = '{$data['client_id']}' "; |
||||
$query1 .= $id ? " AND clc_id <> '{$id}'; " : ';'; |
||||
} |
||||
|
||||
$result = pg_query($dbcon, $query1 . $query); |
||||
$contato = registraContatoPrincipal($dbcon, $data['client_id']); |
||||
SetClientePrincipal($dbcon, $contato); |
||||
if (!$result) { |
||||
throw new Exception('Não foi possível ' . ($id ? 'atualizar' : 'cadastrar') . ' o registro! Erro: ' . pg_last_error()); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Adiciona um contato como principal mantendo sempre 1 como principal. |
||||
* @param type $dbcon |
||||
* @param type $id |
||||
* @return type |
||||
* @throws Exception |
||||
*/ |
||||
function registraContatoPrincipal($dbcon, $id) { |
||||
$resp = GetContatoPorCliente($dbcon, $id); |
||||
$lastid = null; |
||||
$contato = null; |
||||
foreach ($resp as $v) { |
||||
if ($v['clc_contato_principal']) { |
||||
return $v; |
||||
} else { |
||||
$lastid = $v['clc_id']; |
||||
$contato = $v; |
||||
} |
||||
} |
||||
|
||||
$query = "UPDATE pbx_cliente_contato SET clc_contato_principal = 1 WHERE clc_id = {$lastid};"; |
||||
$result = pg_query($dbcon, $query); |
||||
if (!$result) { |
||||
throw new Exception('Não foi atualizar o registro principal! Erro: ' . pg_last_error()); |
||||
} |
||||
return $contato; |
||||
} |
||||
|
||||
/** |
||||
* Busca o contato pode o cliente; |
||||
* @param type $dbcon |
||||
* @param type $cliente |
||||
* @return type |
||||
*/ |
||||
function GetContatoPorCliente($dbcon, $cliente) { |
||||
$query = "SELECT * FROM pbx_cliente_contato WHERE client_id = '{$cliente}' ORDER BY clc_nome;"; |
||||
$result = pg_query($dbcon, $query); |
||||
$rows = pg_fetch_all($result); |
||||
return $rows; |
||||
} |
||||
|
||||
/** |
||||
* Busca o contato por o contato_id = clc_id |
||||
* @param type $dbcon |
||||
* @param type $clc_id |
||||
* @return type |
||||
*/ |
||||
function GetContatoPorId($dbcon, $clc_id) { |
||||
$query = "SELECT * FROM pbx_cliente_contato WHERE clc_id = '{$clc_id}';"; |
||||
$result = pg_query($dbcon, $query); |
||||
$rows = pg_fetch_assoc($result); |
||||
return $rows; |
||||
} |
||||
|
||||
/** |
||||
* Deleta o contato pelo id. |
||||
* @param type $dbcon |
||||
* @param type $contato |
||||
* @throws Exception |
||||
*/ |
||||
function deleteContato($dbcon, $contato) { |
||||
$query = "DELETE FROM pbx_cliente_contato WHERE clc_id = '{$contato}';"; |
||||
$result = pg_query($dbcon, $query); |
||||
if (!$result) { |
||||
throw new Exception('Não foi possível remover o registro! Erro: ' . pg_last_error()); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Verifica os dados passados no POST conforme o tamanho do campo da tabela. |
||||
* Caso o campo seja inteiro é informado o número 0. |
||||
* @param type $fieldpost |
||||
* @return type |
||||
* @throws Exception |
||||
*/ |
||||
function verifyDataPost($fieldpost) { |
||||
$fields = array( |
||||
array("field" => 'user_reg', "size" => 0, "type" => "int", "require" => true), |
||||
array("field" => 'client_id', "size" => 0, "type" => "int", "require" => true), |
||||
array("field" => 'clc_contato_principal', "size" => 0, "type" => "int", "require" => false), |
||||
array("field" => 'clc_nome', "size" => 128, "type" => "string", "require" => true, "upper" => true), |
||||
array("field" => 'clc_email', "size" => 128, "type" => "string", "require" => false), |
||||
array("field" => 'clc_fone', "size" => 32, "type" => "int", "require" => true), |
||||
array("field" => 'clc_sms', "size" => 32, "type" => "int", "require" => false), |
||||
array("field" => 'clc_whatsapp', "size" => 32, "type" => "int", "require" => false), |
||||
array("field" => 'clc_telegram', "size" => 32, "type" => "int", "require" => false) |
||||
); |
||||
|
||||
$data = array(); |
||||
foreach ($fields as $k => $v) { |
||||
if (array_key_exists($v['field'], $fieldpost) && ((strlen($fieldpost[$v['field']]) > 0 && strlen($fieldpost[$v['field']]) <= $v['size']) || ($v['size'] == 0))) { |
||||
if ($v['type'] == 'int') { |
||||
$data[$v['field']] = soNumero($fieldpost[$v['field']]); |
||||
} else { |
||||
$data[$v['field']] = $v['upper'] ? strtoupper($fieldpost[$v['field']]) : $fieldpost[$v['field']]; |
||||
} |
||||
} else if ($v['require']) { |
||||
flash("É necessário preencher o campo " . ucfirst(str_replace('_', '', str_replace('clc_', '', $v['field']))) . "!", 'red'); |
||||
return false; |
||||
} |
||||
} |
||||
return $data; |
||||
} |
||||
|
||||
/** |
||||
* Busca o cliente pelo seu ID. |
||||
* @param type $dbcon |
||||
* @param type $cliente |
||||
* @return type |
||||
*/ |
||||
function GetCliente($dbcon, $cliente) { |
||||
$query = "SELECT * FROM pbx_cliente WHERE client_id = '{$cliente}';"; |
||||
$result = pg_query($dbcon, $query); |
||||
$rows = pg_fetch_assoc($result); |
||||
return $rows; |
||||
} |
||||
|
||||
/** |
||||
* Atualiza os dados do cliente conforme o contato principal. |
||||
* @param type $dbcon |
||||
* @param type $contato |
||||
* @throws Exception |
||||
*/ |
||||
function SetClientePrincipal($dbcon, $contato) { |
||||
$query = "UPDATE pbx_cliente SET client_telefone = '{$contato['clc_fone']}', " |
||||
. "client_email = '{$contato['clc_email']}', client_nome_contato = '{$contato['clc_nome']}' " |
||||
. " WHERE client_id = '{$contato['client_id']}';"; |
||||
$result = pg_query($dbcon, $query); |
||||
if (!$result) { |
||||
throw new Exception("Não foi possível atualizar o contato do cliente!"); |
||||
} |
||||
} |
||||
|
||||
function flash($message = null, $color = 'green') { |
||||
if ($message) { |
||||
$_SESSION['SSMSGFlash'] = $message; |
||||
$_SESSION['SSMSGFlashColor'] = $color; |
||||
} else { |
||||
$message = $_SESSION['SSMSGFlash']; |
||||
$color = $_SESSION['SSMSGFlashColor']; |
||||
unset($_SESSION['SSMSGFlash'], $_SESSION['SSMSGFlashColor']); |
||||
} |
||||
return array($message, $color); |
||||
} |
||||
|
||||
?> |
@ -1,419 +0,0 @@
|
||||
<?php |
||||
|
||||
/** |
||||
| STATUS DE REGISTRO status_cmpr: |
||||
| |
||||
| 0 = NAO PROCESSADA |
||||
| 1 = PROCESSADA COM SUCESSO |
||||
| 2 = PROCESSADA COM ERRO |
||||
*/ |
||||
require "util/SimpleMail.php"; |
||||
|
||||
$tpLayout = 1; |
||||
$temp = isset($_POST['temp']) ? explode('|', $_POST['temp'])[0] : ''; |
||||
$client = isset($_REQUEST['client_id']) ? $_REQUEST['client_id'] : ''; |
||||
$cmp = isset($_REQUEST['cmp']) ? $_REQUEST['cmp'] : ''; |
||||
$acao = isset($_GET['action']) ? $_GET['action'] : ''; |
||||
$listId = isset($_GET['list_id']) ? $_GET['list_id'] : ''; |
||||
|
||||
define('CONF_MAIL_PATH_TEMPLATE', '/var/www/html/aplicativo/'); |
||||
|
||||
$queryClient = $_SESSION['SSQueryClient']; |
||||
|
||||
try { |
||||
$user = GetUsuario($dbcon, GetMatricula()); |
||||
|
||||
if ($acao == 'finish' && $listId) { |
||||
__SetFinalizarLista($listId); |
||||
} |
||||
|
||||
if ($cmp && $queryClient && isset($_POST['btnEnviar'])) { |
||||
$campanha = __createCamp(); |
||||
__createListaCamp($campanha['cmp_id'], $user, $temp); |
||||
} |
||||
|
||||
if (isset($_POST['btnEnviar']) && $client && !$cmp) { |
||||
sendMailToClient($client, $temp, $user); |
||||
} |
||||
} catch (Exception $ex) { |
||||
flash($ex->getMessage(), 'red'); |
||||
} |
||||
|
||||
if ($cmp) { |
||||
$smarty->assign("listcamp", __GetCampanhaList()); |
||||
} |
||||
|
||||
$dataTemplate = getTemplates(null, $temp); |
||||
$smarty->assign("flash", flash()); |
||||
$smarty->assign("client_id", $client); |
||||
$smarty->assign("templates", $dataTemplate[1]); |
||||
$smarty->assign("templ", formatTemplate($user, $dataTemplate[2], $client)); |
||||
$smarty->assign("cmp", $cmp); |
||||
$smarty->assign("emailfrom", (__GetAdminCampanha(GetMatricula()) ? true : false)); |
||||
GetTemplate($smarty, 'cadastros/cliente/clienteMail.tpl'); |
||||
|
||||
/** |
||||
* - Coleto cliente e faz o envio do email para suas informações da pbx_client; |
||||
* - Anexa as informacoes no tamplate para apresentacao do conteudo enviado. |
||||
* @param type $client |
||||
* @param type $temp |
||||
* @return boolean |
||||
*/ |
||||
function sendMailToClient($client, $temp, $user = null) { |
||||
$data = getClient($client); |
||||
if ($data['client_email'] && $temp) { |
||||
//$nome = $data['client_nome_contato'] ? base64_encode($data['client_nome_contato']) : ''; |
||||
//$telefone = $data['client_telefone'] ? base64_encode($data['client_telefone']) : ''; |
||||
//$agente = $user['nome'] ? base64_encode($user['nome']) : ''; |
||||
//$linkliguegratis = "https://simplesip.com.br/email/liguegratis.php?n={$nome}&t={$telefone}&c={$agente}"; |
||||
|
||||
$dataTempl = array(); |
||||
foreach ($data as $key => $t){ |
||||
$dataTempl['{'.$key.'}'] = $t; |
||||
} |
||||
|
||||
if (sendMail($data['client_email'], $dataTempl, $temp, $user['email'])) { |
||||
flash('E-mail enviado com sucesso!', 'green'); |
||||
return true; |
||||
} |
||||
} |
||||
flash('Não foi possível enviar o e-mail para o solicitante!', 'red'); |
||||
return false; |
||||
} |
||||
|
||||
/** |
||||
* Faz o envio de email de modo unitário. |
||||
* @param type $email |
||||
* @param type $data |
||||
* @param type $template |
||||
* @return boolean |
||||
*/ |
||||
function sendMail($email, $data, $template, $colabMail) { |
||||
$templ = getTemplates($template); |
||||
$param = __GetParam(); |
||||
$simple = new SimpleMail($param['user_param'], $param['password_param'], utf8_encode($templ['subject_tpl'])); |
||||
$simple->config($param['host_param'], $param['port_param'], utf8_encode($templ['title_tpl'])); |
||||
$simple->setFrom(($colabMail ? $colabMail : $param['user_from'])); |
||||
$simple->pathBodyMail(CONF_MAIL_PATH_TEMPLATE . $templ['path_tpl'], $data); |
||||
if ($simple->mailing($email)) { |
||||
return true; |
||||
} |
||||
flash('Não foi possível enviar o e-mail para o solicitante!' . $simple->getErrorSend(), 'red'); |
||||
return false; |
||||
} |
||||
|
||||
/** |
||||
* busca as infomacoes do cliente |
||||
* @param type $client |
||||
* @return type |
||||
*/ |
||||
function getClient($client) { |
||||
global $dbcon; |
||||
$query = "SELECT * FROM pbx_cliente a |
||||
LEFT JOIN pbx_usuarios b ON a.client_user_contato = b.matricula |
||||
WHERE client_id = {$client}"; |
||||
$result = pg_query($dbcon, $query); |
||||
return pg_fetch_assoc($result); |
||||
} |
||||
|
||||
/** |
||||
* Retorna uma array de template associativo caso passe o parametro $tpl se não |
||||
* irá retornar um array com um select formatado em html. |
||||
* @param type $tpl |
||||
* @param type $select |
||||
* @return type |
||||
*/ |
||||
function getTemplates($tpl = null, $select = null) { |
||||
global $dbcon,$user,$client; |
||||
$query = "SELECT * FROM pbx_campanha_template"; |
||||
$query .= $tpl ? " WHERE id_tpl = {$tpl} " : ''; |
||||
$query .= " ORDER BY nome_tpl "; |
||||
$result = pg_query($dbcon, $query); |
||||
|
||||
if ($tpl) { |
||||
return pg_fetch_assoc($result); |
||||
} |
||||
|
||||
$data = pg_fetch_all($result); |
||||
if ($data) { |
||||
$opt = "<select name='temp' id='selecttemplate' onclick=\"viewTemplate()\">"; |
||||
foreach ($data as $vl) { |
||||
$selected = $select == $vl['id_tpl'] ? 'selected' : ''; |
||||
$opt .= sprintf("<option value='{$vl['id_tpl']}|%s' $selected>{$vl['nome_tpl']}</option>", formatTemplate($user, $vl['path_tpl'], $client)); |
||||
} |
||||
$opt .= "</select>"; |
||||
} |
||||
return array($data, $opt, $data[0]['path_tpl']); |
||||
} |
||||
|
||||
function formatTemplate($user, $template, $client = null) { |
||||
if($client){ |
||||
$data = getClient($client); |
||||
} else { |
||||
$data = array('client_nome_contato' => 'CLIENTE', 'nome' => $user['nome']); |
||||
} |
||||
|
||||
$json = json_encode($data); |
||||
return sprintf("mail_template.php?t=%s&d=%s", base64_encode($template), base64_encode($json)); |
||||
} |
||||
|
||||
function flash($message = null, $color = 'green') { |
||||
if ($message) { |
||||
$_SESSION['SSMSGFlash'] = $message; |
||||
$_SESSION['SSMSGFlashColor'] = $color; |
||||
} else { |
||||
$message = $_SESSION['SSMSGFlash']; |
||||
$color = $_SESSION['SSMSGFlashColor']; |
||||
unset($_SESSION['SSMSGFlash'], $_SESSION['SSMSGFlashColor']); |
||||
} |
||||
return array($message, $color); |
||||
} |
||||
|
||||
############################################################################ |
||||
######## CRIACAO DE CAMPANHA E LISTA ######## |
||||
############################################################################ |
||||
|
||||
/** |
||||
* Cria uma nova campanha |
||||
* @param type $descricao |
||||
* @param type $dac |
||||
* @throws Exception |
||||
*/ |
||||
function __createCamp() { |
||||
global $dbcon; |
||||
|
||||
try { |
||||
__transaction('BEGIN;'); |
||||
|
||||
$query = "SELECT cmp_id FROM pbx_campanha WHERE cmp_descricao = 'CAMPANHA_SERVICE_MAIL'"; |
||||
$result = pg_query($dbcon, $query); |
||||
$res = pg_fetch_assoc($result); |
||||
|
||||
if (!$res['cmp_id']) { |
||||
$query = "INSERT INTO pbx_campanha(cmp_descricao, cmp_ramal, id_dac, cmp_aguarda_agente, cmp_numero_ligacoes_agente, ident_proc, cmp_status, cmp_tipo_campanha, cmp_seletiva) |
||||
VALUES(%s,'-1',%s,'1','1',%s,'2','3','1') RETURNING cmp_id;"; |
||||
$query = sprintf($query, QuotedStr('CAMPANHA_SERVICE_MAIL'), QuotedStr('00'), QuotedStr('Inserido: listacampanhaemail Data: ' . date('Y-m-d H:i:s'))); |
||||
|
||||
$result = pg_query($dbcon, $query); |
||||
$res = pg_fetch_assoc($result); |
||||
if (!$result) { |
||||
throw new Exception("[ERROR CAMPANHA 001] - Não foi possível criar a campanha!"); |
||||
} |
||||
} |
||||
|
||||
__transaction('COMMIT;'); |
||||
flash('Campanha criada com sucesso!', 'green'); |
||||
|
||||
return $res; |
||||
} catch (Exception $ex) { |
||||
__transaction('ROLLBACK;'); |
||||
flash($ex->getMessage(), 'red'); |
||||
} |
||||
|
||||
return false; |
||||
} |
||||
|
||||
/** |
||||
* Cria as listas com as informacoes dos clientes e suas expecificacoes, como, display de agente, contatos, lista de telefone e permissoes de campanha. |
||||
* Tabelas: |
||||
* > pbx_campanha |
||||
* > pbx_campanha_lista |
||||
* > pbx_campanha_contato |
||||
* > pbx_campanha_contato_fone |
||||
* > pbx_campanha_usuarios |
||||
* |
||||
* @param type $cmp_id |
||||
* @throws Exception |
||||
*/ |
||||
function __createListaCamp($cmp_id, $user, $temp) { |
||||
global $dbcon; |
||||
$regfail = 0; |
||||
$regsuccess = 0; |
||||
|
||||
try { |
||||
__transaction('BEGIN;'); |
||||
|
||||
$nomelist = "CMP-EMAIL_" . date('d-m-Y_H-i-s'); |
||||
/** |
||||
* Table: pbx_campanha_lista |
||||
* CRIA UM LISTA PARA A CAMPANHA |
||||
*/ |
||||
$sql = "INSERT INTO pbx_campanha_lista(cmp_id, list_nome, list_file, list_status, id_usuario, list_id_tpl) VALUES('{$cmp_id}', '{$nomelist}', '{$nomelist}', '1', '{$user['id']}', {$temp}) RETURNING list_id;"; |
||||
$result = pg_query($dbcon, $sql); |
||||
|
||||
if (!$result) { |
||||
__transaction('ROLLBACK;'); |
||||
throw new Exception("[ERROR LIST 003] - Não foi possível criar a lista para campanha!" . pg_result_error($result)); |
||||
} |
||||
$lstCamp = pg_fetch_assoc($result); |
||||
__transaction('COMMIT;'); |
||||
|
||||
$data = __getClientCamp(); |
||||
|
||||
/** |
||||
* @pbx_campanha_contato |
||||
* BUSCA TODOS OS CLIENTE PARA INSERIR NA LISTA DE CONTATO |
||||
*/ |
||||
foreach ($data as $value) { |
||||
if ($value['client_email']) { |
||||
__transaction('BEGIN;'); |
||||
|
||||
$nomeContato = $value['client_nome_contato'] ? $value['client_nome_contato'] : '-'; |
||||
$telefone = $value['client_telefone'] ? $value['client_telefone'] : ($value['client_celular'] ? $value['client_celular'] : ''); |
||||
|
||||
/** LOCAL PARA CRIAR REGRAS DE ENVIOS */ |
||||
/** FIM DA REGRA */ |
||||
/** @pbx_campanha_contato */ |
||||
$query1 = sprintf(" INSERT INTO pbx_campanha_contato(cmp_id, list_id, cont_identificador, cont_param1, cont_param2, cont_param3, cont_param4, cont_status, conf_matricula_exclusiva) " |
||||
. "VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s) RETURNING cont_id; ", |
||||
QuotedStr($cmp_id), |
||||
QuotedStr($lstCamp['list_id']), |
||||
QuotedStr($value['client_id']), |
||||
QuotedStr($nomeContato), |
||||
QuotedStr($value['client_razao_social']), |
||||
QuotedStr($value['client_documento']), |
||||
QuotedStr($telefone), |
||||
QuotedStr(0), |
||||
QuotedStr($value['client_user_contato'])); |
||||
$result = pg_query($dbcon, $query1); |
||||
|
||||
if (!$result) { |
||||
__transaction('ROLLBACK;'); |
||||
continue; |
||||
} |
||||
$cont_id = pg_fetch_assoc($result)['cont_id']; |
||||
|
||||
/** @pbx_campanha_contato_fone */ |
||||
$query2 = sprintf(" INSERT INTO pbx_campanha_contato_fone(cmp_id, list_id, cont_id, conf_fone, conf_status, conf_status_lista, conf_discado) " |
||||
. "VALUES(%s, %s, %s, %s, %s, %s, %s) RETURNING conf_id;", |
||||
QuotedStr($cmp_id), |
||||
QuotedStr($lstCamp['list_id']), |
||||
QuotedStr($cont_id), |
||||
QuotedStr($value['client_email']), |
||||
QuotedStr(0), |
||||
QuotedStr(1), |
||||
QuotedStr(0) |
||||
); |
||||
$result = pg_query($dbcon, $query2); |
||||
|
||||
if (!$result) { |
||||
$regfail++; |
||||
__transaction('ROLLBACK;'); |
||||
continue; |
||||
} |
||||
$conf_id = pg_fetch_assoc($result)['conf_id']; |
||||
|
||||
/** @pbx_campanha_registro */ |
||||
$query3 = "INSERT INTO pbx_campanha_registro (list_id, cont_id, conf_id, ctp_id, matricula_exclusiva, contato_cmpr, status_cmpr, inicio_cmpr, user_reg) VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s)"; |
||||
$query = sprintf($query3, |
||||
QuotedStr($lstCamp['list_id']), |
||||
QuotedStr($cont_id), |
||||
QuotedStr($conf_id), |
||||
'3', |
||||
QuotedStr($value['client_user_contato']), |
||||
QuotedStr($value['client_email']), |
||||
'0', |
||||
QuotedStr(date('Y-m-d H:i:s')), |
||||
QuotedStr($user['id'])); |
||||
$result = pg_query($dbcon, $query); |
||||
|
||||
if (!$result) { |
||||
__transaction('ROLLBACK;'); |
||||
continue; |
||||
} |
||||
$regsuccess++; |
||||
|
||||
__transaction('COMMIT;'); |
||||
} else { |
||||
$regfail++; |
||||
} |
||||
} |
||||
|
||||
if ($regsuccess) { |
||||
flash("A campanha foi registrado com sucesso! Criados: {$regsuccess} Regeitados: {$regfail}.", 'green'); |
||||
} else { |
||||
$query = "DELETE FROM pbx_campanha_lista WHERE list_id = {$lstCamp['list_id']};"; |
||||
pg_query($dbcon, $query); |
||||
flash("Nenhum registro foi adicionado a campanha! Criados: {$regsuccess} Regeitados: {$regfail}", 'red'); |
||||
} |
||||
} catch (Exception $ex) { |
||||
flash($ex->getMessage(), 'red'); |
||||
} |
||||
} |
||||
|
||||
function __GetAdminCampanha($matricula) { |
||||
$query = "SELECT * FROM pbx_fornecedor_permissao WHERE matricula_permissao = '$matricula'"; |
||||
$result = pg_query($query); |
||||
$resp = pg_fetch_assoc($result); |
||||
return $resp; |
||||
} |
||||
|
||||
function __getClientCamp() { |
||||
global $dbcon; |
||||
|
||||
$result = pg_query($dbcon, $_SESSION['SSQueryClient']); |
||||
$data = pg_fetch_all($result); |
||||
if (!$result || !$data) { |
||||
throw new Exception('Nenhum cliente selecionado para a criação da lista!'); |
||||
} |
||||
return $data; |
||||
} |
||||
|
||||
function __GetParam() { |
||||
global $dbcon; |
||||
$query = "SELECT * FROM pbx_campanha_parametros"; |
||||
$result = pg_query($dbcon, $query); |
||||
return pg_fetch_assoc($result); |
||||
} |
||||
|
||||
function __SetFinalizarLista($listId) { |
||||
global $dbcon; |
||||
$query = "UPDATE pbx_campanha_lista SET list_status = 2 WHERE list_id = {$listId};"; |
||||
$result = pg_query($dbcon, $query); |
||||
if (!$result) { |
||||
throw new Exception('Não foi possível para a campanha em execução!'); |
||||
} |
||||
} |
||||
|
||||
function __GetCampanhaList() { |
||||
global $dbcon; |
||||
|
||||
$query = sprintf("SELECT b.list_id, b.data_reg, list_status, SUM(CASE WHEN(conf_discado = 1)THEN 1 ELSE 0 END) AS enviados, count(*) AS total |
||||
FROM pbx_campanha a |
||||
INNER JOIN pbx_campanha_lista b ON b.cmp_id = a.cmp_id |
||||
INNER JOIN pbx_campanha_contato c ON b.list_id = c.list_id |
||||
INNER JOIN pbx_campanha_contato_fone d ON c.cont_id = d.cont_id |
||||
INNER JOIN pbx_cliente e ON e.client_id = c.cont_identificador::INT |
||||
LEFT JOIN pbx_usuarios f ON f.matricula = e.client_user_contato |
||||
WHERE list_id_tpl IS NOT NULL |
||||
AND conf_status_lista = '1' |
||||
AND cmp_tipo_campanha = 3 |
||||
%s |
||||
GROUP BY b.list_id, b.data_reg, list_status |
||||
ORDER BY list_id DESC", (!IsAdmin() ? "AND b.id_usuario = " . GetIdUser() : '')); |
||||
|
||||
$result = pg_query($dbcon, $query); |
||||
$data = pg_fetch_all($result); |
||||
|
||||
$tbl = "<table width=\"50%\" id=\"tblResult\" align=\"center\" cellspacing=\"0\" cellpadding=\"2\" class=\"grid\">"; |
||||
$tbl .= "<tr> <th>Lista ID</th> <th>Data Hora</th> <th>Status</th> <th>Enviados</th> <th>Não Enviados</th> <th>Total</th> <th>FINALIZAR</th></tr>"; |
||||
foreach ($data as $list) { |
||||
$tbl .= "<tr align=\"center\">"; |
||||
$tbl .= "<td>{$list['list_id']}</td>"; |
||||
$tbl .= sprintf("<td>%s</td>", date('d/m/Y H:i:s', strtotime($list['data_reg']))); |
||||
$tbl .= sprintf("<td>%s</td>", ($list['list_status'] == '2' ? "<img src='imgSite/Yes.png'>" : "<img src='imgSite/ampulheta.png'>")); |
||||
$tbl .= "<td>{$list['enviados']}</td>"; |
||||
$tbl .= sprintf("<td>%s</td>", ($list['total'] - $list['enviados'])); |
||||
$tbl .= "<td>{$list['total']}</td>"; |
||||
$tbl .= sprintf("<td>%s</td>", ($list['list_status'] == '2' ? "<img title='ESSA CAMPANHA JÁ FOI FINALIZADA!' src='imgSite/Info.png'>" : "<a href='index.php?idProg=349&cmp=1&action=finish&list_id={$list['list_id']}'><img src='imgSite/Stop sign.png'></a>")); |
||||
$tbl .= "</tr>"; |
||||
} |
||||
$tbl .= "</table>"; |
||||
return $tbl; |
||||
} |
||||
|
||||
function __transaction($type) { |
||||
global $dbcon; |
||||
pg_query($dbcon, $type); |
||||
} |
||||
|
@ -1,78 +0,0 @@
|
||||
<?php |
||||
|
||||
/** @popup * */ |
||||
$tpLayout = 1; |
||||
|
||||
/** COLETA OS DADOS DO POST * */ |
||||
$fieldspost = filter_input_array(INPUT_POST, FILTER_SANITIZE_SPECIAL_CHARS); |
||||
|
||||
try { |
||||
$param = GetParam(); |
||||
|
||||
if (isset($fieldspost['bt_gravar'])) { |
||||
SetParam($fieldspost); |
||||
} |
||||
} catch (Exception $ex) { |
||||
flash($ex->getMessage(), 'red'); |
||||
} |
||||
|
||||
$smarty->assign("flash", flash()); |
||||
$smarty->assign("param", $param); |
||||
GetTemplate($smarty, 'cadastros/cliente/clienteSMTP.tpl'); |
||||
|
||||
function GetParam() { |
||||
global $dbcon; |
||||
$query = "SELECT * FROM pbx_campanha_parametros"; |
||||
$result = pg_query($dbcon, $query); |
||||
return pg_fetch_assoc($result); |
||||
} |
||||
|
||||
function SetParam($param) { |
||||
global $dbcon; |
||||
|
||||
if (!$param['id_param']) { |
||||
$query = "INSERT INTO pbx_campanha_parametros (host_param, user_param, password_param, port_param, secure_param, charset_param, auth_param, from_param) " |
||||
. "VALUES(%s, %s, %s, %s, %s, %s, %s, %s) RETURNING id_param;"; |
||||
} else { |
||||
$query = "UPDATE pbx_campanha_parametros SET " |
||||
. "host_param = %s," |
||||
. "user_param = %s," |
||||
. "password_param = %s," |
||||
. "port_param = %s," |
||||
. "secure_param = %s," |
||||
. "charset_param = %s," |
||||
. "auth_param = %s," |
||||
. "from_param = %s, " |
||||
. "update_reg = '" . date('Y-m-d H:i:s') . "' WHERE id_param = {$param['id_param']}"; |
||||
} |
||||
|
||||
$query = sprintf($query, |
||||
QuotedStr($param['host_param']), |
||||
QuotedStr($param['user_param']), |
||||
QuotedStr($param['password_param']), |
||||
QuotedStr($param['port_param']), |
||||
QuotedStr(($param['secure_param'] ? $param['secure_param'] : 'TLS')), |
||||
QuotedStr(($param['charset_param'] ? $param['charset_param'] : 'UTF8')), |
||||
QuotedStr(($param['auth_param'] ? $param['auth_param'] : 0)), |
||||
QuotedStr($param['from_param'])); |
||||
|
||||
$result = pg_query($dbcon, $query); |
||||
|
||||
if (!$result) { |
||||
throw new Exception("Não foi possível " . ($param['id_param'] ? "atualizar" : "criar") . " o registro! Erro: " . pg_last_error()); |
||||
} |
||||
flash("O registro foi " . ($param['id_param'] ? "atualizado" : "criado") . " com sucesso!", 'green'); |
||||
} |
||||
|
||||
function flash($message = null, $color = 'green') { |
||||
if ($message) { |
||||
$_SESSION['SSMSGFlash'] = $message; |
||||
$_SESSION['SSMSGFlashColor'] = $color; |
||||
} else { |
||||
$message = $_SESSION['SSMSGFlash']; |
||||
$color = $_SESSION['SSMSGFlashColor']; |
||||
unset($_SESSION['SSMSGFlash'], $_SESSION['SSMSGFlashColor']); |
||||
} |
||||
return array($message, $color); |
||||
} |
||||
|
@ -1,13 +0,0 @@
|
||||
<?php |
||||
|
||||
define('CONF_MAIL_LIMIT', 50); |
||||
|
||||
define('CONF_MAIL_HOST', 'mail.simplesip.com.br'); |
||||
define('CONF_MAIL_PORT', '587'); |
||||
|
||||
define('CONF_MAIL_TITLE', 'SIMPLES IP'); |
||||
define('CONF_MAIL_SENDER', 'marketing@simplesip.com.br'); |
||||
define('CONF_MAIL_PASSWD', '$m@rk2t3ng_#'); |
||||
define('CONF_MAIL_SUBJECT', utf8_encode('SEU PABX PODE SER UMA MAQUINA DE FAZER VENDAS, VEJA COMOO É FÁCIL!!')); |
||||
|
||||
define('CONF_MAIL_PATH_TEMPLATE', '/var/www/html/aplicativo/'); |
@ -1,146 +0,0 @@
|
||||
<?php |
||||
|
||||
/* |
||||
* |
||||
* Prepara form |
||||
*/ |
||||
$template = "contribuinte.tpl"; |
||||
$tpLayout = 1; |
||||
|
||||
if (GetFormAcao() == FORM_NEW) { |
||||
$tpIdent = TIPO_IDENTIFICA_CNPJ; |
||||
$acaoForm = FORM_INSERT; |
||||
|
||||
$smarty->assign("client_status", GetStatusProspect($_POST["client_status"])); |
||||
$smarty->assign("client_tipo_contato", GetClientTipoContato("0")); |
||||
if ($_SESSION["txtConsulta"]) |
||||
$smarty->assign("client_telefone", $_SESSION["txtConsulta"]); |
||||
} else { |
||||
$msgForm = array(); |
||||
|
||||
if (!validaForm($fields, $fieldsObrig, $fieldsType, $fieldsDiplay, $msgForm)) { |
||||
$acaoForm = FORM_INSERT; |
||||
$tpIdent = $_POST["client_tipo_documento"]; |
||||
|
||||
//formata mensagem de erro para script |
||||
$msgRet = ""; |
||||
foreach ($msgForm as $value) |
||||
$msgRet .= "\\n" . $value; |
||||
|
||||
$jsStartup[] = "alert('$msgRet');"; |
||||
|
||||
//formata mensagem de erro para o form |
||||
$msgRet = ""; |
||||
foreach ($msgForm as $value) |
||||
$msgRet .= $value . " "; |
||||
|
||||
//erros no form |
||||
$smarty->assign("msgErro", $msgRet); |
||||
$_POST["client_status"] = GetStatusProspect($_POST["client_status"]); |
||||
$_POST["client_tipo_contato"] = GetClientTipoContato($_POST["client_tipo_contato"]); |
||||
|
||||
$smarty->assign("client_status", $_POST["client_status"]); |
||||
$smarty->assign("client_tipo_contato", $_POST["client_tipo_contato"]); |
||||
|
||||
//valores no form |
||||
$smarty->assign('client_class', GetClassificacaoVendas($_POST["client_class"])); |
||||
$smarty->assign('client_agendamento', date('d/m/Y', strtotime($_POST["client_agendamento"]))); |
||||
|
||||
foreach ($fields as $value) |
||||
$smarty->assign($value, $_POST[$value]); |
||||
} else { |
||||
$acaoForm = FORM_INSERT; |
||||
$query = "select max(client_id) from pbx_cliente"; |
||||
$result = pg_query($dbcon, $query); |
||||
$row = @pg_fetch_row($result); |
||||
|
||||
$id = $row[0] ? $row[0] + 1 : 1; |
||||
$razao = QuotedStr(strtoupper($_POST["client_razao_social"])); |
||||
|
||||
$documento = trim($_POST["client_documento"]); |
||||
$documento = !$documento ? "null" : QuotedStr($documento); |
||||
|
||||
$email = trim($_POST["client_email"]); |
||||
$email = !$email ? "null" : QuotedStr($email); |
||||
|
||||
$status = QuotedStr($_POST["client_status"]); |
||||
|
||||
$contato = trim($_POST["client_nome_contato"]); |
||||
$contato = !$contato ? "null" : QuotedStr(strtoupper($_POST["client_nome_contato"])); |
||||
|
||||
$tpContato = trim($_POST["client_tipo_contato"]); |
||||
$tpContato = !$tpContato ? "null" : QuotedStr($_POST["client_tipo_contato"]); |
||||
|
||||
$fone = soNumero($_POST["client_telefone"]); |
||||
$fone = !$fone ? "null" : QuotedStr($fone); |
||||
|
||||
$agendamento = $_POST["client_agenda"]; |
||||
$agendamento = !$agendamento ? "null" : QuotedStr(FormatDtMssql($agendamento)); |
||||
|
||||
$classificacao = sonumero($_POST["client_class"]); |
||||
$classificacao = !$classificacao ? '0' : QuotedStr($classificacao); |
||||
|
||||
$obs = trim($_POST["client_obs"]) ? QuotedStr(trim($_POST["client_obs"])) : ''; |
||||
|
||||
$user_contato = QuotedStr(GetMatricula()); |
||||
|
||||
$query = "insert into pbx_cliente(client_id, client_razao_social, client_status, client_email, client_nome_contato, client_telefone, client_tipo_contato, client_agendamento, client_class, client_documento, client_user_contato) |
||||
values( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) RETURNING client_id;"; |
||||
$query = sprintf($query, $id, $razao, $status, $email, $contato, $fone, $tpContato, $agendamento, $classificacao, $documento, $user_contato); |
||||
|
||||
$result = pg_query($dbcon, $query); |
||||
$resp = pg_fetch_assoc($result); |
||||
|
||||
if ($obs) { |
||||
$sql = "INSERT INTO pbx_cliente_anotacoes (client_id, cla_anotacao, user_reg) VALUES(%s, %s, %s);"; |
||||
$sql = sprintf($sql, $resp['client_id'], $obs, $user_contato); |
||||
pg_query($dbcon, $sql); |
||||
} |
||||
|
||||
$_POST["client_status"] = GetStatusProspect($_POST["client_status"]); |
||||
$_POST["client_tipo_contato"] = GetClientTipoContato($_POST["client_tipo_contato"]); |
||||
|
||||
$smarty->assign("client_status", $_POST["client_status"]); |
||||
$smarty->assign("client_tipo_contato", $_POST["client_tipo_contato"]); |
||||
//valores no form |
||||
foreach ($fields as $value) |
||||
$smarty->assign($value, $value == "client_id" ? $id : $_POST[$value]); |
||||
|
||||
$tpIdent = $tipo; |
||||
if ($result) { |
||||
$acaoForm = FORM_SAVE; |
||||
$msgRet = "Registro inserido com sucesso!"; |
||||
$jsStartup[] = "window.opener.ResetForm();"; |
||||
$_SESSION["txtConsulta"] = ""; |
||||
if ($_SESSION["selContrib"]) { |
||||
$_SESSION["selContrib"] = false; |
||||
$nome = $_POST["client_razao_social"]; |
||||
$_SESSION["contribRef"] = "$id - $nome"; |
||||
$jsStartup[] = "window.opener.ChamSetContribuinte('$id','$nome');"; |
||||
//$jsStartup[] = "window.opener.document.formGeral.txtConsulta.value = \"$id-$nome\";"; |
||||
$jsStartup[] = "window.close();"; |
||||
} else { |
||||
$jsStartup[] = "alert('$msgRet');"; |
||||
$smarty->assign("msg", $msgRet); |
||||
} |
||||
} else { |
||||
$msgRet = "A operação não pode ser realizada!"; |
||||
$jsStartup[] = "alert('$msgRet');"; |
||||
$msgRet .= pg_last_error() ? " Erro: " . pg_last_error() : ""; |
||||
$smarty->assign("msgErro", $msgRet); |
||||
} |
||||
} |
||||
} |
||||
|
||||
function ExisteContribuinte($id, &$msg) { |
||||
$sql = "select count(*) from pbx_cliente where client_documento = '$id'"; |
||||
$result = pg_query($sql); |
||||
$row = @pg_fetch_row($result); |
||||
if ($row[0] > 0) { |
||||
$msg[] = "Identificação já cadastrada!"; |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
?> |
@ -1,357 +0,0 @@
|
||||
<?php |
||||
|
||||
$paramPesquisa = isset($_REQUEST['paramPesquisa']) ? $_REQUEST['paramPesquisa'] : ''; |
||||
$filtro = trim(isset($_REQUEST["paramPesquisa"]) ? trim($_REQUEST["paramPesquisa"]) : ''); |
||||
$cloid = trim(isset($_REQUEST["clo_id"]) ? trim($_REQUEST["clo_id"]) : ''); |
||||
$clientTipoContato = trim(isset($_REQUEST["client_tipo_contato"]) ? trim($_REQUEST["client_tipo_contato"]) : ''); |
||||
$clientEtapa = ($_REQUEST["client_etapa"] != "-1") ? trim($_REQUEST["client_etapa"]) : '1'; |
||||
$clientStatus = ($_REQUEST["client_status"] != "-1") ? trim($_REQUEST["client_status"]) : '-1'; |
||||
$clientUf = trim(isset($_REQUEST["client_uf"]) ? trim($_REQUEST["client_uf"]) : ''); |
||||
$clientAgenda = trim(isset($_REQUEST["client_agenda"]) ? trim($_REQUEST["client_agenda"]) : ''); |
||||
$dataIni = isset($_REQUEST['dataIni']) && is_date($_REQUEST['dataIni']) ? $_REQUEST['dataIni'] : ''; |
||||
$dataFim = isset($_REQUEST['dataFim']) && is_date($_REQUEST['dataFim']) ? $_REQUEST['dataFim'] : ''; |
||||
$tipoDataSet = isset($_REQUEST['tipoDataSet']) ? $_REQUEST['tipoDataSet'] : 'Contato'; |
||||
$client_user_contato = isset($_REQUEST['client_user_contato']) ? $_REQUEST['client_user_contato'] : ''; |
||||
|
||||
/** |
||||
* Dados para ser passado via AJAX |
||||
*/ |
||||
$action = isset($_GET['action']) ? $_GET['action'] : null; |
||||
$ajax = isset($_GET['ajax']) ? $_GET['ajax'] : null; |
||||
$data = isset($_GET['data']) ? $_GET['data'] : null; |
||||
|
||||
if ($ajax && $action) { |
||||
if ($action == 'sendmail') { |
||||
echo enviarMailCampanha($data, $dbcon); |
||||
} |
||||
|
||||
if ($action == 'addvendamais') { |
||||
$conn = ConectaMssql(); |
||||
echo ExportaContato($conn, $data); |
||||
} |
||||
exit(); |
||||
} |
||||
|
||||
if (!isset($acao)) { |
||||
$acao = FORM_SELECT; |
||||
} |
||||
|
||||
$filtroNovo = !isset($_REQUEST["pgn"]) ? '' : sprintf("¶mPesquisa%s&pgn=%s&bloco=%s&pg=%s", $_REQUEST["paramPesquisa"], $_REQUEST["pgn"], $_REQUEST["bloco"], $_REQUEST["pg"]); |
||||
|
||||
$recontaPag = ($acao == 'inseri') || (GetFormAcao() == FORM_DELETE) || isset($_POST['pesquisa']); |
||||
|
||||
$refresh = false; |
||||
if (GetFormAcao() == FORM_DELETE) { |
||||
$client_id = $_GET["id"]; |
||||
$query = "delete from pbx_cliente where client_id = $client_id"; |
||||
$result = pg_query($dbcon, $query); |
||||
|
||||
if ($result) { |
||||
$msgRet = "Registro excluido com sucesso!"; |
||||
} else { |
||||
$msgRet = "Não foi possível excluir o registro!"; |
||||
} |
||||
$jsStartup[] = "alert('$msgRet')"; |
||||
$refresh = true; |
||||
} |
||||
|
||||
$template = 'contribuinteSelect.tpl'; |
||||
|
||||
$linha = ""; |
||||
$numReg = 0; |
||||
$msgErro = ""; |
||||
$acaoForm = FORM_SELECT; |
||||
|
||||
$selContrib = (isset($_GET["selContrib"]) && $_GET["selContrib"]) || (isset($_POST["selContrib"]) && $_POST["selContrib"]); |
||||
if ($selContrib) { |
||||
$tpLayout = 1; |
||||
$wTab = "100%"; |
||||
$tForm = GetNomeCadCli(); |
||||
$_SESSION["selContrib"] = true; |
||||
} |
||||
$consulta = $selContrib && isset($_GET["fone"]) ? soNumero($_GET["fone"]) : $filtro; |
||||
$_SESSION["paramPesquisa"] = $filtro; |
||||
|
||||
//if ((isset($_POST['pesquisa']) && $_POST['pesquisa']) || ($selContrib)) { |
||||
if ($filtro) { |
||||
$compl = PreparaLike($filtro, true); |
||||
$compl = sprintf("AND (a.client_razao_social ILIKE %s OR " |
||||
. "client_nome_contato ILIKE %s " |
||||
. "OR sonumero(a.client_telefone) ILIKE %s OR " |
||||
. "client_obs ILIKE %s OR " |
||||
. "client_municipio ILIKE %s OR " |
||||
. "apelido ILIKE %s OR " |
||||
. "client_email ILIKE %s OR " |
||||
. "client_id IN (SELECT client_id FROM pbx_cliente_anotacoes WHERE cla_anotacao ILIKE %s))\n", $compl, $compl, $compl, $compl, $compl, $compl, $compl, $compl); |
||||
} |
||||
|
||||
if ($clientEtapa) { |
||||
$compl .= "\n AND a.cletp_id = '{$clientEtapa}' \n"; |
||||
} |
||||
|
||||
if ($clientStatus != '-1') { |
||||
$clientStatus = !$clientStatus ? '0' : $clientStatus; |
||||
$compl .= " AND client_status = '{$clientStatus}' \n"; |
||||
} |
||||
|
||||
if ($clientUf) { |
||||
$compl .= " AND client_uf = '{$clientUf}' \n"; |
||||
} |
||||
|
||||
if ($clientTipoContato) { |
||||
$compl .= " AND client_tipo_contato = '{$clientTipoContato}' \n"; |
||||
} |
||||
|
||||
if ($cloid) { |
||||
$compl .= " AND a.clo_id = '{$cloid}' AND cmp_id IS NOT NULL \n"; |
||||
} |
||||
|
||||
if ($client_user_contato) { |
||||
$compl .= " AND client_user_contato = '$client_user_contato' "; |
||||
} |
||||
|
||||
if (GetMatricula()) { |
||||
$compl .= sprintf("\n AND (client_user_contato = '%s' OR b.cfr_id IN (SELECT x.cfr_id FROM pbx_fornecedor_permissao x WHERE matricula_permissao = '%s'))", GetMatricula(), GetMatricula()); |
||||
} |
||||
|
||||
//$tipoData = (strtoupper($tipoDataSet) == 'CONTATO') ? 'client_data_contato' : 'client_agendamento'; |
||||
$tipoData = "client_update"; |
||||
if (is_date($dataIni) && is_date($dataFim)) { |
||||
$compl .= sprintf(" AND {$tipoData}::DATE >= '%s' and {$tipoData}::date <= '%s' \n", FormatDtMssql($dataIni), FormatDtMssql($dataFim)); |
||||
} else if (is_date($dataIni)) { |
||||
$compl .= sprintf(" AND {$tipoData}::DATE >= '%s' \n", FormatDtMssql($dataIni)); |
||||
} else if (is_date($dataFim)) { |
||||
$compl .= sprintf(" AND {$tipoData}::DATE <= '%s' \n", FormatDtMssql($dataFim)); |
||||
} |
||||
|
||||
$query = "SELECT client_ref_id, client_out_id, client_id, client_tipo_documento, client_documento, ctst_nome, client_razao_social, client_nome_fantasia, |
||||
client_municipio, client_uf, client_telefone, client_email, client_nome_contato, client_fone_contato, |
||||
client_email_contato, client_obs, client_tipo_contato, client_data_contato, d.apelido, |
||||
client_user_contato, client_agendamento, a.cletp_id, f.cletp_descricao, client_status, |
||||
(SELECT apelido FROM pbx_usuarios WHERE id = a.user_reg) as modificado |
||||
FROM pbx_cliente a |
||||
INNER JOIN pbx_cliente_origem b ON a.clo_id = b.clo_id |
||||
INNER JOIN pbx_cliente_fornecedor c ON b.cfr_id = c.cfr_id |
||||
inner join pbx_cliente_etapa f on f.cletp_id = a.cletp_id |
||||
LEFT JOIN pbx_usuarios d on d.matricula = a.client_user_contato |
||||
LEFT JOIN pbx_campanha_contato_status e ON e.ctst_id = a.client_status::int |
||||
WHERE 1=1 $compl ORDER BY client_razao_social"; |
||||
|
||||
$_SESSION['SSQueryClient'] = $query; |
||||
|
||||
$params = "¶mPesquisa=$filtro&client_tipo_contato=$clientTipoContato&client_etapa=$clientEtapa&client_status=$clientStatus&client_uf=$clientUf&dataIni=$dataIni&dataFim=$dataFim&client_user_contato=$client_user_contato&clo_id=$cloid"; |
||||
$links = PaginaDados($idProg, $query, $params, $regPagina, $offSet, $pagMostra, true); |
||||
$query .= " LIMIT $regPagina OFFSET $offSet"; |
||||
|
||||
// echo $query; exit; |
||||
|
||||
$result = pg_query($dbcon, $query); |
||||
while ($row = @pg_fetch_array($result)) { |
||||
$client_id = $row["client_id"]; |
||||
$client_tipo_documento = $row["client_tipo_documento"]; |
||||
$client_documento = $row["client_documento"]; |
||||
$cletp_descricao = $row["cletp_descricao"]; |
||||
$client_status = $row["ctst_nome"]; |
||||
$client_data_contato = substr(FormataDBDataHora($row["client_data_contato"]), 0, 10); |
||||
$client_agendamento = FormataDBDataHora($row["client_agendamento"]); |
||||
$client_razao = $row["client_razao_social"]; |
||||
$client_razao_social = GetLinkFormUpdate("&id=$client_id", "cadCliente", "", 0, 1, $row["client_razao_social"]); |
||||
$client_nome_fantasia = $row["client_nome_fantasia"]; |
||||
$client_nome_contato = $row["client_nome_contato"]; |
||||
$client_municipio = $row["client_municipio"]; |
||||
$client_uf = $row["client_uf"]; |
||||
$client_telefone = $row["client_telefone"]; |
||||
$client_email = $row["client_email"]; |
||||
$client_tipo_contato = $row["client_tipo_contato"]; |
||||
$client_usercontato = $row["modificado"]; |
||||
$client_agente = $row["apelido"]; |
||||
$client_class = $row["clit_descricao"]; |
||||
$acaoApaga = GetLinkFormDelete($client_id . "|" . $params, 'DeletaContribuinte'); |
||||
$acaoAtualiza = GetLinkFormUpdate("&id=$client_id", 'cadCliente'); |
||||
$clientOutId = ($client_status == '446') ? $row["client_out_id"] : 0; |
||||
|
||||
list($nomeDisp) = explode(" ", $row["client_razao_social"]); |
||||
|
||||
$discar = RemoveDddPadrao($client_telefone); |
||||
$acao = "<img src=\"imgSite/ramalOn16.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"Ligar para o cliente: $nomeDisp\" title=\"Ligar para o cliente: $nomeDisp\">"; |
||||
|
||||
if ($row["client_email"]) { |
||||
$mailsend = "<a href=\"javaScript:NovaJanela('index.php?idProg=349&client_id={$row["client_id"]}', 'clientMail', '1250', '750', 'jhTela')\"><img src=\"imgSite/mail16.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"Enviar E-mail: $nomeDisp\" title=\"Enviar E-mail: $nomeDisp\"></a>"; |
||||
} else { |
||||
$mailsend = "<img src=\"imgSite/email-no.png\" border=\"0\" width=\"16\" height=\"16\" title=\"O contato Não possui email cadastrado: $nomeDisp\">"; |
||||
} |
||||
|
||||
if ($row["client_email"] && $row["client_telefone"] && $row["client_status"] == '13') { |
||||
$vendamais = "<a href='#' onclick=\"sendContribuiente('{$row["client_out_id"]}', 'addvendamais')\"><img src=\"imgSite/vendamais.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"Exportar o registro no Venda+: $nomeDisp\" title=\"Exportar o registro no Venda+: $nomeDisp\"></a>"; |
||||
} else { |
||||
$vendamais = '<img src="imgSite/vendamais-no.png" border="0" width="16" height="16" title="Contato possui pendencia para ser Exportado!">'; |
||||
} |
||||
|
||||
$sound = sprintf("<a href=\"javaScript:NovaJanela('index.php?idProg=347&client_id={$row["client_id"]}&n=%s', 'audioContato', '1250', '500', 'jhTela')\"><img src=\"imgSite/sound22.png\" border='0' width='16' height='16' title='Áudios do cliente!'></a>", base64_encode($row['client_nome_fantasia'])); |
||||
$linkRamal = "<a href=\"javaScript:RetornaAbd('$discar',{$row["client_id"]});\">$acao</a>"; |
||||
|
||||
$janH = 650; |
||||
$anotacoesCliente = GetLinkFormAction("jnAnotacoes", FORM_SELECT, 46, "imgSite/Comment.png", "client_id={$client_id}&client_razao={$client_razao}&client_out_id={$clientOutId}", ""); |
||||
|
||||
$linha .= "<tr> |
||||
<td align=\"right\">$client_id</td> |
||||
<td align=\"left\">$client_data_contato</td> |
||||
<td align=\"left\">$client_agendamento</td> |
||||
<td align=\"left\">$client_razao_social</td> |
||||
<td align=\"left\">$cletp_descricao</td> |
||||
<td align=\"left\">$client_status</td> |
||||
<td align=\"left\">$client_municipio</td> |
||||
<td align=\"left\">$client_uf</td> |
||||
<td align=\"left\">$client_nome_contato</td> |
||||
<td align=\"left\">$client_telefone</td> |
||||
<td align=\"left\">$client_email</td> |
||||
<td align=\"left\">$client_tipo_contato</td> |
||||
<td align=\"left\">$client_agente</td> |
||||
<td align=\"left\">$client_usercontato</td> |
||||
<td width=\"20\" style=\"border-right: 0\" align=\"center\">$mailsend</td> |
||||
<td width=\"20\" style=\"border-left: 0\" align=\"center\">$vendamais</td> |
||||
<td width=\"20\" style=\"border-left: 0\" align=\"center\">$anotacoesCliente</td> |
||||
<td width=\"20\" style=\"border-left: 0\" align=\"center\">$sound</td> |
||||
<td width=\"20\" align=\"center\">$acaoAtualiza</td> |
||||
</tr>"; |
||||
|
||||
//<td width=\"20\" style=\"border-left: 0\" align=\"center\">$acaoApaga</td> |
||||
|
||||
$numReg++; |
||||
} |
||||
|
||||
$imgCampEmail = "<a href=\"javaScript:NovaJanela('index.php?idProg=349&cmp=1', 'clientMail', '1250', '750', 'jhTela')\"><img src=\"imgSite/Message.png\" border=\"0\" width=\"16\" height=\"16\" align=\"absmiddle\" alt=\"Criar campanha com a lista de contatos selecionados na tela\" title=\"Criar campanha com a lista de contatos selecionados na tela\"> Campanha Email</a>"; |
||||
$imgNovo = GetLinkFormInsert("cadCliente", 'images/novo.gif', $filtroNovo, ' Novo Registro'); |
||||
$imgUpdate = '<a href="javaScript:NovaJanela(\'index.php?idProg=338\', \'novaListaCliente\', \'500\', \'500\', \'jhTela\')"><img src="imgSite/Update.png" width="16px" border="0" align="absmiddle" /> Nova Lista</a>'; |
||||
|
||||
$smarty->assign("list_cliente", GetClienteLista($cloid)); |
||||
$smarty->assign("client_tipo_contato", GetClientTipoContato($clientTipoContato)); |
||||
$smarty->assign("client_etapa", GetEtapaProspect($clientEtapa)); |
||||
$smarty->assign("client_status", GetStatusProspect($clientStatus, true)); |
||||
$smarty->assign("client_uf", GetClientUf($clientUf, true)); |
||||
$smarty->assign("tipoDataSet", $tipoDataSet); |
||||
$smarty->assign("dataIni", $dataIni); |
||||
$smarty->assign("dataFim", $dataFim); |
||||
$smarty->assign("linhas", $linha); |
||||
$smarty->assign("paramPesquisa", $paramPesquisa); |
||||
$smarty->assign("imgCampEmail", $imgCampEmail); |
||||
$smarty->assign("imgNovo", $imgNovo); |
||||
$smarty->assign("imgUpdate", $imgUpdate); |
||||
$smarty->assign("links", $links); |
||||
$smarty->assign("pagMostra", $pagMostra); |
||||
$smarty->assign("totalReg", $totalReg); |
||||
$smarty->assign("pgn", $_REQUEST["pgn"]); |
||||
$smarty->assign("bloco", $_REQUEST["bloco"]); |
||||
$smarty->assign("pg", $_REQUEST["pg"]); |
||||
$smarty->assign("agentes", (PermissaoAdminCampanha(GetMatricula()) ? AgenteCampanha($client_user_contato) : '')); |
||||
|
||||
function enviarMailCampanha($mail, $dbcon) { |
||||
$params = array(); |
||||
$representante = GetUsuario($dbcon, GetMatricula()); |
||||
$params['email_template'] = 'campanha_vendas.html'; |
||||
$params['email_conta_envio'] = "vendas@simplesip.com.br"; |
||||
$params['email_senha_envio'] = "SimpleS#Root@2021"; |
||||
$params['email_retorno'] = "vendas@simplesip.com.br"; |
||||
$params['email_template_info'] = array('NOME' => $representante['nome']); |
||||
$params['email_html'] = 'campanha_vendas.html'; |
||||
$params['email_envio'] = $mail; |
||||
$params['email_assunto'] = 'Transforme agora em seu Callcenter'; |
||||
if (SendEmail($params)) { |
||||
$msg = "Email enviado com sucesso!"; |
||||
sendedMail($dbcon, $mail); |
||||
} else { |
||||
$msg = "Não foi possível realizar o envio!"; |
||||
} |
||||
return $msg; |
||||
} |
||||
|
||||
function sendedMail($conn, $mail) { |
||||
$query = "UPDATE pbx_cliente SET client_status = '16' WHERE client_email = '{$mail}';"; |
||||
pg_query($conn, $query); |
||||
} |
||||
|
||||
function ExportaContato($conn, $outid) { |
||||
|
||||
try { |
||||
$dados = getContatoLead($outid); |
||||
|
||||
if (!$dados) { |
||||
throw new Exception("Este contato ainda possui pendencias para ser exportado!"); |
||||
} |
||||
|
||||
$msql = ConectaMssql(); |
||||
if (!mssql_query('begin tran', $conn)) { |
||||
throw new Exception("Nao foi possivel inciar uma trasacao com o Venda+."); |
||||
} |
||||
|
||||
//@dataEnvio, @VendedorId, @RazaoSocial, @Email, @Telefone, @TipoPessoa, @CGC_CPF, @RegiaoId, @uf, @municipio, @ClienteStatusId, @ClienteIdExterno, @NomeContato |
||||
$query = sprintf("EXEC dbo.sip_insert_prospect '%s','%s',%s,%s,'%s','%s','%s',%s,'%s',%s,'%s','%s', %s, '%s'", |
||||
$dados['conf_data'], $dados['vendedor_id'], |
||||
QuotedStr($dados['client_razao_social']), QuotedStr($dados['client_email']), |
||||
$dados['client_telefone'], ($dados['client_tipo_pessoa'] == "CNPJ" ? "J" : "F"), |
||||
trim($dados['client_documento']), |
||||
QuotedStr($dados['client_regiao']), $dados['client_uf'], QuotedStr($dados['client_municipio']), |
||||
"EM PROSPECÇÃO", $dados['client_id'], QuotedStr($dados['client_nome_contato']), GetMatricula()); |
||||
|
||||
if (!$result = mssql_query($query, $conn)) { |
||||
throw new Exception("Não foi possível exportar o contato.\n{$query}\n"); |
||||
} |
||||
|
||||
if (!$data = mssql_fetch_row($result)) { |
||||
throw new Exception("Não foi possível consultar o contato no VM.\n{$query}\n"); |
||||
} |
||||
|
||||
if (!mssql_query('commit tran', $conn)) { |
||||
throw new Exception("Nao foi possivel inciar uma trasacao com o Venda+."); |
||||
} |
||||
|
||||
mssql_close($msql); |
||||
AtulizaContatoVendaMais($outid, $data[0]); |
||||
return "Contato Exportado com sucesso! Contato ID: " . $data[0]; |
||||
} catch (Exception $ex) { |
||||
mssql_query('rollback tran', $conn); |
||||
return $ex->getMessage(); |
||||
} |
||||
} |
||||
|
||||
function getContatoLead($outid = null) { |
||||
|
||||
$query = "SELECT client_data_contato, client_razao_social, |
||||
client_email_contato, client_fone_contato, client_tipo_contato, client_documento, |
||||
client_endereco, client_uf, client_municipio, client_status, client_id, client_nome_contato, client_user_contato, |
||||
(select reg_sigla from mkt_regiao_estados where reg_uf = b.client_uf) as client_regiao |
||||
FROM pbx_cliente b |
||||
WHERE client_status = '13' "; |
||||
|
||||
if ($outid) { |
||||
$query .= " AND client_out_id = '$outid' "; |
||||
} |
||||
|
||||
$result = pg_query($query); |
||||
$resp = pg_fetch_assoc($result); |
||||
|
||||
$rs = GetCodVendedor($resp['client_user_contato']); |
||||
$resp['vendedor_id'] = $rs['cod_vendedor']; |
||||
$resp['conf_data'] = date('Y-m-d H:i:s'); |
||||
return $resp; |
||||
} |
||||
|
||||
function GetCodVendedor($clientUserContato) { |
||||
$query = sprintf("SELECT * FROM pbx_cliente_referencia_vendedor WHERE matricula = '%s'", $clientUserContato); |
||||
$result = pg_query($query); |
||||
$resp = pg_fetch_assoc($result); |
||||
if (!$resp) { |
||||
throw new Exception('Você não possui nenhum vendedor referenciado!'); |
||||
} |
||||
return $resp; |
||||
} |
||||
|
||||
function AtulizaContatoVendaMais($outid, $idvenda) { |
||||
$query = sprintf("UPDATE pbx_cliente SET client_out_id = '{$idvenda}', client_status = '21', user_reg = %s, client_update = NOW() WHERE client_out_id = '$outid';", GetIdUser()); |
||||
$result = pg_query($query); |
||||
if (!$result) { |
||||
throw new Exception('Não foi possível atualizar o registro de exportação'); |
||||
} |
||||
} |
||||
|
||||
?> |
@ -1,304 +0,0 @@
|
||||
<?php |
||||
|
||||
$template = "contribuinte.tpl"; |
||||
$tpLayout = 1; |
||||
$offSet = 0; |
||||
$refresh = isset($_GET['refresh']) ? true : false; |
||||
|
||||
define('CONF_PATH_INTEGRACAO', '/var/lib/asterisk/scripts/integracao/custom/GoogleCalendar/'); |
||||
|
||||
define('CONF_PATH_CLASS', 'GoogleCalendar.php'); |
||||
define('CONF_PATH_CREDENTIALS', 'credentials.json'); |
||||
define('CONF_PATH_TOKEN', 'token.json'); |
||||
define('CONF_STATUS_EXPORTADO', 21); |
||||
|
||||
include CONF_PATH_INTEGRACAO . CONF_PATH_CLASS; |
||||
|
||||
if (GetFormAcao() == FORM_UPDATE) { |
||||
$acaoForm = FORM_SAVE; |
||||
|
||||
$id = $_GET["id"] ? $_GET["id"] : $_POST['client_id']; |
||||
$query = "SELECT client_id, |
||||
CASE WHEN(COALESCE(client_tipo_documento, '') = '')THEN 'CNPJ' ELSE client_tipo_documento END AS client_tipo_documento, |
||||
client_documento, client_razao_social,client_municipio, client_uf, client_nome_contato, client_status, client_email, |
||||
client_telefone, client_obs, client_tipo_contato, client_agendamento, client_class, client_update, (SELECT apelido FROM pbx_usuarios WHERE id = user_reg) as modificado |
||||
FROM pbx_cliente |
||||
WHERE client_id = {$id}"; |
||||
|
||||
$result = pg_query($dbcon, $query); |
||||
$row = @pg_fetch_array($result, null, PGSQL_ASSOC); |
||||
|
||||
list($nomeDisp) = explode(" ", $row["client_razao_social"]); |
||||
|
||||
if ($row['client_agendamento']) { |
||||
$discar = RemoveDddPadrao($row['client_telefone']); |
||||
$acao = "<img src=\"imgSite/ramalOn16.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"Ligar para o cliente: $nomeDisp\" title=\"Ligar para o cliente: $nomeDisp\">"; |
||||
$linkRamal = "<a href=\"javaScript:RetornaAbd('$discar',{$row["client_id"]});\">$acao</a>"; |
||||
} |
||||
|
||||
/** ENVIAR EMAIL * */ |
||||
if ($row["client_email"]) { |
||||
$mailsend = "<a href='#' onclick=\"sendContribuiente('{$row["client_email"]}','sendmail')\"><img src=\"imgSite/mail16.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"Enviar E-mail: $nomeDisp\" title=\"Enviar E-mail: $nomeDisp\"></a>"; |
||||
} else { |
||||
$mailsend = "<img src=\"imgSite/email-no.png\" border=\"0\" width=\"16\" height=\"16\" title=\"O contato Não possui email cadastrado: $nomeDisp\">"; |
||||
} |
||||
|
||||
/** CONTATOS */ |
||||
$contatos = "<a href=\"javaScript:NovaJanela('index.php?idProg=346&client_id={$row["client_id"]}', 'contatosCliente', '900', '250', 'jhTela')\"><img src=\"imgSite/User group.png\" border=\"0\" width=\"16\" height=\"16\" alt=\"Contatos do cliente ID: $nomeDisp\" title=\"Contatos do cliente ID: $nomeDisp\"></a>"; |
||||
|
||||
$row["client_agenda"] = $row["client_agendamento"] ? date('d/m/Y H:i', strtotime($row["client_agendamento"])) : ''; |
||||
$row["client_status"] = GetStatusProspect($row["client_status"], false, ($refresh || $row["client_status"] == CONF_STATUS_EXPORTADO ? TRUE : FALSE)); |
||||
$row["client_tipo_contato"] = GetClientTipoContato($row["client_tipo_contato"]); |
||||
$row["client_update"] = $row["client_update"] ? date('d/m/Y H:i:s', strtotime($row["client_update"])) : '-'; |
||||
|
||||
/** |
||||
* TABELA ANOTAÇÃO |
||||
*/ |
||||
$query1 = "SELECT cla_id, cla_anotacao, apelido, data_reg FROM pbx_cliente_anotacoes a " |
||||
. "INNER JOIN pbx_usuarios b ON b.matricula::int = a.user_reg " |
||||
. "WHERE client_id = '{$id}' ORDER BY data_reg DESC\n"; |
||||
$sql = GetTotalRegistro($dbcon, $query1); |
||||
|
||||
$params = sprintf("&client_id=%s&client_razao=%s", $id, $row['client_razao_social']); |
||||
$links = PaginaDados($idProg, $sql, $params, $regPagina, $offSet, $pagMostra, true); |
||||
$query1 .= " LIMIT $regPagina OFFSET $offSet"; |
||||
$res = pg_query($dbcon, $query1); |
||||
$data = pg_fetch_all($res); |
||||
$tblAnota = ''; |
||||
|
||||
foreach ($data as $anota) { |
||||
$tblAnota .= "<tr>"; |
||||
$tblAnota .= sprintf("<td>%s</td>", date('d/m/Y H:i:s', strtotime($anota['data_reg']))); |
||||
$tblAnota .= sprintf("<td>%s</td>", $anota['apelido']); |
||||
$tblAnota .= sprintf("<td>%s</td>", $anota['cla_anotacao']); |
||||
$tblAnota .= "</tr>"; |
||||
} |
||||
|
||||
$smarty->assign("links", $links); |
||||
$smarty->assign("pagMostra", $pagMostra); |
||||
$smarty->assign("totalReg", $totalReg); |
||||
$smarty->assign('anotacao', $tblAnota); |
||||
$smarty->assign('mailsend', $mailsend); |
||||
$smarty->assign('contatos', $contatos); |
||||
$smarty->assign('linkRamal', $linkRamal); |
||||
$smarty->assign('sound', $sound); |
||||
|
||||
if ($result) { |
||||
//valores no form |
||||
foreach ($row as $key => $value) { |
||||
$smarty->assign($key, $value); |
||||
} |
||||
} else { |
||||
$acaoForm = FORM_INSERT; |
||||
$msgRet = "A operação não pode ser realizada!"; |
||||
$jsStartup[] = "alert('$msgRet');"; |
||||
$msgRet .= pg_last_error() ? " Erro: " . pg_last_error() : ""; |
||||
$smarty->assign("msg", $msgRet); |
||||
} |
||||
} else { |
||||
$msgForm = array(); |
||||
|
||||
if (!validaForm($fields, $fieldsObrig, $fieldsType, $fieldsDiplay, $msgForm)) { |
||||
$acaoForm = FORM_SAVE; |
||||
|
||||
//formata mensagem de erro para script |
||||
$msgRet = ""; |
||||
foreach ($msgForm as $value) { |
||||
$msgRet .= "\\n" . $value; |
||||
} |
||||
|
||||
$jsStartup[] = "alert('$msgRet');"; |
||||
|
||||
//formata mensagem de erro para o form |
||||
$msgRet = ""; |
||||
foreach ($msgForm as $value) { |
||||
$msgRet .= $value . " "; |
||||
} |
||||
|
||||
//erros no form |
||||
$smarty->assign("msgErro", $msgRet); |
||||
|
||||
$_POST["client_status"] = GetStatusProspect($_POST["client_status"], false, $refresh); |
||||
$_POST["client_tipo_contato"] = GetClientTipoContato($_POST["client_tipo_contato"]); |
||||
//valores no form |
||||
foreach ($fields as $value) { |
||||
$smarty->assign($value, $_POST[$value]); |
||||
} |
||||
} else { |
||||
$acaoForm = FORM_SAVE; |
||||
|
||||
$id = $_POST["client_id"]; |
||||
$nome = QuotedStr(strtoupper($_POST["client_nome_contato"])); |
||||
$status = isset($_POST["client_status"]) ? QuotedStr($_POST["client_status"]) : null; |
||||
$tpContato = QuotedStr($_POST["client_tipo_contato"]); |
||||
$tpDoc = QuotedStr($_POST["client_tipo_documento"]); |
||||
|
||||
$doc = sonumero($_POST["client_documento"]); |
||||
$doc = !$doc ? "null" : QuotedStr($doc); |
||||
|
||||
$email = trim($_POST["client_email"]); |
||||
$email = !$email ? "null" : QuotedStr($email); |
||||
|
||||
$fone = sonumero($_POST["client_telefone"]); |
||||
$fone = !$fone ? "null" : QuotedStr($fone); |
||||
|
||||
if (!$_POST["client_agenda"]) { |
||||
$agendamento = 'null'; |
||||
} else { |
||||
$agendamento = strlen($_POST["client_agenda"]) == 10 ? QuotedStr(FormatDtMssql($_POST["client_agenda"]) . " 00:00") : QuotedStr(FormatDtMssql(substr($_POST["client_agenda"], 0, 10)) . substr($_POST["client_agenda"], 10, 16)); |
||||
} |
||||
|
||||
$user_contato = QuotedStr(GetMatricula()); |
||||
|
||||
$obs = trim($_POST["client_obs"]); |
||||
$obs = !$obs ? null : QuotedStr($obs); |
||||
|
||||
$user_reg = GetIdUser(); |
||||
|
||||
/* |
||||
* Atribui uma nova etapa de acordo com o status. |
||||
*/ |
||||
$client_etapa = GetClienteEtapa($_POST["client_status"]); |
||||
|
||||
$query = "update pbx_cliente |
||||
set client_tipo_documento = {$tpDoc}, |
||||
client_documento = {$doc}, |
||||
client_nome_contato = {$nome},$client_etapa"; |
||||
|
||||
if (isset($_POST["client_status"])) { |
||||
$query .= "client_status = {$status},"; |
||||
} |
||||
|
||||
if ($status != CONF_STATUS_EXPORTADO && $status) { |
||||
$query .= "user_reg = {$user_reg}, client_update = now(),"; |
||||
} |
||||
|
||||
$query .= "client_email = {$email}, |
||||
client_telefone = {$fone}, |
||||
client_tipo_contato = {$tpContato}, |
||||
client_agendamento = {$agendamento} |
||||
where client_id = {$id} "; |
||||
|
||||
$result = pg_query($dbcon, $query); |
||||
|
||||
if ($obs) { |
||||
$sql = "INSERT INTO pbx_cliente_anotacoes (client_id, cla_anotacao, user_reg) VALUES(%s, %s, %s);"; |
||||
$sql = sprintf($sql, $id, $obs, $user_contato); |
||||
pg_query($dbcon, $sql); |
||||
} |
||||
|
||||
atualizaContato($dbcon, $_POST["client_id"], $nome, $fone, $email); |
||||
|
||||
//valores no form |
||||
foreach ($fields as $value) { |
||||
if (array_search($value, $_POST) !== false) { |
||||
$smarty->assign($value, $value == "client_id" ? $id : $_POST[$value]); |
||||
} |
||||
} |
||||
|
||||
if ($result) { |
||||
|
||||
if ($_POST['intg_agenda'] && $_POST["client_agenda"] && $_POST['client_razao_social']) { |
||||
integCalendar($_POST["client_agenda"], $_POST['client_razao_social'], trim('desenv02@simplesip.com.br')); |
||||
} |
||||
|
||||
$msgRet = "Registro alterado com sucesso!"; |
||||
$jsStartup[] = "alert('$msgRet');"; |
||||
$smarty->assign("msg", $msgRet); |
||||
if (!$_GET['refresh']) { |
||||
$jsStartup[] = "window.opener.ResetForm();"; |
||||
} |
||||
|
||||
$jsStartup[] = "window.close();"; |
||||
} else { |
||||
$msgRet = "A operação não pode ser realizada!"; |
||||
$jsStartup[] = "alert('$msgRet');"; |
||||
$msgRet .= pg_last_error() ? (IsAdmin() ? " Erro: " . pg_last_error() : "") : ""; |
||||
$smarty->assign("msg", $msgRet); |
||||
} |
||||
} |
||||
} |
||||
|
||||
function atualizaContato($dbcon, $cliente, $nome, $fone, $email = 'null') { |
||||
$query = "SELECT clc_id FROM pbx_cliente_contato WHERE client_id = {$cliente} AND clc_contato_principal = 1;"; |
||||
$result = pg_query($dbcon, $query); |
||||
$data = pg_fetch_assoc($result); |
||||
|
||||
if ($data) { |
||||
$query = "UPDATE pbx_cliente_contato SET clc_nome = {$nome}, clc_email = {$email}, clc_fone = {$fone} WHERE clc_id = {$data['clc_id']};"; |
||||
pg_query($dbcon, $query); |
||||
} |
||||
} |
||||
|
||||
function integCalendar($agenda, $empresa, $email) { |
||||
if ((file_exists(CONF_PATH_INTEGRACAO . CONF_PATH_CLASS) && (file_exists(CONF_PATH_INTEGRACAO . CONF_PATH_TOKEN)) && (file_exists(CONF_PATH_INTEGRACAO . CONF_PATH_CREDENTIALS)))) { |
||||
$formtData = strlen($agenda) == 10 ? FormatDtMssql($agenda) . " 00:00" : FormatDtMssql(substr($agenda, 0, 10)) . substr($agenda, 10, 16); |
||||
|
||||
$emails = GetAllMailAdmin(); |
||||
$emails[]['email'] = $email; |
||||
|
||||
$gg = new GoogleCalendar(); |
||||
$gg->getClient(); |
||||
|
||||
$dataIni = date('Y-m-d\TH:i:s-04:00', strtotime($formtData)); |
||||
$dataFim = date('Y-m-d\TH:i:s-04:00', strtotime($formtData . ' +1 hours')); |
||||
|
||||
$link = $gg->createEventCalendar( |
||||
'APRESENTACAO COM ' . RemoveAcentos($empresa), |
||||
'AGENDAMENTO DA APRESENTACAO DOS PRODUTOS SIMPLES IP', |
||||
$dataIni, |
||||
$dataFim, |
||||
$emails |
||||
); |
||||
|
||||
return $link; |
||||
} |
||||
} |
||||
|
||||
function GetClienteEtapa($status) { |
||||
|
||||
$query = " select ctst_nome from pbx_campanha_contato_status where ctst_id = '$status';\n"; |
||||
$result = pg_query($query); |
||||
$data = pg_fetch_row($result); |
||||
$statusAtual = $data[0]; |
||||
$novaEtapa = ''; |
||||
|
||||
switch ($statusAtual) { |
||||
case "NOVO": $novaEtapa = 'VALIDACAO'; |
||||
break; |
||||
case "ATENDIDA": |
||||
case "NÃO ATENDIDA": |
||||
case "ELETRÔNICA": |
||||
case "MUDA": |
||||
case "OCUPADA": |
||||
case "DESLIGOU": |
||||
case "CLIENTE": |
||||
case "PROSPECT": |
||||
case "LEAD": |
||||
case "ENVIADO": |
||||
case "AGENDADO": |
||||
case "INTERESSE": |
||||
case "CONTABILIDADE": $novaEtapa = 'PROSPECCAO'; |
||||
break; |
||||
case "NÃO ENVIAR": |
||||
case "RESPONDIDO" : |
||||
case "REPROCESSAR": |
||||
case "INVALIDO": |
||||
case "SEM INTERESSE": |
||||
case "EXCLUIR": |
||||
case "EXPORTADO": |
||||
case "REMOVER": $novaEtapa = 'FINALIZACAO'; |
||||
break; |
||||
} |
||||
|
||||
$query = "select cletp_id from pbx_cliente_etapa where cletp_descricao = '$novaEtapa';\n"; |
||||
$result = pg_query($query); |
||||
|
||||
if (!$result || !pg_num_rows($result)) { |
||||
return ''; |
||||
} |
||||
$data = pg_fetch_row($result); |
||||
return sprintf("\ncletp_id = '%s',", $data[0]); |
||||
} |
||||
|
||||
?> |
@ -1,304 +0,0 @@
|
||||
<?php |
||||
|
||||
/* |
||||
* variavel que vai conter o template |
||||
*/ |
||||
//VerificaPerfilAcesso(SEG_CONTRIBUINTE); |
||||
$template = "contribuinteSelect.tpl"; |
||||
|
||||
/* |
||||
* fields correspondem aos campos retornados da consulta |
||||
*/ |
||||
$fields = array("client_id", "client_tipo_documento", "client_documento", "client_razao_social", "client_municipio", "client_uf", "client_nome_contato", "client_status", "client_email", "client_telefone", "client_obs"); |
||||
//$fields = array("client_id", "client_razao_social", "client_nome_contato", "client_status", "contrib_email", "client_telefone"); |
||||
// |
||||
//-- DROP TABLE pbx_cliente; |
||||
// |
||||
//CREATE TABLE pbx_cliente |
||||
//( |
||||
// client_id bigserial NOT NULL, |
||||
// client_tipo_documento character varying(16) NOT NULL DEFAULT 'CPF'::character varying, |
||||
// client_documento character varying(64), |
||||
// client_status character varying(32), |
||||
// client_razao_social character varying(128) NOT NULL, |
||||
// client_razao_fantasia character varying(128), |
||||
// client_telefone character varying(32), |
||||
// client_email character varying(128), |
||||
// client_nome_contato character varying(128) NOT NULL, |
||||
// client_fone_contato character varying(32), |
||||
// client_email_contato character varying(128), |
||||
// client_obs text, |
||||
// client_data timestamp without time zone NOT NULL DEFAULT now(), |
||||
// client_update timestamp without time zone, |
||||
// CONSTRAINT pbx_cliente_pkey PRIMARY KEY (client_id) |
||||
//); |
||||
/* |
||||
* nome das colunas que vão aparecer na consulta |
||||
*/ |
||||
$fieldsDiplay = array(); |
||||
$fieldsDiplay["client_id"] = "ID"; |
||||
$fieldsDiplay["client_tipo_documento"] = "Tipo de Documento"; |
||||
$fieldsDiplay["client_documento"] = "Documento"; |
||||
$fieldsDiplay["client_status"] = "Status"; |
||||
$fieldsDiplay["client_razao_socia"] = "Razão Social"; |
||||
$fieldsDiplay["client_nome_fantasia"] = "Nome de Fantasia"; |
||||
$fieldsDiplay["client_telefone"] = "Telefone"; |
||||
$fieldsDiplay["client_email"] = "Email"; |
||||
$fieldsDiplay["client_nome_contato"] = "Responsável"; |
||||
$fieldsDiplay["client_fone_contato"] = "Fone Responsável"; |
||||
$fieldsDiplay["client_email_contato"] = "E-mail Responsável"; |
||||
$fieldsDiplay["client_obs"] = "Obs"; |
||||
$fieldsDiplay["client_tipo_contato"] = "Contatar"; |
||||
|
||||
/* |
||||
* campos obrigatorios usados na funcao validaForm |
||||
*/ |
||||
$fieldsObrig = array(); |
||||
$fieldsObrig["contrib_razao_social"] = 1; |
||||
//$fieldsObrig["client_status"] = 1; |
||||
//$fieldsObrig["client_documento"] = 1; |
||||
|
||||
/* |
||||
* identifica o tipo do dado |
||||
*/ |
||||
$fieldsType = array(); |
||||
$fieldsType["client_id"] = TYPE_INTEGER; |
||||
$fieldsType["client_tipo_documento"] = TYPE_STRING; |
||||
$fieldsType["client_documento"] = TYPE_STRING; |
||||
$fieldsType["client_status"] = TYPE_STRING; |
||||
$fieldsType["client_razao_socia"] = TYPE_STRING; |
||||
$fieldsType["client_nome_fantasia"] = TYPE_STRING; |
||||
$fieldsType["client_municipio"] = TYPE_STRING; |
||||
$fieldsType["client_uf"] = TYPE_STRING; |
||||
$fieldsType["client_telefone"] = TYPE_FONE; |
||||
$fieldsType["client_email"] = TYPE_EMAIL; |
||||
$fieldsType["client_nome_contato"] = TYPE_STRING; |
||||
$fieldsType["client_fone_contato"] = TYPE_FONE; |
||||
$fieldsType["client_email_contato"] = TYPE_EMAIL; |
||||
$fieldsType["client_obs"] = TYPE_STRING; |
||||
/* |
||||
* Valores para o form |
||||
*/ |
||||
$fielsValues = array(); |
||||
|
||||
/* |
||||
* TIPO DE INDENTIFICAÇÃO |
||||
*/ |
||||
define("CONTRIB_TIPO_CPF", 'CPF'); |
||||
define("CONTRIB_TIPO_CRC", 'CRC'); |
||||
define("CONTRIB_TIPO_IE", 'IE'); |
||||
define("CONTRIB_TIPO_CNPJ", 'CNPJ'); |
||||
define("CONTRIB_TIPO_OUTROS", 'Outro'); |
||||
//define tamanho da janela de cadastro |
||||
$janW = 500; |
||||
$janH = 260; |
||||
|
||||
if ((GetFormAcao() == FORM_SELECT) || (GetFormAcao() == FORM_DELETE)) { |
||||
include("cadastros/cliente/contribSelect.php"); |
||||
} else if ((GetFormAcao() == FORM_NEW) || (GetFormAcao() == FORM_INSERT)) { |
||||
$tpLayout = 1; |
||||
include("cadastros/cliente/contribInsert.php"); |
||||
} else if ((GetFormAcao() == FORM_UPDATE) || (GetFormAcao() == FORM_SAVE)) { |
||||
$tpLayout = 1; |
||||
include("cadastros/cliente/contribUpdate.php"); |
||||
} |
||||
|
||||
//variaveis para o template |
||||
$smarty->assign("selContrib", isset($selContrib) ? $selContrib : "" ); |
||||
$smarty->assign("tForm", isset($tForm) ? $tForm : ""); |
||||
$smarty->assign("wTab", isset($wTab) ? $wTab : '' ); |
||||
$smarty->assign("formAction", isset($acaoForm) ? $acaoForm : '' ); |
||||
$smarty->assign("formAcaoDesc", GetFormAcaoDesc($acaoForm)); |
||||
$smarty->assign("nomeCadCli", GetNomeCadCli()); |
||||
/* |
||||
* Carrega o template correspondente ao cadastro |
||||
*/ |
||||
GetTemplate($smarty, $template); |
||||
|
||||
/** |
||||
* FUNÇÃO PARA RETORNAR A ETAPA EM QUE O LEAD SE ENCONTRA |
||||
* @param type $etapa |
||||
* @param type $semEtapa |
||||
* @return string |
||||
*/ |
||||
function GetEtapaProspect($etapa, $readonly = false) { |
||||
|
||||
$readonly = $readonly ? 'disabled="true"' : ''; |
||||
|
||||
$serv = "<select name=\"client_etapa\" id=\"client_etapa\" size=\"1\" {$readonly}>"; |
||||
$sel = !$etapa ? 'selected="selected"' : ""; |
||||
$serv .= sprintf('<option value="0" %s>----------------</option>', ($etapa == '0' ? : '')); |
||||
|
||||
|
||||
$query = "select cletp_id, cletp_descricao from pbx_cliente_etapa;"; |
||||
|
||||
$result = pg_query($query); |
||||
while ($dados = pg_fetch_row($result)) { |
||||
$sel = ($etapa === $dados[0]) ? 'selected="selected"' : ""; |
||||
$serv .= "<option value=\"$dados[0]\" $sel>$dados[1]</option>"; |
||||
} |
||||
$serv .= "</select>"; |
||||
|
||||
return $serv; |
||||
} |
||||
|
||||
/** |
||||
* FUNÇÃO PARA RETORNAR O SELECT DOS STATUS DO CLIENTES |
||||
* @param type $status |
||||
* @param type $semStatus |
||||
* @return string |
||||
*/ |
||||
function GetStatusProspect($status, $semStatus = false, $readonly = false) { |
||||
|
||||
$readonly = $readonly ? 'disabled="true"' : ''; |
||||
|
||||
$serv = "<select name=\"client_status\" id=\"client_status\" size=\"1\" {$readonly}>"; |
||||
$sel = ""; |
||||
if ($semStatus) { |
||||
$serv .= sprintf('<option value="-1" %s>----------------</option>', ($status == '00' ? 'selected="selected"' : '')); |
||||
} |
||||
|
||||
$query = sprintf("SELECT DISTINCT d.ctst_id, d.ctst_nome |
||||
FROM pbx_usuarios a |
||||
INNER JOIN pbx_grupo_usuario b ON a.id = b.user_id |
||||
INNER JOIN pbx_grupo_campanha_contato_status c ON b.gp_id = c.gp_id |
||||
INNER JOIN pbx_campanha_contato_status d ON c.ctst_id = d.ctst_id |
||||
WHERE matricula = '%s' |
||||
AND d.ctst_status = 1 |
||||
ORDER BY ctst_nome", GetMatricula()); |
||||
|
||||
$result = pg_query($query); |
||||
while ($dados = pg_fetch_row($result)) { |
||||
if ($status === $dados[0]) { |
||||
$sel = "selected"; |
||||
} else { |
||||
$sel = ""; |
||||
} |
||||
$serv .= "<option value=\"$dados[0]\" $sel>$dados[1]</option>"; |
||||
} |
||||
$serv .= "</select>"; |
||||
|
||||
return $serv; |
||||
} |
||||
|
||||
function GetClientTipoContato($clientTipoContato) { |
||||
$tipos = array('TELEFONE', 'WHATSAPP', 'EMAIL', 'TELEGRAM', 'SMS', 'SKYPE'); |
||||
$opt = "<select name=\"client_tipo_contato\" id=\"client_tipo_contato\" size=\"1\">"; |
||||
$opt .= sprintf('<option value="0" %s>----------------</option>', (!$clientTipoContato ? 'selected="selected"' : '')); |
||||
|
||||
foreach ($tipos as $tipo) { |
||||
$opt .= sprintf('<option value="%s" %s>%s</option>', $tipo, (($clientTipoContato == $tipo) ? 'selected="selected"' : ''), $tipo); |
||||
} |
||||
$opt .= "</select>"; |
||||
return $opt; |
||||
} |
||||
|
||||
function GetClientUf($clientUf) { |
||||
$tipos = array('AC', 'AL', 'AP', 'AM', 'BA', 'CE', 'DF', 'ES', 'GO', 'MA', 'MT', 'MS', 'MG', 'PA', 'PB', 'PR', 'PE', 'PI', 'RJ', 'RN', 'RS', 'RO', 'RR', 'SC', 'SP', 'SE', 'TO'); |
||||
$opt = "<select name=\"client_uf\" id=\"client_tipo_contato\" size=\"1\">"; |
||||
$opt .= sprintf('<option value="" %s>----------------</option>', (!$clientUf ? 'selected="selected"' : '')); |
||||
|
||||
foreach ($tipos as $tipo) { |
||||
$opt .= sprintf('<option value="%s" %s>%s</option>', $tipo, (($clientUf == $tipo) ? 'selected="selected"' : ''), $tipo); |
||||
} |
||||
$opt .= "</select>"; |
||||
return $opt; |
||||
} |
||||
|
||||
function GetClassificacaoVendas($select = null) { |
||||
$query = "SELECT b.clit_id, b.clit_descricao, a.clas_status FROM pbx_classifica_atendimento a |
||||
INNER JOIN pbx_classifica_item b ON b.clas_id = a.clas_id |
||||
WHERE clas_descricao = 'CAMPANHA_TELEVENDAS' |
||||
AND clas_status = 1"; |
||||
$result = pg_query($query); |
||||
$data = pg_fetch_all($result); |
||||
|
||||
$opt = "<option value='0'>-------------</option>"; |
||||
if ($data) { |
||||
foreach ($data as $clas) { |
||||
$selected = $select == $clas['clit_id'] ? 'selected' : ''; |
||||
$opt .= "<option value='{$clas['clit_id']}' $selected> {$clas['clit_descricao']}</option>"; |
||||
} |
||||
} |
||||
return $opt; |
||||
} |
||||
|
||||
function SetDataAgendamento($id, $clientAgenda) { |
||||
$query = "UPDATE pbx_cliente SET client_agendamento = '{$clientAgenda}' WHERE client_id = {$id}"; |
||||
pg_query($query); |
||||
|
||||
if (pg_last_error()) { |
||||
throw new Exception('Não foi possível atualizar a DATA de Agendamento do cliente!'); |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
function GetClienteLista($select = null) { |
||||
$query = "SELECT clo_id, clo_titulo FROM pbx_cliente_origem "; |
||||
$result = pg_query($query); |
||||
$data = pg_fetch_all($result); |
||||
|
||||
$opt = "<select name=\"clo_id\" id=\"clo_id\" size=\"1\">"; |
||||
$opt .= "<option value='0'>-------------</option>"; |
||||
if ($data) { |
||||
foreach ($data as $clas) { |
||||
$selected = $select == $clas['clo_id'] ? 'selected' : ''; |
||||
$opt .= "<option value='{$clas['clo_id']}' $selected> {$clas['clo_titulo']}</option>"; |
||||
} |
||||
} |
||||
$opt .= "</select>"; |
||||
return $opt; |
||||
} |
||||
|
||||
function AgenteCampanha($select = null) { |
||||
$query = "SELECT DISTINCT id, nome, apelido, matricula FROM pbx_usuarios a |
||||
INNER JOIN pbx_grupo_usuario b ON a.id = b.user_id |
||||
INNER JOIN pbx_grupo_funcoes c ON c.gp_id = b.gp_id |
||||
WHERE b.gp_id IN(SELECT gp_id FROM (SELECT CASE WHEN(COUNT(gp_id) > 1) THEN gp_id END AS gp_id |
||||
FROM pbx_grupo_funcoes WHERE fun_id = 209 OR fun_id = 2 |
||||
GROUP BY gp_id |
||||
ORDER BY 1) AS DATA)"; |
||||
$result = pg_query($query); |
||||
$resp = pg_fetch_all($result); |
||||
|
||||
$opt = "<select name=\"client_user_contato\" id=\"client_user_contato\" size=\"1\">"; |
||||
$opt .= "<option value='0'>-------------</option>"; |
||||
if ($resp) { |
||||
foreach ($resp as $val) { |
||||
$selected = $select == $val['matricula'] ? 'selected' : ''; |
||||
$opt .= "<option value='{$val['matricula']}' $selected>{$val['apelido']}</option>"; |
||||
} |
||||
} |
||||
$opt .= "</select>"; |
||||
return $opt; |
||||
} |
||||
|
||||
function PermissaoAdminCampanha($matricula) { |
||||
$query = "SELECT * FROM pbx_fornecedor_permissao WHERE matricula_permissao = '$matricula'"; |
||||
$result = pg_query($query); |
||||
$resp = pg_fetch_assoc($result); |
||||
return $resp; |
||||
} |
||||
|
||||
function GetAllMailAdmin(){ |
||||
$query = "SELECT email FROM pbx_usuarios a |
||||
INNER JOIN pbx_fornecedor_permissao b ON b.matricula_permissao = a.matricula |
||||
WHERE email <> ''"; |
||||
$result = pg_query($query); |
||||
$resp = pg_fetch_all($result); |
||||
return $resp; |
||||
} |
||||
|
||||
function ConectaMssql() { |
||||
$dbhost = "192.168.115.28"; |
||||
$dbname = "VendaMaisDB_simplesip"; |
||||
$user = "sa"; |
||||
$passwd = "SimpleS_root"; |
||||
$conn = mssql_connect($dbhost, $user, $passwd); |
||||
mssql_select_db($dbname); |
||||
|
||||
return $conn; |
||||
} |
||||
|
||||
?> |
@ -1,120 +0,0 @@
|
||||
<?php |
||||
//LIMPA VARIAVEIS |
||||
$Pesquisar = ""; |
||||
$municipio = ""; |
||||
$acao = ""; |
||||
//Recebe |
||||
$Pesquisar = $_POST['pesquisar']; |
||||
$acao = $_GET['acao']; |
||||
$deletaMunicipio = 0; |
||||
|
||||
//Deleta |
||||
if ($_GET['acao'] == "deletaMunicipio") { |
||||
$deletaMunicipio = 1; |
||||
$mun_id = $_GET['municipio']; |
||||
$sql = "DELETE FROM pbx_municipio_prefixo WHERE mun_id='$mun_id'"; |
||||
$result = pg_query($dbcon, $sql); |
||||
$sql = "DELETE FROM pbx_municipio_classifica WHERE mun_id='$mun_id'"; |
||||
$query = pg_query($dbcon, $sql); |
||||
} |
||||
|
||||
//Pesquisa |
||||
if (IsPostBack() || $deletaMunicipio) { |
||||
if (isset($_POST['municipio'])) { |
||||
$_SESSION['ssMunicipioSearch'] = $_POST['municipio']; |
||||
$_SESSION['ssMunicipioUF'] = $_POST['UF']; |
||||
} |
||||
|
||||
$municipio = isset($_POST['municipio']) ? $_POST['municipio'] : $_SESSION['ssMunicipioSearch']; |
||||
$recebe_uf = isset($_POST['UF']) ? $_POST['UF'] : $_SESSION['ssMunicipioUF']; |
||||
|
||||
if (empty($municipio)) { |
||||
|
||||
if ($recebe_uf == '0') { |
||||
$condicao = ""; |
||||
} else { |
||||
$condicao = "WHERE uf='$recebe_uf'"; |
||||
} |
||||
} else { |
||||
if ($recebe_uf == '0') { |
||||
$condicao = " WHERE mun_nome ILIKE '%$municipio%'"; |
||||
} else { |
||||
$condicao = " WHERE mun_nome ILIKE '%$municipio%' AND uf='$recebe_uf'"; |
||||
} |
||||
} |
||||
|
||||
if (is_numeric($municipio)) { |
||||
if (strlen($municipio) == 2) { |
||||
$sql = pg_query($dbcon, "SELECT uf FROM pbx_municipio_classifica WHERE mun_ddd = $municipio"); |
||||
while ($rowMUN = pg_fetch_array($sql)) { |
||||
$recebe_uf = $rowMUN['uf']; |
||||
} |
||||
$condicao = " WHERE mun_ddd='$municipio' AND uf='$recebe_uf'"; |
||||
} |
||||
if (strlen($municipio) > 2) { |
||||
$busca = "SELECT mun_id FROM pbx_municipio_prefixo WHERE prx_prefixo ILIKE '%$municipio%' "; |
||||
$result = pg_query($dbcon, $busca); |
||||
while ($row = pg_fetch_array($result)) { |
||||
$mun_id = $row['mun_id']; |
||||
} |
||||
$condicao = "WHERE mun_id ILIKE '%$mun_id%'"; |
||||
} |
||||
} |
||||
$sql = "SELECT mun_id,uf,mun_ddd,mun_nome FROM pbx_municipio_classifica $condicao ORDER BY mun_ddd,mun_nome ASC "; |
||||
} else { |
||||
$sql = "SELECT mun_id,uf,mun_ddd,mun_nome FROM pbx_municipio_classifica ORDER BY mun_ddd,mun_nome ASC "; |
||||
} |
||||
//IMPRIMI REGISTROS---- |
||||
$result = pg_query($dbcon, $sql); |
||||
if (pg_num_rows($result) < 1) { |
||||
$municipio = $_POST['municipio']; |
||||
$uf = $_POST['uf']; |
||||
$busca = pg_query($dbcon, "SELECT mun_ddd FROM pbx_municipio_classifica WHERE uf='$recebe_uf'"); |
||||
while ($x = pg_fetch_array($busca)) { |
||||
$ddd = $x['mun_ddd']; |
||||
} |
||||
$resultados = ' |
||||
<td colspan="4" style="text-align:center;">Nenhum registro encontrado!</td> |
||||
<td colspan="2" style="text-align: center;"><a href="javaScript:NovaJanela(\'index.php?idProg=164&acao=in&ddd=' . $ddd . '&municipio=' . $municipio . '&uf=' . $recebe_uf . '\', \'CadastrodeMunicipio\', \'380\', \'220\', \'resizable=NO,scrollbars=1\');" title="Cadastrar um novo ramal"><img src="imgSite/novoUser.png" border="0"></td>'; |
||||
} |
||||
$numero = 0; |
||||
while ($row = pg_fetch_array($result)) { |
||||
$numero++; |
||||
$mun_id = $row["mun_id"]; |
||||
$uf = $row["uf"]; |
||||
$mun_nome = $row["mun_nome"]; |
||||
$mun_ddd = $row["mun_ddd"]; |
||||
$sql = pg_query($dbcon, 'SELECT prx_prefixo FROM pbx_municipio_prefixo WHERE mun_id=' . $mun_id . ' '); |
||||
while ($x = pg_fetch_array($sql)) { |
||||
$prefixoX .= "$x[prx_prefixo] /"; |
||||
} |
||||
$resultados .= '<tr> |
||||
<td>' . $mun_id . '</td> |
||||
<td>' . $uf . '</td> |
||||
<td>' . $mun_ddd . '</td> |
||||
<td>' . $mun_nome . '</td> |
||||
<td style="text-align: center;"><a href="javaScript:NovaJanela(\'index.php?idProg=168&acao=Mun&id=' . $mun_id . '\', \'CadastrodeMunicipio\', \'340\', \'190\', \'resizable=NO,scrollbars=1\');" title="Prefixo(s): ' . $prefixoX . '"><img src="imgSite/prefixo.jpg" width="15" height="15" border="0"></a></td> |
||||
<td style="text-align: center;"><a href="javaScript:NovaJanela(\'index.php?idProg=164&acao=in&ddd=' . $mun_ddd . '&uf=' . $uf . '\', \'CadastrodeMunicipio\', \'380\', \'220\', \'resizable=NO,scrollbars=1\');" title="Novo Municipio"><img src="imgSite/novoUser.png" border="0"></a></td> |
||||
<td style="text-align: center;"><a href="javaScript:NovaJanela(\'index.php?idProg=165&acao=up&idMunicipio=' . $mun_id . '\', \'CadastrodeMunicipio\', \'380\', \'220\', \'resizable=NO,scrollbars=1\');" title="Editar Municipio"><img src="imgSite/editaUser.png" border="0"></a></td> |
||||
<td style="text-align: center;"><a href="javaScript:DeletaMunicipio(\'' . $mun_id . '\');" title="Excluir este Municipio."><img src="imgSite/deletaUser.png" border="0"></a></td> |
||||
</tr>'; |
||||
if ($numero >= 50) { |
||||
break; |
||||
} |
||||
} |
||||
//IMPRIMI COMBO UF---- |
||||
$sqlUF = "SELECT uf FROM pbx_uf ORDER BY 1"; |
||||
$resultUF = pg_query($dbcon, $sqlUF); |
||||
$optionUF .= "<option value=\"0\" " . ($recebe_uf == 0 ? 'selected' : '' ) . ">TODOS</option>"; |
||||
while ($rowUF = pg_fetch_array($resultUF)) { |
||||
$uf_select = $rowUF["uf"]; |
||||
$optionUF .= "<option value=\"" . $uf_select . "\" " . ($uf_select == $recebe_uf ? 'selected' : '' ) . ">" . $uf_select . "</option>"; |
||||
} |
||||
|
||||
$smarty->assign('resultados', $resultados); |
||||
$smarty->assign('optionUF', $optionUF); |
||||
$smarty->assign('municipio', $municipio); |
||||
$smarty->assign('mes', $mes); |
||||
$smarty->display("cadastros/municipio/municipio.html"); |
||||
?> |
||||
<!--<input type="radio" id="online" name="online" onclick="submit()" >--> |
@ -1,89 +0,0 @@
|
||||
<?php |
||||
|
||||
$tpLayout = 1; |
||||
//LIMPA VARIAVEIS |
||||
$uf = ""; |
||||
$ddd = ""; |
||||
$nome = ""; |
||||
$acao = ""; |
||||
//Recebe |
||||
if ($_GET['acao'] == "in") { |
||||
$ddd = $_GET['ddd']; |
||||
$uf = $_GET['uf']; |
||||
$nome = $_GET['municipio']; |
||||
} else { |
||||
$uf = $_POST['uf']; |
||||
$ddd = $_POST['ddd']; |
||||
$nome = $_POST['nome']; |
||||
} |
||||
$acao = $_GET['acao']; |
||||
|
||||
//Trata Valores |
||||
function TrataValor($uf, $ddd, $nome) { |
||||
if (empty($uf) || empty($ddd) || empty($nome)) { |
||||
return "Preencha todos os campos!"; |
||||
} |
||||
if (!is_numeric($ddd)) { |
||||
$erro = "2"; |
||||
return "Preencha o campo DDD corretamente!"; |
||||
} |
||||
if ($erro < 1) { |
||||
return 1; |
||||
} |
||||
} |
||||
|
||||
//funcao insert |
||||
function ExecBanco($dbcon, $tabela, $uf, $ddd, $nome, $id) { |
||||
//verifica se ja exite municipio |
||||
$sql = "SELECT uf,mun_nome,mun_ddd FROM $tabela WHERE uf='$uf' AND mun_ddd='$ddd' AND mun_nome='$nome'"; |
||||
$query = pg_query($dbcon, $sql); |
||||
if ($resultRow = pg_num_rows($query) >= 1) { |
||||
return 0; |
||||
} else { |
||||
$insert = "INSERT INTO $tabela (uf,mun_ddd,mun_nome) VALUES ('$uf','$ddd','$nome')"; |
||||
$query = pg_query($dbcon, $insert); |
||||
|
||||
$sql = "SELECT mun_id FROM $tabela WHERE uf='$uf' AND mun_ddd='$ddd' AND mun_nome='$nome'"; |
||||
$query = pg_query($dbcon, $sql); |
||||
if (pg_num_rows($query) >= 1) { |
||||
return 1; |
||||
} else { |
||||
return 0; |
||||
} |
||||
} |
||||
} |
||||
|
||||
//verifica tratamento dos valores |
||||
if (TrataValor($uf, $ddd, $nome) == 1) { |
||||
|
||||
$tabela = "pbx_municipio_classifica"; |
||||
$inseri = ExecBanco($dbcon, $tabela, $uf, $ddd, $nome, $id); |
||||
//retorna verdadeiro se registro for inserido |
||||
if ($inseri == 1) { |
||||
$mes = "Registro inserido com sucesso!"; |
||||
} else { |
||||
$mes = "O registro já existe na base de dados!"; |
||||
} |
||||
} |
||||
// |
||||
if (!is_numeric(TrataValor($uf, $ddd, $nome))) { |
||||
$mes .= TrataValor($uf, $ddd, $nome); |
||||
} |
||||
if ($_GET['acao'] == "inEX") { |
||||
$nome = $_GET['municipio']; |
||||
$uf = $_GET['uf']; |
||||
} |
||||
|
||||
//IMPRIMI COMBO UF---- |
||||
$sqlUF = "SELECT uf FROM pbx_uf ORDER BY 1"; |
||||
$resultUF = pg_query($dbcon, $sqlUF); |
||||
while ($rowUF = pg_fetch_array($resultUF)) { |
||||
$uf_select = $rowUF["uf"]; |
||||
$optionUF .= "<option value=\"" . $uf_select . "\" " . ($uf_select == $uf ? 'selected' : '' ) . ">" . $uf_select . "</option>"; |
||||
} |
||||
$smarty->assign('mes', $mes); |
||||
$smarty->assign('optionUF', $optionUF); |
||||
$smarty->assign('ddd', $ddd); |
||||
$smarty->assign('nome', $nome); |
||||
$smarty->display("cadastros/municipio/municipioInsert.html"); |
||||
?> |
@ -1,100 +0,0 @@
|
||||
<?php |
||||
|
||||
$tpLayout = 1; |
||||
//Limpa valores |
||||
$id = ""; |
||||
$finalizar = ""; |
||||
//Recebe |
||||
if (empty($_GET['id'])) { |
||||
if ($_GET['acao'] == "deleta") { |
||||
$id = $_GET['prefixo']; |
||||
$id = substr($id, (strlen($id) - 5), strlen($id)); |
||||
} else { |
||||
$id = $_POST['id']; |
||||
} |
||||
} else { |
||||
$id = $_GET['id']; |
||||
} |
||||
|
||||
|
||||
$finalizar = $_POST['finalizar']; |
||||
//Desenvolvimento |
||||
////DELETA |
||||
if ($_GET['acao'] == "deleta") { |
||||
$prefixo = $_GET['prefixo']; |
||||
$prefixo = substr($prefixo, 0, 6); |
||||
; |
||||
$sql = "DELETE FROM pbx_municipio_prefixo WHERE prx_prefixo='$prefixo'"; |
||||
$query = pg_query($dbcon, $sql); |
||||
} |
||||
|
||||
|
||||
$sql = "SELECT a.mun_id,a.uf,a.mun_ddd,b.prx_prefixo FROM pbx_municipio_classifica a LEFT OUTER JOIN pbx_municipio_prefixo b ON a.mun_id=b.mun_id WHERE a.mun_id=$id"; |
||||
$result = pg_query($dbcon, $sql); |
||||
if (pg_num_rows($result) < 1) { |
||||
$mes = 'Nenhum prefixo relacionado!'; |
||||
} |
||||
while ($row = pg_fetch_array($result)) { |
||||
$id = $row['mun_id']; |
||||
$uf = $row['uf']; |
||||
$prefixoX = $row['prx_prefixo']; |
||||
$ddd = $row['mun_ddd']; |
||||
$prefixoX = substr($prefixoX, (strlen($prefixoX) - 4), strlen($prefixoX)); |
||||
if (empty($prefixoX)) { |
||||
$prefixoX = "Insira um novo prefixo!! "; |
||||
} |
||||
|
||||
if ($dr = 1) { |
||||
$color = '#FFFFFF'; |
||||
$dr = 2; |
||||
} else { |
||||
$color = '#CCCCCC'; |
||||
$dr = 1; |
||||
} |
||||
$resultados .= ' |
||||
<tr> |
||||
<td bgcolor=' . $color . '>' . $uf . '/' . $ddd . '</td> |
||||
<td bgcolor=' . $color . '>' . $prefixoX . '</td> |
||||
<td style="text-align: center;"><a href="javaScript:DeletaPrefixo(\'' . $ddd . '' . $prefixoX . ',' . $id . '\');" title="Excluir este Prefixo."><img src="imgSite/deletaUser.png" border="0"></a></td> |
||||
</tr> |
||||
'; |
||||
$smarty->assign('ddd', $ddd); |
||||
} |
||||
|
||||
//// INSERT |
||||
if ($finalizar == "Gravar") { |
||||
$ddd = $_POST['ddd']; |
||||
$prefixo = $_POST['prefixo']; |
||||
if (empty($prefixo)) { |
||||
$mes = "Por favor preencha o campo prefixo!"; |
||||
} else { |
||||
|
||||
if (!is_numeric($prefixo)) { |
||||
$mes = "Por favor preencha o campo prefixo corretamente!"; |
||||
} else { |
||||
$busca = "SELECT prx_prefixo FROM pbx_municipio_prefixo WHERE mun_id='$id' AND prx_prefixo='$ddd$prefixo'"; |
||||
$result = pg_query($dbcon, $busca); |
||||
if (pg_num_rows($result) >= 1) { |
||||
$mes = "Prefixo ja existente!"; |
||||
} else { |
||||
$insert = "INSERT INTO pbx_municipio_prefixo (mun_id,prx_prefixo) VALUES ('$id','$ddd$prefixo')"; |
||||
$query = pg_query($dbcon, $insert); |
||||
$sql = "SELECT mun_id,prx_prefixo FROM pbx_municipio_prefixo WHERE mun_id='$id' AND prx_prefixo='$ddd$prefixo'"; |
||||
$result = pg_query($dbcon, $sql); |
||||
if (pg_num_rows($result) < 1) { |
||||
$mes = "O prefixo nao foi inserido!"; |
||||
} else { |
||||
$mes = "Prefixo inserido com sucesso!"; |
||||
header("Location: index.php?idProg=168&id=$id"); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
$smarty->assign('prefixo', $prefixo); |
||||
} |
||||
|
||||
$smarty->assign('resultados', $resultados); |
||||
$smarty->assign('mes', $mes); |
||||
$smarty->assign('id', $id); |
||||
$smarty->display("cadastros/municipio/municipioPrefixo.html"); |
||||
?> |
@ -1,90 +0,0 @@
|
||||
<?php |
||||
|
||||
$tpLayout = 1; |
||||
//LIMPA VARIAVEIS |
||||
$uf = ""; |
||||
$ddd = ""; |
||||
$nome = ""; |
||||
$acao = ""; |
||||
//Recebe |
||||
$id = $_GET['idMunicipio']; |
||||
$acao = $_POST['concluir']; |
||||
//imprimi registro na tela |
||||
$sql = "SELECT a.mun_id,a.mun_nome,a.mun_ddd,a.uf FROM pbx_municipio_classifica a LEFT OUTER JOIN pbx_municipio_prefixo b ON a.mun_id=b.mun_id WHERE a.mun_id='$id'"; |
||||
$query = pg_query($dbcon, $sql); |
||||
while ($row = pg_fetch_array($query)) { |
||||
$nome = $row['mun_nome']; |
||||
$ddd = $row['mun_ddd']; |
||||
$uf = $row['uf']; |
||||
} |
||||
$prefixo = substr($prefixo, (strlen($prefixo) - 4), strlen($prefixo)); |
||||
if ($acao == "Finalizar") { |
||||
//recebe valores post |
||||
$uf = $_POST['uf']; |
||||
$nome = $_POST['nome']; |
||||
$ddd = $_POST['ddd']; |
||||
$prefixo = $_POST['prefixo']; |
||||
|
||||
$id = $_POST['idMunicipio']; |
||||
//trata os valores |
||||
TrataValor($uf, $ddd, $nome); |
||||
//verifica se valores estao corretos |
||||
if (TrataValor($uf, $ddd, $nome) == 1) { |
||||
$tabela = "pbx_municipio_classifica"; |
||||
$update = ExecBancoUpdate($dbcon, $tabela, $uf, $ddd, $nome, $id); |
||||
//retorna verdadeiro se registro for inserido |
||||
if ($update == 1) { |
||||
$mes = "Registro alterado com sucesso!"; |
||||
} else { |
||||
$mes = "Nao foi possivel realizar a operação!"; |
||||
} |
||||
} |
||||
} |
||||
|
||||
//Trata Valores |
||||
function TrataValor($uf, $ddd, $nome) { |
||||
if (empty($uf) || empty($ddd) || empty($nome)) { |
||||
return "Preencha todos os campos!"; |
||||
} |
||||
if (!is_numeric($ddd)) { |
||||
$erro = "2"; |
||||
return "Preencha o campo DDD corretamente!"; |
||||
} |
||||
if ($erro < 1) { |
||||
return 1; |
||||
} |
||||
} |
||||
|
||||
//funcao update |
||||
function ExecBancoUpdate($dbcon, $tabela, $uf, $ddd, $nome, $id) { |
||||
|
||||
$update = "UPDATE $tabela SET uf='$uf' , mun_ddd='$ddd' , mun_nome='$nome' WHERE mun_id='$id'"; |
||||
$query = pg_query($dbcon, $update); |
||||
$sql = "SELECT mun_id FROM $tabela WHERE uf='$uf' AND mun_ddd='$ddd' AND mun_nome='$nome'"; |
||||
$query = pg_query($dbcon, $sql); |
||||
if (pg_num_rows($query) >= 1) { |
||||
return 1; |
||||
} else { |
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
// |
||||
if (!is_numeric(TrataValor($uf, $ddd, $nome))) { |
||||
$mes .= TrataValor($uf, $ddd, $nome); |
||||
} |
||||
//IMPRIMI COMBO UF---- |
||||
$sqlUF = "SELECT uf FROM pbx_uf ORDER BY 1"; |
||||
$resultUF = pg_query($dbcon, $sqlUF); |
||||
while ($rowUF = pg_fetch_array($resultUF)) { |
||||
$uf_select = $rowUF["uf"]; |
||||
$optionUF .= "<option value=\"" . $uf_select . "\" " . ($uf_select == $uf ? 'selected' : '' ) . ">" . $uf_select . "</option>"; |
||||
} |
||||
$smarty->assign('mes', $mes); |
||||
$smarty->assign('optionUF', $optionUF); |
||||
$smarty->assign('ddd', $ddd); |
||||
$smarty->assign('nome', $nome); |
||||
$smarty->assign('id', $id); |
||||
$smarty->assign('prefixo', $prefixo); |
||||
$smarty->display("cadastros/municipio/municipioUpdate.html"); |
||||
?> |
Binary file not shown.
@ -1,25 +0,0 @@
|
||||
COPYRIGHT: |
||||
Copyright (c) 2011 Drew Phillips |
||||
All rights reserved. |
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, |
||||
are permitted provided that the following conditions are met: |
||||
|
||||
- Redistributions of source code must retain the above copyright notice, |
||||
this list of conditions and the following disclaimer. |
||||
- Redistributions in binary form must reproduce the above copyright notice, |
||||
this list of conditions and the following disclaimer in the documentation |
||||
and/or other materials provided with the distribution. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||||
POSSIBILITY OF SUCH DAMAGE. |
||||
|
@ -1,12 +0,0 @@
|
||||
AHGBold.ttf is used by Securimage under the following license: |
||||
|
||||
Alte Haas Grotesk is a typeface that look like an helvetica printed in an old Muller-Brockmann Book. |
||||
|
||||
These fonts are freeware and can be distributed as long as they are |
||||
together with this text file. |
||||
|
||||
I would appreciate very much to see what you have done with it anyway. |
||||
|
||||
yann le coroller |
||||
www.yannlecoroller.com |
||||
yann@lecoroller.com |
@ -1,204 +0,0 @@
|
||||
NAME: |
||||
|
||||
Securimage - A PHP class for creating captcha images and audio with many options. |
||||
|
||||
VERSION: |
||||
|
||||
3.5.4 |
||||
|
||||
AUTHOR: |
||||
|
||||
Drew Phillips <drew@drew-phillips.com> |
||||
|
||||
DOWNLOAD: |
||||
|
||||
The latest version can always be |
||||
found at http://www.phpcaptcha.org |
||||
|
||||
DOCUMENTATION: |
||||
|
||||
Online documentation of the class, methods, and variables can |
||||
be found at http://www.phpcaptcha.org/Securimage_Docs/ |
||||
|
||||
REQUIREMENTS: |
||||
|
||||
PHP 5.2 or greater |
||||
GD 2.0 |
||||
FreeType (Required, for TTF fonts) |
||||
PDO (if using Sqlite, MySQL, or PostgreSQL) |
||||
|
||||
SYNOPSIS: |
||||
|
||||
require_once 'securimage.php'; |
||||
|
||||
**Within your HTML form** |
||||
|
||||
<form method="post" action=""> |
||||
.. form elements |
||||
|
||||
<div> |
||||
<?php echo Securimage::getCaptchaHtml() ?> |
||||
</div> |
||||
</form> |
||||
|
||||
|
||||
**Within your PHP form processor** |
||||
|
||||
// Code Validation |
||||
|
||||
$image = new Securimage(); |
||||
if ($image->check($_POST['captcha_code']) == true) { |
||||
echo "Correct!"; |
||||
} else { |
||||
echo "Sorry, wrong code."; |
||||
} |
||||
|
||||
DESCRIPTION: |
||||
|
||||
What is Securimage? |
||||
|
||||
Securimage is a PHP class that is used to generate and validate CAPTCHA |
||||
images. |
||||
|
||||
The classes uses an existing PHP session or creates its own if |
||||
none is found to store the CAPTCHA code. In addition, a database can be |
||||
used instead of session storage. |
||||
|
||||
Variables within the class are used to control the style and display of |
||||
the image. The class uses TTF fonts and effects for strengthening the |
||||
security of the image. |
||||
|
||||
It also creates audible codes which are played for visually impared users. |
||||
|
||||
COPYRIGHT: |
||||
|
||||
Copyright (c) 2014 Drew Phillips |
||||
All rights reserved. |
||||
|
||||
Redistribution and use in source and binary forms, with or without |
||||
modification, are permitted provided that the following conditions are met: |
||||
|
||||
- Redistributions of source code must retain the above copyright notice, |
||||
this list of conditions and the following disclaimer. |
||||
- Redistributions in binary form must reproduce the above copyright notice, |
||||
this list of conditions and the following disclaimer in the documentation |
||||
and/or other materials provided with the distribution. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||||
POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
LICENSES: |
||||
|
||||
The WavFile.php class used in Securimage by Drew Phillips and Paul Voegler |
||||
is used under the BSD License. See WavFile.php for details. |
||||
Many thanks to Paul Voegler (http://www.voegler.eu/) for contributing to |
||||
Securimage. |
||||
|
||||
--------------------------------------------------------------------------- |
||||
Flash code created by Age Bosma & Mario Romero (animario@hotmail.com) |
||||
Many thanks for releasing this to the project! |
||||
|
||||
--------------------------------------------------------------------------- |
||||
Portions of Securimage contain code from Han-Kwang Nienhuys' PHP captcha |
||||
|
||||
Han-Kwang Nienhuys' PHP captcha |
||||
Copyright June 2007 |
||||
|
||||
This copyright message and attribution must be preserved upon |
||||
modification. Redistribution under other licenses is expressly allowed. |
||||
Other licenses include GPL 2 or higher, BSD, and non-free licenses. |
||||
The original, unrestricted version can be obtained from |
||||
http://www.lagom.nl/linux/hkcaptcha/ |
||||
|
||||
--------------------------------------------------------------------------- |
||||
AHGBold.ttf (AlteHaasGroteskBold.ttf) font was created by Yann Le Coroller |
||||
and is distributed as freeware. |
||||
|
||||
Alte Haas Grotesk is a typeface that look like an helvetica printed in an |
||||
old Muller-Brockmann Book. |
||||
|
||||
These fonts are freeware and can be distributed as long as they are |
||||
together with this text file. |
||||
|
||||
I would appreciate very much to see what you have done with it anyway. |
||||
|
||||
yann le coroller |
||||
www.yannlecoroller.com |
||||
yann@lecoroller.com |
||||
|
||||
--------------------------------------------------------------------------- |
||||
Portions of securimage_play.swf use the PopForge flash library for |
||||
playing audio |
||||
|
||||
/** |
||||
* Copyright(C) 2007 Andre Michelle and Joa Ebert |
||||
* |
||||
* PopForge is an ActionScript3 code sandbox developed by Andre Michelle |
||||
* and Joa Ebert |
||||
* http://sandbox.popforge.de |
||||
* |
||||
* PopforgeAS3Audio is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* PopforgeAS3Audio is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/> |
||||
*/ |
||||
|
||||
-------------------------------------------------------------------------- |
||||
Some graphics used are from the Humility Icon Pack by WorLord |
||||
|
||||
License: GNU/GPL (http://findicons.com/pack/1723/humility) |
||||
http://findicons.com/icon/192558/gnome_volume_control |
||||
http://findicons.com/icon/192562/gtk_refresh |
||||
|
||||
-------------------------------------------------------------------------- |
||||
Background noise sound files are from SoundJay.com |
||||
http://www.soundjay.com/tos.html |
||||
|
||||
All sound effects on this website are created by us and protected under |
||||
the copyright laws, international treaty provisions and other applicable |
||||
laws. By downloading sounds, music or any material from this site implies |
||||
that you have read and accepted these terms and conditions: |
||||
|
||||
Sound Effects |
||||
You are allowed to use the sounds free of charge and royalty free in your |
||||
projects (such as films, videos, games, presentations, animations, stage |
||||
plays, radio plays, audio books, apps) be it for commercial or |
||||
non-commercial purposes. |
||||
|
||||
But you are NOT allowed to |
||||
- post the sounds (as sound effects or ringtones) on any website for |
||||
others to download, copy or use |
||||
- use them as a raw material to create sound effects or ringtones that |
||||
you will sell, distribute or offer for downloading |
||||
- sell, re-sell, license or re-license the sounds (as individual sound |
||||
effects or as a sound effects library) to anyone else |
||||
- claim the sounds as yours |
||||
- link directly to individual sound files |
||||
- distribute the sounds in apps or computer programs that are clearly |
||||
sound related in nature (such as sound machine, sound effect |
||||
generator, ringtone maker, funny sounds app, sound therapy app, etc.) |
||||
or in apps or computer programs that use the sounds as the program's |
||||
sound resource library for other people's use (such as animation |
||||
creator, digital book creator, song maker software, etc.). If you are |
||||
developing such computer programs, contact us for licensing options. |
||||
|
||||
If you use the sound effects, please consider giving us a credit and |
||||
linking back to us but it's not required. |
||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -1,207 +0,0 @@
|
||||
<?php |
||||
session_start(); // this MUST be called prior to any output including whitespaces and line breaks! |
||||
|
||||
$GLOBALS['ct_recipient'] = 'YOU@EXAMPLE.COM'; // Change to your email address! |
||||
$GLOBALS['ct_msg_subject'] = 'Securimage Test Contact Form'; |
||||
|
||||
$GLOBALS['DEBUG_MODE'] = 1; |
||||
// CHANGE TO 0 TO TURN OFF DEBUG MODE |
||||
// IN DEBUG MODE, ONLY THE CAPTCHA CODE IS VALIDATED, AND NO EMAIL IS SENT |
||||
|
||||
|
||||
// Process the form, if it was submitted |
||||
process_si_contact_form(); |
||||
|
||||
?> |
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
||||
<html xmlns="http://www.w3.org/1999/xhtml"> |
||||
<head> |
||||
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" /> |
||||
<title>Securimage Example Form</title> |
||||
<style type="text/css"> |
||||
<!-- |
||||
#success_message { border: 1px solid #000; width: 550px; text-align: left; padding: 10px 7px; background: #33ff33; color: #000; font-weight; bold; font-size: 1.2em; border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px; } |
||||
fieldset { width: 90%; } |
||||
legend { font-size: 24px; } |
||||
.note { font-size: 18px; } |
||||
--> |
||||
</style> |
||||
</head> |
||||
<body> |
||||
|
||||
<fieldset> |
||||
<legend>Example Form</legend> |
||||
|
||||
<p class="note"> |
||||
This is an example PHP form that processes user information, checks for errors, and validates the captcha code.<br /> |
||||
This example form also demonstrates how to submit a form to itself to display error messages. |
||||
</p> |
||||
|
||||
<div id="success_message" style="display: none">Your message has been sent!<br />We will contact you as soon as possible.</div> |
||||
|
||||
<form method="post" action="" id="contact_form" onsubmit="return processForm()"> |
||||
<input type="hidden" name="do" value="contact" /> |
||||
|
||||
<p> |
||||
<strong>Name*:</strong><br /> |
||||
<input type="text" name="ct_name" size="35" value="" /> |
||||
</p> |
||||
|
||||
<p> |
||||
<strong>Email*:</strong><br /> |
||||
<input type="text" name="ct_email" size="35" value="" /> |
||||
</p> |
||||
|
||||
<p> |
||||
<strong>URL:</strong><br /> |
||||
<input type="text" name="ct_URL" size="35" value="" /> |
||||
</p> |
||||
|
||||
<p> |
||||
<strong>Message*:</strong><br /> |
||||
<textarea name="ct_message" rows="12" cols="60"></textarea> |
||||
</p> |
||||
|
||||
<p> |
||||
<img id="siimage" style="border: 1px solid #000; margin-right: 15px" src="./securimage_show.php?sid=<?php echo md5(uniqid()) ?>" alt="CAPTCHA Image" align="left" />
|
||||
<object type="application/x-shockwave-flash" data="./securimage_play.swf?bgcol=#ffffff&icon_file=./images/audio_icon.png&audio_file=./securimage_play.php" height="32" width="32"> |
||||
<param name="movie" value="./securimage_play.swf?bgcol=#ffffff&icon_file=./images/audio_icon.png&audio_file=./securimage_play.php" /> |
||||
</object> |
||||
|
||||
<a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false"><img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0" /></a><br /> |
||||
<strong>Enter Code*:</strong><br /> |
||||
<input type="text" name="ct_captcha" size="12" maxlength="8" /> |
||||
</p> |
||||
|
||||
<p> |
||||
<br /> |
||||
<input type="submit" value="Submit Message" /> |
||||
</p> |
||||
|
||||
</form> |
||||
</fieldset> |
||||
|
||||
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> |
||||
<script type="text/javascript"> |
||||
$.noConflict(); |
||||
|
||||
function reloadCaptcha() |
||||
{ |
||||
jQuery('#siimage').prop('src', './securimage_show.php?sid=' + Math.random()); |
||||
} |
||||
|
||||
function processForm() |
||||
{ |
||||
jQuery.ajax({ |
||||
url: '<?php echo $_SERVER['PHP_SELF'] ?>',
|
||||
type: 'POST', |
||||
data: jQuery('#contact_form').serialize(), |
||||
dataType: 'json', |
||||
}).done(function(data) { |
||||
if (data.error === 0) { |
||||
jQuery('#success_message').show(); |
||||
jQuery('#contact_form')[0].reset(); |
||||
reloadCaptcha(); |
||||
setTimeout("jQuery('#success_message').fadeOut()", 12000); |
||||
} else { |
||||
alert("There was an error with your submission.\n\n" + data.message); |
||||
} |
||||
}); |
||||
|
||||
return false; |
||||
} |
||||
</script> |
||||
|
||||
</body> |
||||
</html> |
||||
|
||||
<?php |
||||
|
||||
// The form processor PHP code |
||||
function process_si_contact_form() |
||||
{ |
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST' && @$_POST['do'] == 'contact') { |
||||
// if the form has been submitted |
||||
|
||||
foreach($_POST as $key => $value) { |
||||
if (!is_array($key)) { |
||||
// sanitize the input data |
||||
if ($key != 'ct_message') $value = strip_tags($value); |
||||
$_POST[$key] = htmlspecialchars(stripslashes(trim($value))); |
||||
} |
||||
} |
||||
|
||||
$name = @$_POST['ct_name']; // name from the form |
||||
$email = @$_POST['ct_email']; // email from the form |
||||
$URL = @$_POST['ct_URL']; // url from the form |
||||
$message = @$_POST['ct_message']; // the message from the form |
||||
$captcha = @$_POST['ct_captcha']; // the user's entry for the captcha code |
||||
$name = substr($name, 0, 64); // limit name to 64 characters |
||||
|
||||
$errors = array(); // initialize empty error array |
||||
|
||||
if (isset($GLOBALS['DEBUG_MODE']) && $GLOBALS['DEBUG_MODE'] == false) { |
||||
// only check for errors if the form is not in debug mode |
||||
|
||||
if (strlen($name) < 3) { |
||||
// name too short, add error |
||||
$errors['name_error'] = 'Your name is required'; |
||||
} |
||||
|
||||
if (strlen($email) == 0) { |
||||
// no email address given |
||||
$errors['email_error'] = 'Email address is required'; |
||||
} else if ( !preg_match('/^(?:[\w\d-]+\.?)+@(?:(?:[\w\d]\-?)+\.)+\w{2,4}$/i', $email)) { |
||||
// invalid email format |
||||
$errors['email_error'] = 'Email address entered is invalid'; |
||||
} |
||||
|
||||
if (strlen($message) < 20) { |
||||
// message length too short |
||||
$errors['message_error'] = 'Please enter a message'; |
||||
} |
||||
} |
||||
|
||||
// Only try to validate the captcha if the form has no errors |
||||
// This is especially important for ajax calls |
||||
if (sizeof($errors) == 0) { |
||||
require_once dirname(__FILE__) . '/securimage.php'; |
||||
$securimage = new Securimage(); |
||||
|
||||
if ($securimage->check($captcha) == false) { |
||||
$errors['captcha_error'] = 'Incorrect security code entered'; |
||||
} |
||||
} |
||||
|
||||
if (sizeof($errors) == 0) { |
||||
// no errors, send the form |
||||
$time = date('r'); |
||||
$message = "A message was submitted from the contact form. The following information was provided.<br /><br />" |
||||
. "Name: $name<br />" |
||||
. "Email: $email<br />" |
||||
. "URL: $URL<br />" |
||||
. "Message:<br />" |
||||
. "<pre>$message</pre>" |
||||
. "<br /><br />IP Address: {$_SERVER['REMOTE_ADDR']}<br />" |
||||
. "Time: $time<br />" |
||||
. "Browser: {$_SERVER['HTTP_USER_AGENT']}<br />"; |
||||
|
||||
if (isset($GLOBALS['DEBUG_MODE']) && $GLOBALS['DEBUG_MODE'] == false) { |
||||
// send the message with mail() |
||||
mail($GLOBALS['ct_recipient'], $GLOBALS['ct_msg_subject'], $message, "From: {$GLOBALS['ct_recipient']}\r\nReply-To: {$email}\r\nContent-type: text/html; charset=ISO-8859-1\r\nMIME-Version: 1.0"); |
||||
} |
||||
|
||||
$return = array('error' => 0, 'message' => 'OK'); |
||||
die(json_encode($return)); |
||||
} else { |
||||
$errmsg = ''; |
||||
foreach($errors as $key => $error) { |
||||
// set up error messages to display with each field |
||||
$errmsg .= " - {$error}\n"; |
||||
} |
||||
|
||||
$return = array('error' => 1, 'message' => $errmsg); |
||||
die(json_encode($return)); |
||||
} |
||||
} // POST |
||||
} // function process_si_contact_form() |
@ -1,203 +0,0 @@
|
||||
<?php |
||||
session_start(); // this MUST be called prior to any output including whitespaces and line breaks! |
||||
|
||||
$GLOBALS['DEBUG_MODE'] = 1; |
||||
// CHANGE TO 0 TO TURN OFF DEBUG MODE |
||||
// IN DEBUG MODE, ONLY THE CAPTCHA CODE IS VALIDATED, AND NO EMAIL IS SENT |
||||
|
||||
$GLOBALS['ct_recipient'] = 'YOU@EXAMPLE.COM'; // Change to your email address! Make sure DEBUG_MODE above is 0 for mail to send! |
||||
$GLOBALS['ct_msg_subject'] = 'Securimage Test Contact Form'; |
||||
|
||||
?> |
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
||||
<html xmlns="http://www.w3.org/1999/xhtml"> |
||||
<head> |
||||
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" /> |
||||
<title>Securimage Example Form</title> |
||||
<style type="text/css"> |
||||
<!-- |
||||
div.error { display: block; color: #f00; font-weight: bold; font-size: 1.2em; } |
||||
span.error { display: block; color: #f00; font-style: italic; } |
||||
.success { color: #00f; font-weight: bold; font-size: 1.2em; } |
||||
form label { display: block; font-weight: bold; } |
||||
fieldset { width: 90%; } |
||||
legend { font-size: 24px; } |
||||
.note { font-size: 18px; |
||||
--> |
||||
</style> |
||||
</head> |
||||
<body> |
||||
|
||||
<fieldset> |
||||
<legend>Example Form</legend> |
||||
|
||||
<p class="note"> |
||||
This is an example PHP form that processes user information, checks for errors, and validates the captcha code.<br /> |
||||
This example form also demonstrates how to submit a form to itself to display error messages. |
||||
</p> |
||||
|
||||
<?php |
||||
|
||||
process_si_contact_form(); // Process the form, if it was submitted |
||||
|
||||
if (isset($_SESSION['ctform']['error']) && $_SESSION['ctform']['error'] == true): /* The last form submission had 1 or more errors */ ?> |
||||
<div class="error">There was a problem with your submission. Errors are displayed below in red.</div><br /> |
||||
<?php elseif (isset($_SESSION['ctform']['success']) && $_SESSION['ctform']['success'] == true): /* form was processed successfully */ ?> |
||||
<div class="success">The captcha was correct and the message has been sent! The captcha was solved in <?php echo $_SESSION['ctform']['timetosolve'] ?> seconds.</div><br />
|
||||
<?php endif; ?> |
||||
|
||||
<form method="post" action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI'] . $_SERVER['QUERY_STRING']) ?>" id="contact_form">
|
||||
<input type="hidden" name="do" value="contact" /> |
||||
|
||||
<p> |
||||
<label for="ct_name">Name*:</label> |
||||
<?php echo @$_SESSION['ctform']['name_error'] ?> |
||||
<input type="text" name="ct_name" size="35" value="<?php echo htmlspecialchars(@$_SESSION['ctform']['ct_name']) ?>" />
|
||||
</p> |
||||
|
||||
<p> |
||||
<label for="ct_email">Email*:</label> |
||||
<?php echo @$_SESSION['ctform']['email_error'] ?> |
||||
<input type="text" name="ct_email" size="35" value="<?php echo htmlspecialchars(@$_SESSION['ctform']['ct_email']) ?>" />
|
||||
</p> |
||||
|
||||
<p> |
||||
<label for="ct_URL">URL:</label> |
||||
<?php echo @$_SESSION['ctform']['URL_error'] ?> |
||||
<input type="text" name="ct_URL" size="35" value="<?php echo htmlspecialchars(@$_SESSION['ctform']['ct_URL']) ?>" />
|
||||
</p> |
||||
|
||||
<p> |
||||
<label for="ct_message">Message*:</label> |
||||
<?php echo @$_SESSION['ctform']['message_error'] ?> |
||||
<textarea name="ct_message" rows="12" cols="60"><?php echo htmlspecialchars(@$_SESSION['ctform']['ct_message']) ?></textarea>
|
||||
</p> |
||||
|
||||
<p> |
||||
<?php |
||||
// show captcha HTML using Securimage::getCaptchaHtml() |
||||
require_once 'securimage.php'; |
||||
$options = array(); |
||||
$options['input_name'] = 'ct_captcha'; // change name of input element for form post |
||||
|
||||
if (!empty($_SESSION['ctform']['captcha_error'])) { |
||||
// error html to show in captcha output |
||||
$options['error_html'] = $_SESSION['ctform']['captcha_error']; |
||||
} |
||||
|
||||
echo Securimage::getCaptchaHtml($options); |
||||
?> |
||||
</p> |
||||
|
||||
<p> |
||||
<br /> |
||||
<input type="submit" value="Submit Message" /> |
||||
</p> |
||||
|
||||
</form> |
||||
</fieldset> |
||||
|
||||
</body> |
||||
</html> |
||||
|
||||
<?php |
||||
|
||||
// The form processor PHP code |
||||
function process_si_contact_form() |
||||
{ |
||||
$_SESSION['ctform'] = array(); // re-initialize the form session data |
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST' && @$_POST['do'] == 'contact') { |
||||
// if the form has been submitted |
||||
|
||||
foreach($_POST as $key => $value) { |
||||
if (!is_array($key)) { |
||||
// sanitize the input data |
||||
if ($key != 'ct_message') $value = strip_tags($value); |
||||
$_POST[$key] = htmlspecialchars(stripslashes(trim($value))); |
||||
} |
||||
} |
||||
|
||||
$name = @$_POST['ct_name']; // name from the form |
||||
$email = @$_POST['ct_email']; // email from the form |
||||
$URL = @$_POST['ct_URL']; // url from the form |
||||
$message = @$_POST['ct_message']; // the message from the form |
||||
$captcha = @$_POST['ct_captcha']; // the user's entry for the captcha code |
||||
$name = substr($name, 0, 64); // limit name to 64 characters |
||||
|
||||
$errors = array(); // initialize empty error array |
||||
|
||||
if (isset($GLOBALS['DEBUG_MODE']) && $GLOBALS['DEBUG_MODE'] == false) { |
||||
// only check for errors if the form is not in debug mode |
||||
|
||||
if (strlen($name) < 3) { |
||||
// name too short, add error |
||||
$errors['name_error'] = 'Your name is required'; |
||||
} |
||||
|
||||
if (strlen($email) == 0) { |
||||
// no email address given |
||||
$errors['email_error'] = 'Email address is required'; |
||||
} else if ( !preg_match('/^(?:[\w\d-]+\.?)+@(?:(?:[\w\d]\-?)+\.)+\w{2,4}$/i', $email)) { |
||||
// invalid email format |
||||
$errors['email_error'] = 'Email address entered is invalid'; |
||||
} |
||||
|
||||
if (strlen($message) < 20) { |
||||
// message length too short |
||||
$errors['message_error'] = 'Your message must be longer than 20 characters'; |
||||
} |
||||
} |
||||
|
||||
// Only try to validate the captcha if the form has no errors |
||||
// This is especially important for ajax calls |
||||
if (sizeof($errors) == 0) { |
||||
require_once dirname(__FILE__) . '/securimage.php'; |
||||
$securimage = new Securimage(); |
||||
|
||||
if ($securimage->check($captcha) == false) { |
||||
$errors['captcha_error'] = 'Incorrect security code entered<br />'; |
||||
} |
||||
} |
||||
|
||||
if (sizeof($errors) == 0) { |
||||
// no errors, send the form |
||||
$time = date('r'); |
||||
$message = "A message was submitted from the contact form. The following information was provided.<br /><br />" |
||||
. "<em>Name: $name</em><br />" |
||||
. "<em>Email: $email</em><br />" |
||||
. "<em>URL: $URL</em><br />" |
||||
. "<em>Message:</em><br />" |
||||
. "<pre>$message</pre>" |
||||
. "<br /><br /><em>IP Address:</em> {$_SERVER['REMOTE_ADDR']}<br />" |
||||
. "<em>Time:</em> $time<br />" |
||||
. "<em>Browser:</em> {$_SERVER['HTTP_USER_AGENT']}<br />"; |
||||
|
||||
$message = wordwrap($message, 70); |
||||
|
||||
if (isset($GLOBALS['DEBUG_MODE']) && $GLOBALS['DEBUG_MODE'] == false) { |
||||
// send the message with mail() |
||||
mail($GLOBALS['ct_recipient'], $GLOBALS['ct_msg_subject'], $message, "From: {$GLOBALS['ct_recipient']}\r\nReply-To: {$email}\r\nContent-type: text/html; charset=UTF-8\r\nMIME-Version: 1.0"); |
||||
} |
||||
|
||||
$_SESSION['ctform']['timetosolve'] = $securimage->getTimeToSolve(); |
||||
$_SESSION['ctform']['error'] = false; // no error with form |
||||
$_SESSION['ctform']['success'] = true; // message sent |
||||
} else { |
||||
// save the entries, this is to re-populate the form |
||||
$_SESSION['ctform']['ct_name'] = $name; // save name from the form submission |
||||
$_SESSION['ctform']['ct_email'] = $email; // save email |
||||
$_SESSION['ctform']['ct_URL'] = $URL; // save URL |
||||
$_SESSION['ctform']['ct_message'] = $message; // save message |
||||
|
||||
foreach($errors as $key => $error) { |
||||
// set up error messages to display with each field |
||||
$_SESSION['ctform'][$key] = "<span class=\"error\">$error</span>"; |
||||
} |
||||
|
||||
$_SESSION['ctform']['error'] = true; // set error floag |
||||
} |
||||
} // POST |
||||
} |
||||
|
||||
$_SESSION['ctform']['success'] = false; // clear success value after running |
File diff suppressed because it is too large
Load Diff
@ -1,65 +0,0 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* Project: Securimage: A PHP class for creating and managing form CAPTCHA images<br /> |
||||
* File: securimage_play.php<br /> |
||||
* |
||||
* This library is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU Lesser General Public |
||||
* License as published by the Free Software Foundation; either |
||||
* version 2.1 of the License, or any later version.<br /><br /> |
||||
* |
||||
* This library is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
* Lesser General Public License for more details.<br /><br /> |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public |
||||
* License along with this library; if not, write to the Free Software |
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA<br /><br /> |
||||
* |
||||
* Any modifications to the library should be indicated clearly in the source code |
||||
* to inform users that the changes are not a part of the original software.<br /><br /> |
||||
* |
||||
* If you found this script useful, please take a quick moment to rate it.<br /> |
||||
* http://www.hotscripts.com/rate/49400.html Thanks. |
||||
* |
||||
* @link http://www.phpcaptcha.org Securimage PHP CAPTCHA |
||||
* @link http://www.phpcaptcha.org/latest.zip Download Latest Version |
||||
* @link http://www.phpcaptcha.org/Securimage_Docs/ Online Documentation |
||||
* @copyright 2012 Drew Phillips |
||||
* @author Drew Phillips <drew@drew-phillips.com> |
||||
* @version 3.5.2 (Feb 15, 2014) |
||||
* @package Securimage |
||||
* |
||||
*/ |
||||
|
||||
require_once dirname(__FILE__) . '/securimage.php'; |
||||
|
||||
// if using database, adjust these options as necessary and change $img = new Securimage(); to $img = new Securimage($options); |
||||
// see test.mysql.php or test.sqlite.php for examples |
||||
$options = array( |
||||
'use_database' => true, |
||||
'database_name' => '', |
||||
'database_user' => '', |
||||
'database_driver' => Securimage::SI_DRIVER_MYSQL |
||||
); |
||||
|
||||
$img = new Securimage(); |
||||
|
||||
// Other audio settings |
||||
//$img->audio_use_sox = true; |
||||
//$img->audio_use_noise = true; |
||||
//$img->degrade_audio = false; |
||||
//$img->sox_binary_path = 'sox'; |
||||
|
||||
// To use an alternate language, uncomment the following and download the files from phpcaptcha.org |
||||
// $img->audio_path = $img->securimage_path . '/audio/es/'; |
||||
|
||||
// If you have more than one captcha on a page, one must use a custom namespace |
||||
// $img->namespace = 'form2'; |
||||
|
||||
// set namespace if supplied to script via HTTP GET |
||||
if (!empty($_GET['namespace'])) $img->setNamespace($_GET['namespace']); |
||||
|
||||
$img->outputAudioFile(); |
Binary file not shown.
@ -1,79 +0,0 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* Project: Securimage: A PHP class for creating and managing form CAPTCHA images<br /> |
||||
* File: securimage_show.php<br /> |
||||
* |
||||
* Copyright (c) 2013, Drew Phillips |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without modification, |
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* - Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||||
* POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
* Any modifications to the library should be indicated clearly in the source code |
||||
* to inform users that the changes are not a part of the original software.<br /><br /> |
||||
* |
||||
* If you found this script useful, please take a quick moment to rate it.<br /> |
||||
* http://www.hotscripts.com/rate/49400.html Thanks. |
||||
* |
||||
* @link http://www.phpcaptcha.org Securimage PHP CAPTCHA |
||||
* @link http://www.phpcaptcha.org/latest.zip Download Latest Version |
||||
* @link http://www.phpcaptcha.org/Securimage_Docs/ Online Documentation |
||||
* @copyright 2013 Drew Phillips |
||||
* @author Drew Phillips <drew@drew-phillips.com> |
||||
* @version 3.5.2 (Feb 15, 2014) |
||||
* @package Securimage |
||||
* |
||||
*/ |
||||
|
||||
// Remove the "//" from the following line for debugging problems |
||||
// error_reporting(E_ALL); ini_set('display_errors', 1); |
||||
|
||||
require_once dirname(__FILE__) . '/securimage.php'; |
||||
|
||||
$img = new Securimage(); |
||||
|
||||
// You can customize the image by making changes below, some examples are included - remove the "//" to uncomment |
||||
|
||||
//$img->ttf_file = './Quiff.ttf'; |
||||
//$img->captcha_type = Securimage::SI_CAPTCHA_MATHEMATIC; // show a simple math problem instead of text |
||||
//$img->case_sensitive = true; // true to use case sensitve codes - not recommended |
||||
//$img->image_height = 90; // height in pixels of the image |
||||
//$img->image_width = $img->image_height * M_E; // a good formula for image size based on the height |
||||
//$img->perturbation = .75; // 1.0 = high distortion, higher numbers = more distortion |
||||
//$img->image_bg_color = new Securimage_Color("#0099CC"); // image background color |
||||
//$img->text_color = new Securimage_Color("#EAEAEA"); // captcha text color |
||||
//$img->num_lines = 8; // how many lines to draw over the image |
||||
//$img->line_color = new Securimage_Color("#0000CC"); // color of lines over the image |
||||
//$img->image_type = SI_IMAGE_JPEG; // render as a jpeg image |
||||
//$img->signature_color = new Securimage_Color(rand(0, 64), |
||||
// rand(64, 128), |
||||
// rand(128, 255)); // random signature color |
||||
|
||||
// see securimage.php for more options that can be set |
||||
|
||||
// set namespace if supplied to script via HTTP GET |
||||
if (!empty($_GET['namespace'])) $img->setNamespace($_GET['namespace']); |
||||
|
||||
|
||||
$img->show(); // outputs the image and content headers to the browser |
||||
// alternate use: |
||||
// $img->show('/path/to/background_image.jpg'); |
File diff suppressed because it is too large
Load Diff
@ -1,89 +0,0 @@
|
||||
#!/usr/bin/php -q |
||||
<?php |
||||
|
||||
function adiciona_coluna($bdcon) { |
||||
$query = "select bloqueio_verificado from pbx_bilhetes limit 1"; |
||||
if (!pg_query($bdcon, $query)) { |
||||
$queryColuna = "alter table pbx_bilhetes add column bloqueio_verificado integer"; |
||||
pg_query($bdcon, $queryColuna); |
||||
} |
||||
} |
||||
|
||||
function registra_log($msg) { |
||||
$fp = fopen('/var/log/asterisk/bloq_algar.log', 'a'); |
||||
$now = date('Y-m-d H:i:s', time()-3600); |
||||
$sNow = "[{$now}] "; |
||||
if ($fp) { |
||||
fwrite($fp, $sNow.$msg."\n"); |
||||
fclose($fp); |
||||
} |
||||
} |
||||
|
||||
$bdcon = pg_connect("host=algar.simplesip.com.br port=5432 dbname=pbx user=contacte password=ctepgSQL"); |
||||
if (!$bdcon) { |
||||
registra_log("Erro ao conectar ao banco de dados da algar, script encerrado."); |
||||
exit(0); |
||||
} |
||||
$queryEmpresas = "select emp_cnpj, emp_vpn from vds_empresas where emp_status = 0"; |
||||
if (!($resourceEmpresa = pg_query($queryEmpresas))) { |
||||
registra_log("Erro ao buscar empresas no banco de dados da algar, script encerrado."); |
||||
exit(0); |
||||
} |
||||
$empresas = pg_fetch_all($resourceEmpresa); |
||||
foreach ($empresas as $empresa) { |
||||
$bdcon0 = pg_connect("host={$empresa['emp_vpn']} port=5432 dbname=pbx user=contacte password=ctepgSQL connect_timeout=10"); |
||||
if (!$bdcon0) { |
||||
continue; |
||||
} |
||||
adiciona_coluna($bdcon0); |
||||
$caminhoPadrao = "/var/lib/asterisk/sounds/appsounds/"; |
||||
$bloqueios = ["ligacaoinvalidaanatel", "horarionaopermitidoanatel", "limitdiarioanatel", "limitemensalanatel"]; |
||||
|
||||
$queryChamadas = "select uniqueid, bloqueio_verificado from pbx_bilhetes where lastapp = 'Playback' " |
||||
. "and (bloqueio_verificado is null or bloqueio_verificado = -1) " |
||||
. "and lastdata in ('{$caminhoPadrao}{$bloqueios[0]}', " |
||||
. "'{$caminhoPadrao}{$bloqueios[1]}', " |
||||
. "'{$caminhoPadrao}{$bloqueios[2]}', " |
||||
. "'{$caminhoPadrao}{$bloqueios[3]}')"; |
||||
|
||||
if (!($resChamadas = pg_query($bdcon0, $queryChamadas))) { |
||||
registra_log("Falha ao procurar audios na tabela pbx_bilhetes do banco de dados do cliente {$empresa['emp_cnpj']}"); |
||||
continue; |
||||
} |
||||
if(!($chamadasCliente = pg_fetch_all($resChamadas))) { |
||||
continue; |
||||
} |
||||
foreach ($chamadasCliente as $chamada) { |
||||
$updateChamada = "update vds_chamadas set bloqueio_anatel = 1 where uid = '{$chamada['uniqueid']}'"; |
||||
$queryChamada = pg_query($bdcon, $updateChamada); |
||||
if ($queryChamada) { |
||||
$updateCliente = "update pbx_bilhetes set bloqueio_verificado = 1 where uniqueid = '{$chamada['uniqueid']}'"; |
||||
$queryCliente = pg_query($bdcon0, $updateCliente); |
||||
if (!queryCliente) { |
||||
$msg = "Erro ao atualizar bloqueio_verificado = 1 para a chamada de uid {$chamada['uniqueid']} na tabela pbx_bilhetes do banco de dados da empresa {$empresa['emp_cnpj']} apesar de ter sido atualizado no banco de dados da algar"; |
||||
registra_log($msg); |
||||
} |
||||
} else { |
||||
if ($chamada['bloqueio_verificado'] == '-1') { |
||||
$updateCliente = "update pbx_bilhetes set bloqueio_verificado = 2 where uniqueid = '{$chamada['uniqueid']}'"; |
||||
if(!(pg_query($bdcon0, $updateCliente))) { |
||||
$msg = "Erro ao atualizar bloqueio_verificado = 2 do audio {$chamada['uniqueid']} na tabela pbx_bilhetes do banco de dados do cliente {$empresa['emp_cnpj']}"; |
||||
registra_log($msg); |
||||
} else { |
||||
$msg = "O audio {$chamada['uniqueid']} foi atualizado para bloqueio_verificado = 2 no banco de dados do cliente {$empresa['emp_cnpj']}," |
||||
. " ou seja, foi marcado como erro e precisa ser analisado."; |
||||
registra_log($msg); |
||||
} |
||||
} else if ($chamada['bloqueio_verificado'] == NULL) { |
||||
$updateCliente = "update pbx_bilhetes set bloqueio_verificado = -1 where uniqueid = '{$chamada['uniqueid']}'"; |
||||
if (!pg_query($bdcon0, $updateCliente)) { |
||||
$msg = "Erro ao atualizar o audio {$chamada['uniqueid']} para bloqueio_verificado = -1 na tabela pbx_bilhetes do banco de dados do cliente {$empresa['emp_cnpj']}"; |
||||
registra_log($msg); |
||||
} |
||||
} |
||||
$msg = "Erro ao atualizar a chamada de uid {$chamada['uniqueid']} para bloqueio_anatel = 1 da empresa de cnpj {$empresa['emp_cnpj']} no banco de dados da algar."; |
||||
registra_log($msg); |
||||
} |
||||
} |
||||
} |
||||
?> |
@ -1,17 +0,0 @@
|
||||
<?php |
||||
$file = basename(dirname(__FILE__)); |
||||
envia_sms("65992893913", sprintf(sprintf("http://repositorio.simplesip.com.br/%s/relatorioMonitoraAlgar.php", $file))); |
||||
|
||||
function envia_sms($telefone, $mensagem) { |
||||
$res = curl_init("https://www.iagentesms.com.br/webservices/http.php?metodo=envio" |
||||
. "&usuario=desenvolvimento@simplesip.com.br" |
||||
. "&senha=SimpleS_root" |
||||
. "&celular={$telefone}" |
||||
. "&mensagem={$mensagem}"); |
||||
//curl_setopt($res, CURLOPT_RETURNTRANSFER, true); |
||||
curl_setopt($res, CURLOPT_SSL_VERIFYPEER, false); |
||||
curl_setopt($res, CURLOPT_SSL_VERIFYHOST, false); |
||||
curl_exec($res); |
||||
curl_close($res); |
||||
return $res; |
||||
} |
@ -1,88 +0,0 @@
|
||||
<?php |
||||
header("Content-Type: application/json"); |
||||
|
||||
function seleciona_emp_id($banco, $cnpj_consulta) { |
||||
$con = pg_connect($banco); |
||||
if ($con) { |
||||
$query = "select emp_id from vds_empresas where emp_cnpj = '".$cnpj_consulta."'"; |
||||
$realiza_query = pg_query($con, $query); |
||||
if ($realiza_query) { |
||||
$emp_id = pg_fetch_assoc($realiza_query); |
||||
return $emp_id['emp_id']; |
||||
} else { |
||||
echo "Falha ao executar query"; |
||||
exit(0); |
||||
} |
||||
|
||||
} else { |
||||
echo "Falha ao conectar ao banco de dados"; |
||||
exit(0); |
||||
} |
||||
} |
||||
|
||||
|
||||
function consulta_audios($banco, $emp_id) { |
||||
$con = pg_connect($banco); |
||||
if ($con) { |
||||
$query = "select vds_chamadas.*, vds_classificacoes.clas_descricao from " |
||||
. "vds_chamadas inner join " |
||||
. "vds_classificacoes on vds_chamadas.uid = vds_classificacoes.uid " |
||||
. "where vds_classificacoes.clas_descricao = 'VENDA' " |
||||
. "and vds_chamadas.emp_id = '".$emp_id."' " |
||||
. "limit 10"; |
||||
$seleciona_audios = pg_query($con, $query); |
||||
if ($seleciona_audios) { |
||||
return pg_fetch_all($seleciona_audios); |
||||
} else { |
||||
echo "Falha ao executar query"; |
||||
exit(0); |
||||
} |
||||
} else { |
||||
echo "Falha ao conectar ao banco de dados"; |
||||
exit(0); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
$filename = "/var/spool/asterisk/monitor/"; |
||||
$cnpj_consulta = $_GET["cnpj"]; //12324775000797 |
||||
$db0 = "host=192.168.115.65 port=5432 dbname=pbx_old user=contacte password=ctepgSQL"; |
||||
$emp_id = seleciona_emp_id($db0, $cnpj_consulta); |
||||
|
||||
|
||||
$db1 = "host=algar.simplesip.com.br port=5432 dbname=pbx user=contacte password=ctepgSQL"; |
||||
$array = consulta_audios($db1, $emp_id); |
||||
$initime = microtime(true); |
||||
/* |
||||
$dir = opendir("/var/spool/asterisk/monitor"); |
||||
$array_audios = []; |
||||
|
||||
if ($dir) { |
||||
while (($item = readdir($dir)) !== false) { |
||||
if ($item == '.' || $item == '..') { |
||||
continue; |
||||
} |
||||
$array_audios[] = $item; |
||||
} |
||||
closedir($dir); |
||||
} |
||||
*/ |
||||
$filename = "/var/spool/asterisk/monitor/"; |
||||
if ($array) { |
||||
foreach ($array as $key => $chamada) { |
||||
if(file_exists($filename.$chamada['chm_userfield'])) { |
||||
$array[$key]["enviado"] = 1; |
||||
} else { |
||||
$array[$key]["enviado"] = 0; |
||||
} |
||||
} |
||||
echo json_encode($array); |
||||
} else { |
||||
$array = []; |
||||
echo json_encode($array); |
||||
|
||||
} |
||||
$fim_time = microtime(true); |
||||
echo $fim_time - $initime; |
@ -1,95 +0,0 @@
|
||||
#!/usr/bin/php -q |
||||
<?php |
||||
|
||||
|
||||
function relatorio_audios($info_array) { |
||||
$relatorio = ''; |
||||
foreach ($info_array as $empresa) { |
||||
$relatorio .= "Foram encontrados {$empresa['qt_audios']} audios desatualizados para a empresa {$empresa['emp_cnpj']}(cnpj) na data {$empresa['data_bilhete']}(informacoes na tabela vds_audios_desatualizados).\n"; |
||||
} |
||||
return $relatorio; |
||||
} |
||||
|
||||
|
||||
function relatorio_serv($info_array) { |
||||
$relatorio = ''; |
||||
foreach ($info_array as $empresa) { |
||||
$relatorio .= "Foram encontrados {$empresa['qt_registros']} registros de dias nao monitorados para a empresa {$empresa['emp_cnpj']}(cnpj). O servidor pode estar ficando desligado.(informacoes na tabela vds_nao_monitorado).\n"; |
||||
} |
||||
return $relatorio; |
||||
} |
||||
|
||||
function envia_sms($telefone, $mensagem) { |
||||
$res = curl_init("https://www.iagentesms.com.br/webservices/http.php?metodo=envio" |
||||
. "&usuario=desenvolvimento@simplesip.com.br" |
||||
. "&senha=SimpleS_root" |
||||
. "&celular={$telefone}" |
||||
. "&mensagem={$mensagem}"); |
||||
curl_setopt($res, CURLOPT_RETURNTRANSFER, true); |
||||
curl_setopt($res, CURLOPT_SSL_VERIFYPEER, false); |
||||
curl_exec($res); |
||||
return $res; |
||||
} |
||||
|
||||
|
||||
//$bdcon = pg_connect("host=177.69.220.78 port=5432 dbname=pbx user=contacte password=ctepgSQL"); |
||||
$bdcon = pg_connect("host=algar.simplesip.com.br port=5432 dbname=pbx user=contacte password=ctepgSQL"); |
||||
|
||||
if (!$bdcon) { |
||||
exit(0); |
||||
} |
||||
|
||||
$query_audios = "select count(id_audio) as qt_audios, emp_cnpj, data_bilhete from vds_audios_desatualizados where data_bilhete = now()::date - 1 group by emp_cnpj, data_bilhete"; |
||||
$query_clientes = "select count(id_problema) as qt_registros, emp_cnpj from vds_nao_monitorado group by emp_cnpj"; |
||||
|
||||
$resQueryAudio = pg_query($bdcon, $query_audios); |
||||
$resQueryClientes = pg_query($bdcon, $query_clientes); |
||||
if (!($resQueryAudio)) { |
||||
exit(0); |
||||
} |
||||
if (!$resQueryClientes) { |
||||
exit(0); |
||||
} |
||||
if ($rel_audios = pg_fetch_all($resQueryAudio)) { |
||||
envia_sms("65993625396", urlencode(relatorio_audios($rel_audios))); |
||||
} |
||||
|
||||
if ($rel_clientes = pg_fetch_all($resQueryClientes)) { |
||||
envia_sms("65993625396", substr(relatorio_serv($rel_clientes), 0, 20)); |
||||
} |
||||
|
||||
?> |
||||
|
||||
<html> |
||||
<head> |
||||
<meta charset="UTF-8"/> |
||||
<title>Relatório</title> |
||||
<style> |
||||
table, th, td { |
||||
border: 1px solid black; |
||||
border-collapse: collapse; |
||||
} |
||||
</style> |
||||
</head> |
||||
<body> |
||||
<h1>Servidores sem conxexão</h1> |
||||
<table> |
||||
<tr> <th>Empresa</th> <th>Qt. de dias sem conexão</th></tr> |
||||
<?php
|
||||
foreach ($rel_clientes as $conn) { |
||||
echo "<tr><td>{$conn['emp_cnpj']}</td><td>{$conn['qt_registros']}</td></tr>"; |
||||
} |
||||
?> |
||||
|
||||
</table> |
||||
<h1>Audios desatualizados </h1> |
||||
<table> |
||||
<tr><th>Empresa</th><th>Audios desatualizados ontem</th></tr> |
||||
<?php foreach ($rel_audios as $audio) { |
||||
echo "<tr><td>{$audio['emp_cnpj']}</td><td>{$audio['qt_audios']}</td></tr>"; |
||||
} |
||||
?> |
||||
</table> |
||||
</body> |
||||
</html> |
||||
|
@ -1,109 +0,0 @@
|
||||
#!/usr/bin/php -q |
||||
<?php |
||||
function inicia_empresas($bdcon) { |
||||
$sQuery = "select * from vds_nao_monitorado where data_script = now()::date - 1"; |
||||
$query = pg_query($bdcon, $sQuery); |
||||
if (pg_num_rows($query) == 0) { |
||||
$valida_dia = "insert into vds_nao_monitorado " |
||||
. "(emp_cnpj, data_script) " |
||||
. "values ('00000000000000', now()::date - 1)"; |
||||
pg_query($bdcon, $valida_dia); |
||||
$sEmpresas = "select emp_cnpj, emp_vpn, emp_status from vds_empresas where emp_vpn <> ''"; |
||||
$res = pg_fetch_all(pg_query($bdcon, $sEmpresas)); |
||||
foreach($res as $empresa) { |
||||
if (!$empresa['emp_status']) { |
||||
$query = "insert into vds_nao_monitorado " |
||||
. "(emp_cnpj, emp_vpn, data_script) " |
||||
. "values ('{$empresa['emp_cnpj']}', '{$empresa['emp_vpn']}', now()::date - 1)"; |
||||
pg_query($bdcon, $query); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
function deleta_script($cnpj, $data, $bdcon) { |
||||
return pg_query($bdcon, "delete from vds_nao_monitorado where emp_cnpj = '{$cnpj}' and data_script = '{$data}'"); |
||||
} |
||||
|
||||
|
||||
$problema_con = []; |
||||
|
||||
//$bdcon1 = pg_connect("host=127.0.0.1 port=5432 dbname=pbx user=contacte password=ctepgSQL"); |
||||
$bdcon = pg_connect("host=algar.simplesip.com.br port=5432 dbname=pbx user=contacte password=ctepgSQL"); |
||||
if (!$bdcon) { |
||||
exit(0); |
||||
} |
||||
inicia_empresas($bdcon); |
||||
$sel_script = "select emp_cnpj, emp_vpn, data_script from vds_nao_monitorado"; |
||||
$scripts = pg_fetch_all(pg_query($bdcon, $sel_script)); |
||||
|
||||
|
||||
|
||||
foreach($scripts as $script) { |
||||
if (!in_array($script['emp_cnpj'], $problema_con)) { |
||||
$bdcon0 = pg_connect("host={$script['emp_vpn']} port=5432 dbname=pbx user=contacte password=ctepgSQL connect_timeout=10"); |
||||
if (!$bdcon0) { |
||||
$problema_con[] = $script['emp_cnpj']; |
||||
continue; |
||||
} |
||||
$invertida = implode("-", array_reverse(explode('-', $script['data_script']))); |
||||
$datas[0] = "'{$script['data_script']}'"; |
||||
$datas[1] = "&DATA={$invertida}"; |
||||
$query = "select a.uniqueid, a.protoparceiro, b.userfield " |
||||
. "as arquivo_audio, b.data_bilhete, " |
||||
. "case when(length(a.protoparceiro) = 12)then 1 else 0 end as status_protocolo " |
||||
. "from pbx_protocolo_reg a, pbx_bilhetes b, pbx_classifica_reg c, pbx_classifica_atendimento d " |
||||
. "where b.uniqueid = a.uniqueid and c.id_bilhetes = a.uniqueid and d.clas_id = c.clas_id " |
||||
. "and a.protointegrado = 1 and d.clas_descricao = 'VENDA' and b.lastapp <> 'Transferred Call' " |
||||
. "and b.billsec > '0'and b.data_bilhete = {$datas[0]}"; |
||||
$audiosQuery = pg_query($bdcon0, $query); |
||||
if (!$audiosQuery) { |
||||
continue; |
||||
} |
||||
$audiosCliente = pg_fetch_all($audiosQuery); |
||||
|
||||
if (!$audiosCliente) { |
||||
$del = deleta_script($script['emp_cnpj'], $script['data_script'], $bdcon); |
||||
continue; |
||||
} |
||||
$ch = curl_init("https://algar.simplesip.com.br/apl/integracao/?method=DisponibilizaAudios&CNPJ=".$script['emp_cnpj']."{$datas[1]}&login=admin&senha=SiP1029384756&tipoRetorno=json"); |
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
||||
$obj = json_decode(curl_exec($ch)); |
||||
if (!(gettype($obj) == "array")) { |
||||
continue; |
||||
} |
||||
|
||||
$audios_algar[] = ''; |
||||
foreach ($obj as $value) { |
||||
if ($value -> enviado) { |
||||
$audios_algar[] = $value -> chm_userfield; |
||||
} |
||||
} |
||||
|
||||
$controle = true; |
||||
foreach ($audiosCliente as $value) { |
||||
if (!(in_array($value['arquivo_audio'], $audios_algar))) { |
||||
$insereAudio = "insert into vds_audios_desatualizados " |
||||
. "(uniqueid, userfield, data_bilhete, emp_cnpj) " |
||||
. "select * from " |
||||
. "(select '".$value["uniqueid"]."' as uniqueid, '".$value['arquivo_audio']."' as userfield, DATE '".$value['data_bilhete']."' as data_bilhete, '{$script['emp_cnpj']}' as emp_cnpj) as tmp " |
||||
. "where not exists (select * from vds_audios_desatualizados where uniqueid = '".$value["uniqueid"]."' " |
||||
. "and userfield = '".$value['arquivo_audio']."' and data_bilhete = DATE '".$value['data_bilhete']."')" |
||||
. " limit 1"; |
||||
pg_query($bdcon, $insereAudio); |
||||
if (!$bdcon) { |
||||
$controle = false; |
||||
} |
||||
} |
||||
|
||||
} |
||||
if ($controle) { |
||||
$del = deleta_script($script['emp_cnpj'], $script['data_script'], $bdcon); |
||||
} |
||||
|
||||
} |
||||
} |
||||
|
||||
?> |
@ -1,12 +0,0 @@
|
||||
<?php |
||||
|
||||
$query = "SELECT * FROM pbx_conf_padrao"; |
||||
$result = pg_query($dbcon, $query); |
||||
|
||||
$dados = pg_fetch_array($result); |
||||
$caminho_back = $dados['caminho_backup']; |
||||
$caminho_producao = $dados['caminho_producao']; |
||||
$caminho_musicas = $dados['caminho_musicas']; |
||||
$url_musicas = $dados['url_musicas']; |
||||
$url_asterisk = $dados['url_asterisk']; |
||||
$path_som = $dados['path_som']; |
@ -1,20 +0,0 @@
|
||||
<!DOCTYPE html> |
||||
<!-- |
||||
To change this license header, choose License Headers in Project Properties. |
||||
To change this template file, choose Tools | Templates |
||||
and open the template in the editor. |
||||
--> |
||||
<html> |
||||
<head> |
||||
<title>TODO supply a title</title> |
||||
</head> |
||||
<body> |
||||
<form action="http://177.124.120.8:8098" method="post" enctype="multipart/form-data" name="form1"> |
||||
<div>TODO write content</div><br> |
||||
<input name="arquivo" type="file" class="caixas" id="arquivo2" /> |
||||
<input name="Submit" type="submit" class="labels" value="Salvar"> |
||||
</form> |
||||
</body> |
||||
</html> |
||||
|
||||
|
@ -0,0 +1,261 @@
|
||||
|
||||
CREATE OR REPLACE FUNCTION refresh_show_events(ip_filter VARCHAR) |
||||
RETURNS VOID AS $$ |
||||
BEGIN |
||||
INSERT INTO resultado_events ( |
||||
id, |
||||
empresa, |
||||
ip_vpn, |
||||
hd, |
||||
troncos_total, |
||||
troncos_fail, |
||||
event_timestamp, |
||||
upstart_information, |
||||
load_average, |
||||
cpu_cores, |
||||
cpu_percentage_busy, |
||||
ram_percentage_busy, |
||||
ram_total |
||||
) |
||||
SELECT |
||||
vemp.emp_id AS id, |
||||
vemp.emp_nome_fantasia AS empresa, |
||||
ve.ip_address_central AS ip_vpn, |
||||
veh.hd, |
||||
COALESCE(troncos_total, 0) AS troncos_total, |
||||
COALESCE(troncos_falhas, 0) AS troncos_fail, |
||||
MAX(ve.event_timestamp) AS event_timestamp, |
||||
upstart_information, |
||||
load_average, |
||||
cpu_cores, |
||||
cpu_percentage_busy, |
||||
ram_percentage_busy, |
||||
ram_total |
||||
FROM |
||||
vds_events ve |
||||
INNER JOIN vds_events_hd veh ON ve.id = veh.id_event |
||||
INNER JOIN vds_empresas vemp ON ve.ip_address_central = vemp.emp_vpn |
||||
WHERE |
||||
ve.ip_address_central = ip_filter |
||||
GROUP BY |
||||
vemp.emp_id, |
||||
vemp.emp_nome_fantasia, |
||||
ve.ip_address_central, |
||||
troncos_total, |
||||
troncos_fail, |
||||
veh.hd, |
||||
upstart_information, |
||||
load_average, |
||||
cpu_cores, |
||||
cpu_percentage_busy, |
||||
ram_percentage_busy, |
||||
ram_total |
||||
ORDER BY |
||||
event_timestamp DESC |
||||
LIMIT 1 |
||||
ON CONFLICT (id) DO UPDATE |
||||
SET |
||||
empresa = EXCLUDED.empresa, |
||||
ip_vpn = EXCLUDED.ip_vpn, |
||||
hd = EXCLUDED.hd, |
||||
troncos_total = EXCLUDED.troncos_total, |
||||
troncos_fail = EXCLUDED.troncos_fail, |
||||
event_timestamp = EXCLUDED.event_timestamp, |
||||
upstart_information = EXCLUDED.upstart_information, |
||||
load_average = EXCLUDED.load_average, |
||||
cpu_cores = EXCLUDED.cpu_cores, |
||||
cpu_percentage_busy = EXCLUDED.cpu_percentage_busy, |
||||
ram_percentage_busy = EXCLUDED.ram_percentage_busy, |
||||
ram_total = EXCLUDED.ram_total; |
||||
|
||||
END; |
||||
$$ LANGUAGE plpgsql; |
||||
|
||||
|
||||
|
||||
DO $$ |
||||
DECLARE |
||||
rec RECORD; |
||||
result RECORD; |
||||
BEGIN |
||||
FOR rec IN |
||||
SELECT DISTINCT emp_id, emp_vpn, emp_nome_fantasia, count(emp_id) AS count_emp |
||||
FROM vds_empresas |
||||
GROUP BY emp_id |
||||
LOOP |
||||
-- Adicionar notificação para depuração |
||||
RAISE NOTICE 'Processing emp_id: %', rec.emp_id; |
||||
|
||||
FOR result IN |
||||
-- HD |
||||
WITH base_query_hd AS ( |
||||
SELECT |
||||
veh.filesystem, |
||||
veh.hd_percentage_busy, |
||||
ve.event_timestamp, |
||||
ve.upstart_information, |
||||
ve.load_average, |
||||
ve.cpu_cores, |
||||
ve.cpu_percentage_busy, |
||||
ve.ram_percentage_busy, |
||||
ve.ram_total, |
||||
vpa.hd_percentage_busy AS alert_threshold, |
||||
ROW_NUMBER() OVER (PARTITION BY veh.filesystem ORDER BY ve.event_timestamp DESC) AS rn |
||||
FROM |
||||
(SELECT * FROM ( SELECT * FROM vds_events ORDER BY event_timestamp DESC LIMIT rec.count_emp ) AS vde WHERE vde.id_servidor IN ( SELECT DISTINCT id_servidor FROM vds_events ) ) vde |
||||
INNER JOIN vds_events_hd veh ON ve.id = veh.id_event |
||||
INNER JOIN ( |
||||
SELECT |
||||
vemp.emp_id, |
||||
vemp.emp_nome_fantasia, |
||||
vs.id AS id_server, |
||||
vs.address, |
||||
pgr.gp_id |
||||
FROM |
||||
vds_empresas vemp |
||||
INNER JOIN vds_servidores vs ON |
||||
vs.address = vemp.emp_vpn |
||||
INNER JOIN pbx_grupo_revendas pgr ON |
||||
pgr.emp_id = vemp.emp_id |
||||
WHERE vemp.emp_id = rec.emp_id |
||||
) servers ON ve.id_servidor = servers.id_server |
||||
INNER JOIN vds_params_alerts vpa ON |
||||
vpa.id_group = servers.gp_id |
||||
AND vpa.status = 1 |
||||
), |
||||
last_event AS ( |
||||
SELECT |
||||
filesystem, |
||||
hd_percentage_busy, |
||||
alert_threshold, |
||||
event_timestamp, |
||||
upstart_information, |
||||
load_average, |
||||
cpu_cores, |
||||
cpu_percentage_busy, |
||||
ram_percentage_busy, |
||||
ram_total |
||||
FROM |
||||
base_query_hd |
||||
WHERE |
||||
rn = 1 |
||||
), |
||||
unique_filesystem_count AS ( |
||||
SELECT COUNT(DISTINCT filesystem) AS count |
||||
FROM last_event |
||||
), |
||||
-- TRONCO |
||||
base_query_troncos AS ( |
||||
WITH latest_events AS ( |
||||
SELECT |
||||
vet.name, |
||||
vet.status, |
||||
ROW_NUMBER() OVER (PARTITION BY vet.name ORDER BY ve.event_timestamp DESC) AS rn |
||||
FROM |
||||
vds_events ve |
||||
INNER JOIN vds_events_troncos vet ON ve.id = vet.id_event |
||||
INNER JOIN ( |
||||
SELECT |
||||
vemp.emp_id, |
||||
vemp.emp_nome_fantasia, |
||||
vs.id AS id_server, |
||||
vs.address, |
||||
pgr.gp_id |
||||
FROM |
||||
vds_empresas vemp |
||||
INNER JOIN vds_servidores vs ON |
||||
vs.address = vemp.emp_vpn |
||||
INNER JOIN pbx_grupo_revendas pgr ON |
||||
pgr.emp_id = vemp.emp_id |
||||
WHERE |
||||
vemp.emp_id = rec.emp_id |
||||
) servers ON ve.id_servidor = servers.id_server |
||||
INNER JOIN vds_params_alerts vpa ON |
||||
vpa.id_group = servers.gp_id |
||||
AND vpa.status = 1 |
||||
) |
||||
SELECT |
||||
COUNT(*) AS troncos_total, |
||||
SUM(CASE WHEN le.status NOT LIKE '%OK%' THEN 1 ELSE 0 END) AS troncos_fail |
||||
FROM |
||||
latest_events le |
||||
WHERE |
||||
le.rn = 1 |
||||
) |
||||
SELECT |
||||
json_agg( |
||||
json_build_object( |
||||
'filesystem', filesystem, |
||||
'status', CASE WHEN le.hd_percentage_busy > le.alert_threshold THEN 1 ELSE 0 END |
||||
) |
||||
) AS hd_total, |
||||
SUM(CASE WHEN le.hd_percentage_busy > le.alert_threshold THEN 1 ELSE 0 END) AS hd_fail, |
||||
COALESCE((SELECT troncos_total FROM base_query_troncos), 0) AS troncos_total, |
||||
COALESCE((SELECT troncos_fail FROM base_query_troncos), 0) AS troncos_fail, |
||||
MAX(event_timestamp) AS event_timestamp, |
||||
MAX(TO_TIMESTAMP(upstart_information::bigint)) AS upstart_information, |
||||
MAX(load_average) AS load_average, |
||||
MAX(cpu_cores) AS cpu_cores, |
||||
MAX(cpu_percentage_busy) AS cpu_percentage_busy, |
||||
MAX(ram_percentage_busy) AS ram_percentage_busy, |
||||
MAX(ram_total) AS ram_total |
||||
FROM |
||||
last_event le |
||||
CROSS JOIN |
||||
unique_filesystem_count ufc |
||||
GROUP BY |
||||
ufc.count |
||||
LOOP |
||||
-- Notificação para depuração |
||||
RAISE NOTICE 'Inserting for emp_id: %s, hd_total: %s, event_timestamp: %s, upstart_information: %s', |
||||
rec.emp_id, result.hd_total, result.event_timestamp, result.upstart_information; |
||||
INSERT INTO resultado_events ( |
||||
id, |
||||
empresa, |
||||
ip_vpn, |
||||
hd_total, |
||||
hd_fail, |
||||
troncos_total, |
||||
troncos_fail, |
||||
event_timestamp, |
||||
upstart_information, |
||||
load_average, |
||||
cpu_cores, |
||||
cpu_percentage_busy, |
||||
ram_percentage_busy, |
||||
ram_total |
||||
) |
||||
VALUES ( |
||||
rec.emp_id, |
||||
rec.emp_nome_fantasia, |
||||
rec.emp_vpn, |
||||
result.hd_total, |
||||
result.hd_fail, |
||||
result.troncos_total, |
||||
result.troncos_fail, |
||||
result.event_timestamp, |
||||
result.upstart_information, |
||||
result.load_average, |
||||
result.cpu_cores, |
||||
result.cpu_percentage_busy, |
||||
result.ram_percentage_busy, |
||||
result.ram_total |
||||
) ON CONFLICT (id) DO |
||||
UPDATE |
||||
SET |
||||
hd_total = EXCLUDED.hd_total, |
||||
ip_vpn = EXCLUDED.ip_vpn, |
||||
hd_fail = EXCLUDED.hd_fail, |
||||
empresa = EXCLUDED.empresa, |
||||
troncos_total = EXCLUDED.troncos_total, |
||||
troncos_fail = EXCLUDED.troncos_fail, |
||||
event_timestamp = EXCLUDED.event_timestamp, |
||||
upstart_information = EXCLUDED.upstart_information, |
||||
load_average = EXCLUDED.load_average, |
||||
cpu_cores = EXCLUDED.cpu_cores, |
||||
cpu_percentage_busy = EXCLUDED.cpu_percentage_busy, |
||||
ram_percentage_busy = EXCLUDED.ram_percentage_busy, |
||||
ram_total = EXCLUDED.ram_total; |
||||
END LOOP; |
||||
END LOOP; |
||||
END $$; |
@ -1,24 +0,0 @@
|
||||
<?php |
||||
|
||||
/* |
||||
* To change this template, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
|
||||
|
||||
$janW = 500; |
||||
$janH = 400; |
||||
$tpl = 'templates/site.tpl'; |
||||
$imgNovo = "<img src=\"imgSite/novoUser.png\" width=\"16\" height=\"16\" border=\"0\" title=\"Inclui novo site\">"; |
||||
$imgNovo = "<a href=\"javaScript:NovaJanela('index.php?idProg=105&idSite=0', 'siteCad', '$janW', '$janH', 'resizable=NO,scrollbars=NO');\">$imgNovo</a>"; |
||||
$isPostBack = true; |
||||
print_r($_POST); |
||||
|
||||
|
||||
|
||||
$smarty->assign('erro', $erro); |
||||
$smarty->assign("linhas", $linha); |
||||
$smarty->assign("txtConsulta", $param); |
||||
|
||||
GetTemplate($smarty, $tpl); |
||||
?> |
@ -1,32 +0,0 @@
|
||||
<?php |
||||
|
||||
/* |
||||
* To change this template, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
|
||||
|
||||
|
||||
|
||||
$acaoForm = FORM_INSERT; |
||||
$erro = IsPostBack() ? ValidaSite($fields, $fieldsName) : ""; |
||||
|
||||
if (IsPostBack() && empty($erro)) { |
||||
$query = "insert into pbx_sites(host, usuario, senha, basedados, porta, descricao, status) values(%s, %s, %s, %s, %s, %s, %s)"; |
||||
$query = sprintf($query, QuotedStr($host), QuotedStr($usuario), QuotedStr($senha), QuotedStr($basedados), QuotedStr($porta), QuotedStr($descricao), $status); |
||||
$result = pg_query($dbcon, $query); |
||||
if ($result) { |
||||
$erro = "Registro inserido com sucesso!"; |
||||
$jsStartup[] = "window.opener.ResetForm();"; |
||||
$id = 0; |
||||
$status = 1; |
||||
$porta = '5432'; |
||||
$host = ''; |
||||
$senha = ''; |
||||
$basedados = ''; |
||||
$descricao = ''; |
||||
$usuario = ''; |
||||
} else |
||||
$erro = "A operação não pode ser realizada! " . (IsAdmin() ? ("Erro: " . pg_last_error($dbcon)) : ""); |
||||
} |
||||
?> |
@ -1,91 +0,0 @@
|
||||
<?php |
||||
|
||||
/* |
||||
* To change this template, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
|
||||
|
||||
$janW = 500; |
||||
$janH = 300; |
||||
$paramPesquisa = isset($_REQUEST['paramPesquisa']) ? $_REQUEST['paramPesquisa'] : ''; |
||||
$filtro = isset($_REQUEST["paramPesquisa"]) ? trim($_REQUEST["paramPesquisa"]) : ''; |
||||
$filtroNovo = !isset($_REQUEST["pgn"]) ? '' : sprintf("¶mPesquisa%s&pgn=%s&bloco=%s&pg=%s", $_REQUEST["paramPesquisa"], $_REQUEST["pgn"], $_REQUEST["bloco"], $_REQUEST["pg"]); |
||||
$recontaPag = ($acao == 'inseri') || (GetFormAcao() == FORM_DELETE) || isset($_POST['pesquisa']); |
||||
|
||||
|
||||
$tpl = 'siteConsulta.tpl'; |
||||
$imgNovo = GetLinkFormInsert("siteCad", 'images/novo.gif', $filtroNovo, ' Novo Site'); |
||||
$linha = ""; |
||||
|
||||
|
||||
if (GetFormAcao() == FORM_DELETE) { |
||||
$id = $_GET["id"] ?? "0"; |
||||
$erro = DeletaSite($dbcon, $id); |
||||
} |
||||
|
||||
$compl = ''; |
||||
if (isset($_REQUEST['paramPesquisa']) && $_REQUEST['paramPesquisa']) { |
||||
$compl = PreparaLike($filtro, true); |
||||
$compl = sprintf("and (a.descricao ilike %s or a.host ilike %s or a.basedados ilike %s)", $compl, $compl, $compl); |
||||
} |
||||
|
||||
$query = "select id, host, usuario, senha, |
||||
basedados, porta, descricao, status |
||||
from pbx_sites a where 1=1 $compl order by descricao"; |
||||
|
||||
$params = "¶mPesquisa=$filtro"; |
||||
$links = PaginaDados($idProg, $query, $params, $regPagina, $offSet, $pagMostra, true); |
||||
$query .= " limit $regPagina offset $offSet"; |
||||
$result = pg_query($dbcon, $query); |
||||
while ($row = pg_fetch_array($result)) { |
||||
$id = $row["id"]; |
||||
$host = $row["host"]; |
||||
$usuario = $row["usuario"]; |
||||
$basedados = $row["basedados"]; |
||||
$porta = $row["porta"]; |
||||
$descricao = $row["descricao"]; |
||||
$status = $row["status"]; |
||||
$imgStatus = $status ? "<img src=\"imgSite/ledOn.gif\" width=\"16\" height=\"16\" border=\"0\" title=\"Ativo\">" : "<img src=\"imgSite/ledOff.gif\" width=\"16\" height=\"16\" border=\"0\" title=\"Inativo\">"; |
||||
$urlEdita = "&id=$id"; |
||||
//9903-2104 |
||||
$descricao = GetLinkFormUpdate($urlEdita, "cadSites", "", 0, 1, $descricao); |
||||
$imgEdita = GetLinkFormUpdate($urlEdita, "cadSites"); |
||||
$imgDel = GetLinkFormDelete($id . '|' . $params, "DeletaSite"); |
||||
$linha .= " <tr class=\"headData\"> |
||||
<td align=\"right\">$id</td> |
||||
<td align=\"left\" nowrap>$descricao</td> |
||||
<td align=\"left\">$host</td> |
||||
<td align=\"left\">$usuario</td> |
||||
<td align=\"left\">$basedados</td> |
||||
<td align=\"left\">$porta</td> |
||||
<td align=\"center\" width=\"20\" style=\"border-right: 0\">$imgEdita</td> |
||||
<td align=\"center\" width=\"20\" style=\"border-left: 0; border-right: 0\">$imgDel</td> |
||||
<td align=\"center\" width=\"20\" style=\"border-left: 0\">$imgStatus</td> |
||||
</tr>"; |
||||
} |
||||
|
||||
|
||||
$smarty->assign('erro', $erro); |
||||
$smarty->assign("linhas", $linha); |
||||
$smarty->assign("paramPesquisa", $paramPesquisa); |
||||
$smarty->assign("imgNovo", $imgNovo); |
||||
$smarty->assign("links", $links); |
||||
$smarty->assign("pagMostra", $pagMostra); |
||||
$smarty->assign("totalReg", $totalReg); |
||||
$smarty->assign("pgn", $_REQUEST["pgn"]); |
||||
$smarty->assign("bloco", $_REQUEST["bloco"]); |
||||
$smarty->assign("pg", $_REQUEST["pg"]); |
||||
|
||||
GetTemplate($smarty, $tpl); |
||||
|
||||
function DeletaSite($db, $id) { |
||||
$query = "delete from pbx_sites where id = $id"; |
||||
$result = pg_query($db, $query); |
||||
if ($result) |
||||
return "Registro deletado com sucesso!"; |
||||
else |
||||
return "A operação não pode ser realizada! " . (IsAdmin() ? ("Erro: " . pg_last_error($dbcon)) : ""); |
||||
} |
||||
|
||||
?> |
@ -1,30 +0,0 @@
|
||||
<?php |
||||
|
||||
/* |
||||
* To change this template, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
|
||||
$acaoForm = FORM_SAVE; |
||||
|
||||
$erro = IsPostBack() ? ValidaSite($fields, $fieldsName) : ""; |
||||
|
||||
if (IsPostBack() && empty($erro)) { |
||||
$query = "update pbx_sites |
||||
set host = %s, |
||||
usuario = %s, |
||||
senha = %s, |
||||
basedados = %s, |
||||
porta = %s, |
||||
descricao = %s, |
||||
status = %s |
||||
where id = %s "; |
||||
$query = sprintf($query, QuotedStr($host), QuotedStr($usuario), QuotedStr($senha), QuotedStr($basedados), QuotedStr($porta), QuotedStr($descricao), $status, $id); |
||||
$result = pg_query($dbcon, $query); |
||||
if ($result) { |
||||
$erro = "Registro alterado com sucesso!"; |
||||
$jsStartup[] = "window.opener.ResetForm();"; |
||||
} else |
||||
$erro = "A operação não pode ser realizada! " . (IsAdmin() ? ("Erro: " . pg_last_error($dbcon)) : ""); |
||||
} |
||||
?> |
@ -1,78 +0,0 @@
|
||||
<?php |
||||
|
||||
/* |
||||
* variavel que vai conter o template |
||||
*/ |
||||
|
||||
$janW = 500; |
||||
$janH = 250; |
||||
|
||||
$fields = array('host', 'usuario', 'senha', 'basedados', 'porta', 'descricao'); |
||||
$fieldsName = array('Host', 'Usuário', 'Senha', 'Base de Dados', 'Porta', 'Nome'); |
||||
$erro = ""; |
||||
if ((GetFormAcao() == FORM_SELECT) || (GetFormAcao() == FORM_DELETE)) { |
||||
include("sites/siteSelect.php"); |
||||
} else { |
||||
$tpl = 'site.tpl'; |
||||
$tpLayout = 1; |
||||
if (IsPostBack()) { |
||||
|
||||
$id = $_POST["idSite"]; |
||||
$host = $_POST["host"]; |
||||
$usuario = isset($_POST["usuario"]) ? $_POST["usuario"] : 'manager'; |
||||
$senha = isset($_POST["senha"]) ? $_POST["senha"] : 'manager007'; |
||||
$basedados = $_POST["basedados"]; |
||||
$porta = $_POST["porta"]; |
||||
$descricao = $_POST["descricao"]; |
||||
$status = isset($_POST["status"]) ? 1 : 0; |
||||
} else { |
||||
|
||||
if (GetFormAcao() == FORM_UPDATE) { |
||||
$id = $_GET["id"] ?? "0"; |
||||
$query = "select id, host, usuario, senha, |
||||
basedados, porta, descricao, status |
||||
from pbx_sites where id = $id"; |
||||
$result = pg_query($dbcon, $query); |
||||
$row = pg_fetch_array($result); |
||||
foreach ($row as $key => $value) { |
||||
$GLOBALS[$key] = $value; |
||||
} |
||||
} else { |
||||
$id = 0; |
||||
$status = 1; |
||||
$porta = '5432'; |
||||
} |
||||
} |
||||
|
||||
if ((GetFormAcao() == FORM_NEW) || (GetFormAcao() == FORM_INSERT)) { |
||||
include("siteInsert.php"); |
||||
} else if ((GetFormAcao() == FORM_UPDATE) || (GetFormAcao() == FORM_SAVE)) { |
||||
|
||||
include("siteUpdate.php"); |
||||
} |
||||
|
||||
$smarty->assign('msgErro', $erro); |
||||
$smarty->assign('host', $host); |
||||
$smarty->assign('usuario', $usuario); |
||||
$smarty->assign('senha', $senha); |
||||
$smarty->assign('basedados', $basedados); |
||||
$smarty->assign('porta', $porta); |
||||
$smarty->assign('descricao', $descricao); |
||||
$smarty->assign('status', $status ? "checked" : ""); |
||||
$smarty->assign('idSite', $id); |
||||
$smarty->assign("formAction", $acaoForm); |
||||
$smarty->assign("formAcaoDesc", GetFormAcaoDesc($acaoForm)); |
||||
|
||||
|
||||
GetTemplate($smarty, $tpl); |
||||
} |
||||
|
||||
function ValidaSite($fields, $fieldsName) { |
||||
foreach ($fields as $key => $value) { |
||||
if (empty($_POST[$value])) |
||||
return $fieldsName[$key] . " é um campo de preenchimento obrigatório!"; |
||||
} |
||||
return ""; |
||||
} |
||||
|
||||
?> |
@ -1,115 +1,119 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
||||
"http://www.w3.org/TR/html4/loose.dtd"> |
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
||||
<html> |
||||
<head> |
||||
<title>{$smarty.const.TITLE_SITE} {$versaoApl}</title> |
||||
{if $smarty.const.FAVICON_SITE}<link rel="shortcut icon" href="{$smarty.const.FAVICON_SITE}">{/if} |
||||
{$styleFile} |
||||
|
||||
<head> |
||||
<title>{$smarty.const.TITLE_SITE} {$versaoApl}</title> |
||||
{if $smarty.const.FAVICON_SITE} |
||||
<link rel="shortcut icon" href="{$smarty.const.FAVICON_SITE}">{/if} |
||||
{$styleFile} |
||||
{if $scriptGlobal}{$scriptGlobal}{/if} |
||||
{if $scriptPage}{$scriptPage}{/if} |
||||
{if $scriptBlok}{$scriptBlok}{/if} |
||||
{$cssBlock} |
||||
{if $scriptPage}{$scriptPage}{/if} |
||||
{if $scriptBlok}{$scriptBlok}{/if} |
||||
{$cssBlock} |
||||
</head> |
||||
|
||||
<body {$onLoad} {$infoBody}> |
||||
<form id="formGeral" |
||||
name="formGeral" {if $setActPage != null} action="{$setActPage}" {if $functionForm}{$functionForm}{/if} {$upload} {/if} |
||||
method="{if $setMethod != null}{$setMethod}{else}post{/if}"> |
||||
<input name="idProg" type="hidden" value="{$idProg}"> |
||||
<input name="idSubProg" type="hidden" value="{$idSubProg}"> |
||||
<input name="pbxRequest" type="hidden" value="{$pbxRequest}"> |
||||
<input name="idHand" type="hidden" value="{$idHand}"> |
||||
<input name="screenW" id="screenW" type="hidden" value="{$screenW}"> |
||||
<input name="screenH" id="screenH" type="hidden" value="{$screenH}"> |
||||
<input name="tbLayout" id="tbLayout" type="hidden" value="{$tbLayout}"> |
||||
<div id="tabLayout" width="760" height="100%" bgcolor="#FFFFFF" style="{$styleLayout}" align="center" |
||||
cellpadding="0" cellspacing="0" border="0"> |
||||
<table width="100%" cellpadding="0"> |
||||
{if !$tpLayout} |
||||
<tr class="noprint"> |
||||
<td class="headSite" valign="top"> |
||||
<table width="100%" class="headSite" align="center" cellpadding="0" cellspacing="0" border="0" style="border: 1px solid #e9e9e9; border-radius: 4px;"> |
||||
<tr> |
||||
<td>{$navLogin}</td> |
||||
</tr> |
||||
<tr> |
||||
<td {$setLogo}>{$logoPrinc}</td> |
||||
</tr> |
||||
<tr> |
||||
<td>{$menuGeral}</td> |
||||
</tr> |
||||
</table> |
||||
</td> |
||||
</tr> |
||||
{/if} |
||||
{if $idProg != 14} |
||||
<form id="formGeral" name="formGeral" {if $setActPage != null} action="{$setActPage}" |
||||
{if $functionForm}{$functionForm}{/if} {$upload} {/if} |
||||
method="{if $setMethod != null}{$setMethod}{else}post{/if}"> |
||||
<input name="idProg" type="hidden" value="{$idProg}"> |
||||
<input name="idSubProg" type="hidden" value="{$idSubProg}"> |
||||
<input name="pbxRequest" type="hidden" value="{$pbxRequest}"> |
||||
<input name="idHand" type="hidden" value="{$idHand}"> |
||||
<input name="screenW" id="screenW" type="hidden" value="{$screenW}"> |
||||
<input name="screenH" id="screenH" type="hidden" value="{$screenH}"> |
||||
<div id="tabLayout" bgcolor="#FFFFFF" style="{$styleLayout}" align="center" cellpadding="0" cellspacing="0" |
||||
border="0"> |
||||
<table width="100%" cellpadding="0"> |
||||
{if !$tpLayout} |
||||
<tr class="noprint"> |
||||
<td class="headSite" valign="top"> |
||||
<table width="100%" class="headSite" align="center" cellpadding="0" cellspacing="0" border="0" |
||||
style="border: 1px solid #e9e9e9; border-radius: 4px;"> |
||||
<tr> |
||||
<td>{$navLogin}</td> |
||||
</tr> |
||||
<tr> |
||||
<td {$setLogo}>{$logoPrinc}</td> |
||||
</tr> |
||||
<tr> |
||||
<td>{$menuGeral}</td> |
||||
</tr> |
||||
</table> |
||||
</td> |
||||
</tr> |
||||
{/if} |
||||
{if $idProg != 14 && $idProg != 370} |
||||
<tr> |
||||
<td> </td> |
||||
</tr> |
||||
{else} |
||||
{literal}<script> |
||||
$('#tabLayout').css({"top": '0px'}) |
||||
</script>{/literal} |
||||
{/if} |
||||
<tr> |
||||
<td> </td> |
||||
<td id="conteudoSite" valign="top"> |
||||
<div id="content" class="content"> |
||||
<table width="100%" height="{$heightMasterContent}" border="0" cellpadding="0"> |
||||
<tr> |
||||
<td> |
||||
{if $smarty.capture.display}{$smarty.capture.display}{else}{$conteudo}{/if} |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
</div> |
||||
</td> |
||||
</tr> |
||||
{else} |
||||
{literal}<script>$('#tabLayout').css({"top": '0px'})</script>{/literal} |
||||
{/if} |
||||
<tr> |
||||
<td id="conteudoSite" valign="top"> |
||||
<div id="content" class="content"> |
||||
<table width="100%" height="{$heightMasterContent}" border="0" |
||||
align="{if $alineMaster ne null}{$alineMaster}{else}center{/if}" cellspacing="0" |
||||
cellpadding="0"> |
||||
<tr> |
||||
<td align="{if !$wAlineMaster}left{else}{$wAlineMaster}{/if}" |
||||
valign="{if $vAlineMaster ne null}{$vAlineMaster}{else}middle{/if}"> |
||||
{if $smarty.capture.display}{$smarty.capture.display}{else}{$conteudo}{/if} |
||||
|
||||
{if $footer} |
||||
<tr class="noprint"> |
||||
<td style="height: 50px"> |
||||
<div id="rodapeSite"> |
||||
<table width="100%" border="0" cellspacing="5" cellpadding="5"> |
||||
<tr> |
||||
<td width="159" valign="middle" align="center"><img |
||||
src="{$smarty.const.LOGO_FOOTER_SITE}" alt="{$smarty.const.NOME_SITE}" |
||||
title="{$smarty.const.NOME_SITE}" align="bottom"></td> |
||||
|
||||
<td valign="middle" align="left" style="color: #ababab"> |
||||
Tel.: {$smarty.const.TELEFONE_SITE1} - Email: {$smarty.const.EMAIL_SITE1} <br /> |
||||
{$smarty.const.POWERED_BY} |
||||
</td> |
||||
<td width="159" align="right"> </td> |
||||
</tr> |
||||
</table> |
||||
</div> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
</div> |
||||
</td> |
||||
</tr> |
||||
{/if} |
||||
</table> |
||||
<!-- ALTERAÇÃO MODAL LUCAS --> |
||||
<div id="myModal" class="modal"> |
||||
<div class="modal-content"> |
||||
<div class="modal-header"> |
||||
<span class="close">×</span> |
||||
<h3>{$smarty.const.NOME_SITE}</h3> |
||||
</div> |
||||
<div class="modal-body"> |
||||
<div class="myIframe"> |
||||
<iframe id="iframe" src='' style="border: none;"></iframe> |
||||
</div> |
||||
|
||||
{if $footer} |
||||
<tr class="noprint"> |
||||
<td style="height: 50px"> |
||||
<div id="rodapeSite"> |
||||
<table width="100%" border="0" cellspacing="5" cellpadding="5"> |
||||
<tr> |
||||
<td width="159" valign="middle" align="center"><img src="{$smarty.const.LOGO_FOOTER_SITE}" alt="{$smarty.const.NOME_SITE}" title="{$smarty.const.NOME_SITE}" align="bottom"></td> |
||||
|
||||
<td valign="middle" align="left" style="color: #ababab"> |
||||
Tel.: {$smarty.const.TELEFONE_SITE1} - Email: {$smarty.const.EMAIL_SITE1} <br/> |
||||
{$smarty.const.POWERED_BY} |
||||
</td> |
||||
<td width="159" align="right"> </td> |
||||
</tr> |
||||
</table> |
||||
<div class="paginacao" style="display:none;"> |
||||
<span id="prev">« Voltar</span> |
||||
<span id="next">Seguir »</span> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</td> |
||||
</tr> |
||||
{/if} |
||||
</table> |
||||
<!-- ALTERAÇÃO MODAL LUCAS --> |
||||
<div id="myModal" class="modal"> |
||||
<div class="modal-content"> |
||||
<div class="modal-header"> |
||||
<span class="close">×</span> |
||||
<h3>{$smarty.const.NOME_SITE}</h3> |
||||
</div> |
||||
<div class="modal-body"> |
||||
<div class="myIframe"> |
||||
<iframe id="iframe" src='' style="border: none;"></iframe> |
||||
</div> |
||||
|
||||
<div class="paginacao" style="display:none;"> |
||||
<span id="prev">« Voltar</span> |
||||
<span id="next">Seguir »</span> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
{$aguarde} |
||||
</form> |
||||
<script src="scriptApl/modal.js"></script> |
||||
<script src="scriptApl/supervisorchat.js"></script> |
||||
{$jQuery} |
||||
{$scriptStartup} |
||||
</body> |
||||
</html> |
||||
{$newLoading} |
||||
</form> |
||||
<script src="scriptApl/modal.js"></script> |
||||
<script src="scriptApl/supervisorchat.js"></script> |
||||
{$jQuery} |
||||
{$scriptStartup} |
||||
</body> |
||||
|
||||
</html> |
@ -1,98 +1,118 @@
|
||||
{capture name="display" assign="display"} |
||||
<table width="100%" cellspacing="2" cellpadding="2" align="center"> |
||||
<tr> |
||||
<td align="center"> |
||||
<table class="filtro" width="100%" border="0" cellspacing="0" cellpadding="2"> |
||||
<tr> |
||||
<td> |
||||
<table align="center"> |
||||
<tr> |
||||
<th>Data Inicial </th> |
||||
<td> </td> |
||||
<th>Data Final</th> |
||||
<td> </td> |
||||
<th>Empresa</th> |
||||
<table width="100%" cellspacing="2" cellpadding="2" align="center"> |
||||
<tr> |
||||
<td align="center"> |
||||
<table class="filtro" width="100%" border="0" cellspacing="0" cellpadding="2"> |
||||
<tr> |
||||
<td> |
||||
<table align="center"> |
||||
{* Nome dos filtros *} |
||||
<tr> |
||||
<td> </td> |
||||
<th class="font-filters">Filtrar alertas</th> |
||||
<td> </td> |
||||
<th class="font-filters">Empresa</th> |
||||
<td> </td> |
||||
</tr> |
||||
{* Conteudo dos filtros *} |
||||
<tr> |
||||
<td> </td> |
||||
<td> |
||||
<div class="divs-filters inputs-filters"> |
||||
<label for="filtroDangerOn"> Sim </label> |
||||
<input class="inputs-filters" name="filtroDanger" id="filtroDangerOn" |
||||
class="clean" type="radio" value='1' {if $filtroDanger == 1 } checked {/if} |
||||
autocomplete="off"/> |
||||
<label for="filtroDangerOff"> Não</label> |
||||
<input class="inputs-filters" name="filtroDanger" id="filtroDangerOff" |
||||
class="clean" type="radio" value='0' {if $filtroDanger == 0 } checked {/if} |
||||
autocomplete="off" /> |
||||
</div> |
||||
</td> |
||||
<td> </td> |
||||
<td> |
||||
<div class="divs-filters"> |
||||
<select class="inputs-filters" name="empresas"> |
||||
{$empresas} |
||||
</select> |
||||
<div> |
||||
</td> |
||||
<td> </td> |
||||
<th class="font-filters">Tempo de atualização (minutos): </th> |
||||
<td> |
||||
<div class="divs-filters"> |
||||
<input class="inputs-filters" type="text" name="refresh" id="refresh" size="5" |
||||
maxlength="5" value="{$refresh}"> |
||||
<div> |
||||
</td> |
||||
<td> </td> |
||||
<div class="divs-filters"> |
||||
<td> |
||||
<input class="inputs-filters" type="submit" name="btConsulta" id="btConsulta" |
||||
value="Consultar" /> |
||||
</td> |
||||
<div> |
||||
</tr> |
||||
</table> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td> |
||||
<table width="100%" class="grid" id="grid" cellspacing="4" cellpadding="4"> |
||||
{$eventRows} |
||||
{if $mensagem} |
||||
<tr> |
||||
<td colspan="11" align="center"> |
||||
<strong>{$mensagem}</strong> |
||||
</td> |
||||
</tr> |
||||
{/if} |
||||
</table> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
<script> |
||||
const valorFiltro = {$filtroDanger}; |
||||
{literal} |
||||
$(function() { |
||||
// Obter o horário do cliente |
||||
let horarioCliente = new Date().toLocaleTimeString(); |
||||
let textoHorario = 'Última atualização: ' + horarioCliente; |
||||
$('#horario-update').text(textoHorario); |
||||
updateData(valorFiltro); |
||||
}) |
||||
|
||||
</tr> |
||||
<tr> |
||||
<td style="white-space: nowrap;"><input name="dataIni" id="dataIni" type="text" |
||||
size="15" maxlength="10" value="{$dataIni}" onkeyup="formataData(this)" |
||||
title="dd/mm/aaaa"></td> |
||||
<td> </td> |
||||
function updateData(valorFiltro) { |
||||
let refresh = $('#refresh').val() * 100000; //converte minuto em milisegundos |
||||
|
||||
<td style="white-space: nowrap;"><input name="dataFim" id="dataFim" type="text" |
||||
size="15" maxlength="10" value="{$dataFim}" onkeyup="formataData(this)" |
||||
title="dd/mm/aaaa"></td> |
||||
<td> </td> |
||||
setInterval(function() { |
||||
let horarioUpdated = new Date().toLocaleTimeString(); |
||||
let filtroDanger = valorFiltro; |
||||
let idEmpresa = $('select[name="empresas"]').val(); |
||||
let textoHorario = 'Última atualização: ' + horarioUpdated; |
||||
|
||||
<td> |
||||
<select name="empresas"> |
||||
{$empresas} |
||||
</select> |
||||
</td> |
||||
<td> </td> |
||||
|
||||
<th style="white-space: nowrap;">Tempo de atualização (minutos): </th> |
||||
<td align="center"> |
||||
<input type="text" name="refresh" id="refresh" size="5" maxlength="5" |
||||
value="{$refresh}"> |
||||
</td> |
||||
<td> |
||||
<input type="submit" name="btConsulta" id="btConsulta" value="Consultar" /> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td> |
||||
<table width="100%" class="grid" id="grid" cellspacing="4" cellpadding="4"> |
||||
{$eventRows} |
||||
{if $mensagem} |
||||
<tr> |
||||
<td colspan="11" align="center"> |
||||
<strong>{$mensagem}</strong> |
||||
</td> |
||||
</tr> |
||||
{/if} |
||||
</table> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
|
||||
{literal} |
||||
<script> |
||||
$(function () { |
||||
updateData() |
||||
}) |
||||
|
||||
function updateData() { |
||||
let refresh = $('#refresh').val() * 60000; //converte minuto em milisegundos |
||||
|
||||
setInterval(function () { |
||||
let dataIni = $('#dataIni').val(); |
||||
let dataFim = $('#dataFim').val(); |
||||
let idEmpresa = $('select[name="empresas"]').val(); |
||||
|
||||
$.ajax({ |
||||
url: 'index.php?idProg=370&ajax=1', |
||||
method: 'POST', |
||||
data: { |
||||
dataIni: dataIni, |
||||
dataFim: dataFim, |
||||
idEmpresa: idEmpresa |
||||
}, |
||||
success: function (response) { |
||||
$('#eventRows').empty(); |
||||
$('#grid').html(response.eventRows); |
||||
} |
||||
$.ajax({ |
||||
url: 'index.php?idProg=370&ajax=1', |
||||
method: 'POST', |
||||
data: { |
||||
filtroDanger: filtroDanger, |
||||
idEmpresa: idEmpresa, |
||||
}, |
||||
success: function(response) { |
||||
$('#eventRows').empty(); |
||||
$('#grid').html(response.eventRows); |
||||
$('#horario-update').text(textoHorario); |
||||
} |
||||
}); |
||||
}, refresh); |
||||
} |
||||
document.getElementById("formGeral").addEventListener("submit", function() { |
||||
document.getElementById("overlay").style.display = "block"; |
||||
document.getElementById("loading").style.display = "block"; |
||||
}); |
||||
}, refresh); |
||||
} |
||||
|
||||
</script> |
||||
{/literal} |
||||
</script> |
||||
{/literal} |
||||
{/capture} |
@ -0,0 +1,140 @@
|
||||
<?php |
||||
|
||||
|
||||
function query_CountEventsHds(){ |
||||
|
||||
return " SELECT |
||||
veh.filesystem, |
||||
SUM(CASE WHEN veh.hd_percentage_busy > vpa.hd_percentage_busy THEN 1 ELSE 0 END) AS total_status_tronco_events |
||||
FROM |
||||
vds_events ve |
||||
INNER JOIN vds_events_hd veh ON ve.id = veh.id_event |
||||
INNER JOIN |
||||
( |
||||
SELECT |
||||
vemp.emp_id, |
||||
vemp.emp_nome_fantasia, |
||||
vs.id AS id_server, |
||||
vs.address, |
||||
pgr.gp_id |
||||
FROM |
||||
vds_empresas vemp |
||||
INNER JOIN vds_servidores vs ON |
||||
vs.address = vemp.emp_vpn |
||||
INNER JOIN pbx_grupo_revendas pgr ON |
||||
pgr.emp_id = vemp.emp_id |
||||
WHERE vemp.emp_id = $1 |
||||
) servers |
||||
ON |
||||
ve.id_servidor = servers.id_server |
||||
INNER JOIN vds_params_alerts vpa ON |
||||
vpa.id_group = servers.gp_id |
||||
AND vpa.status = 1 |
||||
GROUP BY veh.filesystem;"; |
||||
|
||||
} |
||||
|
||||
|
||||
function getCountEventsHds($prepared_name, $param){ |
||||
|
||||
try { |
||||
$result = pg_execute($GLOBALS["dbconn"], $prepared_name, $param); |
||||
|
||||
if ($result) { |
||||
return pg_fetch_all($result); |
||||
} |
||||
|
||||
throw new Exception('Ocorreu um erro na consulta.'); |
||||
} catch (Exception $exception) { |
||||
$log = $exception->getMessage(); |
||||
return false; |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
function getStatusHds($prepared_name, $param){ |
||||
try { |
||||
$result = pg_execute($GLOBALS["dbconn"], $prepared_name, $param); |
||||
|
||||
if ($result) { |
||||
return pg_fetch_all($result); |
||||
} |
||||
|
||||
throw new Exception('Ocorreu um erro na consulta.'); |
||||
} catch (Exception $exception) { |
||||
$log = $exception->getMessage(); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
function query_StatusHds(){ |
||||
return " SELECT |
||||
veh.filesystem, |
||||
MAX(veh.hd_percentage_busy) AS ultimo_status |
||||
FROM |
||||
( |
||||
SELECT |
||||
veh.filesystem, |
||||
veh.hd_percentage_busy, |
||||
ROW_NUMBER() OVER(PARTITION BY veh.filesystem ORDER BY ve.event_timestamp DESC) AS rn |
||||
FROM |
||||
vds_events ve |
||||
INNER JOIN vds_events_hd veh ON ve.id = veh.id_event |
||||
INNER JOIN |
||||
( |
||||
SELECT |
||||
vemp.emp_id, |
||||
vemp.emp_nome_fantasia, |
||||
vs.id AS id_server, |
||||
vs.address, |
||||
pgr.gp_id |
||||
FROM |
||||
vds_empresas vemp |
||||
INNER JOIN vds_servidores vs ON |
||||
vs.address = vemp.emp_vpn |
||||
INNER JOIN pbx_grupo_revendas pgr ON |
||||
pgr.emp_id = vemp.emp_id |
||||
WHERE |
||||
vemp.emp_id = $1 |
||||
) servers |
||||
ON |
||||
ve.id_servidor = servers.id_server |
||||
INNER JOIN vds_params_alerts vpa ON |
||||
vpa.id_group = servers.gp_id |
||||
AND vpa.status = 1 |
||||
) veh |
||||
WHERE |
||||
veh.rn = 1 |
||||
GROUP BY |
||||
veh.filesystem;"; |
||||
} |
||||
|
||||
|
||||
function getEventsHdsHtml($data) |
||||
{ |
||||
$rows = ''; |
||||
|
||||
foreach ($data as $hd) { |
||||
$nome = $hd['filesystem']; |
||||
$hdBusy = $hd['hd_busy']; |
||||
$hdTotal = $hd['hd_total']; |
||||
$hdPercentageBusy = $hd['hd_percentage_busy']; |
||||
|
||||
$servidor = $hd['address']; |
||||
|
||||
$rows .= "<tr>"; |
||||
$rows .= "<td align=\"center\"><a target=\"_blank\" href=\"http://{$servidor}\">{$servidor}</a></td>"; |
||||
$rows .= "<td align=\"center\">" . $nome . "</td>"; |
||||
$rows .= "<td align=\"center\">" . $hdTotal . "</td>"; |
||||
$rows .= "<td align=\"center\">" . $hdBusy . "</td>"; |
||||
$rows .= "<td align=\"center\">" . $hdPercentageBusy . "</td>"; |
||||
$rows .= "</tr>"; |
||||
} |
||||
|
||||
$rows .= "<tr><th colspan='9'></th></tr>"; |
||||
|
||||
return $rows; |
||||
} |
||||
|
||||
|
@ -0,0 +1,120 @@
|
||||
<?php |
||||
|
||||
function query_StatusTroncos(){ |
||||
return " SELECT |
||||
vet.name, |
||||
MAX(vet.status) AS ultimo_status |
||||
FROM |
||||
( |
||||
SELECT |
||||
vet.name, |
||||
vet.status, |
||||
ROW_NUMBER() OVER(PARTITION BY vet.name ORDER BY ve.event_timestamp DESC) AS rn |
||||
FROM |
||||
vds_events ve |
||||
INNER JOIN vds_events_troncos vet ON ve.id = vet.id_event |
||||
INNER JOIN |
||||
( |
||||
SELECT |
||||
vemp.emp_id, |
||||
vemp.emp_nome_fantasia, |
||||
vs.id AS id_server, |
||||
vs.address, |
||||
pgr.gp_id |
||||
FROM |
||||
vds_empresas vemp |
||||
INNER JOIN vds_servidores vs ON |
||||
vs.address = vemp.emp_vpn |
||||
INNER JOIN pbx_grupo_revendas pgr ON |
||||
pgr.emp_id = vemp.emp_id |
||||
WHERE |
||||
vemp.emp_id = $1 |
||||
) servers |
||||
ON |
||||
ve.id_servidor = servers.id_server |
||||
INNER JOIN vds_params_alerts vpa ON |
||||
vpa.id_group = servers.gp_id |
||||
AND vpa.status = 1 |
||||
) vet |
||||
WHERE |
||||
vet.rn = 1 |
||||
GROUP BY |
||||
vet.name;"; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Seleciona o ultimo status de cada tronco, |
||||
* serve para saber se existe algum tronco com falha no momento da ultima consulta |
||||
*/ |
||||
function getStatusTroncos($prepared_name, $param) |
||||
{ |
||||
try { |
||||
$result = pg_execute($GLOBALS["dbconn"], $prepared_name, $param); |
||||
|
||||
if ($result) { |
||||
return pg_fetch_all($result); |
||||
} |
||||
|
||||
throw new Exception('Ocorreu um erro na consulta.'); |
||||
} catch (Exception $exception) { |
||||
$log = $exception->getMessage(); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
|
||||
function query_CountEventsTroncos(){ |
||||
|
||||
return "SELECT |
||||
SUM(CASE WHEN vet.status not like ('%OK%') THEN 1 ELSE 0 END) AS total_status_tronco_events |
||||
FROM |
||||
vds_events ve |
||||
INNER JOIN vds_events_troncos vet ON ve.id = vet.id_event |
||||
INNER JOIN |
||||
( |
||||
SELECT |
||||
vemp.emp_id, |
||||
vemp.emp_nome_fantasia, |
||||
vs.id AS id_server, |
||||
vs.address, |
||||
pgr.gp_id |
||||
FROM |
||||
vds_empresas vemp |
||||
INNER JOIN vds_servidores vs ON |
||||
vs.address = vemp.emp_vpn |
||||
INNER JOIN pbx_grupo_revendas pgr ON |
||||
pgr.emp_id = vemp.emp_id |
||||
WHERE |
||||
vemp.emp_id = $1 |
||||
) servers |
||||
ON |
||||
ve.id_servidor = servers.id_server |
||||
INNER JOIN vds_params_alerts vpa ON |
||||
vpa.id_group = servers.gp_id |
||||
AND vpa.status = 1;"; |
||||
} |
||||
|
||||
|
||||
|
||||
/** |
||||
* Seleciona a quantidade de eventos relacionados aos troncos que ocorreram no periodo |
||||
*/ |
||||
function getCountEventsTroncos($prepared_name, $param) |
||||
{ |
||||
|
||||
try { |
||||
$result = pg_execute( $GLOBALS["dbconn"], $prepared_name, $param ); |
||||
|
||||
if ($result) { |
||||
return pg_fetch_assoc($result); |
||||
} |
||||
|
||||
throw new Exception('Ocorreu um erro na consulta.'); |
||||
} catch (Exception $exception) { |
||||
$log = $exception->getMessage(); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
|
Loading…
Reference in new issue