diff --git a/README.md b/README.md index 6da6adeb8dcca62bab4ffa6f83b4c8ad96e8ab6f..f4493cb48053bab2df2ff79a8ae67fbb3a534a74 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# Ηλεκτρονική υπηρεσία για εγγραφές και μετεγγραφές μαθητών στην Επαγγελματική Εκπαίδευση # +# Ηλεκτρονική υπηρεσία δηλώσεων προτίμησης ΕΠΑΛ για το νέο σχολικό έτος # # Περιγραφή # - Η Ηλεκτρονική Υπηρεσία για τις εγγραφές και μετεγγραφές μαθητών στα Επαγγελματικά Λύκεια (ΕΠΑΛ) που θα αναπτυχθεί έχει ως κύριο σκοπό να παρέχει τη δυνατότητα ηλεκτρονικής δήλωσης προτίμησης των μαθητών για φοίτηση σε κάποιο από τα ΕΠΑΛ της χώρας μας, καθώς και την κατανομή τους σε αυτά με βάση συγκεκριμένα κριτήρια και λαμβάνοντας υπόψη τις προτιμήσεις τους. Η δημιουργία της υπηρεσίας θα υλοποιηθεί από την ομάδα Ανοικτού Λογισμικού του Υπουργείου Παιδείας, η οποία είναι αρμόδια για τον Σχεδιασμό, Ανάπτυξη και Συντήρηση Εφαρμογών Ανοικτού Λογισμικού του ΥΠΠΕΘ και υπάγεται στη Γενική Διεύθυνση Στρατηγικού Σχεδιασμού, Προγραμματισμού και Ηλεκτρονικής Διακυβέρνησης. + Η Ηλεκτρονική Υπηρεσία δηλώσεων προτίμησης Επαγγελματικών Λυκείων (ΕΠΑΛ) για το νέο σχολικό έτος που αναπτύσσεται έχει ως κύριο σκοπό να παρέχει τη δυνατότητα ηλεκτρονικής δήλωσης προτίμησης των μαθητών για φοίτηση σε κάποιο από τα ΕΠΑΛ της χώρας μας, καθώς και την κατανομή τους σε αυτά με βάση συγκεκριμένα κριτήρια και λαμβάνοντας υπόψη τις προτιμήσεις τους. Η δημιουργία της υπηρεσίας θα υλοποιηθεί από την ομάδα Ανοικτού Λογισμικού του Υπουργείου Παιδείας, η οποία είναι αρμόδια για τον Σχεδιασμό, Ανάπτυξη και Συντήρηση Εφαρμογών Ανοικτού Λογισμικού του ΥΠΠΕΘ και υπάγεται στη Γενική Διεύθυνση Στρατηγικού Σχεδιασμού, Προγραμματισμού και Ηλεκτρονικής Διακυβέρνησης. -Οι διαδικασίες υλοποίησης του έργου θα ακολουθήσουν τη μεθοδολογία ευέλικτης ανάπτυξης λογισμικού Agile σε πρότυπα Scrum, που υπόσχεται ανταπόκριση στις αλλαγές, παραγωγικότερες πρακτικές και λιγότερη γραφειοκρατία. Η ανταπόκριση στις αλλαγές αναφέρεται κυρίως στην συνολική ικανότητα της διαδικασίας ανάπτυξης να προσαρμόζεται ανάλογα όταν προκύπτουν αλλαγές στην πορεία του έργου, καθώς και στην ανάγκη για συνεργασία μεταξύ όλων των συμμετεχόντων. Η μέθοδος αυτή είναι μια επαναληπτική και αυξητική προσέγγιση για την ανάπτυξη έργων που επιτρέπει την προσαρμογή στις αλλαγές που προκύπτουν. +Οι διαδικασίες υλοποίησης του έργου θα ακολουθήσουν τη μεθοδολογία ευέλικτης ανάπτυξης λογισμικού Agile σε πρότυπα Scrum, που υπόσχεται ανταπόκριση στις αλλαγές, παραγωγικότερες πρακτικές και λιγότερη γραφειοκρατία. Η ανταπόκριση στις αλλαγές αναφέρεται κυρίως στην συνολική ικανότητα της διαδικασίας ανάπτυξης να προσαρμόζεται ανάλογα όταν προκύπτουν αλλαγές στην πορεία του έργου, καθώς και στην ανάγκη για συνεργασία μεταξύ όλων των συμμετεχόντων. Η μέθοδος αυτή είναι μια επαναληπτική και αυξητική προσέγγιση για την ανάπτυξη έργων που επιτρέπει την προσαρμογή στις αλλαγές που προκύπτουν. -Στην διαδικασία αυτή παρουσιάζονται οι εξής τρείς βασικοί ρόλοι: ο ιδιοκτήτης του προϊόντος (The Product Owner) είναι η Διεύθυνση Επαγγελματικής Εκπαίδευσης και υπεύθυνος ο Δ/ντης κ. Μουστάκας Γ. όπου κατέχει καθοριστικό ρόλο στην ανάπτυξη του συστήματος, εντοπίζοντας τα χαρακτηριστικά της υπηρεσίας και μεταφράζοντας τα σε μια λίστα απαιτήσεων, η ομάδα (team) που χτίζει το προιόν (μέλη της ομάδας του Ανοικτού Λογισμικού) και τέλος η ομάδα εποπτείας (Advisor Board) που αποτελείται από έμπειρα άτομα του χώρου της επαγγελματικής εκπαίδευσης με βασικό σκοπό την σύνταξη απαιτήσεων και την ιεράρχηση τους (Product Backlog). +Στην διαδικασία αυτή παρουσιάζονται οι εξής τρείς βασικοί ρόλοι: ο ιδιοκτήτης του προϊόντος (The Product Owner) είναι η Διεύθυνση Επαγγελματικής Εκπαίδευσης και υπεύθυνος ο Δ/ντης κ. Μουστάκας Γ. όπου κατέχει καθοριστικό ρόλο στην ανάπτυξη του συστήματος, εντοπίζοντας τα χαρακτηριστικά της υπηρεσίας και μεταφράζοντας τα σε μια λίστα απαιτήσεων, η ομάδα (team) που χτίζει το προιόν (μέλη της ομάδας του Ανοικτού Λογισμικού) και τέλος η ομάδα εποπτείας (Advisor Board) που αποτελείται από έμπειρα άτομα του χώρου της επαγγελματικής εκπαίδευσης με βασικό σκοπό την σύνταξη απαιτήσεων και την ιεράρχηση τους (Product Backlog). # Περιβάλλον Ανάπτυξης# @@ -14,7 +14,7 @@ Μπορείτε να δείτε τις προδιαγραφές του έργου σύμφωνα με τα πρότυπα της μεθοδολογίας Agile / Scrum στο https://git.minedu.gov.gr/itminedu/e-epal/wikis/scrum -Η αναλυτική τεκμηρίωση των λειτουργικών απαιτήσεων συντηρείται στο https://git.minedu.gov.gr/itminedu/e-epal/wikis/analysis +Η αναλυτική τεκμηρίωση των λειτουργικών απαιτήσεων συντηρείται στο https://git.minedu.gov.gr/itminedu/e-epal/wikis/analysis # Παρατηρήσεις - Σχόλια # @@ -22,4 +22,4 @@ # License -Code licence: [EUPL v1.1](http://ec.europa.eu/idabc/eupl.html) Content licence: [CC-BY-SA 4.0.](https://creativecommons.ellak.gr/2015/08/21/%CE%B5%CE%BD%CE%B1%CF%82-%CE%B1%CF%80%CE%BB%CF%8C%CF%82-%CE%BF%CE%B4%CE%B7%CE%B3%CF%8C%CF%82-%CE%B3%CE%B9%CE%B1-%CF%84%CE%B9%CF%82-%CE%AC%CE%B4%CE%B5%CE%B9%CE%B5%CF%82-creative-commons-4-0/) \ No newline at end of file +Code licence: [EUPL v1.1](http://ec.europa.eu/idabc/eupl.html) Content licence: [CC-BY-SA 4.0.](https://creativecommons.ellak.gr/2015/08/21/%CE%B5%CE%BD%CE%B1%CF%82-%CE%B1%CF%80%CE%BB%CF%8C%CF%82-%CE%BF%CE%B4%CE%B7%CE%B3%CF%8C%CF%82-%CE%B3%CE%B9%CE%B1-%CF%84%CE%B9%CF%82-%CE%AC%CE%B4%CE%B5%CE%B9%CE%B5%CF%82-creative-commons-4-0/) diff --git a/drupal/modules/epal/epal.module b/drupal/modules/epal/epal.module index 4d30cae327caee577c8615433adbdf2ce7ba2bf4..2d9c82305fcaf132376b2545b8a55f6e034a456c 100755 --- a/drupal/modules/epal/epal.module +++ b/drupal/modules/epal/epal.module @@ -43,17 +43,17 @@ function epal_mail($key, &$message, $params) { switch ($key) { case 'send_verification_code': $message['from'] = \Drupal::config('system.site')->get('mail'); - $message['subject'] = t('Σύστημα υποβολής αιτήσεων εγγραφής σε ΕΠΑΛ: Επιβεβαίωση e-mail', $options); + $message['subject'] = t('Σύστημα υποβολής ηλεκτρονικών δηλώσεων προτίμησης ΕΠΑΛ για το νέο σχολικό έτος: Επιβεβαίωση e-mail', $options); $message['body'][] = $params['message']; break; case 'massive_mail_unallocated': $message['from'] = \Drupal::config('system.site')->get('mail'); - $message['subject'] = t('Μη ικανοποίηση ηλεκτρονικής αίτησης για εγγραφή σε ΕΠΑΛ', $options); + $message['subject'] = t('Μη ικανοποίηση ηλεκτρονικής δήλωσης προτίμησης ΕΠΑΛ', $options); $message['body'][] = $params['message']; break; case 'massive_mail_located': $message['from'] = \Drupal::config('system.site')->get('mail'); - $message['subject'] = t('Ικανοποίηση ηλεκτρονικής αίτησης για εγγραφή σε ΕΠΑΛ', $options); + $message['subject'] = t('Ικανοποίηση ηλεκτρονικής δήλωσης προτίμησης ΕΠΑΛ', $options); $message['body'][] = $params['message']; break; } diff --git a/drupal/modules/epal/src/Client.php b/drupal/modules/epal/src/Client.php index 0b2cbf704605ea91c180803985f5d5eceeac1bb1..31b7a608fbc8d494d3d4d57b6dc27ca04fd1c022 100644 --- a/drupal/modules/epal/src/Client.php +++ b/drupal/modules/epal/src/Client.php @@ -5,6 +5,8 @@ namespace Drupal\epal; use Symfony\Component\HttpFoundation\Response; use Exception; +use Drupal\epal\Crypt; + /** * Description of Client * @@ -171,30 +173,32 @@ class Client }, ''); $result = $this->get($endpoint, [], $headers); // data as path params... + try { + $crypt = new Crypt(); + $val = 'call:' . print_r($endpoint, true) . ':rcv:' . print_r($result, true); + $val_enc = $crypt->encrypt($val); + $this->log(__METHOD__ . $val_enc, 'info'); + } catch (\Exception $e) { + $this->log(__METHOD__ . " cannot log encrypted", 'info'); + } + if ($result['success'] === false) { $this->log(__METHOD__ . " Error while calling ws. Diagnostic: {$result['response']}. Response code: {$result['http_status']}", "error"); throw new Exception("Προέκυψε λάθος κατά την άντληση των στοιχείων."); } - // now return true/false/null ? return $result['response']; - - // if (($response = json_decode($result['response'], true)) !== null) { - // return $response; - // } else { - // throw new Exception("Προέκυψε λάθος κατά την λήψη των στοιχείων. Αδυναμία άντλησης στοιχείων από το response {$result['response']}"); - // } } public function getStudentEpalPromotion($didactic_year_id, $lastname, $firstname, $father_firstname, $mother_firstname, $birthdate, $registry_no, $level_name) { - $this->log(__METHOD__); // " $didactic_year_id, $lastname, $firstname, $father_firstname, $mother_firstname, $birthdate, $registry_no, $level_name"); + $this->log(__METHOD__); return $this->getStudentEpalPromotionOrCertification($this->_settings['ws_endpoint_studentepalpromotion'], $didactic_year_id, $lastname, $firstname, $father_firstname, $mother_firstname, $birthdate, $registry_no, $level_name); } public function getStudentEpalCertification($didactic_year_id, $lastname, $firstname, $father_firstname, $mother_firstname, $birthdate, $registry_no, $level_name) { - $this->log(__METHOD__); // " $didactic_year_id, $lastname, $firstname, $father_firstname, $mother_firstname, $birthdate, $registry_no, $level_name"); + $this->log(__METHOD__); return $this->getStudentEpalPromotionOrCertification($this->_settings['ws_endpoint_studentepalcertification'], $didactic_year_id, $lastname, $firstname, $father_firstname, $mother_firstname, $birthdate, $registry_no, $level_name); } @@ -228,6 +232,14 @@ class Client $result = curl_exec($ch); + // log url as appropriate + try { + $crypt = new Crypt(); + $uri = $crypt->encrypt($uri); + } catch (\Exception $e) { + $uri = '-cannot encrypt-'; + } + if (curl_errno($ch)) { $this->log(__METHOD__ . " Error calling {$uri}. Curl error: " . curl_error($ch) . " Curl info: " . var_export(curl_getinfo($ch), true), "error"); throw new Exception("Λάθος κατά την κλήση της υπηρεσίας."); @@ -263,6 +275,14 @@ class Client $result = curl_exec($ch); + // log url as appropriate + try { + $crypt = new Crypt(); + $uri = $crypt->encrypt($uri); + } catch (\Exception $e) { + $uri = '-cannot encrypt-'; + } + if (curl_errno($ch)) { $this->log(__METHOD__ . " Error calling {$uri}. Curl error: " . curl_error($ch) . " Curl info: " . var_export(curl_getinfo($ch), true), "error"); throw new Exception("Λάθος κατά την κλήση της υπηρεσίας."); diff --git a/drupal/modules/epal/src/Controller/ApplicationSubmit.php b/drupal/modules/epal/src/Controller/ApplicationSubmit.php index 49e7e28da29b46b6b96a1ec645febd4ab30a7b1f..77c872cc8d3e41b6c01e1c28ffefa9152f5d5cde 100755 --- a/drupal/modules/epal/src/Controller/ApplicationSubmit.php +++ b/drupal/modules/epal/src/Controller/ApplicationSubmit.php @@ -79,6 +79,19 @@ class ApplicationSubmit extends ControllerBase ], Response::HTTP_BAD_REQUEST); } + $epalConfigs = $this->entityTypeManager->getStorage('epal_config')->loadByProperties(array('name' => 'epal_config')); + $epalConfig = reset($epalConfigs); + if (!$epalConfig) { + return $this->respondWithStatus([ + "error_code" => 3001 + ], Response::HTTP_FORBIDDEN); + } + if ($epalConfig->lock_application->value) { + return $this->respondWithStatus([ + "error_code" => 3002 + ], Response::HTTP_FORBIDDEN); + } + $crypt = new Crypt(); try { $name_encoded = $crypt->encrypt($applicationForm[0]['name']); @@ -266,14 +279,14 @@ class ApplicationSubmit extends ControllerBase (checkdate($date_parts[1], $date_parts[2], $date_parts[0]) !== true)) { return 1003; } -/* $birthdate = "{$date_parts[2]}-{$date_parts[1]}-{$date_parts[0]}"; + $birthdate = "{$date_parts[2]}-{$date_parts[1]}-{$date_parts[0]}"; // check as per specs: // - can't check certification prior to 2014, pass through // - check certification if last passed class is gym // - check promotion if last passed class is not gym - $check_certification = true; +/* $check_certification = true; $check_promotion = true; if (intval($student['lastschool_unittypeid']) == self::UNIT_TYPE_GYM) { $check_promotion = false; @@ -307,12 +320,12 @@ class ApplicationSubmit extends ControllerBase $student['lastschool_registrynumber'], $level_name ); - $pass = ($service_rv === true); - if ($service_rv === true) { + $pass = ($service_rv == 'true'); + if ($service_rv == 'true') { $error_code = 0; - } elseif ($service_rv === false) { + } elseif ($service_rv == 'false') { $error_code = 8002; - } elseif ($service_rv === null) { + } elseif ($service_rv == 'null') { $error_code = 8003; } else { // -1 is an exception and data is already validated @@ -322,25 +335,8 @@ class ApplicationSubmit extends ControllerBase $pass = false; $error_code = 8000; } - } - - // TODO REMOVE - $this->logger->info( - 'check certification: [' . var_export($check_certification, true) . '] ' . - 'check promotion: [' . var_export($check_promotion, true) . '] ' . - 'pass: [' . var_export($pass, true) . '] ' . - 'check: ' . print_r([ - $didactic_year_id, - $student['studentsurname'], - $student['name'], - $student['fatherfirstname'], - $student['motherfirstname'], - $birthdate, - $student['lastschool_registrynumber'], - $level_name - ], true)); - // return 1000; // TODO stop here until all checks are finished + } */ - return $error_code; */ + return $error_code; } } diff --git a/drupal/modules/epal/src/Controller/DirectorView.php b/drupal/modules/epal/src/Controller/DirectorView.php index d294661c8c5d720f7fa378ba185a79482272d8e7..4cb85c7977099b5a102679fa7dc21f0466874988 100755 --- a/drupal/modules/epal/src/Controller/DirectorView.php +++ b/drupal/modules/epal/src/Controller/DirectorView.php @@ -18,9 +18,11 @@ class DirectorView extends ControllerBase protected $logger; // protected $testSchoolId='0640050'; - public function __construct(EntityTypeManagerInterface $entityTypeManager, - LoggerChannelFactoryInterface $loggerChannel) - { + public function __construct( + EntityTypeManagerInterface $entityTypeManager, + LoggerChannelFactoryInterface $loggerChannel + ) { + $this->entityTypeManager = $entityTypeManager; $this->logger = $loggerChannel->get('epal-school'); } @@ -160,170 +162,201 @@ class DirectorView extends ControllerBase public function getStudentPerSchool(Request $request, $selectId, $classId, $limitdown, $limitup) { try { - $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'); + $authToken = $request->headers->get('PHP_AUTH_USER'); - return $response; - } - - $userRoles = $user->getRoles(); - $userRole = ''; - foreach ($userRoles as $tmpRole) { - if ($tmpRole === 'epal') { - $userRole = $tmpRole; - } + $epalConfigs = $this->entityTypeManager->getStorage('epal_config')->loadByProperties(array('name' => 'epal_config')); + $epalConfig = reset($epalConfigs); + if (!$epalConfig) { + return $this->respondWithStatus([ + "error_code" => 3001 + ], Response::HTTP_FORBIDDEN); } - if ($userRole === '') { + if ($epalConfig->lock_students->value) { return $this->respondWithStatus([ - 'error_code' => 4003, - ], Response::HTTP_FORBIDDEN); - - } elseif ($userRole === 'epal') { - $selectIdNew = $selectId; - if ($classId == 1) { - $selectIdNew = -1; - $studentPerSchool = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('epal_id' => $epalId, 'specialization_id' => $selectIdNew, 'currentclass' => $classId)); - } else { - $studentPerSchool = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('epal_id' => $epalId, 'specialization_id' => $selectIdNew, 'currentclass' => $classId)); + "error_code" => 3002 + ], Response::HTTP_FORBIDDEN); + } + $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()); + return $this->respondWithStatus([ + "message" => "No access to this school" + ], Response::HTTP_FORBIDDEN); } - $i = 0; - if ($studentPerSchool) { - $list = array(); - $i = 0; - if ($limitdown == $limitup && $limitup == 0) { - $list = array( - 'id' => sizeof($studentPerSchool), - 'up' => $limitup, - 'down' => $limitdown, - ); - } else { - foreach ($studentPerSchool as $object) { - $studentId = $object->id(); - $epalStudents = $this->entityTypeManager->getStorage('epal_student')->loadByProperties(array('id' => $studentId)); - $epalStudent = reset($epalStudents); - - if ($epalStudents) { - - - $studentIdNew = $epalStudent->id(); - $checkstatus = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('student_id' => $studentIdNew)); - $checkstudentstatus = reset($checkstatus); - if ($i >= $limitdown && $i < $limitup) { - $sectorName = ''; - $courseName = ''; - if ($epalStudent->currentclass->value === '2') { - $sectors = $this->entityTypeManager->getStorage('epal_student_sector_field')->loadByProperties(array('student_id' => $studentIdNew)); - $sector = reset($sectors); - if ($sector) - $sectorName = $this->entityTypeManager->getStorage('eepal_sectors')->load($sector->sectorfield_id->target_id)->name->value; - } - else if ($epalStudent->currentclass->value === '3' || $epalStudent->currentclass->value === '4') { - $courses = $this->entityTypeManager->getStorage('epal_student_course_field')->loadByProperties(array('student_id' => $studentIdNew)); - $course = reset($courses); - if ($course) - $courseName = $this->entityTypeManager->getStorage('eepal_specialty')->load($course->coursefield_id->target_id)->name->value; - } - $newstatus = $checkstudentstatus->directorconfirm->value; - - $crypt = new Crypt(); - try { - $name_decoded = $crypt->decrypt($epalStudent->name->value); - $studentsurname_decoded = $crypt->decrypt($epalStudent->studentsurname->value); - $fatherfirstname_decoded = $crypt->decrypt($epalStudent->fatherfirstname->value); - $motherfirstname_decoded = $crypt->decrypt($epalStudent->motherfirstname->value); - $regionaddress_decoded = $crypt->decrypt($epalStudent->regionaddress->value); - $regiontk_decoded = $crypt->decrypt($epalStudent->regiontk->value); - $regionarea_decoded = $crypt->decrypt($epalStudent->regionarea->value); - $certificatetype_decoded = $crypt->decrypt($epalStudent->certificatetype->value); - $relationtostudent_decoded = $crypt->decrypt($epalStudent->relationtostudent->value); - $telnum_decoded = $crypt->decrypt($epalStudent->telnum->value); - $guardian_name_decoded = $crypt->decrypt($epalStudent->guardian_name->value); - $guardian_surname_decoded = $crypt->decrypt($epalStudent->guardian_surname->value); - $guardian_fathername_decoded = $crypt->decrypt($epalStudent->guardian_fathername->value); - $guardian_mothername_decoded = $crypt->decrypt($epalStudent->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 getStudentPerSchool Method ") - ], Response::HTTP_INTERNAL_SERVER_ERROR); + $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') { + if ($classId == 1) { + $selectId = -1; + } + $studentPerSchool = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('epal_id' => $epalId, 'specialization_id' => $selectId, 'currentclass' => $classId)); + + if ($studentPerSchool) { + $list = array(); + if ($limitdown == $limitup && $limitup == 0) { + $list = array( + 'id' => sizeof($studentPerSchool), + 'up' => $limitup, + 'down' => $limitdown, + ); + } else { + $i = 0; + foreach ($studentPerSchool as $object) { + $studentId = $object->id(); + $epalStudents = $this->entityTypeManager->getStorage('epal_student')->loadByProperties(array('id' => $studentId)); + $epalStudent = reset($epalStudents); + + if ($epalStudent) { + $studentIdNew = $epalStudent->id(); + $checkstatus = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('student_id' => $studentIdNew)); + $checkstudentstatus = reset($checkstatus); + if ($i >= $limitdown && $i < $limitup) { + $sectorName = ''; + $courseName = ''; + if ($epalStudent->currentclass->value === '2') { + $sectors = $this->entityTypeManager->getStorage('epal_student_sector_field')->loadByProperties(array('student_id' => $studentIdNew)); + $sector = reset($sectors); + if ($sector) { + $sectorName = $this->entityTypeManager->getStorage('eepal_sectors')->load($sector->sectorfield_id->target_id)->name->value; + } + } elseif ($epalStudent->currentclass->value === '3' || $epalStudent->currentclass->value === '4') { + $courses = $this->entityTypeManager->getStorage('epal_student_course_field')->loadByProperties(array('student_id' => $studentIdNew)); + $course = reset($courses); + if ($course) { + $courseName = $this->entityTypeManager->getStorage('eepal_specialty')->load($course->coursefield_id->target_id)->name->value; + } + } + $newstatus = $checkstudentstatus->directorconfirm->value; + + $crypt = new Crypt(); + try { + $name_decoded = $crypt->decrypt($epalStudent->name->value); + $studentsurname_decoded = $crypt->decrypt($epalStudent->studentsurname->value); + $fatherfirstname_decoded = $crypt->decrypt($epalStudent->fatherfirstname->value); + $motherfirstname_decoded = $crypt->decrypt($epalStudent->motherfirstname->value); + $regionaddress_decoded = $crypt->decrypt($epalStudent->regionaddress->value); + $regiontk_decoded = $crypt->decrypt($epalStudent->regiontk->value); + $regionarea_decoded = $crypt->decrypt($epalStudent->regionarea->value); + $certificatetype_decoded = $crypt->decrypt($epalStudent->certificatetype->value); + $relationtostudent_decoded = $crypt->decrypt($epalStudent->relationtostudent->value); + $telnum_decoded = $crypt->decrypt($epalStudent->telnum->value); + $guardian_name_decoded = $crypt->decrypt($epalStudent->guardian_name->value); + $guardian_surname_decoded = $crypt->decrypt($epalStudent->guardian_surname->value); + $guardian_fathername_decoded = $crypt->decrypt($epalStudent->guardian_fathername->value); + $guardian_mothername_decoded = $crypt->decrypt($epalStudent->guardian_mothername->value); + // $name_decoded = $epalStudent->name->value; + // $studentsurname_decoded = $epalStudent->studentsurname->value; + // $fatherfirstname_decoded = $epalStudent->fatherfirstname->value; + // $motherfirstname_decoded = $epalStudent->motherfirstname->value; + // $regionaddress_decoded = $epalStudent->regionaddress->value; + // $regiontk_decoded = $epalStudent->regiontk->value; + // $regionarea_decoded = $epalStudent->regionarea->value; + // $certificatetype_decoded = $epalStudent->certificatetype->value; + // $relationtostudent_decoded = $epalStudent->relationtostudent->value; + // $telnum_decoded = $epalStudent->telnum->value; + // $guardian_name_decoded = $epalStudent->guardian_name->value; + // $guardian_surname_decoded = $epalStudent->guardian_surname->value; + // $guardian_fathername_decoded = $epalStudent->guardian_fathername->value; + // $guardian_mothername_decoded = $epalStudent->guardian_mothername->value; + } catch (\Exception $e) { + $this->logger->warning(__METHOD__ . ' Decrypt error: ' . $e->getMessage()); + return $this->respondWithStatus([ + "message" => t("An unexpected error occured during DECODING data in getStudentPerSchool Method ") + ], Response::HTTP_INTERNAL_SERVER_ERROR); + } + + $list[] = array( + 'i' => $i, + 'id' => $epalStudent->id(), + 'name' => $name_decoded, + 'studentsurname' => $studentsurname_decoded, + 'fatherfirstname' => $fatherfirstname_decoded, + 'fathersurname' => $epalStudent->fathersurname->value, + 'motherfirstname' => $motherfirstname_decoded, + 'mothersurname' => $epalStudent->mothersurname->value, + 'guardian_name' => $guardian_name_decoded, + 'guardian_surname' => $guardian_surname_decoded, + 'guardian_fathername' => $guardian_fathername_decoded, + 'guardian_mothername' => $guardian_mothername_decoded, + 'lastschool_schoolname' => $epalStudent->lastschool_schoolname->value, + 'lastschool_schoolyear' => $epalStudent->lastschool_schoolyear->value, + 'lastschool_class' => $epalStudent->currentclass->value, + 'currentclass' => $epalStudent->currentclass->value, + 'currentsector' => $sectorName, + 'currentcourse' => $courseName, + 'regionaddress' => $regionaddress_decoded, + 'regiontk' => $regiontk_decoded, + 'regionarea' => $regionarea_decoded, + 'certificatetype' => $certificatetype_decoded, + 'graduation_year' => $epalStudent->graduation_year->value, + 'telnum' => $telnum_decoded, + 'relationtostudent' => $relationtostudent_decoded, + //'birthdate' => substr($epalStudent->birthdate->value, 8, 10) . '/' . substr($epalStudent->birthdate->value, 6, 8) . '/' . substr($epalStudent->birthdate->value, 0, 4), + 'birthdate' => date("d-m-Y", strtotime($epalStudent->birthdate->value)), + 'checkstatus' => $newstatus[0][value], + 'created' => date('d/m/Y H:i', $epalStudent->created->value) + ); } - unset($crypt); - - $list[] = array( - 'i' => $i, - 'id' => $epalStudent->id(), - 'name' => $name_decoded, - 'studentsurname' => $studentsurname_decoded, - 'fatherfirstname' => $fatherfirstname_decoded, - 'fathersurname' => $epalStudent->fathersurname->value, - 'motherfirstname' => $motherfirstname_decoded, - 'mothersurname' => $epalStudent->mothersurname->value, - 'guardian_name' =>$guardian_name_decoded, - 'guardian_surname' => $guardian_surname_decoded, - 'guardian_fathername' =>$guardian_fathername_decoded, - 'guardian_mothername' =>$guardian_mothername_decoded, - 'lastschool_schoolname' => $epalStudent->lastschool_schoolname->value, - 'lastschool_schoolyear' => $epalStudent->lastschool_schoolyear->value, - 'lastschool_class' => $epalStudent->currentclass->value, - 'currentclass' =>$epalStudent -> currentclass ->value, - 'currentsector' =>$sectorName, - 'currentcourse' =>$courseName, - 'regionaddress' =>$regionaddress_decoded, - 'regiontk' =>$regiontk_decoded, - 'regionarea' =>$regionarea_decoded, - 'certificatetype' => $certificatetype_decoded, - 'graduation_year' => $epalStudent->graduation_year->value, - 'telnum' =>$telnum_decoded, - 'relationtostudent' => $relationtostudent_decoded, - //'birthdate' => substr($epalStudent->birthdate->value, 8, 10) . '/' . substr($epalStudent->birthdate->value, 6, 8) . '/' . substr($epalStudent->birthdate->value, 0, 4), - 'birthdate' => date("d-m-Y", strtotime($epalStudent->birthdate->value)), - 'checkstatus' => $newstatus[0][value], - 'created' => date('d/m/Y H:i', $epalStudent -> created ->value), - - ); - + ++$i; } - ++$i; } } + + return $this->respondWithStatus( + $list, Response::HTTP_OK); + } else { + if ($limitdown == $limitup && $limitup == 0) { + $list = [ + 'id' => sizeof($studentPerSchool), + 'up' => $limitup, + 'down' => $limitdown, + ]; + } else { + $list = []; + } + + return $this->respondWithStatus($list, Response::HTTP_OK); + } + } else { + if ($limitdown == $limitup && $limitup == 0) { + $list = [ + 'id' => sizeof($studentPerSchool), + 'up' => $limitup, + 'down' => $limitdown, + ]; + } else { + $list = []; } - return $this->respondWithStatus( - $list, Response::HTTP_OK); + return $this->respondWithStatus($list, Response::HTTP_OK); } } else { - $list = array(); - - return $this->respondWithStatus($list, Response::HTTP_OK); - } - } else { - return $this->respondWithStatus([ + return $this->respondWithStatus([ 'message' => t('User not found!'), ], Response::HTTP_FORBIDDEN); - } - } catch (\Exception $e) { - $this->logger->warning($e->getMessage()); - return $this->respondWithStatus([ + } + } catch (\Exception $e) { + $this->logger->warning($e->getMessage()); + return $this->respondWithStatus([ 'message' => t('Unexpected Error'), ], Response::HTTP_FORBIDDEN); - } + } } public function ConfirmStudents(Request $request) @@ -377,7 +410,7 @@ class DirectorView extends ControllerBase return $this->respondWithStatus([ 'message' => t('saved'), - ], Response::HTTP_OK); + ], Response::HTTP_OK); } } else { return $this->respondWithStatus([ @@ -400,6 +433,19 @@ class DirectorView extends ControllerBase } $authToken = $request->headers->get('PHP_AUTH_USER'); + $epalConfigs = $this->entityTypeManager->getStorage('epal_config')->loadByProperties(array('name' => 'epal_config')); + $epalConfig = reset($epalConfigs); + if (!$epalConfig) { + return $this->respondWithStatus([ + "error_code" => 3001 + ], Response::HTTP_FORBIDDEN); + } + if ($epalConfig->lock_capacity->value) { + return $this->respondWithStatus([ + "error_code" => 3002 + ], Response::HTTP_FORBIDDEN); + } + $users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken)); $user = reset($users); if ($user) { @@ -673,10 +719,10 @@ class DirectorView extends ControllerBase $studentPerSchool = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('currentepal' => $schoolid, 'specialization_id' => -1, 'currentclass' => 1)); //foreach ($CourseA as $object) { - if (sizeof($studentPerSchool) < $limit) { - return false; + if (sizeof($studentPerSchool) < $limit) { + return false; // exit; - } + } } // } $CourseB = $this->entityTypeManager->getStorage('eepal_sectors_in_epal')->loadByProperties(array('epal_id' => $schoolid)); @@ -902,12 +948,9 @@ class DirectorView extends ControllerBase $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; + return $this->respondWithStatus([ + 'message' => "No access to this school" + ], Response::HTTP_FORBIDDEN); } $userRoles = $user->getRoles(); $userRole = ''; @@ -918,8 +961,8 @@ class DirectorView extends ControllerBase } if ($userRole === '') { return $this->respondWithStatus([ - 'error_code' => 4003, - ], Response::HTTP_FORBIDDEN); + 'error_code' => 4003, + ], Response::HTTP_FORBIDDEN); } elseif ($userRole === 'epal') { $list = array(); @@ -937,12 +980,12 @@ class DirectorView extends ControllerBase } $list[] = array( - 'id' => '1', - 'name' => 'Α Λυκείου', - 'categ' => $categ, - 'classes' => 1, - 'limitdown' => $limit, - ); + 'id' => '1', + 'name' => 'Α Λυκείου', + 'categ' => $categ, + 'classes' => 1, + 'limitdown' => $limit, + ); } if ($classid == 2) { @@ -953,9 +996,7 @@ class DirectorView extends ControllerBase } $list[] = array( - 'name' => 'Β Λυκείου ', - 'categ' => $categ, 'classes' => 2, 'limitdown' => $limit, @@ -971,7 +1012,6 @@ class DirectorView extends ControllerBase } $list[] = array( - 'categ' => $categ, 'classes' => 3, 'limitdown' => $limit, @@ -979,18 +1019,17 @@ class DirectorView extends ControllerBase ); } - return $this->respondWithStatus( - $list, Response::HTTP_OK); + return $this->respondWithStatus($list, Response::HTTP_OK); } } else { return $this->respondWithStatus([ - 'message' => t('Perfecture not found!'), - ], Response::HTTP_FORBIDDEN); + 'message' => t('Perfecture not found!'), + ], Response::HTTP_FORBIDDEN); } } else { return $this->respondWithStatus([ - 'message' => t('User not found!'), - ], Response::HTTP_FORBIDDEN); + 'message' => t('User not found!'), + ], Response::HTTP_FORBIDDEN); } } diff --git a/drupal/modules/epal/src/Controller/Distribution.php b/drupal/modules/epal/src/Controller/Distribution.php index 453c107bf579e298e21446a51b5e59526078b6bd..1898a770fa54d299f185258f3e58867e5c94f6c2 100755 --- a/drupal/modules/epal/src/Controller/Distribution.php +++ b/drupal/modules/epal/src/Controller/Distribution.php @@ -157,7 +157,7 @@ class Distribution extends ControllerBase { while ($this->choice_id <= $numDistributions) { - //υπολογισμός πλήθους non-finalized αιτήσεων για να καθοριστεί ο αριθμός των fetches που θα κάνουμε με συγκεκριμένο sizeOfBlock + //υπολογισμός πλήθους non-finalized δηλώσεων για να καθοριστεί ο αριθμός των fetches που θα κάνουμε με συγκεκριμένο sizeOfBlock if ($this->choice_id === 1) { $sCon = $this->connection->select('epal_student', 'eStudent') ->fields('eStudent', array('id')); diff --git a/drupal/modules/epal/src/Controller/InformUnlocatedStudents.php b/drupal/modules/epal/src/Controller/InformUnlocatedStudents.php index f3bac3861b1c5b8d02acfbc9d1ffe1bd9b045b2d..f02d24493357d21edba69f1f72d30b47a7846340 100644 --- a/drupal/modules/epal/src/Controller/InformUnlocatedStudents.php +++ b/drupal/modules/epal/src/Controller/InformUnlocatedStudents.php @@ -267,31 +267,20 @@ class InformUnlocatedStudents extends ControllerBase { . " δεν ικανοποιήθηκε. Παρακαλώ επικοινωνήστε άμεσα τηλεφωνικά με τη Διεύθυνση Δευτεροβάθμιας Εκπαίδευσης / Τμήμα Επαγγελματικής Εκπαίδευσης." . "\r\n\r\n Ομάδα Διαχείρισης της εφαρμογής e-epal." . "\r\n Προσοχή: το μήνυμα που διαβάζετε είναι αυτοματοποιημένο. Παρακαλώ μην απαντάτε σε αυτό το μήνυμα.." ;//e-mail body" ;//e-mail body - //add new lines with SENDER name - check it - //$params['subject'] = t('Μη ικανοποίηση ηλεκτρονικής αίτησης για εγγραφή σε ΕΠΑΛ'); - - //$this->logger->warning($params['message']); - - //$langcode = $user->getPreferredLangcode(); $send = true; $mail_sent = $mailManager->mail($module, $key, $to, $langcode, $params, NULL, $send); - //$mail_sent = 1; if ($mail_sent) { - //$this->logger->info("Το mail στάλθηκε με επιτυχία"); return 1; } else { - //$this->logger->info("Αποτυχία αποστολής mail."); return 0; } } public function sendMailToLocatedStudents(Request $request) { - //$msg = "test"; - try { if (!$request->isMethod('GET')) { return $this->respondWithStatus([ diff --git a/drupal/modules/epal/src/Controller/PdfCreator.php b/drupal/modules/epal/src/Controller/PdfCreator.php index 56550465de588857371517d1778bec2fb3f56987..66749fcfee7c1f91d5beca2e644822b1daf789f9 100644 --- a/drupal/modules/epal/src/Controller/PdfCreator.php +++ b/drupal/modules/epal/src/Controller/PdfCreator.php @@ -174,9 +174,9 @@ class PDFCreator extends ControllerBase { private function createHeader($student) { $this->pdf->SetFont($this->fontBold, '', 16); - $this->pdf->MultiCell(0, 8, $this->prepareString('Ηλεκτρονική Αίτηση Εγγραφής Μαθητή σε ΕΠΑΛ'), 0, 'C'); + $this->pdf->MultiCell(0, 8, $this->prepareString('Ηλεκτρονική Δήλωση Προτίμησης ΕΠΑΛ'), 0, 'C'); $this->pdf->SetFont($this->fontBold, '', $this->fontSizeHeader); - $this->pdf->MultiCell(0, 8, $this->prepareString('με αριθμό αίτησης: ' . $student->id->value . ' / ' . date('d-m-y (ώρα: H:i:s)', $student->created->value)), 0, 'C'); + $this->pdf->MultiCell(0, 8, $this->prepareString('με αριθμό δήλωσης: ' . $student->id->value . ' / ' . date('d-m-y (ώρα: H:i:s)', $student->created->value)), 0, 'C'); $this->pdf->Ln(); } @@ -391,7 +391,7 @@ class PDFCreator extends ControllerBase { $this->pdf->Ln(); $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->Cell($width, $height, $this->prepareString($student->relationtostudent->value), 0, 'L'); $this->pdf->Cell($width, $height, $this->prepareString($relationtostudent_decoded), 0, 'L'); diff --git a/drupal/modules/epal/src/Controller/ReportsCreator.php b/drupal/modules/epal/src/Controller/ReportsCreator.php index b050af632b9b4149befb1fd450e60eac478327cc..8722dffad5221116928523d197c4c5761f7d966c 100644 --- a/drupal/modules/epal/src/Controller/ReportsCreator.php +++ b/drupal/modules/epal/src/Controller/ReportsCreator.php @@ -94,12 +94,12 @@ class ReportsCreator extends ControllerBase { ], Response::HTTP_FORBIDDEN); } - //υπολογισμός αριθμού αιτήσεων + //υπολογισμός αριθμού δηλώσεων $sCon = $this->connection->select('epal_student', 'eStudent') ->fields('eStudent', array('id')); $numTotal = $sCon->countQuery()->execute()->fetchField(); - //υπολογισμός αριθμού αιτήσεων που ικανοποιήθηκαν στην i προτίμηση + //υπολογισμός αριθμού δηλώσεων που ικανοποιήθηκαν στην i προτίμηση $numData = array(); for ($i=0; $i < 3; $i++) { $sCon = $this->connection->select('epal_student_class', 'eStudent') @@ -109,7 +109,7 @@ class ReportsCreator extends ControllerBase { array_push($numData, $sCon->countQuery()->execute()->fetchField()); } - // υπολογισμός αριθμού αιτήσεων που ΔΕΝ ικανοποιήθηκαν + // υπολογισμός αριθμού δηλώσεων που ΔΕΝ ικανοποιήθηκαν //Σημείωση: υπολογισμός με queries στη βάση $sCon = $this->connection->select('epal_student_class', 'eStudent') ->fields('eStudent', array('student_id')); @@ -122,7 +122,7 @@ class ReportsCreator extends ControllerBase { ->condition('eStudent.id', $studentIds, 'NOT IN'); $numNoAllocated = $sCon->countQuery()->execute()->fetchField(); - //υπολογισμός αριθμού αιτήσεων που τοποθετήθηκαν προσωρινά σε ολιγομελή τμήματα + //υπολογισμός αριθμού δηλώσεων που τοποθετήθηκαν προσωρινά σε ολιγομελή τμήματα $numInSmallClasses = 0; $sCon = $this->connection->select('epal_student_class', 'eStudent') ->fields('eStudent', array('id')) @@ -132,7 +132,7 @@ class ReportsCreator extends ControllerBase { $list = array(); - array_push($list,(object) array('name' => "Αριθμός Αιτήσεων", 'numStudents' => $numTotal)); + array_push($list,(object) array('name' => "Αριθμός Δηλώσεων Προτίμησης", 'numStudents' => $numTotal)); array_push($list,(object) array('name' => "Αριθμός μαθητών που τοποθετήθηκαν στην πρώτη τους προτίμηση", 'numStudents' => $numData[0])); array_push($list,(object) array('name' => "Αριθμός μαθητών που τοποθετήθηκαν στην δεύτερή τους προτίμηση", 'numStudents' => $numData[1])); array_push($list,(object) array('name' => "Αριθμός μαθητών που τοποθετήθηκαν στην τρίτη τους προτίμηση", 'numStudents' => $numData[2])); diff --git a/drupal/modules/epal/src/Controller/SubmitedApplications.php b/drupal/modules/epal/src/Controller/SubmitedApplications.php index a2952fd94d5504fbf56a17d82a5df8c7eb5bd35e..36ed5e1b469d78e618f1e4807a1b256aaf256361 100755 --- a/drupal/modules/epal/src/Controller/SubmitedApplications.php +++ b/drupal/modules/epal/src/Controller/SubmitedApplications.php @@ -8,16 +8,15 @@ use Symfony\Component\HttpFoundation\JsonResponse; use Drupal\Core\Controller\ControllerBase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; - +use Drupal\Core\Database\Connection; use Drupal\Core\Logger\LoggerChannelFactoryInterface; - use Drupal\epal\Crypt; class SubmitedApplications extends ControllerBase { protected $entityTypeManager; protected $logger; - + protected $connection; /* public function __construct(EntityTypeManagerInterface $entityTypeManager) { @@ -27,51 +26,50 @@ class SubmitedApplications extends ControllerBase */ public function __construct( - EntityTypeManagerInterface $entityTypeManager, - LoggerChannelFactoryInterface $loggerChannel) - { - $this->entityTypeManager = $entityTypeManager; - $this->logger = $loggerChannel->get('epal'); - } + EntityTypeManagerInterface $entityTypeManager, + Connection $connection, + LoggerChannelFactoryInterface $loggerChannel) + { + $this->entityTypeManager = $entityTypeManager; + $this->connection = $connection; + $this->logger = $loggerChannel->get('epal'); + } public static function create(ContainerInterface $container) { return new static( $container->get('entity_type.manager'), + $container->get('database'), $container->get('logger.factory') ); } - public function getSubmittedApplications(Request $request) { - $authToken = $request->headers->get('PHP_AUTH_USER'); $epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken)); $epalUser = reset($epalUsers); if ($epalUser) { - $userid = $epalUser -> id(); + $userid = $epalUser->id(); $epalStudents = $this->entityTypeManager->getStorage('epal_student')->loadByProperties(array('epaluser_id' => $userid)); $i = 0; if ($epalStudents) { - $crypt = new Crypt(); $list = array(); foreach ($epalStudents as $object) { + $indexid = intval($object->id()) - 1; - $indexid = intval($object -> id())-1; - - try { - $name_decoded = $crypt->decrypt($object->name->value); - $studentsurname_decoded = $crypt->decrypt($object->studentsurname->value); - } - catch (\Exception $e) { + 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 ") + 'message' => t('An unexpected error occured during DECODING data in getSubmittedApplications Method '), ], Response::HTTP_INTERNAL_SERVER_ERROR); } @@ -80,52 +78,39 @@ class SubmitedApplications extends ControllerBase //'name' => $object -> name ->value, 'name' => $name_decoded, //'studentsurname' => $object -> studentsurname ->value); - 'studentsurname' => $studentsurname_decoded ); - $i++; + 'studentsurname' => $studentsurname_decoded, ); + ++$i; } unset($crypt); return $this->respondWithStatus( - $list - , Response::HTTP_OK); - } - else { - return $this->respondWithStatus([ - 'message' => t("EPAL user not found"), + $list, Response::HTTP_OK); + } else { + return $this->respondWithStatus([ + 'message' => t('EPAL user not found'), ], Response::HTTP_FORBIDDEN); - } - - - - + } } else { return $this->respondWithStatus([ - 'message' => t("User not found"), + 'message' => t('User not found'), ], Response::HTTP_FORBIDDEN); } - } - - - - public function getStudentApplications(Request $request, $studentId) + public function getStudentApplications(Request $request, $studentId) { - $authToken = $request->headers->get('PHP_AUTH_USER'); $epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken)); $epalUser = reset($epalUsers); if ($epalUser) { - $userid = $epalUser -> id(); - $studentIdNew = intval($studentId) ; - $epalStudents = $this->entityTypeManager->getStorage('epal_student')->loadByProperties(array('epaluser_id' => $userid, 'id'=> $studentIdNew)); - $i = 0; - - if ($epalStudents) { - + $userid = $epalUser->id(); + $studentIdNew = intval($studentId); + $epalStudents = $this->entityTypeManager->getStorage('epal_student')->loadByProperties(array('epaluser_id' => $userid, 'id' => $studentIdNew)); + $i = 0; - $list = array(); + if ($epalStudents) { + $list = array(); foreach ($epalStudents as $object) { $sectorName = ''; @@ -133,41 +118,41 @@ class SubmitedApplications extends ControllerBase if ($object->currentclass->value === '2') { $sectors = $this->entityTypeManager->getStorage('epal_student_sector_field')->loadByProperties(array('student_id' => $object->id())); $sector = reset($sectors); - if ($sector) + if ($sector) { $sectorName = $this->entityTypeManager->getStorage('eepal_sectors')->load($sector->sectorfield_id->target_id)->name->value; - } - else if ($object->currentclass->value === '3' || $object->currentclass->value === '4') { + } + } elseif ($object->currentclass->value === '3' || $object->currentclass->value === '4') { $courses = $this->entityTypeManager->getStorage('epal_student_course_field')->loadByProperties(array('student_id' => $object->id())); $course = reset($courses); - if ($course) + 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) { + 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); + $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); @@ -179,182 +164,156 @@ class SubmitedApplications extends ControllerBase 'studentsurname' => $studentsurname_decoded, //'fatherfirstname' => $object -> fatherfirstname ->value, 'fatherfirstname' => $fatherfirstname_decoded, - 'fathersurname' =>$object -> fathersurname ->value, + 'fathersurname' => $object->fathersurname->value, //'motherfirstname' => $object -> motherfirstname ->value, 'motherfirstname' => $motherfirstname_decoded, - 'mothersurname' =>$object -> mothersurname ->value, + 'mothersurname' => $object->mothersurname->value, //'guardian_name' =>$object -> guardian_name ->value, - 'guardian_name' =>$guardian_name_decoded, + 'guardian_name' => $guardian_name_decoded, //'guardian_surname' =>$object -> guardian_surname ->value, 'guardian_surname' => $guardian_surname_decoded, //'guardian_fathername' =>$object -> guardian_fathername ->value, - 'guardian_fathername' =>$guardian_fathername_decoded, + 'guardian_fathername' => $guardian_fathername_decoded, //'guardian_mothername' =>$object -> guardian_mothername ->value, - 'guardian_mothername' =>$guardian_mothername_decoded, - 'lastschool_schoolname' =>$object -> lastschool_schoolname ->value, - 'lastschool_schoolyear' =>$object -> lastschool_schoolyear ->value, - 'lastschool_class' =>$object -> lastschool_class ->value, - 'currentclass' =>$object -> currentclass ->value, - 'currentsector' =>$sectorName, - 'currentcourse' =>$courseName, + 'guardian_mothername' => $guardian_mothername_decoded, + 'lastschool_schoolname' => $object->lastschool_schoolname->value, + 'lastschool_schoolyear' => $object->lastschool_schoolyear->value, + 'lastschool_class' => $object->lastschool_class->value, + 'currentclass' => $object->currentclass->value, + 'currentsector' => $sectorName, + 'currentcourse' => $courseName, //'regionaddress' =>$object -> regionaddress ->value, - 'regionaddress' =>$regionaddress_decoded, + 'regionaddress' => $regionaddress_decoded, //'regiontk' =>$object -> regiontk ->value, - 'regiontk' =>$regiontk_decoded, + 'regiontk' => $regiontk_decoded, //'regionarea' =>$object -> regionarea ->value, - 'regionarea' =>$regionarea_decoded, + 'regionarea' => $regionarea_decoded, //'certificatetype' =>$object -> certificatetype ->value, 'certificatetype' => $certificatetype_decoded, - 'graduation_year' =>$object -> graduation_year ->value, + 'graduation_year' => $object->graduation_year->value, //'telnum' =>$object -> telnum ->value, - 'telnum' =>$telnum_decoded, + 'telnum' => $telnum_decoded, //'relationtostudent' =>$object -> relationtostudent ->value, 'relationtostudent' => $relationtostudent_decoded, - 'birthdate' => substr($object->birthdate->value, 8, 2) . '/' . substr($object->birthdate->value, 6, 2) . '/' . substr($object->birthdate->value, 0, 4), - 'created' => date('d/m/Y H:i', $object -> created ->value), + 'birthdate' => substr($object->birthdate->value, 8, 2).'/'.substr($object->birthdate->value, 5, 2).'/'.substr($object->birthdate->value, 0, 4), + 'created' => date('d/m/Y H:i', $object->created->value), ); - $i++; + ++$i; } return $this->respondWithStatus( - $list - , Response::HTTP_OK); - } - else { - return $this->respondWithStatus([ - 'message' => t("EPAL user not found"), + $list, Response::HTTP_OK); + } else { + return $this->respondWithStatus([ + 'message' => t('EPAL user not found'), ], Response::HTTP_FORBIDDEN); - } - - - + } } else { return $this->respondWithStatus([ - 'message' => t("User not found!!!!"), + 'message' => t('User not found!!!!'), ], Response::HTTP_FORBIDDEN); } - } - -public function getEpalChosen(Request $request, $studentId) + public function getEpalChosen(Request $request, $studentId) { - $authToken = $request->headers->get('PHP_AUTH_USER'); $epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken)); $epalUser = reset($epalUsers); if ($epalUser) { - $userid = $epalUser -> user_id -> entity -> id(); - $studentIdNew = intval($studentId) ; - $epalChosen = $this->entityTypeManager->getStorage('epal_student_epal_chosen')->loadByProperties(array( 'user_id'=>$userid,'student_id'=> $studentIdNew)); - $i = 0; + $userid = $epalUser->user_id->entity->id(); + $studentIdNew = intval($studentId); + $ecQuery = $this->connection->select('epal_student_epal_chosen', 'ec') + ->fields('ec', array('choice_no')) + ->fields('es', array('name')); + $ecQuery->addJoin('inner', 'eepal_school_field_data', 'es', 'ec.epal_id=es.id'); + $ecQuery->condition('ec.user_id', $userid, '='); + $ecQuery->condition('ec.student_id', $studentIdNew, '='); + $ecQuery->orderBy('ec.choice_no'); + $epalChosen = $ecQuery->execute()->fetchAll(\PDO::FETCH_OBJ); + $i = 0; - if ($epalChosen) { - $list = array(); + if ($epalChosen && sizeof($epalChosen) > 0) { + $list = array(); foreach ($epalChosen as $object) { $list[] = array( - 'epal_id' => $object -> epal_id ->entity->get('name')->value , - 'choice_no' => $object -> choice_no ->value, -); - - $i++; + 'epal_id' => $object->name, + 'choice_no' => $object->choice_no, + ); + ++$i; } return $this->respondWithStatus( - $list - , Response::HTTP_OK); - } - else { - return $this->respondWithStatus([ - 'message' => t("EPAL chosen not found!!!"), + $list, Response::HTTP_OK); + } else { + return $this->respondWithStatus([ + 'message' => t('EPAL chosen not found!!!'), ], Response::HTTP_FORBIDDEN); - } - - - + } } else { return $this->respondWithStatus([ - 'message' => t("User not found"), + 'message' => t('User not found'), ], Response::HTTP_FORBIDDEN); } - } - public function getCritiria(Request $request, $studentId, $type) { - $authToken = $request->headers->get('PHP_AUTH_USER'); $epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken)); $epalUser = reset($epalUsers); if ($epalUser) { - $userid = $epalUser -> user_id -> entity -> id(); - $studentIdNew = intval($studentId) ; - $critiriaChosen = $this->entityTypeManager->getStorage('epal_student_moria')->loadByProperties(array( 'user_id'=>$userid,'student_id'=> $studentIdNew)); - $i = 0; + $userid = $epalUser->user_id->entity->id(); + $studentIdNew = intval($studentId); + $critiriaChosen = $this->entityTypeManager->getStorage('epal_student_moria')->loadByProperties(array('user_id' => $userid, 'student_id' => $studentIdNew)); + $i = 0; if ($critiriaChosen) { - $list = array(); + $list = array(); foreach ($critiriaChosen as $object) { - $critirio_id = $object -> criterio_id ->entity -> id(); - $critiriatype = $this->entityTypeManager->getStorage('epal_criteria')->loadByProperties(array( 'id'=>$critirio_id )); + $critirio_id = $object->criterio_id->entity->id(); + $critiriatype = $this->entityTypeManager->getStorage('epal_criteria')->loadByProperties(array('id' => $critirio_id)); $typeofcritiria = reset($critiriatype); - $typecrit = $typeofcritiria -> category -> value; - if ($typecrit == "Κοινωνικό" && $type == 1){ + $typecrit = $typeofcritiria->category->value; + if ($typecrit == 'Κοινωνικό' && $type == 1) { $list[] = array( - 'critirio' => $object -> criterio_id ->entity->get('name')->value , - 'critirio_id' => $critirio_id , + 'critirio' => $object->criterio_id->entity->get('name')->value, + 'critirio_id' => $critirio_id, ); - $i++; + ++$i; } - if ($typecrit == "Εισοδηματικό" && $type == 2){ + if ($typecrit == 'Εισοδηματικό' && $type == 2) { $list[] = array( - 'critirio' => $object -> criterio_id ->entity->get('name')->value , - 'critirio_id' => $critirio_id , + 'critirio' => $object->criterio_id->entity->get('name')->value, + 'critirio_id' => $critirio_id, ); - $i++; + ++$i; } - - } return $this->respondWithStatus( - $list - , Response::HTTP_OK); - } - else { - return $this->respondWithStatus([ - 'message' => t("EPAL chosen not found!!!"), + $list, Response::HTTP_OK); + } else { + return $this->respondWithStatus([ + 'message' => t('EPAL chosen not found!!!'), ], Response::HTTP_FORBIDDEN); - } - - - + } } else { return $this->respondWithStatus([ - 'message' => t("User not found"), + 'message' => t('User not found'), ], Response::HTTP_FORBIDDEN); } - } - - - - - - private function respondWithStatus($arr, $s) { + private function respondWithStatus($arr, $s) + { $res = new JsonResponse($arr); $res->setStatusCode($s); + return $res; } - - - - - } diff --git a/drupal/modules/epal/src/Controller/WSConsumer.php b/drupal/modules/epal/src/Controller/WSConsumer.php index af7205f8b5c177f2030c2f26ecfbd86970746cf9..89e09a882260c70ba309e99691e72caeb5751ee2 100755 --- a/drupal/modules/epal/src/Controller/WSConsumer.php +++ b/drupal/modules/epal/src/Controller/WSConsumer.php @@ -118,10 +118,4 @@ class WSConsumer extends ControllerBase return $randomString; } - // private function respondWithStatus($arr, $s) - // { - // $res = new JsonResponse($arr); - // $res->setStatusCode($s); - // return $res; - // } } diff --git a/drupal/modules/epal/src/Crypt.php b/drupal/modules/epal/src/Crypt.php index 0e8bc693b8594c85028543e438ef2624ed67e3d5..d86e7010961253085cacba29ae4b0333cb4f1695 100644 --- a/drupal/modules/epal/src/Crypt.php +++ b/drupal/modules/epal/src/Crypt.php @@ -11,7 +11,7 @@ class Crypt private $fname; // store - public function __construct($fname) + public function __construct($fname = null) { if (is_string($fname)) { $this->fname = $fname; diff --git a/package.json b/package.json index 7aaafe91b24338202aa04e186656f0b8cbee6e34..0f213dd981e12802e16e96f7654008f043c546da 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ }, "scripts": { "start": "webpack-dashboard -- webpack --progress --colors --watch --display-error-details --display-cached", - "build": "webpack --progress --colors --watch --display-error-details --display-cached", + "build": "webpack --config webpack.prod.js --progress --colors --watch --display-error-details --display-cached", "typings": "rimraf typings/ && typings install" }, "devDependencies": { @@ -22,6 +22,7 @@ "babel-preset-env": "^1.1.4", "babel-preset-es2015": "^6.18.0", "babel-preset-stage-1": "^6.16.0", + "babili-webpack-plugin": "^0.1.1", "bootstrap-loader": "^2.0.0-beta.20", "css-loader": "^0.25.0", "node-sass": "^4.5.0", @@ -35,6 +36,8 @@ "typescript": "^2.0.10", "url-loader": "^0.5.7", "webpack": "^1.14.0", + "webpack-cleanup-plugin": "^0.5.1", + "webpack-closure-compiler": "^2.1.4", "webpack-dashboard": "^0.2.0", "webpack-dev-server": "^1.16.2" }, @@ -49,8 +52,7 @@ "@angular/router": "^3.2.0", "@ngui/auto-complete": "^0.13.3", "@types/file-saver": "0.0.1", - "@types/html2canvas": "^0.5.33", - "@types/jspdf": "^1.1.31", + "@types/jquery": "^2.0.41", "@types/node": "^6.0.60", "@types/node-sass": "^3.10.32", "babel-polyfill": "^6.20.0", @@ -65,10 +67,8 @@ "file-system": "^2.2.2", "fs-writefile-promise": "^2.0.0", "html-webpack-plugin": "^2.24.1", - "html2canvas": "^0.5.0-beta4", "immutable": "^3.8.1", "jquery": "^3.1.1", - "jspdf": "^1.3.3", "mydatepicker": "^2.0.13", "ng2-redux": "^5.1.0", "ng2-smart-table": "^0.4.0-5", diff --git a/source/app.ts b/source/app.ts index 18edf2e499675a7cb52429d8ab2054030feeb412..a22f620a0a3bd86b2a85b62a580bd9d64b24193d 100644 --- a/source/app.ts +++ b/source/app.ts @@ -31,7 +31,10 @@ import {HelperDataService} from './services/helper-data-service'; import {LoaderService} from './services/Spinner.service'; import {AuthService} from './services/auth.service'; import SchoolAuthGuard from './guards/school.auth.guard'; +import SchoolStudentsLockedGuard from './guards/school.students.locked.guard'; +import SchoolCapacityLockedGuard from './guards/school.capacity.locked.guard'; import StudentAuthGuard from './guards/student.auth.guard'; +import StudentLockGuard from './guards/student.lock.guard'; import RegionEduAuthGuard from './guards/regionedu.auth.guard'; import EduAdminAuthGuard from './guards/eduadmin.auth.guard'; import MinistryAuthGuard from './guards/ministry.auth.guard'; @@ -85,14 +88,16 @@ class MyLocalization extends NgLocalization { LoaderService, AuthService, SchoolAuthGuard, + SchoolStudentsLockedGuard, + SchoolCapacityLockedGuard, StudentAuthGuard, + StudentLockGuard, RegionEduAuthGuard, EduAdminAuthGuard, MinistryAuthGuard - ] }) class AppModule {} -// enableProdMode(); +enableProdMode(); platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/source/components/director/director-view.ts b/source/components/director/director-view.ts index 131f6b5ed701b1d900c6f114d683ad2e2bce54f0..4a7cb011399d6d6968dcd7411b447d429b82b9ef 100644 --- a/source/components/director/director-view.ts +++ b/source/components/director/director-view.ts @@ -1,12 +1,12 @@ -import { Component, OnInit, OnDestroy, ElementRef, ViewChild, Renderer} from "@angular/core"; +import { Component, OnInit, OnDestroy, ElementRef, ViewChild, Renderer } from "@angular/core"; import { Injectable } from "@angular/core"; import { AppSettings } from '../../app.settings'; import { HelperDataService } from '../../services/helper-data-service'; -import {Observable} from "rxjs/Observable"; -import {Http, Headers, RequestOptions} from '@angular/http'; +import { Observable } from "rxjs/Observable"; +import { Http, Headers, RequestOptions } from '@angular/http'; import { NgRedux, select } from 'ng2-redux'; import { IAppState } from '../../store/store'; -import {Router, ActivatedRoute, Params} from '@angular/router'; +import { Router, ActivatedRoute, Params } from '@angular/router'; import { BehaviorSubject, Subscription } from 'rxjs/Rx'; import { ILoginInfo } from '../../store/logininfo/logininfo.types'; @@ -217,7 +217,7 @@ import { private selectionCClass: BehaviorSubject; private limitsSub: Subscription; private limits$: BehaviorSubject; - private SchoolId ; + private SchoolId; private currentclass: Number; private saved: Array = new Array(); private limitdown = 0; @@ -282,29 +282,29 @@ import { ngOnInit() { - this.SchoolSub = this._hds.gettypeofschool().subscribe(x => { - this.School$.next(x); - console.log(x[0].type, "schoolid!"); - this.SchoolId = x[0].type; - if (this.SchoolId == 'ΗΜΕΡΗΣΙΟ'){ - this.selectiontype.next(false); - } + this.SchoolSub = this._hds.gettypeofschool().subscribe(x => { + this.School$.next(x); + console.log(x[0].type, "schoolid!"); + this.SchoolId = x[0].type; + if (this.SchoolId == 'ΗΜΕΡΗΣΙΟ') { + this.selectiontype.next(false); + } - }, - error => { - this.School$.next([{}]); - console.log("Error Getting School"); - }, - () => console.log("Getting School ")); + }, + error => { + this.School$.next([{}]); + console.log("Error Getting School"); + }, + () => console.log("Getting School ")); - } + } verifyclass(txop) { - this.limitdown = 0; - this.limitup = 5; - console.log(this.SchoolId,"schoolida"); + this.limitdown = 0; + this.limitup = 5; + console.log(this.SchoolId, "schoolida"); this.pageno = 1; this.retrievedStudent.next(false); if (txop.value === "1") { @@ -327,7 +327,7 @@ import { } else if (txop.value === "3" || txop.value === "4") { var sectorint = +this.formGroup.value.tomeas; - if (this.formGroup.value.tomeas != '') { + if (this.formGroup.value.tomeas != '') { var sectorint = +this.formGroup.value.tomeas; this.StudentSelectedSpecialSub = this._hds.getSpecialityPerSchool(sectorint).subscribe(data => { @@ -355,7 +355,7 @@ import { checkbclass(tmop, txop) { - console.log(this.SchoolId,"schoolidn"); + console.log(this.SchoolId, "schoolidn"); this.pageno = 1; this.retrievedStudent.next(false); var sectorint = +this.formGroup.value.tomeas; @@ -376,95 +376,88 @@ import { findstudent(txop, pageno) { - - var sectorint = +this.formGroup.value.tomeas; + let sectorint = +this.formGroup.value.tomeas; this.currentclass = +txop.value; this.formGroup.get('pageno').setValue(this.pageno); if (this.pageno == 1) { console.log("mphkepage = 1"); - this.StudentsSizeSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, 0, 0).subscribe(x => { - this.StudentsSize$.next(x); - this.totallimit = x.id; - - this.limitsSub = this._hds.getlimitsofcourse(this.currentclass).subscribe(data => { - this.limits$.next(data); - console.log(this.totallimit, data[0].limitdown, "oria"); - this.tot_pages = x.id / 5; - if (x.id % 5 > 0) { - this.tot_pages = (x.id - (x.id % 5)) / 5 + 1; - } - console.log(this.tot_pages,"totpages") - if (isNaN(this.tot_pages)){ - this.retrievedStudent.next(false); - this.tot_pages = 0; - } - if ( (x.id < data[0].limitdown) || (isNaN(this.tot_pages))) - { - console.log("mphkeprwto!") - this.retrievedStudent.next(false); - this.tot_pages = 0; - this.formGroup.get('maxpage').setValue(this.tot_pages); - //this.outoflimits.next(true); - } - else - { - // this.outoflimits.next(false); - - this.formGroup.get('maxpage').setValue(this.tot_pages); - console.log(this.tot_pages,"mazeuw mathites"); - this.StudentInfoSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, this.limitdown, this.limitup).subscribe(data => { - this.StudentInfo$.next(data); - - console.log("tot.pages", this.formGroup.value.maxpage, "max1", this.tot_pages); - this.retrievedStudent.next(true); - - }, - error => { - this.StudentInfo$.next([{}]); - console.log("Error Getting Students"); - }, - () => console.log("Getting Students")); - - - - } - - }, - error => { - this.limits$.next([{}]); - console.log("Error Getting limits"); - }, - () => console.log("Getting limits")); + this.StudentsSizeSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, 0, 0) + .subscribe(x => { + this.StudentsSize$.next(x); + this.totallimit = x.id; + + this.limitsSub = this._hds.getlimitsofcourse(this.currentclass).subscribe(data => { + this.limits$.next(data); + console.log(this.totallimit, data[0].limitdown, "oria"); + this.tot_pages = Math.floor(x.id / 5); + if (x.id % 5 > 0) { + // this.tot_pages = (x.id - (x.id % 5)) / 5 + 1; + this.tot_pages += 1; + } + console.log(this.tot_pages, "totpages") + if (isNaN(this.tot_pages)) { + this.retrievedStudent.next(false); + this.tot_pages = 0; + } + if ((x.id < parseInt(data[0].limitdown)) || (isNaN(this.tot_pages))) { + console.log("mphkeprwto!") + this.retrievedStudent.next(false); + this.tot_pages = 0; + this.formGroup.get('maxpage').setValue(this.tot_pages); + //this.outoflimits.next(true); + } else { + // this.outoflimits.next(false); + this.formGroup.get('maxpage').setValue(this.tot_pages); + console.log(this.tot_pages, "mazeuw mathites"); + this.StudentInfoSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, this.limitdown, this.limitup) + .subscribe(data => { + this.StudentInfo$.next(data); + console.log("tot.pages", this.formGroup.value.maxpage, "max1", this.tot_pages); + this.retrievedStudent.next(true); + }, + error => { + this.StudentInfo$.next([{}]); + console.log("Error Getting Students"); + }, + () => console.log("Getting Students") + ); + } + }, + error => { + this.limits$.next([{}]); + console.log("Error Getting limits"); + }, + () => console.log("Getting limits") + ); - }); + }); } - else{ - console.log("eisai edw", this.tot_pages); + else { + console.log("eisai edw", this.tot_pages); - if (this.tot_pages == 0 ){ - console.log("mphke1", this.formGroup.value.maxpage, this.tot_pages); - this.retrievedStudent.next(false); - } - else - { - console.log(this.tot_pages,"mazeuw mathites"); + if (this.tot_pages == 0) { + console.log("mphke1", this.formGroup.value.maxpage, this.tot_pages); + this.retrievedStudent.next(false); + } + else { + console.log(this.tot_pages, "mazeuw mathites"); this.StudentInfoSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, this.limitdown, this.limitup).subscribe(data => { - this.StudentInfo$.next(data); + this.StudentInfo$.next(data); - console.log("tot.pages", this.formGroup.value.maxpage, "max1", this.tot_pages); - this.retrievedStudent.next(true); + console.log("tot.pages", this.formGroup.value.maxpage, "max1", this.tot_pages); + this.retrievedStudent.next(true); - }, - error => { - this.StudentInfo$.next([{}]); - console.log("Error Getting Students"); - }, - () => console.log("Getting Students")); - } + }, + error => { + this.StudentInfo$.next([{}]); + console.log("Error Getting Students"); + }, + () => console.log("Getting Students")); + } } } @@ -492,7 +485,7 @@ import { confirmStudent(txop) { - this.SavedStudentsSub = this._hds.saveConfirmStudents(this.saved, this.type).subscribe(data => { + this.SavedStudentsSub = this._hds.saveConfirmStudents(this.saved, this.type).subscribe(data => { this.SavedStudents$.next(data); }, @@ -501,9 +494,9 @@ import { console.log("Error saving Students"); }, () => { - console.log("saved Students"); - this.findstudent(txop, this.pageno); - }); + console.log("saved Students"); + this.findstudent(txop, this.pageno); + }); diff --git a/source/components/director/director.buttons.ts b/source/components/director/director.buttons.ts index 70b53c83bef2ee4324bb981997ac23882eb008a8..2b9d7ee6b3ac36b3959d79557fece3125a088b8d 100644 --- a/source/components/director/director.buttons.ts +++ b/source/components/director/director.buttons.ts @@ -7,7 +7,7 @@ import {OnInit, Component, Injectable} from '@angular/core';
diff --git a/source/components/header/header.component.html b/source/components/header/header.component.html index c3ea375187044d9f798cc31c44f09a0a4068dd9a..9a05baf42be558575962f426428109e180277c46 100644 --- a/source/components/header/header.component.html +++ b/source/components/header/header.component.html @@ -1,36 +1,44 @@
-
- -
\ No newline at end of file + + diff --git a/source/components/header/header.component.ts b/source/components/header/header.component.ts index bea5300a5863c3b7706b1cf8c5397b559488505f..153befb8efbd9e5eae8ca14044ede5ca692ce047 100644 --- a/source/components/header/header.component.ts +++ b/source/components/header/header.component.ts @@ -18,8 +18,8 @@ import { CriteriaActions } from "../../actions/criteria.actions"; import { StudentDataFieldsActions } from "../../actions/studentdatafields.actions"; @Component({ - selector: "reg-header", - templateUrl: "header.component.html" + selector: "reg-header", + templateUrl: "header.component.html" }) export default class HeaderComponent implements OnInit, OnDestroy { private authToken: string; @@ -32,28 +32,28 @@ export default class HeaderComponent implements OnInit, OnDestroy { private modalText: BehaviorSubject; private modalHeader: BehaviorSubject; - constructor( private _ata: LoginInfoActions, - private _hds: HelperDataService, - private _csa: SectorCoursesActions, - private _sfa: SectorFieldsActions, - private _rsa: RegionSchoolsActions, - private _eca: EpalClassesActions, - private _sdfa: StudentDataFieldsActions, - private _cria: CriteriaActions, - private _ngRedux: NgRedux, - private router: Router - ) { + constructor(private _ata: LoginInfoActions, + private _hds: HelperDataService, + private _csa: SectorCoursesActions, + private _sfa: SectorFieldsActions, + private _rsa: RegionSchoolsActions, + private _eca: EpalClassesActions, + private _sdfa: StudentDataFieldsActions, + private _cria: CriteriaActions, + private _ngRedux: NgRedux, + private router: Router + ) { - this.authToken = ""; - this.authRole = ""; - this.cuName = ""; - this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE); - this.showLoader$ = new BehaviorSubject(false); - this.modalTitle = new BehaviorSubject(""); - this.modalText = new BehaviorSubject(""); - this.modalHeader = new BehaviorSubject(""); + this.authToken = ""; + this.authRole = ""; + this.cuName = ""; + this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE); + this.showLoader$ = new BehaviorSubject(false); + this.modalTitle = new BehaviorSubject(""); + this.modalText = new BehaviorSubject(""); + this.modalHeader = new BehaviorSubject(""); - }; + }; ngOnInit() { ($("#headerNotice")).appendTo("body"); @@ -86,19 +86,19 @@ export default class HeaderComponent implements OnInit, OnDestroy { // this.router.navigate(['/school']); this.authToken = ""; this.authRole = ""; - window.location.assign(( data).next); + window.location.assign((data).next); } else if (this.authRole === PDE_ROLE) { // this.router.navigate(["/school"]); this.authToken = ""; this.authRole = ""; - window.location.assign(( data).next); + window.location.assign((data).next); } else if (this.authRole === DIDE_ROLE) { // this.router.navigate(["/school"]); this.authToken = ""; this.authRole = ""; - window.location.assign(( data).next); + window.location.assign((data).next); } else if (this.authRole === STUDENT_ROLE) { this._eca.initEpalClasses(); @@ -121,6 +121,24 @@ export default class HeaderComponent implements OnInit, OnDestroy { }); } + goHome() { + if (this.authRole === SCHOOL_ROLE) { + this.router.navigate(['/school']); + } + else if (this.authRole === PDE_ROLE) { + this.router.navigate(["/school"]); + } + else if (this.authRole === DIDE_ROLE) { + this.router.navigate(["/school"]); + } + else if (this.authRole === STUDENT_ROLE) { + this.router.navigate([""]); + } + else if (this.authRole === MINISTRY_ROLE) { + this.router.navigate(["/ministry"]); + } + } + public showModal(): void { ($("#headerNotice")).modal("show"); } diff --git a/source/components/home.ts b/source/components/home.ts index ef0193d9459688fce0cb9a8ebca517561acfa0ad..bd3c3d294a9c56c18ebc1d8f9d4c92d6c7b9507e 100644 --- a/source/components/home.ts +++ b/source/components/home.ts @@ -28,7 +28,7 @@ import { API_ENDPOINT, API_ENDPOINT_PARAMS } from '../app.settings';
@@ -64,23 +64,19 @@ export default class Home implements OnInit { }; ngOnInit() { -/* this.authToken = this.getCookie('auth_token'); - this.authRole = this.getCookie('auth_role'); - console.log(this.authToken); - console.log(this.authRole); - if (this.authToken && this.authRole) { - this._ata.getloginInfo({ auth_token: this.authToken, auth_role: this.authRole }); - this.removeCookie('auth_token'); - this.removeCookie('auth_role'); - } */ this.loginInfo$ = this._ngRedux.select(state => { if (state.loginInfo.size > 0) { state.loginInfo.reduce(({}, loginInfoToken) => { this.authToken = loginInfoToken.auth_token; this.authRole = loginInfoToken.auth_role; - if (this.authToken && this.authToken.length > 0 && this.authRole && this.authRole === STUDENT_ROLE) - this.router.navigate(['/parent-form']); + if (this.authToken && this.authToken.length > 0 && this.authRole && this.authRole === STUDENT_ROLE) { + if (loginInfoToken.lock_application === 1) + this.router.navigate(['/info']); + else { + this.router.navigate(['/parent-form']); + } + } return loginInfoToken; }, {}); } @@ -93,8 +89,6 @@ export default class Home implements OnInit { if (params) { this.authToken = params['auth_token']; this.authRole = params['auth_role']; -// console.log(this.authToken); -// console.log(this.authRole); } if (this.authToken && this.authRole) diff --git a/source/components/main/breadcrumbs.ts b/source/components/main/breadcrumbs.ts index bba5174ea7da7277e54b4807e847235ae86dbf05..f33ad397a29f57bedc9cf13282f064303dc5a7c5 100644 --- a/source/components/main/breadcrumbs.ts +++ b/source/components/main/breadcrumbs.ts @@ -7,14 +7,14 @@ import { Router } from '@angular/router'; @Component({ selector: 'breadcrumbs', template: ` -

Νέα Αίτηση -> Επιλογή Τάξης

-

Νέα Αίτηση -> Επιλογή Τoμέα

-

Νέα Αίτηση -> Επιλογή Σχολείου ανα Περιφερειακή Διεύθυνση

-

Νέα Αίτηση -> Επιλογή Ειδικότητας ανα τoμέα

-

Νέα Αίτηση -> Σειρά Προτίμησης Επιλεχθέντων Σχολείων

-

Νέα Αίτηση -> Προσωπικά Στοιχεία

-

Νέα Αίτηση -> Προεπισκόπη αίτησης

-

Υποβληθείσες αιτήσεις

+

Νέα Δήλωση Προτίμησης -> Επιλογή Τάξης

+

Νέα Δήλωση Προτίμησης -> Επιλογή Τoμέα

+

Νέα Δήλωση Προτίμησης -> Επιλογή Σχολείου ανα Περιφερειακή Διεύθυνση

+

Νέα Δήλωση Προτίμησης -> Επιλογή Ειδικότητας ανα τoμέα

+

Νέα Δήλωση Προτίμησης -> Σειρά Προτίμησης Επιλεχθέντων Σχολείων

+

Νέα Δήλωση Προτίμησης -> Προσωπικά Στοιχεία

+

Νέα Δήλωση Προτίμησης -> Προεπισκόπηση Δήλωσης Προτίμησης

+

Υποβληθείσες Δηλώσεις Προτίμησης

Διαχειριστής Υπουργείου Παιδείας -> Σύνδεση

diff --git a/source/components/minister/minister-settings.ts b/source/components/minister/minister-settings.ts index 52428b38687bd67e233cee11ce4d5d31204e0443..71b286ee3bc4d3c83d7bf8591843484a90b16fc7 100644 --- a/source/components/minister/minister-settings.ts +++ b/source/components/minister/minister-settings.ts @@ -80,7 +80,7 @@ import { (click)="toggleApplicantsLogin()" >
- +

diff --git a/source/components/navbar/navbar.component.html b/source/components/navbar/navbar.component.html index 1292dd7c9de9fb20b9a512deec55b4a56385d6ac..196b720de4be9b34807e81e06b8939846b9251da 100644 --- a/source/components/navbar/navbar.component.html +++ b/source/components/navbar/navbar.component.html @@ -14,15 +14,15 @@
-