forked from SimplesIP/pabx-app
root
2 years ago
19 changed files with 1361 additions and 374 deletions
@ -1,4 +1,5 @@
|
||||
compara |
||||
templates_c |
||||
integracao/arquivoCampanha |
||||
|
||||
cadastro/licenca/*.lca |
||||
cadastro/licenca/tmp/*.lca |
||||
|
@ -1,126 +1,370 @@
|
||||
<?php |
||||
|
||||
$tpLayout = 1; |
||||
|
||||
/* |
||||
* To change this template, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
$tpLayout = 1; |
||||
$matricula = GetMatricula(); |
||||
$consultar = isset($_POST["btPesquisa"]); |
||||
$valida = isset($_POST["btAnota"]) && (trim($_POST["AnotaTexto"]) != ""); |
||||
$agtAnota = isset($_POST["AnotaTexto"]) ? $_POST["AnotaTexto"] : ""; |
||||
$agtFone = isset($_POST["AnotaFone"]) ? soNumero($_POST["AnotaFone"]) : (isset($_SESSION[RAMAL_DESTINO]) ? soNumero($_SESSION[RAMAL_DESTINO]) : ''); |
||||
$btAnota = isset($_POST["btAnota"]) ? $_POST["btAnota"] : ""; |
||||
$listaAgente = isset($_POST["listaAgente"]) ? $_POST["listaAgente"] : GetMatricula(); |
||||
$dataIni = !isset($_POST["dataIni"]) ? date('d/m/Y') : $_POST["dataIni"]; |
||||
$dataFim = !isset($_POST["dataFim"]) ? date('d/m/Y') : $_POST["dataFim"]; |
||||
|
||||
$msg = ""; |
||||
$pesquisa = ""; |
||||
|
||||
if (isset($_GET["formAction"])) { |
||||
$idDel = $_GET["id"]; |
||||
$query = "delete from pbx_anotacoes where id_text = '$idDel'"; |
||||
@pg_query($dbcon, $query); |
||||
} |
||||
|
||||
if (!is_date($dataIni)) { |
||||
$jsStartup[] = "alert('Data inicial inválida!');"; |
||||
$msg = "Data inicial inválida!"; |
||||
$isValid = 0; |
||||
} else if (!is_date($dataFim)) { |
||||
$jsStartup[] = "alert('Data final inválida!');"; |
||||
$msg = "Data final inválida!"; |
||||
$isValid = 0; |
||||
} else if (!$consultar && $valida && empty($agtFone)) { |
||||
$msg = GetAnotacoesKey() ? "Informe o número do telefone!" : "Informe o número do protocolo!"; |
||||
} else if ($valida && empty($agtAnota)) { |
||||
$msg = "Insira uma anotação!"; |
||||
} else if (!$consultar && $valida) { |
||||
$query = "insert into pbx_anotacoes(conteudo, matricula_agente, fone_cliente) |
||||
values('$agtAnota', '$matricula', '$agtFone')"; |
||||
$result = pg_query($dbcon, $query); |
||||
if ($result) { |
||||
$agtAnota = ""; |
||||
$msg = "Operação realizada com sucesso!"; |
||||
} |
||||
} |
||||
|
||||
|
||||
$pesquisa = PesquisaFone($dbcon, $agtFone); |
||||
if (empty($pesquisa)) |
||||
$pesquisa = "<tr><td colspan=4>Nenhum registro encontrado!</td></tr>"; |
||||
|
||||
|
||||
$cor = !$msg || stripos($msg, 'sucesso') ? '#0000FF' : '#FF0000'; |
||||
$smarty->assign("AnotaFone", $agtFone); |
||||
$smarty->assign("AnotaTexto", $agtAnota); |
||||
$smarty->assign("corErro", $cor); |
||||
$smarty->assign("msg", $msg); |
||||
$smarty->assign("linhas", $pesquisa); |
||||
$smarty->assign("isFone", GetAnotacoesKey()); |
||||
$smarty->assign("isSuper", IsSuper()); |
||||
$smarty->assign("dataIni", $dataIni); |
||||
$smarty->assign("dataFim", $dataFim); |
||||
$smarty->assign("prm_label_protoco_pesquisa", $_SESSION['prm_label_protoco_pesquisa']); |
||||
$smarty->assign("prm_label_protoco_texto", $_SESSION['prm_label_protoco_texto']); |
||||
$smarty->assign("prm_label_protoco_grid", $_SESSION['prm_label_protoco_grid']); |
||||
if (IsSuper()) { |
||||
$agentes = GetAgentesAnotacoes($listaAgente); |
||||
$smarty->assign("listaAgente", $agentes); |
||||
} |
||||
DispLogin($smarty); |
||||
|
||||
function PesquisaFone($db, $num) { |
||||
global $listaAgente, $dataIni, $dataFim; |
||||
$mat = IsSuper() ? $listaAgente : GetMatricula(); |
||||
$query = "select a.id_text, a.conteudo, a.matricula_agente, a.fone_cliente, a.data, b.apelido from pbx_anotacoes a, pbx_usuarios b where b.matricula = a.matricula_agente::text "; |
||||
$query .= $mat ? " and a.matricula_agente::text = '$mat' " : ""; |
||||
$query .= sprintf(" and data::date >= %s and data::date <= %s ", FormatDtMssql($dataIni, true), FormatDtMssql($dataFim, true)); |
||||
$query .= " and fone_cliente like '%" . $num . "%'"; |
||||
$query .= " order by b.apelido, a.data desc"; |
||||
|
||||
$result = @pg_query($db, $query); |
||||
//if(IsAdmin()) echo $query; |
||||
while (($result) && ($row = pg_fetch_array($result))) { |
||||
$fone = GetAnotacoesKey() ? FormataFone($row["fone_cliente"]) : $row["fone_cliente"]; |
||||
$content = $row["conteudo"]; |
||||
$matAgt = $row["matricula_agente"] . '-' . $row["apelido"]; |
||||
$data = date('d/m/Y', strtotime($row["data"])); |
||||
$imgDel = GetLinkFormDelete($row["id_text"], 'DeletaAnotacao'); |
||||
$linha .= "<tr> |
||||
<td align=left>$data</td>"; |
||||
if (IsSuper()) { |
||||
$linha .= " <td align=left>$matAgt</td>"; |
||||
include_once 'util/relatoriosBase.php'; |
||||
|
||||
class AgenteAnota extends Relatorios { |
||||
|
||||
private $___consultar; |
||||
private $___validar; |
||||
private $___agenteAnota; |
||||
private $___agenteFone; |
||||
private $___listaAgente; |
||||
private $___matricula; |
||||
|
||||
public function __construct($idProg, $dbcon, $incDac) { |
||||
parent::__construct($idProg, $dbcon, $incDac); |
||||
$this->___consultar = isset($_POST["btPesquisa"]); |
||||
$this->___validar = isset($_POST["btAnota"]) && (trim($_POST["AnotaTexto"]) != ""); |
||||
$this->___agenteAnota = isset($_POST["AnotaTexto"]) ? $_POST["AnotaTexto"] : ""; |
||||
$this->___agenteFone = isset($_POST["AnotaFone"]) ? soNumero($_POST["AnotaFone"]) : (isset($_SESSION[RAMAL_DESTINO]) ? soNumero($_SESSION[RAMAL_DESTINO]) : ''); |
||||
$this->___listaAgente = isset($_POST["listaAgente"]) ? $_POST["listaAgente"] : GetMatricula(); |
||||
$this->___dataIni = IsPostBack() ? $_POST['dataIni'] : date('d/m/Y'); |
||||
$this->___dataFim = IsPostBack() ? $_POST['dataFim'] : date('d/m/Y'); |
||||
$this->___matricula = GetMatricula(); |
||||
} |
||||
$linha .= " <td align=left>$fone</td> |
||||
<td align=left>$content</td> |
||||
<td align=center>$imgDel</td> |
||||
</tr>"; |
||||
} |
||||
$colspan = IsSuper() ? 4 : 3; |
||||
if (empty($linha)) |
||||
$linha = "<tr><td colspan=\"$colspan\">Nenhum registro encontrado!</td></tr>"; |
||||
|
||||
return $linha; |
||||
} |
||||
|
||||
function DispLogin($smarty) { |
||||
$smarty->display('callcenter/agente/agenteAnota.tpl'); |
||||
} |
||||
|
||||
function GetAgentesAnotacoes($matricula) { |
||||
$query = "select id, apelido, nome, matricula from pbx_usuarios where delete_ = 0 and apelido not in('sinccontasenha' )"; //'admin', |
||||
$result = pg_query($query); |
||||
$sel = $matricula == "0" ? ' Selected="selected" ' : ''; |
||||
$item = "<option value=\"0\"$sel>Todos</option>\n"; |
||||
while ($dados = pg_fetch_array($result, null, PGSQL_ASSOC)) { |
||||
$mat = $dados['matricula']; |
||||
$apelido = $dados['apelido']; |
||||
$sel = $mat == $matricula ? ' Selected="selected" ' : ''; |
||||
$item .= "<option value=\"$mat\"$sel>$apelido-[$mat]</option>\n"; |
||||
|
||||
function ___ValidaForm() { |
||||
|
||||
if (!is_date($this->___dataIni) && empty($this->___agenteFone)) { |
||||
GeraExcept('A "Data Inicial" informada é inválida!'); |
||||
} |
||||
|
||||
if (!is_date($this->___dataFim) && empty($this->___agenteFone)) { |
||||
GeraExcept('A "Data Final" informada é inválida!'); |
||||
} |
||||
|
||||
if (!$this->___consultar && $this->___validar && empty($this->___agenteFone)) { |
||||
$msg = GetAnotacoesKey() ? "Informe o número do telefone!" : "Informe o número do protocolo!"; |
||||
GeraExcept($msg); |
||||
} |
||||
|
||||
if($this->___validar && !$this->___consultar){ |
||||
$this->___InserirAnotacao(); |
||||
} |
||||
} |
||||
|
||||
function ___FiltrosRelatorio() { |
||||
if ($this->___media != MEDIA_PRINT_GRID) { |
||||
/* |
||||
* Recupera os filtros da sess�o do usu�rio. |
||||
*/ |
||||
list($this->___dataIni, $this->___dataFim, $this->___agenteFone) = $_SESSION["SSstorageFiltros"]; |
||||
|
||||
if ($this->___media == MEDIA_PRINT_HTML) { |
||||
return sprintf("Data Inicial: %s Data Final: %s ", $this->___dataIni, $this->___dataFim); |
||||
} |
||||
|
||||
$fltCsv = array(); |
||||
$fltCsv[] = "Data Inicial: " . $this->___dataIni; |
||||
$fltCsv[] = "Data Final: " . $this->___dataFim; |
||||
$fltCsv[] = "Data Hora Emissao: " . date('d/m/Y H i s)'); |
||||
$fltCsv[] = "Emitido Por: " . GetLogin(); |
||||
return $fltCsv; |
||||
} |
||||
|
||||
$lkPrint = ""; |
||||
if ($this->___dataCount) { |
||||
$prt = '<a href="index.php?idProg=%s&media=%s"><img src="imgSite/%s" alt="Clique aqui para imprimir!" width="24" height="24" border="0"></a>'; |
||||
$prtHtml = "<a href=\"javaScript:NovaJanela('index.php?idProg=%s&media=%s', '%s', '720', '700', 'scrollbars=YES');\"><img src=\"imgSite/%s\" alt=\"Clique aqui para imprimir!\" width=\"24\" height=\"24\" border=\"0\"></a>"; |
||||
//$lkPrint .= sprintf($prtHtml, $this->GetidProg(), MEDIA_PRINT_HTML, substr(LimpaString(GetDispProgSel($this->GetIdProg())), 0, 20), 'print.gif'); |
||||
$lkPrint .= sprintf($prt, $this->GetidProg(), MEDIA_PRINT_EXCEL, 'prt-xls.png'); |
||||
//$lkPrint .= sprintf($prt, $this->GetidProg(), MEDIA_PRINT_PDF, 'prt-pdf.png'); |
||||
//$lkPrint .= sprintf($prt, $this->GetidProg(), MEDIA_PRINT_CSV, 'prt-csv.png'); |
||||
} |
||||
|
||||
$filtro .= '<table border="0" align="center" cellpadding="8" cellspacing="0" style="border-top:0;font-size:12px;" > |
||||
<tr> |
||||
<td align="center"> |
||||
<span style="font-face:Arial, Helvetica, sans-serif; font-size:16px; font-weight:bold;"> |
||||
<img src="imgSite/anotacoes.png" alt="Bloco de Anotações" align="absmiddle" width="32" height="32" border="0" title="Bloco de Anotações"> |
||||
Bloco de Anotações |
||||
</span> |
||||
</td> |
||||
</tr> |
||||
</table>'; |
||||
/* |
||||
* Personalise esta função se necessitar de outras opções de filtro. |
||||
*/ |
||||
$filtro .= '<table class="filtro" align="center" border="0" cellspacing="1" cellpadding="1">'; |
||||
/* |
||||
* Rotulos. |
||||
*/ |
||||
$filtro .= '<tr>'; |
||||
$filtro .= IsSuper() ? '<td>Agentes</td>' : ''; |
||||
$filtro .= '<td>Agentes</td>'; |
||||
$filtro .= '<td>Data Inicial </td>'; |
||||
$filtro .= '<td>Data Final </td>'; |
||||
$filtro .= sprintf('<td>%s</td>', GetAnotacoesKey() ? 'Fone' : $_SESSION['prm_label_protoco_pesquisa']); |
||||
|
||||
/* |
||||
* Valores. |
||||
*/ |
||||
$filtro .= '<tr>'; |
||||
$filtro .= IsSuper() ? sprintf("<td><select name='listaAgente'>%s</select></td>", $this->GetAgentesAnotacoes($this->___listaAgente)) : ''; |
||||
$filtro .= sprintf("<td><select name='listaAgente'>%s</select></td>", $this->GetAgentesAnotacoes($this->___listaAgente)); |
||||
$filtro .= '<td><input name="dataIni" id="dataIni" type="text" size="15" maxlength="16" value="%s" onkeyup="formataDataHora(this)" title="dd/mm/aaaa"></td>'; |
||||
$filtro .= '<td><input name="dataFim" id="dataFim" type="text" size="15" maxlength="16" value="%s" onkeyup="formataDataHora(this)" title="dd/mm/aaaa"></td>'; |
||||
$filtro .= '<td><div> '; |
||||
$filtro .= sprintf('<input name="AnotaFone" size="20" type="text" id="AnotaFone" value="%s">' |
||||
. '<input name="btPesquisa" type="submit" id="btPesquisa" value="Pesquisar">' |
||||
. '<input name="btAnota" type="submit" id="btAnota" value="Salvar">', $this->___agenteFone); |
||||
$filtro .= '</div></td>'; |
||||
$filtro .= '<td>%s</td>'; |
||||
$filtro .= '</tr>'; |
||||
$filtro .= '</table>'; |
||||
|
||||
$filtro .= "<br>"; |
||||
|
||||
$filtro .= '<table class="grid" align="center" border="0" cellspacing="1" cellpadding="1">'; |
||||
$filtro .= "<tr><td class='destaque'>{$_SESSION['prm_label_protoco_texto']}</td></tr>"; |
||||
$filtro .= "<tr>"; |
||||
$filtro .= "<td><textarea name='AnotaTexto' cols='114' rows='8' id='AnotaTexto'></textarea></td>"; |
||||
$filtro .= "</tr>"; |
||||
$filtro .= "</table>"; |
||||
|
||||
|
||||
/* |
||||
* Guarda os filtros passados para recuperar na emiss�o dos relat?ios para impress�o. |
||||
*/ |
||||
$_SESSION["SSstorageFiltros"] = array($this->___dataIni, $this->___dataFim, $this->___agenteFone); |
||||
|
||||
return sprintf($filtro, $this->___dataIni, $this->___dataFim, $lkPrint); |
||||
} |
||||
|
||||
protected function ___GetDadosDb() { |
||||
$dataIni = FormatDtMssql($this->___dataIni); |
||||
$dataFim = FormatDtMssql($this->___dataFim); |
||||
|
||||
$query = sprintf("SELECT a.id_text, a.conteudo, a.matricula_agente, a.fone_cliente, a.data, b.apelido |
||||
FROM pbx_anotacoes a |
||||
INNER JOIN pbx_usuarios b ON b.matricula = a.matricula_agente::text |
||||
WHERE data::DATE >= '$dataIni' AND data::DATE <= '$dataFim'"); |
||||
|
||||
if(empty($this->___agenteFone)){ |
||||
$query .= $this->___listaAgente ? " AND a.matricula_agente::text = '$this->___listaAgente' " : ""; |
||||
} |
||||
|
||||
$query .= " AND fone_cliente LIKE '%$this->___agenteFone%'"; |
||||
$query .= " ORDER BY b.apelido, a.data DESC"; |
||||
|
||||
$result = $this->___GetQuery($query); |
||||
$row = pg_fetch_all($result); |
||||
|
||||
$this->SetData($row ? $row : array()); |
||||
} |
||||
|
||||
protected function ___PreparaCsv() { |
||||
|
||||
} |
||||
|
||||
protected function ___PreparaExcel() { |
||||
$dataRel = array(); |
||||
$dataAgrup = array(); |
||||
$filtro = $this->___FiltrosRelatorio(); |
||||
|
||||
/* |
||||
* Inicia o relatório. |
||||
*/ |
||||
|
||||
/* |
||||
* Cria os filtros |
||||
*/ |
||||
$linha = array('LABEL'); |
||||
foreach ($filtro as $values) { |
||||
list($label, $value) = explode(":", $values); |
||||
$linha[] = $label; |
||||
} |
||||
$dataRel[] = $linha; |
||||
|
||||
$linha = array('DADOS'); |
||||
foreach ($filtro as $values) { |
||||
list($label, $value) = explode(":", $values); |
||||
$linha[] = $value; |
||||
} |
||||
|
||||
$dataRel[] = $linha; |
||||
|
||||
$dadosCabecalio = array('ID','Data', RemoveAcentos($_SESSION['prm_label_protoco_pesquisa']), 'Mensagem','Autor'); |
||||
$dadosField = array('id_text', 'data', 'fone_cliente', 'conteudo', 'apelido'); |
||||
|
||||
/* |
||||
* Monta a linha de cabecalio. |
||||
*/ |
||||
$linha = array('LABEL'); |
||||
foreach ($dadosCabecalio as $value) { |
||||
$linha[] = $value; |
||||
} |
||||
$dataRel[] = $linha; |
||||
|
||||
$somaTempo = 0; |
||||
$somaQuantidade = 0; |
||||
/* |
||||
* Linhas de dados. |
||||
*/ |
||||
foreach ($this->GetData()[0] as $row) { |
||||
$row["data"] = date('d/m/Y', strtotime($row["data"])); |
||||
$row["conteudo"] = RemoveAcentos($row['conteudo']); |
||||
// Formata linha de dados. |
||||
$linha = array('DADOS'); |
||||
foreach ($dadosField as $key) { |
||||
$linha[] = $row["$key"]; |
||||
} |
||||
|
||||
$dataRel[] = $linha; |
||||
} |
||||
|
||||
$dataRel[] = $linha; |
||||
|
||||
$this->___dataRel[] = $dataRel; |
||||
} |
||||
|
||||
protected function ___PreparaGrid() { |
||||
$dadosCabecalio = array( |
||||
'ID' => 'align="center"', |
||||
'Data' => 'align="center"', |
||||
$_SESSION['prm_label_protoco_pesquisa'] => 'align="center"', |
||||
'Mensagem' => 'align="left"', |
||||
'Autor' => 'align="center"', |
||||
); |
||||
$dadosField = array( |
||||
'id_text' => 'align="center"', |
||||
'data' => 'align="center"', |
||||
'fone_cliente' => 'align="center"', |
||||
'conteudo' => 'align="left"', |
||||
'apelido' => 'align="center"', |
||||
); |
||||
/* |
||||
* Inicia o relat�rio. |
||||
*/ |
||||
$dataRel[] = '<table width="99%" cellpadding="2" class="grid">'; |
||||
|
||||
/* |
||||
* Monta a linha de cabecalio. |
||||
*/ |
||||
$linha = '<tr>'; |
||||
foreach ($dadosCabecalio as $key => $value) { |
||||
$linha .= sprintf("<th %s>%s</th>", $value, $key); |
||||
} |
||||
$linha .= "</tr>"; |
||||
$dataRel[] = $linha; |
||||
|
||||
/* |
||||
* Verifica se retornou dados |
||||
*/ |
||||
if (!IsPostBack() || !count($this->GetData()[0])) { |
||||
$dataRel[] = sprintf("<tr><td align=\"center\" colspan=\"%s\">%s</td></tr></table>", count($dadosCabecalio), (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!')); |
||||
$this->___dataRel[] = $dataRel; |
||||
return; |
||||
} |
||||
|
||||
$somaQuantidade = 0; |
||||
/* |
||||
* Linhas de dados. |
||||
*/ |
||||
foreach ($this->GetData()[0] as $row) { |
||||
$row["data"] = date('d/m/Y', strtotime($row["data"])); |
||||
|
||||
// Formata linha de dados. |
||||
$linha = "<tr>"; |
||||
foreach ($dadosField as $key => $value) { |
||||
$linha .= sprintf("<td %s>%s</td>", $value, $row["$key"]); |
||||
} |
||||
$linha .= "</tr>"; |
||||
$dataRel[] = $linha; |
||||
} |
||||
/* |
||||
* Linha de totalizacao. |
||||
*/ |
||||
//$linha = '<tr><th colspan="2" align="left">Total</th><th align="left" colspan="2">Registros: %s</th><th align="left" colspan="6">Duração: %s</th></tr>'; |
||||
//$dataRel[] = sprintf($linha, $somaQuantidade, SecondToStrTime($somaTempo)); |
||||
|
||||
/* |
||||
* Fecha relatorio. |
||||
*/ |
||||
$dataRel[] = '</table>'; |
||||
$this->___dataRel[] = $dataRel; |
||||
} |
||||
|
||||
protected function ___PreparaHtml() { |
||||
|
||||
} |
||||
|
||||
protected function ___PreparaPdf() { |
||||
|
||||
} |
||||
|
||||
private function ___InserirAnotacao(){ |
||||
if ($this->___validar && empty($this->___agenteAnota)) { |
||||
GeraExcept("Insira uma anotação!"); |
||||
} |
||||
|
||||
$query = "SELECT * FROM pbx_anotacoes WHERE conteudo = '{$this->___agenteAnota}' AND fone_cliente = '{$this->___agenteFone}';"; |
||||
$res = $this->___GetQuery($query); |
||||
if(pg_fetch_assoc($res)){ |
||||
GeraExcept('Essas informações já foram registradas!'); |
||||
} |
||||
|
||||
$query = "INSERT INTO pbx_anotacoes (conteudo,matricula_agente,fone_cliente) VALUES('$this->___agenteAnota', '$this->___matricula', '$this->___agenteFone');"; |
||||
$result = $this->___GetQuery($query); |
||||
if(!$result){ |
||||
GeraExcept('Não foi possível inserir o registro'); |
||||
} |
||||
} |
||||
|
||||
private function GetAgentesAnotacoes($matricula) { |
||||
$query = "SELECT id, apelido, nome, matricula FROM pbx_usuarios WHERE delete_ = 0 AND apelido NOT IN('sinccontasenha') ORDER BY apelido"; //'admin', |
||||
$result = $this->___GetQuery($query); |
||||
$sel = $matricula == "0" ? ' Selected="selected" ' : ''; |
||||
$item = "<option value=\"0\"$sel>Todos</option>\n"; |
||||
|
||||
while ($dados = pg_fetch_array($result, null, PGSQL_ASSOC)) { |
||||
$mat = $dados['matricula']; |
||||
$apelido = $dados['apelido']; |
||||
$sel = $mat == $matricula ? ' Selected="selected" ' : ''; |
||||
$item .= "<option value=\"$mat\"$sel>$apelido-[$mat]</option>\n"; |
||||
} |
||||
return $item; |
||||
} |
||||
|
||||
public function ExecutaRelatorio() { |
||||
global $jsStartup, $jsJQuery, $smarty; |
||||
try { |
||||
/* |
||||
* Use esta fun��o para validar dados do formul�rio. |
||||
*/ |
||||
$this->___ValidaForm(); |
||||
|
||||
/* |
||||
* Recupera os dados do banco. |
||||
*/ |
||||
$this->___ConteudoRelatorio(); |
||||
|
||||
/* |
||||
* Imprime relat�rio de acordo com a media passada. |
||||
*/ |
||||
$conteudoRelatorio = $this->___ImprimeRelatorio(); |
||||
} catch (Exception $exc) { |
||||
$this->SetMsg($exc->getMessage()); |
||||
$jsStartup[] = sprintf("alert('%s');", $this->GetMsg()); |
||||
$this->___GravaLog(); |
||||
} |
||||
|
||||
/* |
||||
* Inclua os scripts necessários aqui. |
||||
*/ |
||||
$jsJQuery[] = "\$('#dataIni').keypress(function(){formataDataHora(this);}) "; |
||||
$jsJQuery[] = "\$('#dataFim').keypress(function(){formataDataHora(this);}) "; |
||||
|
||||
$smarty->assign('filtros', $this->___FiltrosRelatorio()); |
||||
$smarty->assign('conteudo', $conteudoRelatorio); |
||||
$smarty->assign('msg', $this->GetMsg()); |
||||
GetTemplate($smarty, 'relatoriosGrid.tpl'); |
||||
} |
||||
|
||||
} |
||||
return $item; |
||||
} |
||||
|
||||
$agenteAnota = new AgenteAnota($idProg, $dbcon, 0); |
||||
$agenteAnota->ExecutaRelatorio(); |
||||
?> |
||||
|
@ -0,0 +1,453 @@
|
||||
<?php |
||||
|
||||
include "util/Crypt.php"; |
||||
|
||||
|
||||
define("CONF_KEY_LICENCA", md5("S1MPL3S_IP")); |
||||
define("CONF_FILE_PATH", "/var/www/html/aplicativo/cadastros/licenca/"); |
||||
define("CONF_FILE_UUID", 'uuid.lca'); |
||||
|
||||
/** |
||||
* COLETA AS INFORMAÇÕES DO VENDA MAIS E GERA O TOTAL DE LICENCA EM UM ARQUIVO CRIPTOGRAFADO |
||||
* @param type $licenca |
||||
* @param type $perfil |
||||
*/ |
||||
function GerarArquivo($licenca, $perfil) { |
||||
|
||||
$company = [ |
||||
"perfil_aplicacao_id" => $perfil, |
||||
]; |
||||
|
||||
/** ARRAY PARA GUARDAR INFORMACOES DOS CONTRATOS * */ |
||||
$info = [ |
||||
'licenca_pa' => 0, |
||||
'licenca_ramal' => 0, |
||||
'licenca_supervisor' => 0, |
||||
'licenca_discador_preview' => 0, |
||||
'licenca_discador_powerdial' => 0, |
||||
'licenca_discador_predictive' => 0, |
||||
'licenca_pesquisa' => 0, |
||||
'licenca_tarifador' => 0, |
||||
'licenca_whatsapp' => 0, |
||||
'licenca_workflow' => 0, |
||||
'licenca_mesaoperadora' => 0, |
||||
'licenca_mult_channel' => 0, |
||||
'licenca_helpdesk' => 0, |
||||
'licenca_crm' => 0, |
||||
'licenca_manager_one' => 0, |
||||
'licenca_help_custom' => 0, |
||||
'data_registro' => date('Y-m-d'), |
||||
'user_registro' => 0, |
||||
'server_registro' => 0, |
||||
'confirma_registro' => date('Y-m-d') |
||||
]; |
||||
|
||||
$clto_data = ["contrato_assinatura", "contrato_inicio", "contrato_fim"]; |
||||
$data = []; |
||||
$prefix = "clto_"; |
||||
foreach ($licenca as $clto) { |
||||
foreach ($clto as $k => $v) { |
||||
$data[$prefix . $k] = $v; |
||||
if (array_key_exists($k, $company)) { |
||||
$data[$prefix . $k] = $company[$k]; |
||||
} |
||||
|
||||
if (array_key_exists($k, $info) && is_int($v)) { |
||||
$data[$prefix . $k] += $v; |
||||
} |
||||
|
||||
if (in_array($k, $clto_data)) { |
||||
$data[$prefix . $k] = date('Y-d-m', strtotime($v)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
$fileName = $data['clto_razao_social'] . $data['clto_cnpj']; |
||||
$file = criarArquivo($fileName, $data); |
||||
DownloadArquivo($file); |
||||
} |
||||
|
||||
/** |
||||
* GERA UM ARQUIVO COM AS INFORMACOES DA MAQUINA |
||||
* >> CASO PASSE $tmp GERA UM ARQUIVO TEMPORARIO PARA A CONSULTA DO UUID EM TEMPO REAL |
||||
* @param type $tmp |
||||
* @return string |
||||
*/ |
||||
function GerarUUID($tmp = false) { |
||||
$file = CONF_FILE_PATH . ($tmp ? '/tmp/' . md5(date('Y-m-d') . CONF_KEY_LICENCA) . "_" : '') . CONF_FILE_UUID; |
||||
|
||||
if (!file_exists($file) && $tmp) { |
||||
foreach (glob('*_' . CONF_FILE_UUID) as $f) { |
||||
unlink($f); |
||||
} |
||||
} |
||||
|
||||
if (file_exists($file) && $tmp) { |
||||
return $file; |
||||
} |
||||
|
||||
CnvrtFileExec('dmidecode -t system | grep UUID: > ' . $file); |
||||
CnvrtFileExec('chown pbx:pbx ' . $file); |
||||
|
||||
$contents = __readFile($file, false); |
||||
$uid = explode(':', trim($contents)); |
||||
|
||||
__writeFile($file, ['uuid' => trim($uid[1]), 'genereted' => date('Y-m-d H:i:s'), 'contract' => md5(trim($uid[1]))], false); |
||||
|
||||
return $tmp ? $file : trim($uid[1]); |
||||
} |
||||
|
||||
/** |
||||
* CRIA O ARQUIVO DE LICENCA COM O NOME E DOCUMENTO EM MD5 JUNTAMENTE COM AS INFORMACOES GERADAS DA FUNCAO GERAARQUIVO |
||||
* @param type $filename |
||||
* @param array $data |
||||
* @return string |
||||
*/ |
||||
function criarArquivo($filename, $data) { |
||||
$file = CONF_FILE_PATH . md5($filename) . ".lca"; |
||||
$data['clto_data_log'] = $file; |
||||
__createFile($file, preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $data)); |
||||
return $file; |
||||
} |
||||
|
||||
/** |
||||
* INFORMA OS DADOS DE CONTRATO E UUID PARA O ARQUIVO DE LICENCA QUANDO FIZER O UPLOAD NO SITE |
||||
* @param type $file |
||||
* @return boolean |
||||
*/ |
||||
function validarArquivo($file) { |
||||
$file_lca = CONF_FILE_PATH . $file['conf']['name']; |
||||
$tmpFileLocal = $file['conf']['tmp_name']; |
||||
$tmpFileName = $file['conf']['name']; |
||||
move_uploaded_file($tmpFileLocal, $file_lca); |
||||
|
||||
$content = __readFile($file_lca); |
||||
if (explode('.', $tmpFileName)[1] == 'lca') { |
||||
$uuid = GerarUUID(); |
||||
__writeFile($file_lca, ['clto_server_registro' => $uuid, 'clto_contrato_numero' => md5($uuid)]); |
||||
$content = __readFile($file_lca); |
||||
return $content; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
/** |
||||
* DOWNLOAD DO ARQUIVO REGISTRADO NO VENDAMAIS |
||||
* @param type $nomeArquivo |
||||
* @return type |
||||
*/ |
||||
function DownloadArquivo($nomeArquivo) { |
||||
try { |
||||
ob_clean(); |
||||
$nome = basename($nomeArquivo); |
||||
$linhas = file_get_contents($nomeArquivo); |
||||
header("Pragma: public"); |
||||
header('Cache-Control: no-cache, must-revalidate'); |
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
||||
header('Accept-Ranges: bytes'); |
||||
header('Content-Type: ' . GetMimeContentType($nome)); |
||||
header('Content-Disposition: attachment; filename="' . $nome . '";'); |
||||
header('Content-Transfer-Encoding: binary'); |
||||
header('Connection: close'); |
||||
echo $linhas; |
||||
ob_flush(); |
||||
unlink($nomeArquivo); |
||||
exit; |
||||
} catch (Exception $ex) { |
||||
return $ex->getMessage(); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* VALIDA A LICENCA DURANTE O PRIMEIRO LOGIN COM AS INFORMACOES DO ARQUIVO TEMPORARIO| BANCO SIMPLES E ARQUIVO DE LICENCA |
||||
* @param type $dbcon |
||||
* @return boolean |
||||
*/ |
||||
function validarLicenca($dbcon) { |
||||
$db = __getLicencaPBX($dbcon); |
||||
|
||||
if (!$db) { |
||||
return false; |
||||
} |
||||
|
||||
$f = GerarUUID(true); |
||||
if ($f) { |
||||
$uid = __readFile($f); |
||||
} |
||||
|
||||
$content = __readFile($db['clto_data_log']); |
||||
$uuid = __readFile(CONF_FILE_PATH . CONF_FILE_UUID); |
||||
|
||||
if ($content['clto_server_registro'] != $uid['uuid'] || $db['clto_server_registro'] != $uid['uuid']) { |
||||
return false; |
||||
} |
||||
|
||||
if ($uuid['contract'] != $db['clto_contrato_numero']) { |
||||
return false; |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
######################################## |
||||
#### FUNCOES ESCRITA/LEITURA #### |
||||
######################################## |
||||
|
||||
function __createFile($file, $dados) { |
||||
$crypt = new Crypt(CONF_KEY_LICENCA); |
||||
file_put_contents($file, $crypt->encrypt(json_encode($dados, true))); |
||||
} |
||||
|
||||
function __readFile($file, $encrypeted = true) { |
||||
$crypt = new Crypt(CONF_KEY_LICENCA); |
||||
$content = file_get_contents($file); |
||||
|
||||
if ($encrypeted) { |
||||
$content = $crypt->decrypt($content); |
||||
} |
||||
|
||||
$json = json_decode($content, true); |
||||
if ($json) { |
||||
return $json; |
||||
} |
||||
return $content; |
||||
} |
||||
|
||||
function __writeFile($file, $dados = null, $append = true) { |
||||
$crypt = new Crypt(CONF_KEY_LICENCA); |
||||
$content = __readFile($file); |
||||
if ($dados) { |
||||
if (!$append) { |
||||
file_put_contents($file, $crypt->encrypt(json_encode($dados, true))); |
||||
return; |
||||
} |
||||
foreach ($dados as $k => $v) { |
||||
$content[$k] = $v; |
||||
} |
||||
file_put_contents($file, $crypt->encrypt(json_encode($content, true))); |
||||
return; |
||||
} |
||||
file_put_contents($file, $crypt->encrypt(json_encode($content, true))); |
||||
} |
||||
|
||||
######################################## |
||||
#### BANCO DE DADOS #### |
||||
######################################## |
||||
|
||||
function __getLicencaPBX($dbcon) { |
||||
$query = sprintf("SELECT clto_cnpj, clto_data_log, clto_server_registro, clto_contrato_numero FROM pbx_controle_licenciamento;"); |
||||
$result = pg_query($dbcon, $query); |
||||
$res = pg_fetch_assoc($result); |
||||
return $res; |
||||
} |
||||
|
||||
function __getLicencaVMais($document) { |
||||
$query = sprintf("SELECT clto_cnpj, clto_data_log, clto_server_registro, clto_contrato_numero FROM sip_controle_licenciamento WHERE clto_cnpj = '$document';"); |
||||
$resp = __execSQLServer($query); |
||||
return $resp; |
||||
} |
||||
|
||||
/** |
||||
* INSERE AS INFORMACOES PASSADAS NO ARQUIVO DE LICENCA PARA O BANCO DO SIMPLESIP E VENDA MAIS |
||||
* @param type $dbcon |
||||
* @param type $data |
||||
* @return boolean |
||||
* @throws Exception |
||||
*/ |
||||
function __validLicenca($dbcon, $data) { |
||||
|
||||
if (!$data['clto_cnpj']) { |
||||
throw new Exception("As informações do arquivo está corrompido!"); |
||||
} |
||||
$respbx = __getLicencaPBX($dbcon); |
||||
$resVmais = __getLicencaVMais($data['clto_cnpj']); |
||||
|
||||
$vendamais = $resVmais['clto_cnpj'] == $data['clto_cnpj'] ? 'vendamais' : ''; |
||||
|
||||
if ($respbx['clto_cnpj'] == $data['clto_cnpj'] || $vendamais) { |
||||
__updateLicenca($dbcon, $data, $vendamais); |
||||
return true; |
||||
} |
||||
|
||||
if (__sendLicenca($dbcon, $data)) { |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
function __updateLicenca($dbcon, $data, $t = null) { |
||||
$msql = ConectaMssql(); |
||||
$info = ""; |
||||
foreach ($data as $k => $v) { |
||||
$info .= "$k = '$v',"; |
||||
} |
||||
$set = substr($info, 0, -1); |
||||
$table = ["pbx" => 'pbx_controle_licenciamento', "vendamais" => 'sip_controle_licenciamento']; |
||||
foreach ($table as $k => $v) { |
||||
$query = sprintf("UPDATE $v SET %s WHERE clto_cnpj = '%s';", $set, $data['clto_cnpj']); |
||||
|
||||
if ($k == 'pbx' && (empty($t) || $t == $k)) { |
||||
$result = pg_query($dbcon, $query); |
||||
if (!$result) { |
||||
throw new Exception("Não foi possível atualizar as informações da licença!"); |
||||
} |
||||
} |
||||
|
||||
if ($k == 'vendamais' && (empty($t) || $t == $k)) { |
||||
__execSQLServer($query, false); |
||||
} |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
function __sendLicenca($dbcon, $data) { |
||||
$column = array_keys($data); |
||||
$values = array_values($data); |
||||
$table = ["pbx" => 'pbx_controle_licenciamento', "vendamais" => 'sip_controle_licenciamento']; |
||||
|
||||
foreach ($table as $k => $v) { |
||||
$query = sprintf("INSERT INTO {$v} (%s) VALUES('%s');", implode(',', $column), implode("','", $values)); |
||||
if ($k == 'pbx') { |
||||
if (!pg_query($dbcon, $query)) { |
||||
throw new Exception("Não foi possível inserir as informações da licença no [Simples IP]!"); |
||||
} |
||||
} else { |
||||
__execSQLServer($query, false); |
||||
} |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
function GetPerfilApl() { |
||||
$query = "SELECT * FROM sip_perfil_aplicacao"; |
||||
$resp = __execSQLServer($query); |
||||
return $resp; |
||||
} |
||||
|
||||
function __dadosLicenca($document, $contracts = []) { |
||||
$ctact = implode("','", $contracts); |
||||
$data = date('Y-m-d'); |
||||
$query = "select a.CGC_CPF as cnpj, |
||||
d.Numero as contrato_numero, |
||||
upper(dbo.sip_remove_acentos(RazaoSocial)) razao_social, |
||||
upper(dbo.sip_remove_acentos(Fantasia)) nome_fantasia, |
||||
c.Descricao as atividade_empresa, |
||||
f.Cidade as cidade_empresa, |
||||
f.Uf as uf_empresa, |
||||
b.ContatoId as contato_id, |
||||
upper( dbo.sip_remove_acentos(b.PrimeiroNome)) as contato_nome, |
||||
lower( dbo.sip_remove_acentos(coalesce(b.Email1, b.Email2, Email))) as contato_email, |
||||
coalesce(b.Celular, b.TelefoneComercial, b.TelefoneResidencial, a.Telefone) as contato_fone, |
||||
0 as perfil_aplicacao_id, |
||||
dbo.FormataData(d.DataAssinatura) as contrato_assinatura, |
||||
dbo.FormataData(d.DataInicio) as contrato_inicio, |
||||
dbo.FormataData(d.DataFim) as contrato_fim, |
||||
isnull(( |
||||
select sum( ContratosItens.Quantidade) |
||||
from ContratosItens |
||||
inner join Produtos on Produtos.ProdutoId = ContratosItens.ProdutoId |
||||
inner join Linhas on Linhas.LinhaId = Produtos.LinhaId and Linhas.LinhaId = 32 |
||||
inner join Divisoes on Divisoes.DivisaoId = Linhas.DivisaoId and Divisoes.DivisaoId = 11 |
||||
where ContratosItens.ContratoId = d.ContratoId |
||||
and Produtos.Referencia like '%AG-P%(%PA)%' OR Produtos.Referencia like '%ISP-P%(%PA)%' OR Produtos.Referencia like '%SX-P%(%PA)%' OR Produtos.Referencia like '%SMT-P%(%PA)%' |
||||
),0) as licenca_pa, |
||||
isnull(( |
||||
select sum( ContratosItens.Quantidade) |
||||
from ContratosItens |
||||
inner join Produtos on Produtos.ProdutoId = ContratosItens.ProdutoId |
||||
inner join Linhas on Linhas.LinhaId = Produtos.LinhaId and Linhas.LinhaId = 32 |
||||
inner join Divisoes on Divisoes.DivisaoId = Linhas.DivisaoId and Divisoes.DivisaoId = 11 |
||||
where ContratosItens.ContratoId = d.ContratoId |
||||
and Produtos.Referencia like '%AG-R%(%RAMAL)%' OR Produtos.Referencia like '%ISP-R%(%RAMAL)%' OR Produtos.Referencia like '%SX-R%(%RAMAL)%' OR Produtos.Referencia like '%SMT-R%(%RAMAL)%'), 0) as licenca_ramal, |
||||
isnull ((select sum( ContratosItens.Quantidade) |
||||
from ContratosItens |
||||
inner join Produtos on Produtos.ProdutoId = ContratosItens.ProdutoId |
||||
inner join Linhas on Linhas.LinhaId = Produtos.LinhaId and Linhas.LinhaId = 32 |
||||
inner join Divisoes on Divisoes.DivisaoId = Linhas.DivisaoId and Divisoes.DivisaoId = 11 |
||||
where ContratosItens.ContratoId = d.ContratoId |
||||
and Produtos.Referencia like '%LICENCA DE SUPERVISOR%'), 0) as licenca_supervisor, |
||||
0 as licenca_discador_preview, |
||||
0 as licenca_discador_powerdial, |
||||
0 as licenca_discador_predictive, |
||||
0 as licenca_pesquisa, |
||||
0 as licenca_tarifador, |
||||
0 as licenca_whatsapp, |
||||
0 as licenca_workflow, |
||||
0 as licenca_mesaoperadora, |
||||
0 as mult_channel, |
||||
0 as licenca_helpdesk, |
||||
0 as licenca_crm, |
||||
0 as licenca_manager_one, |
||||
0 as licenca_help_custom, |
||||
'$data' as data_registro, |
||||
0 as user_registro, |
||||
0 as server_registro, |
||||
'$data' as confirma_registro |
||||
from Clientes a |
||||
inner join Contatos b on b.ClienteId = a.ClienteId |
||||
inner join RamosDeAtividade c on c.RamoDeAtividadeId = a.RamoDeAtividadeId |
||||
inner join Contratos d on d.ClienteId = a.ClienteId |
||||
inner join ClientesEnderecos f on f.ClienteId = a.ClienteId and f.TipoDeEnderecoId = (select min(TipoDeEnderecoId) from ClientesEnderecos where ClienteId = a.ClienteId) |
||||
where a.AtivoCliente = 1 |
||||
and b.ContatoPrincipal = 1 |
||||
and d.status = 1 |
||||
and a.CGC_CPF = '$document' |
||||
and d.Numero in('$ctact') |
||||
group by a.ClienteId, |
||||
d.ContratoId, |
||||
d.Numero, |
||||
b.ContatoId, |
||||
a.CGC_CPF, |
||||
upper(dbo.sip_remove_acentos(a.RazaoSocial)), |
||||
upper(dbo.sip_remove_acentos(a.Fantasia)), |
||||
c.Descricao, |
||||
dbo.FormataData(d.DataAssinatura), |
||||
dbo.FormataData(d.DataInicio), |
||||
dbo.FormataData(d.DataFim), |
||||
f.Cidade, |
||||
f.Uf, |
||||
dbo.NumToText(isnull(d.ValorMensal,0)), |
||||
upper( dbo.sip_remove_acentos(b.PrimeiroNome)), |
||||
coalesce(b.Celular, |
||||
b.TelefoneComercial, |
||||
b.TelefoneResidencial, a.Telefone), |
||||
lower(dbo.sip_remove_acentos(coalesce(b.Email1, b.Email2, Email)));"; |
||||
|
||||
$resp = __execSQLServer($query); |
||||
return $resp; |
||||
} |
||||
|
||||
######################################## |
||||
#### CONEXÃO VENDA+ #### |
||||
######################################## |
||||
|
||||
/** |
||||
* Realiza conexao com o banco do venda+ |
||||
* @return type |
||||
*/ |
||||
function ConectaMssql() { |
||||
$dbhost = "vendas.simplesip.com.br"; |
||||
$dbname = "VendaMaisDB_simplesip"; |
||||
$user = "sa"; |
||||
$passwd = "SimpleS_root"; |
||||
$conn = mssql_connect($dbhost, $user, $passwd); |
||||
mssql_select_db($dbname); |
||||
|
||||
return $conn; |
||||
} |
||||
|
||||
function __execSQLServer($query, $return = true) { |
||||
$msql = ConectaMssql(); |
||||
$result = mssql_query($query, $msql); |
||||
|
||||
if ($return) { |
||||
$resp = []; |
||||
while ($data = mssql_fetch_array($result)) { |
||||
$resp[] = $data; |
||||
} |
||||
} |
||||
|
||||
mssql_close($msql); |
||||
return $resp ? $resp : $result; |
||||
} |
||||
|
@ -1 +1,43 @@
|
||||
ALTER TABLE pbx_queues_grupos ADD COLUMN libera_pausa VARCHAR(255) DEFAULT(0); |
||||
ALTER TABLE pbx_usuarios ADD COLUMN perm_licenca INT DEFAULT(0); |
||||
|
||||
CREATE TABLE pbx_controle_licenciamento( |
||||
clto_cnpj varchar(14) not null, |
||||
clto_contrato_numero varchar(32) not null, |
||||
clto_razao_social varchar(128) not null, |
||||
clto_nome_fantasia varchar(128), |
||||
clto_atividade_empresa varchar(64), |
||||
clto_cidade_empresa varchar(64), |
||||
clto_uf_empresa varchar(2), |
||||
clto_contato_id varchar(64), |
||||
clto_contato_nome varchar(64), |
||||
clto_contato_email varchar(64), |
||||
clto_contato_fone varchar(32), |
||||
clto_perfil_aplicacao_id int not null, |
||||
clto_contrato_assinatura date, |
||||
clto_contrato_inicio date, |
||||
clto_contrato_fim date, |
||||
clto_licenca_pa int not null default 0, |
||||
clto_licenca_ramal int not null default 0, |
||||
clto_licenca_supervisor int not null default 0, |
||||
clto_licenca_discador_preview int not null default 0, |
||||
clto_licenca_discador_powerdial int not null default 0, |
||||
clto_licenca_discador_predictive int not null default 0, |
||||
clto_licenca_pesquisa int not null default 0, |
||||
clto_licenca_tarifador int not null default 0, |
||||
clto_licenca_whatsapp int not null default 0, |
||||
clto_licenca_workflow int not null default 0, |
||||
clto_licenca_mesaoperadora int not null default 0, |
||||
clto_mult_channel int not null default 0, |
||||
clto_licenca_helpdesk int not null default 0, |
||||
clto_licenca_crm int not null default 0, |
||||
clto_licenca_manager_one int not null default 0, |
||||
clto_licenca_help_custom int not null default 0, |
||||
clto_licenca_chat int not null default 0, |
||||
clto_data_registro date not null, |
||||
clto_user_registro varchar(64), |
||||
clto_server_registro varchar(255), |
||||
clto_confirma_registro date, |
||||
clto_data_log varchar(1024), |
||||
constraint "pkPbxControleLicenciamento" primary key(clto_cnpj, clto_contrato_numero) |
||||
); |
@ -0,0 +1,114 @@
|
||||
{capture name="subDisplay"} |
||||
{if !$perm} |
||||
<table align="center" width="70%" class="formCad" style="margin-top: 10px"> |
||||
<tr> |
||||
<th colspan="2"> |
||||
Insira o arquivo de Licença |
||||
</th> |
||||
</tr> |
||||
<tr> |
||||
<th> |
||||
Arquivo de Licença |
||||
</th> |
||||
<td> |
||||
<input name="conf" type="file" value="conflicence" > |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td colspan="2"> |
||||
<b>* Informe o arquivo .lca para registrar as configurações da Central!</b> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td> |
||||
<table width="100%" class="formCad" border="0" cellspacing="0" cellpadding="2"> |
||||
<tbody> |
||||
<tr> |
||||
<td> |
||||
<input name="btValidar" type="submit" id="btValidar" value="Validar"> |
||||
</td> |
||||
</tr> |
||||
</tbody> |
||||
</table> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
{else} |
||||
<table width="100%" class="formCad" id="configlicence" border="0" cellspacing="0" cellpadding="2"> |
||||
<tr> |
||||
<td> |
||||
<table width="80%" class="formCad" border="0" cellspacing="0" cellpadding="2" id="tablelca"> |
||||
<tbody> |
||||
<tr> |
||||
<th align="left">Documento CNPJ:</th> |
||||
<td> |
||||
<input name="document" type="text" id="lca_document" value="{$document}" size="50" maxlength="255"> |
||||
</td> |
||||
</tr> |
||||
|
||||
<tr> |
||||
<th align="left">Perfil Central:</th> |
||||
<td> |
||||
<select name="lcnca_perfil" style="width:400px;"> |
||||
{$select_perfil} |
||||
</select> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<th align="left">Nº Contrato 1:</th> |
||||
<td> |
||||
<input name="lcnca_contato1" type="text" id="contrato1" value="{$lcnca_contato1}" size="50" maxlength="255" title=""> |
||||
<a id="addcontract" href="#" title="Adicionar mais um campo para informar o contrato"> |
||||
<img src="images/novo.gif" width="20" height="20" border="0" align="absmiddle" title=""> |
||||
</a> |
||||
</td> |
||||
</tr> |
||||
</tbody> |
||||
</table> |
||||
</td> |
||||
</tr> |
||||
|
||||
<tr> |
||||
<td> |
||||
<table width="100%" class="formCad" border="0" cellspacing="0" cellpadding="2"> |
||||
<tbody> |
||||
<tr> |
||||
<td> |
||||
<input name="btGerar" type="submit" id="btGerar" value="Gerar"> |
||||
</td> |
||||
</tr> |
||||
</tbody> |
||||
</table> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
{/if} |
||||
|
||||
{if $mensagem} |
||||
<table align="center" width="70%" class="formCad" style="margin-top: 10px"> |
||||
<tr> |
||||
<td colspan="2"> |
||||
<div class="alert alert-{$mensagem.type}">{$mensagem.msg}</div> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
{/if} |
||||
|
||||
{literal} |
||||
<script> |
||||
$(function () { |
||||
let cont = 2; |
||||
$("#addcontract").on('click', function () { |
||||
$("#tablelca").append(` |
||||
<tr> |
||||
<th align="left">Nº Contrato ${cont}:</th> |
||||
<td> |
||||
<input name="lcnca_contato${cont}" type="text" id="lcnca_contato${cont}" size="50" maxlength="255" title=""> |
||||
</td> |
||||
</tr>`); |
||||
cont++; |
||||
}) |
||||
}) |
||||
</script> |
||||
{/literal} |
||||
{/capture} |
Loading…
Reference in new issue