Commit 85569720 authored by Open Source Developer's avatar Open Source Developer

changes

parent 4f57c01d
...@@ -78,22 +78,6 @@ epal.allocation: ...@@ -78,22 +78,6 @@ epal.allocation:
_controller: '\Drupal\epal\Controller\Distribution::createDistribution' _controller: '\Drupal\epal\Controller\Distribution::createDistribution'
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
epal.sectorperschool:
path: '/epal/sectorperschool'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::getSectorsPerSchool'
requirements:
_user_is_logged_in: 'TRUE'
epal.specialityperschool:
path: '/epal/specialityperschool/{sectorId}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::getSpecialPerSchool'
requirements:
_user_is_logged_in: 'TRUE'
epal.confirmstudents: epal.confirmstudents:
path: '/epal/confirmstudent' path: '/epal/confirmstudent'
options: options:
...@@ -229,7 +213,7 @@ epal.coursesperschools: ...@@ -229,7 +213,7 @@ epal.coursesperschools:
defaults: defaults:
_controller: '\Drupal\epal\Controller\DirectorView::getCoursesPerSchool' _controller: '\Drupal\epal\Controller\DirectorView::getCoursesPerSchool'
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
epal.critirioschosen: epal.critirioschosen:
path: '/epal/critiriachosen/{studentId}/{type}' path: '/epal/critiriachosen/{studentId}/{type}'
options: options:
...@@ -238,38 +222,6 @@ epal.critirioschosen: ...@@ -238,38 +222,6 @@ epal.critirioschosen:
_controller: '\Drupal\epal\Controller\SubmitedApplications::getCritiria' _controller: '\Drupal\epal\Controller\SubmitedApplications::getCritiria'
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
epal.findcapacity:
path: '/epal/findcapacity/{taxi}/{tomeas}/{specialit}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::findCapacity'
requirements:
_user_is_logged_in: 'TRUE'
epal.findschoolid:
path: '/epal/getschool'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::getSchoolID'
requirements:
_user_is_logged_in: 'TRUE'
epal.gettypeofschool:
path: '/epal/gettypeofschool'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::gettypeofschool'
requirements:
_user_is_logged_in: 'TRUE'
epal.getlimitspercourse:
path: '/epal/getlimitspercourse/{classid}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::getlimitsperCourse'
requirements:
_user_is_logged_in: 'TRUE'
epal.findcapacityperschool: epal.findcapacityperschool:
path: '/epal/findcapacityperschool' path: '/epal/findcapacityperschool'
options: options:
...@@ -310,3 +262,14 @@ epal.svc.getstudentcertification: ...@@ -310,3 +262,14 @@ epal.svc.getstudentcertification:
_controller: '\Drupal\epal\Controller\WSConsumer::getStudentEpalCertification' _controller: '\Drupal\epal\Controller\WSConsumer::getStudentEpalCertification'
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
epal.findcoursesperschool:
path: '/epal/findcoursesperschool'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::FindCoursesPerSchool'
requirements:
_user_is_logged_in: 'TRUE'
...@@ -35,130 +35,8 @@ class DirectorView extends ControllerBase ...@@ -35,130 +35,8 @@ class DirectorView extends ControllerBase
); );
} }
public function getSectorsPerSchool(Request $request)
{
$authToken = $request->headers->get('PHP_AUTH_USER');
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if ($user) {
$epalId = $user->init->value;
$schools = $this->entityTypeManager->getStorage('eepal_school')->
loadByProperties(array('id' => $epalId));
$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;
}
$userRoles = $user->getRoles();
$userRole = '';
foreach ($userRoles as $tmpRole) {
if ($tmpRole === 'epal') {
$userRole = $tmpRole;
}
}
if ($userRole === '') {
return $this->respondWithStatus([
'error_code' => 4003,
], Response::HTTP_FORBIDDEN);
} elseif ($userRole === 'epal') {
$sectorPerSchool = $this->entityTypeManager->getStorage('eepal_sectors_in_epal')->loadByProperties(array('epal_id' => $epalId));
if ($sectorPerSchool) {
$list = array();
foreach ($sectorPerSchool as $object) {
$list[] = array(
'sector_id' => $object->sector_id->entity->get('name')->value,
'id' => $object->sector_id->entity->id(),
);
}
return $this->respondWithStatus(
$list, Response::HTTP_OK);
}
} else {
return $this->respondWithStatus([
'message' => t('School not found!!!'),
], Response::HTTP_OK);
}
} else {
return $this->respondWithStatus([
'message' => t('User not found!'),
], Response::HTTP_FORBIDDEN);
}
}
public function getSpecialPerSchool(Request $request, $sectorId)
{
$authToken = $request->headers->get('PHP_AUTH_USER');
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if ($user) {
$epalId = $user->init->value;
$schools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id' => $epalId));
$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;
}
$userRoles = $user->getRoles();
$userRole = '';
foreach ($userRoles as $tmpRole) {
if ($tmpRole === 'epal') {
$userRole = $tmpRole;
}
}
if ($userRole === '') {
return $this->respondWithStatus([
'error_code' => 4003,
], Response::HTTP_FORBIDDEN);
} elseif ($userRole === 'epal') {
$specialityPerSchool = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $epalId));
$i = 0;
if ($specialityPerSchool) {
$list = array();
$SectorIdNew = intval($sectorId);
foreach ($specialityPerSchool as $object) {
$idSpecial = $object->specialty_id->entity->id();
$specialityPerSector = $this->entityTypeManager->getStorage('eepal_specialty')->loadByProperties(array('id' => $idSpecial, 'sector_id' => $SectorIdNew));
$specialPerSec = reset($specialityPerSector);
if ($specialPerSec) {
$list[] = array(
'specialty_id' => $object->specialty_id->entity->get('name')->value,
'id' => $object->specialty_id->entity->id(), );
++$i;
}
}
return $this->respondWithStatus(
$list, Response::HTTP_OK);
}
} else {
return $this->respondWithStatus([
'message' => t('School not found!!!'),
], Response::HTTP_OK);
}
} else {
return $this->respondWithStatus([
'message' => t('User not found!'),
], Response::HTTP_FORBIDDEN);
}
}
public function getStudentPerSchool(Request $request, $classId, $sector, $specialit) public function getStudentPerSchool(Request $request, $classId, $sector, $specialit)
{ {
try { try {
...@@ -330,6 +208,9 @@ class DirectorView extends ControllerBase ...@@ -330,6 +208,9 @@ class DirectorView extends ControllerBase
} }
} }
public function ConfirmStudents(Request $request) public function ConfirmStudents(Request $request)
{ {
if (!$request->isMethod('POST')) { if (!$request->isMethod('POST')) {
...@@ -420,6 +301,8 @@ class DirectorView extends ControllerBase ...@@ -420,6 +301,8 @@ class DirectorView extends ControllerBase
} }
} }
public function SaveCapacity(Request $request, $taxi, $tomeas, $specialit) public function SaveCapacity(Request $request, $taxi, $tomeas, $specialit)
{ {
if (!$request->isMethod('POST')) { if (!$request->isMethod('POST')) {
...@@ -532,6 +415,8 @@ class DirectorView extends ControllerBase ...@@ -532,6 +415,8 @@ class DirectorView extends ControllerBase
} }
} }
public function getSchools(Request $request) public function getSchools(Request $request)
{ {
$authToken = $request->headers->get('PHP_AUTH_USER'); $authToken = $request->headers->get('PHP_AUTH_USER');
...@@ -584,6 +469,7 @@ class DirectorView extends ControllerBase ...@@ -584,6 +469,7 @@ class DirectorView extends ControllerBase
} }
} }
public function getCoursesPerSchool(Request $request, $schoolid) public function getCoursesPerSchool(Request $request, $schoolid)
{ {
$authToken = $request->headers->get('PHP_AUTH_USER'); $authToken = $request->headers->get('PHP_AUTH_USER');
...@@ -758,13 +644,12 @@ class DirectorView extends ControllerBase ...@@ -758,13 +644,12 @@ class DirectorView extends ControllerBase
} }
return true; return true;
// exit;
} }
public function findCapacity(Request $request, $taxi, $tomeas, $specialit)
public function FindCapacityPerSchool(Request $request)
{ {
$tomeasnew = intval($tomeas); $i = 0;
$specialitnew = intval($specialit);
$authToken = $request->headers->get('PHP_AUTH_USER'); $authToken = $request->headers->get('PHP_AUTH_USER');
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken)); $users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
...@@ -782,6 +667,7 @@ class DirectorView extends ControllerBase ...@@ -782,6 +667,7 @@ class DirectorView extends ControllerBase
return $response; return $response;
} }
$operation_shift = $school -> operation_shift -> value;
$userRoles = $user->getRoles(); $userRoles = $user->getRoles();
$userRole = ''; $userRole = '';
foreach ($userRoles as $tmpRole) { foreach ($userRoles as $tmpRole) {
...@@ -794,66 +680,94 @@ class DirectorView extends ControllerBase ...@@ -794,66 +680,94 @@ class DirectorView extends ControllerBase
'error_code' => 4003, 'error_code' => 4003,
], Response::HTTP_FORBIDDEN); ], Response::HTTP_FORBIDDEN);
} elseif ($userRole === 'epal') { } elseif ($userRole === 'epal') {
$categ = $school->metathesis_region->value;
$list = array(); $list = array();
$CourseA = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id' => $schoolid));
$classcapacity = reset($CourseA);
if (($tomeasnew == 0) && ($specialitnew == 0)) { if ($classcapacity) {
$CapacityPerClass = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id' => $schoolid));
$classcapacity = reset($CapacityPerClass);
if ($classcapacity) { $list[] = array(
$list[] = array( 'class' => 1,
'taxi' => $taxi, 'newsector' => 0,
'capacity' => $classcapacity->capacity_class_a->value, 'newspecialit' => 0,
); 'taxi' => 'Ά Λυκείου',
} 'capacity' => $classcapacity->capacity_class_a->value,
'globalindex' => $i,
);
} }
++$i;
$CourseB = $this->entityTypeManager->getStorage('eepal_sectors_in_epal')->loadByProperties(array('epal_id' => $schoolid));
if ($CourseB) {
if (($tomeasnew != 0) && ($specialitnew == 0)) { foreach ($CourseB as $object) {
$CapacityPerClass = $this->entityTypeManager->getStorage('eepal_sectors_in_epal')->loadByProperties(array('epal_id' => $schoolid, 'sector_id' => $tomeasnew)); $sectorid = $object->sector_id->entity->id();
$classcapacity = reset($CapacityPerClass);
if ($classcapacity) { $CapacityPerClass = $this->entityTypeManager->getStorage('eepal_sectors_in_epal')->loadByProperties(array('epal_id' => $schoolid, 'sector_id' => $sectorid));
$list[] = array( $classcapacity = reset($CapacityPerClass);
'taxi' => $taxi, if ($classcapacity) {
'tomeas' => $tomeasnew, $list[] = array(
'special' => $specialitnew, 'class' => 2,
'newsector' => $object->sector_id->entity->id(),
'newspecialit' => 0,
'taxi' => 'Β Λυκείου '.$object->sector_id->entity->get('name')->value,
'capacity' => $classcapacity->capacity_class_sector->value, 'capacity' => $classcapacity->capacity_class_sector->value,
'sector' => $tomeasnew.'lala'.$specialitnew, 'globalindex' => $i,
); );
}
++$i;
} }
} }
$CourseC = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $schoolid));
if (($tomeasnew != 0) && ($specialitnew != 0) && ($taxi == 3)) { if ($CourseC) {
$CapacityPerClass = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $schoolid, 'specialty_id' => $specialitnew));
$classcapacity = reset($CapacityPerClass); foreach ($CourseC as $object) {
if ($classcapacity) {
$list[] = array( $specialityid = $object->specialty_id->entity->id();
'taxi' => $taxi, $CapacityPerClass = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $schoolid, 'specialty_id' => $specialityid));
'tomeas' => $tomeasnew, $classcapacity = reset($CapacityPerClass);
'special' => $specialitnew, if ($classcapacity) {
'tomeas' => $classcapacity->specialty_id->value, $list[] = array(
'capacity' => $classcapacity->capacity_class_specialty->value, 'class' => 3,
'specialty' => 'fromspeciality', 'newsector' => 0,
); 'newspecialit' => $object->specialty_id->entity->id(),
'taxi' => 'Γ Λυκείου '.$object->specialty_id->entity->get('name')->value,
'capacity' => $classcapacity->capacity_class_specialty->value,
'globalindex' => $i,
);
}
++$i;
} }
} }
if (($tomeasnew != 0) && ($specialitnew != 0) && ($taxi == 4)) { if ($CourseC && $operation_shift != 'ΗΜΕΡΗΣΙΟ') {
$CapacityPerClass = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $schoolid, 'specialty_id' => $specialitnew));
$classcapacity = reset($CapacityPerClass); foreach ($CourseC as $object) {
if ($classcapacity) {
$list[] = array( $specialityid = $object->specialty_id->entity->id();
'taxi' => $taxi,
'tomeas' => $tomeasnew, $CapacityPerClass = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $schoolid, 'specialty_id' => $specialityid));
'special' => $specialitnew, $classcapacity = reset($CapacityPerClass);
'tomeas' => $classcapacity->specialty_id->value, if ($classcapacity) {
'capacity' => $classcapacity->capacity_class_specialty_d->value, $list[] = array(
'specialty' => 'fromspecialityd', 'class' => 4,
); 'newsector' => 0,
'newspecialit' => $object->specialty_id->entity->id(),
'taxi' => 'Δ Λυκείου '.$object->specialty_id->entity->get('name')->value,
'capacity' => $classcapacity->capacity_class_specialty_d->value,
'globalindex' => $i,
);
}
++$i;
} }
} }
return $this->respondWithStatus( return $this->respondWithStatus(
$list, Response::HTTP_OK); $list, Response::HTTP_OK);
} }
} else { } else {
return $this->respondWithStatus([ return $this->respondWithStatus([
...@@ -861,175 +775,9 @@ class DirectorView extends ControllerBase ...@@ -861,175 +775,9 @@ class DirectorView extends ControllerBase
], Response::HTTP_FORBIDDEN); ], Response::HTTP_FORBIDDEN);
} }
} }
public function getSchoolID(Request $request) public function FindCoursesPerSchool(Request $request)
{
$authToken = $request->headers->get('PHP_AUTH_USER');
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if ($user) {
$schid = intval($user->init->value);
$list = array();
$list[] = array(
'id' => $schid,
);
return $this->respondWithStatus(
$list, Response::HTTP_OK);
} else {
return $this->respondWithStatus([
'message' => t('User not found!'),
], Response::HTTP_FORBIDDEN);
}
}
public function gettypeofschool(Request $request)
{
$authToken = $request->headers->get('PHP_AUTH_USER');
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if ($user) {
$schid = intval($user->init->value);
$schools = $this->entityTypeManager->getStorage('eepal_school')->
loadByProperties(array('id' => $schid));
$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;
}
$userRoles = $user->getRoles();
$userRole = '';
foreach ($userRoles as $tmpRole) {
if ($tmpRole === 'epal') {
$userRole = $tmpRole;
}
}
if ($userRole === '') {
return $this->respondWithStatus([
'error_code' => 4003,
], Response::HTTP_FORBIDDEN);
} elseif ($userRole === 'epal') {
$list = array();
$list[] = array(
'type' => $school->operation_shift->value,
);
return $this->respondWithStatus(
$list, Response::HTTP_OK);
}
} else {
return $this->respondWithStatus([
'message' => t('User not found!'),
], Response::HTTP_FORBIDDEN);
}
}
public function getlimitsperCourse(Request $request, $classid)
{
$authToken = $request->headers->get('PHP_AUTH_USER');
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if ($user) {
$schoolid = $user->init->value;
$schools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id' => $schoolid));
$school = reset($schools);
if (!$school) {
$this->logger->warning('no access to this school='.$user->id());
return $this->respondWithStatus([
'message' => "No access to this school"
], Response::HTTP_FORBIDDEN);
}
$userRoles = $user->getRoles();
$userRole = '';
foreach ($userRoles as $tmpRole) {
if ($tmpRole === 'epal') {
$userRole = $tmpRole;
}
}
if ($userRole === '') {
return $this->respondWithStatus([
'error_code' => 4003,
], Response::HTTP_FORBIDDEN);
} elseif ($userRole === 'epal') {
$list = array();
$SchoolCats = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id' => $schoolid));
$SchoolCat = reset($SchoolCats);
if ($SchoolCat) {
$categ = $SchoolCat->metathesis_region->value;
$list = array();
if ($classid == 1) {
$limit_down = $this->entityTypeManager->getStorage('epal_class_limits')->loadByProperties(array('name' => 1, 'category' => $categ));
$limitdown = reset($limit_down);
if ($limitdown) {
$limit = $limitdown->limit_down->value;
}
$list[] = array(
'id' => '1',
'name' => 'Α Λυκείου',
'categ' => $categ,
'classes' => 1,
'limitdown' => $limit,
);
}
if ($classid == 2) {
$limit_down = $this->entityTypeManager->getStorage('epal_class_limits')->loadByProperties(array('name' => 2, 'category' => $categ));
$limitdown = reset($limit_down);
if ($limitdown) {
$limit = $limitdown->limit_down->value;
}
$list[] = array(
'name' => 'Β Λυκείου ',
'categ' => $categ,
'classes' => 2,
'limitdown' => $limit,
);
}
if ($classid == 3) {
$limit_down = $this->entityTypeManager->getStorage('epal_class_limits')->loadByProperties(array('name' => 3, 'category' => $categ));
$limitdown = reset($limit_down);
if ($limitdown) {
$limit = $limitdown->limit_down->value;
}
$list[] = array(
'categ' => $categ,
'classes' => 3,
'limitdown' => $limit,
);
}
return $this->respondWithStatus($list, Response::HTTP_OK);
}
} else {
return $this->respondWithStatus([
'message' => t('Perfecture not found!'),
], Response::HTTP_FORBIDDEN);
}
} else {
return $this->respondWithStatus([
'message' => t('User not found!'),
], Response::HTTP_FORBIDDEN);
}
}
public function FindCapacityPerSchool(Request $request)
{ {
$i = 0; $i = 0;
$authToken = $request->headers->get('PHP_AUTH_USER'); $authToken = $request->headers->get('PHP_AUTH_USER');
...@@ -1064,10 +812,9 @@ class DirectorView extends ControllerBase ...@@ -1064,10 +812,9 @@ class DirectorView extends ControllerBase