diff --git a/app/config/main.php b/app/config/main.php index 62ae2f58b..a5d293838 100755 --- a/app/config/main.php +++ b/app/config/main.php @@ -17,7 +17,7 @@ ), ); -if(YII_DEBUG){ +if(!YII_DEBUG){ array_push($log_config['routes'], array( 'class'=>'CWebLogRoute', ) diff --git a/app/controllers/ReportsController.php b/app/controllers/ReportsController.php index d629f6d6d..b36583bea 100644 --- a/app/controllers/ReportsController.php +++ b/app/controllers/ReportsController.php @@ -12,7 +12,7 @@ public function accessRules() return array( array('allow', // allow authenticated user to perform 'create' and 'update' actions 'actions' => array('index', 'BFReport', 'numberStudentsPerClassroomReport', - 'InstructorsPerClassroomReport', 'StudentsFileReport', + 'EnrollmentStatisticsByYearReport','InstructorsPerClassroomReport', 'StudentsFileReport', 'getStudentsFileInformation', 'ResultBoardReport', 'StatisticalDataReport', 'StudentsDeclarationReport', 'EnrollmentPerClassroomReport', 'AtaSchoolPerformance', @@ -401,6 +401,77 @@ public function actionNumberStudentsPerClassroomReport() $this->render('NumberStudentsPerClassroomReport', $query); } + public function actionEnrollmentStatisticsByYearReport() + { + // Construíndo condicionais e definindo ordenação para a consulta + $criteria = new CDbCriteria; + $criteria->order = 'name ASC'; + $criteria->condition = "school_year = :year"; + $criteria->params = array("year" => Yii::app()->user->year); + //Consulta todas as classes abertas no ano atual + $classrooms = Classroom::model()->findAll($criteria); + $stages = []; + $schools = []; + foreach ($classrooms as $classroom) { + //Coloca em um array o nome de todas as escolas que já não estão no mesmo (através da lista de classes) + if (!in_array($schools, $classroom->schoolInepFk->name)) { + array_push($schools, $classroom->schoolInepFk->name); + } + //Coloca em um array todos o stage number e nome dos estágios que já não estão no mesmo (através da lista de classes) + if (array_search($classroom->edcensoStageVsModalityFk->name, array_column($stages, 'name')) === false) { + array_push($stages, ["stageNumber" => $classroom->edcensoStageVsModalityFk->stage, "name" => $classroom->edcensoStageVsModalityFk->name, "alias" => $classroom->edcensoStageVsModalityFk->alias]); + } + } + //Cria a primeira linha da tabela com o grupo de estágios + $stageNumberGroups = []; + foreach($stages as $stage) { + if ($stageNumberGroups[$stage["stageNumber"]] == null){ + //Adiciona indexado pelo stageNumber do array $stage a quantidade de celulas do estágio e o nome + $stageNumberGroups[$stage["stageNumber"]]["colspan"] = 0; + $stageNumberGroups[$stage["stageNumber"]]["colname"] = $this->translateStageNumbers($stage["stageNumber"]); + } + //Pra cada estagio, concatena mais uma celula ao grupo de estagios + $stageNumberGroups[$stage["stageNumber"]]["colspan"]++; + } + + //Inicializa as celulas de contagem de matriculas com valor 0 + $schoolStages = []; + foreach ($schools as $school) { + foreach ($stages as $stage) { + $schoolStages[$school][$stage["stageNumber"]][$stage["name"]] = 0; + } + } + + //Para cada classe incrementa o contador de matriculas em cada celular dos estágios + foreach ($classrooms as $classroom) { + $schoolStages[$classroom->schoolInepFk->name][$classroom->edcensoStageVsModalityFk->stage][$classroom->edcensoStageVsModalityFk->name] += count($classroom->studentEnrollments); + } + + $this->render('EnrollmentStatisticsByYearReport', array( + 'schoolStages' => $schoolStages, + 'stageNumberGroups' => $stageNumberGroups, + 'stages' => $stages + )); + } + + private function translateStageNumbers ($stageNumber) { + switch($stageNumber) { + case "1" : + return "Ensino Infantil"; + case "2": + return "Ensino Fundamental Menor"; + case "3": + case "7": + return "Ensino Fundamental Maior"; + case "4": + return "Ensino Médio"; + case "6": + return "EJA"; + default: + return "Resto"; + } + } + public function actionClocReport() { $repository = new ReportsRepository; diff --git a/app/migrations/2023-09-19_enrollment_statistics_report/scripts.sql b/app/migrations/2023-09-19_enrollment_statistics_report/scripts.sql new file mode 100644 index 000000000..a30fae188 --- /dev/null +++ b/app/migrations/2023-09-19_enrollment_statistics_report/scripts.sql @@ -0,0 +1,6 @@ +ALTER TABLE +ADD `alias` varchar(20) COLLATE 'utf8_unicode_ci' NULL AFTER `name`; + + +UPDATE `edcenso_stage_vs_modality` + set alias = SUBSTRING(trim(SUBSTRING_INDEX(SUBSTRING_INDEX(name , '-', -1), '-', -1)), 1, 20) diff --git a/app/models/EdcensoStageVsModality.php b/app/models/EdcensoStageVsModality.php index c1dbbfa8e..4fd4ac049 100755 --- a/app/models/EdcensoStageVsModality.php +++ b/app/models/EdcensoStageVsModality.php @@ -6,6 +6,7 @@ * The followings are the available columns in table 'edcenso_stage_vs_modality': * @property integer $id * @property string $name + * @property string $alias * @property integer $stage * * The followings are the available model relations: @@ -108,10 +109,12 @@ public function rules() { // NOTE: you should only define rules for those attributes that // will receive user inputs. return [ - ['name, stage', 'required'], ['stage', 'numerical', 'integerOnly' => TRUE], + ['name, stage', 'required'], + ['stage', 'numerical', 'integerOnly' => TRUE], ['name', 'length', 'max' => 100], // The following rule is used by search(). + ['alias', 'length', 'max'=>20], // Please remove those attributes that should not be searched. - ['id, name, stage', 'safe', 'on' => 'search'], + ['id, name, alias, stage', 'safe', 'on' => 'search'], ]; } @@ -151,6 +154,7 @@ public function search() { $criteria->compare('id', $this->id); $criteria->compare('name', $this->name, TRUE); + $criteria->compare('alias',$this->alias, TRUE); $criteria->compare('stage', $this->stage); return new CActiveDataProvider($this, [ diff --git a/js/reports/EnrollmentStatisticsByYearReport/functions.js b/js/reports/EnrollmentStatisticsByYearReport/functions.js new file mode 100644 index 000000000..00ad17559 --- /dev/null +++ b/js/reports/EnrollmentStatisticsByYearReport/functions.js @@ -0,0 +1,39 @@ +$(document).ready(function() { + + var totalEnrollmentPerSchool; + var columnIndex; + + $('#enrollment-table tbody tr').each(function() { + totalEnrollmentPerSchool = 0; + columnIndex = 0; + $(this).find(".stage-enrollment").each(function(i, value) { + totalEnrollmentPerSchool += Number($(value).html()); + $(value).addClass('col-'+columnIndex); + columnIndex++; + }); + $(this).find(".school-total, .unity-total").html(totalEnrollmentPerSchool); + }); + + $('#enrollment-table tfoot .col-total .stage-total').each(function(i) { + var colTotal = 0; + $('.col-'+i).each(function() { + colTotal += Number($(this).html()); + }); + $(this).html(colTotal); + }); + + $('#enrollment-table tfoot .group-stage-total .group-total').each(function(i) { + var groupTotal = 0; + $('.stage-'+i).each(function() { + groupTotal += Number($(this).html()); + }); + $(this).html(groupTotal); + }); + + var redeTotal = 0; + $('.unity-total').each(function() { + redeTotal += Number($(this).html()); + }); + $('.rede-total').html(redeTotal); + +}); \ No newline at end of file diff --git a/themes/default/views/reports/EnrollmentStatisticsByYearReport.php b/themes/default/views/reports/EnrollmentStatisticsByYearReport.php new file mode 100644 index 000000000..5f5aeafef --- /dev/null +++ b/themes/default/views/reports/EnrollmentStatisticsByYearReport.php @@ -0,0 +1,121 @@ +clientScript->registerCoreScript('jquery'); +$baseUrl = Yii::app()->baseUrl; +$cs = Yii::app()->getClientScript(); +$cs->registerScriptFile($baseUrl . '/js/reports/EnrollmentStatisticsByYearReport/functions.js', CClientScript::POS_END); +$this->setPageTitle('TAG - ' . Yii::t('default', 'Reports')); +?> + + + +
+ renderPartial('HeadWithoutSchool'); ?> +

+
+
+ +
+
+
+ + + + + + $stageNumberGroup): ?> + + + + + + + + $schoolNameValue): ?> + $stageNumberValue): ?> + $enrollmentsCount): ?> + + + + + + + + + + + + + $schoolNameValue): ?> + + + + + $stageNumberValue): ?> + $enrollmentsCount): ?> + + + + + + + + + + + + $schoolNameValue): ?> + $stageNumberValue): ?> + $enrollmentsCount): ?> + + + + + + + + + + $stageNumberGroup): ?> + + + + + +
ANO LETIVO DE user->year ?>">
Unidade EscolarTotal de EstudantesTotal por Unidade
00
Total de Alunos na Rede00
">0
+
+
renderPartial('footer'); ?>
+
+ diff --git a/themes/default/views/reports/HeadWithoutSchool.php b/themes/default/views/reports/HeadWithoutSchool.php new file mode 100644 index 000000000..83fc8a156 --- /dev/null +++ b/themes/default/views/reports/HeadWithoutSchool.php @@ -0,0 +1,36 @@ +findByPk(Yii::app()->user->school); +} + +?> + +

+
+ logo_file_name)){ + echo ''; + }; + ?> + + + + +
diff --git a/themes/default/views/reports/index.php b/themes/default/views/reports/index.php index 30b3c8625..455a5f6f7 100644 --- a/themes/default/views/reports/index.php +++ b/themes/default/views/reports/index.php @@ -48,6 +48,18 @@ + + + +