Updated SubmittedApplications Controller in order to support app deletions...

Updated SubmittedApplications Controller in order to support app deletions from the Director, updated InformStudent Controller/Component in order to manage two application periods
parent 67978471
...@@ -191,29 +191,35 @@ epal.ministry.retrieve-registry-id: ...@@ -191,29 +191,35 @@ epal.ministry.retrieve-registry-id:
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
epal.ministry.massive_mail_unallocated: epal.ministry.massive_mail_unallocated:
path: '/ministry/send-unallocated-massive-mail' path: '/ministry/send-unallocated-massive-mail/{period}'
options: options:
_auth: [ 'basic_auth' ] _auth: [ 'basic_auth' ]
defaults: defaults:
_controller: '\Drupal\epal\Controller\InformUnlocatedStudents::sendMailToUnallocatedStudents' _controller: '\Drupal\epal\Controller\InformUnlocatedStudents::sendMailToUnallocatedStudents'
period: 2
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
period: ^[0,1,2]$
epal.ministry.massive_mail_unallocated_smallclass: epal.ministry.massive_mail_unallocated_smallclass:
path: '/ministry/send-unallocated-sc-massive-mail' path: '/ministry/send-unallocated-sc-massive-mail/{period}'
options: options:
_auth: [ 'basic_auth' ] _auth: [ 'basic_auth' ]
defaults: defaults:
_controller: '\Drupal\epal\Controller\InformUnlocatedStudents::sendMailToUnallocatedStudentsSC' _controller: '\Drupal\epal\Controller\InformUnlocatedStudents::sendMailToUnallocatedStudentsSC'
period: 2
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
period: ^[0,1,2]$
epal.ministry.massive_mail_located: epal.ministry.massive_mail_located:
path: '/ministry/send-located-massive-mail' path: '/ministry/send-located-massive-mail/{period}'
options: options:
_auth: [ 'basic_auth' ] _auth: [ 'basic_auth' ]
defaults: defaults:
_controller: '\Drupal\epal\Controller\InformUnlocatedStudents::sendMailToLocatedStudents' _controller: '\Drupal\epal\Controller\InformUnlocatedStudents::sendMailToLocatedStudents'
period: 2
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
period: ^[0,1,2]$
epal.ministry.retrievesettings: epal.ministry.retrievesettings:
path: '/ministry/retrieve-settings' path: '/ministry/retrieve-settings'
options: options:
...@@ -326,3 +332,11 @@ epal.totalstudents: ...@@ -326,3 +332,11 @@ epal.totalstudents:
_controller: '\Drupal\epal\Controller\HelpDesk::findTotalStudents' _controller: '\Drupal\epal\Controller\HelpDesk::findTotalStudents'
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
epal.application_delete_director:
path: '/epal/application/deleteFromDirector'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\SubmitedApplications::deleteApplicationFromDirector'
requirements:
_user_is_logged_in: 'TRUE'
...@@ -612,14 +612,14 @@ class SubmitedApplications extends ControllerBase ...@@ -612,14 +612,14 @@ class SubmitedApplications extends ControllerBase
if ($applicantsResultsDisabled === "0") { if ($applicantsResultsDisabled === "0") {
$escQuery = $this->connection->select('epal_student_class', 'esc') $escQuery = $this->connection->select('epal_student_class', 'esc')
->fields('esc', array('student_id', 'epal_id', 'finalized')) ->fields('esc', array('student_id', 'epal_id', 'finalized'))
->fields('esch', array('id', 'name', 'street_address','phone_number')); ->fields('esch', array('id', 'name', 'street_address','phone_number'));
$escQuery->addJoin('inner', 'eepal_school_field_data', 'esch', 'esc.epal_id=esch.id'); $escQuery->addJoin('inner', 'eepal_school_field_data', 'esch', 'esc.epal_id=esch.id');
$escQuery->condition('esc.student_id', intval($studentId), '='); $escQuery->condition('esc.student_id', intval($studentId), '=');
//$escQuery->condition('esc.second_period', intval($secondPeriodEnabled), '='); //$escQuery->condition('esc.second_period', intval($secondPeriodEnabled), '=');
$epalStudentClasses = $escQuery->execute()->fetchAll(\PDO::FETCH_OBJ); $epalStudentClasses = $escQuery->execute()->fetchAll(\PDO::FETCH_OBJ);
if (sizeof($epalStudentClasses) === 1) { if (sizeof($epalStudentClasses) === 1) {
$epalStudentClass = reset($epalStudentClasses); $epalStudentClass = reset($epalStudentClasses);
...@@ -668,6 +668,132 @@ class SubmitedApplications extends ControllerBase ...@@ -668,6 +668,132 @@ class SubmitedApplications extends ControllerBase
} }
public function deleteApplicationFromDirector(Request $request)
{
if (!$request->isMethod('POST')) {
return $this->respondWithStatus([
"error_code" => 2001
], Response::HTTP_METHOD_NOT_ALLOWED);
}
$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());
return $this->respondWithStatus([
"message" => "No access to this school"
], Response::HTTP_FORBIDDEN);
}
$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') {
$content = $request->getContent();
$applicationId = 0;
if (!empty($content)) {
$postArr = json_decode($content, TRUE);
$applicationId = $postArr['applicationId'];
}
else {
return $this->respondWithStatus([
"error_code" => 5002
], Response::HTTP_BAD_REQUEST);
}
$transaction = $this->connection->startTransaction();
try {
//ανάκτηση τιμής από ρυθμίσεις διαχειριστή για lock_school_students_view
$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_school_students_view->value) {
return $this->respondWithStatus([
"error_code" => 3002
], Response::HTTP_FORBIDDEN);
}
//$userid = $epalUser->id();
$epalStudents = $this->entityTypeManager->getStorage('epal_student')->loadByProperties(array( 'id' => $applicationId));
$epalStudent = reset($epalStudents);
if ($epalStudent) {
$epalStudentClasses = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('student_id' => $applicationId));
$epalStudentClass = reset($epalStudentClasses);
if ($epalStudentClass) {
if ($epalStudentClass->directorconfirm->value === "1") {
return $this->respondWithStatus([
"error_code" => -1
], Response::HTTP_FORBIDDEN);
}
}
$delQuery = $this->connection->delete('epal_student_epal_chosen');
$delQuery->condition('student_id', $applicationId);
$delQuery->execute();
$delQuery = $this->connection->delete('epal_student_sector_field');
$delQuery->condition('student_id', $applicationId);
$delQuery->execute();
$delQuery = $this->connection->delete('epal_student_course_field');
$delQuery->condition('student_id', $applicationId);
$delQuery->execute();
$delQuery = $this->connection->delete('epal_student_class');
$delQuery->condition('student_id', $applicationId);
$delQuery->execute();
$epalStudent->delete();
return $this->respondWithStatus([
'error_code' => 0,
], Response::HTTP_OK);
} else {
return $this->respondWithStatus([
'message' => t('EPAL student not found'),
], Response::HTTP_FORBIDDEN);
}
} catch (\Exception $e) {
$this->logger->warning($e->getMessage());
$transaction->rollback();
return $this->respondWithStatus([
'error_code' => 5001,
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
}
}
private function respondWithStatus($arr, $s) private function respondWithStatus($arr, $s)
{ {
$res = new JsonResponse($arr); $res = new JsonResponse($arr);
...@@ -675,4 +801,4 @@ class SubmitedApplications extends ControllerBase ...@@ -675,4 +801,4 @@ class SubmitedApplications extends ControllerBase
return $res; return $res;
} }
} }
\ No newline at end of file
import { Component, OnInit, OnDestroy, ElementRef, ViewChild} from "@angular/core"; import { Component, OnInit, OnDestroy, ElementRef, ViewChild } from "@angular/core";
import { Injectable } from "@angular/core"; import { Injectable } from "@angular/core";
import { AppSettings } from '../../app.settings'; import { AppSettings } from '../../app.settings';
import { HelperDataService } from '../../services/helper-data-service'; import { HelperDataService } from '../../services/helper-data-service';
import { Observable} from "rxjs/Observable"; import { Observable } from "rxjs/Observable";
import { Http, Headers, RequestOptions} from '@angular/http'; import { Http, Headers, RequestOptions } from '@angular/http';
import { NgRedux, select } from 'ng2-redux'; import { NgRedux, select } from 'ng2-redux';
import { IAppState } from '../../store/store'; 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 { BehaviorSubject, Subscription } from 'rxjs/Rx';
import { ILoginInfo } from '../../store/logininfo/logininfo.types'; import { ILoginInfo } from '../../store/logininfo/logininfo.types';
import { LOGININFO_INITIAL_STATE } from '../../store/logininfo/logininfo.initial-state'; import { LOGININFO_INITIAL_STATE } from '../../store/logininfo/logininfo.initial-state';
...@@ -20,8 +20,6 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -20,8 +20,6 @@ import { API_ENDPOINT } from '../../app.settings';
class = "loading" *ngIf="successSending == -2" > class = "loading" *ngIf="successSending == -2" >
</div> </div>
<div style="min-height: 400px;">
<div id="emaiSentNotice" (onHidden)="onHidden()" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true"> <div id="emaiSentNotice" (onHidden)="onHidden()" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg"> <div class="modal-dialog modal-lg">
<div class="modal-content"> <div class="modal-content">
...@@ -43,24 +41,67 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -43,24 +41,67 @@ import { API_ENDPOINT } from '../../app.settings';
<h5> >Αποστολή ειδοποιήσεων <br></h5> <h5> >Αποστολή ειδοποιήσεων <br></h5>
<br><br> <br><br>
<div class="col-md-12"> <div class="row" style="margin: 2em 0 2em 0;">
<button type="submit" class="btn btn-lg btn-block" *ngIf="(loginInfo$ | async).size !== 0" (click)="informUnlocatedStudents(1)" [disabled] = "!applicantsResultsDisabled" > <div class="col-md-12">
Αποστολή e-mail στους μαθητές που ΔΕΝ τοποθετήθηκαν<span class="glyphicon glyphicon-menu-right"></span> <h3>Αποστολή e-mail στους μαθητές που ΔΕΝ τοποθετήθηκαν</h3>
</button> </div>
</div> <div class="col-md-4">
<br> <button type="submit" class="btn btn-lg btn-block" *ngIf="(loginInfo$ | async).size !== 0" (click)="informUnlocatedStudents(1, 0)" [disabled] = "!applicantsResultsDisabled" >
<div class="col-md-12"> Α' Περίοδος
<button type="submit" class="btn btn-lg btn-block" *ngIf="(loginInfo$ | async).size !== 0" (click)="informUnlocatedStudents(2)" [disabled] = "!applicantsResultsDisabled" > </button>
Αποστολή e-mail στους μαθητές που τοποθετήθηκαν προσωρινά σε ολιγομελή τμήματα<span class="glyphicon glyphicon-menu-right"></span> </div>
</button> <div class="col-md-4">
<button type="submit" class="btn btn-lg btn-block" *ngIf="(loginInfo$ | async).size !== 0" (click)="informUnlocatedStudents(1, 1)" [disabled] = "!applicantsResultsDisabled" >
B' Περίοδος
</button>
</div>
<div class="col-md-4">
<button type="submit" class="btn btn-lg btn-block" *ngIf="(loginInfo$ | async).size !== 0" (click)="informUnlocatedStudents(1, 2)" [disabled] = "!applicantsResultsDisabled" >
Α' και Β' Περίοδος
</button>
</div>
</div> </div>
<br>
<div class="col-md-12"> <div class="row" style="margin: 2em 0 2em 0;">
<button type="submit" class="btn btn-lg btn-block" *ngIf="(loginInfo$ | async).size !== 0" (click)="informUnlocatedStudents(3)" [disabled] = "!applicantsResultsDisabled"> <div class="col-md-12">
Αποστολή e-mail στους μαθητές που τοποθετήθηκαν<span class="glyphicon glyphicon-menu-right"></span> <h3>Αποστολή e-mail στους μαθητές που τοποθετήθηκαν προσωρινά σε ολιγομελή τμήματα</h3>
</button> </div>
<div class="col-md-4">
<button type="submit" class="btn btn-lg btn-block" *ngIf="(loginInfo$ | async).size !== 0" (click)="informUnlocatedStudents(2, 0)" [disabled] = "!applicantsResultsDisabled" >
Α' Περίοδος
</button>
</div>
<div class="col-md-4">
<button type="submit" class="btn btn-lg btn-block" *ngIf="(loginInfo$ | async).size !== 0" (click)="informUnlocatedStudents(2, 1)" [disabled] = "!applicantsResultsDisabled" >
B' Περίοδος
</button>
</div>
<div class="col-md-4">
<button type="submit" class="btn btn-lg btn-block" *ngIf="(loginInfo$ | async).size !== 0" (click)="informUnlocatedStudents(2, 2)" [disabled] = "!applicantsResultsDisabled" >
Α' και Β' Περίοδος
</button>
</div>
</div> </div>
<div class="row" style="margin: 2em 0 2em 0;">
<div class="col-md-12">
<h3>Αποστολή e-mail στους μαθητές που τοποθετήθηκαν</h3>
</div>
<div class="col-md-4">
<button type="submit" class="btn btn-lg btn-block" *ngIf="(loginInfo$ | async).size !== 0" (click)="informUnlocatedStudents(3, 0)" [disabled] = "!applicantsResultsDisabled" >
Α' Περίοδος
</button>
</div>
<div class="col-md-4">
<button type="submit" class="btn btn-lg btn-block" *ngIf="(loginInfo$ | async).size !== 0" (click)="informUnlocatedStudents(3, 1)" [disabled] = "!applicantsResultsDisabled" >
B' Περίοδος
</button>
</div>
<div class="col-md-4">
<button type="submit" class="btn btn-lg btn-block" *ngIf="(loginInfo$ | async).size !== 0" (click)="informUnlocatedStudents(3, 2)" [disabled] = "!applicantsResultsDisabled" >
Α' και Β' Περίοδος
</button>
</div>
</div> </div>
` `
...@@ -103,7 +144,7 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -103,7 +144,7 @@ import { API_ENDPOINT } from '../../app.settings';
this.loginInfoSub = this._ngRedux.select(state => { this.loginInfoSub = this._ngRedux.select(state => {
if (state.loginInfo.size > 0) { if (state.loginInfo.size > 0) {
state.loginInfo.reduce(({}, loginInfoToken) => { state.loginInfo.reduce(({ }, loginInfoToken) => {
this.minedu_userName = loginInfoToken.minedu_username; this.minedu_userName = loginInfoToken.minedu_username;
this.minedu_userPassword = loginInfoToken.minedu_userpassword; this.minedu_userPassword = loginInfoToken.minedu_userpassword;
return loginInfoToken; return loginInfoToken;
...@@ -150,27 +191,28 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -150,27 +191,28 @@ import { API_ENDPOINT } from '../../app.settings';
//this.isModalShown.next(false); //this.isModalShown.next(false);
} }
informUnlocatedStudents(unallocated) { informUnlocatedStudents(unallocated, period) {
this.successSending = -2; this.successSending = -2;
this.numSuccessMails = 0; this.numSuccessMails = 0;
this.numFailMails = 0; this.numFailMails = 0;
this._hds.informUnlocatedStudents(this.minedu_userName, this.minedu_userPassword, unallocated).subscribe(data => { this._hds.informUnlocatedStudents(this.minedu_userName, this.minedu_userPassword, unallocated, period)
this.numSuccessMails = data.num_success_mail; .subscribe(data => {
this.numFailMails = data.num_fail_mail; this.numSuccessMails = data.num_success_mail;
this.successSending = 1; this.numFailMails = data.num_fail_mail;
this.successSending = 1;
this.modalHeader.next("modal-header-success"); this.modalHeader.next("modal-header-success");
this.modalTitle.next("Κατανομή Μαθητών"); this.modalTitle.next("Κατανομή Μαθητών");
let txtModal = "Έγινε αποστολή " + this.numSuccessMails + " e-mails! "; let txtModal = "Έγινε αποστολή " + this.numSuccessMails + " e-mails! ";
if (this.numFailMails != 0) { if (this.numFailMails != 0) {
this.modalHeader.next("modal-header-warning"); this.modalHeader.next("modal-header-warning");
txtModal += "Κάποια e-mail δεν έχουν σταλεί. Δεν ήταν δυνατή η αποστολή " + this.numFailMails + " e-mails!"; txtModal += "Κάποια e-mail δεν έχουν σταλεί. Δεν ήταν δυνατή η αποστολή " + this.numFailMails + " e-mails!";
} }
this.modalText.next(txtModal); this.modalText.next(txtModal);
this.showModal(); this.showModal();
}, },
error => { error => {
console.log("Error"); console.log("Error");
this.successSending = 0; this.successSending = 0;
...@@ -184,19 +226,19 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -184,19 +226,19 @@ import { API_ENDPOINT } from '../../app.settings';
} }
retrieveSettings() { retrieveSettings() {
this.settingsSub = this._hds.retrieveAdminSettings(this.minedu_userName, this.minedu_userPassword)
this.settingsSub = this._hds.retrieveAdminSettings(this.minedu_userName, this.minedu_userPassword).subscribe(data => { .subscribe(data => {
this.settings$.next(data); this.settings$.next(data);
this.applicantsResultsDisabled = Boolean(Number(this.settings$.value['applicantsResultsDisabled'])); this.applicantsResultsDisabled = Boolean(Number(this.settings$.value['applicantsResultsDisabled']));
if (this.applicantsResultsDisabled == false) { if (this.applicantsResultsDisabled == false) {
this.modalTitle.next("Κατανομή Μαθητών"); this.modalTitle.next("Κατανομή Μαθητών");
this.modalText.next(("ΠΡΟΣΟΧΗ: Για να μπορείτε να αποστείλετε e-mail ενημέρωσης, παρακαλώ πηγαίνετε στις Ρυθμίσεις και ΕΝΕΡΓΟΠΟΙΗΣΤΕ ") + this.modalText.next(("ΠΡΟΣΟΧΗ: Για να μπορείτε να αποστείλετε e-mail ενημέρωσης, παρακαλώ πηγαίνετε στις Ρυθμίσεις και ΕΝΕΡΓΟΠΟΙΗΣΤΕ ") +
("τη δυνατότητα της προβολής αποτελεσμάτων κατανομής από τους μαθητές.")); ("τη δυνατότητα της προβολής αποτελεσμάτων κατανομής από τους μαθητές."));
this.modalHeader.next("modal-header-warning"); this.modalHeader.next("modal-header-warning");
this.showModal(); this.showModal();
} }
}, },
error => { error => {
this.settings$.next([{}]); this.settings$.next([{}]);
console.log("Error Getting MinisterRetrieveSettings"); console.log("Error Getting MinisterRetrieveSettings");
......
...@@ -662,7 +662,7 @@ export class HelperDataService implements OnInit, OnDestroy { ...@@ -662,7 +662,7 @@ export class HelperDataService implements OnInit, OnDestroy {
} }
informUnlocatedStudents(username, userpassword, unallocated) { informUnlocatedStudents(username, userpassword, unallocated, period) {
let headers = new Headers({ let headers = new Headers({
"Content-Type": "application/json", "Content-Type": "application/json",
...@@ -671,12 +671,13 @@ export class HelperDataService implements OnInit, OnDestroy { ...@@ -671,12 +671,13 @@ export class HelperDataService implements OnInit, OnDestroy {
let options = new RequestOptions({ headers: headers }); let options = new RequestOptions({ headers: headers });
let route = ""; let route = "";
if (unallocated == 1) if (unallocated == 1) {
route = "ministry/send-unallocated-massive-mail"; route = "ministry/send-unallocated-massive-mail/" + period;
else if (unallocated == 2) } else if (unallocated == 2) {
route = "ministry/send-unallocated-sc-massive-mail"; route = "ministry/send-unallocated-sc-massive-mail/" + period;
else if (unallocated == 3) } else if (unallocated == 3) {
route = "ministry/send-located-massive-mail"; route = "ministry/send-located-massive-mail/" + period;
}
return this.http.get(`${AppSettings.API_ENDPOINT}/` + route, options) return this.http.get(`${AppSettings.API_ENDPOINT}/` + route, options)
.map(response => response.json()); .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