Commit 2679ba6d authored by Open Source Developer's avatar Open Source Developer

capacities view

parent a0e66629
...@@ -79,7 +79,7 @@ epal.allocation: ...@@ -79,7 +79,7 @@ epal.allocation:
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
epal.sectorperschool: epal.sectorperschool:
path: '/epal/sectorperSchool' path: '/epal/sectorperschool'
options: options:
_auth: [ 'basic_auth' ] _auth: [ 'basic_auth' ]
defaults: defaults:
...@@ -87,7 +87,7 @@ epal.sectorperschool: ...@@ -87,7 +87,7 @@ epal.sectorperschool:
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
epal.specialityperschool: epal.specialityperschool:
path: '/epal/specialityperSchool/{sectorId}' path: '/epal/specialityperschool/{sectorId}'
options: options:
_auth: [ 'basic_auth' ] _auth: [ 'basic_auth' ]
defaults: defaults:
...@@ -103,7 +103,7 @@ epal.confirmstudents: ...@@ -103,7 +103,7 @@ epal.confirmstudents:
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
epal.studentperschool: epal.studentperschool:
path: '/epal/studentperSchool/{selectId}/{classId}/{limitdown}/{limitup}' path: '/epal/studentperschool/{selectId}/{classId}/{limitdown}/{limitup}'
options: options:
_auth: [ 'basic_auth' ] _auth: [ 'basic_auth' ]
defaults: defaults:
...@@ -215,7 +215,7 @@ epal.perfectureschools: ...@@ -215,7 +215,7 @@ epal.perfectureschools:
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
epal.coursesperschools: epal.coursesperschools:
path: '/epal/CoursesperSch/{schoolid}' path: '/epal/coursespersch/{schoolid}'
options: options:
_auth: [ 'basic_auth' ] _auth: [ 'basic_auth' ]
defaults: defaults:
...@@ -231,7 +231,7 @@ epal.critirioschosen: ...@@ -231,7 +231,7 @@ epal.critirioschosen:
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
epal.findcapacity: epal.findcapacity:
path: '/epal/findCapacity/{taxi}/{tomeas}/{specialit}' path: '/epal/findcapacity/{taxi}/{tomeas}/{specialit}'
options: options:
_auth: [ 'basic_auth' ] _auth: [ 'basic_auth' ]
defaults: defaults:
...@@ -254,11 +254,19 @@ epal.gettypeofschool: ...@@ -254,11 +254,19 @@ epal.gettypeofschool:
_controller: '\Drupal\epal\Controller\DirectorView::gettypeofschool' _controller: '\Drupal\epal\Controller\DirectorView::gettypeofschool'
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
getlimitspercourse: epal.getlimitspercourse:
path: '/epal/getlimitsperCourse/{classid}' path: '/epal/getlimitspercourse/{classid}'
options: options:
_auth: [ 'basic_auth' ] _auth: [ 'basic_auth' ]
defaults: defaults:
_controller: '\Drupal\epal\Controller\DirectorView::getlimitsperCourse' _controller: '\Drupal\epal\Controller\DirectorView::getlimitsperCourse'
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
epal.findcapacityperschool:
path: '/epal/findcapacityperschool'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::FindCapacityPerSchool'
requirements:
_user_is_logged_in: 'TRUE'
...@@ -499,9 +499,6 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit) ...@@ -499,9 +499,6 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit)
} }
public function getCoursesPerSchool(Request $request, $schoolid) public function getCoursesPerSchool(Request $request, $schoolid)
{ {
$authToken = $request->headers->get('PHP_AUTH_USER'); $authToken = $request->headers->get('PHP_AUTH_USER');
...@@ -509,13 +506,31 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit) ...@@ -509,13 +506,31 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit)
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken)); $users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users); $user = reset($users);
if ($user) if ($user)
{ {
$newid = $user -> init -> value;
$userRoles = $user->getRoles();
$userRole = '';
foreach ($userRoles as $tmpRole) {
if (($tmpRole === 'regioneduadmin') || ($tmpRole === 'eduadmin')) {
$userRole = $tmpRole;
}
}
if ($userRole === '') {
return $this->respondWithStatus([
'error_code' => 4003,
], Response::HTTP_FORBIDDEN);
}
$list= array(); else if ($userRole === 'regioneduadmin') {
$SchoolCats = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id'=> $schoolid, 'region_edu_admin_id' => $newid));
}
else if ($userRole === 'eduadmin') {
$SchoolCats = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id'=> $schoolid , 'edu_admin_id' => $newid));
}
$SchoolCats = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id'=> $schoolid ));
$SchoolCat = reset($SchoolCats); $SchoolCat = reset($SchoolCats);
if ($SchoolCat){ if ($SchoolCat){
$list= array();
$categ = $SchoolCat-> metathesis_region -> value; $categ = $SchoolCat-> metathesis_region -> value;
} }
$CourseA = $this->entityTypeManager->getStorage('epal_student')->loadByProperties(array('id'=> $schoolid )); $CourseA = $this->entityTypeManager->getStorage('epal_student')->loadByProperties(array('id'=> $schoolid ));
...@@ -981,6 +996,110 @@ public function gettypeofschool(Request $request) ...@@ -981,6 +996,110 @@ public function gettypeofschool(Request $request)
public function FindCapacityPerSchool(Request $request)
{
$authToken = $request->headers->get('PHP_AUTH_USER');
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if ($user) {
$schoolid = $user -> init -> value;
$schools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id'=> $schoolid));
$school = reset($schools);
if (!$school) {
$this->logger->warning("no access to this school=" . $user->id());
$response = new Response();
$response->setContent('No access to this school');
$response->setStatusCode(Response::HTTP_FORBIDDEN);
$response->headers->set('Content-Type', 'application/json');
return $response;
}
$list = array();
$CapacityPerClass = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id' => $schoolid ));
$classcapacity = reset($CapacityPerClass);
if ($classcapacity) {
$list[] = array(
'class' => 1,
'taxi' => 'Ά Λυκείου',
'capacity' => $classcapacity -> capacity_class_a -> value ,
);
}
$CourseB = $this->entityTypeManager->getStorage('eepal_sectors_in_epal')->loadByProperties(array('epal_id' => $schoolid ));
if ($CourseB)
{
foreach ($CourseB as $object)
{
$sectorid = $object -> sector_id -> entity -> id();
$CapacityPerClass = $this->entityTypeManager->getStorage('eepal_sectors_in_epal')->loadByProperties(array('epal_id' => $schoolid, 'sector_id' => $sectorid ));
$classcapacity = reset($CapacityPerClass);
if ($classcapacity) {
$list[] = array(
'class' => 2,
'taxi' => 'Β Λυκείου '.$object -> sector_id -> entity-> get('name')->value,
'capacity' => $classcapacity -> capacity_class_sector -> value ,
);
}
}
}
$CourseC = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $schoolid ));
if ($CourseC)
{
foreach ($CourseC as $object) {
$specialityid = $object -> specialty_id -> entity -> id() ;
$CapacityPerClass = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $schoolid, 'specialty_id' => $specialityid));
$classcapacity = reset($CapacityPerClass);
if ($classcapacity) {
$list[] = array(
'class' => 3,
'taxi' => 'Γ Λυκείου '.$object -> specialty_id -> entity-> get('name')->value,
'capacity' => $classcapacity -> capacity_class_specialty -> value ,
);
}
}
}
if ($CourseC)
{
foreach ($CourseC as $object)
{
$specialityid = $object -> specialty_id -> entity -> id() ;
$CapacityPerClass = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $schoolid, 'specialty_id' => $specialityid));
$classcapacity = reset($CapacityPerClass);
if ($classcapacity) {
$list[] = array(
'class' => 4,
'taxi' => 'Δ Λυκείου '.$object -> specialty_id -> entity-> get('name')->value,
'capacity' => $classcapacity -> capacity_class_specialty_d -> value ,
);
}
}
}
return $this->respondWithStatus(
$list
, Response::HTTP_OK);
} else {
return $this->respondWithStatus([
'message' => t("EPAL user not found"),
], Response::HTTP_FORBIDDEN);
}
}
private function respondWithStatus($arr, $s) { private function respondWithStatus($arr, $s) {
$res = new JsonResponse($arr); $res = new JsonResponse($arr);
$res->setStatusCode($s); $res->setStatusCode($s);
......
...@@ -17,13 +17,14 @@ import {minValue} from '../../constants'; ...@@ -17,13 +17,14 @@ import {minValue} from '../../constants';
import { import {
FormBuilder, FormBuilder,
FormGroup, FormGroup,
FormControl, FormControl,
FormArray, FormArray,
Validators, Validators,
} from '@angular/forms'; } from '@angular/forms';
@Component({ @Component({
selector: 'director-classcapacity', selector: 'director-classcapacity',
template: ` template: `
<div class = "loading" *ngIf="(showLoader | async) === true"></div>
<div style="min-height: 500px;"> <div style="min-height: 500px;">
<form [formGroup]="formGroup"> <form [formGroup]="formGroup">
<label for="taxi">Τάξη</label><br/> <label for="taxi">Τάξη</label><br/>
...@@ -68,8 +69,21 @@ import { ...@@ -68,8 +69,21 @@ import {
Αποθήκευση Αποθήκευση
</button> </button>
</form> </form>
<br>
<br>
<div class="row"> <b>Οι δηλώσεις σας </b></div>
<div *ngFor="let CapacityPerCourses$ of CapacityPerCourse$ | async; let i=index; let isOdd=odd; let isEven=even" >
<li *ngIf="(CapacityPerCourses$.class != 4)" class="list-group-item " [class.oddout]="isOdd" [class.evenout]="isEven" >
<h5 >{{CapacityPerCourses$.taxi}}&nbsp;{{CapacityPerCourses$.capacity}} </h5>
</li>
</div> </div>
</div>
<div id="checksaved" (onHidden)="onHidden('#checksaved')" <div id="checksaved" (onHidden)="onHidden('#checksaved')"
class="modal fade" tabindex="-1" role="dialog" aria-hidden="true"> class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg"> <div class="modal-dialog modal-lg">
...@@ -131,6 +145,8 @@ import { ...@@ -131,6 +145,8 @@ import {
private selectionCClass: BehaviorSubject<boolean>; private selectionCClass: BehaviorSubject<boolean>;
private School$: BehaviorSubject<any>; private School$: BehaviorSubject<any>;
private SchoolSub: Subscription; private SchoolSub: Subscription;
private CapacityPerCourse$: BehaviorSubject<any>;
private CapacityPerCourseSub: Subscription;
private SchoolId; private SchoolId;
private currentclass: Number; private currentclass: Number;
private classCapacity$: BehaviorSubject<any>; private classCapacity$: BehaviorSubject<any>;
...@@ -139,6 +155,7 @@ import { ...@@ -139,6 +155,7 @@ import {
private modalTitle: BehaviorSubject<string>; private modalTitle: BehaviorSubject<string>;
private modalText: BehaviorSubject<string>; private modalText: BehaviorSubject<string>;
private modalHeader: BehaviorSubject<string>; private modalHeader: BehaviorSubject<string>;
private showLoader: BehaviorSubject<boolean>;
...@@ -150,6 +167,7 @@ import { ...@@ -150,6 +167,7 @@ import {
this.StudentSelected$ = new BehaviorSubject([{}]); this.StudentSelected$ = new BehaviorSubject([{}]);
this.StudentSelectedSpecial$ = new BehaviorSubject([{}]); this.StudentSelectedSpecial$ = new BehaviorSubject([{}]);
this.classCapacity$ = new BehaviorSubject([{}]); this.classCapacity$ = new BehaviorSubject([{}]);
this.CapacityPerCourse$ = new BehaviorSubject([{}]);
this.selectionBClass = new BehaviorSubject(false); this.selectionBClass = new BehaviorSubject(false);
this.selectiontype = new BehaviorSubject(true); this.selectiontype = new BehaviorSubject(true);
this.selectionCClass = new BehaviorSubject(false); this.selectionCClass = new BehaviorSubject(false);
...@@ -158,6 +176,7 @@ import { ...@@ -158,6 +176,7 @@ import {
this.modalTitle = new BehaviorSubject(""); this.modalTitle = new BehaviorSubject("");
this.modalText = new BehaviorSubject(""); this.modalText = new BehaviorSubject("");
this.modalHeader = new BehaviorSubject(""); this.modalHeader = new BehaviorSubject("");
this.showLoader = new BehaviorSubject(false);
this.formGroup = this.fb.group({ this.formGroup = this.fb.group({
tomeas: ['', []], tomeas: ['', []],
taxi: ['', []], taxi: ['', []],
...@@ -205,8 +224,9 @@ import { ...@@ -205,8 +224,9 @@ import {
(<any>$('#capacitysaved')).appendTo("body"); (<any>$('#capacitysaved')).appendTo("body");
(<any>$('#checksaved')).appendTo("body"); (<any>$('#checksaved')).appendTo("body");
this.retrievedStudent.next(false); this.retrievedStudent.next(false);
this.SchoolSub = this._hds.gettypeofschool().subscribe(x => { this.SchoolSub = this._hds.gettypeofschool().subscribe(x => {
this.School$.next(x); this.School$.next(x);
console.log(x[0].type, "schoolid!"); console.log(x[0].type, "schoolid!");
this.SchoolId = x[0].type; this.SchoolId = x[0].type;
...@@ -221,6 +241,20 @@ import { ...@@ -221,6 +241,20 @@ import {
}, },
() => console.log("Getting School ")); () => console.log("Getting School "));
this.CapacityPerCourseSub = this._hds.FindCapacityPerSchool().subscribe(x => {
this.CapacityPerCourse$.next(x);
},
error => {
this.CapacityPerCourse$.next([{}]);
console.log("Error Getting Capacity perSchool");
},
() => console.log("Getting School "));
} }
...@@ -235,7 +269,9 @@ import { ...@@ -235,7 +269,9 @@ import {
capacity: '', capacity: '',
}); });
console.log("a class"); console.log("a class");
this.showLoader.next(true);
this.classCapacitySub = this._hds.getCapacityPerSchool(this.formGroup.value.taxi, 0, 0).subscribe(data => { this.classCapacitySub = this._hds.getCapacityPerSchool(this.formGroup.value.taxi, 0, 0).subscribe(data => {
this.showLoader.next(false);
this.classCapacity$.next(data); this.classCapacity$.next(data);
this.retrievedStudent.next(true); this.retrievedStudent.next(true);
this.formGroup.patchValue({ this.formGroup.patchValue({
...@@ -294,9 +330,11 @@ import { ...@@ -294,9 +330,11 @@ import {
console.log(tmop, txop, "tomeas!!!!"); console.log(tmop, txop, "tomeas!!!!");
if (txop.value === "2") { if (txop.value === "2") {
console.log("b class"); console.log("b class");
this.showLoader.next(true);
this.classCapacitySub = this._hds.getCapacityPerSchool(this.formGroup.value.taxi, sectorint, 0).subscribe(data => { this.classCapacitySub = this._hds.getCapacityPerSchool(this.formGroup.value.taxi, sectorint, 0).subscribe(data => {
this.classCapacity$.next(data); this.classCapacity$.next(data);
this.retrievedStudent.next(true); this.retrievedStudent.next(true);
this.showLoader.next(false);
this.formGroup.patchValue({ this.formGroup.patchValue({
capacity : data[0].capacity, capacity : data[0].capacity,
}); });
...@@ -324,10 +362,11 @@ import { ...@@ -324,10 +362,11 @@ import {
if (txop.value === "3" || txop.value === "4") { if (txop.value === "3" || txop.value === "4") {
console.log("c class"); console.log("c class");
console.log(sectorint, specialint, "cclass") console.log(sectorint, specialint, "cclass")
this.showLoader.next(true);
this.classCapacitySub = this._hds.getCapacityPerSchool(this.formGroup.value.taxi, sectorint, specialint).subscribe(data => { this.classCapacitySub = this._hds.getCapacityPerSchool(this.formGroup.value.taxi, sectorint, specialint).subscribe(data => {
this.classCapacity$.next(data); this.classCapacity$.next(data);
this.retrievedStudent.next(true); this.retrievedStudent.next(true);
this.showLoader.next(false);
this.formGroup.patchValue({ this.formGroup.patchValue({
capacity : data[0].capacity, capacity : data[0].capacity,
}); });
...@@ -359,8 +398,9 @@ import { ...@@ -359,8 +398,9 @@ import {
this.showModal("#checksaved"); this.showModal("#checksaved");
} else } else
{ {
this.showLoader.next(true);
this.saveCapacitySub = this._hds.saveCapacity(this.formGroup.value.taxi, tomeas, specialit, this.formGroup.value.capacity).subscribe(data => { this.saveCapacitySub = this._hds.saveCapacity(this.formGroup.value.taxi, tomeas, specialit, this.formGroup.value.capacity).subscribe(data => {
this.showLoader.next(false);
}, },
error => { error => {
...@@ -370,10 +410,20 @@ import { ...@@ -370,10 +410,20 @@ import {
console.log("Saved Capacity"); console.log("Saved Capacity");
this.showModal("#capacitysaved"); this.showModal("#capacitysaved");
}); });
}
this.CapacityPerCourseSub = this._hds.FindCapacityPerSchool().subscribe(x => {
this.CapacityPerCourse$.next(x);
},
error => {
this.CapacityPerCourse$.next([{}]);
console.log("Error Getting Capacity perSchool");
},
() => console.log("Getting School "));
}
} }
......
...@@ -486,7 +486,7 @@ export class HelperDataService implements OnInit, OnDestroy { ...@@ -486,7 +486,7 @@ export class HelperDataService implements OnInit, OnDestroy {
}); });
this.createAuthorizationHeader(headers); this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers }); let options = new RequestOptions({ headers: headers });
return this.http.get(`${AppSettings.API_ENDPOINT}/epal/sectorperSchool/` , options) return this.http.get(`${AppSettings.API_ENDPOINT}/epal/sectorperschool/` , options)
.map(response => response.json()); .map(response => response.json());
} }
...@@ -503,7 +503,7 @@ export class HelperDataService implements OnInit, OnDestroy { ...@@ -503,7 +503,7 @@ export class HelperDataService implements OnInit, OnDestroy {
}); });
this.createAuthorizationHeader(headers); this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers }); let options = new RequestOptions({ headers: headers });
return this.http.get(`${AppSettings.API_ENDPOINT}/epal/specialityperSchool/` + SectorIdNew, options) return this.http.get(`${AppSettings.API_ENDPOINT}/epal/specialityperschool/` + SectorIdNew, options)
.map(response => response.json()); .map(response => response.json());
} }
...@@ -524,7 +524,7 @@ export class HelperDataService implements OnInit, OnDestroy { ...@@ -524,7 +524,7 @@ export class HelperDataService implements OnInit, OnDestroy {
}); });
this.createAuthorizationHeader(headers); this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers }); let options = new RequestOptions({ headers: headers });
return this.http.get(`${AppSettings.API_ENDPOINT}/epal/studentperSchool/` + SelectIdNew + '/' + classId + '/' + limitdown + '/' + limitup, options) return this.http.get(`${AppSettings.API_ENDPOINT}/epal/studentperschool/` + SelectIdNew + '/' + classId + '/' + limitdown + '/' + limitup, options)
.map(response => response.json()); .map(response => response.json());
} }
...@@ -689,7 +689,7 @@ export class HelperDataService implements OnInit, OnDestroy { ...@@ -689,7 +689,7 @@ export class HelperDataService implements OnInit, OnDestroy {
}); });
this.createAuthorizationHeader(headers); this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers }); let options = new RequestOptions({ headers: headers });
return this.http.get(`${AppSettings.API_ENDPOINT}/epal/CoursesperSch/` + PerfectureIdNew , options) return this.http.get(`${AppSettings.API_ENDPOINT}/epal/coursespersch/` + PerfectureIdNew , options)
.map(response => response.json()); .map(response => response.json());
} }
...@@ -845,7 +845,7 @@ getCapacityPerSchool(taxi, tomeas, specialit) { ...@@ -845,7 +845,7 @@ getCapacityPerSchool(taxi, tomeas, specialit) {
}); });
this.createAuthorizationHeader(headers); this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers }); let options = new RequestOptions({ headers: headers });
return this.http.get(`${AppSettings.API_ENDPOINT}/epal/findCapacity/` + taxi + '/' + tomeas + '/' + specialit, options) return this.http.get(`${AppSettings.API_ENDPOINT}/epal/findcapacity/` + taxi + '/' + tomeas + '/' + specialit, options)
.map(response => response.json()); .map(response => response.json());
} }
...@@ -893,7 +893,24 @@ getlimitsofcourse(classid){ ...@@ -893,7 +893,24 @@ getlimitsofcourse(classid){
}); });
this.createAuthorizationHeader(headers); this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers }); let options = new RequestOptions({ headers: headers });
return this.http.get(`${AppSettings.API_ENDPOINT}/epal/getlimitsperCourse/`+ classid , options) return this.http.get(`${AppSettings.API_ENDPOINT}/epal/getlimitspercourse/`+ classid , options)
.map(response => response.json());
}
FindCapacityPerSchool(){
this.loginInfo$.getValue().forEach(loginInfoToken => {
this.authToken = loginInfoToken.auth_token;
this.authRole = loginInfoToken.auth_role;
});
let headers = new Headers({
"Content-Type": "application/json",
});
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers });
return this.http.get(`${AppSettings.API_ENDPOINT}/epal/findcapacityperschool/` , options)
.map(response => response.json()); .map(response => response.json());
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment