Merge branch 'component_updates' into 'develop'

Component updates

See merge request !146
parents f248fded fa6e5a72
......@@ -13,6 +13,8 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\epal\Crypt;
use Drupal\epal\ClientConsumer;
class ApplicationSubmit extends ControllerBase
......@@ -58,38 +60,66 @@ class ApplicationSubmit extends ControllerBase
);
}
public function appSubmit(Request $request)
{
if (!$request->isMethod('POST')) {
return $this->respondWithStatus([
"error_code" => 2001
], Response::HTTP_METHOD_NOT_ALLOWED);
public function appSubmit(Request $request) {
if (!$request->isMethod('POST')) {
return $this->respondWithStatus([
"error_code" => 2001
], Response::HTTP_METHOD_NOT_ALLOWED);
}
$applicationForm = array();
$content = $request->getContent();
if (!empty($content)) {
$applicationForm = json_decode($content, TRUE);
}
else {
return $this->respondWithStatus([
"error_code" => 5002
], Response::HTTP_BAD_REQUEST);
}
$crypt = new Crypt();
try {
$name_encoded = $crypt->encrypt($applicationForm[0]['name']);
$studentsurname_encoded = $crypt->encrypt($applicationForm[0]['studentsurname']);
$fatherfirstname_encoded = $crypt->encrypt($applicationForm[0]['fatherfirstname']);
$motherfirstname_encoded = $crypt->encrypt($applicationForm[0]['motherfirstname']);
$regionaddress_encoded = $crypt->encrypt($applicationForm[0]['regionaddress']);
$regiontk_encoded = $crypt->encrypt($applicationForm[0]['regiontk']);
$regionarea_encoded = $crypt->encrypt($applicationForm[0]['regionarea']);
$certificatetype_encoded = $crypt->encrypt($applicationForm[0]['certificatetype']);
$relationtostudent_encoded = $crypt->encrypt($applicationForm[0]['relationtostudent']);
$telnum_encoded = $crypt->encrypt($applicationForm[0]['telnum']);
$guardian_name_encoded = $crypt->encrypt($applicationForm[0]['cu_name']);
$guardian_surname_encoded = $crypt->encrypt($applicationForm[0]['cu_surname']);
$guardian_fathername_encoded = $crypt->encrypt($applicationForm[0]['cu_fathername']);
$guardian_mothername_encoded = $crypt->encrypt($applicationForm[0]['cu_mothername']);
}
$applicationForm = array();
$content = $request->getContent();
if (!empty($content)) {
$applicationForm = json_decode($content, true);
} else {
return $this->respondWithStatus([
"error_code" => 5002
], Response::HTTP_BAD_REQUEST);
catch (\Exception $e) {
print_r($e->getMessage());
unset($crypt);
$this->logger->warning($e->getMessage());
return $this->respondWithStatus([
"error_code" => 5001
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
unset($crypt);
$transaction = $this->connection->startTransaction();
try {
//insert records in entity: epal_student
$authToken = $request->headers->get('PHP_AUTH_USER');
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken));
$epalUser = reset($epalUsers);
if (!$epalUser) {
return $this->respondWithStatus([
"error_code" => 4003
], Response::HTTP_FORBIDDEN);
}
try {
//insert records in entity: epal_student
$authToken = $request->headers->get('PHP_AUTH_USER');
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken));
$epalUser = reset($epalUsers);
if (!$epalUser){
return $this->respondWithStatus([
"error_code" => 4003
], Response::HTTP_FORBIDDEN);
}
$student = array(
$student = array(
'langcode' => 'el',
'student_record_id' => 0,
'sex' => 0,
......@@ -104,30 +134,31 @@ class ApplicationSubmit extends ControllerBase
'points' => 0,
'user_id' => $epalUser->user_id->target_id,
'epaluser_id' => $epalUser->id(),
'name' => $applicationForm[0]['name'],
'studentsurname' => $applicationForm[0]['studentsurname'],
'birthdate' => $applicationForm[0]['studentbirthdate'],
'fatherfirstname' => $applicationForm[0]['fatherfirstname'],
'motherfirstname' => $applicationForm[0]['motherfirstname'],
'regionaddress' => $applicationForm[0]['regionaddress'],
'regionarea' => $applicationForm[0]['regionarea'],
'regiontk' => $applicationForm[0]['regiontk'],
'certificatetype' => $applicationForm[0]['certificatetype'],
'graduation_year' => $applicationForm[0]['graduation_year'],
'name' => $name_encoded,
'studentsurname' => $studentsurname_encoded,
'birthdate' => $applicationForm[0]['studentbirthdate'],
'fatherfirstname' => $fatherfirstname_encoded,
'motherfirstname' => $motherfirstname_encoded,
'regionaddress' => $regionaddress_encoded,
'regionarea' => $regionarea_encoded,
'regiontk' => $regiontk_encoded,
'certificatetype' => $certificatetype_encoded,
'graduation_year' => $applicationForm[0]['graduation_year'],
'lastschool_registrynumber' => $applicationForm[0]['lastschool_registrynumber'],
'lastschool_unittypeid' => $applicationForm[0]['lastschool_unittypeid'],
'lastschool_schoolname' => $applicationForm[0]['lastschool_schoolname'],
'lastschool_schoolyear' => $applicationForm[0]['lastschool_schoolyear'],
'lastschool_class' => $applicationForm[0]['lastschool_class'],
'currentclass' => $applicationForm[0]['currentclass'],
'guardian_name' => $applicationForm[0]['cu_name'],
'guardian_surname' => $applicationForm[0]['cu_surname'],
'guardian_fathername' => $applicationForm[0]['cu_fathername'],
'guardian_mothername' => $applicationForm[0]['cu_mothername'],
'currentclass' => $applicationForm[0]['currentclass'],
'guardian_name' => $guardian_name_encoded,
'guardian_surname' => $guardian_surname_encoded,
'guardian_fathername' => $guardian_fathername_encoded,
'guardian_mothername' => $guardian_mothername_encoded,
'agreement' => $applicationForm[0]['disclaimer_checked'],
'relationtostudent' => $applicationForm[0]['relationtostudent'],
'telnum' => $applicationForm[0]['telnum']
);
'relationtostudent' => $relationtostudent_encoded,
'telnum' => $telnum_encoded
);
if (($errorCode = $this->validateStudent($student)) > 0) {
return $this->respondWithStatus([
......@@ -140,7 +171,7 @@ class ApplicationSubmit extends ControllerBase
if ((int)date("Y") === $lastSchoolYear && (int)$student['lastschool_unittypeid'] === 5) {
$epalSchools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('registry_no' => $lastSchoolRegistryNumber));
$epalSchool = reset($epalSchools);
/* if (!$epalSchool){
/* if (!$epalSchool){
return $this->respondWithStatus([
"error_code" => 4004
], Response::HTTP_FORBIDDEN);
......
......@@ -11,19 +11,19 @@ use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Drupal\Core\Database\Database;
use Drupal\Core\Database\Connection;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Core\TypedData\Plugin\DataType\TimeStamp;
use Drupal\Core\Language\LanguageManagerInterface;
use FPDF;
use Drupal\epal\Crypt;
define("ERROR_DECODING", -1);
class PDFCreator extends ControllerBase {
......@@ -36,6 +36,7 @@ class PDFCreator extends ControllerBase {
protected $fontBold;
protected $fontSizeHeader;
protected $fontSizeRegular;
protected $crypt;
public function __construct(
EntityTypeManagerInterface $entityTypeManager,
......@@ -121,46 +122,30 @@ class PDFCreator extends ControllerBase {
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
$this->fontLight = "open-sans.light";
$this->fontBold = "open-sans.bold";
$this->fontSizeHeader = 14;
$this->fontSizeRegular = 11;
$this->initPdfHandler();
$this->createHeader($epalStudent);
$this->createGuardianInfo($epalStudent);
$this->createStudentInfo($epalStudent);
$this->createStudentChoices($epalStudent);
/*
// $pdf->SetFont('Arial','B',16);
$pdf->AddFont('Ubuntu', '', 'Ubuntu-Regular.php');
$pdf->SetFont('Ubuntu', '', 16);
$pdf->Cell(40, 10, $this->prepareString('Tούτη εδώ είναι η αίτηση σου'));
$pdf->Ln(10);
$pdf->Cell(40, 10, $this->prepareString('Χρονοσήμανση: ') . date('d/m/Y H:i:s'));
$pdf->Ln(10);
$pdf->SetFont('Ubuntu','',10);
for ($i=1; $i<=30; $i++) {
$pdf->Cell(0, 8 , $this->prepareString('Στοιχείο: ') . $i, 0, 1);
$pdf->Cell(0, 8 , 'Item: ' . $i, 0, 1);
}
*/
//$this->pdf->Close(); // Δεν χρειάζεται, το κάνει η Output
$s = $this->pdf->Output("S", "export.pdf", true);
$response = new Response($s, Response::HTTP_OK, ['Content-Type', 'application/pdf']);
return $response;
$this->fontLight = "open-sans.light";
$this->fontBold = "open-sans.bold";
$this->fontSizeHeader = 14;
$this->fontSizeRegular = 11;
$this->initPdfHandler();
$this->createHeader($epalStudent);
$ret = $this->createGuardianInfo($epalStudent);
if ($ret === ERROR_DECODING)
return $this->respondWithStatus([
"message" => t("An unexpected error occured during DECODING data in createGuardianInfo Method ")
], Response::HTTP_INTERNAL_SERVER_ERROR);
$ret = $this->createStudentInfo($epalStudent);
if ($ret === ERROR_DECODING)
return $this->respondWithStatus([
"message" => t("An unexpected error occured during DECODING data in createStudentInfo Method ")
], Response::HTTP_INTERNAL_SERVER_ERROR);
$this->createStudentChoices($epalStudent);
//$this->pdf->Close(); // Δεν χρειάζεται, το κάνει η Output
$s = $this->pdf->Output("S", "export.pdf", true);
$response = new Response($s, Response::HTTP_OK, ['Content-Type', 'application/pdf']);
return $response;
} //end try
catch (\Exception $e) {
$this->logger->warning($e->getMessage());
......@@ -182,6 +167,8 @@ class PDFCreator extends ControllerBase {
$this->pdf->AddFont($this->fontLight, '', 'open-sans.light.php');
$this->pdf->AddFont($this->fontBold, '', 'open-sans.bold.php');
$this->crypt = new Crypt();
}
private function createHeader($student) {
......@@ -199,6 +186,19 @@ class PDFCreator extends ControllerBase {
$width = 45;
$height = 8;
try {
$guardian_name_decoded = $this->crypt->decrypt($student->guardian_name->value);
$guardian_surname_decoded = $this->crypt->decrypt($student->guardian_surname->value);
$guardian_fathername_decoded = $this->crypt->decrypt($student->guardian_fathername->value);
$guardian_mothername_decoded = $this->crypt->decrypt($student->guardian_mothername->value);
$regionaddress_decoded = $this->crypt->decrypt($student->regionaddress->value);
$regiontk_decoded = $this->crypt->decrypt($student->regiontk->value);
$regionarea_decoded = $this->crypt->decrypt($student->regionarea->value);
}
catch (\Exception $e) {
$this->logger->warning($e->getMessage());
return ERROR_DECODING;
}
$this->pdf->SetFont($this->fontBold, '', $this->fontSizeHeader);
$this->pdf->SetFillColor(255,178,102);
......@@ -209,46 +209,64 @@ class PDFCreator extends ControllerBase {
$this->pdf->Cell($width, $height, $this->prepareString('Όνομα:'), 0, 'L');
$x=$this->pdf->GetX(); $y=$this->pdf->GetY();
$this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular);
$this->pdf->multiCell($width, $height, $this->prepareString($student->guardian_name->value), 0, 'L');
$this->pdf->multiCell($width, $height, $this->prepareString($guardian_name_decoded), 0, 'L');
$x_col1=$this->pdf->GetX();$y_col1=$this->pdf->GetY();
$this->pdf->SetFont($this->fontLight, '', $this->fontSizeRegular);
$this->pdf->SetXY($x+$width,$y);
$this->pdf->Cell($width, $height, $this->prepareString('Επώνυμο:'), 0, 'L');
//$x=$this->pdf->GetX(); $y=$this->pdf->GetY();
$this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular);
$this->pdf->multiCell($width, $height, $this->prepareString($student->guardian_surname->value), 0, 'L');
//$this->pdf->Ln();
$this->pdf->multiCell($width, $height, $this->prepareString($guardian_surname_decoded), 0, 'L');
$x_col2=$this->pdf->GetX();;$y_col2=$this->pdf->GetY();
$x = ($y_col1 > $y_col2) ? $x_col1 : $x_col2;
$y = ($y_col1 > $y_col2) ? $y_col1 : $y_col2;
$this->pdf->SetXY($x,$y);
$this->pdf->SetFont($this->fontLight, '', $this->fontSizeRegular);
$this->pdf->Cell($width, $height, $this->prepareString('Όνομα πατέρα:'), 0, 'L');
$x=$this->pdf->GetX(); $y=$this->pdf->GetY();
$this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular);
$this->pdf->multiCell($width, $height, $this->prepareString($student->guardian_fathername->value), 0, 'L');
//$this->pdf->multiCell($width, $height, $this->prepareString($student->guardian_fathername->value), 0, 'L');
$this->pdf->multiCell($width, $height, $this->prepareString($guardian_fathername_decoded), 0, 'L');
$x_col1=$this->pdf->GetX();$y_col1=$this->pdf->GetY();
$this->pdf->SetFont($this->fontLight, '', $this->fontSizeRegular);
$this->pdf->SetXY($x+$width,$y);
$this->pdf->Cell($width, $height, $this->prepareString('Όνομα μητέρας:'), 0, 'L');
$this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular);
$this->pdf->multiCell($width, $height, $this->prepareString($student->guardian_mothername->value), 0, 'L');
//$this->pdf->Ln();
//$this->pdf->multiCell($width, $height, $this->prepareString($student->guardian_mothername->value), 0, 'L');
$this->pdf->multiCell($width, $height, $this->prepareString($guardian_mothername_decoded), 0, 'L');
$x_col2=$this->pdf->GetX();;$y_col2=$this->pdf->GetY();
$x = ($y_col1 > $y_col2) ? $x_col1 : $x_col2;
$y = ($y_col1 > $y_col2) ? $y_col1 : $y_col2;
$this->pdf->SetXY($x,$y);
//$fullAddressTxt = $student->regionaddress->value . ', ΤΚ: ' . $student->regiontk->value . ', ' . $student->regionarea->value;
$this->pdf->SetFont($this->fontLight, '', $this->fontSizeRegular);
$regAddressTxt = 'ΤΚ: ' . $student->regiontk->value . ', ' . $student->regionarea->value;
//$regAddressTxt = 'ΤΚ: ' . $student->regiontk->value . ', ' . $student->regionarea->value;
$regAddressTxt = 'ΤΚ: ' . $regiontk_decoded . ', ' . $regionarea_decoded;
$this->pdf->Cell($width, $height, $this->prepareString('Διεύθυνση κατοικίας: '), 0, 'L');
$x=$this->pdf->GetX(); $y=$this->pdf->GetY();
$this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular);
$this->pdf->multiCell($width, $height, $this->prepareString($student->regionaddress->value), 0, 'L');
//$this->pdf->multiCell($width, $height, $this->prepareString($student->regionaddress->value), 0, 'L');
$this->pdf->multiCell($width, $height, $this->prepareString($regionaddress_decoded), 0, 'L');
$x_col1=$this->pdf->GetX();$y_col1=$this->pdf->GetY();
$this->pdf->SetFont($this->fontLight, '', $this->fontSizeRegular);
$this->pdf->SetXY($x+$width,$y);
$this->pdf->Cell($width, $height, $this->prepareString('ΤΚ - Πόλη: '), 0, 'L');
$this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular);
$this->pdf->multiCell($width, $height, $this->prepareString($regAddressTxt), 0, 'L');
$this->pdf->Ln();
$x_col2=$this->pdf->GetX();;$y_col2=$this->pdf->GetY();
$this->pdf->Ln();
$x = ($y_col1 > $y_col2) ? $x_col1 : $x_col2;
$y = ($y_col1 > $y_col2) ? $y_col1 : $y_col2;
$this->pdf->SetXY($x,$y);
$this->pdf->Ln();
//$this->pdf->Ln();
}
......@@ -258,6 +276,20 @@ class PDFCreator extends ControllerBase {
$height = 8;
$heightln = 4;
try {
$name_decoded = $this->crypt->decrypt($student->name->value);
$studentsurname_decoded = $this->crypt->decrypt($student->studentsurname->value);
$fatherfirstname_decoded = $this->crypt->decrypt($student->fatherfirstname->value);
$motherfirstname_decoded = $this->crypt->decrypt($student->motherfirstname->value);
$certificatetype_decoded = $this->crypt->decrypt($student->certificatetype->value);
$relationtostudent_decoded = $this->crypt->decrypt($student->relationtostudent->value);
$telnum_decoded = $this->crypt->decrypt($student->telnum->value);
}
catch (\Exception $e) {
$this->logger->warning($e->getMessage());
return ERROR_DECODING;
}
$this->pdf->SetFont($this->fontBold, '', $this->fontSizeHeader);
$this->pdf->SetFillColor(255,178,102);
$this->pdf->MultiCell(0, $height, $this->prepareString('Στοιχεία μαθητή'), 0, 'C',true);
......@@ -267,46 +299,71 @@ class PDFCreator extends ControllerBase {
$this->pdf->Cell($width, $height, $this->prepareString('Όνομα μαθητή:'), 0, 'L');
$x=$this->pdf->GetX(); $y=$this->pdf->GetY();
$this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular);
$this->pdf->multiCell($width, $height, $this->prepareString($student->name->value), 0, 'L');
$this->pdf->multiCell($width, $height, $this->prepareString($name_decoded), 0, 'L');
$x_col1=$this->pdf->GetX();$y_col1=$this->pdf->GetY();
$this->pdf->SetFont($this->fontLight, '', $this->fontSizeRegular);
$this->pdf->SetXY($x+$width,$y);
$this->pdf->Cell($width, $height, $this->prepareString('Επώνυμο μαθητή:'), 0, 'L');
$this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular);
$this->pdf->multiCell($width, $height, $this->prepareString($student->studentsurname->value), 0, 'L');
//$this->pdf->Ln();
//$this->pdf->multiCell($width, $height, $this->prepareString($student->studentsurname->value), 0, 'L');
$this->pdf->multiCell($width, $height, $this->prepareString($studentsurname_decoded), 0, 'L');
$x_col2=$this->pdf->GetX();;$y_col2=$this->pdf->GetY();
$x = ($y_col1 > $y_col2) ? $x_col1 : $x_col2;
$y = ($y_col1 > $y_col2) ? $y_col1 : $y_col2;
$this->pdf->SetXY($x,$y);
$this->pdf->SetFont($this->fontLight, '', $this->fontSizeRegular);
$this->pdf->Cell($width, $height, $this->prepareString('Όνομα πατέρα:'), 0, 'L');
$x=$this->pdf->GetX(); $y=$this->pdf->GetY();
$this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular);
$this->pdf->multiCell($width, $height, $this->prepareString($student->fatherfirstname->value), 0, 'L');
//$this->pdf->multiCell($width, $height, $this->prepareString($student->fatherfirstname->value), 0, 'L');
$this->pdf->multiCell($width, $height, $this->prepareString($fatherfirstname_decoded), 0, 'L');
$x_col1=$this->pdf->GetX();$y_col1=$this->pdf->GetY();
$this->pdf->SetFont($this->fontLight, '', $this->fontSizeRegular);
$this->pdf->SetXY($x+$width,$y);
$this->pdf->Cell($width, $height, $this->prepareString('Όνομα μητέρας:'), 0, 'L');
$this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular);
$this->pdf->multiCell($width, $height, $this->prepareString($student->motherfirstname->value), 0, 'L');
//$this->pdf->Ln();
//$this->pdf->multiCell($width, $height, $this->prepareString($student->motherfirstname->value), 0, 'L');
$this->pdf->multiCell($width, $height, $this->prepareString($motherfirstname_decoded), 0, 'L');
$x_col2=$this->pdf->GetX();;$y_col2=$this->pdf->GetY();
$x = ($y_col1 > $y_col2) ? $x_col1 : $x_col2;
$y = ($y_col1 > $y_col2) ? $y_col1 : $y_col2;
$this->pdf->SetXY($x,$y);
$this->pdf->SetFont($this->fontLight, '', $this->fontSizeRegular);
$this->pdf->Cell($width, $height, $this->prepareString('Ημ/νία γέννησης:'), 0, 'L');
$x=$this->pdf->GetX(); $y=$this->pdf->GetY();
$this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular);
$this->pdf->multiCell($width, $height, $this->prepareString($student->birthdate->value), 0, 'L');
//$temp = $student->birthdate->value;
//$temp2 = date_format(date($temp),'d-m-Y');
//$temp2 = date("d-m-Y", strtotime($temp));
$this->pdf->multiCell($width, $height, $this->prepareString(date("d-m-Y", strtotime($student->birthdate->value))), 0, 'L');
//$this->pdf->multiCell($width, $height, $this->prepareString( $student->birthdate->value), 0, 'L');
$x_col1=$this->pdf->GetX();$y_col1=$this->pdf->GetY();
$this->pdf->SetFont($this->fontLight, '', $this->fontSizeRegular);
$this->pdf->SetXY($x+$width,$y);
$this->pdf->Cell($width, $height, $this->prepareString('Τηλ. επικ/νίας:'), 0, 'L');
$this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular);
$this->pdf->multiCell($width, $height, $this->prepareString($student->telnum->value), 0, 'L');
//$this->pdf->multiCell($width, $height, $this->prepareString($student->telnum->value), 0, 'L');
$this->pdf->multiCell($width, $height, $this->prepareString($telnum_decoded), 0, 'L');
$x_col2=$this->pdf->GetX();;$y_col2=$this->pdf->GetY();
$x = ($y_col1 > $y_col2) ? $x_col1 : $x_col2;
$y = ($y_col1 > $y_col2) ? $y_col1 : $y_col2;
$this->pdf->SetXY($x,$y);
$this->pdf->Ln();
//$this->pdf->Ln();
$this->pdf->SetFont($this->fontLight, '', $this->fontSizeRegular);
$this->pdf->Cell($width+15, $height, $this->prepareString('Τύπος απολυτηρίου:'), 0, 'L');
$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($student->certificatetype->value), 0, 'L');
$this->pdf->Cell($width, $height, $this->prepareString($certificatetype_decoded), 0, 'L');
$this->pdf->Ln();
$this->pdf->SetFont($this->fontLight, '', $this->fontSizeRegular);
......@@ -336,7 +393,8 @@ class PDFCreator extends ControllerBase {
$this->pdf->SetFont($this->fontLight, '', $this->fontSizeRegular);
$this->pdf->Cell($width+15, $height, $this->prepareString('Αίτηση από:'), 0, 'L');
$this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular);
$this->pdf->Cell($width, $height, $this->prepareString($student->relationtostudent->value), 0, 'L');
//$this->pdf->Cell($width, $height, $this->prepareString($student->relationtostudent->value), 0, 'L');
$this->pdf->Cell($width, $height, $this->prepareString($relationtostudent_decoded), 0, 'L');
$this->pdf->Ln();
$this->pdf->Ln();
......
......@@ -24,10 +24,10 @@ use Drupal\Core\TypedData\Plugin\DataType\TimeStamp;
use Drupal\Core\Language\LanguageManagerInterface;
define("ERROR_DB", -1);
define("NO_CLASS_LIMIT_DOWN", -2);
define("SMALL_CLASS", 1);
define("NON_SMALL_CLASS", 2);
define("ERR_DB", -1);
define("NO_CLASS_LIM_DOWN", -2);
define("SMALL_CLS", 1);
define("NON_SMALL_CLS", 2);
class ReportsCreator extends ControllerBase {
......@@ -603,8 +603,8 @@ class ReportsCreator extends ControllerBase {
for ($j = 0; $j < sizeof($schoolNameColumn); $j++) {
//αν έγινε αίτημα για εμφάνιση ολιγομελών και είναι το τρέχον τμήμα ολιγομελές
if ( ($finalized === "1") || ($finalized === "0" && $smallClass[$j] === SMALL_CLASS
&& $schoolSectionColumn[$j] !== "Β τάξη" && $schoolSectionColumn[$j] !== "Γ τάξη" && $schoolSectionColumn[$j] !== "Δ τάξη" ) )
if ( ($finalized === "1") || ($finalized === "0" && $smallClass[$j] === SMALL_CLS
&& $schoolSectionColumn[$j] !== "Β τάξη" && $schoolSectionColumn[$j] !== "Γ τάξη" && $schoolSectionColumn[$j] !== "Δ τάξη" ) )
array_push($list,(object) array(
'name' => $schoolNameColumn[$j],
......@@ -644,16 +644,16 @@ class ReportsCreator extends ControllerBase {
$limitDown = $this->retrieveLimitDown($classId, $regionId);
if ($limitDown === NO_CLASS_LIMIT_DOWN)
return NO_CLASS_LIMIT_DOWN;
else if ($limitDown === ERROR_DB)
return ERROR_DB;
if ($limitDown === NO_CLASS_LIM_DOWN)
return NO_CLASS_LIM_DOWN;
else if ($limitDown === ERR_DB)
return ERR_DB;
$numStudents = (int) $numStud;
if ( ($numStudents < $limitDown) /*&& ($numStudents > 0)*/ )
return SMALL_CLASS;
return SMALL_CLS;
else
return NON_SMALL_CLASS;
return NON_SMALL_CLS;
}
......@@ -671,12 +671,12 @@ class ReportsCreator extends ControllerBase {
return $classLimit->limit_down;
}
else {
return NO_CLASS_LIMIT_DOWN;
return NO_CLASS_LIM_DOWN;
}
} //end try
catch (\Exception $e) {
$this->logger->warning($e->getMessage());
return ERROR_DB;
return ERR_DB;
}
} //end function
......
......@@ -9,19 +9,36 @@ use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\epal\Crypt;
class SubmitedApplications extends ControllerBase
{
protected $entityTypeManager;
protected $logger;
/*
public function __construct(EntityTypeManagerInterface $entityTypeManager)
{
$this->entityTypeManager = $entityTypeManager;
}
*/
public function __construct(
EntityTypeManagerInterface $entityTypeManager,
LoggerChannelFactoryInterface $loggerChannel)
{
$this->entityTypeManager = $entityTypeManager;
$this->logger = $loggerChannel->get('epal');
}
public static function create(ContainerInterface $container)
{
return new static(
$container->get('entity_type.manager')
$container->get('entity_type.manager'),
$container->get('logger.factory')
);
}
......@@ -38,17 +55,37 @@ class SubmitedApplications extends ControllerBase
$epalStudents = $this->entityTypeManager->getStorage('epal_student')->loadByProperties(array('epaluser_id' => $userid));
$i = 0;
if ($epalStudents) {
$list = array();
$crypt = new Crypt();
$list = array();
foreach ($epalStudents as $object) {
$indexid = intval($object -> id())-1;
try {
$name_decoded = $crypt->decrypt($object->name->value);
$studentsurname_decoded = $crypt->decrypt($object->studentsurname->value);
}
catch (\Exception $e) {
unset($crypt);
$this->logger->warning($e->getMessage());
return $this->respondWithStatus([
"message" => t("An unexpected error occured during DECODING data in getSubmittedApplications Method ")
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
$list[] = array(
'id' => $indexid,
'name' => $object -> name ->value,
'studentsurname' => $object -> studentsurname ->value);
//'name' => $object -> name ->value,
'name' => $name_decoded,
//'studentsurname' => $object -> studentsurname ->value);
'studentsurname' => $studentsurname_decoded );
$i++;
}
unset($crypt);
return $this->respondWithStatus(
$list
, Response::HTTP_OK);
......@@ -105,31 +142,74 @@ class SubmitedApplications extends ControllerBase
if ($course)
$courseName = $this->entityTypeManager->getStorage('eepal_specialty')->load($course->coursefield_id->target_id)->name->value;
}
$crypt = new Crypt();
try {
$name_decoded = $crypt->decrypt($object->name->value);
$studentsurname_decoded = $crypt->decrypt($object->studentsurname->value);
$fatherfirstname_decoded = $crypt->decrypt($object->fatherfirstname->value);
$motherfirstname_decoded = $crypt->decrypt($object->motherfirstname->value);
$regionaddress_decoded = $crypt->decrypt($object->regionaddress->value);
$regiontk_decoded = $crypt->decrypt($object->regiontk->value);
$regionarea_decoded = $crypt->decrypt($object->regionarea->value);
$certificatetype_decoded = $crypt->decrypt($object->certificatetype->value);
$relationtostudent_decoded = $crypt->decrypt($object->relationtostudent->value);
$telnum_decoded = $crypt->decrypt($object->telnum->value);
$guardian_name_decoded = $crypt->decrypt($object->guardian_name->value);
$guardian_surname_decoded = $crypt->decrypt($object->guardian_surname->value);
$guardian_fathername_decoded = $crypt->decrypt($object->guardian_fathername->value);
$guardian_mothername_decoded = $crypt->decrypt($object->guardian_mothername->value);
}
catch (\Exception $e) {
//print_r($e->getMessage());
unset($crypt);
$this->logger->warning($e->getMessage());
return $this->respondWithStatus([
"message" => t("An unexpected error occured during DECODING data in getStudentApplications Method ")
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
unset($crypt);
$list[] = array(
'applicationId' => $object->id(),
'name' => $object -> name ->value,
'studentsurname' => $object -> studentsurname ->value,
'fatherfirstname' => $object -> fatherfirstname ->value,
//'name' => $object -> name ->value,
'name' => $name_decoded,
//'studentsurname' => $object -> studentsurname ->value,
'studentsurname' => $studentsurname_decoded,
//'fatherfirstname' => $object -> fatherfirstname ->value,
'fatherfirstname' => $fatherfirstname_decoded,
'fathersurname' =>$object -> fathersurname ->value,
'motherfirstname' => $object -> motherfirstname ->value,
//'motherfirstname' => $object -> motherfirstname ->value,
'motherfirstname' => $motherfirstname_decoded,
'mothersurname' =>$object -> mothersurname ->value,
'guardian_name' =>$object -> guardian_name ->value,
'guardian_surname' =>$object -> guardian_surname ->value,
'guardian_fathername' =>$object -> guardian_fathername ->value,
'guardian_mothername' =>$object -> guardian_mothername ->value,
//'guardian_name' =>$object -> guardian_name ->value,