Commit 553ee287cd6cec88f5cb255b9fe89b8eaae6a4fe

Authored by Caroline Salib
2 parents 0680dff1 203601c3
Exists in master

Merge branch 'fix_instituicao_date' into 'master'

Fix data_base_remanejamento e data_base_transferencia

Corrige problema ao adicionar ou editar uma nova instituição devido aos novos campos de data.

O problema foi corrigido na issue #40, na questão do tipo da coluna no banco de dados, porém faltou uma atualização no arquivo educar_instituicao_cad.php, quando não se passava uma data no formulário, dava erro na inserção ou update, pois o campo date não estava aceitando uma string vazia.

See merge request !21
ieducar/intranet/educar_instituicao_cad.php
@@ -194,6 +194,13 @@ class indice extends clsCadastro @@ -194,6 +194,13 @@ class indice extends clsCadastro
194 $obj->data_base_remanejamento = Portabilis_Date_Utils::brToPgSQL($this->data_base_remanejamento); 194 $obj->data_base_remanejamento = Portabilis_Date_Utils::brToPgSQL($this->data_base_remanejamento);
195 $obj->data_base_transferencia = Portabilis_Date_Utils::brToPgSQL($this->data_base_transferencia); 195 $obj->data_base_transferencia = Portabilis_Date_Utils::brToPgSQL($this->data_base_transferencia);
196 196
  197 + if ($this->data_base_remanejamento == '')
  198 + unset($obj->data_base_remanejamento);
  199 +
  200 + if ($this->data_base_transferencia == '')
  201 + unset($obj->data_base_transferencia);
  202 +
  203 +
197 $cadastrou = $obj->cadastra(); 204 $cadastrou = $obj->cadastra();
198 if( $cadastrou ) 205 if( $cadastrou )
199 { 206 {
@@ -218,6 +225,12 @@ class indice extends clsCadastro @@ -218,6 +225,12 @@ class indice extends clsCadastro
218 $obj->data_base_remanejamento = Portabilis_Date_Utils::brToPgSQL($this->data_base_remanejamento); 225 $obj->data_base_remanejamento = Portabilis_Date_Utils::brToPgSQL($this->data_base_remanejamento);
219 $obj->data_base_transferencia = Portabilis_Date_Utils::brToPgSQL($this->data_base_transferencia); 226 $obj->data_base_transferencia = Portabilis_Date_Utils::brToPgSQL($this->data_base_transferencia);
220 227
  228 + if ($this->data_base_remanejamento == '')
  229 + unset($obj->data_base_remanejamento);
  230 +
  231 + if ($this->data_base_transferencia == '')
  232 + unset($obj->data_base_transferencia);
  233 +
221 $editou = $obj->edita(); 234 $editou = $obj->edita();
222 if( $editou ) 235 if( $editou )
223 { 236 {
ieducar/misc/database/migrations/20161007002450_add_columns_transferido_remanejado.php
@@ -9,8 +9,8 @@ class AddColumnsTransferidoRemanejado extends AbstractMigration @@ -9,8 +9,8 @@ class AddColumnsTransferidoRemanejado extends AbstractMigration
9 { 9 {
10 $this->execute("ALTER TABLE pmieducar.matricula_turma ADD COLUMN transferido boolean;"); 10 $this->execute("ALTER TABLE pmieducar.matricula_turma ADD COLUMN transferido boolean;");
11 $this->execute("ALTER TABLE pmieducar.matricula_turma ADD COLUMN remanejado boolean;"); 11 $this->execute("ALTER TABLE pmieducar.matricula_turma ADD COLUMN remanejado boolean;");
12 - $this->execute("ALTER TABLE pmieducar.instituicao ADD COLUMN data_base_remanejamento boolean;");  
13 - $this->execute("ALTER TABLE pmieducar.instituicao ADD COLUMN data_base_transferencia boolean;"); 12 + $this->execute("ALTER TABLE pmieducar.instituicao ADD COLUMN data_base_remanejamento date;");
  13 + $this->execute("ALTER TABLE pmieducar.instituicao ADD COLUMN data_base_transferencia date;");
14 } 14 }
15 15
16 public function down() 16 public function down()