acoes_acao_cad.php
12.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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
<?php
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @author Prefeitura Municipal de Itajaí *
* @updated 29/03/2007 *
* Pacote: i-PLB Software Público Livre e Brasileiro *
* *
* Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí *
* ctima@itajai.sc.gov.br *
* *
* Este programa é software livre, você pode redistribuí-lo e/ou *
* modificá-lo sob os termos da Licença Pública Geral GNU, conforme *
* publicada pela Free Software Foundation, tanto a versão 2 da *
* Licença como (a seu critério) qualquer versão mais nova. *
* *
* Este programa é distribuído na expectativa de ser útil, mas SEM *
* QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- *
* ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- *
* sulte a Licença Pública Geral GNU para obter mais detalhes. *
* *
* Você deve ter recebido uma cópia da Licença Pública Geral GNU *
* junto com este programa. Se não, escreva para a Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA *
* 02111-1307, USA. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
$desvio_diretorio = "";
require_once ("include/clsBase.inc.php");
require_once ("include/clsCadastro.inc.php");
require_once ("include/pmiacoes/geral.inc.php");
require_once( "include/Geral.inc.php" );
class clsIndex extends clsBase
{
function Formular()
{
$this->SetTitulo( "{$this->_instituicao} Sistema de Cadastro de A��es do Governo - Cadastro de ações do Governo" );
$this->processoAp = "551";
}
}
class indice extends clsCadastro
{
var $pessoa_logada;
var $cod_acao_governo;
var $nm_acao;
var $descricao;
var $data_inauguracao;
var $valor;
var $destaque;
var $categorias = array();
var $categoria;
var $idbai;
var $fotos_portal = array();
var $noticias = array();
var $nm_arquivo = array();
var $secretarias = array();
var $nm_fotos = array();
var $arquivos = array();
var $fotos = array();
var $data_fotos = array();
//edicao
var $edit_categorias = array();
var $edit_fotos_portal = array();
var $edit_noticias = array();
var $edit_nm_arquivo = array();
var $edit_secretarias = array();
//var $edit_nm_fotos = array();
var $edit_arquivos = array();
//var $edit_nm_arquivos = array();
var $edit_fotos = array();
var $edit_data_fotos = array();
var $edit_nm_fotos = array();
var $valida = "acao();";
function Inicializar()
{
$retorno = "Novo";
@session_start();
$this->pessoa_logada = $_SESSION['id_pessoa'];
@session_write_close();
$this->cod_acao_governo = $_GET['cod_acao_governo'];
$obj = new clsPmiacoesAcaoGoverno($this->cod_acao_governo,null,null,null,null,null,null,null,null,null,1);
$detalhe = $obj->detalhe();
if(!$detalhe && $this->cod_acao_governo)
header("location: acoes_acao_lst.php");
if($detalhe)
{
$this->nm_acao = $detalhe['nm_acao'];
$this->descricao = $detalhe['descricao'];
$this->numero = $detalhe['numero'];
$this->categoria = $detalhe['categoria'];
$this->data_inauguracao = $detalhe['data_inauguracao'];
$this->idbai = $detalhe['idbai'];
$this->valor = $detalhe['valor'];
$this->destaque = $detalhe['destaque'];
$this->fexcluir = true;
$retorno = "Editar";
$obj_funcionario = new clsFuncionario($this->pessoa_logada);
$detalhe_func = $obj_funcionario->detalhe();
$setor_funcionario = $detalhe_func["ref_cod_setor_new"];
//*
$obj = new clsSetor();
$setor_pai = array_shift(array_reverse($obj->getNiveis($setor_funcionario)));
//*
$obj_secretaria_responsavel = new clsPmiacoesSecretariaResponsavel($setor_pai);
$obj_secretaria_responsavel_det = $obj_secretaria_responsavel->detalhe();
if($obj_secretaria_responsavel_det == false && $detalhe["status_acao"] == 1)
header("location: acoes_acao_lst.php");
}
$this->url_cancelar = ($retorno == "Editar") ? "acoes_acao_det.php?cod_acao_governo={$this->cod_acao_governo}" : "acoes_acao_lst.php";
$this->nome_url_cancelar = "Cancelar";
$this->acao_enviar =$this->valida;
return $retorno;
}
function Gerar()
{
@session_start();
$this->pessoa_logada = $_SESSION['id_pessoa'];
@session_write_close();
$this->form_enctype = " enctype='multipart/form-data'";
$this->cod_acao_governo ? $this->campoOculto("cod_acao_governo",$this->cod_acao_governo) : null;
$this->campoTexto( "nm_acao", "Nome da ação", $this->nm_acao, 30, 255, true );
$this->campoMemo( "descricao", "Descrição", $this->descricao,100,5,false);
$this->campoData( "data_inauguracao", "Data da inauguração", dataToBrasil($this->data_inauguracao),false);
$this->campoMonetario( "valor", "Valor",$this->valor,10,16,false);
$this->campoRadio("categoria", "Categoria", array("Obras", "Ações"), $this->categoria);
$objBairo = new clsBairro();
$listaBai['0'] = "Selecione";
$listaBairro = $objBairo->lista(8507);
if($listaBairro)
{
foreach ($listaBairro as $valores)
{
$listaBai[$valores['idbai']] = $valores['nome'] ;
}
}
$this->campoLista("idbai", "Bairro", $listaBai, $this->idbai);
//*
/* $obj_funcionario = new clsFuncionario($this->pessoa_logada);
$detalhe_func = $obj_funcionario->detalhe();
$setor_funcionario = $detalhe_func["ref_cod_setor_new"];
$obj = new clsSetor();
$setor_pai = array_shift(array_reverse($obj->getNiveis($setor_funcionario)));*/
//$isSecom = $setor_pai == 4327 ? true : false;
//*
/*if($isSecom)
$this->campoCheck("destaque","Destaque",$this->destaque, "Marcar como destaque");
else
$this->campoOculto("destaque","0");
*/
}
function Novo()
{
@session_start();
$this->pessoa_logada = $_SESSION['id_pessoa'];
@session_write_close();
/*$obj_funcionario = new clsFuncionario($this->pessoa_logada);
$detalhe_func = $obj_funcionario->detalhe();
$setor_funcionario = $detalhe_func["ref_cod_setor_new"];
//*
$obj = new clsSetor();
$setor_pai = array_shift(array_reverse($obj->getNiveis($setor_funcionario)));
//
$obj_secretaria_responsavel = new clsPmiacoesSecretariaResponsavel($setor_funcionario);
$obj_secretaria_responsavel_det = $obj_secretaria_responsavel->detalhe();
*/
//if($obj_secretaria_responsavel_det == false)
if(!$this->permiteEditar())
$pendente = 0;
else
$pendente = 1;
$this->destaque = $this->destaque == "on" ? 1 : 0;
$obj_acao_governo = new clsPmiacoesAcaoGoverno(null,null,$this->pessoa_logada,$this->nm_acao,$this->descricao,$this->data_inauguracao,str_replace(array(".",","),array("","."),$this->valor),$this->destaque,$pendente,1,null, $this->categoria, $this->idbai);
if(! $cod_acao_governo = $obj_acao_governo->cadastra())
return false;
header("location: acoes_acao_det.php?cod_acao_governo={$cod_acao_governo}");
return false;
}
function Editar()
{
@session_start();
$this->pessoa_logada = $_SESSION['id_pessoa'];
@session_write_close();
/*$obj_funcionario = new clsFuncionario($this->pessoa_logada);
$detalhe_func = $obj_funcionario->detalhe();
$setor_funcionario = $detalhe_func["ref_cod_setor_new"];
$obj_secretaria_responsavel = new clsPmiacoesSecretariaResponsavel($setor_funcionario);
$obj_secretaria_responsavel_det = $obj_secretaria_responsavel->detalhe();*/
//if($obj_secretaria_responsavel_det == false)
if(!$this->permiteEditar())
$pendente = 0;
else
$pendente = 1;
//$this->destaque = $this->destaque == "on" ? 1 : 0;
$obj_acao_governo = new clsPmiacoesAcaoGoverno($this->cod_acao_governo,null,$this->pessoa_logada,$this->nm_acao,$this->descricao,dataToBanco($this->data_inauguracao),str_replace(array(".",","),array("","."),$this->valor),null,$pendente,null,null, $this->categoria, $this->idbai);
if(!$obj_acao_governo->edita())
return false;
header("location: acoes_acao_det.php?cod_acao_governo={$this->cod_acao_governo}");
return false;
}
function Excluir()
{
@session_start();
$this->pessoa_logada = $_SESSION['id_pessoa'];
@session_write_close();
/* $obj_funcionario = new clsFuncionario($this->pessoa_logada);
$detalhe_func = $obj_funcionario->detalhe();
$setor_funcionario = $detalhe_func["ref_cod_setor_new"];
$obj_secretaria_responsavel = new clsPmiacoesSecretariaResponsavel($setor_funcionario);
$obj_secretaria_responsavel_det = $obj_secretaria_responsavel->detalhe();
if($obj_secretaria_responsavel_det == false)
header("Location: acoes_acao_lst.php");
*/
$obj_acao = new clsPmiacoesAcaoGoverno($this->cod_acao_governo);
if(!$obj_acao->excluir())
return false;
header("Location: acoes_acao_lst.php");
return true;
}
function permiteEditar()
{
$retorno = false;
$obj_funcionario = new clsFuncionario($this->pessoa_logada);
$detalhe_func = $obj_funcionario->detalhe();
$setor_funcionario = $detalhe_func["ref_cod_setor_new"];
//*
$obj = new clsSetor();
$setor_pai = array_shift(array_reverse($obj->getNiveis($setor_funcionario)));
//*
$obj_secretaria_responsavel = new clsPmiacoesSecretariaResponsavel($setor_pai);
$obj_secretaria_responsavel_det = $obj_secretaria_responsavel->detalhe();
$obj_acao = new clsPmiacoesAcaoGoverno($this->cod_acao_governo);
$obj_acao_det = $obj_acao->detalhe();
$status = $obj_acao_det["status_acao"];
//**
$func_cad = $obj_acao_det["ref_funcionario_cad"];
$obj_funcionario = new clsFuncionario($func_cad);
$detalhe_func = $obj_funcionario->detalhe();
$setor_cad = $detalhe_func["ref_cod_setor_new"];
$setor_cad = array_shift(array_reverse($obj->getNiveis($setor_cad)));
//**
// $isSecom = $setor_pai == 4327 ? true : false;
$retorno = ($obj_secretaria_responsavel_det != false )? true : false;
return $retorno;
}
}
$pagina = new clsIndex();
$miolo = new indice();
$pagina->addForm( $miolo );
$pagina->MakeAll();
?>
<script>
function chama_expansivel(pagina,campo)
{
var numero = /([0-9])+$/.exec(campo)[0];
var parametros = "";
var and = "";
for(var ct = 2 ; ct <arguments.length ; ct++){
parametros += and + "campo" + (ct - 1) + "=" + arguments[ct] + numero ;
and = "&";
}
showExpansivel( 500,450, "<iframe name='miolo' id='miolo' frameborder='0' height='100%' width='500' marginheight='0' marginwidth='0' src='" + pagina + ".php?" + parametros + "'></iframe>");
}
function valida(){
//var categoria = arguments[0];
var acao = document.getElementById("tipoacao").value;
if(acao.toLowerCase() == "novo"){
var tt = "contCategorias";
for(var ct1 = 0 ;ct1 < eval(tt) ;ct1++){
var temp = ("" + "Categorias" + ct1 + "").toLowerCase();
if((window.parent.document.getElementById(temp) && window.parent.document.getElementById(temp).value) ||
(window.parent.document.getElementById(temp) && window.parent.document.getElementById(temp).text)){
achou = true;
}
}
if(achou == false){
alert('Preencha o campo ' + arguments[ct].replace("_"," ") + " corretamente!");
return;
}
}else{ //editar
//var tt = "edit_categorias[4]";
var hidden_elements = document.getElementsByTagName('input');
var achou = false;
for(var ct1 = 0 ;ct1 < hidden_elements.length ;ct1++){
if(hidden_elements[ct1].name.indexOf('edit_categorias[') == 0){
achou = true;
break;
}
}
if(achou == false){
var tt = "contCategorias";
for(var ct1 = 0 ;ct1 < eval(tt) ;ct1++){
var temp = ("" + "Categorias" + ct1 + "").toLowerCase();
if((window.parent.document.getElementById(temp) && window.parent.document.getElementById(temp).value) ||
(window.parent.document.getElementById(temp) && window.parent.document.getElementById(temp).text)){
achou = true;
}
}
if(achou == false){
alert("Preencha o campo Categoria corretamente!");
return false;
}
}
}
var tt = "contNovas_Fotos";
for(var ct1 = 0 ;ct1 < eval(tt) ;ct1++){
if(!check("fotos" + ct1))
return false;
}
return true;
}
function check(campo) {
var ext = document.getElementById(campo).value;
if(ext){
ext = ext.substring(ext.length-3,ext.length);
ext = ext.toLowerCase();
if(ext != 'jpg' && ext != 'jpeg' && ext != 'gif' && ext != 'png' && ext != 'bmp') {
alert('Favor selecionar um arquivo de imagem');
var set_focus= document.getElementById(campo);
set_focus.focus();
return false;
}
}
return true;
}
//onload = setFocus();
</script>