Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/ipti/br.tag into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
LiviaMartinsIPTI committed Apr 23, 2024
2 parents e09e332 + c03c1ea commit 1b189a8
Show file tree
Hide file tree
Showing 31 changed files with 1,301 additions and 833 deletions.
31 changes: 28 additions & 3 deletions CHANGELOG.md
@@ -1,3 +1,31 @@
## [Versão 3.77.135]
- Adicionado novas inconsistências para a falta de componentes curriculasres

## [Versão 3.77.134]
- Consertado tela de frequencia para os professores
-
## [Versão 3.77.133]
- Realizado correções nas validações das datas para Professor, Estudante e Escola

## [Versão 3.78.132]
- Adicionado campo para a assinatura do diretor

## [Versão 3.77.132]
- Criando as telas relacionadas a agricultor no novo módulo de merenda escolar

## [Versão 3.76.131]
- Adicionado gerência de editais anuais de aquisição de gêneros alimentícios da agricultura familiar e empreendedor familiar rural

## [Versão 3.76.130]
- Correção no conteúdo ministrado em sala de aula

## [Versão 3.76.129]
- Correção na descrição da séries para as inconsistências sagres

## [Versão 3.76.128]
- Corrigido erro que não mostrava o nome da escola e das turmas nas inconsistências sagres
- Corrigido na busca por profissional na mesma escola

## [Versão 3.76.127]
- Corrigido erro que não saía do painel de cadastros pendentes, referente à matriz curricular e estrutura de notas

Expand All @@ -18,9 +46,6 @@
## [Versão 3.75.122]
- Adicionada lógica, para que ao reaproveitar turmas, os alunos do ano de 2023 entrarão como matriculados.

## [Versão 3.75.121]
- Adicionado gerência de editais anuais de aquisição de gêneros alimentícios da agricultura familiar e empreendedor familiar rural

## [Versão 3.74.121]
- Correção no relatório de professores por escola

Expand Down
74 changes: 54 additions & 20 deletions app/controllers/ClassesController.php
Expand Up @@ -40,13 +40,15 @@ public function accessRules()
'index',
'frequency',
'saveFrequency',
'SaveFrequencies',
'classContents',
'getClassContents',
'saveClassContents',
'getmonthsanddisciplines',
'getdisciplines',
'getfrequency',
'saveJustification'
'saveJustification',
'saveJustifications'
),
'users' => array('@'),
),
Expand Down Expand Up @@ -82,7 +84,6 @@ public function actionClassContents()
);

$classrooms = Classroom::model()->findAll($criteria);

} else {
$classrooms = Classroom::model()->findAll(
'school_year = :school_year and school_inep_fk = :school_inep_fk order by name',
Expand Down Expand Up @@ -114,8 +115,7 @@ public function actionGetClassContents()
$students = $this->getStudentsByClassroom($classroomId);

if (!$isMinorEducation) {
$schedules = $this->getSchedulesFromMajorStage($classroomId, $month, $disciplineId, $year);

$schedules = $this->getSchedulesFromMajorStage($classroomId, $month, $year, $disciplineId);
} else {
$schedules = $this->getSchedulesFromMinorStage($classroomId, $month, $year);
}
Expand Down Expand Up @@ -183,7 +183,7 @@ public function actionGetClassContents()
"courseClasses" => $courseClasses,
]);
} else {
echo json_encode(["valid" => false, "error" => "Mês/Ano " . ($_POST["fundamentalMaior"] == "1" ? "e Disciplina": "") . " sem aula no Quadro de Horário."]);
echo json_encode(["valid" => false, "error" => "Mês/Ano " . ($_POST["fundamentalMaior"] == "1" ? "e Disciplina" : "") . " sem aula no Quadro de Horário."]);
}
}

Expand All @@ -195,7 +195,7 @@ public function actionGetClassContents()
* @param integer $disciplineId
* @return Schedule[]
*/
private function getSchedulesFromMajorStage($classroomId, $month, $year, $disciplineId)
private function getSchedulesFromMajorStage($classroomId, $month, $disciplineId, $year)
{
return Schedule::model()->findAll(
"classroom_fk = :classroom_fk and month = :month and year = :year and discipline_fk = :discipline_fk and unavailable = 0 order by day, schedule",
Expand Down Expand Up @@ -244,7 +244,6 @@ private function getStudentsByClassroom($classroomId)
)
->bindParam(":classroom_fk", $classroomId)
->queryAll();

}

