Merge branch 'pde-dde-views' into 'develop'

changes

See merge request !155
parents daf7e47f 85569720
......@@ -78,22 +78,6 @@ epal.allocation:
_controller: '\Drupal\epal\Controller\Distribution::createDistribution'
requirements:
_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:
path: '/epal/confirmstudent'
options:
......@@ -237,7 +221,7 @@ epal.coursesperschools:
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::getCoursesPerSchool'
requirements:
_user_is_logged_in: 'TRUE'
_user_is_logged_in: 'TRUE'
epal.critirioschosen:
path: '/epal/critiriachosen/{studentId}/{type}'
options:
......@@ -246,38 +230,6 @@ epal.critirioschosen:
_controller: '\Drupal\epal\Controller\SubmitedApplications::getCritiria'
requirements:
_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:
path: '/epal/findcapacityperschool'
options:
......@@ -318,3 +270,14 @@ epal.svc.getstudentcertification:
_controller: '\Drupal\epal\Controller\WSConsumer::getStudentEpalCertification'
requirements:
_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
);
}
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)
{
try {
......@@ -330,6 +208,9 @@ class DirectorView extends ControllerBase
}
}
public function ConfirmStudents(Request $request)
{
if (!$request->isMethod('POST')) {
......@@ -420,6 +301,8 @@ class DirectorView extends ControllerBase
}
}
public function SaveCapacity(Request $request, $taxi, $tomeas, $specialit)
{
if (!$request->isMethod('POST')) {
......@@ -532,6 +415,8 @@ class DirectorView extends ControllerBase
}
}
public function getSchools(Request $request)
{
$authToken = $request->headers->get('PHP_AUTH_USER');
......@@ -584,6 +469,7 @@ class DirectorView extends ControllerBase
}
}
public function getCoursesPerSchool(Request $request, $schoolid)
{
$authToken = $request->headers->get('PHP_AUTH_USER');
......@@ -758,13 +644,12 @@ class DirectorView extends ControllerBase
}
return true;
// exit;
}
public function findCapacity(Request $request, $taxi, $tomeas, $specialit)
public function FindCapacityPerSchool(Request $request)
{
$tomeasnew = intval($tomeas);
$specialitnew = intval($specialit);
$i = 0;
$authToken = $request->headers->get('PHP_AUTH_USER');
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
......@@ -782,6 +667,7 @@ class DirectorView extends ControllerBase
return $response;
}
$operation_shift = $school -> operation_shift -> value;
$userRoles = $user->getRoles();
$userRole = '';
foreach ($userRoles as $tmpRole) {
......@@ -794,66 +680,94 @@ class DirectorView extends ControllerBase
'error_code' => 4003,
], Response::HTTP_FORBIDDEN);
} elseif ($userRole === 'epal') {
$categ = $school->metathesis_region->value;
$list = array();
$CourseA = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id' => $schoolid));
$classcapacity = reset($CourseA);
if (($tomeasnew == 0) && ($specialitnew == 0)) {
$CapacityPerClass = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id' => $schoolid));
$classcapacity = reset($CapacityPerClass);
if ($classcapacity) {
if ($classcapacity) {
$list[] = array(
'taxi' => $taxi,
'capacity' => $classcapacity->capacity_class_a->value,
);
}
$list[] = array(
'class' => 1,
'newsector' => 0,
'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)) {
$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,
foreach ($CourseB as $object) {
$sectorid = $object->sector_id->entity->id();
$CapacityPerClass = $this->entityTypeManager->getStorage('eepal_sectors_in_epal')->loadByProperties(array('epal_id' => $schoolid, 'sector_id' => $sectorid));
$classcapacity = reset($CapacityPerClass);
if ($classcapacity) {
$list[] = array(
'class' => 2,
'newsector' => $object->sector_id->entity->id(),
'newspecialit' => 0,
'taxi' => 'Β Λυκείου '.$object->sector_id->entity->get('name')->value,
'capacity' => $classcapacity->capacity_class_sector->value,
'sector' => $tomeasnew.'lala'.$specialitnew,
);
'globalindex' => $i,
);
}
++$i;
}
}
if (($tomeasnew != 0) && ($specialitnew != 0) && ($taxi == 3)) {
$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,
'specialty' => 'fromspeciality',
);
$CourseC = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $schoolid));
if ($CourseC) {
foreach ($CourseC as $object) {
$specialityid = $object->specialty_id->entity->id();
$CapacityPerClass = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $schoolid, 'specialty_id' => $specialityid));
$classcapacity = reset($CapacityPerClass);
if ($classcapacity) {
$list[] = array(
'class' => 3,
'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)) {
$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_d->value,
'specialty' => 'fromspecialityd',
);
if ($CourseC && $operation_shift != 'ΗΜΕΡΗΣΙΟ') {
foreach ($CourseC as $object) {
$specialityid = $object->specialty_id->entity->id();
$CapacityPerClass = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $schoolid, 'specialty_id' => $specialityid));
$classcapacity = reset($CapacityPerClass);
if ($classcapacity) {
$list[] = array(
'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(
$list, Response::HTTP_OK);
$list, Response::HTTP_OK);
}
} else {
return $this->respondWithStatus([
......@@ -861,175 +775,9 @@ class DirectorView extends ControllerBase
], Response::HTTP_FORBIDDEN);
}
}
public function getSchoolID(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)
public function FindCoursesPerSchool(Request $request)
{
$i = 0;
$authToken = $request->headers->get('PHP_AUTH_USER');
......@@ -1064,10 +812,9 @@ class DirectorView extends ControllerBase
} elseif ($userRole === 'epal') {
$categ = $school->metathesis_region->value;
$list = array();
$CapacityPerClass = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id' => $schoolid));
$classcapacity = reset($CapacityPerClass);
if ($classcapacity) {
$CourseA = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id' => $schoolid));
if ($CourseA) {
$limit_down = $this->entityTypeManager->getStorage('epal_class_limits')->loadByProperties(array('name' => 1, 'category' => $categ));
$limitdown = reset($limit_down);
if ($limitdown) {
......@@ -1080,7 +827,6 @@ class DirectorView extends ControllerBase
'newsector' => 0,
'newspecialit' => 0,
'taxi' => 'Ά Λυκείου',
'capacity' => $classcapacity->capacity_class_a->value,
'globalindex' => $i,
'limitdown' => $limit,
'size' => sizeof($studentPerSchool),
......@@ -1098,20 +844,18 @@ class DirectorView extends ControllerBase
foreach ($CourseB as $object) {
$sectorid = $object->sector_id->entity->id();
$studentPerSchool = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('currentepal' => $schoolid, 'specialization_id' => $sectorid, 'currentclass' => 2));
$CapacityPerClass = $this->entityTypeManager->getStorage('eepal_sectors_in_epal')->loadByProperties(array('epal_id' => $schoolid, 'sector_id' => $sectorid));
$classcapacity = reset($CapacityPerClass);
if ($classcapacity) {
$list[] = array(
'class' => 2,
'newsector' => $object->sector_id->entity->id(),
'newspecialit' => 0,
'taxi' => 'Β Λυκείου '.$object->sector_id->entity->get('name')->value,
'capacity' => $classcapacity->capacity_class_sector->value,
'globalindex' => $i,
'limitdown' => $limit,
'size' => sizeof($studentPerSchool),
);
}
++$i;
}
}
......@@ -1126,20 +870,17 @@ class DirectorView extends ControllerBase
$specialityid = $object->specialty_id->entity->id();
$studentPerSchool = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('currentepal' => $schoolid, 'specialization_id' => $specialityid, 'currentclass' => 3));
$CapacityPerClass = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $schoolid, 'specialty_id' => $specialityid));
$classcapacity = reset($CapacityPerClass);
if ($classcapacity) {
$list[] = array(
'class' => 3,
'newsector' => 0,
'newspecialit' => $object->specialty_id->entity->id(),
'taxi' => 'Γ Λυκείου '.$object->specialty_id->entity->get('name')->value,
'capacity' => $classcapacity