updated InformUnallocatedStudents Component, updated Modal alerts in Ministry...

updated InformUnallocatedStudents Component, updated Modal alerts in Ministry environment, updated reports output
parent 31a930eb
......@@ -46,5 +46,11 @@ function epal_mail($key, &$message, $params) {
$message['subject'] = t('Σύστημα υποβολής αιτήσεων εγγραφής σε ΕΠΑΛ: Επιβεβαίωση e-mail', $options);
$message['body'][] = $params['message'];
break;
case 'massive_mail':
$message['from'] = \Drupal::config('system.site')->get('mail');
$message['subject'] = t('Μη ικανοποίηση ηλεκτρονικής αίτησης για εγγραφή σε ΕΠΑΛ', $options);
$message['body'][] = $params['message'];
break;
}
}
......@@ -70,12 +70,6 @@ epal.application_submit:
_controller: '\Drupal\epal\Controller\ApplicationSubmit::appSubmit'
requirements:
_user_is_logged_in: 'TRUE'
epal.demo_data:
path: '/epal/demodata'
defaults:
_controller: '\Drupal\epal\Controller\CreateDemoData::createData'
requirements:
_access: 'TRUE'
epal.allocation:
path: '/epal/distribution'
options:
......
......@@ -108,7 +108,8 @@ class Distribution extends ControllerBase {
try {
//initialize/empty epal_student_class if there are already data in it!
$this->connection->delete('epal_student_class')->execute();
//$this->connection->delete('epal_student_class')->execute();
$this->initializeResults();
//$limitUp_class = $this->retrieveCapacityLimitUp("Α");
$limitUp_class = $this->retrieveCapacityLimitUp("1");
......@@ -509,9 +510,27 @@ class Distribution extends ControllerBase {
return $res;
}
private function initializeResults() {
//initialize/empty epal_student_class if there are already data in it!
try {
$this->connection->delete('epal_student_class')->execute();
}
catch (\Exception $e) {
$this->logger->warning($e->getMessage());
return $this->respondWithStatus([
"message" => t("An unexpected problem occured during initializeResults Method of Distribution")
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
/*
public function makegGeneralReport(Request $request) {
try {
......@@ -574,15 +593,7 @@ class Distribution extends ControllerBase {
->condition('eStudent.id', $studentIds, 'NOT IN');
$numNoAllocated = $sCon->countQuery()->execute()->fetchField();
/*
$list[] = array(
'num_applications' => $numTotal,
'numchoice1' => $numData[0],
'numchoice2' => $numData[1],
'numchoice3' => $numData[2],
'num_noallocated' => $numNoAllocated,
);
*/
......@@ -616,73 +627,11 @@ class Distribution extends ControllerBase {
}
}
*/
/*
public function makeReport1(Request $request) {
try {
if (!$request->isMethod('GET')) {
return $this->respondWithStatus([
"message" => t("Method Not Allowed")
], Response::HTTP_METHOD_NOT_ALLOWED);
}
//user validation
$authToken = $request->headers->get('PHP_AUTH_USER');
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if (!$user) {
return $this->respondWithStatus([
'message' => t("User not found"),
], Response::HTTP_FORBIDDEN);
}
//user role validation
$roles = $user->getRoles();
$validRole = false;
foreach ($roles as $role)
if ($role === "ministry") {
$validRole = true;
break;
}
if (!$validRole) {
return $this->respondWithStatus([
'message' => t("User Invalid Role"),
], Response::HTTP_FORBIDDEN);
}
$list = array();
$sCon = $this->connection->select('eepal_school_field_data', 'eSchool')
->fields('eSchool', array('id', 'name'));
$epalSchools = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
//$schoolIds = array();
foreach ($epalSchools as $epalSchool) {
//array_push($schoolIds, $schoolId->id);
$sCon = $this->connection->select('epal_student_class', 'eStudent')
->fields('eStudent', array('id', 'epal_id'))
->condition('eStudent.epal_id', $epalSchool->id , '=');
$num = $sCon->countQuery()->execute()->fetchField();
if ($num !== "0")
array_push($list,(object) array('schoolName' => $epalSchool->name, 'numStudents' => $num));
}
return $this->respondWithStatus(
$list
, Response::HTTP_OK);
} //end try
catch (\Exception $e) {
$this->logger->warning($e->getMessage());
return $this->respondWithStatus([
"message" => t("An unexpected problem occured in makeReport1 Method")
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
*/
......
......@@ -166,7 +166,10 @@ class InformUnlocatedStudents extends ControllerBase {
.t(' δεν ικανοποιήθηκε. Παρακαλώ επικοινωνήστε άμεσα τηλεφωνικά με τη Διεύθυνση Δευτεροβάθμιας Εκπαίδευσης / Τμήμα Επαγγελματικής Εκπαίδευσης,
στην οποία ανήκετε, ώστε να διερευνηθεί η δυνατότητα εγγραφής σας σε αντίστοιχο ΕΠΑΛ'); //e-mail body
//add new lines with SENDER name - check it
$params['subject'] = t('Μη ικανοποίηση ηλεκτρονικής αίτησης για εγγραφή σε ΕΠΑΛ');
//$params['subject'] = t('Μη ικανοποίηση ηλεκτρονικής αίτησης για εγγραφή σε ΕΠΑΛ');
//$this->logger->warning($params['message']);
//$langcode = $user->getPreferredLangcode();
$send = true;
......
......@@ -258,10 +258,10 @@ class ReportsCreator extends ControllerBase {
->condition('eStudent.currentclass', $classId , '=');
array_push( $num, $sCon->countQuery()->execute()->fetchField() );
//βρες ποσοστά συμπλήρωσης
array_push( $perc, number_format($num[$classId-1] / $capacity[$classId-1] * 100 , 2) . "%");
array_push( $perc, number_format($num[$classId-1] / $capacity[$classId-1] * 100, 2));
}
$percTotal = number_format (array_sum($num) / array_sum($capacity) * 100, 2) . "%";
$percTotal = number_format (array_sum($num) / array_sum($capacity) * 100, 2);
//αποστολή αποτελεσμάτων / στατιστικών
array_push($list,(object) array(
......@@ -352,6 +352,8 @@ class ReportsCreator extends ControllerBase {
$capacityColumn = array();
$percColumn = array();
$numClassSec = 0;
$numClassCour = 0;
//εύρεση ονόματος ΠΔΕ που ανήκει το σχολείο
$sCon = $this->connection->select('eepal_region_field_data', 'eRegion')
......@@ -367,50 +369,54 @@ class ReportsCreator extends ControllerBase {
$epalAdmins = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
$epalAdmin = reset($epalAdmins);
//εύρεση αριθμού μαθητών για κάθε τάξη
//array_push($schoolSectionColumn, 'Α τάξη');
//array_push($schoolSectionColumn, 'Β τάξη');
//array_push($schoolSectionColumn, 'Γ τάξη');
if ($sectorId === "0" && $courseId == 0) { //|| courseId === 0
$clidstart = 1;
$clidend = 3;
if ($classId !== "0") {
$clidstart = $classId;
$clidend = $classId;
if ($classId === "1")
array_push($schoolSectionColumn, 'Α τάξη');
else if ($classId === "2")
array_push($schoolSectionColumn, 'Β τάξη');
else if ($classId === "3")
array_push($schoolSectionColumn, 'Γ τάξη');
}
else {
array_push($schoolSectionColumn, 'Α τάξη');
array_push($schoolSectionColumn, 'Β τάξη');
array_push($schoolSectionColumn, 'Γ τάξη');
}
for ( $clId = $clidstart; $clId <= $clidend; $clId++) {
$sCon = $this->connection->select('epal_student_class', 'eStudent')
->fields('eStudent', array('id', 'epal_id', 'currentclass'))
->condition('eStudent.epal_id', $epalSchool->id , '=')
->condition('eStudent.currentclass', $clId , '=');
$numStud = $sCon->countQuery()->execute()->fetchField();
array_push($schoolNameColumn, $epalSchool->name);
array_push($regionColumn, $epalRegion->name);
array_push($adminColumn, $epalAdmin->name);
//array_push($numColumn, $sCon->countQuery()->execute()->fetchField() );
array_push($numColumn, $numStud);
array_push($capacityColumn, $epalSchool->capacity_class_a * $limitup);
array_push($percColumn, number_format($numStud / ($epalSchool->capacity_class_a * $limitup) * 100, 2) . '%' );
}
//εύρεση αριθμού μαθητών για κάθε ειδικότητα της Γ' τάξης
if ($classId === "0" || $classId === "3") {
$sCon = $this->connection->select('eepal_specialties_in_epal_field_data', 'eSchool')
->fields('eSchool', array('specialty_id', 'capacity_class_specialty'))
->condition('eSchool.epal_id', $epalSchool->id , '=');
if ($courseId !== "0")
$sCon->condition('eSchool.specialty_id', $courseId, '=');
$specialtiesInEpals = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($specialtiesInEpals as $specialtiesInEpal) {
$sCon = $this->connection->select('eepal_specialty_field_data', 'eSpecialties')
->fields('eSpecialties', array('name'))
->condition('eSpecialties.id', $specialtiesInEpal->specialty_id , '=');
if ($courseId === "0" && $sectorId !== "0")
$sCon->condition('eSpecialties.sector_id', $sectorId, '=');
$specialtiesNamesInEpals = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($specialtiesNamesInEpals as $specialtiesNamesInEpal) {
array_push($regionColumn, $epalRegion->name);
array_push($adminColumn, $epalAdmin->name);
array_push($schoolNameColumn, $epalSchool->name);
array_push($schoolSectionColumn, 'Γ τάξη / ' . $specialtiesNamesInEpal->name );
$sCon = $this->connection->select('epal_student_class', 'eStudent')
->fields('eStudent', array('id'))
->condition('eStudent.epal_id', $epalSchool->id , '=')
->condition('eStudent.currentclass', 3 , '=')
->condition('eStudent.specialization_id', $specialtiesInEpal->specialty_id , '=');
$numStud = $sCon->countQuery()->execute()->fetchField();
array_push( $numColumn, $numStud );
array_push($capacityColumn, $specialtiesInEpal->capacity_class_specialty * $limitup);
array_push($percColumn, number_format($numStud / ($specialtiesInEpal->capacity_class_specialty * $limitup) * 100, 2 ));
/*
$specChar = "";
$prc = $numStud / ($specialtiesInEpal->capacity_class_specialty * $limitup) * 100;
if ($prc < 10)
$specChar = '0';
//array_push($percColumn, number_format($numStud / ($specialtiesInEpal->capacity_class_specialty * $limitup) * 100, 2) . "%");
array_push($percColumn, $specChar . number_format($prc, 2) . "%");
*/
} //end foreach $specialtiesNamesInEpal
$numClassCour += $specialtiesInEpal->capacity_class_specialty;
} //end foreach $specialtiesInEpals
} //end if
//εύρεση αριθμού μαθητών για κάθε τομέα της Β' τάξης
......@@ -443,53 +449,84 @@ class ReportsCreator extends ControllerBase {
$numStud = $sCon->countQuery()->execute()->fetchField();
array_push( $numColumn, $numStud );
array_push($capacityColumn, $sectorsInEpal->capacity_class_sector * $limitup);
array_push($percColumn, number_format($numStud / ($sectorsInEpal->capacity_class_sector * $limitup) * 100, 2) . '%' );
}
}
array_push($percColumn, number_format($numStud / ($sectorsInEpal->capacity_class_sector * $limitup) * 100, 2) );
/*
$specChar = "";
$prc = $numStud / ($sectorsInEpal->capacity_class_sector * $limitup) * 100;
if ($prc < 10)
$specChar = '0';
array_push($percColumn, $specChar . number_format($prc, 2) . "%");
*/
} //end foreach sectorsNamesInEpals
$numClassSec += $sectorsInEpal->capacity_class_sector;
} //end foreach sectorsInEpal
} //end if
//εύρεση αριθμού μαθητών για κάθε ειδικότητα της Γ' τάξης
if ($classId === "0" || $classId === "3") {
$sCon = $this->connection->select('eepal_specialties_in_epal_field_data', 'eSchool')
->fields('eSchool', array('specialty_id', 'capacity_class_specialty'))
->condition('eSchool.epal_id', $epalSchool->id , '=');
if ($courseId !== "0")
$sCon->condition('eSchool.specialty_id', $courseId, '=');
$specialtiesInEpals = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($specialtiesInEpals as $specialtiesInEpal) {
$sCon = $this->connection->select('eepal_specialty_field_data', 'eSpecialties')
->fields('eSpecialties', array('name'))
->condition('eSpecialties.id', $specialtiesInEpal->specialty_id , '=');
if ($courseId === "0" && $sectorId !== "0")
$sCon->condition('eSpecialties.sector_id', $sectorId, '=');
$specialtiesNamesInEpals = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($specialtiesNamesInEpals as $specialtiesNamesInEpal) {
array_push($regionColumn, $epalRegion->name);
array_push($adminColumn, $epalAdmin->name);
array_push($schoolNameColumn, $epalSchool->name);
array_push($schoolSectionColumn, 'Γ τάξη / ' . $specialtiesNamesInEpal->name );
$sCon = $this->connection->select('epal_student_class', 'eStudent')
->fields('eStudent', array('id'))
->condition('eStudent.epal_id', $epalSchool->id , '=')
->condition('eStudent.currentclass', 3 , '=')
->condition('eStudent.specialization_id', $specialtiesInEpal->specialty_id , '=');
$numStud = $sCon->countQuery()->execute()->fetchField();
array_push( $numColumn, $numStud );
array_push($capacityColumn, $specialtiesInEpal->capacity_class_specialty * $limitup);
array_push($percColumn, number_format($numStud / ($specialtiesInEpal->capacity_class_specialty * $limitup) * 100, 2) . '%' );
} //end foreach
} //end foreach
//εύρεση αριθμού μαθητών για κάθε τάξη
$numClasses = array();
array_push($numClasses, $epalSchool->capacity_class_a);
array_push($numClasses,$numClassSec);
array_push($numClasses, $numClassCour);
if ($sectorId === "0" && $courseId == 0) {
$clidstart = 1;
$clidend = 3;
if ($classId !== "0") {
$clidstart = $classId;
$clidend = $classId;
if ($classId === "1")
array_push($schoolSectionColumn, 'Α τάξη');
else if ($classId === "2")
array_push($schoolSectionColumn, 'Β τάξη');
else if ($classId === "3")
array_push($schoolSectionColumn, 'Γ τάξη');
}
else {
array_push($schoolSectionColumn, 'Α τάξη');
array_push($schoolSectionColumn, 'Β τάξη');
array_push($schoolSectionColumn, 'Γ τάξη');
}
for ( $clId = $clidstart; $clId <= $clidend; $clId++) {
$sCon = $this->connection->select('epal_student_class', 'eStudent')
->fields('eStudent', array('id', 'epal_id', 'currentclass'))
->condition('eStudent.epal_id', $epalSchool->id , '=')
->condition('eStudent.currentclass', $clId , '=');
$numStud = $sCon->countQuery()->execute()->fetchField();
array_push($schoolNameColumn, $epalSchool->name);
array_push($regionColumn, $epalRegion->name);
array_push($adminColumn, $epalAdmin->name);
array_push($numColumn, $numStud);
//Modify here!
//array_push($capacityColumn, $epalSchool->capacity_class_a * $limitup);
//array_push($percColumn, number_format($numStud / ($epalSchool->capacity_class_a * $limitup) * 100, 2) . '%' );
array_push($capacityColumn, $numClasses[$clId-1] * $limitup);
array_push($percColumn, number_format($numStud / ($numClasses[$clId-1] * $limitup) * 100, 2) );
/*
$specChar = "";
$prc = $numStud / ($numClasses[$clId-1] * $limitup) * 100;
if ($prc < 10)
$specChar = '0';
array_push($percColumn, $specChar . number_format($prc, 2) . "%");
*/
}
} //end if
for ($j = 0; $j < sizeof($schoolNameColumn); $j++) {
for ($j = 0; $j < sizeof($schoolNameColumn); $j++) {
array_push($list,(object) array(
'name' => $schoolNameColumn[$j],
'region' => $regionColumn[$j],
......@@ -549,7 +586,7 @@ class ReportsCreator extends ControllerBase {
$roles = $user->getRoles();
$validRole = false;
foreach ($roles as $role)
if ( $role === "regioneduadmin") {
if ( $role === "regioneduadmin" || $role === "eduadmin") {
$validRole = true;
break;
}
......
......@@ -10,15 +10,6 @@ import { Router, ActivatedRoute, Params} from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import { ILoginInfo } from '../../store/logininfo/logininfo.types';
import { LOGININFO_INITIAL_STATE } from '../../store/logininfo/logininfo.initial-state';
import {
FormBuilder,
FormGroup,
FormControl,
FormArray,
} from '@angular/forms';
import { API_ENDPOINT } from '../../app.settings';
@Component({
......@@ -29,68 +20,25 @@ import { API_ENDPOINT } from '../../app.settings';
class = "loading" *ngIf="successSending == -2" >
</div>
<div id="mailSuccessNotice" (onHidden)="onHidden('#mailSuccessNotice')" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div id="emaiSentNotice" (onHidden)="onHidden()" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title pull-left">Κατανομή μαθητών</h4>
<button type="button" class="close pull-right" aria-label="Close" (click)="hideModal('#mailSuccessNotice')">
<span aria-hidden="true">&times;</span>
<div class="modal-header {{modalHeader}}" >
<h3 class="modal-title pull-left"><i class="fa fa-check-square-o"></i>&nbsp;&nbsp;{{ modalTitle | async }}</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>Έγινε αποστολή {{numSuccessMails}} e-mails!</p>
<p>{{ modalText | async }}</p>
</div>
</div>
</div>
</div>
<div id="mailFailureNotice" (onHidden)="onHidden('#mailFailureNotice')" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title pull-left">Κατανομή μαθητών</h4>
<button type="button" class="close pull-right" aria-label="Close" (click)="hideModal('#mailFailureNotice')">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<p>Αποτυχία αποστολής e-mails!</p>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">Κλείσιμο</button>
</div>
</div>
</div>
</div>
<div id="mailNonSendingNotice" (onHidden)="onHidden('#mailNonSendingNotice')" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title pull-left">Κατανομή μαθητών</h4>
<button type="button" class="close pull-right" aria-label="Close" (click)="hideModal('#mailNonSendingNotice')">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<p>Κάποια e-mail δεν έχουν σταλεί.
Δεν ήταν δυνατή η αποστολή {{numFailMails}} e-mails!</p>
</div>
</div>
</div>
</div>
<!--
<div class="alert alert-success" *ngIf="successSending == 1 ">
Έγινε αποστολή {{numSuccessMails}} e-mails!
</div>
<div class="alert alert-warning" *ngIf="successSending == 0">
Αποτυχία αποστολής e-mails!
</div>
<div class="alert alert-warning" *ngIf="numFailMails != 0">
Κάποια e-mail δεν έχουν σταλεί.
Δεν ήταν δυνατή η αποστολή {{numFailMails}} e-mails!
</div>
-->
<br><br>
<div class="col-md-12">
<button type="submit" class="btn btn-lg btn-block" *ngIf="(loginInfo$ | async).size !== 0" (click)="informUnlocatedStudents()" >
......@@ -98,17 +46,16 @@ import { API_ENDPOINT } from '../../app.settings';
</button>
</div>
`
})
@Injectable() export default class InformStudents implements OnInit, OnDestroy {
public formGroup: FormGroup;
//private loginInfo$: Observable<ILoginInfo>;
loginInfo$: BehaviorSubject<ILoginInfo>;
private modalTitle: BehaviorSubject<string>;
private modalText: BehaviorSubject<string>;
//public isModalShown: BehaviorSubject<boolean>;
public modalHeader: string;
loginInfoSub: Subscription;
private numSuccessMails:number;
private numFailMails:number;
......@@ -117,26 +64,22 @@ import { API_ENDPOINT } from '../../app.settings';
private minedu_userName: string;
private minedu_userPassword: string;
constructor(private fb: FormBuilder,
// private _ata: LoginInfoActions,
constructor(
private _ngRedux: NgRedux<IAppState>,
private _hds: HelperDataService,
private activatedRoute: ActivatedRoute,
private router: Router) {
this.formGroup = this.fb.group({
});
this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE);
//this.isModalShown = new BehaviorSubject(false);
this.modalTitle = new BehaviorSubject("");
this.modalText = new BehaviorSubject("");
}
ngOnInit() {
(<any>$('#mailSuccessNotice')).appendTo("body");
(<any>$('#mailFailureNotice')).appendTo("body");
(<any>$('#mailNonSendingNotice')).appendTo("body");
(<any>$('#emaiSentNotice')).appendTo("body");
this.loginInfoSub = this._ngRedux.select(state => {
if (state.loginInfo.size > 0) {
......@@ -157,47 +100,35 @@ import { API_ENDPOINT } from '../../app.settings';
ngOnDestroy() {
(<any>$('#mailSuccessNotice')).remove();
(<any>$('#mailFailureNotice')).remove();
(<any>$('#mailNonSendingNotice')).remove();
(<any>$('#emaiSentNotice')).remove();
if (this.loginInfoSub)
this.loginInfoSub.unsubscribe();
if (this.loginInfoSub) this.loginInfoSub.unsubscribe();
this.loginInfo$.unsubscribe();
}
public showModal(popupMsgId):void {
public showModal():void {
console.log("about to show modal");
//(<any>$('#distributionWaitingNotice')).modal('show');
(<any>$(popupMsgId)).modal('show');
(<any>$('#emaiSentNotice')).modal('show');
}
public hideModal(popupMsgId):void {
//(<any>$('#distributionWaitingNotice')).modal('hide');