Commit 976db410233414dd4a1d2eca31dfdf8935e72884

Authored by Eriksen Costa
1 parent 6f07a95c
Exists in master

Atualizado CRUD de aluno para conter opções de cadastro de transporte escolar

ieducar/intranet/educar_aluno_cad.php
@@ -33,7 +33,10 @@ require_once 'include/clsCadastro.inc.php'; @@ -33,7 +33,10 @@ 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/Model/SimNao.php';
36 require_once 'App/Model/ZonaLocalizacao.php'; 37 require_once 'App/Model/ZonaLocalizacao.php';
  38 +require_once 'Transporte/Model/AlunoDataMapper.php';
  39 +require_once 'Transporte/Model/Responsavel.php';
37 40
38 /** 41 /**
39 * clsIndexBase class. 42 * clsIndexBase class.
@@ -702,6 +705,26 @@ class indice extends clsCadastro @@ -702,6 +705,26 @@ class indice extends clsCadastro
702 705
703 $this->campoQuebra2('#224488'); 706 $this->campoQuebra2('#224488');
704 707
  708 + // Transporte escolar
  709 + $transporteMapper = new Transporte_Model_AlunoDataMapper();
  710 + $transporte = NULL;
  711 +
  712 + try {
  713 + $transporte = $transporteMapper->find(array($this->cod_aluno));
  714 + }
  715 + catch (Exception $e) {
  716 + }
  717 +
  718 + $bit = App_Model_SimNao::getInstance();
  719 + $this->campoLista('transporte_aluno', 'Transporte', $bit->getEnums(),
  720 + !is_null($transporte) ? 1 : 0, 'transporteResponsavel();');
  721 +
  722 + $responsavel = Transporte_Model_Responsavel::getInstance();
  723 + $this->campoLista('transporte_responsavel', 'Responsável', $responsavel->getEnums(),
  724 + !is_null($transporte) ? $transporte->get('responsavel') : 0);
  725 +
  726 + $this->campoQuebra2('#224488');
  727 +
705 $obj_beneficio = new clsPmieducarAlunoBeneficio(); 728 $obj_beneficio = new clsPmieducarAlunoBeneficio();
706 $obj_beneficio_lista = $obj_beneficio->lista(NULL, NULL, NULL, NULL, NULL, 729 $obj_beneficio_lista = $obj_beneficio->lista(NULL, NULL, NULL, NULL, NULL,
707 NULL, NULL, NULL, NULL, 1); 730 NULL, NULL, NULL, NULL, 1);
@@ -1611,10 +1634,11 @@ class indice extends clsCadastro @@ -1611,10 +1634,11 @@ class indice extends clsCadastro
1611 1634
1612 if ($this->ref_idpes) { 1635 if ($this->ref_idpes) {
1613 if ($obj->existePessoa()) { 1636 if ($obj->existePessoa()) {
1614 - $obj->edita(); 1637 + $aluno = $obj->edita();
  1638 + $this->cod_aluno = $aluno['cod_aluno'];
1615 } 1639 }
1616 else { 1640 else {
1617 - $obj->cadastra(); 1641 + $this->cod_aluno = $obj->cadastra();
1618 } 1642 }
1619 } 1643 }
1620 } 1644 }
@@ -1634,6 +1658,10 @@ class indice extends clsCadastro @@ -1634,6 +1658,10 @@ class indice extends clsCadastro
1634 } 1658 }
1635 } 1659 }
1636 1660
  1661 + // Atualiza a informação de uso de transporte escolar.
  1662 + $this->_cadastraTransporte($this->cod_aluno, $this->transporte_aluno,
  1663 + $this->transporte_responsavel, $this->pessoa_logada);
  1664 +
1637 header('Location: educar_aluno_det.php?cod_aluno=' . $this->cod_aluno); 1665 header('Location: educar_aluno_det.php?cod_aluno=' . $this->cod_aluno);
1638 die(); 1666 die();
1639 } 1667 }
@@ -1765,6 +1793,53 @@ class indice extends clsCadastro @@ -1765,6 +1793,53 @@ class indice extends clsCadastro
1765 1793
1766 return $nome_do_arquivo; 1794 return $nome_do_arquivo;
1767 } 1795 }
  1796 +
  1797 + /**
  1798 + * Cadastra ou atualiza a informação de uso de transporte escolar.
  1799 + *
  1800 + * @access protected
  1801 + * @param int $codAluno Código do aluno
  1802 + * @param bool $transporte [Opcional] TRUE para cadastrar/atualizar e FALSE
  1803 + * para remover a informação de uso de transporte escolar
  1804 + * @param int $responsavel [Opcional] Código do responsável pelo transporte
  1805 + * escolar, valor mapeado para o enum Transporte_Model_Responsavel. Apenas
  1806 + * obrigatório caso $transporte = TRUE
  1807 + * @param int $user Código do usuário a alterar o registroo
  1808 + * @return bool TRUE caso tenha criado/editado/apagado o registro com sucesso
  1809 + * @since Método disponível desde a versão 1.2.0
  1810 + */
  1811 + function _cadastraTransporte($codAluno, $transporte = TRUE, $responsavel = NULL,
  1812 + $user)
  1813 + {
  1814 + $data = array(
  1815 + 'aluno' => $codAluno,
  1816 + 'responsavel' => $responsavel,
  1817 + 'user' => $user,
  1818 + 'created_at' => 'NOW()'
  1819 + );
  1820 +
  1821 + $transporteMapper = new Transporte_Model_AlunoDataMapper();
  1822 +
  1823 + if ($transporte) {
  1824 + if (is_null($responsavel)) {
  1825 + return FALSE;
  1826 + }
  1827 +
  1828 + try {
  1829 + $transporteMapper->find(array('aluno' => $codAluno));
  1830 + }
  1831 + catch (Exception $e) {
  1832 + $transporteMapper->save(
  1833 + $transporteMapper->createNewEntityInstance($data)
  1834 + );
  1835 + }
  1836 + }
  1837 + else {
  1838 + $transporteMapper->delete(array('aluno' => $codAluno));
  1839 + }
  1840 +
  1841 + return TRUE;
  1842 + }
