conflict resolution

parents a11d79ca 4d0e3dd0
......@@ -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:
......@@ -188,3 +188,19 @@ coursesperschools:
_controller: '\Drupal\epal\Controller\DirectorView::getCoursesPerSchool'
requirements:
_user_is_logged_in: 'TRUE'
critirioschosen:
path: '/epal/critiriachosen/{studentId}/{type}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\SubmitedApplications::getCritiria'
requirements:
_user_is_logged_in: 'TRUE'
findcapacity:
path: '/epal/findCapacity/{taxi}/{tomeas}/{specialit}/{schoolid}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::findCapacity'
requirements:
_user_is_logged_in: 'TRUE'
\ No newline at end of file
......@@ -209,9 +209,13 @@ public function getStudentPerSchool(Request $request, $epalId , $selectId, $clas
$epalStudent = reset($epalStudents);
if ($epalStudents) {
$studentIdNew = $epalStudent -> id();
$checkstatus = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array( 'student_id'=> $studentIdNew));
$checkstudentstatus = reset($checkstatus);
if ($i >= $limitdown && $i < $limitup)
{
$newstatus = $checkstudentstatus -> directorconfirm-> getValue();
$list[] = array(
'i' => $i,
'id' => $epalStudent -> id(),
......@@ -221,7 +225,17 @@ public function getStudentPerSchool(Request $request, $epalId , $selectId, $clas
'fathersurname' =>$epalStudent -> fathersurname ->value,
'motherfirstname' => $epalStudent -> motherfirstname ->value,
'mothersurname' =>$epalStudent -> mothersurname ->value,
'guardianfirstname' =>$epalUser -> name ->value,
'guardiansurname' =>$epalUser -> surname ->value,
'regionaddress' =>$epalStudent -> regionaddress ->value,
'regiontk' =>$epalStudent -> regiontk ->value,
'regionarea' =>$epalStudent -> regionarea ->value,
'certificatetype' =>$epalStudent -> certificatetype ->value,
'telnum' =>$epalStudent -> telnum ->value,
'relationtostudent' =>$epalStudent -> relationtostudent ->value,
'birthdate' =>$epalStudent -> birthdate ->value,
'checkstatus' =>$newstatus[0][value],
);
}
$i++;
......@@ -282,13 +296,19 @@ public function getStudentPerSchool(Request $request, $epalId , $selectId, $clas
{
$postData = json_decode($content);
$arr = $postData->students;
$type = $postData ->type;
foreach ($arr as $value) {
$valnew = intval($value);
$studentForConfirm = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('id' => $valnew ));
$studentConfirm = reset($studentForConfirm);
if ($studentConfirm) {
if ($type == 1)
$studentConfirm->set('directorconfirm', true);
if ($type == 2)
$studentConfirm->set('directorconfirm', false);
if ($type == 3)
unset($studentConfirm->{directorconfirm});
$studentConfirm->save();
}
}
......@@ -318,6 +338,8 @@ public function getStudentPerSchool(Request $request, $epalId , $selectId, $clas
public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid)
{
if (!$request->isMethod('POST')) {
return $this->respondWithStatus([
"message" => t("Method Not Allowed")
......@@ -575,6 +597,96 @@ public function returnstatus($id)
}
public function findCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid)
{
$tomeasnew = intval($tomeas);
$specialitnew = intval($specialitnew) ;
$authToken = $request->headers->get('PHP_AUTH_USER');
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if ($user) {
$schools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('registry_no' => $this->testSchoolId));
$school = reset($schools);
if (!$school) {
$this->logger->warning("no access to this school=" . $user->id());
$response = new Response();
$response->setContent('No access to this school');
$response->setStatusCode(Response::HTTP_FORBIDDEN);
$response->headers->set('Content-Type', 'application/json');
return $response;
}
$list = array();
if (($tomeasnew == 0) && ($specialitnew == 0))
{
$CapacityPerClass = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id' => $schoolid ));
$classcapacity = reset($CapacityPerClass);
if ($classcapacity) {
$list[] = array(
'taxi' => $taxi,
'capacity' => $classcapacity -> capacity_class_a -> value ,
);
}
}
if (($tomeasnew != 0) && ($specialitnew == 0))
{
$CapacityPerClass = $this->entityTypeManager->getStorage('eepal_sectors_in_epal')->loadByProperties(array('epal_id' => $schoolid, 'sector_id' => $tomeasnew ));
$classcapacity = reset($CapacityPerClass);
if ($classcapacity) {
$list[] = array(
'taxi' => $taxi,
'tomeas' => $tomeasnew,
'special' =>$specialitnew,
'capacity' => $classcapacity -> capacity_class_sector -> value ,
);
}
}
if (($tomeasnew != 0) && ($specialitnew != 0))
{
$CapacityPerClass = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $schoolid, 'specialty_id' => $specialitnew));
$classcapacity = reset($CapacityPerClass);
if ($classcapacity) {
$list[] = array(
'taxi' =>$taxi,
'tomeas' => $tomeasnew,
'special' =>$specialitnew,
'tomeas' => $classcapacity -> specialty_id -> value,
'capacity' => $classcapacity -> capacity_class_specialty -> value ,
);
}
}
return $this->respondWithStatus(
$list
, Response::HTTP_OK);
} else {
return $this->respondWithStatus([
'message' => t("EPAL user not found"),
], Response::HTTP_FORBIDDEN);
}
}
private function respondWithStatus($arr, $s) {
$res = new JsonResponse($arr);
$res->setStatusCode($s);
......
......@@ -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) {
......
......@@ -95,8 +95,16 @@ class SubmitedApplications extends ControllerBase
'fathersurname' =>$object -> fathersurname ->value,
'motherfirstname' => $object -> motherfirstname ->value,
'mothersurname' =>$object -> mothersurname ->value,
'guardianfirstname' =>$epalUser -> name ->value,
'guardiansurname' =>$epalUser -> surname ->value,
'regionaddress' =>$object -> regionaddress ->value,
'regiontk' =>$object -> regiontk ->value,
'regionarea' =>$object -> regionarea ->value,
'certificatetype' =>$object -> certificatetype ->value,
'telnum' =>$object -> telnum ->value,
'relationtostudent' =>$object -> relationtostudent ->value,
'birthdate' =>$object -> birthdate ->value,
);
);
$i++;
}
......@@ -115,7 +123,7 @@ class SubmitedApplications extends ControllerBase
} else {
return $this->respondWithStatus([
'message' => t("User not found"),
'message' => t("User not found!!!!"),
], Response::HTTP_FORBIDDEN);
}
......@@ -166,6 +174,67 @@ public function getEpalChosen(Request $request, $studentId)
}
public function getCritiria(Request $request, $studentId, $type)
{
$authToken = $request->headers->get('PHP_AUTH_USER');
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken));
$epalUser = reset($epalUsers);
if ($epalUser) {
$userid = $epalUser -> user_id -> entity -> id();
$studentIdNew = intval($studentId) ;
$critiriaChosen = $this->entityTypeManager->getStorage('epal_student_moria')->loadByProperties(array( 'user_id'=>$userid,'student_id'=> $studentIdNew));
$i = 0;
if ($critiriaChosen) {
$list = array();