Commit 95e6073c5e00edd7f3d1031f6e69e9ff8e01b935

Authored by Eriksen Costa Paixão
1 parent 16bb11c1
Exists in master

Refactoring para coding standards

Showing 1 changed file with 327 additions and 344 deletions   Show diff stats
ieducar/intranet/educar_calendario_pesquisas.php
1 1 <?php
2   -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3   - * *
4   - * @author Prefeitura Municipal de Itajaí *
5   - * @updated 29/03/2007 *
6   - * Pacote: i-PLB Software Público Livre e Brasileiro *
7   - * *
8   - * Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí *
9   - * ctima@itajai.sc.gov.br *
10   - * *
11   - * Este programa é software livre, você pode redistribuí-lo e/ou *
12   - * modificá-lo sob os termos da Licença Pública Geral GNU, conforme *
13   - * publicada pela Free Software Foundation, tanto a versão 2 da *
14   - * Licença como (a seu critério) qualquer versão mais nova. *
15   - * *
16   - * Este programa é distribuído na expectativa de ser útil, mas SEM *
17   - * QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- *
18   - * ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- *
19   - * sulte a Licença Pública Geral GNU para obter mais detalhes. *
20   - * *
21   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU *
22   - * junto com este programa. Se não, escreva para a Free Software *
23   - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA *
24   - * 02111-1307, USA. *
25   - * *
26   - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
27   -
28   - $obj_permissoes = new clsPermissoes();
29   - $nivel_usuario = $obj_permissoes->nivel_acesso($this->pessoa_logada);
30   - if($nivel_usuario <=4 && !empty($nivel_usuario)){
31   - $retorno .= '<tr>
32   - <td height="24" colspan="2" class="formdktd">
33   - <span class="form">
34   - <b>Filtros de busca</b>
35   - </span>
36   - </td>
37   - </tr>';
38   -
39   - $retorno .= '<form action="" method="post" id="formcadastro" name="formcadastro">';
40   - if ($obrigatorio)
41   - {
42   - $instituicao_obrigatorio = $escola_obrigatorio = true;
43   - }
44   - else
45   - {
46   - $instituicao_obrigatorio = isset($instituicao_obrigatorio) ? $instituicao_obrigatorio : $obrigatorio;
47   - $escola_obrigatorio = isset($escola_obrigatorio) ? $escola_obrigatorio : $obrigatorio;
48   - }
49   -
50   - if ($desabilitado)
51   - {
52   - $instituicao_desabilitado = $escola_desabilitado = true;
53   - }
54   - else
55   - {
56   - $instituicao_desabilitado = isset($instituicao_desabilitado) ? $instituicao_desabilitado : $desabilitado;
57   - $escola_desabilitado = isset($escola_desabilitado) ? $escola_desabilitado : $desabilitado;
58   - }
59   -
60   - $obj_permissoes = new clsPermissoes();
61   - $nivel_usuario = $obj_permissoes->nivel_acesso($this->pessoa_logada);
62   -
63   - if( $nivel_usuario == 1 )
64   - {
65   - if( class_exists( "clsPmieducarInstituicao" ) )
66   - {
67   - $opcoes = array( "" => "Selecione" );
68   - $obj_instituicao = new clsPmieducarInstituicao();
69   - $obj_instituicao->setCamposLista("cod_instituicao, nm_instituicao");
70   - $obj_instituicao->setOrderby("nm_instituicao ASC");
71   - $lista = $obj_instituicao->lista(null,null,null,null,null,null,null,null,null,null,null,null,null,1);
72   - if ( is_array( $lista ) && count( $lista ) )
73   - {
74   - foreach ( $lista as $registro )
75   - {
76   - $opcoes["{$registro['cod_instituicao']}"] = "{$registro['nm_instituicao']}";
77   - }
78   - }
79   - }
80   - else
81   - {
82   - echo "<!--\nErro\nClasse clsPmieducarInstituicao n&atilde;o encontrada\n-->";
83   - $opcoes = array( "" => "Erro na gera&ccedil;&atilde;o" );
84   - }
85   - if ($get_escola)
86   - {
87   - $retorno .= '<tr id="tr_status">
88   - <td valign="top" class="formlttd">
89   - <span class="form">Institui&ccedil;&atilde;o</span>
90   - <span class="campo_obrigatorio">*</span>
91   - <br/>
92   - <sub style="vertical-align: top;"/>
93   - </td>';
94   - $retorno .= '<td valign="top" class="formlttd"><span class="form">';
95   - $retorno .= "<select onchange=\"habilitaCampos('ref_cod_instituicao');\" class='geral' name='ref_cod_instituicao' id='ref_cod_instituicao'>";
96   -
97   - reset( $opcoes );
98   - while (list( $chave, $texto ) = each($opcoes ))
99   - {
100   - $retorno .= "<option id=\"ref_cod_instituicao_".urlencode($chave)."\" value=\"".urlencode($chave)."\"";
101   -
102   - if( $chave==$this->ref_cod_instituicao)
103   - {
104   - $retorno .= " selected";
105   - }
106   - $retorno .= ">$texto</option>";
107   - }
108   - $retorno .= "</select>";
109   - $retorno .= '</span>
110   - </td>
111   - </tr>';
112   - //$this->campoLista( "ref_cod_instituicao", "Institui&ccedil;&atilde;o", $opcoes, $this->ref_cod_instituicao,"getDuplo();",null,null,null,$instituicao_desabilitado,$instituicao_obrigatorio);
113   - }
114   - }
115   - if ( $nivel_usuario == 2 ) {
116   - if ( $get_instituicao )
117   - {
118   - $obj_per = new clsPermissoes();
119   - $this->ref_cod_instituicao = $obj_per->getInstituicao( $this->pessoa_logada );
120   - $retorno .= "<input type='hidden' id='red_cod_instituicao' value='{$this->ref_cod_instituicao}'>";
121   - // $this->campoOculto( "ref_cod_instituicao", $this->ref_cod_instituicao );
122   - }
123   - }
124   - elseif ( $nivel_usuario != 1 )
125   - {
126   - $obj_usuario = new clsPmieducarUsuario($this->pessoa_logada);
127   - $det_usuario = $obj_usuario->detalhe();
128   - $this->ref_cod_instituicao = $det_usuario["ref_cod_instituicao"];
129   - if ($nivel_usuario == 4 || $nivel_usuario == 8)
130   - {
131   - $obj_usuario = new clsPmieducarUsuario($this->pessoa_logada);
132   - $det_usuario = $obj_usuario->detalhe();
133   - $this->ref_cod_escola = $det_usuario["ref_cod_escola"];
134   -
135   - }
136   - }
137   -
138   - if ($nivel_usuario == 1 || $nivel_usuario == 2)
139   - {
140   - if ($get_escola)
141   - {
142   - if( class_exists( "clsPmieducarEscola" ) )
143   - {
144   - $opcoes_escola = array( "" => "Selecione" );
145   - $todas_escolas = "escola = new Array();\n";
146   - $obj_escola = new clsPmieducarEscola();
147   - $lista = $obj_escola->lista(null,null,null,null,null,null,null,null,null,null,1);
148   - if ( is_array( $lista ) && count( $lista ) )
149   - {
150   - foreach ( $lista as $registro )
151   - {
152   - $todas_escolas .= "escola[escola.length] = new Array( {$registro["cod_escola"]}, '{$registro['nome']}', {$registro["ref_cod_instituicao"]} );\n";
153   - }
154   - }
155   - echo "<script>{$todas_escolas}</script>";
156   - }
157   - else
158   - {
159   - echo "<!--\nErro\nClasse clsPmieducarEscola n&atilde;o encontrada\n-->";
160   - $opcoes_escola = array( "" => "Erro na gera&ccedil;&atilde;o" );
161   - }
162   - if ($this->ref_cod_instituicao)
163   - {
164   - if( class_exists( "clsPmieducarEscola" ) )
165   - {
166   - $opcoes_escola = array( "" => "Selecione" );
167   - $obj_escola = new clsPmieducarEscola();
168   - $lista = $obj_escola->lista(null,null,null,$this->ref_cod_instituicao,null,null,null,null,null,null,1);
169   - if ( is_array( $lista ) && count( $lista ) )
170   - {
171   - foreach ( $lista as $registro )
172   - {
173   - $opcoes_escola["{$registro["cod_escola"]}"] = "{$registro['nome']}";
174   - }
175   - }
176   - }
177   - else
178   - {
179   - echo "<!--\nErro\nClasse clsPmieducarEscola n&atilde;o encontrada\n-->";
180   - $opcoes_escola = array( "" => "Erro na gera&ccedil;&atilde;o" );
181   - }
182   - }
183   - if ($get_escola)
184   - {
185   - $retorno .= '<tr id="tr_escola">
186   - <td valign="top" class="formmdtd">
187   - <span class="form">Escola</span>
188   - <span class="campo_obrigatorio">*</span>
189   - <br/>
190   - <sub style="vertical-align: top;"/>
191   - </td>';
192   - $retorno .= '<td valign="top" class="formmdtd"><span class="form">';
193   -
194   - $disabled = !$this->ref_cod_escola && $nivel_usuario == 1? "disabled='true' " : "" ;
195   - $retorno .= " <select class='geral' name='ref_cod_escola' {$disabled} id='ref_cod_escola'>";
196   -
197   - reset( $opcoes_escola );
198   - while (list( $chave, $texto ) = each($opcoes_escola ))
199   - {
200   - $retorno .= "<option id=\"ref_cod_escola_".urlencode($chave)."\" value=\"".urlencode($chave)."\"";
201   -
202   - if( $chave==$this->ref_cod_escola)
203   - {
204   - $retorno .= " selected";
205   - }
206   - $retorno .= ">$texto</option>";
207   - }
208   - $retorno .= "</select>";
209   - $retorno .= '</span>
210   - </td>
211   - </tr>';
212   -
213   - //$this->campoLista( "ref_cod_instituicao", "Institui&ccedil;&atilde;o", $opcoes, $this->ref_cod_instituicao,"getDuplo();",null,null,null,$instituicao_desabilitado,$instituicao_obrigatorio);
214   - }
215   - //$this->campoLista( "ref_cod_escola", "Escola", $opcoes_escola, $this->ref_cod_escola,null,null,null,null,$escola_desabilitado,$escola_obrigatorio );
216   - }
217   - }
218   -
219   - if (isset($get_cabecalho))
220   - {
221   - if ($nivel_usuario == 1 || $nivel_usuario == 2)
222   - ${$get_cabecalho}[] = "Escola";
223   - if ($nivel_usuario == 1)
224   - ${$get_cabecalho}[] = "Institui&ccedil;&atilde;o";
225   - }
226   -
227   - $validacao = "";
228   - if($nivel_usuario== 1){
229   - $validacao = 'if(!document.getElementById("ref_cod_instituicao").value){
230   - alert("Por favor, selecione uma instituicao");
231   - return false;
232   - }
233   - if(!document.getElementById("ref_cod_escola").value){
234   - alert("Por favor, selecione uma escola");
235   - return false;
236   - } ';
237   - }elseif($nivel_usuario== 2 ){
238   - $validacao = '
239   - if(!document.getElementById("ref_cod_escola").value){
240   - alert("Por favor, selecione uma escola");
241   - return false;
242   - } ';
243   - }
244   - $retorno .= '<tr id="tr_escola">
245   - <td valign="top" class="formldtd">
246   - <span class="form">Ano</span>
247   - <span class="campo_obrigatorio">*</span>
248   - <br/>
249   - <sub style="vertical-align: top;"/>
250   - </td>';
251   - $retorno .= '<td valign="top" class="formldtd"><span class="form">';
252   - $retorno .= " <select class='geral' name='ano' id='ano'>";
253   - $lim = 5;
254   - for($a = date('Y') ; $a < date('Y') + $lim ; $a++ ){
255   -
256   - $retorno .= "<option value=\"".$a."\"";
257   -
258   - if($a == $_POST['ano'])
259   - {
260   - $retorno .= " selected";
261   - }
262   - $retorno .= ">$a</option>";
263   - }
264   - $retorno .= "</select>";
265   - $retorno .= '</span>
266   - </td>
267   - </tr>';
268   - $retorno .= '</form>';
269   - $retorno .= "<tr>
270   - <td colspan='2' class='formdktd'/>
271   - </tr>
272   - <tr>
273   - <td align='center' colspan='2'>
274   - <script language='javascript'>
275   - function acao() {
276   - {$validacao}
277   -
278   - document.formcadastro.submit();
279   - }
280   - </script>
281   - <input type='button' id='botao_busca' value='busca' onclick='javascript:acao();' class='botaolistagem'/>
282   - </td>
283   - </tr><tr><td>&nbsp;</td></tr>";
284   - ?>
285   -
286   - <?
287   - if ( $nivel_usuario == 1 || $nivel_usuario == 2 )
288   - {
289   - ?>
290   - <script>
291   - //caso seja preciso executar uma funcao no onchange da instituicao adicionar uma funcao as seguintes variaveis no arquivo
292   - //que precisar , assim, toda vez que for chamada a funcao serao executadas estas funcoes
293   - var before_getEscola = function(){}
294   - var after_getEscola = function(){}
295   -
296   - function getEscola()
297   - {
298   - before_getEscola();
299   -
300   - var campoInstituicao = document.getElementById('ref_cod_instituicao').value;
301   - if ( document.getElementById('ref_cod_escola') )
302   - var campoEscola = document.getElementById('ref_cod_escola');
303   - if ( document.getElementById('ref_ref_cod_escola') )
304   - var campoEscola = document.getElementById('ref_ref_cod_escola');
305   -
306   - campoEscola.length = 1;
307   - campoEscola.options[0] = new Option( 'Selecione uma escola', '', false, false );
308   - for (var j = 0; j < escola.length; j++)
309   - {
310   - if (escola[j][2] == campoInstituicao)
311   - {
312   - campoEscola.options[campoEscola.options.length] = new Option( escola[j][1], escola[j][0],false,false);
313   - }
314   - }
315   - if ( campoEscola.length == 1 && campoInstituicao != '' ) {
316   - campoEscola.options[0] = new Option( 'A institui��o n�o possui nenhuma escola', '', false, false );
317   - }
318   -
319   - after_getEscola();
320   - }
321   -
322   - function habilitaCampos(campo)
323   - {
324   - var campo_instituicao = document.getElementById("ref_cod_instituicao");
325   - var campo_escola = document.getElementById("ref_cod_escola");
326   -
327   - if( campo == "")
328   - {
329   - campo_instituicao.disabled = true;
330   - campo_escola.disabled = true;
331   - }
332   - else if( campo == "ref_cod_instituicao" )
333   - {
334   - campo_escola.disabled = false;
335   - getEscola();
336   - }
337   -
338   - }
339   - </script>
340   - <? }
341   -
342   -}//nivel usuario <=3
343   -if($nivel_usuario == 4){ ?>
344   -
345   -<?}?>
346 2 \ No newline at end of file
  3 +
  4 +$obj_permissoes = new clsPermissoes();
  5 +$nivel_usuario = $obj_permissoes->nivel_acesso($this->pessoa_logada);
  6 +
  7 +if ($nivel_usuario <= 4 && !empty($nivel_usuario)) {
  8 + $retorno .= '
  9 + <tr>
  10 + <td height="24" colspan="2" class="formdktd">
  11 + <span class="form"><b>Filtros de busca</b></span>
  12 + </td>
  13 + </tr>';
  14 +
  15 + $retorno .= '<form action="" method="post" id="formcadastro" name="formcadastro">';
  16 +
  17 + if ($obrigatorio) {
  18 + $instituicao_obrigatorio = $escola_obrigatorio = TRUE;
  19 + }
  20 + else {
  21 + $instituicao_obrigatorio = isset($instituicao_obrigatorio) ?
  22 + $instituicao_obrigatorio : $obrigatorio;
  23 +
  24 + $escola_obrigatorio = isset($escola_obrigatorio) ?
  25 + $escola_obrigatorio : $obrigatorio;
  26 + }
  27 +
  28 + if ($desabilitado) {
  29 + $instituicao_desabilitado = $escola_desabilitado = TRUE;
  30 + }
  31 + else {
  32 + $instituicao_desabilitado = isset($instituicao_desabilitado) ?
  33 + $instituicao_desabilitado : $desabilitado;
  34 +
  35 + $escola_desabilitado = isset($escola_desabilitado) ?
  36 + $escola_desabilitado : $desabilitado;
  37 + }
  38 +
  39 + $obj_permissoes = new clsPermissoes();
  40 + $nivel_usuario = $obj_permissoes->nivel_acesso($this->pessoa_logada);
  41 +
  42 + if ($nivel_usuario == 1) {
  43 + if (class_exists('clsPmieducarInstituicao')) {
  44 + $opcoes = array('' => 'Selecione');
  45 +
  46 + $obj_instituicao = new clsPmieducarInstituicao();
  47 + $obj_instituicao->setCamposLista('cod_instituicao, nm_instituicao');
  48 + $obj_instituicao->setOrderby('nm_instituicao ASC');
  49 +
  50 + $lista = $obj_instituicao->lista(NULL, NULL, NULL, NULL, NULL, NULL,
  51 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1);
  52 +
  53 + if (is_array($lista) && count($lista)) {
  54 + foreach ($lista as $registro) {
  55 + $opcoes[$registro['cod_instituicao']] = $registro['nm_instituicao'];
  56 + }
  57 + }
  58 + }
  59 + else {
  60 + $opcoes = array('' => 'Erro na geração');
  61 + }
  62 +
  63 + if ($get_escola) {
  64 + $retorno .= '
  65 + <tr id="tr_status">
  66 + <td valign="top" class="formlttd">
  67 + <span class="form">Instituição</span>
  68 + <span class="campo_obrigatorio">*</span><br/>
  69 + <sub style="vertical-align: top;"/>
  70 + </td>';
  71 +
  72 + $retorno .= '<td valign="top" class="formlttd"><span class="form">';
  73 + $retorno .= '<select onchange="habilitaCampos(\'ref_cod_instituicao\');" class="geral" name="ref_cod_instituicao" id="ref_cod_instituicao">';
  74 +
  75 + reset($opcoes);
  76 +
  77 + while (list($chave, $texto) = each($opcoes)) {
  78 + $retorno .= sprintf(
  79 + '<option id="ref_cod_instituicao_%s" value="%s"',
  80 + urlencode($chave), urlencode($chave)
  81 + );
  82 +
  83 + if ($chave == $this->ref_cod_instituicao) {
  84 + $retorno .= " selected";
  85 + }
  86 +
  87 + $retorno .= ">$texto</option>";
  88 + }
  89 +
  90 + $retorno .= '</select>';
  91 + $retorno .= '</span></td></tr>';
  92 + }
  93 + }
  94 +
  95 + if ($nivel_usuario == 2) {
  96 + if ($get_instituicao) {
  97 + $obj_per = new clsPermissoes();
  98 + $this->ref_cod_instituicao = $obj_per->getInstituicao($this->pessoa_logada);
  99 + $retorno .= sprintf(
  100 + '<input type="hidden" id="red_cod_instituicao" value="%s">',
  101 + $this->ref_cod_instituicao
  102 + );
  103 + }
  104 + }
  105 + elseif ($nivel_usuario != 1) {
  106 + $obj_usuario = new clsPmieducarUsuario($this->pessoa_logada);
  107 + $det_usuario = $obj_usuario->detalhe();
  108 + $this->ref_cod_instituicao = $det_usuario['ref_cod_instituicao'];
  109 +
  110 + if ($nivel_usuario == 4 || $nivel_usuario == 8) {
  111 + $obj_usuario = new clsPmieducarUsuario($this->pessoa_logada);
  112 + $det_usuario = $obj_usuario->detalhe();
  113 + $this->ref_cod_escola = $det_usuario['ref_cod_escola'];
  114 + }
  115 + }
  116 +
  117 + if ($nivel_usuario == 1 || $nivel_usuario == 2) {
  118 + if ($get_escola) {
  119 + if (class_exists('clsPmieducarEscola')) {
  120 + $opcoes_escola = array('' => 'Selecione');
  121 +
  122 + $todas_escolas = 'escola = new Array();' . "\n";
  123 + $obj_escola = new clsPmieducarEscola();
  124 +
  125 + $lista = $obj_escola->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  126 + NULL, NULL, NULL, 1);
  127 +
  128 + if (is_array($lista) && count($lista)) {
  129 + foreach ($lista as $registro) {
  130 + $todas_escolas .= sprintf(
  131 + 'escola[escola.length] = new Array(%s, \'%s\', %s);' . "\n",
  132 + $registro['cod_escola'], $registro['nome'], $registro['ref_cod_instituicao']
  133 + );
  134 + }
  135 + }
  136 +
  137 + echo sprintf('<script>%s</script>', $todas_escolas);
  138 + }
  139 + else {
  140 + $opcoes_escola = array('' => 'Erro na geração');
  141 + }
  142 +
  143 + if ($this->ref_cod_instituicao) {
  144 + if (class_exists('clsPmieducarEscola')) {
  145 + $opcoes_escola = array('' => 'Selecione');
  146 + $obj_escola = new clsPmieducarEscola();
  147 + $lista = $obj_escola->lista(NULL, NULL, NULL, $this->ref_cod_instituicao,
  148 + NULL, NULL, NULL, NULL, NULL, NULL, 1);
  149 +
  150 + if (is_array($lista) && count($lista)) {
  151 + foreach ($lista as $registro) {
  152 + $opcoes_escola[$registro['cod_escola']] = $registro['nome'];
  153 + }
  154 + }
  155 + }
  156 + else {
  157 + $opcoes_escola = array('' => 'Erro na geração');
  158 + }
  159 + }
  160 +
  161 + if ($get_escola) {
  162 + $retorno .= '
  163 + <tr id="tr_escola">
  164 + <td valign="top" class="formmdtd">
  165 + <span class="form">Escola</span>
  166 + <span class="campo_obrigatorio">*</span><br/>
  167 + <sub style="vertical-align: top;"/>
  168 + </td>';
  169 +
  170 + $retorno .= '<td valign="top" class="formmdtd"><span class="form">';
  171 +
  172 + $disabled = !$this->ref_cod_escola && $nivel_usuario == 1 ? 'disabled="true" ' : '';
  173 + $retorno .= sprintf(
  174 + ' <select class="geral" name="ref_cod_escola" %s id="ref_cod_escola">', $disabled
  175 + );
  176 +
  177 + reset($opcoes_escola);
  178 +
  179 + while (list($chave, $texto) = each($opcoes_escola)) {
  180 + $retorno .= sprintf(
  181 + '<option id="ref_cod_escola_%s" value="%s"', urlencode($chave), urlencode($chave)
  182 + );
  183 +
  184 + if ($chave == $this->ref_cod_escola) {
  185 + $retorno .= ' selected';
  186 + }
  187 +
  188 + $retorno .= sprintf('>%s</option>', $texto);
  189 + }
  190 +
  191 + $retorno .= '</select>';
  192 + $retorno .= '</span></td></tr>';
  193 + }
  194 + }
  195 + }
  196 +
  197 + if (isset($get_cabecalho)) {
  198 + if ($nivel_usuario == 1 || $nivel_usuario == 2) {
  199 + ${$get_cabecalho}[] = 'Escola';
  200 + }
  201 + if ($nivel_usuario == 1) {
  202 + ${$get_cabecalho}[] = 'Instituição';
  203 + }
  204 + }
  205 +
  206 + $validacao = '';
  207 +
  208 + if ($nivel_usuario == 1) {
  209 + $validacao = '
  210 + if (!document.getElementById("ref_cod_instituicao").value) {
  211 + alert("Por favor, selecione uma instituicao");
  212 + return false;
  213 + }
  214 + if (!document.getElementById("ref_cod_escola").value) {
  215 + alert("Por favor, selecione uma escola");
  216 + return false;
  217 + } ';
  218 + }
  219 + elseif ($nivel_usuario == 2) {
  220 + $validacao = '
  221 + if (!document.getElementById("ref_cod_escola").value){
  222 + alert("Por favor, selecione uma escola");
  223 + return false;
  224 + } ';
  225 + }
  226 +
  227 + $retorno .= '
  228 + <tr id="tr_escola">
  229 + <td valign="top" class="formldtd">
  230 + <span class="form">Ano</span>
  231 + <span class="campo_obrigatorio">*</span><br/>
  232 + <sub style="vertical-align: top;"/>
  233 + </td>';
  234 + $retorno .= '<td valign="top" class="formldtd"><span class="form">';
  235 + $retorno .= " <select class='geral' name='ano' id='ano'>";
  236 +
  237 + $lim = 5;
  238 +
  239 + for ($a = date('Y'); $a < date('Y') + $lim; $a++) {
  240 + $retorno .= sprintf('<option value="%s"', $a);
  241 +
  242 + if ($a == $_POST['ano']) {
  243 + $retorno .= " selected";
  244 + }
  245 +
  246 + $retorno .= '>' . $a . '</option>';
  247 + }
  248 +
  249 + $retorno .= '</select>';
  250 + $retorno .= '</span></td></tr>';
  251 +
  252 + $retorno .= '</form>';
  253 +
  254 + $retorno .= sprintf("
  255 + <tr>
  256 + <td colspan='2' class='formdktd'/>
  257 + </tr>
  258 + <tr>
  259 + <td align='center' colspan='2'>
  260 + <script language='javascript'>
  261 + function acao() {
  262 + %s
  263 + document.formcadastro.submit();
  264 + }
  265 + </script>
  266 + <input type='button' id='botao_busca' value='busca' onclick='javascript:acao();' class='botaolistagem'/>
  267 + </td>
  268 + </tr>
  269 + <tr>
  270 + <td>&nbsp;</td>
  271 + </tr>", $validacao);
  272 +?>
  273 +
  274 +<?php if ($nivel_usuario == 1 || $nivel_usuario == 2): ?>
  275 + <script type="text/javascript">
  276 + var before_getEscola = function() {}
  277 + var after_getEscola = function() {}
  278 +
  279 + function getEscola()
  280 + {
  281 + before_getEscola();
  282 +
  283 + var campoInstituicao = document.getElementById('ref_cod_instituicao').value;
  284 +
  285 + if (document.getElementById('ref_cod_escola')) {
  286 + var campoEscola = document.getElementById('ref_cod_escola');
  287 + }
  288 +
  289 + if (document.getElementById('ref_ref_cod_escola')) {
  290 + var campoEscola = document.getElementById('ref_ref_cod_escola');
  291 + }
  292 +
  293 + campoEscola.length = 1;
  294 + campoEscola.options[0] = new Option('Selecione uma escola', '', false, false);
  295 + for (var j = 0; j < escola.length; j++) {
  296 + if (escola[j][2] == campoInstituicao) {
  297 + campoEscola.options[campoEscola.options.length] = new Option(
  298 + escola[j][1], escola[j][0], false, false
  299 + );
  300 + }
  301 + }
  302 +
  303 + if (campoEscola.length == 1 && campoInstituicao != '') {
  304 + campoEscola.options[0] = new Option(
  305 + 'A institução não possui nenhuma escola', '', false, false
  306 + );
  307 + }
  308 +
  309 + after_getEscola();
  310 + }
  311 +
  312 + function habilitaCampos(campo)
  313 + {
  314 + var campo_instituicao = document.getElementById('ref_cod_instituicao');
  315 + var campo_escola = document.getElementById('ref_cod_escola');
  316 +
  317 + if (campo == "") {
  318 + campo_instituicao.disabled = true;
  319 + campo_escola.disabled = true;
  320 + }
  321 + else if (campo == 'ref_cod_instituicao') {
  322 + campo_escola.disabled = false;
  323 + getEscola();
  324 + }
  325 + }
  326 + </script>
  327 +<?php endif; ?>
  328 +<?php
  329 +}
347 330 \ No newline at end of file
... ...