diff --git a/CHANGELOG.md b/CHANGELOG.md
index 00b78acfe..ad33601ce 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,14 +1,28 @@
-## [Versão 3.91.208]
-- Permitindo que o usuário de professor consiga visualizar no relatório as aulas ministradas cadastradas por outros professores
-## [Versão 3.91.207]
+## [Versão 3.93.210]
+- Corrigindo a busca por aulas em aulas ministradas quando o usuário é um professor da educação infantil
+
+## [Versão 3.93.209]
+- Trocado "Série" por "Etapa" na Ficha de Matrícula
+- O Campo 27 da Ficha de Matrícula (Autorização do Termo de Consentimento de Imagem) agora traz preenchido do cadastro do aluno
+
+## [Versão 3.92.209]
+- Corrigido o relatório de alunos por escola (Cpg, Rg e Nis), exibindo somente os alunos do ano em que o relatório foi emitido
+
+## [Versão 3.92.208]
+- Permitindo o acesso dos coordenadores pedagógicos as telas de frequência de professor e a tela de notas
+- Filtrando por escola os professores que podem ser selecionados na tela de frequência de professor
+
+## [Versão 3.92.207]
- Feito com que o aluno rematricule numa turma que havia sido transferida
- Aumentado fonte da ficha de notas
- Inserido campos no cabeçalho da ficha de notas (gênero, filiação, data de nascimento, naturalidade)
- Inserido opção pra imprimir ficha de notas com local/data ou não
- Trocado signatário de inspetor escolar para secretário escolar na ficha de notas
+- Adicionado filtro de etapa para as turmas multiseriadas
+
-## [Versão 3.90.206]
+## [Versão 3.91.206]
- Corrigido erro ao carregar campo de tipo de unidade em estrutura de unidades e avaliações
## [Versão 3.91.205]
diff --git a/app/components/utils/TagUtils.php b/app/components/utils/TagUtils.php
index 47548104c..cffdca544 100644
--- a/app/components/utils/TagUtils.php
+++ b/app/components/utils/TagUtils.php
@@ -35,7 +35,7 @@ public static function isStageChildishEducation($stage){
}
public static function isMultiStage($stage){
$refMinorStages = [
- '12','13','22','23','24','41','56','83', '84'
+ '12','13','22','23','24','56','83', '84'
];
$stages = new CList($refMinorStages, true);
return $stages->contains(strval($stage));
diff --git a/app/controllers/ClassesController.php b/app/controllers/ClassesController.php
index 5f429c86b..44a732d69 100755
--- a/app/controllers/ClassesController.php
+++ b/app/controllers/ClassesController.php
@@ -189,13 +189,11 @@ public function actionGetClassContents()
->queryAll();
$additionalClasses = Yii::app()->db->createCommand(
- "select distinct cc.id, cp.name as cpname, ed.id as edid, ed.name as edname, cc.order, cc.content, cp.id as cpid
+ "select cc.id, cp.name as cpname, cp.discipline_fk ,cc.order, cc.content, cp.id as cpid
from course_class cc
join course_plan cp on cp.id = cc.course_plan_fk
- join course_plan_discipline_vs_abilities dvsa on dvsa.course_class_fk = cc.id
- join edcenso_discipline ed on ed.id = dvsa.discipline_fk
where cp.school_inep_fk = :school_inep_fk and cp.modality_fk = :modality_fk and cp.users_fk = :users_fk and cp.discipline_fk IS NULL
- order by ed.name, cp.name"
+ order by cp.name"
)
->bindParam(":school_inep_fk", Yii::app()->user->school)
->bindParam(":modality_fk", $schedules[0]->classroomFk->edcenso_stage_vs_modality_fk)
diff --git a/app/controllers/GradesController.php b/app/controllers/GradesController.php
index 86315c9b4..462380c09 100644
--- a/app/controllers/GradesController.php
+++ b/app/controllers/GradesController.php
@@ -39,7 +39,8 @@ public function accessRules()
'getGradesRelease',
'getReportCardGrades',
'saveGradesReportCard',
- 'saveGradesRelease'
+ 'saveGradesRelease',
+ 'getClassroomStages'
),
'users' => array('@'),
),
@@ -86,14 +87,43 @@ public function actionGrades()
$criteria->params = array(':school_year' => $year, ':school_inep_fk' => $school, ':users_fk' => Yii::app()->user->loginInfos->id);
$classroom = Classroom::model()->findAll($criteria);
- $classroom = CHtml::listData($classroom, 'id', 'name');
} else {
$classroom = Classroom::model()->findAll('school_year = :school_year and school_inep_fk = :school_inep_fk order by name', ['school_year' => $year, 'school_inep_fk' => $school]);
- $classroom = CHtml::listData($classroom, 'id', 'name');
}
$this->render('grades', ['classrooms' => $classroom]);
}
+ public function actionGetClassroomStages()
+ {
+ $classroomId = Yii::app()->request->getPost("classroomId");
+ $classroomStage = Classroom::model()->findByPk($classroomId)->edcensoStageVsModalityFk;
+ $criteria = new CDbCriteria();
+ $criteria->alias = 'stages';
+ $criteria->join = 'INNER JOIN student_enrollment ON student_enrollment.edcenso_stage_vs_modality_fk = stages.id';
+ $criteria->join .= ' INNER JOIN classroom ON classroom.id = student_enrollment.classroom_fk';
+ $criteria->condition = 'classroom.id = :classroomId';
+ $criteria->group = 'stages.name';
+ $criteria->params = array(':classroomId' => $classroomId);
+ $stages = EdcensoStageVsModality::model()->findAll($criteria);
+
+
+ echo CHtml::tag('option',
+ array(
+ 'value' => $classroomStage->id,
+ 'data-classroom-stage' => '1',
+ ),
+ CHtml::encode($classroomStage->name),
+ true
+ );
+
+ foreach ($stages as $stage) {
+ echo CHtml::tag('option', array(
+ 'value' => $stage->id,
+ 'data-classroom-stage' => '0',
+ ), CHtml::encode($stage->name), true);
+ }
+
+ }
public function actionGetDisciplines()
{
@@ -131,8 +161,14 @@ public function actionGetDisciplines()
}
public function actionGetUnities()
{
- $classroom = Classroom::model()->findByPk($_POST["classroom"]);
- $unities = GradeUnity::model()->findAllByAttributes(["edcenso_stage_vs_modality_fk" => $classroom->edcenso_stage_vs_modality_fk]);
+ $classroomId = Yii::app()->request->getPost("classroom");
+ $stage = Yii::app()->request->getPost("stage");
+ if(isset(($stage)) && $stage !== "") {
+ $unities = GradeUnity::model()->findAllByAttributes(["edcenso_stage_vs_modality_fk" => $stage]);
+ } else {
+ $classroom = Classroom::model()->findByPk($classroomId);
+ $unities = GradeUnity::model()->findAllByAttributes(["edcenso_stage_vs_modality_fk" => $classroom->edcenso_stage_vs_modality_fk]);
+ }
$result = [];
foreach ($unities as $unity) {
@@ -507,6 +543,7 @@ public function actionSaveGrades()
$students = Yii::app()->request->getPost("students");
$disciplineId = Yii::app()->request->getPost("discipline");
$classroomId = Yii::app()->request->getPost("classroom");
+ $stage = Yii::app()->request->getPost("stage");
$isConcept = Yii::app()->request->getPost("isConcept");
$transaction = Yii::app()->db->beginTransaction();
@@ -552,7 +589,7 @@ public function actionSaveGrades()
}
}
}
- self::saveGradeResults($classroomId, $disciplineId);
+ self::saveGradeResults($classroomId, $disciplineId, $stage);
$transaction->commit();
header('HTTP/1.1 200 OK');
echo json_encode(["valid" => true]);
@@ -570,21 +607,21 @@ public function actionGetGrades()
Yii::import("application.domain.grades.usecases.GetStudentGradesByDisciplineUsecase");
- $classroomId = (int) Yii::app()->request->getPost("classroom");
- $disciplineId = (int) Yii::app()->request->getPost("discipline");
- $unityId = (int) Yii::app()->request->getPost("unity");
+ $classroomId = Yii::app()->request->getPost("classroom");
+ $disciplineId = Yii::app()->request->getPost("discipline");
+ $unityId = Yii::app()->request->getPost("unity");
+ $stageId = Yii::app()->request->getPost("stage");
+ $isClassroomStage = Yii::app()->request->getPost("isClassroomStage");
if (!isset($classroomId) || !isset($disciplineId) || !isset($unityId)) {
throw new CHttpException(400, "Requisição mal formada, faltam dados");
}
-
-
- if (!isset($classroomId) || !isset($disciplineId) || !isset($unityId)) {
- throw new CHttpException(400, "Requisição mal formada, faltam dados");
+ if ($stageId=== "") {
+ $classroom = Classroom::model()->with("activeStudentEnrollments.studentFk")->findByPk($classroomId);
+ $stageId = (int) $classroom->edcenso_stage_vs_modality_fk;
}
-
- $usecase = new GetStudentGradesByDisciplineUsecase($classroomId, $disciplineId, $unityId);
+ $usecase = new GetStudentGradesByDisciplineUsecase($classroomId, $disciplineId, $unityId, $stageId, $isClassroomStage);
$result = $usecase->exec();
echo CJSON::encode($result);
@@ -594,28 +631,47 @@ public function actionCalculateFinalMedia()
{
$transaction = Yii::app()->db->beginTransaction();
try {
-
$classroomId = Yii::app()->request->getPost("classroom");
+ $stage = Yii::app()->request->getPost("stage");
$disciplineId = Yii::app()->request->getPost("discipline");
+ $isClassroomStage = Yii::app()->request->getPost("isClassroomStage");
$classroom = Classroom::model()->with("activeStudentEnrollments.studentFk")->findByPk($classroomId);
+ if($stage==="") {
+ $stage = $classroom->edcenso_stage_vs_modality_fk;
+ }
+
$gradeRules = GradeRules::model()->findByAttributes([
- "edcenso_stage_vs_modality_fk" => $classroom->edcenso_stage_vs_modality_fk
+ "edcenso_stage_vs_modality_fk" => $stage
]);
TLog::info("Começado processo de calcular média final.", ["Classroom" => $classroom->id, "GradeRules" => $gradeRules->id]);
-
- foreach ($classroom->activeStudentEnrollments as $enrollment) {
+ $TotalEnrollments = $classroom->activeStudentEnrollments;
+ $studentEnrollments = [];
+ if(TagUtils::isMultiStage($classroom->edcenso_stage_vs_modality_fk) && $isClassroomStage == 0){
+ foreach ($TotalEnrollments as $enrollment) {
+ if($enrollment->edcenso_stage_vs_modality_fk == $stage){
+ array_push($studentEnrollments, $enrollment);
+ }
+ }
+ } else {
+ $studentEnrollments = $classroom->activeStudentEnrollments;
+ }
+ foreach ($studentEnrollments as $enrollment) {
$gradeUnities = new GetGradeUnitiesByDisciplineUsecase($gradeRules->edcenso_stage_vs_modality_fk);
$gradesStudent = $gradeUnities->exec();
$countUnities = $gradeUnities->execCount();
+ TLog::info("Unidades por disciplina", ["GradeUnities" => CHtml::listData($gradesStudent, 'id', 'id')]);
TLog::info("Unidades por disciplina", ["GradeUnities" => CHtml::listData($gradesStudent, 'id', 'id')]);
$gradeResult = (new GetStudentGradesResultUsecase($enrollment->id, $disciplineId))->exec();
(new CalculateFinalMediaUsecase($gradeResult, $gradeRules, $countUnities, $gradesStudent))->exec();
- (new ChageStudentStatusByGradeUsecase($gradeResult, $gradeRules, $countUnities))->exec();
+ if($gradeRules->rule_type === "N") {
+ (new ChageStudentStatusByGradeUsecase($gradeResult, $gradeRules, $countUnities, $stage))->exec();
+ }
+
}
$transaction->commit();
} catch (Exception $e) {
@@ -626,20 +682,23 @@ public function actionCalculateFinalMedia()
}
- public static function saveGradeResults($classroomId, $disciplineId)
+ public static function saveGradeResults($classroomId, $disciplineId, $stage)
{
TLog::info("Executando: SaveGradeResults.", array(
"Classroom" => $classroomId,
- "Discipline" => $disciplineId
+ "Discipline" => $disciplineId,
+ "Stage" => $stage
));
$usecase = new CalculateGradeResultsUsecase(
$classroomId,
- $disciplineId
+ $disciplineId,
+ $stage
);
$usecase->exec();
TLog::info("Finalizado: SaveGradeResults.", array(
"Classroom" => $classroomId,
- "Discipline" => $disciplineId
+ "Discipline" => $disciplineId,
+ "Stage" => $stage
));
}
}
diff --git a/app/domain/grades/usecases/CalculateConceptGradeUsecase.php b/app/domain/grades/usecases/CalculateConceptGradeUsecase.php
index 03fe1c292..e9003043b 100644
--- a/app/domain/grades/usecases/CalculateConceptGradeUsecase.php
+++ b/app/domain/grades/usecases/CalculateConceptGradeUsecase.php
@@ -3,26 +3,38 @@
/**
* @property int $classroomId
* @property int $discipline
+ * @property int $stage
*/
class CalculateConceptGradeUsecase
{
-
- private $classroomId;
- private $discipline;
- public function __construct($classroom, $discipline)
+ public function __construct($classroom, $discipline, $stage)
{
$this->classroomId = $classroom;
$this->discipline = $discipline;
+ $this->stage = $stage;
}
public function exec()
{
$classroom = Classroom::model()->with("activeStudentEnrollments.studentFk")->findByPk($this->classroomId);
- $studentEnrollments = $classroom->activeStudentEnrollments;
- $unitiesByDiscipline = $this->getGradeUnitiesByClassroomStage($this->classroomId);
+ $TotalEnrollments = $classroom->activeStudentEnrollments;
+ $studentEnrollments = [];
+ if(TagUtils::isMultiStage($classroom->edcenso_stage_vs_modality_fk)) {
+
+ foreach ($TotalEnrollments as $enrollment) {
+ if($enrollment->edcenso_stage_vs_modality_fk == $this->stage){
+ array_push($studentEnrollments, $enrollment);
+ }
+ }
+ } else {
+ $studentEnrollments = $classroom->activeStudentEnrollments;
+ $this->stage = $classroom->edcenso_stage_vs_modality_fk;
+
+ }
+ // $unitiesByDiscipline = $this->getGradeUnitiesByClassroomStage($this->classroomId);
foreach ($studentEnrollments as $studentEnrollment) {
- $this->calculateConceptGrades($studentEnrollment, $unitiesByDiscipline, $this->discipline);
+ $this->calculateConceptGrades($studentEnrollment, $this->discipline);
}
}
@@ -69,28 +81,31 @@ private function getGradesResultForStudent($studentEnrollmentId, $disciplineId)
return $gradeResult;
}
- private function calculateConceptGrades($studentEnrollment, $gradeUnities, $disciplineId)
+ private function calculateConceptGrades($studentEnrollment, $disciplineId)
{
$gradeResult = $this->getGradesResultForStudent($studentEnrollment->id, $disciplineId);
//notas por conceito
$hasAllGrades = true;
- foreach ($gradeUnities as $unityKey => $gradeUnity) {
- $grades = $this->getStudentGradesFromUnity(
+
+ $grades = $this->getStudentGrades(
$studentEnrollment->id,
$disciplineId,
- $gradeUnity->id
);
- foreach ($grades as $grade) {
- if($grade->grade_concept_fk === null){
- $hasAllGrades = false;
- }
+ foreach ($grades as $gradeKey => $grade) {
- $gradeResult["grade_concept_" . ($unityKey + 1)] = $grade->gradeConceptFk->acronym;
+ $gradeResult["grade_concept_" . ($gradeKey + 1)] = $grade->gradeConceptFk->acronym;
}
+
+ $gradeUnities = new GetGradeUnitiesByDisciplineUsecase($this->stage);
+ $numUnities = $gradeUnities->execCount();
+
+ if (!$this->hasAllGrades($numUnities, $gradeResult)) {
+ $hasAllGrades = false;
}
+
$gradeResult->situation = StudentEnrollment::STATUS_ACTIVE;
if ($hasAllGrades) {
@@ -114,7 +129,7 @@ private function calculateConceptGrades($studentEnrollment, $gradeUnities, $disc
*
* @return Grade[]
*/
- private function getStudentGradesFromUnity($enrollmentId, $discipline, $unityId)
+ private function getStudentGrades($enrollmentId, $discipline)
{
$gradesIds = array_column(Yii::app()->db->createCommand(
@@ -123,10 +138,9 @@ private function getStudentGradesFromUnity($enrollmentId, $discipline, $unityId)
FROM grade g
join grade_unity_modality gum on g.grade_unity_modality_fk = gum.id
join grade_unity gu on gu.id= gum.grade_unity_fk
- WHERE g.enrollment_fk = :enrollment_id and g.discipline_fk = :discipline_id and gu.id = :unity_id and gum.type = '" . GradeUnityModality::TYPE_COMMON . "'"
+ WHERE g.enrollment_fk = :enrollment_id and g.discipline_fk = :discipline_id and gum.type = '" . GradeUnityModality::TYPE_COMMON . "' and gu.type = 'UC'"
)->bindParam(":enrollment_id", $enrollmentId)
- ->bindParam(":discipline_id", $discipline)
- ->bindParam(":unity_id", $unityId)->queryAll(), "id");
+ ->bindParam(":discipline_id", $discipline)->queryAll(), "id");
if ($gradesIds == null) {
return [];
@@ -139,4 +153,14 @@ private function getStudentGradesFromUnity($enrollmentId, $discipline, $unityId)
);
}
+ private function hasAllGrades($numUnities, $gradeResult)
+ {
+ for ($i = 1; $i <= $numUnities; $i++) {
+ if (!isset($gradeResult["grade_concept_" . $i]) || $gradeResult["grade_concept_" . $i] === "") {
+ return false;
+ }
+ }
+ return true;
+ }
+
}
diff --git a/app/domain/grades/usecases/CalculateFinalMediaUsecase.php b/app/domain/grades/usecases/CalculateFinalMediaUsecase.php
index 15ef895d1..9e9dbd2f6 100644
--- a/app/domain/grades/usecases/CalculateFinalMediaUsecase.php
+++ b/app/domain/grades/usecases/CalculateFinalMediaUsecase.php
@@ -23,7 +23,6 @@ public function __construct($gradesResult, $gradeRule, $countUnities, $gradesStu
public function exec()
{
- try {
$grades = [];
if ($this->gradeRule->gradeCalculationFk->name == 'Média Semestral') {
$semRecPartial1 = is_numeric($this->gradesResult["sem_rec_partial_1"]) ? $this->gradesResult["sem_rec_partial_1"] : 0;
@@ -32,11 +31,11 @@ public function exec()
$gradesSemAvarage1 = max($this->gradesResult["sem_avarage_1"], $semRecPartial1);
$gradesSemAvarage2 = max($this->gradesResult["sem_avarage_2"], $semRecPartial2);
- if($gradesSemAvarage1 != null) {
+ if ($gradesSemAvarage1 !== null) {
$grades[] = $gradesSemAvarage1;
}
- if($gradesSemAvarage2 != null) {
+ if ($gradesSemAvarage2 !== null) {
$grades[] = $gradesSemAvarage2;
}
@@ -83,10 +82,6 @@ public function exec()
$this->saveFinalMedia($this->gradesResult, $finalMedia);
- } catch (Exception $e) {
- TLog::error("Erro ao salvar média final", ["Exception" => $e]);
- }
-
}
private function saveFinalMedia($gradesResult, $finalMedia)
diff --git a/app/domain/grades/usecases/CalculateGradeResultsUsecase.php b/app/domain/grades/usecases/CalculateGradeResultsUsecase.php
index b4042876f..2959b441d 100644
--- a/app/domain/grades/usecases/CalculateGradeResultsUsecase.php
+++ b/app/domain/grades/usecases/CalculateGradeResultsUsecase.php
@@ -3,22 +3,25 @@
/**
* @property int $classroomId
* @property int $discipline
+ * @property int $stage
*/
class CalculateGradeResultsUsecase {
- private $classroomId;
- private $discipline;
- public function __construct($classroom, $discipline) {
+ public function __construct($classroom, $discipline, $stage) {
$this->classroomId = $classroom;
$this->discipline = $discipline;
+ $this->stage = $stage;
}
public function exec() {
$classroom = Classroom::model()->findByPk($this->classroomId);
+ if($this->stage === "") {
+ $this->stage = $classroom->edcenso_stage_vs_modality_fk;
+ }
$gradeRules = GradeRules::model()->findByAttributes([
- "edcenso_stage_vs_modality_fk" => $classroom->edcenso_stage_vs_modality_fk
+ "edcenso_stage_vs_modality_fk" => $this->stage
]);
if($gradeRules->rule_type === "N") {
- $usercase = new CalculateNumericGradeUsecase($this->classroomId, $this->discipline);
+ $usercase = new CalculateNumericGradeUsecase($this->classroomId, $this->discipline, $this->stage);
$usercase->exec();
TLog::info("Notas numéricas calculadas com sucesso.", array(
"Classroom" => $classroom->id,
@@ -27,7 +30,7 @@ public function exec() {
));
return;
} elseif ($gradeRules->rule_type === "C"){
- $usercase = new CalculateConceptGradeUsecase($this->classroomId, $this->discipline);
+ $usercase = new CalculateConceptGradeUsecase($this->classroomId, $this->discipline, $this->stage);
$usercase->exec();
TLog::info("Notas por conceito calculadas com sucesso.", array(
"Classroom" => $classroom->id,
diff --git a/app/domain/grades/usecases/CalculateNumericGradeUsecase.php b/app/domain/grades/usecases/CalculateNumericGradeUsecase.php
index df4f1a9c3..58492c4e7 100644
--- a/app/domain/grades/usecases/CalculateNumericGradeUsecase.php
+++ b/app/domain/grades/usecases/CalculateNumericGradeUsecase.php
@@ -2,24 +2,35 @@
/**
* @property int $classroomId
+ * @property int $stage
* @property int $discipline
*/
class CalculateNumericGradeUsecase
{
- private $classroomId;
- private $discipline;
-
- public function __construct($classroom, $discipline)
+ public function __construct($classroom, $discipline, $stage)
{
$this->classroomId = $classroom;
$this->discipline = $discipline;
+ $this->stage = $stage;
}
public function exec()
{
$classroom = Classroom::model()->with("activeStudentEnrollments.studentFk")->findByPk($this->classroomId);
- $studentEnrollments = $classroom->activeStudentEnrollments;
- $unitiesByDiscipline = $this->getGradeUnitiesByClassroomStage($this->classroomId);
+ $totalEnrollments = $classroom->activeStudentEnrollments;
+ if($classroom->edcenso_stage_vs_modality_fk !== $this->stage){
+ $totalEnrollments = $classroom->activeStudentEnrollments;
+ $studentEnrollments = [];
+ foreach ($totalEnrollments as $enrollment) {
+ if($enrollment->edcenso_stage_vs_modality_fk == $this->stage){
+ array_push($studentEnrollments, $enrollment);
+ }
+ }
+ } else {
+ $studentEnrollments = $totalEnrollments;
+ }
+
+ $unitiesByDiscipline = $this->getGradeUnitiesByClassroomStage($this->stage);
foreach ($studentEnrollments as $studentEnrollment) {
$this->calculateNumericGrades($studentEnrollment, $this->discipline, $unitiesByDiscipline);
@@ -170,16 +181,15 @@ private function getRecoveryGradeFromUnity($enrollmentId, $discipline, $unityId)
);
}
- private function getGradeUnitiesByClassroomStage($classroom)
+ private function getGradeUnitiesByClassroomStage($stage)
{
$criteria = new CDbCriteria();
$criteria->alias = "gu";
$criteria->join = "join edcenso_stage_vs_modality esvm on gu.edcenso_stage_vs_modality_fk = esvm.id";
- $criteria->join .= " join classroom c on c.edcenso_stage_vs_modality_fk = esvm.id";
- $criteria->condition = "c.id = :classroom";
+ $criteria->condition = "esvm.id = :stage";
$criteria->order = "gu.type desc";
- $criteria->params = array(":classroom" => $classroom);
+ $criteria->params = array(":stage" => $stage);
return GradeUnity::model()->findAll($criteria);
}
diff --git a/app/domain/grades/usecases/ChageStudentStatusByGradeUsecase.php b/app/domain/grades/usecases/ChageStudentStatusByGradeUsecase.php
index 58537b152..ab3b695ff 100644
--- a/app/domain/grades/usecases/ChageStudentStatusByGradeUsecase.php
+++ b/app/domain/grades/usecases/ChageStudentStatusByGradeUsecase.php
@@ -5,6 +5,7 @@
* @property GradeRules $gradeRule
* @property integer $numUnities
* @property integer $frequency
+ * @property integer $stage
*/
class ChageStudentStatusByGradeUsecase
{
@@ -13,23 +14,24 @@ class ChageStudentStatusByGradeUsecase
private $gradeRule;
private $numUnities;
private $frequency;
+ private $stage;
private const SITUATION_APPROVED = "APROVADO";
private const SITUATION_DISPPROVED = "REPROVADO";
private const SITUATION_RECOVERY = "RECUPERAÇÃO";
- public function __construct($gradeResult, $gradeRule, $numUnities, $frequency = null)
+ public function __construct($gradeResult, $gradeRule, $numUnities, $stage, $frequency = null)
{
$this->gradeResult = $gradeResult;
$this->gradeRule = $gradeRule;
$this->numUnities = $numUnities;
$this->frequency = $frequency;
+ $this->$stage = $stage;
}
public function exec()
{
- try {
$enrollment = $this->getStudentEnrollment($this->gradeResult->enrollment_fk);
@@ -48,9 +50,6 @@ public function exec()
}
$this->updateStudentSituation();
- } catch (Exception $e) {
- TLog::error("Erro ao atualizar status da matrícula", ["Exception" => $e]);
- }
}
private function getStudentEnrollment($enrollmentId)
@@ -110,10 +109,12 @@ private function updateStudentSituation()
$recoveryMedia = $this->gradeResult->rec_final;
$finalRecoveryMedia = $this->gradeRule->final_recover_media;
+ $finalRecovery = GradeUnity::model()->findAllByAttributes(["edcenso_stage_vs_modality_fk" => $this->stage, "type" => "RF"]);
+
$hasRecoveryGrade = isset($recoveryMedia) && $recoveryMedia !== "";
if (!$hasRecoveryGrade) {
$this->gradeResult->situation = $recoverySituation;
- } elseif ($recoveryMedia >= $finalRecoveryMedia) {
+ } elseif ($recoveryMedia >= $finalRecoveryMedia && $finalRecovery->gradeCalculationFk->name == "Maior") {
$this->gradeResult->situation = $approvedSituation;
}
diff --git a/app/domain/grades/usecases/GetStudentGradesByDisciplineUsecase.php b/app/domain/grades/usecases/GetStudentGradesByDisciplineUsecase.php
index 157140df6..e83c54c11 100644
--- a/app/domain/grades/usecases/GetStudentGradesByDisciplineUsecase.php
+++ b/app/domain/grades/usecases/GetStudentGradesByDisciplineUsecase.php
@@ -3,31 +3,47 @@
* @property int $classroomId
* @property int $disciplineId
* @property int $unityId
+ * @property int $stageId
+ * @property int isClassroomStage
*/
class GetStudentGradesByDisciplineUsecase
{
private $classroomId;
private $disciplineId;
private $unityId;
+ private $stageId;
+ private $isClassroomStage;
- public function __construct(int $classroomId, int $disciplineId, int $unityId)
+ public function __construct(int $classroomId, int $disciplineId, int $unityId, int $stageId, int $isClassroomStage)
{
$this->classroomId = $classroomId;
$this->disciplineId = $disciplineId;
$this->unityId = $unityId;
+ $this->stageId = $stageId;
+ $this->isClassroomStage = $isClassroomStage;
}
public function exec()
{
/** @var Classroom $classroom */
$classroom = Classroom::model()->with("activeStudentEnrollments.studentFk")->findByPk($this->classroomId);
- $rules = GradeRules::model()->findByAttributes([
- "edcenso_stage_vs_modality_fk" => $classroom->edcenso_stage_vs_modality_fk
+ $rules = GradeRules::model()->findByAttributes([
+ "edcenso_stage_vs_modality_fk" => $this->stageId
]);
- $studentEnrollments = $classroom->activeStudentEnrollments;
- $showSemAvarageColumn = $this->checkSemesterUnities($classroom->edcenso_stage_vs_modality_fk);
+ $TotalEnrollments = $classroom->activeStudentEnrollments;
+ $studentEnrollments = [];
+ if(TagUtils::isMultiStage($classroom->edcenso_stage_vs_modality_fk) && $this->isClassroomStage == 0){
+ foreach ($TotalEnrollments as $enrollment) {
+ if($enrollment->edcenso_stage_vs_modality_fk == $this->stageId){
+ array_push($studentEnrollments, $enrollment);
+ }
+ }
+ } else {
+ $studentEnrollments= $classroom->activeStudentEnrollments;
+ }
+ $showSemAvarageColumn = $this->checkSemesterUnities( $this->stageId);
- $unitiesByDisciplineResult = $this->getGradeUnitiesByDiscipline($classroom->edcenso_stage_vs_modality_fk);
+ $unitiesByDisciplineResult = $this->getGradeUnitiesByDiscipline( $this->stageId);
$unitiesByDiscipline = array_filter($unitiesByDisciplineResult, function ($item){
return $item["id"] == $this->unityId;
});
@@ -35,7 +51,7 @@ public function exec()
$unityOrder = $this->searchUnityById($unitiesByDisciplineResult);
- if ($studentEnrollments == null) {
+ if ($studentEnrollments == []) {
throw new NoActiveStudentsException();
}
@@ -155,11 +171,11 @@ private function getpartialRecoveriesByUnity() {
}
public function getSemRecPartial ($gradeResult, $semester, $type) {
if($type == "RF") {
- if($gradeResult->sem_avarage_1 == null && $gradeResult->sem_avarage_2 == null) {
+ if($gradeResult->sem_avarage_1 === null && $gradeResult->sem_avarage_2 === null) {
return "";
- } elseif($gradeResult->sem_avarage_1 != null && $gradeResult->sem_avarage_2 == null){
+ } elseif($gradeResult->sem_avarage_1 !== null && $gradeResult->sem_avarage_2 === null){
return $gradeResult->sem_rec_partial_1 < $gradeResult->sem_avarage_1 ? $gradeResult->sem_avarage_1 : $gradeResult->sem_rec_partial_1;
- } elseif($gradeResult->sem_avarage_1 == null && $gradeResult->sem_avarage_2 != null){
+ } elseif($gradeResult->sem_avarage_1 === null && $gradeResult->sem_avarage_2 !== null){
return $gradeResult->sem_rec_partial_2 < $gradeResult->sem_avarage_2 ? $gradeResult->sem_avarage_2 : $gradeResult->sem_rec_partial_2;
}
@@ -173,9 +189,9 @@ public function getSemRecPartial ($gradeResult, $semester, $type) {
} else {
if($semester == 1) {
- return $gradeResult->sem_avarage_1 == null ? "" : $gradeResult->sem_avarage_1;
+ return $gradeResult->sem_avarage_1 === null ? "" : $gradeResult->sem_avarage_1;
} elseif($semester == 2) {
- return $gradeResult->sem_avarage_2 == null ? "" : $gradeResult->sem_avarage_2;
+ return $gradeResult->sem_avarage_2 === null ? "" : $gradeResult->sem_avarage_2;
}
}
}
diff --git a/app/migrations/2024-12-07_consent_form_studentsfile/sql b/app/migrations/2024-12-07_consent_form_studentsfile/sql
new file mode 100644
index 000000000..df4ceb66a
--- /dev/null
+++ b/app/migrations/2024-12-07_consent_form_studentsfile/sql
@@ -0,0 +1,186 @@
+
+create or replace
+algorithm = UNDEFINED view `studentsfile` as
+select
+ `s`.`id` as `id`,
+ `se`.`id` as `enrollment_id`,
+ if(isnull(`svm`.`alias`),
+ `svm`.`name`,
+ `svm`.`alias`) as `stage_name`,
+ (case
+ `svm`.`stage` when '1' then 'EDUCAÇÃO INFANTIL'
+ when '2' then 'ENSINO FUNDAMENTAL'
+ when '3' then 'ENSINO FUNDAMENTAL'
+ when '4' then 'ENSINO MÉDIO'
+ when '5' then 'EDUCAÇÃO PROFISSIONAL'
+ when '6' then 'EDUCAÇÃO DE JOVENS E ADULTOS'
+ when '7' then (case
+ `svm`.`id` when '56' then 'MULTIETAPA'
+ else 'ENSINO FUNDAMENTAL'
+ end)
+ end) as `stage`,
+ concat((case when (`svm`.`id` in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38)) then 'NA ' when (`svm`.`id` in (14, 15, 16, 17, 18, 19, 20, 21, 41)) then 'NO ' else '' end),(case when (`svm`.`id` = 1) then 'CRECHE' when (`svm`.`id` = 2) then 'PRÉ-ESCOLA' when (`svm`.`id` = 3) then 'EDUCAÇÃO INFANTIL' when (`svm`.`id` in (4, 14, 25, 30, 35)) then '1' when (`svm`.`id` in (5, 15, 26, 31, 36)) then '2' when (`svm`.`id` in (6, 16, 27, 32, 37)) then '3' when (`svm`.`id` in (7, 17, 28, 33, 38)) then '4' when (`svm`.`id` in (8, 18)) then '5' when (`svm`.`id` in (9, 19)) then '6' when (`svm`.`id` in (10, 20)) then '7' when (`svm`.`id` in (11, 21)) then '8' when (`svm`.`id` = 41) then '9' else '' end),(case when (`svm`.`id` in (1, 2, 3)) then '' when (`svm`.`id` in (4, 5, 6, 7, 8, 9, 10, 11, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38)) then 'ª SÉRIE' when (`svm`.`id` in (14, 15, 16, 17, 18, 19, 20, 21, 41)) then 'º ANO' else 'NA ____________________' end)) as `class`,
+ `s`.`inep_id` as `inep_id`,
+ `sd`.`nis` as `nis`,
+ `s`.`name` as `name`,
+ `ec`.`name` as `birth_city`,
+ if((`s`.`sex` = 1),
+ 'Masculino',
+ 'Feminino') as `gender`,
+ (case
+ `s`.`color_race` when '1' then 'Branca'
+ when '2' then 'Preta'
+ when '3' then 'Parda'
+ when '4' then 'Amarela'
+ when '5' then 'Indígena'
+ else 'Não Declarada'
+ end) as `color`,
+ `s`.`birthday` as `birthday`,
+ `eu`.`acronym` as `birth_uf`,
+ (case
+ `s`.`nationality` when '1' then 'Brasileira'
+ when '2' then 'Brasileira: Nascido no exterior ou Naturalizado'
+ when '3' then 'Estrangeira'
+ end) as `nationality`,
+ `en`.`name` as `nation`,
+ `sd`.`address` as `address`,
+ `eca`.`name` as `adddress_city`,
+ `eua`.`acronym` as `address_uf`,
+ `sd`.`number` as `number`,
+ `sd`.`cep` as `cep`,
+ `sd`.`rg_number` as `rg`,
+ `sd`.`cpf` as `cpf`,
+ `sd`.`cns` as `cns`,
+ `sd`.`civil_certification` as `cc`,
+ `sd`.`consent_form` as `consent_form`,
+ if((`sd`.`civil_certification_type` = 2),
+ 'Casamento',
+ 'Nascimento') as `cc_type`,
+ `eno`.`name` as `cc_name`,
+ `sd`.`civil_register_enrollment_number` as `cc_new`,
+ `sd`.`civil_certification_term_number` as `cc_number`,
+ `sd`.`civil_certification_book` as `cc_book`,
+ `sd`.`civil_certification_sheet` as `cc_sheet`,
+ `ecn`.`name` as `cc_city`,
+ `eun`.`acronym` as `cc_uf`,
+ `s`.`filiation_1` as `mother`,
+ `s`.`filiation_1_rg` as `mother_rg`,
+ `s`.`filiation_1_cpf` as `mother_cpf`,
+ `s`.`filiation_1_job` as `mother_job`,
+ `s`.`filiation_2` as `father`,
+ `s`.`filiation_2_rg` as `father_rg`,
+ `s`.`filiation_2_cpf` as `father_cpf`,
+ `s`.`filiation_2_job` as `father_job`,
+ `s`.`responsable` as `responsable`,
+ (case
+ `s`.`responsable` when '0' then concat(`s`.`filiation_2`, ' (PAI)')
+ when '1' then concat(`s`.`filiation_1`, ' (MÃE)')
+ when '2' then `s`.`responsable_name`
+ end) as `responsable_name`,
+ `s`.`responsable_rg` as `responsable_rg`,
+ `s`.`responsable_cpf` as `responsable_cpf`,
+ (case
+ `s`.`responsable_scholarity` when '1' then 'Formação Geral'
+ when '2' then 'Modalidade Normal (Magistério)'
+ when '3' then 'Curso Técnico'
+ when '4' then 'Magistério Indígena Modalidade Normal'
+ end) as `responsable_scholarity`,
+ if(isnull(`s`.`filiation_1_scholarity`),
+ 'Não Declarado',
+ (case
+ `s`.`filiation_1_scholarity` when '0' then 'Não sabe Ler e Escrever'
+ when '1' then 'Sabe Ler e Escrever'
+ when '2' then 'Ensino Fundamental Incompleto'
+ when '3' then 'Ensino Fundamental Completo'
+ when '4' then 'Ensino Médio Incompleto'
+ when '5' then 'Ensino Médio Completo'
+ when '6' then 'Ensino Superior Incompleto'
+ when '7' then 'Ensino Superior Completo'
+ end)) as `mother_scholarity`,
+ if(isnull(`s`.`filiation_2_scholarity`),
+ 'Não Declarado',
+ (case
+ `s`.`filiation_2_scholarity` when '0' then 'Não sabe Ler e Escrever'
+ when '1' then 'Sabe Ler e Escrever'
+ when '2' then 'Ensino Fundamental Incompleto'
+ when '3' then 'Ensino Fundamental Completo'
+ when '4' then 'Ensino Médio Incompleto'
+ when '5' then 'Ensino Médio Completo'
+ when '6' then 'Ensino Superior Incompleto'
+ when '7' then 'Ensino Superior Completo'
+ end)) as `father_scholarity`,
+ `s`.`responsable_job` as `responsable_job`,
+ concat_ws('; ', if((`sd`.`received_cc` = 1), 'Certidão de nascimento', null), if((`sd`.`received_address` = 1), 'Comprovante de endereço', null), if((`sd`.`received_photo` = 1), 'Foto 3x4', null), if((`sd`.`received_nis` = 1), 'Comprovante NIS', null), if((`sd`.`received_history` = 1), 'Histórico', null), if((`sd`.`received_responsable_rg` = 1), 'Cópia RG (responsável)', null), if((`sd`.`received_responsable_cpf` = 1), 'Cópia CPF (responsável)', null)) as `received_documents`,
+ if(isnull(`se`.`school_admission_date`),
+ null,
+ `se`.`school_admission_date`) as `school_admission_date`,
+ (case
+ `se`.`current_stage_situation` when 0 then 'Primeira matrícula no curso (nível e/ou modalidade de ensino)'
+ when 1 then 'Promovido na série anterior do mesmo curso (nível e/ou modalidade de ensino)'
+ when 2 then 'Repetente'
+ end) as `current_stage_situation`,
+ (case
+ `se`.`previous_stage_situation` when 0 then 'Não frequentou'
+ when 1 then 'Reprovado'
+ when 2 then 'Afastado por transferência'
+ when 3 then 'Afastado por abandono'
+ when 4 then 'Matrícula final em Educação Infantil'
+ end) as `previous_stage_situation`,
+ if((`s`.`bf_participator` = 0),
+ 'Não',
+ 'Sim') as `bf_participator`,
+ `s`.`food_restrictions` as `food_restrictions`,
+ `se`.`transport_responsable_government` as `transport_responsable_government`,
+ `se`.`vehicle_type_van` as `vehicle_type_van`,
+ `se`.`vehicle_type_microbus` as `vehicle_type_microbus`,
+ `se`.`vehicle_type_bus` as `vehicle_type_bus`,
+ `se`.`vehicle_type_bike` as `vehicle_type_bike`,
+ `se`.`vehicle_type_animal_vehicle` as `vehicle_type_animal_vehicle`,
+ `se`.`vehicle_type_other_vehicle` as `vehicle_type_other_vehicle`,
+ `se`.`vehicle_type_waterway_boat_5` as `vehicle_type_waterway_boat_5`,
+ `se`.`vehicle_type_waterway_boat_5_15` as `vehicle_type_waterway_boat_5_15`,
+ `se`.`vehicle_type_waterway_boat_15_35` as `vehicle_type_waterway_boat_15_35`,
+ `se`.`vehicle_type_waterway_boat_35` as `vehicle_type_waterway_boat_35`,
+ `se`.`vehicle_type_metro_or_train` as `vehicle_type_metro_or_train`,
+ `se`.`status` as `status`,
+ if((isnull(`se`.`vehicle_type_bus`)
+ or (`se`.`vehicle_type_bus` = 0)),
+ 'Não',
+ concat_ws(': ', 'Sim', concat_ws('; ', if((`se`.`vehicle_type_van` = 1), 'Van / Kombi', if(isnull(`se`.`vehicle_type_van`), 'Van / Kombi', null)), if((`se`.`vehicle_type_microbus` = 1), 'Microônibus', if(isnull(`se`.`vehicle_type_microbus`), 'Microônibus', null)), if((`se`.`vehicle_type_bus` = 1), 'Ônibus', if(isnull(`se`.`vehicle_type_bus`), 'Ônibus', null)), if((`se`.`vehicle_type_bike` = 1), 'Bicicleta', if(isnull(`se`.`vehicle_type_bike`), 'Bicicleta', null)), if((`se`.`vehicle_type_animal_vehicle` = 1), 'Tração animal', if(isnull(`se`.`vehicle_type_animal_vehicle`), 'Tração animal', null)), if((`se`.`vehicle_type_other_vehicle` = 1), 'Rodoviário - Outro', if(isnull(`se`.`vehicle_type_other_vehicle`), 'Rodoviário - Outro', null)), if((`se`.`vehicle_type_waterway_boat_5` = 1), 'Embarcação - Até 5 alunos', if(isnull(`se`.`vehicle_type_waterway_boat_5`), 'Embarcação - Até 5 alunos', null)), if((`se`.`vehicle_type_waterway_boat_5_15` = 1), 'Embarcação - De 5 a 15 alunos', if(isnull(`se`.`vehicle_type_waterway_boat_5_15`), 'Embarcação - De 5 a 15 alunos', null)), if((`se`.`vehicle_type_waterway_boat_15_35` = 1), 'Embarcação - De 15 a 35 alunos', if(isnull(`se`.`vehicle_type_waterway_boat_15_35`), 'Embarcação - De 15 a 35 alunos', null)), if((`se`.`vehicle_type_waterway_boat_35` = 1), 'Embarcação - Acima de 35 alunos', if(isnull(`se`.`vehicle_type_waterway_boat_35`), 'Embarcação - Acima de 35 alunos', null)), if((`se`.`vehicle_type_metro_or_train` = 1), 'Trem / Metrô', if(isnull(`se`.`vehicle_type_metro_or_train`), 'Trem / Metrô', null))))) as `public_transport`,
+ `s`.`responsable_telephone` as `responsable_telephone`,
+ if((`s`.`deficiency` = 0),
+ 'Não',
+ concat_ws(': ', 'Possui', concat_ws(', ', if((`s`.`deficiency_type_blindness` = 1), 'Cegueira', null), if((`s`.`deficiency_type_low_vision` = 1), 'Baixa visão', null), if((`s`.`deficiency_type_deafness` = 1), 'Surdez', null), if((`s`.`deficiency_type_disability_hearing` = 1), 'Deficiência Auditiva', null), if((`s`.`deficiency_type_deafblindness` = 1), 'Surdocegueira', null), if((`s`.`deficiency_type_phisical_disability` = 1), 'Deficiência Física', null), if((`s`.`deficiency_type_intelectual_disability` = 1), 'Deficiência Intelectual', null), if((`s`.`deficiency_type_multiple_disabilities` = 1), 'Deficiência Múltipla', null), if((`s`.`deficiency_type_autism` = 1), 'Autismo Infantil', null), if((`s`.`deficiency_type_aspenger_syndrome` = 1), 'Síndrome de Asperger', null), if((`s`.`deficiency_type_rett_syndrome` = 1), 'Síndrome de Rett', null), if((`s`.`deficiency_type_childhood_disintegrative_disorder` = 1), 'Transtorno Desintegrativo da Infância', null), if((`s`.`deficiency_type_gifted` = 1), 'Altas habilidades / Superdotação', null)))) as `deficiency`,
+ (case
+ `sd`.`justice_restriction` when 1 then 'LA - Liberdade Assistida'
+ when 2 then 'PSC - Prestação de Serviços Comunitários'
+ else 'Não'
+ end) as `justice_restriction`
+from
+ ((((((((((((`student_identification` `s`
+join `student_documents_and_address` `sd` on
+ ((`s`.`id` = `sd`.`id`)))
+join `student_enrollment` `se` on
+ ((`s`.`id` = `se`.`student_fk`)))
+left join `classroom` `c` on
+ ((`se`.`classroom_fk` = `c`.`id`)))
+left join `edcenso_stage_vs_modality` `svm` on
+ ((`c`.`edcenso_stage_vs_modality_fk` = `svm`.`id`)))
+left join `edcenso_uf` `eu` on
+ ((`s`.`edcenso_uf_fk` = `eu`.`id`)))
+left join `edcenso_city` `ec` on
+ ((`s`.`edcenso_city_fk` = `ec`.`id`)))
+left join `edcenso_nation` `en` on
+ ((`s`.`edcenso_nation_fk` = `en`.`id`)))
+left join `edcenso_uf` `eua` on
+ ((`sd`.`edcenso_uf_fk` = `eua`.`id`)))
+left join `edcenso_city` `eca` on
+ ((`sd`.`edcenso_city_fk` = `eca`.`id`)))
+left join `edcenso_uf` `eun` on
+ ((`sd`.`notary_office_uf_fk` = `eun`.`id`)))
+left join `edcenso_city` `ecn` on
+ ((`sd`.`notary_office_city_fk` = `ecn`.`id`)))
+left join `edcenso_notary_office` `eno` on
+ ((`sd`.`edcenso_notary_office_fk` = `eno`.`cod`)))
+order by
+ `s`.`name`;
diff --git a/app/migrations/2024-12-11_add_new_grade_concept_columns/sql.sql b/app/migrations/2024-12-11_add_new_grade_concept_columns/sql.sql
new file mode 100644
index 000000000..cbe7253b2
--- /dev/null
+++ b/app/migrations/2024-12-11_add_new_grade_concept_columns/sql.sql
@@ -0,0 +1,5 @@
+ALTER TABLE grade_results
+ADD COLUMN grade_concept_9 VARCHAR(50) NULL,
+ADD COLUMN grade_concept_10 VARCHAR(50) NULL,
+ADD COLUMN grade_concept_11 VARCHAR(50) NULL,
+ADD COLUMN grade_concept_12 VARCHAR(50) NULL;
diff --git a/app/models/ClassContents.php b/app/models/ClassContents.php
index 629f8a84f..cd625150e 100644
--- a/app/models/ClassContents.php
+++ b/app/models/ClassContents.php
@@ -201,6 +201,10 @@ public function buildClassContents($schedules, $students)
$courseClasses = [];
foreach ($schedule->classContents as $classContent) {
+ if(TagUtils::isInstructor() && $classContent->courseClassFk->coursePlanFk->users_fk != Yii::app()->user->loginInfos->id) {
+ continue;
+ }
+
if (!isset($classContents[$schedule->day]["contents"])) {
$classContents[$schedule->day]["contents"] = [];
}
diff --git a/app/modules/calendar/controllers/DefaultController.php b/app/modules/calendar/controllers/DefaultController.php
index fc05e2448..59f1d0688 100755
--- a/app/modules/calendar/controllers/DefaultController.php
+++ b/app/modules/calendar/controllers/DefaultController.php
@@ -118,6 +118,23 @@ public function actionChangeEvent()
$isSoftUnavailableEvent = !$isSoftUnavailableEvent ? $event->calendar_event_type_fk == 101 || $event->calendar_event_type_fk == 104 : $isSoftUnavailableEvent;
$isPreviousDate = !$isPreviousDate ? strtotime($event->start_date) < strtotime('now') : $isPreviousDate;
$oldColor = $event->calendarEventTypeFk->color;
+
+ //re-disponibilizar as aulas do evento. Isso serve pra garantir que, caso o evento mude de intervalo, o intervalo antigo não continue indisponível erroneamente.
+ $start = new DateTime($event->start_date);
+ $end = new DateTime($event->end_date);
+ $end->modify('+1 day');
+ $interval = DateInterval::createFromDateString('1 day');
+ $period = new DatePeriod($start, $interval, $end);
+ foreach ($period as $dt) {
+ $schedulesToAdjust = Yii::app()->db->createCommand("
+ select s.id from schedule s
+ join classroom cr on s.classroom_fk = cr.id
+ join calendar c on cr.calendar_fk = c.id
+ where c.id = :id and s.day = :day and s.month = :month and s.year = :year")->bindParam(":id", $_POST["calendarFk"])->bindParam(":day", $dt->format("j"))->bindParam(":month", $dt->format("n"))->bindParam(":year", $dt->format("Y"))->queryAll();
+ foreach ($schedulesToAdjust as $scheduleToAdjust) {
+ Schedule::model()->updateAll(["unavailable" => 0], "id = :id", [":id" => $scheduleToAdjust["id"]]);
+ }
+ }
}
if (!$_POST["confirm"] && (int)$result["qtd"] > 0 && $isHardUnavailableEvent) {
echo json_encode(["valid" => false, "alert" => "primary", "error" => "ATENÇÃO: adicionar ou modificar eventos de férias poderá refletir no quadro de horário, aulas ministradas e frequência das escolas que a utilizam.
TEM CERTEZA que deseja continuar? Clique aqui para confirmar."]);
diff --git a/app/modules/timesheet/controllers/TimesheetController.php b/app/modules/timesheet/controllers/TimesheetController.php
index cadc74fb7..a86b5b045 100755
--- a/app/modules/timesheet/controllers/TimesheetController.php
+++ b/app/modules/timesheet/controllers/TimesheetController.php
@@ -28,7 +28,7 @@ public function accessRules()
'allow', // allow authenticated user to perform 'create' and 'update' actions
'actions' => [
'index', 'instructors', 'GetInstructorDisciplines', 'addInstructors', 'loadUnavailability',
- 'getTimesheet', 'generateTimesheet', "addinstructorsdisciplines", "changeSchedules", "ChangeInstructor", "changeUnavailableSchedule"
+ 'getTimesheet', 'generateTimesheet', "addinstructorsdisciplines", "changeSchedules", "ChangeInstructor", "changeUnavailableSchedule", "fixBuggedUnavailableDaysFor2024"
], 'users' => ['@'],
], [
'allow', // allow admin user to perform 'admin' and 'delete' actions
@@ -756,6 +756,44 @@ public function actionAddSchedule()
echo json_encode(["valid" => true, "adds" => $adds, "disciplines" => $disciplines]);
}
+ public function actionFixBuggedUnavailableDaysFor2024()
+ {
+ //Nessa função, precisa-se passar em cada schedule de 2024 e verificar se o dia está indisponível (coluna unavailable = 1) quando, na verdade, ele está disponível
+ //O erro surgiu quando o usuário chamava o método chanceEvent no calendário e trocava um evento de feriado/férias por um evento útil. Naquele algoritmo, ele não trocava a flag de unavailable de 1 para 0.
+ //Isso foi resolvido a nível de código, mas os problemas que já existiam no banco continuaram.
+ //Esse algoritmo, em resumo, considerará o dia disponível quando estiver:
+ //(I) entre a data de início e fim do calendário; e
+ //(II) fora de um intervalo marcado como feriado, férias ou ponto facultativo.
+ //OBS: ESSE ERRO FOI DESCOBERTO PORQUE TINHA DIAS DE AULA NO QUADRO DE HORÁRIO QUE NÃO CONSTAVAM EM AULAS MINISTRADAS. VERIFICOU-SE QUE AS AULAS DAQUELE DIA, APESAR DE ÚTIL, ESTAVAM MARCADAS COMO UNAVAILABLE
+ $classrooms = Classroom::model()->findAll("school_year = 2024");
+ foreach ($classrooms as $classroom) {
+ $calendar = $classroom->calendarFk;
+ $calendarStartDate = $calendar->start_date;
+ $calendarEndDate = $calendar->end_date;
+ foreach ($classroom->schedules as $schedule) {
+ if ($schedule->unavailable) {
+ $scheduleDate = $schedule->year . "-" . str_pad($schedule->month, 2, "0", STR_PAD_LEFT) . "-" . str_pad($schedule->day, 2, "0", STR_PAD_LEFT);
+ if ($scheduleDate >= $calendarStartDate && $scheduleDate <= $calendarEndDate) {
+ $mustRemoveUnavailable = false;
+ foreach ($calendar->calendarEvents as $calendarEvent) {
+ if ($calendarEvent->calendar_event_type_fk == 101 || $calendarEvent->calendar_event_type_fk == 102 || $calendarEvent->calendar_event_type_fk == 104) {
+ if (str_replace(" 00:00:00", "", $calendarEvent->start_date) >= $scheduleDate && str_replace(" 00:00:00", "", $calendarEvent->end_date) <= $scheduleDate) {
+ //Ao entrar aqui, a schedule está dentro do calendário letivo e não está em nenhum dia de feriado, férias ou ponto facultativo. Deve-se mudar a flag de unavailable de 1 para 0.
+ $mustRemoveUnavailable = true;
+ break;
+ }
+ }
+ }
+ if ($mustRemoveUnavailable) {
+ Schedule::model()->updateAll(["unavailable" => 0], "id = :id", [":id" => $schedule->id]);
+ }
+ }
+ }
+ };
+ }
+ var_dump("Fim de código");
+ }
+
// public function actionGetInstructorDisciplines($id)
// {
// /** @var $istructorDisciplines InstructorDisciplines[]
diff --git a/app/repository/ReportsRepository.php b/app/repository/ReportsRepository.php
index 454ae6f98..190c0e791 100644
--- a/app/repository/ReportsRepository.php
+++ b/app/repository/ReportsRepository.php
@@ -116,11 +116,12 @@ public function getStudentCpfRgNisAllClassrooms(): array
jOIN student_identification si ON se.student_fk = si.id
JOIN student_documents_and_address sdaa ON si.id = sdaa.id
JOIN classroom c ON se.classroom_fk = c.id
- WHERE c.school_inep_fk = :school_inep_id AND ((`se`.`status` IN (1, 6, 7, 8, 9, 10) or `se`.`status` is null))
+ WHERE c.school_inep_fk = :school_inep_id AND c.school_year = :school_year AND ((`se`.`status` IN (1, 6, 7, 8, 9, 10) or `se`.`status` is null))
GROUP BY si.name
ORDER BY si.name;";
$result = Yii::app()->db->createCommand($sql)
->bindParam(":school_inep_id", $school->inep_id)
+ ->bindParam(":school_year", Yii::app()->user->year)
->queryAll();
$allClassrooms = true;
diff --git a/config.php b/config.php
index 48aeba3b3..8bc552b7f 100644
--- a/config.php
+++ b/config.php
@@ -7,7 +7,7 @@
defined('YII_DEBUG') or define('YII_DEBUG', $debug);
defined("SESSION_MAX_LIFETIME") or define('SESSION_MAX_LIFETIME', 3600);
-define("TAG_VERSION", '3.91.208');
+define("TAG_VERSION", '3.93.210');
define("YII_VERSION", Yii::getVersion());
define("BOARD_MSG", '