Merge branch 'develop' into 'master'

Merge to master

See merge request !230
parents ad71778f 887da2d0
......@@ -11,6 +11,7 @@ use Drupal\Core\Database\Connection;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use phpCAS;
......@@ -190,10 +191,6 @@ class CASLogout extends ControllerBase
session_unset();
session_destroy();
\Drupal::service('page_cache_kill_switch')->trigger();
if ('casost_sch_sso_config' === $configRowName) {
return new RedirectResponse($this->redirectUrl.'&error_code=' . $errorCode, 302, []);
} else {
return new RedirectResponseWithCookieExt($this->redirectUrl .'&error_code=' . $errorCode, 302, []);
}
return new RedirectResponse($this->redirectUrl.'&error_code=' . $errorCode, 302, []);
}
}
......@@ -191,29 +191,35 @@ epal.ministry.retrieve-registry-id:
requirements:
_user_is_logged_in: 'TRUE'
epal.ministry.massive_mail_unallocated:
path: '/ministry/send-unallocated-massive-mail'
path: '/ministry/send-unallocated-massive-mail/{period}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\InformUnlocatedStudents::sendMailToUnallocatedStudents'
period: 2
requirements:
_user_is_logged_in: 'TRUE'
period: ^[0,1,2]$
epal.ministry.massive_mail_unallocated_smallclass:
path: '/ministry/send-unallocated-sc-massive-mail'
path: '/ministry/send-unallocated-sc-massive-mail/{period}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\InformUnlocatedStudents::sendMailToUnallocatedStudentsSC'
period: 2
requirements:
_user_is_logged_in: 'TRUE'
period: ^[0,1,2]$
epal.ministry.massive_mail_located:
path: '/ministry/send-located-massive-mail'
path: '/ministry/send-located-massive-mail/{period}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\InformUnlocatedStudents::sendMailToLocatedStudents'
period: 2
requirements:
_user_is_logged_in: 'TRUE'
period: ^[0,1,2]$
epal.ministry.retrievesettings:
path: '/ministry/retrieve-settings'
options:
......@@ -326,3 +332,11 @@ epal.totalstudents:
_controller: '\Drupal\epal\Controller\HelpDesk::findTotalStudents'
requirements:
_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
if ($applicantsResultsDisabled === "0") {
$escQuery = $this->connection->select('epal_student_class', 'esc')
->fields('esc', array('student_id', 'epal_id', 'finalized'))
$escQuery = $this->connection->select('epal_student_class', 'esc')
->fields('esc', array('student_id', 'epal_id', 'finalized'))
->fields('esch', array('id', 'name', 'street_address','phone_number'));
$escQuery->addJoin('inner', 'eepal_school_field_data', 'esch', 'esc.epal_id=esch.id');
$escQuery->condition('esc.student_id', intval($studentId), '=');
//$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) {
$epalStudentClass = reset($epalStudentClasses);
......@@ -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)
{
$res = new JsonResponse($arr);
......@@ -675,4 +801,4 @@ class SubmitedApplications extends ControllerBase
return $res;
}
}
}
\ No newline at end of file
......@@ -24,6 +24,46 @@ import {
@Component({
selector: 'director-classcapacity',
template: `
<div id="applicationDeleteConfirm" (onHidden)="onHidden()" class="modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header modal-header-danger">
<h3 class="modal-title pull-left"><i class="fa fa-close"></i>&nbsp;&nbsp;Διαγραφή Δήλωσης Προτίμησης ΕΠΑΛ</h3>
<button type="button" class="close pull-right" aria-label="Close" (click)="hideModal()">
<span aria-hidden="true"><i class="fa fa-times"></i></span>
</button>
</div>
<div class="modal-body">
<p>Επιλέξατε να διαγράψετε τη δήλωση προτίμησης ΕΠΑΛ. Παρακαλούμε επιλέξτε Επιβεβαίωση</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" (click)="hideConfirmModal()">Ακύρωση</button>
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" (click)="deleteApplicationDo()">Επιβεβαίωση</button>
</div>
</div>
</div>
</div>
<div id="applicationDeleteError" (onHidden)="onHidden()" class="modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header modal-header-danger">
<h3 class="modal-title pull-left"><i class="fa fa-ban"></i>&nbsp;&nbsp;Αποτυχία Διαγραφής Δήλωσης Προτίμησης ΕΠΑΛ</h3>
<button type="button" class="close pull-right" aria-label="Close" (click)="hideModal()">
<span aria-hidden="true"><i class="fa fa-times"></i></span>
</button>
</div>
<div class="modal-body">
<p>Η δήλωσή δεν διαγράφηκε. Δεν μπορείτε να διαγράψετε τη δήλωσή μαθητή εαν έχετε κάνει την επιβεβαίωση εγγραφής.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-right" data-dismiss="modal" (click)="hideErrorModal()">Κλείσιμο</button>
</div>
</div>
</div>
</div>
<div class = "loading" *ngIf="(showLoader | async) === true"></div>
<div style="min-height: 500px;">
<form [formGroup]="formGroup">
......@@ -55,6 +95,8 @@ import {
[class.oddout]="isOdd" [class.evenout]="isEven" style="margin: 0px 2px 0px 2px;">
<div class="col-md-5" style="font-size: 0.8em; font-weight: bold;" (click) ="setActiveStudent(j)" >{{StudentDetails$.studentsurname}}</div>
<div class="col-md-5" style="font-size: 0.8em; font-weight: bold;" (click) ="setActiveStudent(j)">{{StudentDetails$.name}}</div>
<div class="col-md-2" style="font-size: 1.5em; font-weight: bold;"><i class="fa fa-trash isclickable" (click)="deleteApplication(StudentDetails$.id, CoursesPerSchools$.class, CoursesPerSchools$.newsector, CoursesPerSchools$.newspecialit)"></i></div>
<div [hidden]="StudentActive !== j" class="col-md-2 pull-right" style="color: black;" > <span aria-hidden="true"><button type="button" class="btn-primary btn-sm pull-right" (click) ="setActiveStudentnew(j)">Κλείσιμο</button></span> </div>
<div style="width: 100%; color: #000000;">
......@@ -255,6 +297,10 @@ import {
private StudentActive = <number>-1;
private showLoader: BehaviorSubject<boolean>;
private opened;
private applicationId = <number>0;
private taxi = <number>0;
private sector = <number>0;
private special = <number>0;
......@@ -276,6 +322,21 @@ import {
}
public showConfirmModal(): void {
(<any>$('#applicationDeleteConfirm')).modal('show');
}
public showErrorModal(): void {
(<any>$('#applicationDeleteError')).modal('show');
}
public hideConfirmModal(): void {
(<any>$('#applicationDeleteConfirm')).modal('hide');
}
public hideErrorModal(): void {
(<any>$('#applicationDeleteError')).modal('hide');
}
public showModal(popupMsgId): void {
(<any>$(popupMsgId)).modal('show');
......@@ -292,13 +353,16 @@ import {
ngOnDestroy() {
(<any>$('#applicationDeleteConfirm')).remove();
(<any>$('#applicationDeleteError')).remove();
}
ngOnInit() {
(<any>$('#checksaved')).appendTo("body");
(<any>$('#dangermodal')).appendTo("body");
(<any>$('#emptyselection')).appendTo("body");
(<any>$('#applicationDeleteConfirm')).appendTo("body");
(<any>$('#applicationDeleteError')).appendTo("body");
this.showLoader.next(true);
this.CoursesPerSchoolSub = this._hds.FindCoursesPerSchool().subscribe(x => {
this.CoursesPerSchool$.next(x);
......@@ -387,4 +451,60 @@ import {
});
}
deleteApplication(appId: number, taxi, sector, special): void {
this.applicationId = appId;
this.taxi = taxi;
this.sector = sector;
this.special = special;
this.showConfirmModal();
}
deleteApplicationDo(): void {
this.hideConfirmModal();
this.showLoader.next(true);
this._hds.deleteApplicationforDirector(this.applicationId).then(data => {
this.StudentInfoSub.unsubscribe();
this.CoursesPerSchoolSub.unsubscribe();
this.showLoader.next(false);
this.StudentActive = -1;
//this.courseActive = -1;
this.CoursesPerSchoolSub = this._hds.FindCoursesPerSchool().subscribe(x => {
this.CoursesPerSchool$.next(x);
this.showLoader.next(false);
},
error => {
this.CoursesPerSchool$.next([{}]);
console.log("Error Getting courses perSchool");
this.showLoader.next(false);
});
this.StudentInfoSub = this._hds.getStudentPerSchool(this.taxi, this.sector, this.special)
.subscribe(data => {
this.StudentInfo$.next(data);
this.retrievedStudent.next(true);
this.showLoader.next(false);
},
error => {
this.StudentInfo$.next([{}]);
console.log("Error Getting Students");
this.showLoader.next(false);
this.showModal("#emptyselection");
});
}).catch(err => {
this.showErrorModal();
this.showLoader.next(false);
});
}
}
......@@ -23,9 +23,23 @@ 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="bg-warning" style="padding: 2em;">
<p>
<strong>Ανακοίνωση:</strong> Παρακαλείσθε να μην καταχωρείτε δήλωση προτίμησης επιλέγοντας τα παρακάτω:</p>
<ul>
<li> 9ο ΕΠΑ.Λ. Πειραιά, Β τάξη, Τομέας Ναυτιλιακών Επαγγελμάτων, Γ τάξη-Ειδικότητες Πλοίαρχος Εμπορικού Ναυτικού, Μηχανικός Εμπορικού Ναυτικού
</li>
<li> 1ο ΕΠΑ.Λ. Δάφνης, Γ τάξη, Ειδικότητα Βοηθός Νοσηλευτή
</li>
<li> 1ο Ημερήσιο ΕΠΑ.Λ. Σιβιτανιδείου, Γ τάξη, Ειδικότητα Βοηθός Νοσηλευτή
</li>
</ul>
<p>Τα τμήματα έχουν πληρότητα από την 1η περίοδο κατανομής.
</p>
</div>
<div *ngFor="let loginInfoToken$ of loginInfo$ | async; let i=index"></div>
<div class="row" style="min-height: 300px; margin-top: 100px;">
......
......@@ -662,7 +662,7 @@ export class HelperDataService implements OnInit, OnDestroy {
}
informUnlocatedStudents(username, userpassword, unallocated) {
informUnlocatedStudents(username, userpassword, unallocated, period) {
let headers = new Headers({
"Content-Type": "application/json",
......@@ -671,12 +671,13 @@ export class HelperDataService implements OnInit, OnDestroy {
let options = new RequestOptions({ headers: headers });
let route = "";
if (unallocated == 1)
route = "ministry/send-unallocated-massive-mail";
else if (unallocated == 2)
route = "ministry/send-unallocated-sc-massive-mail";
else if (unallocated == 3)
route = "ministry/send-located-massive-mail";
if (unallocated == 1) {
route = "ministry/send-unallocated-massive-mail/" + period;
} else if (unallocated == 2) {
route = "ministry/send-unallocated-sc-massive-mail/" + period;
} else if (unallocated == 3) {
route = "ministry/send-located-massive-mail/" + period;
}
return this.http.get(`${AppSettings.API_ENDPOINT}/` + route, options)
.map(response => response.json());
......@@ -1026,4 +1027,35 @@ export class HelperDataService implements OnInit, OnDestroy {
}
deleteApplicationforDirector(appId) {
this.loginInfo$.getValue().forEach(loginInfoToken => {
this.authToken = loginInfoToken.auth_token;
this.authRole = loginInfoToken.auth_role;
});
let headers = new Headers({
"Content-Type": "application/json",
});
this.createAuthorizationHeader(headers);
// let options = new RequestOptions({ headers: headers, withCredentials: true });
let options = new RequestOptions({ headers: headers });
return new Promise((resolve, reject) => {
this.http.post(`${AppSettings.API_ENDPOINT}/epal/application/deleteFromDirector`, { applicationId: appId }, options)
.map(response => response.json())
.subscribe(data => {
resolve(<any>data);
},
error => {
console.log("Error Removing Application");
reject("Error Removing Application");
});
});
}
}
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