Commit ad64726cfec4c83d2cb46cf3f08292bfe2e1a428

Authored by Lucas Schmoeller da Silva
1 parent b32808eb
Exists in master

Criado controle de fechamento de turma e ordenação

portabilis/ieducar#114
ieducar/intranet/educar_turma_cad.php
... ... @@ -33,6 +33,7 @@ require_once 'include/clsCadastro.inc.php';
33 33 require_once 'include/clsBanco.inc.php';
34 34 require_once 'include/pmieducar/geral.inc.php';
35 35 require_once 'Portabilis/String/Utils.php';
  36 +require_once 'lib/Portabilis/Date/Utils.php';
36 37  
37 38 /**
38 39 * clsIndexBase class.
... ... @@ -85,6 +86,7 @@ class indice extends clsCadastro
85 86 var $hora_final;
86 87 var $hora_inicio_intervalo;
87 88 var $hora_fim_intervalo;
  89 + var $data_fechamento;
88 90  
89 91 var $ref_cod_instituicao;
90 92 var $ref_cod_curso;
... ... @@ -319,6 +321,8 @@ class indice extends clsCadastro
319 321  
320 322 $this->campoNumero('max_aluno', 'Máximo de Alunos', $this->max_aluno, 3, 3, TRUE);
321 323  
  324 + $this->inputsHelper()->date('data_fechamento', array('required' => false,'label' => 'Data de fechamento' ,'value' => Portabilis_Date_Utils::pgSQLToBr($this->data_fechamento)));
  325 +
322 326 $ativo = isset($this->cod_turma) ? dbBool($this->visivel) : true;
323 327 $this->campoCheck('visivel', 'Ativo', $ativo);
324 328  
... ... @@ -672,6 +676,8 @@ class indice extends clsCadastro
672 676 $this->pessoa_logada = $_SESSION['id_pessoa'];
673 677 @session_write_close();
674 678  
  679 + $this->data_fechamento = Portabilis_Date_Utils::brToPgSQL($this->data_fechamento);
  680 +
675 681 if(! $this->canCreateTurma($this->ref_cod_escola, $this->ref_ref_cod_serie, $this->turma_turno_id))
676 682 return false;
677 683  
... ... @@ -705,7 +711,7 @@ class indice extends clsCadastro
705 711 $this->hora_inicio_intervalo, $this->hora_fim_intervalo, $this->ref_cod_regente,
706 712 $this->ref_cod_instituicao_regente, $this->ref_cod_instituicao,
707 713 $this->ref_cod_curso, $this->ref_ref_cod_serie_mult, $this->ref_cod_escola,
708   - $this->visivel, $this->turma_turno_id, $this->tipo_boletim, $this->ano);
  714 + $this->visivel, $this->turma_turno_id, $this->tipo_boletim, $this->ano, $this->data_fechamento);
709 715  
710 716 $cadastrou = $obj->cadastra();
711 717  
... ... @@ -772,7 +778,7 @@ class indice extends clsCadastro
772 778 $this->ref_cod_regente, $this->ref_cod_instituicao_regente,
773 779 $this->ref_cod_instituicao, $this->ref_cod_curso,
774 780 $this->ref_ref_cod_serie_mult, $this->ref_cod_escola, $this->visivel,
775   - $this->turma_turno_id, $this->tipo_boletim, $this->ano);
  781 + $this->turma_turno_id, $this->tipo_boletim, $this->ano, $this->data_fechamento);
776 782  
777 783 $cadastrou = $obj->cadastra();
778 784  
... ... @@ -801,6 +807,8 @@ class indice extends clsCadastro
801 807 $this->pessoa_logada = $_SESSION['id_pessoa'];
802 808 @session_write_close();
803 809  
  810 + $this->data_fechamento = Portabilis_Date_Utils::brToPgSQL($this->data_fechamento);
  811 +
804 812 if(is_numeric($this->ano_hidden))
805 813 $this->ano = $this->ano_hidden;
806 814  
... ... @@ -837,7 +845,7 @@ class indice extends clsCadastro
837 845 $this->visivel,
838 846 $this->turma_turno_id,
839 847 $this->tipo_boletim,
840   - $this->ano);
  848 + $this->ano, $this->data_fechamento);
841 849  
842 850 $editou = $obj->edita();
843 851  
... ... @@ -908,7 +916,7 @@ class indice extends clsCadastro
908 916 $this->hora_inicio_intervalo, $this->hora_fim_intervalo, $this->ref_cod_regente,
909 917 $this->ref_cod_instituicao_regente, $this->ref_cod_instituicao,
910 918 $this->ref_cod_curso, $this->ref_ref_cod_serie_mult, $this->ref_cod_escola,
911   - $this->visivel, $this->turma_turno_id, $this->tipo_boletim, $this->ano);
  919 + $this->visivel, $this->turma_turno_id, $this->tipo_boletim, $this->ano, $this->data_fechamento);
912 920  
913 921 $editou = $obj->edita();
914 922 }
... ...
ieducar/intranet/include/pmieducar/clsPmieducarMatriculaTurma.inc.php
... ... @@ -51,6 +51,7 @@ class clsPmieducarMatriculaTurma
51 51 var $ativo;
52 52 var $ref_cod_turma_transf;
53 53 var $sequencial;
  54 + var $sequencial_fechamento;
54 55  
55 56 /**
56 57 * Armazena o total de resultados obtidos na última chamada ao método lista().
... ... @@ -294,6 +295,14 @@ class clsPmieducarMatriculaTurma
294 295 $campos .= "{$gruda}data_enturmacao";
295 296 $valores .= "{$gruda}'{$this->data_enturmacao}'";
296 297 $gruda = ", ";
  298 + }
  299 +
  300 + $this->sequencial_fechamento = $this->getSequencialFechamento($this->ref_cod_matricula, $this->ref_cod_turma, $this->data_enturmacao);
  301 +
  302 + if(is_numeric($this->sequencial_fechamento)){
  303 + $campos .= "{$gruda}sequencial_fechamento";
  304 + $valores .= "{$gruda}'{$this->sequencial_fechamento}'";
  305 + $gruda = ", ";
297 306 }
298 307  
299 308 $db->Consulta("INSERT INTO {$this->_tabela} ($campos) VALUES ($valores)");
... ... @@ -1269,4 +1278,15 @@ class clsPmieducarMatriculaTurma
1269 1278  
1270 1279 return FALSE;
1271 1280 }
  1281 + function getSequencialFechamento($matriculaId, $turmaId, $dataEnturmacao){
  1282 + $db = new clsBanco();
  1283 + $possui_fechamento = $db->CampoUnico("SELECT data_fechamento FROM pmieducar.turma WHERE cod_turma = {$turmaId}");
  1284 + if (is_string($possui_fechamento)){
  1285 + if (strtotime($possui_fechamento) < strtotime($dataEnturmacao))
  1286 + return $db->CampoUnico("SELECT MAX(sequencial_fechamento)+1 FROM {$this->_tabela} where ref_cod_turma = {$turmaId}");
  1287 + else
  1288 + return 0;
  1289 + }else
  1290 + return 0;
  1291 + }
1272 1292 }
... ...
ieducar/intranet/include/pmieducar/clsPmieducarTurma.inc.php
... ... @@ -54,14 +54,15 @@ class clsPmieducarTurma
54 54 var $hora_fim_intervalo;
55 55  
56 56 var $ref_cod_regente;
57   - var $ref_cod_instituicao_regente;
  57 + var $ref_cod_instituicao_regente;
58 58  
59   - var $ref_cod_instituicao;
60   - var $ref_cod_curso;
  59 + var $ref_cod_instituicao;
  60 + var $ref_cod_curso;
61 61  
62   - var $ref_ref_cod_serie_mult;
63   - var $ref_ref_cod_escola_mult;
64   - var $visivel;
  62 + var $ref_ref_cod_serie_mult;
  63 + var $ref_ref_cod_escola_mult;
  64 + var $visivel;
  65 + var $data_fechamento;
65 66 // propriedades padrao
66 67  
67 68 /**
... ... @@ -126,13 +127,13 @@ class clsPmieducarTurma
126 127 *
127 128 * @return object
128 129 */
129   - function clsPmieducarTurma( $cod_turma = null, $ref_usuario_exc = null, $ref_usuario_cad = null, $ref_ref_cod_serie = null, $ref_ref_cod_escola = null, $ref_cod_infra_predio_comodo = null, $nm_turma = null, $sgl_turma = null, $max_aluno = null, $multiseriada = null, $data_cadastro = null, $data_exclusao = null, $ativo = null, $ref_cod_turma_tipo = null, $hora_inicial = null, $hora_final = null, $hora_inicio_intervalo = null, $hora_fim_intervalo = null, $ref_cod_regente = null, $ref_cod_instituicao_regente = null, $ref_cod_instituicao = null, $ref_cod_curso = null, $ref_ref_cod_serie_mult = null, $ref_ref_cod_escola_mult = null, $visivel = null, $turma_turno_id = null, $tipo_boletim = null, $ano = null)
130   - {
  130 + function clsPmieducarTurma( $cod_turma = null, $ref_usuario_exc = null, $ref_usuario_cad = null, $ref_ref_cod_serie = null, $ref_ref_cod_escola = null, $ref_cod_infra_predio_comodo = null, $nm_turma = null, $sgl_turma = null, $max_aluno = null, $multiseriada = null, $data_cadastro = null, $data_exclusao = null, $ativo = null, $ref_cod_turma_tipo = null, $hora_inicial = null, $hora_final = null, $hora_inicio_intervalo = null, $hora_fim_intervalo = null, $ref_cod_regente = null, $ref_cod_instituicao_regente = null, $ref_cod_instituicao = null, $ref_cod_curso = null, $ref_ref_cod_serie_mult = null, $ref_ref_cod_escola_mult = null, $visivel = null, $turma_turno_id = null, $tipo_boletim = null, $ano = null, $data_fechamento = NULL)
  131 + {
131 132 $db = new clsBanco();
132 133 $this->_schema = "pmieducar.";
133 134 $this->_tabela = "{$this->_schema}turma";
134 135  
135   - $this->_campos_lista = $this->_todos_campos = "t.cod_turma, t.ref_usuario_exc, t.ref_usuario_cad, t.ref_ref_cod_serie, t.ref_ref_cod_escola, t.ref_cod_infra_predio_comodo, t.nm_turma, t.sgl_turma, t.max_aluno, t.multiseriada, t.data_cadastro, t.data_exclusao, t.ativo, t.ref_cod_turma_tipo, t.hora_inicial, t.hora_final, t.hora_inicio_intervalo, t.hora_fim_intervalo, t.ref_cod_regente, t.ref_cod_instituicao_regente,t.ref_cod_instituicao, t.ref_cod_curso, t.ref_ref_cod_serie_mult, t.ref_ref_cod_escola_mult, t.visivel, t.turma_turno_id, t.tipo_boletim, t.ano";
  136 + $this->_campos_lista = $this->_todos_campos = "t.cod_turma, t.ref_usuario_exc, t.ref_usuario_cad, t.ref_ref_cod_serie, t.ref_ref_cod_escola, t.ref_cod_infra_predio_comodo, t.nm_turma, t.sgl_turma, t.max_aluno, t.multiseriada, t.data_cadastro, t.data_exclusao, t.ativo, t.ref_cod_turma_tipo, t.hora_inicial, t.hora_final, t.hora_inicio_intervalo, t.hora_fim_intervalo, t.ref_cod_regente, t.ref_cod_instituicao_regente,t.ref_cod_instituicao, t.ref_cod_curso, t.ref_ref_cod_serie_mult, t.ref_ref_cod_escola_mult, t.visivel, t.turma_turno_id, t.tipo_boletim, t.ano, t.data_fechamento ";
136 137  
137 138 if( is_numeric( $ref_cod_turma_tipo ) )
138 139 {
... ... @@ -453,9 +454,10 @@ class clsPmieducarTurma
453 454 $this->visivel = dbBool($visivel);
454 455 }
455 456  
456   - $this->turma_turno_id = $turma_turno_id;
457   - $this->tipo_boletim = $tipo_boletim;
458   - $this->ano = $ano;
  457 + $this->turma_turno_id = $turma_turno_id;
  458 + $this->tipo_boletim = $tipo_boletim;
  459 + $this->ano = $ano;
  460 + $this->data_fechamento = $data_fechamento;
459 461 }
460 462  
461 463 /**
... ... @@ -616,6 +618,12 @@ class clsPmieducarTurma
616 618 $gruda = ", ";
617 619 }
618 620  
  621 + if(is_string($this->data_fechamento) && $this->data_fechamento!=''){
  622 + $campos .= "{$gruda}data_fechamento";
  623 + $valores .= "{$gruda}'{$this->data_fechamento}'";
  624 + $gruda = ", ";
  625 + }
  626 +
619 627 $db->Consulta( "INSERT INTO {$this->_tabela} ( $campos ) VALUES( $valores )" );
620 628 return $db->InsertId( "{$this->_tabela}_cod_turma_seq");
621 629 }
... ... @@ -801,6 +809,15 @@ class clsPmieducarTurma
801 809 $gruda = ", ";
802 810 }
803 811  
  812 + if(is_string($this->data_fechamento) && $this->data_fechamento!='') {
  813 + $set .= "{$gruda}data_fechamento = '{$this->data_fechamento}'";
  814 + $gruda = ", ";
  815 + }
  816 + else {
  817 + $set .= "{$gruda}data_fechamento = NULL";
  818 + $gruda = ", ";
  819 + }
  820 +
804 821 if( $set )
805 822 {
806 823 $db->Consulta( "UPDATE {$this->_tabela} SET $set WHERE cod_turma = '{$this->cod_turma}'" );
... ...
ieducar/misc/database/deltas/portabilis/68_cria_processo_fechamento_turma.sql 0 → 100644
... ... @@ -0,0 +1,23 @@
  1 + -- //
  2 +
  3 + --
  4 + -- Cria coluna para data de enturmação
  5 + --
  6 + -- @author Lucas Schmoeller da Silva <lucas@portabilis.com.br>
  7 + -- @license @@license@@
  8 + -- @version $Id$
  9 +
  10 + ALTER TABLE pmieducar.matricula_turma ALTER COLUMN data_enturmacao SET NOT NULL;
  11 +
  12 + ALTER TABLE pmieducar.matricula_turma
  13 + add COLUMN sequencial_fechamento INTEGER NOT NULL default 0;
  14 +
  15 + ALTER TABLE pmieducar.turma
  16 + add COLUMN data_fechamento date;
  17 +
  18 + -- //@UNDO
  19 +
  20 + ALTER TABLE pmieducar.matricula_turma DROP COLUMN sequencial_fechamento;
  21 + ALTER TABLE pmieducar.turma DROP COLUMN data_fechamento;
  22 +
  23 + -- //
0 24 \ No newline at end of file
... ...