agenda_admin_cad.php
10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<?php
$desvio_diretorio = "";
require_once ("include/clsBase.inc.php");
require_once ("include/clsCadastro.inc.php");
require_once ("include/clsBanco.inc.php");
class clsIndex extends clsBase
{
function Formular()
{
$this->SetTitulo( "{$this->_instituicao} Agenda" );
$this->processoAp = "343";
}
}
class indice extends clsCadastro
{
var $cod_agenda,
$ref_ref_cod_pessoa_exc,
$ref_ref_cod_pessoa_cad,
$nm_agenda,
$publica,
$envia_alerta,
$data_cad,
$data_edicao,
$ref_ref_cod_pessoa_own,
$dono,
$editar;
function Inicializar()
{
$retorno = "Novo";
$this->editar = false;
if ( isset( $_GET['cod_agenda'] ) )
{
$this->cod_agenda = $_GET['cod_agenda'];
$db = new clsBanco();
$db->Consulta( "SELECT cod_agenda, ref_ref_cod_pessoa_exc, ref_ref_cod_pessoa_cad, nm_agenda, publica, envia_alerta, data_cad, data_edicao, ref_ref_cod_pessoa_own FROM portal.agenda WHERE cod_agenda='{$this->cod_agenda}'" );
if ($db->ProximoRegistro())
{
list( $this->cod_agenda, $this->ref_ref_cod_pessoa_exc, $this->ref_ref_cod_pessoa_cad, $this->nm_agenda, $this->publica, $this->envia_alerta, $this->data_cad, $this->data_edicao, $this->ref_ref_cod_pessoa_own ) = $db->Tupla();
$this->fexcluir = true;
$retorno = "Editar";
$this->editar = true;
}
if( isset( $_GET["edit_rem"] ) && is_numeric( $_GET["edit_rem"] ) )
{
$db->Consulta( "DELETE FROM portal.agenda_responsavel WHERE ref_ref_cod_pessoa_fj = '{$_GET["edit_rem"]}' AND ref_cod_agenda = '{$this->cod_agenda}'" );
$this->mensagem = "Editor removido";
}
if( isset( $_POST["novo_editor"] ) && is_numeric( $_POST["novo_editor"] ) )
{
$db->Consulta( "SELECT 1 FROM portal.agenda_responsavel WHERE ref_ref_cod_pessoa_fj = '{$_POST["novo_editor"]}' AND ref_cod_agenda = '{$this->cod_agenda}'" );
if( ! $db->ProximoRegistro() )
{
$db->Consulta( "SELECT 1 FROM agenda WHERE ref_ref_cod_pessoa_own = '{$_POST["novo_editor"]}' AND cod_agenda = '{$this->cod_agenda}'" );
if( ! $db->ProximoRegistro() )
{
$db->Consulta( "INSERT INTO agenda_responsavel ( ref_ref_cod_pessoa_fj, ref_cod_agenda ) VALUES ( '{$_POST["novo_editor"]}', '{$this->cod_agenda}' )" );
}
else
{
$this->mensagem = "O dono da agenda já é considerado um editor da mesma.";
}
}
else
{
$this->mensagem = "Este editor já está cadastrado";
}
}
}
if( $retorno == "Editar" )
{
$this->url_cancelar = "agenda_admin_det.php?cod_agenda={$this->cod_agenda}";
}
else
{
$this->url_cancelar = "agenda_admin_lst.php";
}
$this->nome_url_cancelar = "Cancelar";
$nomeMenu = $retorno == "Editar" ? $retorno : "Cadastrar";
$localizacao = new LocalizacaoSistema();
$localizacao->entradaCaminhos( array(
$_SERVER['SERVER_NAME']."/intranet" => "Início",
"" => "$nomeMenu agenda"
));
$this->enviaLocalizacao($localizacao->montar());
return $retorno;
}
function Gerar()
{
$db = new clsBanco();
$objPessoa = new clsPessoaFisica();
$this->campoOculto( "pessoaFj", $this->pessoaFj );
$this->campoOculto( "cod_agenda", $this->cod_agenda );
$this->campoTexto( "nm_agenda", "Nome da Agenda", $this->nm_agenda, 50, 50 );
$this->campoLista( "publica", "Pública", array( "Não", "Sim" ), $this->publica );
$this->campoLista( "envia_alerta", "Envia Alerta", array( "Não", "Sim" ), $this->envia_alerta );
$i = 0;
if( $this->ref_ref_cod_pessoa_own )
{
list( $nome ) = $objPessoa->queryRapida( $this->ref_ref_cod_pessoa_own, "nome" );
$this->campoTextoInv( "editor{$i}", "Editores", $nome, 50, 255 );
}
$lista = array( "Pesquise a pessoa clicando no botao ao lado" );
if ($this->cod_agenda)
{
$db->Consulta( "SELECT ref_ref_cod_pessoa_fj FROM portal.agenda_responsavel WHERE ref_cod_agenda = '{$this->cod_agenda}'" );
while ( $db->ProximoRegistro() )
{
$i++;
list( $idpes ) = $db->Tupla();
list( $nome ) = $objPessoa->queryRapida( $idpes, "nome" );
$this->campoTextoInv( "editor{$i}", "Editores", $nome, 50, 255, false, false, false, false, "<a href=\"agenda_admin_cad.php?cod_agenda={$this->cod_agenda}&edit_rem=$idpes\">remover</a>" );
}
//$this->campoListaPesq( "novo_editor", "Novo Editor", $lista, 0, "pesquisa_funcionario.php", false, false, false, " <a href=\"javascript:var idpes = document.getElementById('novo_editor').value; if( idpes != 0 ) { document.location.href='agenda_admin_cad.php?cod_agenda={$this->cod_agenda}&edit_add=' + idpes; } else { alert( 'Selecione a pessoa clicando na imagem da Lupa' ); }\">Adicionar</a>" );
$parametros = new clsParametrosPesquisas();
$parametros->setSubmit( 1 );
$parametros->adicionaCampoSelect( "novo_editor", "ref_cod_pessoa_fj", "nome" );
$this->campoListaPesq( "novo_editor", "Novo Editor", $lista, 0, "pesquisa_funcionario_lst.php", "", false, "", "", null, null, "", false, $parametros->serializaCampos() );
//$this->campoLista( "edit_add", "Editores", $lista, "", "", false, "", "<img id='lupa' src=\"imagens/lupa.png\" border=\"0\" onclick=\"showExpansivel( 500,500, '<iframe name=\'miolo\' id=\'miolo\' frameborder=\'0\' height=\'100%\' width=\'500\' marginheight=\'0\' marginwidth=\'0\' src=\'pesquisa_funcionario_lst.php?campos=$serializedcampos\'></iframe>' );\">", false, true );
unset( $campos );
}
else
{
//$this->campoListaPesq( "dono", "Dono da agenda", $lista, 0, "pesquisa_funcionario.php" );
$parametros = new clsParametrosPesquisas();
$parametros->setSubmit( 0 );
$parametros->adicionaCampoSelect( "dono", "ref_cod_pessoa_fj", "nome" );
$this->campoListaPesq( "dono", "Dono da agenda", $lista, 0, "pesquisa_funcionario_lst.php", "", false, "", "", null, null, "", false, $parametros->serializaCampos() );
//$this->campoLista( "dono", "Dono da agenda", $lista, "", "", false, "", "<img id='lupa' src=\"imagens/lupa.png\" border=\"0\" onclick=\"showExpansivel( 500,500, '<iframe name=\'miolo\' id=\'miolo\' frameborder=\'0\' height=\'100%\' width=\'500\' marginheight=\'0\' marginwidth=\'0\' src=\'pesquisa_funcionario_lst.php?campos=$serializedcampos\'></iframe>' );\">", false, true );
}
}
function Novo()
{
$campos = "";
$values = "";
$db = new clsBanco();
if($this->nm_agenda)
{
if( is_string( $this->nm_agencia ) )
{
$campos .= ", nm_agencia";
$values .= ", '{$this->nm_agencia}'";
}
if( is_numeric( $this->dono ) )
{
if( $this->dono )
{
$campos .= ", ref_ref_cod_pessoa_own";
$values .= ", '{$this->dono}'";
}
else
{
$campos .= ", ref_ref_cod_pessoa_own";
$values .= ", NULL";
}
}
if( is_numeric( $this->publica ) )
{
$campos .= ", publica";
$values .= ", '{$this->publica}'";
}
if( is_numeric( $this->envia_alerta ) )
{
$campos .= ", envia_alerta";
$values .= ", '{$this->envia_alerta}'";
}
$db->Consulta( "INSERT INTO portal.agenda( ref_ref_cod_pessoa_cad, data_cad, nm_agenda $campos) VALUES( '{$this->pessoa_logada}', NOW(), '{$this->nm_agenda}' $values)" );
$id_agenda = $db->insertId( "portal.agenda_cod_agenda_seq" );
$db->Consulta( "INSERT INTO portal.agenda_responsavel( ref_ref_cod_pessoa_fj, ref_cod_agenda ) VALUES( '{$this->pessoa_logada}', '{$id_agenda}' )" );
$this->simpleRedirect('agenda_admin_lst.php');
}
else
{
return false;
}
}
function Editar()
{
$set = "";
$db = new clsBanco();
if( is_numeric( $this->cod_agenda ) )
{
if( is_string( $this->nm_agenda ) )
{
$set .= ", nm_agenda = '{$this->nm_agenda}'";
}
if( is_numeric( $this->publica ) )
{
$set .= ", publica = '{$this->publica}'";
}
if( is_numeric( $this->envia_alerta ) )
{
$set .= ", envia_alerta = '{$this->envia_alerta}'";
}
$db->Consulta( "UPDATE portal.agenda SET ref_ref_cod_pessoa_exc = '{$this->pessoa_logada}', data_edicao = NOW() $set WHERE cod_agenda = '{$this->cod_agenda}'" );
$this->simpleRedirect('agenda_admin_lst.php');
}
else
{
$this->mensagem = "Codigo de Diaria invalido!";
return false;
}
return true;
}
function Excluir()
{
if( is_numeric( $this->cod_agenda ) )
{
$db = new clsBanco();
$db->Consulta( "DELETE FROM portal.agenda_compromisso WHERE ref_cod_agenda={$this->cod_agenda}" );
$db->Consulta( "DELETE FROM portal.agenda_responsavel WHERE ref_cod_agenda={$this->cod_agenda}" );
$db->Consulta( "DELETE FROM portal.agenda WHERE cod_agenda={$this->cod_agenda}" );
$this->simpleRedirect('agenda_admin_lst.php');
}
$this->mensagem = "Codigo da Agenda inválido!";
return false;
}
}
$pagina = new clsIndex();
$miolo = new indice();
$pagina->addForm( $miolo );
$pagina->MakeAll();
?>