added showResults functionality in application preview

parent 933a4aa0
......@@ -301,4 +301,12 @@ epal.user.send_email:
defaults:
_controller: '\Drupal\epal\Controller\HelpDesk::sendEmail'
requirements:
_user_is_logged_in: 'TRUE'
\ No newline at end of file
_user_is_logged_in: 'TRUE'
epal.applicant.showresults:
path: '/epal/showresults/{studentId}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\SubmitedApplications::getResults'
requirements:
_user_is_logged_in: 'TRUE'
......@@ -394,6 +394,95 @@ class SubmitedApplications extends ControllerBase
}
}
public function getResults(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) {
$list = array();
//ανάκτηση τιμής από ρυθμίσεις διαχειριστή για 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 {
$applicantsResultsDisabled = $epalConfig->lock_results->getString();
}
//ανάκτηση αποτελέσματος
// εύρεση τοποθέτησης (περίπτωση μαθητή που τοποθετήθηκε "οριστικά")
if ($applicantsResultsDisabled === "0") {
$sCon = $this->connection->select('epal_student_class', 'eStudent')
->fields('eStudent', array('student_id', 'epal_id', 'finalized'))
->condition('eStudent.student_id', intval($studentId), '=');
//->condition('eStudent.finalized', "1" , '=');
$epalStudents = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
if (sizeof($epalStudents) === 1) {
$epalStudent = reset($epalStudents);
$sCon = $this->connection->select('eepal_school_field_data', 'eSchool')
->fields('eSchool', array('id', 'name', 'street_address','phone_number'))
->condition('eSchool.id', $epalStudent->epal_id, '=');
$epalSchools = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
//status: 0: δεν τοποθετήθηκε, 1: τοποθετήθηκε, 2: τοποθετήθηκε "προσωρινά" σε ολιγομελές
if (sizeof($epalSchools) === 1) {
$epalSchool = reset($epalSchools);
if ($epalStudent->finalized === "1") {
$status = "1";
$schoolName = $epalSchool->name;
$schoolAddress = $epalSchool->street_address;
$schoolTel = $epalSchool->phone_number;
}
else {
$status = "2";
}
}
}
else {
$status = "0";
}
} //endif $applicantsResultsDisabled === "0"
$list[] = array(
'applicantsResultsDisabled' => $applicantsResultsDisabled,
'status' => $status,
'schoolName' => $schoolName,
'schoolAddress' => $schoolAddress,
'schoolTel' => $schoolTel,
);
return $this->respondWithStatus(
$list, Response::HTTP_OK);
}
else {
return $this->respondWithStatus([
'message' => t('EPAL user not found'),
], Response::HTTP_FORBIDDEN);
}
}
}
private function respondWithStatus($arr, $s)
{
$res = new JsonResponse($arr);
......
......@@ -70,6 +70,26 @@ 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 class="col-md-12" style="font-size: 1.0em; color: #a52a2a;">
Η αίτησή σας ικανοποιήθηκε. Έχετε επιλεγεί για να εγγραφείτε στο {{StudentResult$.schoolName}}.
Παρακαλώ να προσέλθετε ΑΜΕΣΑ στο σχολείο για να προχωρήσει η διαδικασία εγγραφής σας σε αυτό, επισυνάπτοντας τα απαραίτητα δικαιολογητικά.
Διεύθυνση σχολείου: {{StudentResult$.schoolAddress}}, Τηλέφωνο σχολείου: {{StudentResult$.schoolTel}}<br><br>
</div>
</div>
<div *ngIf = "StudentResult$.status != '1'" >
<div class="col-md-12" style="font-size: 1.0em; color: #a52a2a;">
Η αίτησή σας δεν ήταν δυνατό να ικανοποιηθεί. Παρακαλώ επικοινωνήστε άμεσα τηλεφωνικά με τη Διεύθυνση Δευτεροβάθμιας Εκπαίδευσης στην οποία ανήκετε,
προκειμένου να διερευνηθεί εκ νέου η δυνατότητα εγγραφής σας.<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>
<div class="col-md-3" style="font-size: 0.8em; font-weight: bold">{{StudentDetails$.applicationId}}</div>
......@@ -170,13 +190,20 @@ import {Location} from '@angular/common';
</div>
<div class="row" style="margin-top: 20px; margin-bottom: 20px;">
<!--
<div class="col-md-6">
<button type="button" class="btn-primary btn-lg pull-left isclickable" style="width: 10em;" (click)="showResults()" [hidden] = "StudentDetails$.applicantsResultsDisabled == '0'">
<span style="font-size: 0.9em; font-weight: bold;">Αποτελέσματα</span>
</button>
</div>
-->
<div class="col-md-12">
<button type="button" class="btn-primary btn-lg pull-right isclickable" style="width: 10em;" (click)="createPdfServerSide()">
<span style="font-size: 0.9em; font-weight: bold;">Εκτύπωση(PDF)&nbsp;&nbsp;&nbsp;</span>
</button>
</div>
</div>
</div>
</div>
......@@ -213,6 +240,8 @@ import {Location} from '@angular/common';
private incomeChosenSub: Subscription;
private CritirioChosen$: BehaviorSubject<any>;
private CritirioChosenSub: Subscription;
private StudentResults$: BehaviorSubject<any>;
private StudentResultsSub: Subscription;
private showLoader$: BehaviorSubject<boolean>;
private modalTitle: BehaviorSubject<string>;
private modalText: BehaviorSubject<string>;
......@@ -243,6 +272,7 @@ import {Location} from '@angular/common';
this.modalHeader = new BehaviorSubject("");
this.modalHeaderIcon = new BehaviorSubject("");
this.isModalShown = new BehaviorSubject(false);
this.StudentResults$ = new BehaviorSubject([{}]);
}
......@@ -258,10 +288,13 @@ import {Location} from '@angular/common';
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();
}
......@@ -310,12 +343,39 @@ import {Location} from '@angular/common';
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() {
this._hds.createPdfServerSide(this.applicationIdActive);
}
/*
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.modalTitle.next("Διαγραφή Δήλωσης Προτίμησης ΕΠΑΛ");
this.modalText.next("Επιλέξατε να διαγράψετε τη δήλωση προτίμησης ΕΠΑΛ. Παρακαλούμε επιλέξτε Επιβεβαίωση");
......
......@@ -998,6 +998,19 @@ export class HelperDataService implements OnInit, OnDestroy {
});
}
showResults(headerid) {
let headers = new Headers({
"Content-Type": "application/json",
});
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers });
let headerIdStr = headerid.toString();
return this.http.get(`${AppSettings.API_ENDPOINT}/epal/showresults/` + headerIdStr, options)
.map(response => response.json());
}
......
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