/**
Expand Down Expand Up @@ -274,7 +273,6 @@ private function buildClassContents($schedules, $students)
}

return $classContents;

}

private function updateStudentAnottations($schedule, $students)
Expand Down Expand Up @@ -340,7 +338,6 @@ private function loadSchedulesByStage($isMajorStage, $classroom, $month, $year,
"year" => $year,
]
);

}

/**
Expand All @@ -364,7 +361,6 @@ private function saveSchedule($schedule, $classContent)
foreach ($classContent["contents"] as $content) {
$this->saveClassContents($content, $schedule);
}

}

private function saveClassContents($content, $schedule)
Expand Down Expand Up @@ -464,6 +460,7 @@ public function actionGetFrequency()
$criteria->order = 'name';
$enrollments = StudentEnrollment::model()->findAllByAttributes(array('classroom_fk' => $_POST["classroom"]), $criteria);
if ($schedules != null) {
$scheduleDays = $this->getScheduleDays($schedules);
if ($enrollments != null) {
$students = [];
$dayName = ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado"];
Expand All @@ -474,23 +471,56 @@ public function actionGetFrequency()
foreach ($schedules as $schedule) {
$classFault = ClassFaults::model()->find("schedule_fk = :schedule_fk and student_fk = :student_fk", ["schedule_fk" => $schedule->id, "student_fk" => $enrollment->student_fk]);
$available = date("Y-m-d") >= $schedule->year . "-" . str_pad($schedule->month, 2, "0", STR_PAD_LEFT) . "-" . str_pad($schedule->day, 2, "0", STR_PAD_LEFT);
$date = $this->gerateDate($schedule->day, $schedule->month, $schedule->year);
array_push($array["schedules"], [
"available" => $available,
"day" => $schedule->day,
"week_day" => $dayName[$schedule->week_day],
"schedule" => $schedule->schedule,
"fault" => $classFault != null,
"justification" => $classFault->justification
"justification" => $classFault->justification,
"date" => $date
]);
}
array_push($students, $array);
}
echo json_encode(["valid" => true, "students" => $students]);
echo json_encode(["valid" => true, "students" => $students, "scheduleDays" => $scheduleDays]);
} else {
echo json_encode(["valid" => false, "error" => "Matricule alunos nesta turma para trazer o Quadro de Frequência."]);
}
} else {
echo json_encode(["valid" => false, "error" => "Mês/Ano " . ($_POST["fundamentalMaior"] == "1" ? "e Disciplina": "") . " sem aula no Quadro de Horário."]);
echo json_encode(["valid" => false, "error" => "Mês/Ano " . ($_POST["fundamentalMaior"] == "1" ? "e Disciplina" : "") . " sem aula no Quadro de Horário."]);
}
}
private function gerateDate($day, $month, $year)
{
$day = ($day < 10) ? '0' . $day : $day;
$month = ($month < 10) ? '0' . $month : $month;
return $day . "/" . $month . "/" . $year;
}
private function getScheduleDays($schedules)
{
$result = [];
foreach ($schedules as $schedule) {
$day = ($schedule->day < 10) ? '0' . $schedule->day : $schedule->day;
$month = ($schedule->month < 10) ? '0' . $schedule->month : $schedule->month;
$date = $day . "/" . $month . "/" . $schedule->year;
$index = array_search($date, array_column($result, 'date'));
if ($index === false) {
array_push($result, [
"day" => $schedule->day,
"date" => $date
]);
}
}
return $result;
}

public function actionSaveFrequencies()
{
$schedules = Schedule::model()->findAll("classroom_fk = :classroom_fk and day = :day and year = :year and month = :month", ["classroom_fk" => $_POST["classroomId"], "day" => $_POST["day"], "month" => $_POST["month"], "year" => $_POST["year"]]);
foreach ($schedules as $schedule) {
$this->saveFrequency($schedule);
}
}

Expand Down Expand Up @@ -522,7 +552,6 @@ private function saveFrequency($schedule)
} else {
ClassFaults::model()->deleteAll("schedule_fk = :schedule_fk and student_fk = :student_fk", ["schedule_fk" => $schedule->id, "student_fk" => $_POST["studentId"]]);
}

} else {
if ($_POST["fault"] == "1") {
$enrollments = StudentEnrollment::model()->findAll("classroom_fk = :classroom_fk", ["classroom_fk" => $_POST["classroomId"]]);
Expand All @@ -542,6 +571,15 @@ private function saveFrequency($schedule)
}
}

public function actionSaveJustifications()
{
$schedules = Schedule::model()->findAll("classroom_fk = :classroom_fk and day = :day and month = :month and year = :year ", ["classroom_fk" => $_POST["classroomId"], "day" => $_POST["day"], "month" => $_POST["month"], "year" => $_POST["year"]]);
foreach ($schedules as $schedule) {
$classFault = ClassFaults::model()->find("schedule_fk = :schedule_fk and student_fk = :student_fk", ["schedule_fk" => $schedule->id, "student_fk" => $_POST["studentId"]]);
$classFault->justification = $_POST["justification"] == "" ? null : $_POST["justification"];
$classFault->save();
}
}
public function actionSaveJustification()
{

Expand All @@ -550,15 +588,12 @@ public function actionSaveJustification()
$classFault = ClassFaults::model()->find("schedule_fk = :schedule_fk and student_fk = :student_fk", ["schedule_fk" => $schedule->id, "student_fk" => $_POST["studentId"]]);
$classFault->justification = $_POST["justification"] == "" ? null : $_POST["justification"];
$classFault->save();


} else {
$schedules = Schedule::model()->findAll("classroom_fk = :classroom_fk and day = :day and month = :month and year = :year ", ["classroom_fk" => $_POST["classroomId"], "day" => $_POST["day"], "month" => $_POST["month"], "year" => $_POST["year"]]);
foreach ($schedules as $schedule) {
$classFault = ClassFaults::model()->find("schedule_fk = :schedule_fk and student_fk = :student_fk", ["schedule_fk" => $schedule->id, "student_fk" => $_POST["studentId"]]);
$classFault->justification = $_POST["justification"] == "" ? null : $_POST["justification"];
$classFault->save();

}
}
}
Expand Down Expand Up @@ -594,7 +629,8 @@ public function actionGetMonthsAndDisciplines()
join instructor_identification ii on ii.id = itd.instructor_fk
join curricular_matrix cm on cm.id = tm.curricular_matrix_fk
join edcenso_discipline ed on ed.id = cm.discipline_fk
where ii.users_fk = :userid and itd.classroom_id_fk = :crid order by ed.name")->bindParam(":userid", Yii::app()->user->loginInfos->id)->bindParam(":crid", $classroom->id)->queryAll();
where ii.users_fk = :userid and itd.classroom_id_fk = :crid order by ed.name"
)->bindParam(":userid", Yii::app()->user->loginInfos->id)->bindParam(":crid", $classroom->id)->queryAll();
} else {
$disciplines = Yii::app()->db->createCommand("select ed.id, ed.name from curricular_matrix join edcenso_discipline ed on ed.id = curricular_matrix.discipline_fk where stage_fk = :stage_fk and school_year = :year order by ed.name")->bindParam(":stage_fk", $classroom->edcenso_stage_vs_modality_fk)->bindParam(":year", Yii::app()->user->year)->queryAll();
}
Expand All @@ -608,8 +644,6 @@ public function actionGetMonthsAndDisciplines()
$result = ["valid" => false, "error" => "A Turma está sem Calendário Escolar vinculado."];
}
echo json_encode($result);


}

/**
Expand Down
17 changes: 16 additions & 1 deletion app/controllers/StudentController.php
Expand Up @@ -455,6 +455,8 @@ public function actionUpdate($id)
$modelStudentDocumentsAndAddress = $this->loadModel($id, $this->STUDENT_DOCUMENTS_AND_ADDRESS);
$modelStudentRestrictions = $this->loadModel($id, $this->STUDENT_RESTRICTIONS);

$oldCpf = $modelStudentDocumentsAndAddress->cpf;

$vaccines = Vaccine::model()->findAll(array('order' => 'name'));
$studentVaccinesSaves = StudentVaccine::model()->findAll(['select' => 'vaccine_id', 'condition' => 'student_id=:student_id', 'params' => [':student_id' => $id]]);
if ($studentVaccinesSaves) {
Expand All @@ -478,6 +480,19 @@ public function actionUpdate($id)
date_default_timezone_set("America/Recife");
$modelStudentIdentification->last_change = date('Y-m-d G:i:s');

$newCpf = $_POST[$this->STUDENT_DOCUMENTS_AND_ADDRESS]['cpf'];

if($oldCpf !== $newCpf && $newCpf !== "") {
$existCpf = StudentDocumentsAndAddress::model()->findByAttributes(array('cpf' => $modelStudentDocumentsAndAddress->cpf));

if($existCpf !== null) {
Yii::app()->user->setFlash(
'error', Yii::t('default', 'Já existe um registro associado a este CPF de um aluno cadastrado!')
);
$this->redirect(array('/student/update', 'id' => $modelStudentDocumentsAndAddress->id));
}
}

if ($modelStudentIdentification->validate() && $modelStudentDocumentsAndAddress->validate()) {
if ($modelStudentIdentification->save()) {
$modelStudentRestrictions->student_fk = $modelStudentIdentification->id;
Expand Down Expand Up @@ -525,7 +540,7 @@ public function actionUpdate($id)
}
}
}

if ($saved) {
$flash = "success";
$msg = 'O Cadastro de ' . $modelStudentIdentification->name . ' foi alterado com sucesso!';
Expand Down
14 changes: 14 additions & 0 deletions app/migrations/2024-06-04_add_lunch_unities/sql.sql
@@ -0,0 +1,14 @@
insert into lunch_unity (name, acronym) values
("Grama", "G"),
("Mililitro", "ML"),
("Unidade", "U"),
("Duzia", "DZ"),
("Pacote", "PCT");

UPDATE lunch_unity
SET acronym = 'L'
WHERE acronym = 'ML' AND name = 'litro';

UPDATE lunch_unity
SET acronym = 'ML'
WHERE acronym = 'mL' AND name = 'Mililitro';
@@ -0,0 +1 @@
ALTER TABLE farmer_register ADD COLUMN reference_id varchar(36);
35 changes: 35 additions & 0 deletions app/models/StudentDocumentsAndAddress.php
Expand Up @@ -115,9 +115,44 @@ public function rules()
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('register_type, school_inep_id_fk, student_fk, id, rg_number, rg_number_edcenso_organ_id_emitter_fk, rg_number_edcenso_uf_fk, rg_number_expediction_date, civil_certification, civil_certification_type, civil_certification_term_number, civil_certification_sheet, civil_certification_book, civil_certification_date, notary_office_uf_fk, notary_office_city_fk, edcenso_notary_office_fk, civil_register_enrollment_number, cpf, foreign_document_or_passport, nis, residence_zone, cep, address, number, complement, neighborhood, edcenso_uf_fk, edcenso_city_fk, received_cc, received_address, received_photo, received_nis, received_history, received_responsable_rg, received_responsable_cpf, cns, fkid, justice_restriction, diff_location', 'safe', 'on'=>'search'),
array('cpf', 'validateCPF')
);
}

public function validateCPF($cpfStudent)
{
$cpfStu = $this->$cpfStudent;

if($cpfStu === "") {
return true;
}

$cpf = preg_replace('/[^0-9]/', '', $cpfStu);

if (strlen($cpf) !== 11) {
$this->addError($cpfStudent, 'O CPF deve conter exatamente 11 números.');
return;
}

if (preg_match('/(\d)\1{10}/', $cpf)) {
$this->addError($cpfStudent, 'O CPF não pode ter todos os dígitos iguais.');
return;
}

for ($t = 9; $t < 11; $t++) {
for ($d = 0, $c = 0; $c < $t; $c++) {
$d += $cpf[$c] * (($t + 1) - $c);
}
$d = ((10 * $d) % 11) % 10;
if ($cpf[$c] != $d) {
$this->addError($cpfStudent, 'O CPF é inválido.');
return;
}
}
return true;
}


/**
* @return array relational rules.
*/
Expand Down

0 comments on commit 1b189a8

Please sign in to comment.