Merge branch 'component_updates' into 'develop'

adding course filter to report creation, updated SectorList / CourseFields Views in Drupal

See merge request !79
parents 7661ec7b 80db8b2d
......@@ -141,7 +141,7 @@ epal.ministry.log_out_go:
requirements:
_user_is_logged_in: 'TRUE'
epal.ministry.general_report:
path: '/ministry/general-report/{regionId}/{adminId}/{schId}'
path: '/ministry/general-report'
options:
_auth: [ 'basic_auth' ]
defaults:
......@@ -157,7 +157,7 @@ epal.ministry.report-completeness:
requirements:
_user_is_logged_in: 'TRUE'
epal.ministry.report-all-stat:
path: '/ministry/report-all-stat/{regionId}/{adminId}/{schId}'
path: '/ministry/report-all-stat/{regionId}/{adminId}/{schId}/{classId}/{sectorId}/{courseId}'
options:
_auth: [ 'basic_auth' ]
defaults:
......
......@@ -56,7 +56,7 @@ class ReportsCreator extends ControllerBase {
}
public function makegGeneralReport(Request $request, $regionId, $adminId, $schId) {
public function makegGeneralReport(Request $request) {
try {
if (!$request->isMethod('GET')) {
......@@ -141,8 +141,6 @@ class ReportsCreator extends ControllerBase {
public function makeReportCompleteness(Request $request, $regionId, $adminId, $schId) {
//$this->checkAuthorization($request);
try {
if (!$request->isMethod('GET')) {
......@@ -177,6 +175,17 @@ class ReportsCreator extends ControllerBase {
$list = array();
//βρες ανώτατο επιτρεπόμενο όριο μαθητών
/*
$sCon = $this->connection->select('epal_class_limits', 'eSchool')
->fields('eSchool', array('name', 'limit_up'))
->condition('eSchool.name', '1' , '=');
$epalLimitUps = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
$epalLimitUp = reset($epalLimitUps);
$limitUp = $epalLimitUp->limit_up;
*/
$limitUp = $this->retrieveUpLimit();
//βρες όλα τα σχολεία που πληρούν τα κριτήρια / φίλτρα
$sCon = $this->connection->select('eepal_school_field_data', 'eSchool')
->fields('eSchool', array('id', 'name', 'capacity_class_a', 'region_edu_admin_id', 'edu_admin_id'));
......@@ -188,15 +197,26 @@ class ReportsCreator extends ControllerBase {
$sCon->condition('eSchool.id', $schId, '=');
$epalSchools = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
//βρες ανώτατο επιτρεπόμενο όριο μαθητών
$sCon = $this->connection->select('epal_class_limits', 'eSchool')
->fields('eSchool', array('name', 'limit_up'))
->condition('eSchool.name', '1' , '=');
$epalLimitUps = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
$epalLimitUp = reset($epalLimitUps);
$limitUp = $epalLimitUp->limit_up;
foreach ($epalSchools as $epalSchool) {
//εύρεση ονόματος ΠΔΕ που ανήκει το σχολείο
$sCon = $this->connection->select('eepal_region_field_data', 'eRegion')
->fields('eRegion', array('id','name'))
->condition('eRegion.id', $epalSchool->region_edu_admin_id, '=');
$epalRegions = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
$epalRegion = reset($epalRegions);
$regionColumn = $epalRegion->name;
//εύρεση ονόματος ΔΙΔΕ που ανήκει το σχολείο
$sCon = $this->connection->select('eepal_admin_area_field_data', 'eAdmin')
->fields('eAdmin', array('id','name'))
->condition('eAdmin.id', $epalSchool->edu_admin_id, '=');
$epalAdmins = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
$epalAdmin = reset($epalAdmins);
$adminColumn = $epalAdmin->name;
//βρες μέγιστη χωρητικότητα για κάθε τάξη
$capacity = array();
//χωρητικότητα για Α' τάξη
......@@ -232,27 +252,17 @@ class ReportsCreator extends ControllerBase {
->condition('eStudent.currentclass', $classId , '=');
array_push( $num, $sCon->countQuery()->execute()->fetchField() );
//βρες ποσοστά συμπλήρωσης
array_push( $perc, number_format($num[$classId-1] / $capacity[$classId-1] * 100 , 1) . "%");
array_push( $perc, number_format($num[$classId-1] / $capacity[$classId-1] * 100 , 2) . "%");
}
$percTotal = number_format (array_sum($num) / array_sum($capacity) * 100, 1) . "%";
$percTotal = number_format (array_sum($num) / array_sum($capacity) * 100, 2) . "%";
//αποστολή αποτελεσμάτων / στατιστικών
//if ($num[0] !== "0" || $num[1] !== "0" || $num[2] !== "0")
/*
array_push($list,(object) array(
'name' => $epalSchool->name, 'numStudents' => $num[0] + $num[1] + $num[2], 'capacityTotal' => $capacityTotal, 'percTotal' => $percTotal,
'numStudentsA' => $num[0], 'capacityA' => $capacity[0], 'percA' => $perc[0],
'numStudentsB' => $num[1], 'capacityB' => $capacity[1], 'percB' => $perc[1],
'numStudentsC' => $num[2], 'capacityC' => $capacity[2], 'percC' => $perc[2])
);
*/
array_push($list,(object) array(
'name' => $epalSchool->name, 'percTotal' => $percTotal,
'name' => $epalSchool->name,
'region' => $regionColumn,
'admin' => $adminColumn,
'percTotal' => $percTotal,
'percA' => $perc[0],
'percB' => $perc[1],
'percC' => $perc[2])
......@@ -276,7 +286,7 @@ class ReportsCreator extends ControllerBase {
public function makeReportAllStat(Request $request, $regionId, $adminId, $schId) {
public function makeReportAllStat(Request $request, $regionId, $adminId, $schId, $classId, $sectorId, $courseId) {
try {
......@@ -310,6 +320,8 @@ class ReportsCreator extends ControllerBase {
], Response::HTTP_FORBIDDEN);
}
$limitup = $this->retrieveUpLimit();
$list = array();
//βρες όλα τα σχολεία που πληρούν τα κριτήρια / φίλτρα
......@@ -327,10 +339,13 @@ class ReportsCreator extends ControllerBase {
foreach ($epalSchools as $epalSchool) { //για κάθε σχολείο
$schoolNameColumn = array();
$regionColumn = array();
$adminColumn = array();
$schoolSectionColumn = array();
$numColumn = array();
$adminColumn = array();
$regionColumn = array();
$capacityColumn = array();
$percColumn = array();
//εύρεση ονόματος ΠΔΕ που ανήκει το σχολείο
$sCon = $this->connection->select('eepal_region_field_data', 'eRegion')
......@@ -347,31 +362,71 @@ class ReportsCreator extends ControllerBase {
$epalAdmin = reset($epalAdmins);
//εύρεση αριθμού μαθητών για κάθε τάξη
array_push($schoolSectionColumn, 'Α τάξη');
array_push($schoolSectionColumn, 'Β τάξη');
array_push($schoolSectionColumn, 'Γ τάξη');
for ( $classId = 1; $classId <= 3; $classId++) {
$sCon = $this->connection->select('epal_student_class', 'eStudent')
->fields('eStudent', array('id', 'epal_id', 'currentclass'))
->condition('eStudent.epal_id', $epalSchool->id , '=')
->condition('eStudent.currentclass', $classId , '=');
array_push($schoolNameColumn, $epalSchool->name);
array_push( $numColumn, $sCon->countQuery()->execute()->fetchField() );
array_push($regionColumn, $epalRegion->name);
array_push($adminColumn, $epalAdmin->name);
}
//array_push($schoolSectionColumn, 'Α τάξη');
//array_push($schoolSectionColumn, 'Β τάξη');
//array_push($schoolSectionColumn, 'Γ τάξη');
if ($sectorId === "0" && $courseId == 0) { //|| courseId === 0
$clidstart = 1;
$clidend = 3;
if ($classId !== "0") {
$clidstart = $classId;
$clidend = $classId;
if ($classId === "1")
array_push($schoolSectionColumn, 'Α τάξη');
else if ($classId === "2")
array_push($schoolSectionColumn, 'Β τάξη');
else if ($classId === "3")
array_push($schoolSectionColumn, 'Γ τάξη');
}
else {
array_push($schoolSectionColumn, 'Α τάξη');
array_push($schoolSectionColumn, 'Β τάξη');
array_push($schoolSectionColumn, 'Γ τάξη');
}
for ( $clId = $clidstart; $clId <= $clidend; $clId++) {
$sCon = $this->connection->select('epal_student_class', 'eStudent')
->fields('eStudent', array('id', 'epal_id', 'currentclass'))
->condition('eStudent.epal_id', $epalSchool->id , '=')
->condition('eStudent.currentclass', $clId , '=');
$numStud = $sCon->countQuery()->execute()->fetchField();
array_push($schoolNameColumn, $epalSchool->name);
array_push($regionColumn, $epalRegion->name);
array_push($adminColumn, $epalAdmin->name);
//array_push($numColumn, $sCon->countQuery()->execute()->fetchField() );
array_push($numColumn, $numStud);
array_push($capacityColumn, $epalSchool->capacity_class_a * $limitup);
array_push($percColumn, number_format($numStud / ($epalSchool->capacity_class_a * $limitup) * 100, 2) . '%' );
}
} //end if
//εύρεση αριθμού μαθητών για κάθε τομέα της Β' τάξης
if ($classId === "0" || $classId === "2") {
$sCon = $this->connection->select('eepal_sectors_in_epal_field_data', 'eSchool')
->fields('eSchool', array('sector_id'))
->fields('eSchool', array('sector_id','capacity_class_sector'))
->condition('eSchool.epal_id', $epalSchool->id , '=');
if ($sectorId != "0")
$sCon->condition('eSchool.sector_id', $sectorId, '=');
$sectorsInEpals = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($sectorsInEpals as $sectorsInEpal) {
$sCon = $this->connection->select('eepal_sectors_field_data', 'eSectors')
->fields('eSectors', array('name'))
->condition('eSectors.id', $sectorsInEpal->sector_id , '=');
$sectorsNamesInEpals = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($sectorsNamesInEpals as $sectorsNamesInEpal) {
array_push($regionColumn, $epalRegion->name);
array_push($adminColumn, $epalAdmin->name);
array_push($schoolNameColumn, $epalSchool->name);
array_push($schoolSectionColumn, 'Β τάξη / ' . $sectorsNamesInEpal->name );
$sCon = $this->connection->select('epal_student_class', 'eStudent')
......@@ -379,35 +434,53 @@ class ReportsCreator extends ControllerBase {
->condition('eStudent.epal_id', $epalSchool->id , '=')
->condition('eStudent.currentclass', 2 , '=')
->condition('eStudent.specialization_id', $sectorsInEpal->sector_id , '=');
array_push( $numColumn, $sCon->countQuery()->execute()->fetchField() );
array_push($regionColumn, $epalRegion->name);
array_push($adminColumn, $epalAdmin->name);
$numStud = $sCon->countQuery()->execute()->fetchField();
array_push( $numColumn, $numStud );
array_push($capacityColumn, $sectorsInEpal->capacity_class_sector * $limitup);
array_push($percColumn, number_format($numStud / ($sectorsInEpal->capacity_class_sector * $limitup) * 100, 2) . '%' );
}
}
} //end if
//εύρεση αριθμού μαθητών για κάθε ειδικότητα της Γ' τάξης
$sCon = $this->connection->select('eepal_specialties_in_epal_field_data', 'eSchool')
->fields('eSchool', array('specialty_id'))
->condition('eSchool.epal_id', $epalSchool->id , '=');
$specialtiesInEpals = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($specialtiesInEpals as $specialtiesInEpal) {
$sCon = $this->connection->select('eepal_specialty_field_data', 'eSpecialties')
->fields('eSpecialties', array('name'))
->condition('eSpecialties.id', $specialtiesInEpal->specialty_id , '=');
$specialtiesNamesInEpals = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($specialtiesNamesInEpals as $specialtiesNamesInEpal) {
array_push($schoolNameColumn, $epalSchool->name);
array_push($schoolSectionColumn, 'Γ τάξη / ' . $specialtiesNamesInEpal->name );
$sCon = $this->connection->select('epal_student_class', 'eStudent')
->fields('eStudent', array('id'))
->condition('eStudent.epal_id', $epalSchool->id , '=')
->condition('eStudent.currentclass', 3 , '=')
->condition('eStudent.specialization_id', $specialtiesInEpal->specialty_id , '=');
array_push( $numColumn, $sCon->countQuery()->execute()->fetchField() );
array_push($regionColumn, $epalRegion->name);
array_push($adminColumn, $epalAdmin->name);
}
}
if ($classId === "0" || $classId === "3") {
$sCon = $this->connection->select('eepal_specialties_in_epal_field_data', 'eSchool')
->fields('eSchool', array('specialty_id', 'capacity_class_specialty'))
->condition('eSchool.epal_id', $epalSchool->id , '=');
if ($courseId !== "0")
$sCon->condition('eSchool.specialty_id', $courseId, '=');
$specialtiesInEpals = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($specialtiesInEpals as $specialtiesInEpal) {
$sCon = $this->connection->select('eepal_specialty_field_data', 'eSpecialties')
->fields('eSpecialties', array('name'))
->condition('eSpecialties.id', $specialtiesInEpal->specialty_id , '=');
if ($courseId === "0" && $sectorId !== "0")
$sCon->condition('eSpecialties.sector_id', $sectorId, '=');
$specialtiesNamesInEpals = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($specialtiesNamesInEpals as $specialtiesNamesInEpal) {
array_push($regionColumn, $epalRegion->name);
array_push($adminColumn, $epalAdmin->name);
array_push($schoolNameColumn, $epalSchool->name);
array_push($schoolSectionColumn, 'Γ τάξη / ' . $specialtiesNamesInEpal->name );
$sCon = $this->connection->select('epal_student_class', 'eStudent')
->fields('eStudent', array('id'))
->condition('eStudent.epal_id', $epalSchool->id , '=')
->condition('eStudent.currentclass', 3 , '=')
->condition('eStudent.specialization_id', $specialtiesInEpal->specialty_id , '=');
$numStud = $sCon->countQuery()->execute()->fetchField();
array_push( $numColumn, $numStud );
array_push($capacityColumn, $specialtiesInEpal->capacity_class_specialty * $limitup);
array_push($percColumn, number_format($numStud / ($specialtiesInEpal->capacity_class_specialty * $limitup) * 100, 2) . '%' );
} //end foreach
} //end foreach
} //end if
for ($j = 0; $j < sizeof($schoolNameColumn); $j++) {
......@@ -416,8 +489,10 @@ class ReportsCreator extends ControllerBase {
'region' => $regionColumn[$j],
'admin' => $adminColumn[$j],
'section' => $schoolSectionColumn[$j],
'num' => $numColumn[$j])
);
'num' => $numColumn[$j],
'capacity' => $capacityColumn[$j],
'percentage' => $percColumn[$j],
));
}
......@@ -441,6 +516,27 @@ class ReportsCreator extends ControllerBase {
}
public function retrieveUpLimit() {
//βρες ανώτατο επιτρεπόμενο όριο μαθητών
//$limitup = 1;
try {
$sCon = $this->connection->select('epal_class_limits', 'eSchool')
->fields('eSchool', array('name', 'limit_up'))
->condition('eSchool.name', '1' , '=');
$epalLimitUps = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
$epalLimitUp = reset($epalLimitUps);
//$limitup = $epalLimitUp->limit_up;
//return $limitup;
return $epalLimitUp->limit_up;
}
catch (\Exception $e) {
$this->logger->warning($e->getMessage());
return -1;
}
}
private function respondWithStatus($arr, $s) {
......
......@@ -5,6 +5,9 @@ dependencies:
- user.role.administrator
- user.role.applicant
- user.role.authenticated
- user.role.eduadmin
- user.role.ministry
- user.role.regioneduadmin
module:
- basic_auth
- epalreadydata
......@@ -12,7 +15,7 @@ dependencies:
- serialization
- user
_core:
default_config_hash: x1x9jIC8SmXp0wDILOEs5_1lxH47q3VCokKYxEu4U-8
default_config_hash: YTXNI4Qb3Jgg7KwwlzgRShhY83j2js-q24x9a-SgLgg
id: coursefields
label: coursefields
module: views
......@@ -35,6 +38,9 @@ display:
authenticated: authenticated
administrator: administrator
applicant: applicant
ministry: ministry
eduadmin: eduadmin
regioneduadmin: regioneduadmin
cache:
type: tag
options: { }
......@@ -220,7 +226,46 @@ display:
footer: { }
empty: { }
relationships: { }
arguments: { }
arguments:
sector_id:
id: sector_id
table: eepal_specialty_field_data
field: sector_id
relationship: none
group_type: group
admin_label: ''
default_action: default
exception:
value: all
title_enable: false
title: All
title_enable: false
title: ''
default_argument_type: query_parameter
default_argument_options:
query_param: sector_id
fallback: ''
multiple: and
default_argument_skip_url: false
summary_options:
base_path: ''
count: true
items_per_page: 25
override: false
summary:
sort_order: asc
number_of_records: 0
format: default_summary
specify_validation: false
validate:
type: none
fail: 'not found'
validate_options: { }
break_phrase: false
not: false
entity_type: eepal_specialty
entity_field: sector_id
plugin_id: numeric
display_extenders: { }
cache_metadata:
max-age: -1
......@@ -228,6 +273,7 @@ display:
- 'languages:language_content'
- 'languages:language_interface'
- request_format
- url
- url.query_args
- user.roles
tags: { }
......@@ -259,6 +305,9 @@ display:
name:
alias: ''
raw_output: true
sector_id:
alias: ''
raw_output: true
auth:
- basic_auth
cache_metadata:
......@@ -267,5 +316,6 @@ display:
- 'languages:language_content'
- 'languages:language_interface'
- request_format
- url
- user.roles
tags: { }
......@@ -5,6 +5,9 @@ dependencies:
- user.role.administrator
- user.role.applicant
- user.role.authenticated
- user.role.eduadmin
- user.role.ministry
- user.role.regioneduadmin
module:
- basic_auth
- epalreadydata
......@@ -13,7 +16,7 @@ dependencies:
- serialization
- user
_core:
default_config_hash: 5rM-pSfc1ywl4-ufHeAQsKiVGcBMDcz4RLfYmMeVGfo
default_config_hash: 2Ow8_rRpftR4qqbwfsr6yc_XMzbRKZjHSEuFzrXvzV8
id: sectorlist
label: sectorList
module: views
......@@ -36,6 +39,9 @@ display:
authenticated: authenticated
administrator: administrator
applicant: applicant
ministry: ministry
eduadmin: eduadmin
regioneduadmin: regioneduadmin
cache:
type: tag
options: { }
......
......@@ -22,21 +22,20 @@ import {
Validators,
} from '@angular/forms';
//import * as d3 from 'd3';
//import * as _ from '..
import { API_ENDPOINT } from '../../app.settings';
@Component({
selector: 'report-all-stat',
//encapsulation: ViewEncapsulation.None,
template: `
<div>
<!--
<div
class = "loading" *ngIf="validCreator == 0" >
</div>
-->
<form [formGroup]="formGroup" #form>
......@@ -45,27 +44,57 @@ import { API_ENDPOINT } from '../../app.settings';
<button type="button" class="btn-link" (click)="toggleRegionFilter()" >
> Φίλτρο Επιλογής Περιφ/κής Δ/νσης - Δ/νσης Εκπ/σης - Σχολείου
</button>
<div class="form-group">
<div class="col-md-11 offset-md-1">
<label *ngIf = "enableRegionFilter"> Περιφερειακή Διεύθυνση </label>
<select #regsel class="form-control" (change)="checkregion(regsel)" *ngIf = "enableRegionFilter" formControlName="region">
<option value="0"></option>
<option *ngFor="let RegionSelection$ of RegionSelections$ | async; let i=index" [value] = "RegionSelection$.id"> {{RegionSelection$.name}} </option>
</select>
</div>
<div class="form-group">
<div class="col-md-11 offset-md-1">
<label *ngIf="(showAdminList | async) && enableRegionFilter">Διεύθυνση Εκπαίδευσης</label>
<select #admsel class="form-control" *ngIf="(showAdminList | async) && enableRegionFilter" (change)="checkadminarea(admsel)" formControlName="adminarea">
<option value="0"></option>
<option *ngFor="let AdminAreaSelection$ of AdminAreaSelections$ | async; let i=index" [value] = "AdminAreaSelection$.id"> {{AdminAreaSelection$.name}}</option>
</select>
</div>
<div class="form-group">
<div class="col-md-11 offset-md-1">
<label *ngIf="(showAdminList | async) && enableRegionFilter">Σχολείο</label>
<select #schsel class="form-control" *ngIf="(showAdminList | async) && enableRegionFilter" (change)="checkschool(schsel)" formControlName="schoollist">
<option value="0"></option>
<option *ngFor="let SchoolSelection$ of SchoolSelections$ | async; let i=index" [value] = "SchoolSelection$.epal_id"> {{SchoolSelection$.epal_name}} </option>
</select>
</div>
<button type="button" class="btn-link" (click)="toggleCourseFilter()" *ngIf = "reportId == 3" >
> Φίλτρο Επιλογής Τομέα / Ειδικότητας
</button>
<br>
<div class="col-md-11 offset-md-1">
<label for="classid" *ngIf = "enableCourseFilter" >Τάξη</label><br/>
<select #class_sel class="form-control" (change)="checkclass(class_sel)" *ngIf = "enableCourseFilter" formControlName="classid" >
<option value="0" ></option>
<option value="1" >Α' Λυκείου</option>
<option value="2" >Β' Λυκείου</option>
<option value="3" >Γ' Λυκείου</option>
</select>
</div>
<div class="col-md-11 offset-md-1">
<label *ngIf="(showSectorList | async) && enableCourseFilter && (classSelected == 2 || classSelected == 3) ">Τομέας</label>
<select #secsel class="form-control" *ngIf="(showSectorList | async) && enableCourseFilter && (classSelected == 2 || classSelected == 3)" (change)="checksector(secsel)" formControlName="sector">
<option value="0"></option>
<option *ngFor="let SectorSelection$ of SectorSelections$ | async; let i=index" [value] = "SectorSelection$.id"> {{SectorSelection$.name}}</option>
</select>
</div>
<div class="col-md-11 offset-md-1">
<label *ngIf="(showCourseList | async) && enableCourseFilter && classSelected == 3">Ειδικότητα</label>
<select #coursel class="form-control" *ngIf="(showCourseList | async) && enableCourseFilter && classSelected == 3" (change)="checkcourse(coursel)" formControlName="course">
<option value="0"></option>
<option *ngFor="let CourseSelection$ of CourseSelections$ | async; let i=index" [value] = "CourseSelection$.id"> {{CourseSelection$.name}}</option>
</select>
</div>
<br>
<button type="submit" class="btn btn-alert" (click)="createReport(regsel)" [hidden]="minedu_userName == ''" >
<i class="fa fa-file-text"></i>
Δημιουργία Αναφοράς
......@@ -102,24 +131,33 @@ import { API_ENDPOINT } from '../../app.settings';
private RegionSelections$: BehaviorSubject<any>;
private AdminAreaSelections$: BehaviorSubject<any>;
private SchoolSelections$: BehaviorSubject<any>;
private SectorSelections$: BehaviorSubject<any>;
private CourseSelections$: BehaviorSubject<any>;
private generalReportSub: Subscription;
private RegionSelectionsSub: Subscription;
private AdminAreaSelectionsSub: Subscription;
private SchoolSelectionsSub: Subscription;
private SectorSelectionsSub: Subscription;
private CourseSelectionsSub: Subscription;
private apiEndPoint = API_ENDPOINT;
private minedu_userName: string;
private minedu_userPassword: string;
private distStatus = "READY";
private data;
private validCreator: number;
//private createGraph: boolean;
private reportId: number;