Merge branch 'component_updates' into 'develop'

updated InformUnallocatedStudents Component, updated Modal alerts in Ministry en…

See merge request !89
parents 9e59ca4d 81a1f1d4
......@@ -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;
}
}
......@@ -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;
......
......@@ -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');
(<any>$(popupMsgId)).modal('hide');
public hideModal():void {
(<any>$('#emaiSentNotice')).modal('hide');
}
public onHidden(popupMsgId):void {
public onHidden():void {
//this.isModalShown.next(false);
}
informUnlocatedStudents() {
/*
this._hds.informUnlocatedStudents(this.minedu_userName, this.minedu_userPassword)
.catch(err => {console.log(err); })
.then(msg => {
console.log("Success");
});
*/
this.successSending = -2;
this.numSuccessMails = 0;
this.numFailMails = 0;
this._hds.informUnlocatedStudents(this.minedu_userName, this.minedu_userPassword).subscribe(data => {
//this.data = data;
//this.successSending = 0;
this.numSuccessMails = data.num_success_mail;
this.numFailMails = data.num_fail_mail;
//console.log("HERE!");
......@@ -206,14 +137,25 @@ import { API_ENDPOINT } from '../../app.settings';
error => {
console.log("Error");
this.successSending = 0;
this.showModal("#mailFailureNotice");
this.modalTitle.next("Κατανομή Μαθητών");
this.modalText.next("Αποτυχία αποστολής e-mails!");
this.modalHeader = "modal-header-warning";
this.showModal();
},
() => {
console.log("Success");
this.successSending = 1;
this.showModal("#mailSuccessNotice");
if (this.numFailMails != 0)
this.showModal("#mailNonSendingNotice");
this.modalHeader = "modal-header-success";
this.modalTitle.next("Κατανομή Μαθητών");
let txtModal = "Έγινε αποστολή " + this.numSuccessMails + " e-mails! ";
if (this.numFailMails != 0) {
this.modalHeader = "modal-header-warning";
txtModal += "Κάποια e-mail δεν έχουν σταλεί. Δεν ήταν δυνατή η αποστολή " + this.numFailMails + " e-mails!";
}
this.modalText.next(txtModal);
this.showModal();
}
)
......
......@@ -10,7 +10,7 @@ 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 { PDE_ROLE, DIDE_ROLE } from '../../constants';
import { MINISTRY_ROLE, PDE_ROLE, DIDE_ROLE } from '../../constants';
import {
FormBuilder,
......@@ -32,7 +32,7 @@ import { API_ENDPOINT } from '../../app.settings';
<h5><br> >Επιλογή Αναφοράς<br><br></h5>
<div class="col-md-1">
<button type="button" class="btn btn-alert" (click)="nav_to_reportpath(1)" [hidden]="minedu_userName == ''" >
<button type="button" class="btn btn-alert" (click)="nav_to_reportpath(1)" [hidden]="minedu_userName == '' || userRole == 'pde' || userRole == 'dide'" >
<i class="fa fa-file-text"></i>
Κατανομή Μαθητών με Βάση τη Σειρά Προτίμησης
</button>
......@@ -63,6 +63,7 @@ import { API_ENDPOINT } from '../../app.settings';
private minedu_userName: string;
private minedu_userPassword: string;
private distStatus = "READY";
private userRole: string;
constructor(private fb: FormBuilder,
private _ngRedux: NgRedux<IAppState>,
......@@ -78,6 +79,7 @@ import { API_ENDPOINT } from '../../app.settings';
this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE);
this.minedu_userName = '';
this.userRole = MINISTRY_ROLE;
}
......@@ -92,6 +94,7 @@ import { API_ENDPOINT } from '../../app.settings';
console.log(loginInfoToken.auth_role);
if (loginInfoToken.auth_role == PDE_ROLE || loginInfoToken.auth_role == DIDE_ROLE) {
console.log("inside..");
this.userRole = loginInfoToken.auth_role;
this.minedu_userName = loginInfoToken.auth_token;
this.minedu_userPassword = loginInfoToken.auth_token;
}
......
This diff is collapsed.
......@@ -52,8 +52,8 @@ import { API_ENDPOINT } from '../../app.settings';
</select>
</div>
<div class="col-md-11 offset-md-1">
<label *ngIf="(showAdminList | async) && enableRegionFilter">Διεύθυνση Εκπαίδευσης</label>
<select #admsel class="form-control" *ngIf="(showAdminList | async) && enableRegionFilter" (change)="checkadminarea(admsel)" formControlName="adminarea">
<label *ngIf="(showAdminList | async) && enableRegionFilter && userLoggedIn != 'dide'">Διεύθυνση Εκπαίδευσης</label>
<select #admsel class="form-control" *ngIf="(showAdminList | async) && enableRegionFilter" (change)="checkadminarea(admsel)" [hidden] = "userLoggedIn == 'dide'" formControlName="adminarea">
<option value="0"></option>
<option *ngFor="let AdminAreaSelection$ of AdminAreaSelections$ | async; let i=index" [value] = "AdminAreaSelection$.id"> {{AdminAreaSelection$.name}}</option>
</select>
......@@ -222,9 +222,10 @@ import { API_ENDPOINT } from '../../app.settings';
this.userLoggedIn = loginInfoToken.auth_role;
if (loginInfoToken.auth_role == PDE_ROLE || loginInfoToken.auth_role == DIDE_ROLE) {
console.log("inside..");
let regId = -1;
this.minedu_userName = loginInfoToken.auth_token;
this.minedu_userPassword = loginInfoToken.auth_token;
if (loginInfoToken.auth_role == PDE_ROLE) {
if (loginInfoToken.auth_role == PDE_ROLE || loginInfoToken.auth_role == DIDE_ROLE) {
//CALL CONTROLLER THAT RETURNS ID OF PDE
......@@ -234,14 +235,25 @@ import { API_ENDPOINT } from '../../app.settings';
},
error => {
this.RegionRetrieve$.next([{}]);
console.log("Error Getting getRegionId");
console.log("Error Getting getUserRegistryNo");
},
() => {
this.regionSelected = this.data['id'];
console.log("Success Getting getRegionId");
regId = this.data['id'];
console.log("Success Getting getUserRegistryNo");
if (loginInfoToken.auth_role == PDE_ROLE) {
this.regionSelected = regId;
this.showAdminList.next(true);
this.checkregion(this. regionSelected);
}
else if (loginInfoToken.auth_role == DIDE_ROLE) {
this.adminAreaSelected = regId;
this.showAdminList.next(false);
this.checkadminarea(this.adminAreaSelected);
//console.log("Test");
//console.log(this.adminAreaSelected);
}
this.showAdminList.next(true);
this.checkregion(this. regionSelected);
}
);
}
......@@ -328,6 +340,18 @@ createReport(regionSel) {
this.generalReportSub = this._hds.makeReport(this.minedu_userName, this.minedu_userPassword, route, regSel, admSel, schSel, clSel, secSel, courSel).subscribe(data => {
this.generalReport$.next(data);
this.data = data;
//console.log("Debugging..");
//whehever you find column "num" cast it to number value in order to be ordered properly
for (let i=0;i<this.data.length;i++) {
this.data[i].num = Number(data[i].num);
this.data[i].percentage = Number(data[i].percentage);
this.data[i].percTotal = Number(data[i].percTotal);
this.data[i].percA = Number(data[i].percA);
this.data[i].percB = Number(data[i].percB);
this.data[i].percC = Number(data[i].percC);
}
},
error => {
this.generalReport$.next([{}]);
......@@ -424,10 +448,10 @@ checkregion(regionId) {
console.log("TI EINAI;")
console.log(adminId);
console.log(adminId.value);
this.adminAreaSelected = adminId.value;
this.SchoolSelectionsSub = this._hds.getSchoolsPerAdminArea(this.minedu_userName, this.minedu_userPassword, adminId.value).subscribe(data => {
if (typeof adminId.value != "undefined")
this.adminAreaSelected = adminId.value;
this.SchoolSelectionsSub = this._hds.getSchoolsPerAdminArea(this.minedu_userName, this.minedu_userPassword, this.adminAreaSelected).subscribe(data => {
this.SchoolSelections$.next(data);
},
error => {
......
......@@ -50,95 +50,44 @@ reportAllStatSchema = {
columns: {
name: {
title: 'Σχολείο',
width: '18%',
filter: false
},
region: {
title: 'Περιφερειακή Διεύθυνση',
width: '15%',
filter: false
},
admin: {
title: 'Διεύθυνση Εκπαίδευσης',
width: '15%',
filter: false
},
section: {
title: 'Τάξη/Τομέας/Ειδικότητα',
width: '18%',
filter: false
},
num: {
title: 'Αριθμός Μαθητών',
width: '8%',
filter: false
},
capacity: {
title: 'Χωρ/κα',
width: '8%',
filter: false
},
percentage: {
title: 'Ποσοστό',
title: 'Ποσοστό (%)',
width: '8%',
filter: false
}
}
};
reportCompletenessSchemaFull = {
actions: false,
noDataMessage: 'Δεν υπάρχουν δεδομένα που περιέχουν το κείμενο αναζήτησης',
columns: {
name: {
title: 'Σχολείο',
filter: false,
hide: true
},
numStudents: {
title: 'Αριθμός',
filter: false
},
capacityTotal: {
title: 'Χωρ/τα',
filter: false
},
percTotal: {
title: 'Πληρότητα',
filter: false
},
numStudentsA: {
title: 'Α Τάξη',
filter: false
},
capacityA: {
title: 'Χωρ/τα',
filter: false
},
percA: {
title: 'Πληρότητα',
filter: false
},
numStudentsB: {
title: 'Β Τάξη',
filter: false
},
capacityB: {
title: 'Χωρ/τα',
filter: false
},
percB: {
title: 'Πληρότητα',
filter: false
},
numStudentsC: {
title: 'Γ Τάξη',
filter: false
},
capacityC: {
title: 'Χωρ/τα',
filter: false
},
percC: {
title: 'Πληρότητα',
filter: false
}
}
};
reportCompletenessSchema = {
......@@ -147,30 +96,37 @@ reportCompletenessSchema = {
columns: {
name: {
title: 'Σχολείο',
width: '17%',
filter: false
},
region: {
title: 'ΠΔΕ',
width: '13%',
filter: false
},
admin: {
title: 'ΔΙΔΕ',
width: '13%',
filter: false
},
percTotal: {
title: 'Πληρότητα Σχολείου',
width: '11%',
filter: false
},
percA: {
title: 'Πληρότητα Α\' τάξης',
title: 'Πληρότητα Α\' τάξης (%)',
width: '11%',
filter: false
},
percB: {
title: 'Πληρότητα Β\' τάξης',
title: 'Πληρότητα Β\' τάξης (%)',
width: '11%',
filter: false
},
percC: {
title: 'Πληρότητα Γ\' τάξης',
title: 'Πληρότητα Γ\' τάξης (%)',
width: '11%',
filter: false
}
}
......
......@@ -49,6 +49,11 @@
<a class="nav-link" [routerLink]="['/ministry/minister-reports']" [routerLinkActive]="['active']"><b>Αναφορές</b></a>
</li>
</div>
<div *ngIf="(loginInfo$ | async).size > 0" class="nav-item" >