Merged updated code. Resolved conflicts

parents 80a39455 b632bf1c
......@@ -86,22 +86,6 @@ epal.allocation:
_controller: '\Drupal\epal\Controller\Distribution::createDistribution'
requirements:
_user_is_logged_in: 'TRUE'
epal.sectorperschool:
path: '/epal/sectorperschool'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::getSectorsPerSchool'
requirements:
_user_is_logged_in: 'TRUE'
epal.specialityperschool:
path: '/epal/specialityperschool/{sectorId}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::getSpecialPerSchool'
requirements:
_user_is_logged_in: 'TRUE'
epal.confirmstudents:
path: '/epal/confirmstudent'
options:
......@@ -142,6 +126,14 @@ epal.ministry.log_out_go:
_controller: '\Drupal\epal\Controller\MinistryLogin::logoutGo'
requirements:
_user_is_logged_in: 'TRUE'
epal.ministry.report_users:
path: '/ministry/report-users'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\ReportsCreator::makeReportUsers'
requirements:
_user_is_logged_in: 'TRUE'
epal.ministry.general_report:
path: '/ministry/general-report'
options:
......@@ -215,7 +207,7 @@ epal.ministry.retrievesettings:
requirements:
_user_is_logged_in: 'TRUE'
epal.ministry.storesettings:
path: '/ministry/store-settings/{capacityDisabled}/{directorViewDisabled}/{applicantsLoginDisabled}/{applicantsResultsDisabled}'
path: '/ministry/store-settings/{capacityDisabled}/{directorViewDisabled}/{applicantsLoginDisabled}/{applicantsResultsDisabled}/{secondPeriodEnabled}'
options:
_auth: [ 'basic_auth' ]
defaults:
......@@ -237,7 +229,7 @@ epal.coursesperschools:
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::getCoursesPerSchool'
requirements:
_user_is_logged_in: 'TRUE'
_user_is_logged_in: 'TRUE'
epal.critirioschosen:
path: '/epal/critiriachosen/{studentId}/{type}'
options:
......@@ -246,38 +238,6 @@ epal.critirioschosen:
_controller: '\Drupal\epal\Controller\SubmitedApplications::getCritiria'
requirements:
_user_is_logged_in: 'TRUE'
epal.findcapacity:
path: '/epal/findcapacity/{taxi}/{tomeas}/{specialit}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::findCapacity'
requirements:
_user_is_logged_in: 'TRUE'
epal.findschoolid:
path: '/epal/getschool'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::getSchoolID'
requirements:
_user_is_logged_in: 'TRUE'
epal.gettypeofschool:
path: '/epal/gettypeofschool'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::gettypeofschool'
requirements:
_user_is_logged_in: 'TRUE'
epal.getlimitspercourse:
path: '/epal/getlimitspercourse/{classid}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::getlimitsperCourse'
requirements:
_user_is_logged_in: 'TRUE'
epal.findcapacityperschool:
path: '/epal/findcapacityperschool'
options:
......@@ -318,3 +278,14 @@ epal.svc.getstudentcertification:
_controller: '\Drupal\epal\Controller\WSConsumer::getStudentEpalCertification'
requirements:
_user_is_logged_in: 'TRUE'
epal.findcoursesperschool:
path: '/epal/findcoursesperschool'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::FindCoursesPerSchool'
requirements:
_user_is_logged_in: 'TRUE'
......@@ -131,6 +131,7 @@ class ApplicationSubmit extends ControllerBase
], Response::HTTP_FORBIDDEN);
}
$second_period = $this->retrievePeriod();
$student = array(
'langcode' => 'el',
......@@ -170,7 +171,9 @@ class ApplicationSubmit extends ControllerBase
'guardian_mothername' => $guardian_mothername_encoded,
'agreement' => $applicationForm[0]['disclaimer_checked'],
'relationtostudent' => $relationtostudent_encoded,
'telnum' => $telnum_encoded
'telnum' => $telnum_encoded,
'second_period' => $second_period,
);
if (($errorCode = $this->validateStudent($student)) > 0) {
......@@ -253,12 +256,28 @@ class ApplicationSubmit extends ControllerBase
return $res;
}
private function retrievePeriod() {
$config_storage = $this->entityTypeManager->getStorage('epal_config');
$epalConfigs = $config_storage->loadByProperties(array('name' => 'epal_config'));
$epalConfig = reset($epalConfigs);
if (!$epalConfig)
return 0;
else
$secondPeriodEnabled = $epalConfig->activate_second_period->getString();
return $secondPeriodEnabled;
}
/**
*
* @return int error code ελέγχου; 0 εάν ο έλεγχος επιτύχει, μη μηδενικό εάν αποτύχει:
* 1001 δεν επιλέχθηκε το πλαίσιο συμφωνης γνώμης
* 1002 λανθασμένο τελευταίο έτος φοίτησης
* 1003 λανθασμένη ημερομηνία
* 1004-> 1023: λανθασμένα πεδία αίτησης
* 8000 μη αναμενόμενο λάθος
* 8001 δικτυακό λάθος κλήσης υπηρεσίας επιβεβαίωσης στοιχείων
* 8002 τα στοιχεία φοίτησης δεν επικυρώθηκαν
......@@ -282,6 +301,67 @@ class ApplicationSubmit extends ControllerBase
}
$birthdate = "{$date_parts[2]}-{$date_parts[1]}-{$date_parts[0]}";
if (!$student["name"]) {
return 1004;
}
if (!$student["studentsurname"]) {
return 1005;
}
if (!$student["fatherfirstname"]) {
return 1006;
}
if (!$student["motherfirstname"]) {
return 1007;
}
if (!$student["regionaddress"]) {
return 1008;
}
if (!$student["regiontk"]) {
return 1009;
}
if (!$student["regionarea"]) {
return 1010;
}
if (!$student["certificatetype"]) {
return 1011;
}
if (!$student["graduation_year"]) {
return 1012;
}
if (!$student["currentclass"] || ($student["currentclass"] !== "1" && $student["currentclass"] !== "2" && $student["currentclass"] !== "3" && $student["currentclass"] !== "4") ) {
return 1013;
}
if (!$student["relationtostudent"]) {
return 1014;
}
if (!$student["telnum"]) {
return 1015;
}
if (!$student["guardian_name"]) {
return 1016;
}
if (!$student["guardian_surname"]) {
return 1017;
}
if (!$student["guardian_fathername"]) {
return 1018;
}
if (!$student["guardian_mothername"]) {
return 1019;
}
if (!$student["lastschool_registrynumber"]) {
return 1020;
}
if (!$student["lastschool_unittypeid"]) {
return 1021;
}
if (!$student["lastschool_schoolname"]) {
return 1022;
}
if (!$student["lastschool_class"]) {
return 1023;
}
// check as per specs:
// - can't check certification prior to 2014, pass through
// - check certification if last passed class is gym
......
......@@ -99,6 +99,7 @@ class MinisterSettings extends ControllerBase {
$directorViewDisabled = $epalConfig->lock_school_students_view->getString();
$applicantsLoginDisabled = $epalConfig->lock_application->getString();
$applicantsResultsDisabled = $epalConfig->lock_results->getString();
$secondPeriodEnabled = $epalConfig->activate_second_period->getString();
}
$config_storage->resetCache();
......@@ -109,6 +110,7 @@ class MinisterSettings extends ControllerBase {
'directorViewDisabled' => $directorViewDisabled,
'applicantsLoginDisabled' => $applicantsLoginDisabled,
'applicantsResultsDisabled' => $applicantsResultsDisabled,
'secondPeriodEnabled' => $secondPeriodEnabled,
], Response::HTTP_OK);
} //end try
......@@ -125,7 +127,7 @@ class MinisterSettings extends ControllerBase {
}
public function storeSettings(Request $request, $capacityDisabled, $directorViewDisabled, $applicantsLoginDisabled, $applicantsResultsDisabled ) {
public function storeSettings(Request $request, $capacityDisabled, $directorViewDisabled, $applicantsLoginDisabled, $applicantsResultsDisabled, $secondPeriodEnabled ) {
try {
if (!$request->isMethod('GET')) {
......@@ -171,6 +173,8 @@ public function storeSettings(Request $request, $capacityDisabled, $directorView
$epalConfig->set('lock_school_students_view', $directorViewDisabled);
$epalConfig->set('lock_application', $applicantsLoginDisabled);
$epalConfig->set('lock_results', $applicantsResultsDisabled);
$epalConfig->set('activate_second_period', $secondPeriodEnabled);
$epalConfig->save();
}
$config_storage->resetCache();
......@@ -182,6 +186,7 @@ public function storeSettings(Request $request, $capacityDisabled, $directorView
'directorViewDisabled' => $directorViewDisabled,
'applicantsLoginDisabled' => $applicantsLoginDisabled,
'applicantsResultsDisabled' => $applicantsResultsDisabled,
'secondPeriodEnabled' => $secondPeriodEnabled,
], Response::HTTP_OK);
} //end try
......@@ -198,8 +203,6 @@ public function storeSettings(Request $request, $capacityDisabled, $directorView
}
private function respondWithStatus($arr, $s) {
$res = new JsonResponse($arr);
$res->setStatusCode($s);
......
......@@ -75,18 +75,34 @@ class PDFCreator extends ControllerBase {
$authToken = $request->headers->get('PHP_AUTH_USER');
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
/*
return $this->respondWithStatus([
'message' => t("User:") . $authToken,
], Response::HTTP_FORBIDDEN);
*/
if (!$user) {
return $this->respondWithStatus([
'message' => t("User not found"),
], Response::HTTP_FORBIDDEN);
}
//test
/*
return $this->respondWithStatus([
'message' => t("User:") . $authToken,
], Response::HTTP_FORBIDDEN);
*/
//New epal-user validation
$authToken = $request->headers->get('PHP_AUTH_USER');
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken));
$epalUser = reset($epalUsers);
if ($epalUser) {
$userid = $epalUser->id();
$epalStudents = $this->entityTypeManager->getStorage('epal_student')->loadByProperties(array('epaluser_id' => $userid));
if (!$epalStudents) {
return $this->respondWithStatus([
'message' => t("EPAL User not found"),
], Response::HTTP_FORBIDDEN);
}
}
//end New User validation
//user role validation
$roles = $user->getRoles();
......@@ -531,9 +547,8 @@ private function createSchoolChoices($student) {
$this->pdf->Cell($width, $height, $this->prepareString('Σειρά προτίμησης'), 0, 0, 'L');
$this->pdf->multiCell($width, $height, $this->prepareString('ΕΠΑΛ επιλογής'), 0, 'L');
//$this->pdf->Ln();
//$x=$this->pdf->GetX(); $y=$this->pdf->GetY();
/*
$epalSchools = $this->entityTypeManager->getStorage('epal_student_epal_chosen')->loadByProperties(array('student_id'=> $student->id->value));
foreach ($epalSchools as $epalSchool) {
......@@ -545,26 +560,21 @@ private function createSchoolChoices($student) {
$this->pdf->Cell($width, $height, $this->prepareString($epalSchool->choice_no->value), 0, 0, 'C');
$this->pdf->multiCell(4*width, $height, $this->prepareString($epalSchoolName->name->value), 0, 'L');
//$this->pdf->Ln();
}
*/
for ($i = 0; $i < 3; $i++) {
$epalSchools = $this->entityTypeManager->getStorage('epal_student_epal_chosen')->loadByProperties(array('student_id'=> $student->id->value, 'choice_no'=> $i+1 ));
if ($epalSchools) {
$epalSchool = reset($epalSchools);
$epalSchoolNames = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id'=> $epalSchool->epal_id->getString()));
$epalSchoolName = reset($epalSchoolNames);
//....
/*
$this->pdf->SetFont($this->fontLight, '', $this->fontSizeRegular);
$this->pdf->Cell($width, $height, $this->prepareString('Όνομα μαθητή:'), 0, 'L');
$x=$this->pdf->GetX(); $y=$this->pdf->GetY();
$this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular);
$this->pdf->multiCell($width, $height, $this->prepareString($student->name->value), 0, 'L');
$this->pdf->SetFont($this->fontLight, '', $this->fontSizeRegular);
$this->pdf->SetXY($x+$width,$y);
$this->pdf->Cell($width, $height, $this->prepareString('Επώνυμο μαθητή:'), 0, 'L');
$this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular);
$this->pdf->multiCell($width, $height, $this->prepareString($student->studentsurname->value), 0, 'L');
*/
$this->pdf->SetFont($this->fontBold, '', $this->fontSizeRegular);
$this->pdf->Cell($width, $height, $this->prepareString($epalSchool->choice_no->value), 0, 0, 'C');
$this->pdf->multiCell(4*width, $height, $this->prepareString($epalSchoolName->name->value), 0, 'L');
}
}
}
......
......@@ -61,6 +61,71 @@ class ReportsCreator extends ControllerBase {
}
public function makeReportUsers(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);
}
//υπολογισμός αριθμού δηλώσεων
$sCon = $this->connection->select('epal_student', 'eStudent')
->fields('eStudent', array('id'));
$numApplications = $sCon->countQuery()->execute()->fetchField();
//υπολογισμός αριθμού χρηστών
$sCon = $this->connection->select('epal_users', 'eUser')
->fields('eUser', array('id'));
$numUsers = $sCon->countQuery()->execute()->fetchField();
$list = array();
array_push($list,(object) array('name' => "Αριθμός Αιτήσεων", 'numStudents' => $numApplications));
array_push($list,(object) array('name' => "Αριθμός Εγγεγραμένων Χρηστών", 'numStudents' => $numUsers));
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 during makegGeneralReport Method")
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
public function makegGeneralReport(Request $request) {
try {
......
......@@ -280,6 +280,26 @@ class EpalConfig extends ContentEntityBase implements EpalConfigInterface {
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['activate_second_period'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Activate second periods of applications'))
->setDescription(t('Activate second periods of applications.'))
->setSettings(array(
'text_processing' => 0,
))
->setRequired(FALSE)
->setDefaultValue(FALSE)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'boolean',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'boolean',
'weight' => -4,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Publishing status'))
->setDescription(t('A boolean indicating whether the Epal config is published.'))
......
......@@ -101,10 +101,8 @@ import {
private isEdit: boolean;
private courseActive = <number>-1;
private showLoader: BehaviorSubject<boolean>;
private School$: BehaviorSubject<any>;
private SchoolSub: Subscription;
private selectiontype: BehaviorSubject<boolean>;
private SchoolId;
......@@ -116,8 +114,7 @@ import {
this.CapacityPerCourse$ = new BehaviorSubject([{}]);
this.showLoader = new BehaviorSubject(false);
this.isEdit = false;
this.School$ = new BehaviorSubject([{}]);
this.selectiontype = new BehaviorSubject(true);
this.formGroup = this.fb.group({
});
......@@ -148,20 +145,7 @@ import {
ngOnInit() {
(<any>$('#checksaved1')).appendTo("body");
this.SchoolSub = this._hds.gettypeofschool().subscribe(x => {
this.School$.next(x);
console.log(x[0].type, "schoolid!");
this.SchoolId = x[0].type;
if (this.SchoolId == 'ΗΜΕΡΗΣΙΟ'){
this.selectiontype.next(false);
}
},
error => {
this.School$.next([{}]);
console.log("Error Getting School");
},
() => console.log("Getting School "));
......
......@@ -28,10 +28,9 @@ import {
<div style="min-height: 500px;">
<form [formGroup]="formGroup">
<p style="margin-top: 20px; line-height: 2em;"> H παρακάτω λίστα διαμορφώνει τη δυναμική του σχολείου σας σε τμήματα με κριτήριο τον αριθμό των διαθεσίμων αιθουσών. </p>
<p style="margin-top: 20px; line-height: 2em;"> Παρακαλείστε να καταγράψετε τον αριθμό των τμημάτων ανά τάξη, τομέα και ειδικότητα. </p>
<p style="margin-top: 20px; line-height: 2em;"> Στην παρακάτω λίστα βλέπετε τα τμήματα του σχολείου σας. Κάντε κλίκ σε κάθε τμήμα για να δείτε
τους μαθητές που κατανεμίθηκαν μετά απο ηλεκτρονική δήλωση προτίμησης τους στο σχολείο σας. Προσοχή! κάποια τμήματα τα βλέπετε με κόκκινο χρώμα. Τους μαθητές των
τμημάτων αυτών δεν μπορείτε ακόμα να τους εγγράψετε επισήμως στο σχολείο σας. Εκκρεμμεί η έγκριση λειτουργίας των τμημάτων αυτών. </p>
<div class="row" style="margin-top: 20px; line-height: 2em;" > <b> Τα τμήματα του σχολείου σας. </b></div>
<div *ngFor="let CoursesPerSchools$ of CoursesPerSchool$ | async; let i=index; let isOdd=odd; let isEven=even" >
<li class="list-group-item isclickable" (click)="setActive(i)"
......@@ -237,10 +236,6 @@ import {
private courseActive = <number>-1;
private StudentActive = <number>-1;
private showLoader: BehaviorSubject<boolean>;
private School$: BehaviorSubject<any>;
private SchoolSub: Subscription;
private selectiontype: BehaviorSubject<boolean>;
private SchoolId;
private opened;
......@@ -252,32 +247,30 @@ import {
this.CoursesPerSchool$ = new BehaviorSubject([{}]);
this.showLoader = new BehaviorSubject(false);
this.School$ = new BehaviorSubject([{}]);
this.selectiontype = new BehaviorSubject(true);
this.StudentInfo$ = new BehaviorSubject([{}]);
this.retrievedStudent = new BehaviorSubject(false);
this.SavedStudents$ = new BehaviorSubject({});
this.opened = false;
this.formGroup = this.fb.group({
});
});
}
public showModal(popupMsgId):void {
public showModal(popupMsgId): void {
console.log("about to show modal", popupMsgId);
(<any>$(popupMsgId)).modal('show');
}
public hideModal(popupMsgId):void {
public hideModal(popupMsgId): void {
(<any>$(popupMsgId)).modal('hide');
}
public onHidden(popupMsgId):void {
public onHidden(popupMsgId): void {
}
......@@ -287,114 +280,88 @@ import {
}
ngOnInit() {
(<any>$('#checksaved')).appendTo("body");
(<any>$('#dangermodal')).appendTo("body");
(<any>$('#emptyselection')).appendTo("body");
this.SchoolSub = this._hds.gettypeofschool().subscribe(x => {
this.School$.next(x);
console.log(x[0].type, "schoolid!");
this.SchoolId = x[0].type;
if (this.SchoolId == 'ΗΜΕΡΗΣΙΟ'){
this.selectiontype.next(false);
}
},
error => {
this.School$.next([{}]);
console.log("Error Getting School");
},
() => console.log("Getting School "));
this.showLoader.next(true);
this.CoursesPerSchoolSub = this._hds.FindCapacityPerSchool().subscribe(x => {
this.CoursesPerSchool$.next(x);
this.showLoader.next(false);
},
error => {
this.CoursesPerSchool$.next([{}]);
console.log("Error Getting courses perSchool");
this.showLoader.next(false);
},
() => console.log("Getting School "));
(<any>$('#checksaved')).appendTo("body");
(<any>$('#dangermodal')).appendTo("body");
(<any>$('#emptyselection')).appendTo("body");
this.showLoader.next(true);
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);
},
() => console.log("Getting School "));
}
findstudent(taxi,sector,special) {
this.showLoader.next(true);
this.retrievedStudent.next(false);
this.StudentInfoSub = this._hds.getStudentPerSchool(taxi,sector,special)
.subscribe(data => {
this.StudentInfo$.next(data);
this.retrievedStudent.next(true);
this.showLoader.next(false);
},
findstudent(taxi, sector, special) {
this.showLoader.next(true);
this.retrievedStudent.next(false);
this.StudentInfoSub = this._hds.getStudentPerSchool(taxi, sector, 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");
},
() => console.log("Getting Students"));
this.StudentInfo$.next([{}]);
console.log("Error Getting Students");
this.showLoader.next(false);
this.showModal("#emptyselection");
},
() => console.log("Getting Students"));
}
setActive(ind) {
this.StudentActive = -1;
if (this.courseActive == ind)
{
ind = -1;
}
this.courseActive = ind;
console.log(this.courseActive, ind, "ind");
setActive(ind) {
this.StudentActive = -1;
if (this.courseActive == ind) {
ind = -1;
}
this.courseActive = ind;
console.log(this.courseActive, ind, "ind");
}
setActiveStudent(ind)
{
this.opened = true;
if (this.StudentActive == ind)
{
ind = -1;
}
this.StudentActive = ind;
console.log(this.courseActive, ind, "ind");
}
setActiveStudent(ind) {
this.opened = true;
if (this.StudentActive == ind) {
ind = -1;
}
this.StudentActive = ind;
console.log(this.courseActive, ind, "ind");
}