Commit 99593fe7 authored by Χάρης Παπαδόπουλος's avatar Χάρης Παπαδόπουλος
Browse files

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.'))
......
import { Component, OnInit, OnDestroy, ElementRef, ViewChild} from "@angular/core";
import { Injectable } from "@angular/core";
import { AppSettings } from '../../app.settings';
import { HelperDataService } from '../../services/helper-data-service';
import {Observable} from "rxjs/Observable";
import {Http, Headers, RequestOptions} from '@angular/http';
import { NgRedux, select } from 'ng2-redux';
import { IAppState } from '../../store/store';
import {Router, ActivatedRoute, Params} from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import { ILoginInfo } from '../../store/logininfo/logininfo.types';
import { VALID_CAPACITY_PATTERN} from '../../constants';
import {maxValue} from '../../constants';
import {minValue} from '../../constants';
import {
FormBuilder,
FormGroup,
FormControl,
FormArray,
Validators,
} from '@angular/forms';
@Component({
selector: 'director-classcapacity',
template: `
<div class = "loading" *ngIf="(showLoader | async) === true"></div>
<div style="min-height: 500px;">
<form [formGroup]="formGroup">
<label for="taxi">Τάξη</label><br/>
<div class="form-group">
<select #txoption class="form-control" (change)="verifyclass(txoption)" formControlName="taxi">
<option value="1" >Α' Λυκείου</option>
<option value="2" >Β' Λυκείου</option>
<option value="3" >Γ' Λυκείου</option>
<option *ngIf="(selectiontype | async)" value="4" >Δ' Λυκείου</option>
</select>
</div>
<div class="form-group">
<select #tmop class="form-control" *ngIf="(selectionBClass | async)" (change)="checkbclass(tmop,txoption)" formControlName="tomeas">
<option *ngFor="let SectorSelection$ of StudentSelected$ | async; let i=index" [value] = "SectorSelection$.id"> {{SectorSelection$.sector_id}} </option>
</select>
</div>
<div class="form-group">
<select #spop class="form-control" *ngIf="(selectionCClass | async)" (change)="checkcclass(tmop,txoption,spop)" formControlName="specialit">
<option *ngFor="let SpecialSelection$ of StudentSelectedSpecial$ | async; let i=index" [value] = "SpecialSelection$.id"> {{SpecialSelection$.specialty_id}} </option>
</select>
</div>
<p style="margin-top: 20px; line-height: 2em;"> Αλλάξτε παρακαλώ τον αριθμό των τμημάτων που μπορείτε να δημιουργήσετε στο σχολείο σας και πατήστε <i>Αποθήκευση</i>.</p>
<input type="number" formControlName="capacity" min="1" max="10" ng-min="1" ng-max="99" >
<div class="alert alert-danger" *ngIf="formGroup.get('capacity').touched && formGroup.get('capacity').hasError('maxValue')">
Παρακαλώ συμπληρώστε ένα μικρότερο αριθμό!
</div>
<div class="alert alert-danger" *ngIf="formGroup.get('capacity').touched && formGroup.get('capacity').hasError('minValue')">
Παρακαλώ συμπληρώστε ένα μεγαλύτερο αριθμό!
</div>
<div class="alert alert-danger" *ngIf="formGroup.get('capacity').touched && formGroup.get('capacity').hasError('required')">
Συμπληρώστε την διαθεσιμότητα σας σε τμήματα !
</div>
<button type="button" class="btn-primary btn-sm pull-right" (click) ="saveCapacity()">
Αποθήκευση
</button>
</form>
<br>
<br>
<div class="row" style="margin-top: 20px; line-height: 2em;" > <b> Οι δηλώσεις σας </b></div>
<div *ngFor="let CapacityPerCourses$ of CapacityPerCourse$ | async; let i=index; let isOdd=odd; let isEven=even" >
<li *ngIf="(!(selectiontype | async) && (CapacityPerCourses$.class < 4)) ||((selectiontype | async) && (CapacityPerCourses$.class < 5))" class="list-group-item " [class.oddout]="isOdd" [class.evenout]="isEven" >
<h5 [class.changelistcolor]= "CapacityPerCourses$.capacity === null" >{{CapacityPerCourses$.taxi}}&nbsp; <b>{{CapacityPerCourses$.capacity}}</b></h5>
</li>
</div>
</div>
<div id="checksaved" (onHidden)="onHidden('#checksaved')"
class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<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-check-square-o"></i>&nbsp;&nbsp;Πρέπει να συπληρώσετε όλα τα πεδία</h3>
<button type="button" class="close pull-right" aria-label="Close" (click)="hideModal('#checksaved')">
<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">Κλείσιμο</button>
</div>
</div>
</div>
</div>
<div id="capacitysaved" (onHidden)="onHidden('#capacitysaved')"
class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header modal-header-success">
<h3 class="modal-title pull-left"><i class="fa fa-check-square-o"></i>&nbsp;&nbsp;Αποθήκευση Δυναμικής</h3>
<button type="button" class="close pull-right" aria-label="Close" (click)="hideModal('#capacitysaved')">
<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">Κλείσιμο</button>
</div>
</div>
</div>
</div>
`
})
@Injectable() export default class DirectorClassCapacity implements OnInit, OnDestroy {