Commit 49681e06 authored by Open Source Developer's avatar Open Source Developer

bugs

parents 695e19e1 9e92e774
...@@ -188,9 +188,11 @@ class CASLogin extends ControllerBase ...@@ -188,9 +188,11 @@ class CASLogin extends ControllerBase
phpCAS::trace($umdobject); phpCAS::trace($umdobject);
phpCAS::trace($physicaldeliveryofficename); // phpCAS::trace($physicaldeliveryofficename);
$gsnunitcodedn = $filterAttribute('edupersonorgunitdn:gsnunitcode:extended'); // $gsnunitcodedn = $filterAttribute('edupersonorgunitdn:gsnunitcode:extended');
$gsnunitcode = substr($gsnunitcodedn, strpos($gsnunitcodedn, ";") + 1); $gsnunitcode = substr($gsnunitcodedn, strpos($gsnunitcodedn, ";") + 1);
$gsnunitcode = $filterAttribute('edupersonorgunitdn:gsnunitcode');
phpCAS::trace("$gsnunitcode=");
phpCAS::trace($gsnunitcode); phpCAS::trace($gsnunitcode);
/* check if myschool account */ /* check if myschool account */
...@@ -274,6 +276,7 @@ class CASLogin extends ControllerBase ...@@ -274,6 +276,7 @@ class CASLogin extends ControllerBase
if ($user) { if ($user) {
$user->setPassword($epalToken); $user->setPassword($epalToken);
$user->setUsername($epalToken); $user->setUsername($epalToken);
$user->set('init', $userAssigned["id"]);
$user->save(); $user->save();
} }
......
...@@ -46,6 +46,14 @@ epal.submitedapplications: ...@@ -46,6 +46,14 @@ epal.submitedapplications:
_controller: '\Drupal\epal\Controller\SubmitedApplications::getSubmittedApplications' _controller: '\Drupal\epal\Controller\SubmitedApplications::getSubmittedApplications'
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
epal.application_delete:
path: '/epal/application/delete'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\SubmitedApplications::deleteApplication'
requirements:
_user_is_logged_in: 'TRUE'
epal.studentapplication: epal.studentapplication:
path: '/epal/student/{studentId}' path: '/epal/student/{studentId}'
options: options:
...@@ -78,6 +86,14 @@ epal.allocation: ...@@ -78,6 +86,14 @@ 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.allocation_second:
path: '/epal/distribution-secondperiod'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\Distribution::locateSecondPeriodStudents'
requirements:
_user_is_logged_in: 'TRUE'
epal.confirmstudents: epal.confirmstudents:
path: '/epal/confirmstudent' path: '/epal/confirmstudent'
options: options:
...@@ -221,7 +237,7 @@ epal.coursesperschools: ...@@ -221,7 +237,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:
...@@ -278,6 +294,3 @@ epal.findcoursesperschool: ...@@ -278,6 +294,3 @@ epal.findcoursesperschool:
_controller: '\Drupal\epal\Controller\DirectorView::FindCoursesPerSchool' _controller: '\Drupal\epal\Controller\DirectorView::FindCoursesPerSchool'
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
...@@ -101,7 +101,7 @@ class ApplicationSubmit extends ControllerBase ...@@ -101,7 +101,7 @@ class ApplicationSubmit extends ControllerBase
$regionaddress_encoded = $crypt->encrypt($applicationForm[0]['regionaddress']); $regionaddress_encoded = $crypt->encrypt($applicationForm[0]['regionaddress']);
$regiontk_encoded = $crypt->encrypt($applicationForm[0]['regiontk']); $regiontk_encoded = $crypt->encrypt($applicationForm[0]['regiontk']);
$regionarea_encoded = $crypt->encrypt($applicationForm[0]['regionarea']); $regionarea_encoded = $crypt->encrypt($applicationForm[0]['regionarea']);
$certificatetype_encoded = $crypt->encrypt($applicationForm[0]['certificatetype']); //$certificatetype_encoded = $crypt->encrypt($applicationForm[0]['certificatetype']);
$relationtostudent_encoded = $crypt->encrypt($applicationForm[0]['relationtostudent']); $relationtostudent_encoded = $crypt->encrypt($applicationForm[0]['relationtostudent']);
$telnum_encoded = $crypt->encrypt($applicationForm[0]['telnum']); $telnum_encoded = $crypt->encrypt($applicationForm[0]['telnum']);
$guardian_name_encoded = $crypt->encrypt($applicationForm[0]['cu_name']); $guardian_name_encoded = $crypt->encrypt($applicationForm[0]['cu_name']);
...@@ -157,8 +157,8 @@ class ApplicationSubmit extends ControllerBase ...@@ -157,8 +157,8 @@ class ApplicationSubmit extends ControllerBase
'regionaddress' => $regionaddress_encoded, 'regionaddress' => $regionaddress_encoded,
'regionarea' => $regionarea_encoded, 'regionarea' => $regionarea_encoded,
'regiontk' => $regiontk_encoded, 'regiontk' => $regiontk_encoded,
'certificatetype' => $certificatetype_encoded, //'certificatetype' => $certificatetype_encoded,
'graduation_year' => $applicationForm[0]['graduation_year'], //'graduation_year' => $applicationForm[0]['graduation_year'],
'lastschool_registrynumber' => $applicationForm[0]['lastschool_registrynumber'], 'lastschool_registrynumber' => $applicationForm[0]['lastschool_registrynumber'],
'lastschool_unittypeid' => $applicationForm[0]['lastschool_unittypeid'], 'lastschool_unittypeid' => $applicationForm[0]['lastschool_unittypeid'],
'lastschool_schoolname' => $applicationForm[0]['lastschool_schoolname'], 'lastschool_schoolname' => $applicationForm[0]['lastschool_schoolname'],
...@@ -285,6 +285,7 @@ class ApplicationSubmit extends ControllerBase ...@@ -285,6 +285,7 @@ class ApplicationSubmit extends ControllerBase
*/ */
private function validateStudent($student) private function validateStudent($student)
{ {
$error_code = 0;
if (!$student["agreement"]) { if (!$student["agreement"]) {
return 1001; return 1001;
} }
...@@ -298,6 +299,8 @@ class ApplicationSubmit extends ControllerBase ...@@ -298,6 +299,8 @@ class ApplicationSubmit extends ControllerBase
(checkdate($date_parts[1], $date_parts[2], $date_parts[0]) !== true)) { (checkdate($date_parts[1], $date_parts[2], $date_parts[0]) !== true)) {
return 1003; return 1003;
} }
if (intval($date_parts[0]) >= 2003)
return 1003;
$birthdate = "{$date_parts[2]}-{$date_parts[1]}-{$date_parts[0]}"; $birthdate = "{$date_parts[2]}-{$date_parts[1]}-{$date_parts[0]}";
if (!$student["name"]) { if (!$student["name"]) {
...@@ -321,12 +324,14 @@ class ApplicationSubmit extends ControllerBase ...@@ -321,12 +324,14 @@ class ApplicationSubmit extends ControllerBase
if (!$student["regionarea"]) { if (!$student["regionarea"]) {
return 1010; return 1010;
} }
/*
if (!$student["certificatetype"]) { if (!$student["certificatetype"]) {
return 1011; return 1011;
} }
if (!$student["graduation_year"]) { if (!$student["graduation_year"]) {
return 1012; return 1012;
} }
*/
if (!$student["currentclass"] || ($student["currentclass"] !== "1" && $student["currentclass"] !== "2" && $student["currentclass"] !== "3" && $student["currentclass"] !== "4") ) { if (!$student["currentclass"] || ($student["currentclass"] !== "1" && $student["currentclass"] !== "2" && $student["currentclass"] !== "3" && $student["currentclass"] !== "4") ) {
return 1013; return 1013;
} }
......
...@@ -10,6 +10,7 @@ use Symfony\Component\HttpFoundation\Request; ...@@ -10,6 +10,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\Database\Connection; use Drupal\Core\Database\Connection;
use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\epal\Crypt;
class CurrentUser extends ControllerBase class CurrentUser extends ControllerBase
{ {
...@@ -84,16 +85,45 @@ class CurrentUser extends ControllerBase ...@@ -84,16 +85,45 @@ class CurrentUser extends ControllerBase
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken)); $epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken));
$epalUser = reset($epalUsers); $epalUser = reset($epalUsers);
if ($epalUser) { if ($epalUser) {
$crypt = new Crypt();
try {
$name_decoded = $crypt->decrypt($epalUser->name->value);
$surname_decoded = $crypt->decrypt($epalUser->surname->value);
$fathername_decoded = $crypt->decrypt($epalUser->fathername->value);
$mothername_decoded = $crypt->decrypt($epalUser->mothername->value);
}
catch (\Exception $e) {
unset($crypt);
$this->logger->warning($e->getMessage());
return $this->respondWithStatus([
"error_code" => 5001
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
unset($crypt);
/*
$userName = $epalUser->name->value; $userName = $epalUser->name->value;
$userSurname = $epalUser->surname->value; $userSurname = $epalUser->surname->value;
$userFathername = $epalUser->fathername->value; $userFathername = $epalUser->fathername->value;
$userMothername = $epalUser->mothername->value; $userMothername = $epalUser->mothername->value;
*/
$userName = $name_decoded;
$userSurname = $surname_decoded ;
$userFathername = $fathername_decoded;
$userMothername =$mothername_decoded;
$userEmail = $user->mail->value; $userEmail = $user->mail->value;
return $this->respondWithStatus([ return $this->respondWithStatus([
'cu_name' => mb_substr($epalUser->name->value,0,4,'UTF-8') !== "####" ? $epalUser->name->value : '', //'cu_name' => mb_substr($epalUser->name->value,0,4,'UTF-8') !== "####" ? $epalUser->name->value : '',
'cu_surname' => mb_substr($epalUser->surname->value,0,4,'UTF-8') !== "####" ? $epalUser->surname->value : '', //'cu_surname' => mb_substr($epalUser->surname->value,0,4,'UTF-8') !== "####" ? $epalUser->surname->value : '',
'cu_fathername' => mb_substr($epalUser->fathername->value,0,4,'UTF-8') !== "####" ? $epalUser->fathername->value : '', //'cu_fathername' => mb_substr($epalUser->fathername->value,0,4,'UTF-8') !== "####" ? $epalUser->fathername->value : '',
'cu_mothername' => mb_substr($epalUser->mothername->value,0,4,'UTF-8') !== "####" ? $epalUser->mothername->value : '', //'cu_mothername' => mb_substr($epalUser->mothername->value,0,4,'UTF-8') !== "####" ? $epalUser->mothername->value : '',
'cu_name' => mb_substr($userName,0,4,'UTF-8') !== "####" ? $userName : '',
'cu_surname' => mb_substr($userSurname,0,4,'UTF-8') !== "####" ? $userSurname : '',
'cu_fathername' => mb_substr($userFathername,0,4,'UTF-8') !== "####" ? $userFathername : '',
'cu_mothername' => mb_substr($userMothername,0,4,'UTF-8') !== "####" ? $userMothername : '',
'cu_email' => mb_substr($user->mail->value,0,4,'UTF-8') !== "####" ? $user->mail->value : '', 'cu_email' => mb_substr($user->mail->value,0,4,'UTF-8') !== "####" ? $user->mail->value : '',
'minedu_username' => '', 'minedu_username' => '',
'minedu_userpassword' => '', 'minedu_userpassword' => '',
...@@ -119,16 +149,39 @@ class CurrentUser extends ControllerBase ...@@ -119,16 +149,39 @@ class CurrentUser extends ControllerBase
if ($epalUser) { if ($epalUser) {
$user = $this->entityTypeManager->getStorage('user')->load($epalUser->user_id->target_id); $user = $this->entityTypeManager->getStorage('user')->load($epalUser->user_id->target_id);
if ($user) { if ($user) {
$userName = $epalUser->name->value;
$userSurname = $epalUser->surname->value; $crypt = new Crypt();
$userFathername = $epalUser->fathername->value; try {
$userMothername = $epalUser->mothername->value; $userName = $crypt->decrypt($epalUser->name->value);
$userSurname = $crypt->decrypt($epalUser->surname->value);
$userFathername = $crypt->decrypt($epalUser->fathername->value);
$userMothername = $crypt->decrypt($epalUser->mothername->value);
}
catch (\Exception $e) {
unset($crypt);
$this->logger->warning($e->getMessage());
return $this->respondWithStatus([
"error_code" => 5001
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
unset($crypt);
//$userName = $epalUser->name->value;
//$userSurname = $epalUser->surname->value;
//$userFathername = $epalUser->fathername->value;
//$userMothername = $epalUser->mothername->value;
$userEmail = $user->mail->value; $userEmail = $user->mail->value;
return $this->respondWithStatus([ return $this->respondWithStatus([
'userName' => mb_substr($epalUser->name->value,0,4,'UTF-8') !== "####" ? $epalUser->name->value : '', //'userName' => mb_substr($epalUser->name->value,0,4,'UTF-8') !== "####" ? $epalUser->name->value : '',
'userSurname' => mb_substr($epalUser->surname->value,0,4,'UTF-8') !== "####" ? $epalUser->surname->value : '', //'userSurname' => mb_substr($epalUser->surname->value,0,4,'UTF-8') !== "####" ? $epalUser->surname->value : '',
'userFathername' => mb_substr($epalUser->fathername->value,0,4,'UTF-8') !== "####" ? $epalUser->fathername->value : '', //'userFathername' => mb_substr($epalUser->fathername->value,0,4,'UTF-8') !== "####" ? $epalUser->fathername->value : '',
'userMothername' => mb_substr($epalUser->mothername->value,0,4,'UTF-8') !== "####" ? $epalUser->mothername->value : '', //'userMothername' => mb_substr($epalUser->mothername->value,0,4,'UTF-8') !== "####" ? $epalUser->mothername->value : '',
'userName' => mb_substr($userName,0,4,'UTF-8') !== "####" ? $userName : '',
'userSurname' => mb_substr($userSurname,0,4,'UTF-8') !== "####" ? $userSurname : '',
'userFathername' => mb_substr($userFathername,0,4,'UTF-8') !== "####" ? $userFathername : '',
'userMothername' => mb_substr($userMothername,0,4,'UTF-8') !== "####" ? $userMothername : '',
'userEmail' => mb_substr($user->mail->value,0,4,'UTF-8') !== "####" ? $user->mail->value : '', 'userEmail' => mb_substr($user->mail->value,0,4,'UTF-8') !== "####" ? $user->mail->value : '',
'verificationCodeVerified' => $epalUser->verificationcodeverified->value, 'verificationCodeVerified' => $epalUser->verificationcodeverified->value,
], Response::HTTP_OK); ], Response::HTTP_OK);
...@@ -286,23 +339,56 @@ class CurrentUser extends ControllerBase ...@@ -286,23 +339,56 @@ class CurrentUser extends ControllerBase
$postData = null; $postData = null;
if ($content = $request->getContent()) { if ($content = $request->getContent()) {
$postData = json_decode($content); $postData = json_decode($content);
$crypt = new Crypt();
try {
$name_encoded = $crypt->encrypt($postData->userProfile->userName);
$surname_encoded = $crypt->encrypt($postData->userProfile->userSurname);
$fathername_encoded = $crypt->encrypt($postData->userProfile->userMothername);
$mothername_encoded = $crypt->encrypt($postData->userProfile->userFathername);
}
catch (\Exception $e) {
unset($crypt);
$this->logger->warning($e->getMessage());
return $this->respondWithStatus([
"error_code" => 5001
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
unset($crypt);
/*
$epalUser->set('name', $postData->userProfile->userName); $epalUser->set('name', $postData->userProfile->userName);
$epalUser->set('surname', $postData->userProfile->userSurname); $epalUser->set('surname', $postData->userProfile->userSurname);
$epalUser->set('mothername', $postData->userProfile->userMothername); $epalUser->set('mothername', $postData->userProfile->userMothername);
$epalUser->set('fathername', $postData->userProfile->userFathername); $epalUser->set('fathername', $postData->userProfile->userFathername);
*/
$epalUser->set('name', $name_encoded);
$epalUser->set('surname', $surname_encoded);
$epalUser->set('mothername', $fathername_encoded);
$epalUser->set('fathername', $mothername_encoded);
$epalUser->save(); $epalUser->save();
$user = $this->entityTypeManager->getStorage('user')->load($epalUser->user_id->target_id);
if ($user) {
$user->set('mail', $postData->userProfile->userEmail);
$user->save();
} else {
return $this->respondWithStatus([
'error_code' => '1001',
], Response::HTTP_FORBIDDEN);
}
return $this->respondWithStatus([ return $this->respondWithStatus([
'message' => t("profile saved"), 'error_code' => '0',
], Response::HTTP_OK); ], Response::HTTP_OK);
} else { } else {
return $this->respondWithStatus([ return $this->respondWithStatus([
'message' => t("post with no data"), 'error_code' => '1002',
], Response::HTTP_BAD_REQUEST); ], Response::HTTP_BAD_REQUEST);
} }
} else { } else {
return $this->respondWithStatus([ return $this->respondWithStatus([
'message' => t("EPAL user not found"), 'error_code' => '1003',
], Response::HTTP_FORBIDDEN); ], Response::HTTP_FORBIDDEN);
} }
} }
......
This diff is collapsed.
...@@ -276,7 +276,7 @@ class Distribution extends ControllerBase { ...@@ -276,7 +276,7 @@ class Distribution extends ControllerBase {
$this->logger->warning($e->getMessage()); $this->logger->warning($e->getMessage());
$transaction->rollback(); $transaction->rollback();
return $this->respondWithStatus([ return $this->respondWithStatus([
"message" => t("An unexpected problem occured") "message" => t("An unexpected problem occured in createDistribution Method")
], Response::HTTP_INTERNAL_SERVER_ERROR); ], Response::HTTP_INTERNAL_SERVER_ERROR);
} }
...@@ -346,6 +346,8 @@ class Distribution extends ControllerBase { ...@@ -346,6 +346,8 @@ class Distribution extends ControllerBase {
$timestamp = strtotime(date("Y-m-d")); $timestamp = strtotime(date("Y-m-d"));
$this->connection->insert('epal_student_class')->fields( $this->connection->insert('epal_student_class')->fields(
array('id' => $this->globalCounterId++, array('id' => $this->globalCounterId++,
'uuid' => \Drupal::service('uuid')->generate(), 'uuid' => \Drupal::service('uuid')->generate(),
...@@ -356,7 +358,7 @@ class Distribution extends ControllerBase { ...@@ -356,7 +358,7 @@ class Distribution extends ControllerBase {
'currentclass' => $epalStudent->currentclass, 'currentclass' => $epalStudent->currentclass,
'currentepal' => $epalStudent->currentepal, 'currentepal' => $epalStudent->currentepal,
'specialization_id' => $specialization_id, 'specialization_id' => $specialization_id,
'points' => $epalStudent->points, //'points' => $epalStudent->points,
'distribution_id' => $choice_id, 'distribution_id' => $choice_id,
'finalized' => 1, 'finalized' => 1,
'status' => 1, 'status' => 1,
...@@ -364,6 +366,7 @@ class Distribution extends ControllerBase { ...@@ -364,6 +366,7 @@ class Distribution extends ControllerBase {
'changed' => $timestamp,) 'changed' => $timestamp,)
)->execute(); )->execute();
} //end if } //end if
} //foreach } //foreach
...@@ -797,5 +800,127 @@ public function checkCapacityAndArrange($epalId, $classId, $secCourId, $limitup, ...@@ -797,5 +800,127 @@ public function checkCapacityAndArrange($epalId, $classId, $secCourId, $limitup,
public function locateSecondPeriodStudents(Request $request) {
//POST method is checked
if (!$request->isMethod('POST')) {
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") {
$validRole = true;
break;
}
if (!$validRole) {
return $this->respondWithStatus([
'message' => t("User Invalid Role"),
], Response::HTTP_FORBIDDEN);
}
//check where distribution can be done now
$secondPeriodEnabled = "0";
$config_storage = $this->entityTypeManager->getStorage('epal_config');
$epalConfigs = $config_storage->loadByProperties(array('id' => 1));
$epalConfig = reset($epalConfigs);
if (!$epalConfig) {
return $this->respondWithStatus([
'message' => t("EpalConfig Enity not found"),
], Response::HTTP_FORBIDDEN);
}
else {
$secondPeriodEnabled = $epalConfig->activate_second_period->getString();
}
if ($secondPeriodEnabled === "0" ) {
return $this->respondWithStatus([
'message' => t("secondPeriodEnabled setting is false"),
], Response::HTTP_FORBIDDEN);
}
try {
$sCon = $this->connection->select('epal_student', 'eStudent')
->fields('eStudent', array('id', 'currentclass', 'currentepal'))
->condition('eStudent.second_period', 1 , '=');
$epalStudents = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
//$this->globalCounterId = 10000;
$this->globalCounterId = $this->retrieveLastStudentId() + 1;
if ($this->locateStudent(1, $epalStudents) === ERROR_DB)
return $this->respondWithStatus([
"message" => t("Unexpected Error in locateStudent function")
], Response::HTTP_INTERNAL_SERVER_ERROR);
if ($this->findSmallClasses() === ERROR_DB)
return $this->respondWithStatus([
"message" => t("Unexpected Error in findSmallClasses function AFTER locateSecondPeriodStudents!")
], Response::HTTP_INTERNAL_SERVER_ERROR);
//αν αποτύχει, δεν γίνεται rollback. --> Λύση: διαγρα΄φή των όποιων αποτελεσμάτων ;;
}
catch (\Exception $e) {
$this->logger->warning($e->getMessage());
return $this->respondWithStatus([
"message" => t("An unexpected problem occured in locateSecondPeriodStudents Method")
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
$postData = null;
if ($content = $request->getContent()) {
$postData = json_decode($content);
return $this->respondWithStatus([
'message' => "locateSecondPeriodStudents has made successfully",
], Response::HTTP_OK);
}
else {
return $this->respondWithStatus([
'message' => t("post with no data"),
], Response::HTTP_BAD_REQUEST);
}
}
private function retrieveLastStudentId() {
$sCon = $this->connection->select('epal_student', 'eStudent')
->fields('eStudent', array('id'));
$sCon->orderBy('eStudent.id','desc');
$epalStudents = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
if ($epalStudents) {
$epalStrudent = reset($epalStudents);
return $epalStrudent->id;
}
return 0;
}
} }
...@@ -88,7 +88,8 @@ class PDFCreator extends ControllerBase { ...@@ -88,7 +88,8 @@ class PDFCreator extends ControllerBase {
], Response::HTTP_FORBIDDEN); ], Response::HTTP_FORBIDDEN);
*/ */
//New epal-user validation //Epal-user validation
$authToken = $request->headers->get('PHP_AUTH_USER'); $authToken = $request->headers->get('PHP_AUTH_USER');
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken)); $epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken));
$epalUser = reset($epalUsers); $epalUser = reset($epalUsers);
...@@ -101,7 +102,6 @@ class PDFCreator extends ControllerBase { ...@@ -101,7 +102,6 @@ class PDFCreator extends ControllerBase {
], Response::HTTP_FORBIDDEN); ], Response::HTTP_FORBIDDEN);
} }
} }
//end New User validation
//user role validation //user role validation
...@@ -297,7 +297,7 @@ class PDFCreator extends ControllerBase { ...@@ -297,7 +297,7 @@ class PDFCreator extends ControllerBase {
$studentsurname_decoded = $this->crypt->decrypt($student->studentsurname->value); $studentsurname_decoded = $this->crypt->decrypt($student->studentsurname->value);
$fatherfirstname_decoded = $this->crypt->decrypt($student->fatherfirstname->value); $fatherfirstname_decoded = $this->crypt->decrypt($student->fatherfirstname->value);
$motherfirstname_decoded = $this->crypt->decrypt($student->motherfirstname->value); $motherfirstname_decoded = $this->crypt->decrypt($student->motherfirstname->value);
$certificatetype_decoded = $this->crypt->decrypt($student->certificatetype->value); //$certificatetype_decoded = $this->crypt->decrypt($student->certificatetype->value);
$relationtostudent_decoded = $this->crypt->decrypt($student->relationtostudent->value); $relationtostudent_decoded = $this->crypt->decrypt($student->relationtostudent->value);
$telnum_decoded = $this->crypt->decrypt($student->telnum->value); $telnum_decoded = $this->crypt->decrypt($student->telnum->value);
} }
...@@ -375,18 +375,21 @@ class PDFCreator extends ControllerBase { ...@@ -375,18 +375,21 @@ class PDFCreator extends ControllerBase {
$this->pdf->Ln(); $this->pdf->Ln();
/*
$this->pdf->SetFont($this->fontLight, '', $this->fontSizeRegular); $this->pdf->SetFont($this->fontLight, '', $this->fontSizeRegular);
$this->pdf->Cell($width+15, $height, $this->prepareString('Τύπος απολυτηρίου:'), 0, 'L'); $this->pdf->Cell($width+15, $height, $this->prepareString('Τύπος απολυτηρίου:'), 0, 'L');
$this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular); $this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular);
//$this->pdf->Cell($width, $height, $this->prepareString($student->certificatetype->value), 0, 'L');
$this->pdf->Cell($width, $height, $this->prepareString($certificatetype_decoded), 0, 'L'); $this->pdf->Cell($width, $height, $this->prepareString($certificatetype_decoded), 0, 'L');
$this->pdf->Ln(); $this->pdf->Ln();
*/
/*
$this->pdf->SetFont($this->fontLight, '', $this->fontSizeRegular); $this->pdf->SetFont($this->fontLight, '', $this->fontSizeRegular);
$this->pdf->Cell($width+15, $height, $this->prepareString('Έτος κτήσης απολυτηρίου:'), 0, 'L'); $this->pdf->Cell($width+15, $height, $this->prepareString('Έτος κτήσης απολυτηρίου:'), 0, 'L');
$this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular); $this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular);
$this->pdf->Cell($width, $height, $this->prepareString($student->graduation_year->value), 0, 'L'); $this->pdf->Cell($width, $height, $this->prepareString($student->graduation_year->value), 0, 'L');
$this->pdf->Ln(); $this->pdf->Ln();
*/
$this->pdf->SetFont($this->fontLight, '', $this->fontSizeRegular); $this->pdf->SetFont($this->fontLight, '', $this->fontSizeRegular);
$this->pdf->Cell($width+15, $height, $this->prepareString('Σχολείο τελευταίας φοίτησης:'), 0, 'L'); $this->pdf->Cell($width+15, $height, $this->prepareString('Σχολείο τελευταίας φοίτησης:'), 0, 'L');
...@@ -573,7 +576,7 @@ private function createSchoolChoices($student) { ...@@ -573,7 +576,7 @@ private function createSchoolChoices($student) {
$this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular); $this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular);
$this->pdf->Cell($width, $height, $this->prepareString($epalSchool->choice_no->value), 0, 0, 'C'); $this->pdf->Cell($width, $height, $this->prepareString($epalSchool->choice_no->value), 0, 0, 'C');
$this->pdf->multiCell(4*width, $height, $this->prepareString($epalSchoolName->name->value), 0, 'L'); $this->pdf->multiCell(4*$width, $height, $this->prepareString($epalSchoolName->name->value), 0, 'L');
} }
} }
......
...@@ -44,6 +44,86 @@ class SubmitedApplications extends ControllerBase ...@@ -44,6 +44,86 @@ class SubmitedApplications extends ControllerBase
); );
} }
public function deleteApplication(Request $request)
{
if (!$request->isMethod('POST')) {
return $this->respondWithStatus([
"error_code" => 2001
], Response::HTTP_METHOD_NOT_ALLOWED);
}
$content = $request->getContent();
$applicationId = 0;
if (!empty($content)) {
$postArr = json_decode($content, TRUE);