1768 } 1843 }
1769 1844
1770 // Instancia objeto de página 1845 // Instancia objeto de página
@@ -2083,4 +2158,18 @@ if (!$_GET['cod_aluno']) { @@ -2083,4 +2158,18 @@ if (!$_GET['cod_aluno']) {
2083 } 2158 }
2084 /** Javascript condicional */ 2159 /** Javascript condicional */
2085 ?> 2160 ?>
  2161 +Event.observe(window, 'load', transporteResponsavel, false);
  2162 +
  2163 +function transporteResponsavel()
  2164 +{
  2165 + obj1 = document.getElementById('transporte_aluno');
  2166 + obj2 = document.getElementById('transporte_responsavel');
  2167 +
  2168 + if (obj1.value == 1) {
  2169 + obj2.disabled = false;
  2170 + }
  2171 + else {
  2172 + obj2.disabled = true;
  2173 + }
  2174 +}
2086 </script> 2175 </script>
2087 \ No newline at end of file 2176 \ No newline at end of file
ieducar/intranet/educar_aluno_det.php
@@ -34,6 +34,7 @@ require_once &#39;include/clsBanco.inc.php&#39;; @@ -34,6 +34,7 @@ require_once &#39;include/clsBanco.inc.php&#39;;
34 require_once 'include/pmieducar/geral.inc.php'; 34 require_once 'include/pmieducar/geral.inc.php';
35 35
36 require_once 'App/Model/ZonaLocalizacao.php'; 36 require_once 'App/Model/ZonaLocalizacao.php';
  37 +require_once 'Transporte/Model/AlunoDataMapper.php';
37 38
38 /** 39 /**
39 * clsIndexBase class. 40 * clsIndexBase class.
@@ -610,6 +611,20 @@ class indice extends clsDetalhe @@ -610,6 +611,20 @@ class indice extends clsDetalhe
610 )); 611 ));
611 } 612 }
612 613
  614 + // Transporte escolar.
  615 + $transporteMapper = new Transporte_Model_AlunoDataMapper();
  616 + $transporteAluno = NULL;
  617 + try {
  618 + $transporteAluno = $transporteMapper->find(array('aluno' => $this->cod_aluno));
  619 + }
  620 + catch (Exception $e) {
  621 + }
  622 +
  623 + $this->addDetalhe(array('Transporte escolar', isset($transporteAluno) ? 'Sim' : 'Não'));
  624 + if ($transporteAluno) {
  625 + $this->addDetalhe(array('Responsável transporte', $transporteAluno->responsavel));
  626 + }
  627 +
613 $this->addDetalhe(array('Matrícula', $this->montaTabelaMatricula())); 628 $this->addDetalhe(array('Matrícula', $this->montaTabelaMatricula()));
614 629
615 // Verificação de permissão para cadastro. 630 // Verificação de permissão para cadastro.