conflict resolution

parents f5c46168 43b77c51
......@@ -310,4 +310,4 @@ class CASLogin extends ControllerBase
return false;
}
}
}
\ No newline at end of file
......@@ -152,4 +152,4 @@ class CASLogout extends ControllerBase
return new RedirectResponseWithCookieExt($this->redirectUrl .'&error_code=' . $errorCode, 302, []);
}
}
}
}
\ No newline at end of file
......@@ -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;
}
}
......@@ -206,3 +206,12 @@ findcapacity:
_controller: '\Drupal\epal\Controller\DirectorView::findCapacity'
requirements:
_user_is_logged_in: 'TRUE'
findschoolid:
path: '/epal/getschool'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::getSchoolID'
requirements:
_user_is_logged_in: 'TRUE'
......@@ -687,6 +687,48 @@ public function findCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid
}
public function getSchoolID(Request $request)
{
$authToken = $request->headers->get('PHP_AUTH_USER');
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if ($user) {
$schid = intval($user -> init -> value );
$list = array();
$list[] = array(
'id' => $schid
);
$i++;
return $this->respondWithStatus(
$list
, Response::HTTP_OK);
} else {
return $this->respondWithStatus([
'message' => t("User not found!"),
], Response::HTTP_FORBIDDEN);
}
}
private function respondWithStatus($arr, $s) {
$res = new JsonResponse($arr);
$res->setStatusCode($s);
......
......@@ -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;
}
......
......@@ -156,6 +156,8 @@ import {
public formGroup: FormGroup;
private StudentSelected$: BehaviorSubject<any>;
private StudentSelectedSub: Subscription;
private School$: BehaviorSubject<any>;
private SchoolSub: Subscription;
private StudentInfo$: BehaviorSubject<any>;
private StudentInfoSub: Subscription;
private StudentsSize$: BehaviorSubject<any>;
......@@ -167,7 +169,7 @@ import {
private retrievedStudent: BehaviorSubject<boolean>;
private selectionBClass: BehaviorSubject<boolean>;
private selectionCClass: BehaviorSubject<boolean>;
private SchoolId = 147;
private SchoolId ;
private currentclass: Number;
private saved: Array<number> = new Array();
private limitdown = 0;
......@@ -192,6 +194,9 @@ import {
this.retrievedStudent = new BehaviorSubject(false);
this.selectionBClass = new BehaviorSubject(false);
this.selectionCClass = new BehaviorSubject(false);
this.School$ = new BehaviorSubject([{}]);
this.formGroup = this.fb.group({
tomeas: ['', []],
taxi: ['', []],
......@@ -220,10 +225,24 @@ import {
ngOnInit() {
}
this.SchoolSub = this._hds.getSchoolId().subscribe(x => {
this.School$.next(x);
console.log(x[0].id, "schoolid!");
this.SchoolId = x[0].id;
},
error => {
this.School$.next([{}]);
console.log("Error Getting School");
},
() => console.log("Getting School "));
}
verifyclass(txop) {
console.log(this.SchoolId,"schoolida");
this.pageno = 1;
this.retrievedStudent.next(false);
if (txop.value === "1") {
......@@ -275,6 +294,7 @@ import {
checkbclass(tmop, txop) {
console.log(this.SchoolId,"schoolidn");
this.pageno = 1;
this.retrievedStudent.next(false);
var sectorint = +this.formGroup.value.tomeas;
......@@ -321,8 +341,6 @@ import {
}
// this.StudentInfo$ = new BehaviorSubject([{}]);
// this.StudentInfoSub = this._hds.getStudentPerSchool(this.SchoolId, sectorint, this.currentclass).subscribe(this.StudentInfo$);
this.StudentInfoSub = this._hds.getStudentPerSchool(this.SchoolId, sectorint, this.currentclass, this.limitdown, this.limitup).subscribe(data => {
this.StudentInfo$.next(data);
this.retrievedStudent.next(true);
......@@ -363,9 +381,6 @@ import {
confirmStudent() {
this._hds.saveConfirmStudents(this.saved, this.type);
let event = new MouseEvent('click', { bubbles: true });
this.fileInput.nativeElement.dispatchEvent(event);
}
checkcclass() {
......
......@@ -55,8 +55,11 @@ import {
private CoursesPerPerfSub: Subscription;
private StudentsSize$: BehaviorSubject<any>;
private StudentsSizeSub: Subscription;
public perfecture = 1;
public perfecture ;
private regionActive = <number>-1;
private School$: BehaviorSubject<any>;
private SchoolSub: Subscription;
constructor(private fb: FormBuilder,
......@@ -67,6 +70,7 @@ import {
this.LimitPerCateg$ = new BehaviorSubject([{}]);
this.CoursesPerPerf$ = new BehaviorSubject([{}]);
this.StudentsSize$ = new BehaviorSubject({});
this.School$ = new BehaviorSubject([{}]);
this.formGroup = this.fb.group({
});
......@@ -77,6 +81,19 @@ import {
ngOnInit() {
this.SchoolSub = this._hds.getSchoolId().subscribe(x => {
this.School$.next(x);
console.log(x[0].id, "perfectureID");
this.perfecture = x[0].id;
},
error => {
this.School$.next([{}]);
console.log("Error Getting School");
},
() => console.log("Getting School "));
this.SchoolPerPerfSub = this._hds.getSchoolPerPerfecture(this.perfecture).subscribe(data => {
this.SchoolsPerPerf$.next(data);
......
......@@ -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';