delete gel app added

parent 47fec85d
......@@ -154,6 +154,8 @@ class PDFCreator extends ControllerBase {
$this->fontLight = "open-sans.light";
$this->fontBold = "open-sans.bold";
//$this->fontLight = "test2";
//$this->fontBold = "test2";
$this->fontSizeHeader = 14;
$this->fontSizeRegular = 11;
......@@ -196,6 +198,8 @@ class PDFCreator extends ControllerBase {
$this->pdf->AddFont($this->fontLight, '', 'open-sans.light.php');
$this->pdf->AddFont($this->fontBold, '', 'open-sans.bold.php');
//$this->pdf->AddFont($this->fontLight, '', 'test2.php');
//$this->pdf->AddFont($this->fontBold, '', 'test2.php');
$this->crypt = new Crypt();
......
......@@ -958,11 +958,11 @@ class SubmitedApplications extends ControllerBase
//λογική διαγραφή αίτησης μαθητή από Διευθυντή
public function deleteApplicationFromDirector(Request $request)
{
if (!$request->isMethod('POST')) {
return $this->respondWithStatus([
"error_code" => 2001
], Response::HTTP_METHOD_NOT_ALLOWED);
}
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));
......
......@@ -30,6 +30,14 @@ gel.application_delete:
_controller: '\Drupal\gel\Controller\GelSubmittedApplications::gelDeleteApplication'
requirements:
_user_is_logged_in: 'TRUE'
gel.application_delete_director:
path: '/gel/application/deleteFromDirector'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\gel\Controller\GelSubmittedApplications::gelDeleteApplicationFromDirector'
requirements:
_user_is_logged_in: 'TRUE'
gel.applicationdetails:
path: '/gel/application/{studentId}'
options:
......
......@@ -116,6 +116,147 @@ class GelSubmittedApplications extends ControllerBase
}
//λογική διαγραφή αίτησης μαθητή από Διευθυντή
public function gelDeleteApplicationFromDirector(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) {
/*
//TO BE DONE: να ανακτείται ο κωδικός σχολείου. Προϋποθέτει: entity με ΓΕΛ σχολεία!!
$gelId = $user->init->value;
$schools = $this->entityTypeManager->getStorage('gel_school')->loadByProperties(array('id' => $gelId));
$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_delete
$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);
}
//μη διαγραφή αν δεν είναι ενεργή η περίοδος υποβολής αιτήσεων
else if ($epalConfig->lock_application->value) {
return $this->respondWithStatus([
"error_code" => 3002
], Response::HTTP_FORBIDDEN);
}
*/
else if ($epalConfig->lock_delete->value) {
return $this->respondWithStatus([
"error_code" => 3002
], Response::HTTP_FORBIDDEN);
}
$applicantStudents = $this->entityTypeManager->getStorage('gel_student')->loadByProperties(array( 'id' => $applicationId));
$applicantStudent = reset($applicantStudents);
if ($applicantStudent) {
/*
//ΔΙΑΓΡΑΦΗ ΑΠΟ ΠΙΝΑΚΑ ΑΠΟΤΕΛΕΣΜΑΤΩΝ -> ΘΑ ΥΠΑΡΧΕΙ ΣΤΟ ΓΕΛ??
$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);
}
}
*/
$applicantStudent->set('delapp', 1);
$timestamp = strtotime(date("Y-m-d"));
$applicantStudent->set('delapp_changed', $timestamp);
$applicantStudent->set('delapp_role', 'director');
//ΝΑ ΕΚΤΕΛΕΣΤΕΙ ΟΤΑΝ ΦΤΙΑΧΤΕΙ ΤΟ gel_sschools
//$epalStudent->set('delapp_epalid', $gelId);
$epalStudent->save();
/*
//ΔΙΑΓΡΑΦΗ ΑΠΟ ΠΙΝΑΚΑ ΑΠΟΤΕΛΕΣΜΑΤΩΝ -> ΘΑ ΥΠΑΡΧΕΙ ΣΤΟ ΓΕΛ??
$delQuery = $this->connection->delete('epal_student_class');
$delQuery->condition('student_id', $applicationId);
$delQuery->execute();
*/
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);
}
}
}
}
public function getGelSubmittedApplications(Request $request)
{
$authToken = $request->headers->get('PHP_AUTH_USER');
......@@ -154,6 +295,10 @@ class GelSubmittedApplications extends ControllerBase
// else {
// $canDelete = 0;
// }
if (!$applicantsAppDelDisabled)
$canDelete = 1;
else
$canDelete = 0;
try {
$name_decoded = $crypt->decrypt($object->name->value);
......@@ -193,6 +338,8 @@ class GelSubmittedApplications extends ControllerBase
}
public function getGelApplicationDetails(Request $request, $studentId)
{
$authToken = $request->headers->get('PHP_AUTH_USER');
......
......@@ -80,6 +80,7 @@ import { IAppState } from "../../store/store";
<breadcrumbs></breadcrumbs>
</div>
<div *ngIf="(SubmitedApplic$ | async).length > 0 || (GelSubmittedApplic$ | async).length > 0" class="row" style="margin: 10px 2px 10px 2px;">
<p>Έχουν υποβληθεί οι παρακάτω δηλώσεις προτίμησης για το νέο σχολικό έτος.</p>
<p>Επιλέξτε το όνομα ή το επώνυμο του μαθητή για να δείτε αναλυτικά τη δήλωσή σας και να την εκτυπώσετε σε μορφή PDF.</p>
......@@ -98,6 +99,9 @@ import { IAppState } from "../../store/store";
<div class="col-md-1" style="font-size: 1em; font-weight: bold;">&nbsp;</div>
</div>
<!--
*ngIf="(GelSubmittedApplic$ | async).length > 0"
-->
<div *ngIf="(GelSubmittedApplic$ | async).length > 0">
<div class="row list-group-item isclickable" style="margin: 0px 2px 0px 2px;" [class.oddout]="isOdd" [class.evenout]="isEven" [class.selectedappout]="applicationGelIdActive === UserData$.id"
*ngFor="let UserData$ of GelSubmittedApplic$ | async; let i=index; let isOdd=odd; let isEven=even" >
......@@ -513,7 +517,7 @@ import { IAppState } from "../../store/store";
this.resetStore();
this.SubmitedUsersSub = this._hds.getSubmittedPreviw().subscribe(
this.SubmitedUsersSub = this._hds.getSubmittedPreview().subscribe(
data => {
this.SubmitedApplic$.next(data);
this.showLoader$.next(false);
......@@ -634,18 +638,32 @@ import { IAppState } from "../../store/store";
this.hideConfirmModal();
this.showLoader$.next(true);
this._hds.deleteApplication(this.applicationId, this.schooltype).then(data => {
this.SubmitedUsersSub.unsubscribe();
this.SubmitedUsersSub = this._hds.getSubmittedPreviw().subscribe(
data => {
this.SubmitedApplic$.next(data);
this.showLoader$.next(false);
},
error => {
this.SubmitedApplic$.next([{}]);
this.showLoader$.next(false);
console.log("Error Getting Schools");
});
if (this.schooltype === "epal") {
this.SubmitedUsersSub.unsubscribe();
this.SubmitedUsersSub = this._hds.getSubmittedPreview().subscribe(
data => {
this.SubmitedApplic$.next(data);
this.showLoader$.next(false);
},
error => {
this.SubmitedApplic$.next([{}]);
this.showLoader$.next(false);
console.log("Error Getting Schools");
});
}
else if (this.schooltype === "gel") {
this.SubmittedGelUsersSub.unsubscribe();
this.SubmittedGelUsersSub = this._hds.getGelSubmittedPreview().subscribe(
data => {
this.GelSubmittedApplic$.next(data);
this.showLoader$.next(false);
},
error => {
this.GelSubmittedApplic$.next([{}]);
this.showLoader$.next(false);
console.log("Error Getting Schools");
});
}
}).catch(err => {
this.showLoader$.next(false);
......@@ -857,7 +875,7 @@ import { IAppState } from "../../store/store";
this._cfa.saveDataModeSelected({app_update: true, appid: this.GelSubmittedDetails$.getValue()[0].applicationId});
this._sta.saveSchoolTypeSelected(1, "ΓΕΛ");
this._gca.getClassesList(false).then(()=>{
this._gca.saveGelClassesSelected(-1, this.GelSubmittedDetails$.getValue()[0].nextclass -1 );
});
......@@ -891,8 +909,6 @@ import { IAppState } from "../../store/store";
});
}
let birthdate = this.GelSubmittedDetails$.getValue()[0].birthdate;
let birthparts = birthdate.split("/",3);
this._gsdf.saveGelStudentDataFields([{name: this.GelSubmittedDetails$.getValue()[0].name,
......@@ -931,46 +947,6 @@ import { IAppState } from "../../store/store";
*/
/*
this.electivecourseFieldsSub = this._ngRedux.select("electivecourseFields")
.map(electivecourseFields => <IElectiveCourseFieldRecords>electivecourseFields)
.subscribe(sfds => {
console.log("Mpika1");
let electcnt = 0;
sfds.reduce(({}, electivecourseField) => {
console.log("Mpika2");
++electcnt;
//if (electivecourseField.get("id")=== this.electiveCourse_id ) {
for (let k=0; k < (this.GelSubmittedDetails$.getValue()[0].gelStudentChoices).length; k++) {
if ( this.GelSubmittedDetails$.getValue()[0].gelStudentChoices[k].choice_type === "ΕΠΙΛΟΓΗ" &&
electivecourseField.get("id") === this.GelSubmittedDetails$.getValue()[0].gelStudentChoices[k].choice_id) {
this._ecf.saveElectiveCourseFieldsSelected(electcnt-1, 0, this.GelSubmittedDetails$.getValue()[0].gelStudentChoices[k].order_id);
}
}
return electivecourseField;
}, {});
}, error => { console.log("error selecting electivecourseFields"); });
*/
/*
this.OrientationGroupSub = this._ngRedux.select("orientationGroup")
.map(orientationGroup => <IOrientationGroupRecords>orientationGroup)
.subscribe(ogs => {
let orientcnt = 0;
ogs.reduce(({}, orientationgroup) => {
++orientcnt;
//if (orientationgroup.get("id") === this.orientationGroup_id) {
for (let k=0; k < (this.GelSubmittedDetails$.getValue()[0].gelStudentChoices).length; k++) {
if ( this.GelSubmittedDetails$.getValue()[0].gelStudentChoices[k].choice_type === "ΟΠ" &&
orientationgroup.get("id") === this.GelSubmittedDetails$.getValue()[0].gelStudentChoices[k].choice_id) {
this._ogs.saveOrientationGroupSelected(orientcnt-1, 0);
}
}
return orientationgroup;
}, {});
}, error => { console.log("error selecting orientation"); });
*/
}
......
......@@ -174,20 +174,8 @@ export class HelperDataService implements OnInit, OnDestroy {
});
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers });
/*
let getConnectionString;
if (schooltype === "ΕΠΑΛ")
getConnectionString = `${AppSettings.API_ENDPOINT}/epal/application/delete/`;
else if (schooltype === "ΓΕΛ")
getConnectionString = `${AppSettings.API_ENDPOINT}/gel/application/delete/`;
*/
let getConnectionString = `${AppSettings.API_ENDPOINT}/` + schooltype + `/application/delete/`;
console.log("Nikos");
console.log(schooltype);
console.log(appId);
return new Promise((resolve, reject) => {
//this.http.post(`${AppSettings.API_ENDPOINT}/epal/application/delete/` + schooltype, { applicationId: appId }, options)
this.http.post(getConnectionString, { applicationId: appId }, options)
......@@ -477,7 +465,7 @@ export class HelperDataService implements OnInit, OnDestroy {
});
}
getSubmittedPreviw() {
getSubmittedPreview() {
this.loginInfo$.getValue().forEach(loginInfoToken => {
this.authToken = loginInfoToken.auth_token;
......
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