Commit fe9bb20e7b33e727c0ab4f2836e3c97ce9968e91
1 parent
721d1ffa
Exists in
master
#76 by Eriksen Costa: Melhorias no calendário de ano letivo, permitindo que o a…
…no letivo termine em anos posteriores
Showing
10 changed files
with
495 additions
and
126 deletions
Show diff stats
ieducar/intranet/clsCalendario.inc.php
@@ -297,10 +297,11 @@ class clsCalendario | @@ -297,10 +297,11 @@ class clsCalendario | ||
297 | * @todo Substituir código de geração de calendário por uma biblioteca | 297 | * @todo Substituir código de geração de calendário por uma biblioteca |
298 | * com licença compatível com GPL2 | 298 | * com licença compatível com GPL2 |
299 | */ | 299 | */ |
300 | - function getCalendario($mes, $ano, $nome, $mixVariaveisMantidas) | 300 | + function getCalendario($mes, $ano, $nome, $mixVariaveisMantidas, |
301 | + array $formValues = array()) | ||
301 | { | 302 | { |
302 | - $array_color = $array_color; | ||
303 | - $array_legenda = $array_legenda; | 303 | + $array_color = $this->array_cor; |
304 | + $array_legenda = $this->array_legenda; | ||
304 | 305 | ||
305 | if ( | 306 | if ( |
306 | isset($mixVariaveisMantidas["{$nome}_mes"]) && | 307 | isset($mixVariaveisMantidas["{$nome}_mes"]) && |
@@ -354,7 +355,7 @@ class clsCalendario | @@ -354,7 +355,7 @@ class clsCalendario | ||
354 | 355 | ||
355 | // Create the table tag opener and day headers | 356 | // Create the table tag opener and day headers |
356 | // GET | 357 | // GET |
357 | - $linkFixo = $strUrl . "?"; | 358 | + $linkFixo = '?'; |
358 | if (is_array($mixVariaveisMantidas)) { | 359 | if (is_array($mixVariaveisMantidas)) { |
359 | foreach ($mixVariaveisMantidas as $key => $value) { | 360 | foreach ($mixVariaveisMantidas as $key => $value) { |
360 | if ($key != "{$nome}_mes" && $key != "{$nome}_ano") { | 361 | if ($key != "{$nome}_mes" && $key != "{$nome}_ano") { |
@@ -427,11 +428,15 @@ class clsCalendario | @@ -427,11 +428,15 @@ class clsCalendario | ||
427 | 428 | ||
428 | $form = sprintf(' | 429 | $form = sprintf(' |
429 | <form id="form_calendario" name="form_calendario" method="post" action="%s"> | 430 | <form id="form_calendario" name="form_calendario" method="post" action="%s"> |
430 | - <input type="hidden" id="nome" name="nome" value=""> | ||
431 | - <input type="hidden" id="dia" name="dia" value=""> | ||
432 | - <input type="hidden" id="mes" name="mes" value=""> | ||
433 | - <input type="hidden" id="ano" name="ano" value=""> | ||
434 | - </form>', $linkFixo); | 431 | + <input type="hidden" id="cal_nome" name="nome" value=""> |
432 | + <input type="hidden" id="cal_dia" name="dia" value=""> | ||
433 | + <input type="hidden" id="cal_mes" name="mes" value=""> | ||
434 | + <input type="hidden" id="cal_ano" name="ano" value=""> | ||
435 | + %s | ||
436 | + </form>', | ||
437 | + $linkFixo, | ||
438 | + $this->_generateFormValues($formValues, array('nome', 'ano', 'mes', 'dia')) | ||
439 | + ); | ||
435 | 440 | ||
436 | if ($this->permite_trocar_ano == TRUE) { | 441 | if ($this->permite_trocar_ano == TRUE) { |
437 | $select = sprintf( | 442 | $select = sprintf( |
@@ -467,8 +472,8 @@ class clsCalendario | @@ -467,8 +472,8 @@ class clsCalendario | ||
467 | <a href="#" onclick="acaoCalendario(\'%s\', \'\', \'%s\', \'%s\')"> | 472 | <a href="#" onclick="acaoCalendario(\'%s\', \'\', \'%s\', \'%s\')"> |
468 | <img src="/intranet/imagens/i-educar/seta_esq.gif" border="0" style="margin-right: 5px;" alt="Mês Anterior"> | 473 | <img src="/intranet/imagens/i-educar/seta_esq.gif" border="0" style="margin-right: 5px;" alt="Mês Anterior"> |
469 | </a> | 474 | </a> |
470 | - %s | ||
471 | - ', $nome, $mes_ano, $ano_anterior_ano, $ano); | 475 | + %s', |
476 | + $nome, $mes_ano, $ano_anterior_ano, $ano); | ||
472 | 477 | ||
473 | $cab[] = sprintf(' | 478 | $cab[] = sprintf(' |
474 | <a href="#" onclick="acaoCalendario(\'%s\', \'\', \'%s\', \'%s\')"> | 479 | <a href="#" onclick="acaoCalendario(\'%s\', \'\', \'%s\', \'%s\')"> |
@@ -568,7 +573,7 @@ class clsCalendario | @@ -568,7 +573,7 @@ class clsCalendario | ||
568 | 573 | ||
569 | $style_dia = sprintf('background-color: %s;', $this->array_cor[0]); | 574 | $style_dia = sprintf('background-color: %s;', $this->array_cor[0]); |
570 | 575 | ||
571 | - if ($this->array_cor_dia_padrao[$DiaSemana]) | 576 | + if (isset($this->array_cor_dia_padrao[$DiaSemana])) |
572 | $style_dia = sprintf('background-color: %s;', $this->array_cor_dia_padrao[$DiaSemana]); | 577 | $style_dia = sprintf('background-color: %s;', $this->array_cor_dia_padrao[$DiaSemana]); |
573 | 578 | ||
574 | if (key_exists($diaCorrente,$this->array_dias)) { | 579 | if (key_exists($diaCorrente,$this->array_dias)) { |
@@ -607,7 +612,7 @@ class clsCalendario | @@ -607,7 +612,7 @@ class clsCalendario | ||
607 | $diaCorrente_ = strlen($diaCorrente) == 1 ? '0' . $diaCorrente : $diaCorrente; | 612 | $diaCorrente_ = strlen($diaCorrente) == 1 ? '0' . $diaCorrente : $diaCorrente; |
608 | $NomeMes = strtolower($NomeMes); | 613 | $NomeMes = strtolower($NomeMes); |
609 | 614 | ||
610 | - if (key_exists($diaCorrente,$this->array_div_flutuante_dias)) { | 615 | + if (key_exists($diaCorrente, $this->array_div_flutuante_dias)) { |
611 | $message = "onmouseover=\"ShowContent('{$diaCorrente}','{$mes}','{$ano}','{$nome}'); return true;\""; | 616 | $message = "onmouseover=\"ShowContent('{$diaCorrente}','{$mes}','{$ano}','{$nome}'); return true;\""; |
612 | $mouseout = "onmouseout=\"HideContent(event,'{$diaCorrente}','{$mes}','{$ano}','{$nome}')\" "; | 617 | $mouseout = "onmouseout=\"HideContent(event,'{$diaCorrente}','{$mes}','{$ano}','{$nome}')\" "; |
613 | $mensagens .= " | 618 | $mensagens .= " |
@@ -713,8 +718,53 @@ class clsCalendario | @@ -713,8 +718,53 @@ class clsCalendario | ||
713 | $calendario .= '</td></tr>'; | 718 | $calendario .= '</td></tr>'; |
714 | $calendario .= '</table></div>'; | 719 | $calendario .= '</table></div>'; |
715 | 720 | ||
716 | - $calendario .= $mensagens; | 721 | + if (isset($mensagens)) { |
722 | + $calendario .= $mensagens; | ||
723 | + } | ||
717 | 724 | ||
718 | return $calendario; | 725 | return $calendario; |
719 | } | 726 | } |
727 | + | ||
728 | + /** | ||
729 | + * Gera campos hidden para o formulário do calendário. | ||
730 | + * | ||
731 | + * Exemplo de uso: | ||
732 | + * | ||
733 | + * <code> | ||
734 | + * <?php | ||
735 | + * $formValues = array( | ||
736 | + * 'formFieldKey' => 'formFieldValue' | ||
737 | + * ); | ||
738 | + * print $this->_generateFormValues($formValues); | ||
739 | + * // <input id="cal_formFieldKey" name="formFieldKey" type="hidden" value="formFieldValue" /> | ||
740 | + * </code> | ||
741 | + * | ||
742 | + * @access protected | ||
743 | + * @param array $formValues Array associativo onde a chave torna-se o | ||
744 | + * o valor dos atributos id e name do campo hidden. | ||
745 | + * @param array $invalidNames Array com nomes inválidos para campos. Útil | ||
746 | + * para evitar que sejam criados campos duplicados. | ||
747 | + * @return string String com o HTML dos campos hidden gerados. | ||
748 | + * @since Método disponível desde a versão 1.2.0 | ||
749 | + * @todo Refatorar código de geração de html para uma classe externa. | ||
750 | + */ | ||
751 | + function _generateFormValues($formValues = array(), $invalidNames = array()) | ||
752 | + { | ||
753 | + $ret = ''; | ||
754 | + | ||
755 | + if (is_array($formValues) && 0 < count($formValues)) { | ||
756 | + foreach ($formValues as $name => $value) { | ||
757 | + if (in_array($name, $invalidNames)) { | ||
758 | + continue; | ||
759 | + } | ||
760 | + | ||
761 | + $ret .= sprintf( | ||
762 | + '<input id="cal_%s" name="%s" type="hidden" value="%s" />', | ||
763 | + $name, $name, $value | ||
764 | + ); | ||
765 | + } | ||
766 | + } | ||
767 | + | ||
768 | + return $ret; | ||
769 | + } | ||
720 | } | 770 | } |
721 | \ No newline at end of file | 771 | \ No newline at end of file |
ieducar/intranet/educar_ano_letivo_modulo_cad.php
@@ -33,6 +33,8 @@ require_once 'include/clsCadastro.inc.php'; | @@ -33,6 +33,8 @@ require_once 'include/clsCadastro.inc.php'; | ||
33 | require_once 'include/clsBanco.inc.php'; | 33 | require_once 'include/clsBanco.inc.php'; |
34 | require_once 'include/pmieducar/geral.inc.php'; | 34 | require_once 'include/pmieducar/geral.inc.php'; |
35 | 35 | ||
36 | +require_once 'App/Date/Utils.php'; | ||
37 | + | ||
36 | /** | 38 | /** |
37 | * clsIndexBase class. | 39 | * clsIndexBase class. |
38 | * | 40 | * |
@@ -280,12 +282,16 @@ class indice extends clsCadastro | @@ -280,12 +282,16 @@ class indice extends clsCadastro | ||
280 | 282 | ||
281 | if ($this->ano_letivo_modulo) { | 283 | if ($this->ano_letivo_modulo) { |
282 | $obj = new clsPmieducarEscolaAnoLetivo($this->ref_ref_cod_escola, | 284 | $obj = new clsPmieducarEscolaAnoLetivo($this->ref_ref_cod_escola, |
283 | - $this->ref_ano, $this->pessoa_logada, NULL, 0, NULL, NULL, 1 | 285 | + $this->ref_ano, $this->pessoa_logada, NULL, 0, NULL, NULL, 1 |
284 | ); | 286 | ); |
285 | 287 | ||
286 | $cadastrou = $obj->cadastra(); | 288 | $cadastrou = $obj->cadastra(); |
287 | 289 | ||
288 | if ($cadastrou) { | 290 | if ($cadastrou) { |
291 | + if (FALSE == $this->_verificaModuloDatas($this->ano_letivo_modulo)) { | ||
292 | + return FALSE; | ||
293 | + } | ||
294 | + | ||
289 | foreach ($this->ano_letivo_modulo as $campo) { | 295 | foreach ($this->ano_letivo_modulo as $campo) { |
290 | $campo['data_inicio_'] = dataToBanco($campo['data_inicio_']); | 296 | $campo['data_inicio_'] = dataToBanco($campo['data_inicio_']); |
291 | $campo['data_fim_'] = dataToBanco($campo['data_fim_']); | 297 | $campo['data_fim_'] = dataToBanco($campo['data_fim_']); |
@@ -336,6 +342,10 @@ class indice extends clsCadastro | @@ -336,6 +342,10 @@ class indice extends clsCadastro | ||
336 | $excluiu = $obj->excluirTodos(); | 342 | $excluiu = $obj->excluirTodos(); |
337 | 343 | ||
338 | if ($excluiu) { | 344 | if ($excluiu) { |
345 | + if (FALSE == $this->_verificaModuloDatas($this->ano_letivo_modulo)) { | ||
346 | + return FALSE; | ||
347 | + } | ||
348 | + | ||
339 | foreach ($this->ano_letivo_modulo as $campo) { | 349 | foreach ($this->ano_letivo_modulo as $campo) { |
340 | $campo['data_inicio_'] = dataToBanco($campo['data_inicio_']); | 350 | $campo['data_inicio_'] = dataToBanco($campo['data_inicio_']); |
341 | $campo['data_fim_'] = dataToBanco($campo['data_fim_']); | 351 | $campo['data_fim_'] = dataToBanco($campo['data_fim_']); |
@@ -397,6 +407,33 @@ class indice extends clsCadastro | @@ -397,6 +407,33 @@ class indice extends clsCadastro | ||
397 | $this->mensagem = 'Exclusão não realizada.<br />'; | 407 | $this->mensagem = 'Exclusão não realizada.<br />'; |
398 | return FALSE; | 408 | return FALSE; |
399 | } | 409 | } |
410 | + | ||
411 | + /** | ||
412 | + * Verifica se ao menos uma das datas as datas de início dos módulos é do | ||
413 | + * mesmo ano letivo da escola. Em caso de erro, configura a mensagem de | ||
414 | + * erro que é retornado pelo formulário. | ||
415 | + * | ||
416 | + * @access private | ||
417 | + * @param array $modulos O array associativo recebido via POST pelo formulário. | ||
418 | + * @return bool FALSE caso nenhuma das datas esteja no mesmo ano letivo da escola. | ||
419 | + */ | ||
420 | + function _verificaModuloDatas(array $modulos) | ||
421 | + { | ||
422 | + $dates = array(); | ||
423 | + foreach ($modulos as $modulo) { | ||
424 | + $dates[] = $modulo['data_inicio_']; | ||
425 | + } | ||
426 | + | ||
427 | + try { | ||
428 | + App_Date_Utils::datesYearAtLeast($dates, $this->ref_ano, 1); | ||
429 | + } | ||
430 | + catch (App_Date_Exception $e) { | ||
431 | + $this->mensagem = $e->getMessage(); | ||
432 | + return FALSE; | ||
433 | + } | ||
434 | + | ||
435 | + return TRUE; | ||
436 | + } | ||
400 | } | 437 | } |
401 | 438 | ||
402 | // Instancia objeto de página | 439 | // Instancia objeto de página |
@@ -412,37 +449,43 @@ $pagina->addForm($miolo); | @@ -412,37 +449,43 @@ $pagina->addForm($miolo); | ||
412 | $pagina->MakeAll(); | 449 | $pagina->MakeAll(); |
413 | ?> | 450 | ?> |
414 | <script type="text/javascript"> | 451 | <script type="text/javascript"> |
452 | +/** | ||
453 | + * Realiza validação client-side do formulário. | ||
454 | + */ | ||
415 | function incluir() | 455 | function incluir() |
416 | { | 456 | { |
417 | - if (new Date(document.getElementById('data_fim').value) > new Date(document.getElementById('data_inicio').value)) | 457 | + var phpjs = ied_phpjs.getInstance(); |
458 | + var startDate = null; | ||
459 | + var endDate = null; | ||
460 | + | ||
461 | + startDate = document.getElementById('data_inicio').value.split('/'); | ||
462 | + endDate = document.getElementById('data_fim').value.split('/'); | ||
463 | + | ||
464 | + if ('' === document.getElementById('ref_cod_modulo').value) { | ||
465 | + alert('É necessário selecionar um "módulo".'); | ||
466 | + return false; | ||
467 | + } | ||
418 | 468 | ||
419 | - if (! (/(((0[1-9]|[12][0-9])\/(02))|((0[1-9]|[12][0-9]|(30))\/(0[4689]|(11)))|((0[1-9]|[12][0-9]|3[01])\/(0[13578]|(10)|(12))))\/[1-2][0-9]{3}/.test( document.getElementById("data_inicio").value ))) { | ||
420 | - mudaClassName('formdestaque', 'obrigatorio'); | 469 | + if (!phpjs.checkdate(startDate[1], startDate[0], startDate[2])) { |
421 | document.getElementById('data_inicio').className = 'formdestaque'; | 470 | document.getElementById('data_inicio').className = 'formdestaque'; |
422 | alert('Preencha o campo "Data Início" corretamente!'); | 471 | alert('Preencha o campo "Data Início" corretamente!'); |
423 | - | ||
424 | document.getElementById('data_inicio').focus(); | 472 | document.getElementById('data_inicio').focus(); |
425 | return false; | 473 | return false; |
426 | } | 474 | } |
427 | 475 | ||
428 | - if (!(/(((0[1-9]|[12][0-9])\/(02))|((0[1-9]|[12][0-9]|(30))\/(0[4689]|(11)))|((0[1-9]|[12][0-9]|3[01])\/(0[13578]|(10)|(12))))\/[1-2][0-9]{3}/.test( document.getElementById("data_fim").value ))) { | ||
429 | - mudaClassName('formdestaque', 'obrigatorio'); | 476 | + if (!phpjs.checkdate(endDate[1], endDate[0], endDate[2])) { |
430 | document.getElementById('data_fim').className = 'formdestaque'; | 477 | document.getElementById('data_fim').className = 'formdestaque'; |
431 | alert('Preencha o campo "Data Fim" corretamente!'); | 478 | alert('Preencha o campo "Data Fim" corretamente!'); |
432 | - | ||
433 | document.getElementById('data_fim').focus(); | 479 | document.getElementById('data_fim').focus(); |
434 | return false; | 480 | return false; |
435 | } | 481 | } |
436 | 482 | ||
437 | - var dt1 = document.getElementById('data_inicio').value.split('/'); | ||
438 | - var dt2 = document.getElementById('data_fim').value.split('/'); | ||
439 | - | ||
440 | - var data_ini = new Date(parseInt(dt1[2]), parseInt(dt1[1], 10), parseInt(dt1[0], 10)); | ||
441 | - var data_fim = new Date(parseInt(dt2[2]), parseInt(dt2[1], 10), parseInt(dt2[0], 10)); | 483 | + startDate = new Date(parseInt(startDate[2], 10), parseInt(startDate[1], 10) - 1, parseInt(startDate[0], 10)); |
484 | + endDate = new Date(parseInt(endDate[2], 10), parseInt(endDate[1], 10) - 1, parseInt(endDate[0], 10)); | ||
442 | 485 | ||
443 | - if (data_ini > data_fim || parseInt(dt1[2]) != parseInt(dt2[2])) { | ||
444 | - alert( 'Datas incorretas!\n1- Verifique se as datas são do mesmo ano.\n2- Verifique se a "Data Fim" é maior que a "Data Início".'); | ||
445 | - return; | 486 | + if (endDate < startDate) { |
487 | + alert('"Data Início" não pode ser posterior a "Data Fim".'); | ||
488 | + return false; | ||
446 | } | 489 | } |
447 | 490 | ||
448 | document.getElementById('incluir_modulo').value = 'S'; | 491 | document.getElementById('incluir_modulo').value = 'S'; |
ieducar/intranet/educar_calendario_ano_letivo_lst.php
@@ -118,11 +118,11 @@ class indice extends clsConfig | @@ -118,11 +118,11 @@ class indice extends clsConfig | ||
118 | <tbody>'; | 118 | <tbody>'; |
119 | 119 | ||
120 | if ($_POST) { | 120 | if ($_POST) { |
121 | - $this->ref_cod_escola = $_POST['ref_cod_escola'] ? | ||
122 | - $_POST['ref_cod_escola'] : $_SESSION['calendario']['ref_cod_escola']; | 121 | + $this->ref_cod_escola = $_POST['ref_cod_escola'] ? |
122 | + $_POST['ref_cod_escola'] : $_SESSION['calendario']['ref_cod_escola']; | ||
123 | 123 | ||
124 | - $this->ref_cod_instituicao = $_POST['ref_cod_instituicao'] ? | ||
125 | - $_POST['ref_cod_instituicao'] : $_SESSION['calendario']['ref_cod_instituicao']; | 124 | + $this->ref_cod_instituicao = $_POST['ref_cod_instituicao'] ? |
125 | + $_POST['ref_cod_instituicao'] : $_SESSION['calendario']['ref_cod_instituicao']; | ||
126 | 126 | ||
127 | if ($_POST['mes']) { | 127 | if ($_POST['mes']) { |
128 | $this->mes = $_POST['mes']; | 128 | $this->mes = $_POST['mes']; |
@@ -131,19 +131,15 @@ class indice extends clsConfig | @@ -131,19 +131,15 @@ class indice extends clsConfig | ||
131 | if ($_POST['ano']) { | 131 | if ($_POST['ano']) { |
132 | $this->ano = $_POST['ano']; | 132 | $this->ano = $_POST['ano']; |
133 | } | 133 | } |
134 | - } | ||
135 | - else { | ||
136 | - if ($_GET){ | ||
137 | - // passa todos os valores obtidos no GET para atributos do objeto | ||
138 | - foreach($_GET as $var => $val) { | ||
139 | - $this->$var = ( $val === "" ) ? NULL: $val; | ||
140 | - } | 134 | + |
135 | + if ($_POST['cod_calendario_ano_letivo']) { | ||
136 | + $this->cod_calendario_ano_letivo = $_POST['cod_calendario_ano_letivo']; | ||
141 | } | 137 | } |
142 | - elseif ($_SESSION['calendario']) { | ||
143 | - // passa todos os valores em SESSION para atributos do objeto | ||
144 | - foreach ($_SESSION['calendario'] as $var => $val) { | ||
145 | - $this->$var = ($val === '') ? NULL : $val; | ||
146 | - } | 138 | + } |
139 | + elseif (isset($_SESSION['calendario'])) { | ||
140 | + // passa todos os valores em SESSION para atributos do objeto | ||
141 | + foreach ($_SESSION['calendario'] as $var => $val) { | ||
142 | + $this->$var = ($val === '') ? NULL : $val; | ||
147 | } | 143 | } |
148 | } | 144 | } |
149 | 145 | ||
@@ -159,49 +155,6 @@ class indice extends clsConfig | @@ -159,49 +155,6 @@ class indice extends clsConfig | ||
159 | $this->ano = date('Y'); | 155 | $this->ano = date('Y'); |
160 | } | 156 | } |
161 | 157 | ||
162 | - $obj_cal = new clsPmieducarCalendarioAnoLetivo(); | ||
163 | - | ||
164 | - if ($this->ref_cod_escola && $this->ano) { | ||
165 | - if ($obj_cal->lista(NULL, $this->ref_cod_escola, NULL, NULL, | ||
166 | - $this->ano, NULL, NULL, NULL, NULL, 1) | ||
167 | - ) { | ||
168 | - $_SESSION['calendario']['ultimo_valido'] = 1; | ||
169 | - | ||
170 | - if ($this->ref_cod_escola) { | ||
171 | - $_SESSION['calendario']['ref_cod_escola'] = $this->ref_cod_escola; | ||
172 | - } | ||
173 | - | ||
174 | - if ($this->ref_cod_instituicao) { | ||
175 | - $_SESSION['calendario']['ref_cod_instituicao'] = $this->ref_cod_instituicao; | ||
176 | - } | ||
177 | - | ||
178 | - if ($this->ano) { | ||
179 | - $_SESSION['calendario']['ano'] = $this->ano; | ||
180 | - } | ||
181 | - | ||
182 | - if ($this->mes) { | ||
183 | - $_SESSION['calendario']['mes'] = $this->mes; | ||
184 | - } | ||
185 | - } | ||
186 | - } | ||
187 | - elseif (! $_POST) { | ||
188 | - if ($_SESSION['calendario']['ref_cod_escola']) { | ||
189 | - $this->ref_cod_escola = $_SESSION["calendario"]["ref_cod_escola"]; | ||
190 | - } | ||
191 | - | ||
192 | - if ($_SESSION['calendario']['ref_cod_instituicao']) { | ||
193 | - $this->ref_cod_instituicao = $_SESSION['calendario']['ref_cod_instituicao']; | ||
194 | - } | ||
195 | - | ||
196 | - if ($_SESSION['calendario']['mes']) { | ||
197 | - $this->ano = $_SESSION['calendario']['mes']; | ||
198 | - } | ||
199 | - | ||
200 | - if ($_SESSION['calendario']['mes']) { | ||
201 | - $this->mes = $_SESSION['calendario']['mes']; | ||
202 | - } | ||
203 | - } | ||
204 | - | ||
205 | $nivel_usuario = $obj_permissoes->nivel_acesso($this->pessoa_logada); | 158 | $nivel_usuario = $obj_permissoes->nivel_acesso($this->pessoa_logada); |
206 | 159 | ||
207 | if (! $this->ref_cod_escola) { | 160 | if (! $this->ref_cod_escola) { |
@@ -234,22 +187,14 @@ class indice extends clsConfig | @@ -234,22 +187,14 @@ class indice extends clsConfig | ||
234 | } | 187 | } |
235 | 188 | ||
236 | $lista = $obj_calendario_ano_letivo->lista( | 189 | $lista = $obj_calendario_ano_letivo->lista( |
237 | - NULL, | 190 | + $this->cod_calendario_ano_letivo, |
238 | $this->ref_cod_escola, | 191 | $this->ref_cod_escola, |
239 | NULL, | 192 | NULL, |
240 | NULL, | 193 | NULL, |
241 | - $this->ano, | ||
242 | - NULL, | ||
243 | - NULL, | ||
244 | - 1, | ||
245 | - NULL, | ||
246 | - NULL, | 194 | + (!isset($this->cod_calendario_ano_letivo) ? $this->ano : NULL), |
247 | NULL, | 195 | NULL, |
248 | NULL, | 196 | NULL, |
249 | - NULL, | ||
250 | - NULL, | ||
251 | - NULL, | ||
252 | - NULL | 197 | + 1 |
253 | ); | 198 | ); |
254 | break; | 199 | break; |
255 | } | 200 | } |
@@ -270,33 +215,32 @@ class indice extends clsConfig | @@ -270,33 +215,32 @@ class indice extends clsConfig | ||
270 | } | 215 | } |
271 | } | 216 | } |
272 | 217 | ||
273 | - | ||
274 | // Monta a lista | 218 | // Monta a lista |
275 | if (is_array($lista) && count($lista)) { | 219 | if (is_array($lista) && count($lista)) { |
276 | foreach ($lista as $key => $registro) { | 220 | foreach ($lista as $key => $registro) { |
277 | - $registro['inicio_ano_letivo_time'] = strtotime(substr($registro['inicio_ano_letivo'], 0, 16)); | ||
278 | - $registro['inicio_ano_letivo_br'] = date('d/m/Y', $registro['inicio_ano_letivo_time']); | ||
279 | - $registro['termino_ano_letivo_time'] = strtotime(substr($registro['termino_ano_letivo'], 0, 16)); | ||
280 | - $registro['termino_ano_letivo_br'] = date('d/m/Y', $registro['termino_ano_letivo_time']); | ||
281 | - | ||
282 | - // Pega detalhes de foreign_keys | ||
283 | - if (class_exists('clsPmieducarEscola')) { | ||
284 | - $obj_ref_cod_escola = new clsPmieducarEscola($registro['ref_cod_escola']); | ||
285 | - $det_ref_cod_escola = $obj_ref_cod_escola->detalhe(); | ||
286 | - $registro['nm_escola'] = $det_ref_cod_escola['nome']; | ||
287 | - } | ||
288 | - else { | ||
289 | - $registro['ref_cod_escola'] = 'Erro na geração'; | ||
290 | - } | 221 | + // Guarda dados na $_SESSION |
222 | + $_SESSION['calendario'] = array( | ||
223 | + 'cod_calendario_ano_letivo' => $registro['cod_calendario_ano_letivo'], | ||
224 | + 'ref_cod_instituicao' => $this->ref_cod_instituicao, | ||
225 | + 'ref_cod_escola' => $this->ref_cod_escola, | ||
226 | + 'ano' => $this->ano, | ||
227 | + 'mes' => $this->mes | ||
228 | + ); | ||
291 | 229 | ||
230 | + // Nome da escola | ||
231 | + $obj_ref_cod_escola = new clsPmieducarEscola($registro['ref_cod_escola']); | ||
232 | + $det_ref_cod_escola = $obj_ref_cod_escola->detalhe(); | ||
233 | + $registro['nm_escola'] = $det_ref_cod_escola['nome']; | ||
234 | + | ||
235 | + // Início e término do ano letivo. | ||
292 | $obj_ano_letivo_modulo = new clsPmieducarAnoLetivoModulo(); | 236 | $obj_ano_letivo_modulo = new clsPmieducarAnoLetivoModulo(); |
293 | 237 | ||
294 | $inicio_ano = $obj_ano_letivo_modulo->menorData( | 238 | $inicio_ano = $obj_ano_letivo_modulo->menorData( |
295 | - $this->ano, $this->ref_cod_escola | 239 | + $registro['ano'], $this->ref_cod_escola |
296 | ); | 240 | ); |
297 | 241 | ||
298 | $fim_ano = $obj_ano_letivo_modulo->maiorData( | 242 | $fim_ano = $obj_ano_letivo_modulo->maiorData( |
299 | - $this->ano, $this->ref_cod_escola | 243 | + $registro['ano'], $this->ref_cod_escola |
300 | ); | 244 | ); |
301 | 245 | ||
302 | $inicio_ano = explode('/', dataFromPgToBr($inicio_ano)); | 246 | $inicio_ano = explode('/', dataFromPgToBr($inicio_ano)); |
@@ -391,12 +335,12 @@ class indice extends clsConfig | @@ -391,12 +335,12 @@ class indice extends clsConfig | ||
391 | } | 335 | } |
392 | 336 | ||
393 | if ($this->mes <= (int) $inicio_ano[1] && $this->ano == (int) $inicio_ano[2]) { | 337 | if ($this->mes <= (int) $inicio_ano[1] && $this->ano == (int) $inicio_ano[2]) { |
394 | - if ($this->mes == (int)$inicio_ano[1] ){ | 338 | + if ($this->mes == (int) $inicio_ano[1]) { |
395 | $obj_calendario->adicionarLegenda('Início Ano Letivo', 'AMARELO'); | 339 | $obj_calendario->adicionarLegenda('Início Ano Letivo', 'AMARELO'); |
396 | $obj_calendario->adicionarArrayDias('Início Ano Letivo', array($inicio_ano[0])); | 340 | $obj_calendario->adicionarArrayDias('Início Ano Letivo', array($inicio_ano[0])); |
397 | } | 341 | } |
398 | 342 | ||
399 | - $dia_inicio = (int)$inicio_ano[0]; | 343 | + $dia_inicio = (int) $inicio_ano[0]; |
400 | $dias = array(); | 344 | $dias = array(); |
401 | 345 | ||
402 | if ($this->mes < (int) $inicio_ano[1]) { | 346 | if ($this->mes < (int) $inicio_ano[1]) { |
@@ -414,6 +358,7 @@ class indice extends clsConfig | @@ -414,6 +358,7 @@ class indice extends clsConfig | ||
414 | } | 358 | } |
415 | else { | 359 | else { |
416 | $dia_inicio; | 360 | $dia_inicio; |
361 | + | ||
417 | for ($d = 1 ; $d < $dia_inicio ; $d++) { | 362 | for ($d = 1 ; $d < $dia_inicio ; $d++) { |
418 | $dias[] = $d; | 363 | $dias[] = $d; |
419 | } | 364 | } |
@@ -470,7 +415,7 @@ class indice extends clsConfig | @@ -470,7 +415,7 @@ class indice extends clsConfig | ||
470 | 415 | ||
471 | $obj_anotacao = new clsPmieducarCalendarioDiaAnotacao(); | 416 | $obj_anotacao = new clsPmieducarCalendarioDiaAnotacao(); |
472 | $lista_anotacoes = $obj_anotacao->lista( | 417 | $lista_anotacoes = $obj_anotacao->lista( |
473 | - NULL, $this->mes,$registro['cod_calendario_ano_letivo'], NULL, 1 | 418 | + NULL, $this->mes, $registro['cod_calendario_ano_letivo'], NULL, 1 |
474 | ); | 419 | ); |
475 | 420 | ||
476 | if ($lista_anotacoes) { | 421 | if ($lista_anotacoes) { |
@@ -489,8 +434,10 @@ class indice extends clsConfig | @@ -489,8 +434,10 @@ class indice extends clsConfig | ||
489 | $registro['cod_calendario_ano_letivo'] | 434 | $registro['cod_calendario_ano_letivo'] |
490 | ); | 435 | ); |
491 | 436 | ||
437 | + // Gera código HTML do calendário | ||
492 | $calendario = $obj_calendario->getCalendario( | 438 | $calendario = $obj_calendario->getCalendario( |
493 | - $this->mes, $registro['ano'], 'mes_corrente', $_GET | 439 | + $this->mes, $this->ano, 'mes_corrente', $_GET, |
440 | + array('cod_calendario_ano_letivo' => $registro['cod_calendario_ano_letivo']) | ||
494 | ); | 441 | ); |
495 | 442 | ||
496 | $retorno .= sprintf( | 443 | $retorno .= sprintf( |
ieducar/intranet/scripts/calendario.js
@@ -278,10 +278,10 @@ function tamanhoTela() | @@ -278,10 +278,10 @@ function tamanhoTela() | ||
278 | 278 | ||
279 | function acaoCalendario(nome, dia, mes, ano) | 279 | function acaoCalendario(nome, dia, mes, ano) |
280 | { | 280 | { |
281 | - document.getElementById('nome').value = nome; | ||
282 | - document.getElementById('dia').value = dia; | ||
283 | - document.getElementById('mes').value = mes; | ||
284 | - document.form_calendario.ano.value = ano; | 281 | + document.getElementById('cal_nome').value = nome; |
282 | + document.getElementById('cal_dia').value = dia; | ||
283 | + document.getElementById('cal_mes').value = mes; | ||
284 | + document.getElementById('cal_ano').value = ano; | ||
285 | 285 | ||
286 | - document.form_calendario.submit(); | 286 | + document.getElementById('form_calendario').submit(); |
287 | } | 287 | } |
288 | \ No newline at end of file | 288 | \ No newline at end of file |
@@ -0,0 +1,45 @@ | @@ -0,0 +1,45 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package App_Date | ||
27 | + * @since Arquivo disponível desde a versão 1.2.0 | ||
28 | + * @version $Id$ | ||
29 | + */ | ||
30 | + | ||
31 | +require_once 'CoreExt/Exception.php'; | ||
32 | + | ||
33 | +/** | ||
34 | + * App_Date_Exception class. | ||
35 | + * | ||
36 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
37 | + * @category i-Educar | ||
38 | + * @license @@license@@ | ||
39 | + * @package App_Date | ||
40 | + * @since Classe disponível desde a versão 1.2.0 | ||
41 | + * @version @@package_version@@ | ||
42 | + */ | ||
43 | +class App_Date_Exception extends CoreExt_Exception | ||
44 | +{ | ||
45 | +} | ||
0 | \ No newline at end of file | 46 | \ No newline at end of file |
@@ -0,0 +1,92 @@ | @@ -0,0 +1,92 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package App_Date | ||
27 | + * @since Arquivo disponível desde a versão 1.1.0 | ||
28 | + * @version $Id$ | ||
29 | + */ | ||
30 | + | ||
31 | +require_once 'App/Date/Exception.php'; | ||
32 | + | ||
33 | +/** | ||
34 | + * App_Date_Utils class. | ||
35 | + * | ||
36 | + * Possui métodos | ||
37 | + * | ||
38 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
39 | + * @category i-Educar | ||
40 | + * @license @@license@@ | ||
41 | + * @package App_Date | ||
42 | + * @since Classe disponível desde a versão 1.2.0 | ||
43 | + * @version @@package_version@@ | ||
44 | + */ | ||
45 | +class App_Date_Utils | ||
46 | +{ | ||
47 | + /** | ||
48 | + * Retorna o ano de uma string nos formatos dd/mm/yyyy e dd/mm/yyyy hh:ii:ss. | ||
49 | + * @param string $date | ||
50 | + * @param int | ||
51 | + */ | ||
52 | + public static function getYear($date) | ||
53 | + { | ||
54 | + $parts = explode('/', $date); | ||
55 | + $year = explode(' ', $parts[2]); | ||
56 | + | ||
57 | + if (is_array($year)) { | ||
58 | + $year = $year[0]; | ||
59 | + } | ||
60 | + | ||
61 | + return (int) $year; | ||
62 | + } | ||
63 | + | ||
64 | + /** | ||
65 | + * Verifica se ao menos uma das datas de um array é do ano especificado. | ||
66 | + * @param array $dates Datas nos formatos dd/mm/yyyy [hh:ii:ss]. | ||
67 | + * @param int $year Ano esperado. | ||
68 | + * @param int $at Quantidade mínima de datas esperadas no ano $year. | ||
69 | + * @return bool TRUE se ao menos uma das datas estiver no ano esperado. | ||
70 | + * @throws App_Date_Exception | ||
71 | + */ | ||
72 | + public static function datesYearAtLeast(array $dates, $year, $at = 1) | ||
73 | + { | ||
74 | + $matches = 0; | ||
75 | + | ||
76 | + foreach ($dates as $date) { | ||
77 | + $dateYear = self::getYear($date); | ||
78 | + if ($year == $dateYear) { | ||
79 | + $matches++; | ||
80 | + } | ||
81 | + } | ||
82 | + | ||
83 | + if ($matches >= $at) { | ||
84 | + return TRUE; | ||
85 | + } | ||
86 | + | ||
87 | + throw new App_Date_Exception(sprintf( | ||
88 | + 'Ao menos "%d" das datas informadas deve ser do ano "%d". Datas: "%s".', | ||
89 | + $at, $year, implode('", "', $dates) | ||
90 | + )); | ||
91 | + } | ||
92 | +} | ||
0 | \ No newline at end of file | 93 | \ No newline at end of file |
ieducar/tests/unit/App/AllTests.php
@@ -29,6 +29,7 @@ | @@ -29,6 +29,7 @@ | ||
29 | * @version $Id$ | 29 | * @version $Id$ |
30 | */ | 30 | */ |
31 | 31 | ||
32 | +require_once 'App/Date/AllTests.php'; | ||
32 | require_once 'App/Model/AllTests.php'; | 33 | require_once 'App/Model/AllTests.php'; |
33 | require_once 'App/Service/AllTests.php'; | 34 | require_once 'App/Service/AllTests.php'; |
34 | 35 | ||
@@ -50,6 +51,7 @@ class App_AllTests | @@ -50,6 +51,7 @@ class App_AllTests | ||
50 | public static function suite() | 51 | public static function suite() |
51 | { | 52 | { |
52 | $suite = new PHPUnit_Framework_TestSuite('Suíte de testes unitários de App'); | 53 | $suite = new PHPUnit_Framework_TestSuite('Suíte de testes unitários de App'); |
54 | + $suite->addTest(App_Date_AllTests::suite()); | ||
53 | $suite->addTest(App_Model_AllTests::suite()); | 55 | $suite->addTest(App_Model_AllTests::suite()); |
54 | $suite->addTest(App_Service_AllTests::suite()); | 56 | $suite->addTest(App_Service_AllTests::suite()); |
55 | return $suite; | 57 | return $suite; |
@@ -0,0 +1,55 @@ | @@ -0,0 +1,55 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package App_Model | ||
27 | + * @subpackage UnitTests | ||
28 | + * @since Arquivo disponível desde a versão 1.2.0 | ||
29 | + * @version $Id$ | ||
30 | + */ | ||
31 | + | ||
32 | +/** | ||
33 | + * App_Date_AllTests class. | ||
34 | + * | ||
35 | + * Arquivo de definição de suíte para o pacote App_Date. | ||
36 | + * | ||
37 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
38 | + * @category i-Educar | ||
39 | + * @license @@license@@ | ||
40 | + * @package App_Date | ||
41 | + * @subpackage UnitTests | ||
42 | + * @since Classe disponível desde a versão 1.2.0 | ||
43 | + * @version @@package_version@@ | ||
44 | + */ | ||
45 | +class App_Date_AllTests extends TestCollector | ||
46 | +{ | ||
47 | + protected $_name = 'Suíte de testes unitários de App_Date'; | ||
48 | + protected $_file = __FILE__; | ||
49 | + | ||
50 | + public static function suite() | ||
51 | + { | ||
52 | + $instance = new self(); | ||
53 | + return $instance->addDirectoryTests(); | ||
54 | + } | ||
55 | +} | ||
0 | \ No newline at end of file | 56 | \ No newline at end of file |
@@ -0,0 +1,71 @@ | @@ -0,0 +1,71 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package App_Date | ||
27 | + * @subpackage UnitTests | ||
28 | + * @since Arquivo disponível desde a versão 1.2.0 | ||
29 | + * @version $Id$ | ||
30 | + */ | ||
31 | + | ||
32 | +require_once 'App/Date/Utils.php'; | ||
33 | + | ||
34 | +/** | ||
35 | + * App_Date_UtilsTest class. | ||
36 | + * | ||
37 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
38 | + * @category i-Educar | ||
39 | + * @license @@license@@ | ||
40 | + * @package App_Date | ||
41 | + * @subpackage UnitTests | ||
42 | + * @since Classe disponível desde a versão 1.2.0 | ||
43 | + * @version @@package_version@@ | ||
44 | + */ | ||
45 | +class App_Date_UtilsTest extends UnitBaseTest | ||
46 | +{ | ||
47 | + public function testDatesYearAtLeast() | ||
48 | + { | ||
49 | + $dates = array( | ||
50 | + '01/01/2000', | ||
51 | + '01/02/2000' | ||
52 | + ); | ||
53 | + | ||
54 | + try { | ||
55 | + App_Date_Utils::datesYearAtLeast($dates, 2001, 1); | ||
56 | + $this->fail('::datesYearAtLeast() deveria lançar App_Date_Exception.'); | ||
57 | + } | ||
58 | + catch (App_Date_Exception $e) { | ||
59 | + $this->assertEquals( | ||
60 | + 'Ao menos "1" das datas informadas deve ser do ano "2001". Datas: "01/01/2000", "01/02/2000".', | ||
61 | + $e->getMessage(), | ||
62 | + '' | ||
63 | + ); | ||
64 | + } | ||
65 | + | ||
66 | + $this->assertTrue( | ||
67 | + App_Date_Utils::datesYearAtLeast($dates, 2000, 2), | ||
68 | + '::datesYearAtLeast() retorna "TRUE" quando uma das datas é do ano esperado.' | ||
69 | + ); | ||
70 | + } | ||
71 | +} | ||
0 | \ No newline at end of file | 72 | \ No newline at end of file |
@@ -0,0 +1,64 @@ | @@ -0,0 +1,64 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package Core | ||
27 | + * @subpackage UnitTests | ||
28 | + * @since Arquivo disponível desde a versão 1.2.0 | ||
29 | + * @version $Id$ | ||
30 | + */ | ||
31 | + | ||
32 | +require_once 'clsCalendario.inc.php'; | ||
33 | + | ||
34 | +/** | ||
35 | + * ClsCalendarioTest class. | ||
36 | + * | ||
37 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | ||
38 | + * @category i-Educar | ||
39 | + * @license @@license@@ | ||
40 | + * @package Ied_Include | ||
41 | + * @subpackage UnitTests | ||
42 | + * @since Classe disponível desde a versão 1.2.0 | ||
43 | + * @todo Mover para diretório Ied | ||
44 | + * @version @@package_version@@ | ||
45 | + */ | ||
46 | +class ClsCalendarioTest extends UnitBaseTest | ||
47 | +{ | ||
48 | + public function testGenerateFormValues() | ||
49 | + { | ||
50 | + $formValues = array( | ||
51 | + 'formFieldKey' => 'formFieldValue' | ||
52 | + ); | ||
53 | + | ||
54 | + $calendario = new clsCalendario(); | ||
55 | + | ||
56 | + // Teste sem permissão de troca de ano | ||
57 | + $html = $calendario->getCalendario(1, 2000, 'testGenerateFormValues', array(), $formValues); | ||
58 | + | ||
59 | + $this->assertRegExp( | ||
60 | + '/<input id="cal_formFieldKey" name="formFieldKey" type="hidden" value="formFieldValue" \/>/', | ||
61 | + $html, '->getCalendario() gera campos extras de formulário.' | ||
62 | + ); | ||
63 | + } | ||
64 | +} | ||
0 | \ No newline at end of file | 65 | \ No newline at end of file |