Skip to content

Commit

Permalink
Fix/inconsistency lunch (#679)
Browse files Browse the repository at this point in the history
* fix: added new id for lunch inconsistencys

* Feat: added property for class model

* Feat: added min caractres for restrictions lunch

* Feat: added msg for error

* Feat: added new version for changelog and config

* Feat: added migration

---------

Co-authored-by: Igor Gonçalves <igor_goncalves@live.com>
  • Loading branch information
nathanipti and igorgoncalves committed Apr 26, 2024
1 parent 38b5ca7 commit 6e625a5
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -21,6 +21,7 @@
- Adicionado unidades de medida para o lançamento no estoque

## [Versão 3.77.132]
- Adicionado correção para a tamanho da descrição da merenda
- Criando as telas relacionadas a agricultor no novo módulo de merenda escolar

## [Versão 3.76.131]
Expand Down
1 change: 1 addition & 0 deletions app/migrations/2024-04-12_inconsistency_lunch/default.sql
@@ -0,0 +1 @@
ALTER TABLE inconsistency_sagres ADD idLunch INT NULL;
4 changes: 2 additions & 2 deletions app/modules/lunch/messages/pt_br/lunch.php
Expand Up @@ -35,7 +35,7 @@
'Portion decreased successfully!' => 'Porção decrementada com sucesso!',
'Portion removed successfully!' => 'Porção removida com sucesso!',

'Error when adding new meal' => 'Erro ao adicionar nova refeição',
'Error when adding new meal' => 'Erro ao adicionar nova refeição <br>Possíveis erros: <br>- A descrição não pode ter menos que 5 caracteres',
'Meal added successfully!' => 'Refeição adicionada com sucesso!',

'Menu updated successfully!' => 'Menu atualizado com sucesso!',
Expand All @@ -47,7 +47,7 @@
'New Lunch' => 'Nova Refeição',

'Meal updated successfully!' => 'Refeição atualizada com sucesso!',
'Error when updating meal.' => 'Erro ao atualizar refeição.'
'Error when updating meal.' => 'Erro ao atualizar refeição <br>Possíveis erros: <br>- A descrição deve conter mais que 5 caracteres'


];
2 changes: 1 addition & 1 deletion app/modules/lunch/models/Meal.php
Expand Up @@ -40,7 +40,7 @@ public function rules()
// will receive user inputs.
return array(
array('restrictions', 'required'),
array('restrictions', 'length', 'max'=>1000),
array('restrictions', 'length', 'min' => 5,'max'=>1000),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, restrictions', 'safe', 'on'=>'search'),
Expand Down
16 changes: 14 additions & 2 deletions app/modules/sagres/models/SagresConsultModel.php
Expand Up @@ -816,7 +816,8 @@ public function getMenuList($schoolId, $year, $month)
fm.start_date as data,
fm.description AS descricaoMerenda,
fm.adjusted AS ajustado,
fmm.turn AS turno
fmm.turn AS turno,
fmm.menu_fk
FROM food_menu fm
JOIN food_menu_meal fmm on fmm.food_menuId = fm.id
WHERE YEAR(fm.start_date) = :year and month(fm.start_date) <= :month";
Expand All @@ -829,7 +830,8 @@ public function getMenuList($schoolId, $year, $month)
lm.date AS data,
lm.turn AS turno,
lm2.restrictions AS descricaoMerenda,
lm.adjusted AS ajustado
lm.adjusted AS ajustado,
lmm.menu_fk
FROM lunch_menu lm
JOIN lunch_menu_meal lmm ON lm.id = lmm.menu_fk
JOIN lunch_meal lm2 on lmm.meal_fk = lm2.id
Expand Down Expand Up @@ -864,6 +866,8 @@ public function getMenuList($schoolId, $year, $month)
$inconsistencyModel->school = $schoolRes['name'];
$inconsistencyModel->description = 'Turno inválido';
$inconsistencyModel->action = 'Informar um turno válido para o cardápio';
$inconsistencyModel->identifier = '11';
$inconsistencyModel->idLunch = $menu['menu_fk'];
$inconsistencyModel->idSchool = $schoolId;
$inconsistencyModel->insert();
}
Expand All @@ -874,6 +878,8 @@ public function getMenuList($schoolId, $year, $month)
$inconsistencyModel->school = $schoolRes['name'];
$inconsistencyModel->description = 'Descrição para merenda menor que 5 caracteres';
$inconsistencyModel->action = 'Informar uma descrição para merenda maior que 4 caracteres';
$inconsistencyModel->identifier = '11';
$inconsistencyModel->idLunch = $menu['menu_fk'];
$inconsistencyModel->idSchool = $schoolId;
$inconsistencyModel->insert();
}
Expand All @@ -884,6 +890,8 @@ public function getMenuList($schoolId, $year, $month)
$inconsistencyModel->school = $schoolRes['name'];
$inconsistencyModel->description = 'Descrição para a merenda maior que 1000 caracteres';
$inconsistencyModel->action = 'Informar uma descrição para a merenda menor que 1000 caracteres';
$inconsistencyModel->identifier = '11';
$inconsistencyModel->idLunch = $menu['menu_fk'];
$inconsistencyModel->idSchool = $schoolId;
$inconsistencyModel->insert();
}
Expand All @@ -894,6 +902,8 @@ public function getMenuList($schoolId, $year, $month)
$inconsistencyModel->school = $schoolRes['name'];
$inconsistencyModel->description = 'Valor inválido para o campo ajustado';
$inconsistencyModel->action = 'Marque ou desmarque o checkbox para o campo ajustado';
$inconsistencyModel->identifier = '11';
$inconsistencyModel->idLunch = $menu['menu_fk'];
$inconsistencyModel->idSchool = $schoolId;
$inconsistencyModel->insert();
}
Expand All @@ -904,6 +914,8 @@ public function getMenuList($schoolId, $year, $month)
$inconsistencyModel->school = $schoolRes['name'];
$inconsistencyModel->description = 'Data no formato inválido';
$inconsistencyModel->action = 'Adicione uma data no formato válido';
$inconsistencyModel->identifier = '11';
$inconsistencyModel->idLunch = $menu['menu_fk'];
$inconsistencyModel->idSchool = $schoolId;
$inconsistencyModel->insert();
}
Expand Down
1 change: 1 addition & 0 deletions app/modules/sagres/models/ValidationSagresModel.php
Expand Up @@ -10,6 +10,7 @@
* @property integer $idClass;
* @property integer $identifier;
* @property integer $idStudent;
* @property integer $idLunch
*
*/
class ValidationSagresModel extends CActiveRecord
Expand Down
3 changes: 2 additions & 1 deletion app/modules/sagres/views/default/inconsistencys.php
Expand Up @@ -43,7 +43,8 @@ class="display js-tag-table student-table
'3' => '?r=professional/default/update&id=' . $model->idProfessional,
'4' => '?r=school/update&id=' . $model->idSchool,
'9' => '?r=student/update&id=' . $model->idStudent,
'10' => '?r=classroom/update&id=' . $model->idClass
'10' => '?r=classroom/update&id=' . $model->idClass,
'11' => '?r=lunch/lunch/update&id=' . $model->idLunch
];

$link = $map[$model->identifier];
Expand Down

0 comments on commit 6e625a5

Please sign in to comment.