Commit e62d2e2d authored by Ασπασία Κατσή's avatar Ασπασία Κατσή

Merge branch 'reportmergedclasses' into 'develop'

Reportmergedclasses

See merge request !282
parents c85e9975 5b610241
......@@ -380,6 +380,14 @@ epal.merging_groups:
_controller: '\Drupal\epal\Controller\SmallClassDistribution::findMergingSchoolsforUndo'
requirements:
_user_is_logged_in: 'TRUE'
epal.ministry.report-merged-classes:
path: '/ministry/report-merged-classes/{regionId}/{adminId}/{schId}/{classId}/{sectorId}/{courseId}/{finalized}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\ReportsCreator::makeReportMergedClasses'
requirements:
_user_is_logged_in: 'TRUE'
epal.undomerge:
path: '/epal/undomerge/{classId}/{sector}/{speciality}'
options:
......
......@@ -1112,4 +1112,203 @@ class ReportsCreator extends ControllerBase
$res->setStatusCode($s);
return $res;
}
public function makeReportMergedClasses(Request $request, $regionId, $adminId, $schId, $classId, $sectorId, $courseId, $finalized)
{
try {
$list = array();
if (!$request->isMethod('GET')) {
return $this->respondWithStatus([
"message" => t("Method Not Allowed")
], Response::HTTP_METHOD_NOT_ALLOWED);
}
//user validation
$authToken = $request->headers->get('PHP_AUTH_USER');
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if (!$user) {
return $this->respondWithStatus([
'message' => t("User not found"),
], Response::HTTP_FORBIDDEN);
}
//user role validation
$roles = $user->getRoles();
$validRole = false;
foreach ($roles as $role) {
if ($role === "ministry" || $role === "regioneduadmin" || $role === "eduadmin") {
$validRole = $role;
break;
}
}
if ($validRole === false) {
return $this->respondWithStatus([
'message' => t("User Invalid Role"),
], Response::HTTP_FORBIDDEN);
}
if (!$this->canReportOn($user, $role, $regionId, $adminId, $schId)) {
return $this->respondWithStatus([
'message' => t('User access to area forbidden'),
], Response::HTTP_FORBIDDEN);
}
if ( ($classId==3 || $classId==4) && $sectorId!=0 && $courseId==0 ){
$sCon = \Drupal::database()->select('eepal_specialty_field_data', 'eSectors');
$sCon->fields('eSectors', array('sector_id', 'id', 'name', ));
$sCon->condition('eSectors.sector_id', $sectorId, '=');
$specialties_in_sector = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
}
$sector_specialties=array();
foreach ($specialties_in_sector as $specialty){
array_push($sector_specialties,$specialty->id);
}
$sCon = \Drupal::database()->select('epal_student_class', 'eStudent');
$sCon->join('eepal_school_field_data','eSchool1','eSchool1.id=eStudent.initial_epal_id');
$sCon->join('eepal_region_field_data', 'eRegion1', 'eRegion1.id = eSchool1.region_edu_admin_id');
$sCon->join('eepal_admin_area_field_data', 'eAdmin1', 'eAdmin1.id = eSchool1.edu_admin_id');
$sCon->join('eepal_school_field_data','eSchool2','eSchool2.id=eStudent.epal_id');
$sCon->join('eepal_region_field_data', 'eRegion2', 'eRegion2.id = eSchool2.region_edu_admin_id');
$sCon->join('eepal_admin_area_field_data', 'eAdmin2', 'eAdmin2.id = eSchool2.edu_admin_id');
$sCon->fields('eStudent', array('initial_epal_id', 'epal_id', 'currentclass', 'specialization_id'));
$sCon->addField('eRegion1', 'name','regionAName');
$sCon->addField('eAdmin1', 'name','adminAName');
$sCon->addField('eSchool1', 'name','schoolAName');
$sCon->addField('eRegion2', 'name','regionBName');
$sCon->addField('eAdmin2', 'name','adminBName');
$sCon->addField('eSchool2', 'name','schoolBName');
if ($classId != 0) {
$sCon->condition('eStudent.currentclass', $classId, '=');
}
if ($sectorId != 0) {
if ($classId==2){
$sCon->condition('eStudent.specialization_id', $sectorId, '=');
}
if (($classId==3 || $classId==4) && $courseId==0){
$sCon->condition('eStudent.specialization_id', $sector_specialties, 'IN');
}
}
if ($courseId!=0){
if ($classId==3 || $classId==4){
$sCon->condition('eStudent.specialization_id', $courseId, '=');
}
}
if ($regionId != 0) {
$sCon->condition('eSchool1.region_edu_admin_id', $regionId, '=');
}
if ($adminId != 0) {
$sCon->condition('eSchool1.edu_admin_id', $adminId, '=');
}
if ($schId != 0) {
$sCon->condition('eSchool1.id', $schId, '=');
}
$sCon->condition('eStudent.initial_epal_id', 0, '!=');
$sCon->groupBy('initial_epal_id');
$sCon->groupBy('epal_id');
$sCon->groupBy('currentclass');
$sCon->groupBy('specialization_id');
$sCon->groupBy('eRegion1.name');
$sCon->groupBy('eAdmin1.name');
$sCon->groupBy('eSchool1.name');
$sCon->groupBy('eRegion2.name');
$sCon->groupBy('eAdmin2.name');
$sCon->groupBy('eSchool2.name');
$sCon->addExpression('count(eStudent.id)', 'eStudent_count');
$mergedSchools = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
$schoolANameColumn = array();
$regionAColumn = array();
$adminAColumn = array();
$schoolSectionColumn = array();
$numAColumn = array();
$schoolBNameColumn = array();
$regionBColumn = array();
$adminBColumn = array();
$numBColumn = array();
foreach ($mergedSchools as $mergedSchool) {
array_push($regionAColumn, $mergedSchool->regionAName);
array_push($adminAColumn, $mergedSchool->adminAName);
array_push($schoolANameColumn, $mergedSchool->schoolAName);
if ($mergedSchool->currentclass==1){
array_push($schoolSectionColumn, 'Α Tάξη');
}
else if ($mergedSchool->currentclass==2){
$sCon = \Drupal::database()->select('eepal_sectors_field_data', 'eSectors');
$sCon->addField('eSectors', 'name');
$sCon->condition('eSectors.id', $mergedSchool->specialization_id, '=');
$sector_name = $sCon->execute()->fetchField();
array_push($schoolSectionColumn, 'Β τάξη / ' . $sector_name);
}
else{
$sCon = \Drupal::database()->select('eepal_specialty_field_data', 'eSpecialties');
$sCon->join('eepal_sectors_field_data', 'eSectors','eSectors.id=eSpecialties.sector_id');
$sCon->addField('eSectors', 'name','sectorName');
$sCon->addField('eSpecialties', 'name','specialtyName');
$sCon->condition('eSpecialties.id', $mergedSchool->specialization_id, '=');
$sector_specialty = $sCon->execute()->fetchAssoc();
if ($mergedSchool->currentclass==3){
array_push($schoolSectionColumn, 'Γ Tάξη / ' . $sector_specialty['sectorName'].'/'.$sector_specialty['specialtyName']);//->specialization_id);
}
else if ($mergedSchool->currentclass==4){
array_push($schoolSectionColumn, 'Δ Tάξη / ' . $mergedSchool->specialization_id);
}
}
array_push($numAColumn, $mergedSchool->eStudent_count);
array_push($regionBColumn, $mergedSchool->regionBName);
array_push($adminBColumn, $mergedSchool->adminBName);
array_push($schoolBNameColumn, $mergedSchool->schoolBName);
$sCon = \Drupal::database()->select('epal_student_class', 'eStudent');
$sCon->condition('eStudent.epal_id', $mergedSchool->epal_id, '=');
$sCon->condition('eStudent.currentclass', $mergedSchool->currentclass, '=');
$sCon->condition('eStudent.specialization_id', $mergedSchool->specialization_id, '=');
$sCon->addExpression('count(eStudent.id)', 'eStudent_extra_count');
$sCon->groupBy('eStudent.epal_id');
$sCon->groupBy('eStudent.currentclass');
$sCon->groupBy('eStudent.specialization_id');
$eStudent_extra_count = $sCon->execute()->fetchAssoc();
array_push($numBColumn, $eStudent_extra_count['eStudent_extra_count']);
}
for ($j = 0; $j < sizeof($schoolANameColumn); $j++) {
array_push($list, (object) array(
'nameΑ' => $schoolANameColumn[$j],
'regionΑ' => $regionAColumn[$j],
'adminΑ' => $adminAColumn[$j],
'sectionΑ' => str_replace(",", "", $schoolSectionColumn[$j]),
'numΑ' => $numAColumn[$j],
'nameΒ' => $schoolBNameColumn[$j],
'regionΒ' => $regionBColumn[$j],
'adminΒ' => $adminBColumn[$j],
'numΒ' => $numBColumn[$j],
));
}
return $this->respondWithStatus($list, Response::HTTP_OK);
}
catch (\Exception $e) {
$this->logger->warning($e->getMessage());
return $this->respondWithStatus([
"message" => t("An unexpected problem occured in makeReportCompleteness Method")
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
}
......@@ -41,6 +41,10 @@ import { IAppState } from "../../store/store";
<div *ngIf = "minedu_userName != '' && userRole != 'pde' && userRole != 'dide'">
<button type="button" class="btn btn-block" (click)="nav_to_reportpath(5)"><i class="fa fa-file-text"></i> Ολιγομελή τμήματα (Προσωρινά τοποθετημένοι μαθητές)</button>
</div>
<div *ngIf = "minedu_userName != ''">
<button type="button" class="btn btn-block" (click)="nav_to_reportpath(6)"><i class="fa fa-file-text"></i> Συγχωνεύσεις Ολιγομελών Τμημάτων</button>
</div>
</div>
`
......@@ -103,6 +107,8 @@ import { IAppState } from "../../store/store";
this.router.navigate(["/ministry/report-all-stat", repId]);
} else if (repId === 4) {
this.router.navigate(["/ministry/report-no-capacity", repId]);
} else if(repId === 6){
this.router.navigate(["/ministry/report-merged-classes"]);
}
}
......
This diff is collapsed.
......@@ -174,6 +174,62 @@ export class ReportsSchema {
}
};
reportMergedClassesSchema = {
actions: false,fileName: "e-ΕΠΑΛ Συγχωνέυσεις Τμημάτων",
pager: {
display: true,
perPage: 5
},
noDataMessage: "Δεν υπάρχουν δεδομένα που περιέχουν το κείμενο αναζήτησης",
columns: {
nameΑ: {
title: "Σχολείο Συγχώνευσης",
width: "40%",
filter: false
},
regionΑ: {
title: "Περιφερειακή Διεύθυνση",
width: "40%",
filter: false
},
adminΑ: {
title: "Διεύθυνση Εκπαίδευσης",
width: "40%",
filter: false
},
sectionΑ: {
title: "Τάξη/Τομέας/Ειδικότητα",
width: "40%",
filter: false
},
numΑ: {
title: "Αριθμός Μαθητών",
width: "5%",
filter: false
},
nameΒ: {
title: "Σχολείο Υποδοχής",
width: "40%",
filter: false
},
regionΒ: {
title: "Π.Δ.Ε. Υποδοχής",
width: "40%",
filter: false
},
adminΒ: {
title: "ΔΙ.Δ.Ε. Υποδοχής",
width: "40%",
filter: false
},
numΒ: {
title: "Σύνολο Μαθητών",
width: "5%",
filter: false
}
}
};
constructor() { }
}
......@@ -360,4 +360,8 @@ label {
.reports-container h6,
.reports-container button {
margin: 0 0 1em 0;
}
\ No newline at end of file
}
.smart-table-container {
overflow-x: scroll;
}
\ No newline at end of file
......@@ -45,6 +45,7 @@ import StudentAuthGuard from "../guards/student.auth.guard";
import StudentLockGuard from "../guards/student.lock.guard";
import { CamelCasePipe } from "../pipes/camelcase";
import { RemoveSpaces } from "../pipes/removespaces";
import ReportMergedClasses from "../components/minister/report-merged-classes";
export const MainRoutes: Routes = [
{ path: "", component: Home },
......@@ -83,6 +84,8 @@ export const MainRoutes: Routes = [
{ path: "school/mergeschools", component: MergeSchools, canActivate: [RegionEduAuthGuard] },
{ path: "school/undomerge", component: UndoMergeSchools, canActivate: [RegionEduAuthGuard] },
{ path: "help-desk", component: HelpDesk, canActivate: [StudentAuthGuard] },
{ path: "ministry/report-merged-classes", component: ReportMergedClasses, canActivate: [ReportsAuthGuard] },
];
export const MainDeclarations = [
......@@ -121,5 +124,6 @@ export const MainDeclarations = [
HelpDesk,
LegalInfo,
MergeSchools,
UndoMergeSchools
UndoMergeSchools,
ReportMergedClasses,
];
......@@ -618,6 +618,11 @@ export class HelperDataService implements OnInit, OnDestroy {
return this.http.get(`${AppSettings.API_ENDPOINT}` + routepath + capacityFilter, options)
.map(response => response.json());
}
else if (routepath === "/ministry/report-merged-classes/") {
return this.http.get(`${AppSettings.API_ENDPOINT}` + routepath + regionsel + "/" + adminsel + "/" + schsel + "/" +
clsel + "/" + secsel + "/" + coursel + "/" + distribfinal, options)
.map(response => response.json());
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment