Commit f759a438 authored by Χάρης Παπαδόπουλος's avatar Χάρης Παπαδόπουλος
Browse files

Merge branch 'edge' into 'develop'

SubmitedApplications rewrite. submited.aplication.preview rewrite. New validation check in ApplicationSubmit

See merge request !219
parents ab02224d 45801abc
......@@ -38,6 +38,14 @@ epal.current_user:
_controller: '\Drupal\epal\Controller\CurrentUser::getLoginInfo'
requirements:
_user_is_logged_in: 'TRUE'
epal.applicationdetails:
path: '/epal/application/{studentId}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\SubmitedApplications::getApplicationDetails'
requirements:
_user_is_logged_in: 'TRUE'
epal.submitedapplications:
path: '/epal/subapplic'
options:
......@@ -317,4 +325,4 @@ epal.totalstudents:
defaults:
_controller: '\Drupal\epal\Controller\HelpDesk::findTotalStudents'
requirements:
_user_is_logged_in: 'TRUE'
\ No newline at end of file
_user_is_logged_in: 'TRUE'
......@@ -117,8 +117,7 @@ class ApplicationSubmit extends ControllerBase
$guardian_fathername_encoded = $crypt->encrypt($applicationForm[0]['cu_fathername']);
$guardian_mothername_encoded = $crypt->encrypt($applicationForm[0]['cu_mothername']);
} catch (\Exception $e) {
print_r($e->getMessage());
$this->logger->warning($e->getMessage());
$this->logger->error($e->getMessage());
return $this->respondWithStatus([
"error_code" => 5001
], Response::HTTP_INTERNAL_SERVER_ERROR);
......@@ -197,7 +196,8 @@ class ApplicationSubmit extends ControllerBase
'guardian_mothername' => $applicationForm[0]['cu_mothername']
]), sizeof($applicationForm[1]), $applicationForm[0]['currentclass'],
$applicationForm[3]['sectorfield_id'],
$applicationForm[3]['coursefield_id'])) > 0) {
$applicationForm[3]['coursefield_id'],
$epalUser)) > 0) {
return $this->respondWithStatus([
"error_code" => $errorCode
], Response::HTTP_OK);
......@@ -284,7 +284,7 @@ class ApplicationSubmit extends ControllerBase
if (!$epalConfig) {
$secondPeriodEnabled = 0;
} else {
$secondPeriodEnabled = $epalConfig->activate_second_period->getString();
$secondPeriodEnabled = intval($epalConfig->activate_second_period->getString());
}
return $secondPeriodEnabled;
}
......@@ -301,7 +301,7 @@ class ApplicationSubmit extends ControllerBase
* 8002 τα στοιχεία φοίτησης δεν επικυρώθηκαν
* 8003 τα στοιχεία φοίτησης δεν είναι έγκυρα
*/
private function validateStudent($student, $numberOfSchools, $chosenClass, $chosenSector, $chosenCourse)
private function validateStudent($student, $numberOfSchools, $chosenClass, $chosenSector, $chosenCourse, $epalUser = null)
{
$error_code = 0;
if ($numberOfSchools < 1) {
......@@ -386,6 +386,34 @@ class ApplicationSubmit extends ControllerBase
return 1023;
}
// second period: check if application exists
if ($student['second_period'] == 1 && $epalUser !== null) {
$esQuery = $this->connection->select('epal_student', 'es')
->fields('es',
array('name',
'studentsurname',
'birthdate',
));
$esQuery->condition('es.epaluser_id', $epalUser->id(), '=');
$existing = $esQuery->execute()->fetchAll(\PDO::FETCH_OBJ);
/* $existing = $this->entityTypeManager->getStorage('epal_student')
->loadByProperties(['epaluser_id' => $epalUser->id->value]); */
if ($existing && sizeof($existing) > 0) {
$crypt = new Crypt();
foreach ($existing as $candidate) {
if (($crypt->decrypt($candidate->name) == $student['name'])
&& ($crypt->decrypt($candidate->studentsurname) == $student['studentsurname'])
&& ($candidate->birthdate == $student['birthdate'])
) {
return 8004;
}
}
}
}
// check as per specs:
// - can't check certification prior to 2014, pass through
// - check certification if last passed class is gym
......
......@@ -62,6 +62,20 @@ class SubmitedApplications extends ControllerBase
$authToken = $request->headers->get('PHP_AUTH_USER');
$transaction = $this->connection->startTransaction();
try {
//ανάκτηση τιμής από ρυθμίσεις διαχειριστή για lock_results
$config_storage = $this->entityTypeManager->getStorage('epal_config');
$epalConfigs = $config_storage->loadByProperties(array('name' => 'epal_config'));
$epalConfig = reset($epalConfigs);
if (!$epalConfig) {
return $this->respondWithStatus([
'message' => t("EpalConfig Enity not found"),
], Response::HTTP_FORBIDDEN);
}
else if ($epalConfig->lock_application->value) {
return $this->respondWithStatus([
"error_code" => 3002
], Response::HTTP_FORBIDDEN);
}
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken));
$epalUser = reset($epalUsers);
if ($epalUser) {
......@@ -281,6 +295,182 @@ class SubmitedApplications extends ControllerBase
}
}
public function getApplicationDetails(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) {
$config_storage = $this->entityTypeManager->getStorage('epal_config');
$epalConfigs = $config_storage->loadByProperties(array('name' => 'epal_config'));
$epalConfig = reset($epalConfigs);
if (!$epalConfig) {
return $this->respondWithStatus([
'message' => t("EpalConfig Enity not found"),
], Response::HTTP_FORBIDDEN);
}
else {
$applicantsResultsDisabled = $epalConfig->lock_results->value;
}
$status = "0";
$schoolName = '';
$schoolAddress = '';
$schoolTel = '';
$esQuery = $this->connection->select('epal_student', 'es')
->fields('es',
array('name',
'studentsurname',
'fatherfirstname',
'motherfirstname',
'regionaddress',
'regiontk',
'regionarea',
'relationtostudent',
'telnum',
'guardian_name',
'guardian_surname',
'guardian_fathername',
'guardian_mothername',
'id',
'lastschool_schoolname',
'lastschool_schoolyear',
'lastschool_class',
'currentclass',
'birthdate',
'created',
))
->fields('esec',
array('choice_no'
))
->fields('eesch',
array('name'
))
->fields('eese',
array('name',
))
->fields('eesp',
array('name',
))
->fields('esc',
array('finalized',
))
->fields('eeschfin',
array('id',
'name',
'street_address',
'phone_number'
));
$esQuery->addJoin('left outer', 'epal_student_epal_chosen', 'esec', 'es.id=esec.student_id');
$esQuery->addJoin('left outer', 'eepal_school_field_data', 'eesch', 'esec.epal_id=eesch.id');
$esQuery->addJoin('left outer', 'epal_student_sector_field', 'essf', 'es.id=essf.student_id');
$esQuery->addJoin('left outer', 'eepal_sectors_field_data', 'eese', 'essf.sectorfield_id=eese.id');
$esQuery->addJoin('left outer', 'epal_student_course_field', 'escf', 'es.id=escf.student_id');
$esQuery->addJoin('left outer', 'eepal_specialty_field_data', 'eesp', 'escf.coursefield_id=eesp.id');
$esQuery->addJoin('left outer', 'epal_student_class', 'esc', 'es.id=esc.student_id');
$esQuery->addJoin('left outer', 'eepal_school_field_data', 'eeschfin', 'esc.epal_id=eeschfin.id');
$esQuery->condition('es.id', intval($studentId), '=');
$esQuery->condition('es.epaluser_id', $epalUser->id(), '=');
$esQuery->orderBy('esec.choice_no');
$epalStudents = $esQuery->execute()->fetchAll(\PDO::FETCH_OBJ);
if ($epalStudents && sizeof($epalStudents) > 0) {
$epalSchoolsChosen = array();
foreach ($epalStudents as $es) {
array_push($epalSchoolsChosen, array(
'epal_id' => $es->eesch_name,
'choice_no' => $es->choice_no,
));
}
$epalStudent = reset($epalStudents);
$list = array();
$crypt = new Crypt();
try {
$name_decoded = $crypt->decrypt($epalStudent->name);
$studentsurname_decoded = $crypt->decrypt($epalStudent->studentsurname);
$fatherfirstname_decoded = $crypt->decrypt($epalStudent->fatherfirstname);
$motherfirstname_decoded = $crypt->decrypt($epalStudent->motherfirstname);
$regionaddress_decoded = $crypt->decrypt($epalStudent->regionaddress);
$regiontk_decoded = $crypt->decrypt($epalStudent->regiontk);
$regionarea_decoded = $crypt->decrypt($epalStudent->regionarea);
$relationtostudent_decoded = $crypt->decrypt($epalStudent->relationtostudent);
$telnum_decoded = $crypt->decrypt($epalStudent->telnum);
$guardian_name_decoded = $crypt->decrypt($epalStudent->guardian_name);
$guardian_surname_decoded = $crypt->decrypt($epalStudent->guardian_surname);
$guardian_fathername_decoded = $crypt->decrypt($epalStudent->guardian_fathername);
$guardian_mothername_decoded = $crypt->decrypt($epalStudent->guardian_mothername);
} catch (\Exception $e) {
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);
if ($epalStudent->finalized === null) {
$status = "0";
}
else if ($epalStudent->finalized === "1") {
$status = "1";
} else {
$status = "2";
}
$list[] = array(
'applicationId' => $epalStudent->id,
'name' => $name_decoded,
'studentsurname' => $studentsurname_decoded,
'fatherfirstname' => $fatherfirstname_decoded,
'fathersurname' => $epalStudent->fathersurname,
'motherfirstname' => $motherfirstname_decoded,
'mothersurname' => $epalStudent->mothersurname,
'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,
'lastschool_schoolyear' => $epalStudent->lastschool_schoolyear,
'lastschool_class' => $epalStudent->lastschool_class,
'currentclass' => $epalStudent->currentclass,
'currentsector' => $epalStudent->eese_name,
'currentcourse' => $epalStudent->eesp_name,
'regionaddress' => $regionaddress_decoded,
'regiontk' => $regiontk_decoded,
'regionarea' => $regionarea_decoded,
'telnum' => $telnum_decoded,
'relationtostudent' => $relationtostudent_decoded,
'birthdate' => substr($epalStudent->birthdate, 8, 2).'/'.substr($epalStudent->birthdate, 5, 2).'/'.substr($epalStudent->birthdate, 0, 4),
'created' => date('d/m/Y H:i', $epalStudent->created),
'epalSchoolsChosen' => $epalSchoolsChosen,
'applicantsResultsDisabled' => $applicantsResultsDisabled,
'status' => $status,
'schoolName' => $epalStudent->eeschfin_name,
'schoolAddress' => $epalStudent->street_address,
'schoolTel' => $epalStudent->phone_number,
);
return $this->respondWithStatus(
$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!!!!'),
], Response::HTTP_FORBIDDEN);
}
}
public function getEpalChosen(Request $request, $studentId)
{
$authToken = $request->headers->get('PHP_AUTH_USER');
......@@ -401,6 +591,11 @@ class SubmitedApplications extends ControllerBase
$applicantsResultsDisabled = $epalConfig->lock_results->getString();
}
$status = "0";
$schoolName = '';
$schoolAddress = '';
$schoolTel = '';
//ανάκτηση αποτελέσματος
// εύρεση τοποθέτησης (περίπτωση μαθητή που τοποθετήθηκε "οριστικά")
......
......@@ -23,9 +23,9 @@ import { API_ENDPOINT, API_ENDPOINT_PARAMS } from '../app.settings';
<form [formGroup]="formGroup" method = "POST" action="{{apiEndPoint}}/oauth/login{{apiEndPointParams}}" #form>
<!-- <input type="hidden" name="X-oauth-enabled" value="true"> -->
<div class="text-center bg-warning" style="padding: 2em;"><p>
<strong>Ανακοίνωση:</strong> τη Δευτέρα <strong>26/6/2017</strong>
το σύστημα θα είναι διαθέσιμο<br/> <strong>μετά τις 13:00</strong> λόγω εργασιών συντήρησης.</p></div>
<!-- <div class="text-center bg-warning" style="padding: 2em;"><p>
<strong>Ανακοίνωση:</strong> τη Δευτέρα <strong>26/6/2017</strong>
το σύστημα θα είναι διαθέσιμο<br/> <strong>μετά τις 13:00</strong> λόγω εργασιών συντήρησης.</p></div> -->
<div *ngFor="let loginInfoToken$ of loginInfo$ | async; let i=index"></div>
<div class="row" style="min-height: 300px; margin-top: 100px;">
......
......@@ -440,6 +440,11 @@ import { HelperDataService } from "../../services/helper-data-service";
mText = "Τα στοιχεία φοίτησης που υποβάλλατε δεν είναι έγκυρα. Παρακαλώ ελέγξτε τη φόρμα σας και προσπαθήστε ξανά. Εάν το θέμα συνεχίσει να υφίσταται, επικοινωνήστε με την ομάδα υποστήριξης.";
mHeader = "modal-header-danger";
break;
case 8004:
mTitle = "Αποτυχία Υποβολής Δήλωσης Προτίμησης";
mText = "Τα στοιχεία φοίτησης που υποβάλλατε δεν είναι έγκυρα. Παρακαλώ ελέγξτε τη φόρμα σας και προσπαθήστε ξανά. Ελέγξτε επίσης αν έχετε ήδη κάνει δήλωση για τον ίδιο μαθητή.";
mHeader = "modal-header-danger";
break;
default:
mTitle = "Αποτυχία Υποβολής Δήλωσης Προτίμησης";
mText = "Ελέξτε τη φόρμα σας. Υπάρχουν λάθη - ελλείψεις που δεν επιτρέπουν την υποβολή.";
......
......@@ -89,25 +89,22 @@ import {Location} from '@angular/common';
<div style="width: 100%">
<div *ngFor="let StudentDetails$ of SubmitedDetails$ | async" [hidden]="UserData$.id !== applicationIdActive" style="margin: 10px 10px 10px 10px;">
<div *ngFor="let StudentResult$ of StudentResults$ | async">
<div *ngIf = "StudentResult$.applicantsResultsDisabled == '0'" >
<div *ngIf = "StudentResult$.status == '1'" >
<div *ngIf = "StudentDetails$.applicantsResultsDisabled == '0'" >
<div *ngIf = "StudentDetails$.status == '1'" >
<div class="col-md-12" style="font-size: 1.0em; color: #143147; font-weight: bold;">
Η αίτησή σας ικανοποιήθηκε. Έχετε επιλεγεί για να εγγραφείτε στο {{StudentResult$.schoolName}}.
Παρακαλώ να προσέλθετε ΑΜΕΣΑ στο σχολείο για να προχωρήσει η διαδικασία εγγραφής σας σε αυτό, επισυνάπτοντας τα απαραίτητα δικαιολογητικά.
Διεύθυνση σχολείου: {{StudentResult$.schoolAddress}}, Τηλέφωνο σχολείου: {{StudentResult$.schoolTel}}<br><br>
Η αίτησή σας ικανοποιήθηκε. Έχετε επιλεγεί για να εγγραφείτε στο {{StudentDetails$.schoolName}}.
Παρακαλώ να προσέλθετε ΑΜΕΣΑ στο σχολείο για να προχωρήσει η διαδικασία εγγραφής σας σε αυτό, προσκομίζοντας τα απαραίτητα δικαιολογητικά. Διεύθυνση σχολείου: {{StudentDetails$.schoolAddress}}, Τηλέφωνο σχολείου: {{StudentDetails$.schoolTel}}<br><br>
</div>
</div>
<div *ngIf = "StudentResult$.status != '1'" >
<div *ngIf = "StudentDetails$.status != '1'" >
<div class="col-md-12" style="font-size: 1.0em; color: #a52a2a; font-weight: bold;">
Η αίτησή σας δεν ήταν δυνατό να ικανοποιηθεί. Παρακαλώ επικοινωνήστε άμεσα τηλεφωνικά με τη Διεύθυνση Δευτεροβάθμιας Εκπαίδευσης στην οποία ανήκετε,
προκειμένου να διερευνηθεί εκ νέου η δυνατότητα εγγραφής σας.<br><br>
Η αίτησή σας είναι σε εκκρεμότητα. Για την τοποθέτησή σας και τις ενέργειες που πρέπει να κάνετε θα ενημερωθείτε με νέο μήνυμα, με τον ίδιο τρόπο, μετά τις 8-7-2017.<br><br>
</div>
</div>
</div>
</div>
<div class="row oddin" style="margin: 0px 2px 0px 2px; line-height: 2em;">
<div class="col-md-3" style="font-size: 0.8em;">Αριθμός Δήλωσης Προτίμησης ΕΠΑΛ</div>
......@@ -203,7 +200,7 @@ import {Location} from '@angular/common';
<div class="col-md-6" style="font-size: 1em; font-weight: bold;">Επιλογή ΕΠΑΛ</div>
</div>
<div class="row oddin" style="margin: 0px 2px 0px 2px; line-height: 2em;" *ngFor="let epalChoices$ of EpalChosen$ | async; let i=index; let isOdd=odd; let isEven=even" [hidden]="UserData$.id !== applicationIdActive">
<div class="row oddin" style="margin: 0px 2px 0px 2px; line-height: 2em;" *ngFor="let epalChoices$ of StudentDetails$['epalSchoolsChosen']; let i=index; let isOdd=odd; let isEven=even" [hidden]="UserData$.id !== applicationIdActive">
<div class="col-md-6" style="font-size: 0.8em; font-weight: bold; text-align: center;">{{epalChoices$.choice_no}}</div>
<div class="col-md-6" style="font-size: 0.8em; font-weight: bold;">{{epalChoices$.epal_id}}</div>
</div>
......@@ -253,14 +250,6 @@ import {Location} from '@angular/common';
private SubmitedUsersSub: Subscription;
private SubmitedDetails$: BehaviorSubject<any>;
private SubmitedDetailsSub: Subscription;
private EpalChosen$: BehaviorSubject<any>;
private EpalChosenSub: Subscription;
private incomeChosen$: BehaviorSubject<any>;
private incomeChosenSub: Subscription;
private CritirioChosen$: BehaviorSubject<any>;
private CritirioChosenSub: Subscription;
private StudentResults$: BehaviorSubject<any>;
private StudentResultsSub: Subscription;
private showLoader$: BehaviorSubject<boolean>;
public isModalShown: BehaviorSubject<boolean>;
private applicationIdActive = <number>-1;
......@@ -278,13 +267,8 @@ import {Location} from '@angular/common';
) {
this.SubmitedApplic$ = new BehaviorSubject([{}]);
this.SubmitedDetails$ = new BehaviorSubject([{}]);
this.EpalChosen$ = new BehaviorSubject([{}]);
this.CritirioChosen$ = new BehaviorSubject([{}]);
this.incomeChosen$ = new BehaviorSubject([{}]);
this.showLoader$ = new BehaviorSubject(false);
this.isModalShown = new BehaviorSubject(false);
this.StudentResults$ = new BehaviorSubject([{}]);
}
ngOnDestroy() {
......@@ -294,20 +278,8 @@ import {Location} from '@angular/common';
this.SubmitedUsersSub.unsubscribe();
if (this.SubmitedDetailsSub)
this.SubmitedDetailsSub.unsubscribe();
if (this.EpalChosenSub)
this.EpalChosenSub.unsubscribe();
if (this.CritirioChosenSub)
this.CritirioChosenSub.unsubscribe();
if (this.incomeChosenSub)
this.incomeChosenSub.unsubscribe();
if (this.StudentResultsSub)
this.StudentResultsSub.unsubscribe();
this.SubmitedDetails$.unsubscribe();
this.EpalChosen$.unsubscribe();
this.SubmitedApplic$.unsubscribe();
this.StudentResults$.unsubscribe();
}
ngOnInit() {
......@@ -347,25 +319,6 @@ import {Location} from '@angular/common';
this.showLoader$.next(false);
});
this.EpalChosenSub = this._hds.getEpalchosen(this.applicationIdActive).subscribe(data => {
this.EpalChosen$.next(data);
},
error => {
this.EpalChosen$.next([{}]);
console.log("Error Getting Schools");
});
this.StudentResultsSub = this._hds.showResults(this.applicationIdActive).subscribe(data => {
this.StudentResults$.next(data);
this.showLoader$.next(false);
},
error => {
this.StudentResults$.next([{}]);
console.log("Error Getting Results");
this.showLoader$.next(false);
});
}
createPdfServerSide() {
......@@ -373,22 +326,6 @@ import {Location} from '@angular/common';
}
/*
showResults() {
this.StudentResultsSub = this._hds.showResults(this.applicationIdActive).subscribe(data => {
this.StudentResults$.next(data);
this.showLoader$.next(false);
},
error => {
this.StudentResults$.next([{}]);
console.log("Error Getting Results");
this.showLoader$.next(false);
});
}
*/
deleteApplication(appId: number): void {
this.applicationId = appId;
this.showConfirmModal();
......
......@@ -487,7 +487,7 @@ export class HelperDataService implements OnInit, OnDestroy {
});
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers });
return this.http.get(`${AppSettings.API_ENDPOINT}/epal/student/` + headerIdNew, options)
return this.http.get(`${AppSettings.API_ENDPOINT}/epal/application/` + headerIdNew, options)
.map(response => response.json());
}
......@@ -509,8 +509,6 @@ export class HelperDataService implements OnInit, OnDestroy {
getStudentPerSchool(classId, sector, specialit) {
this.loginInfo$.getValue().forEach(loginInfoToken => {
......@@ -997,7 +995,7 @@ export class HelperDataService implements OnInit, OnDestroy {
});
}
showResults(headerid) {
/* showResults(headerid) {
let headers = new Headers({
"Content-Type": "application/json",
......@@ -1008,7 +1006,7 @@ export class HelperDataService implements OnInit, OnDestroy {
return this.http.get(`${AppSettings.API_ENDPOINT}/epal/showresults/` + headerIdStr, options)
.map(response => response.json());
}
} */
findTotalStudents() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment