Commit 582f8c41 authored by Open Source Developer's avatar Open Source Developer

trans

parent f5ca8c2d
......@@ -90,3 +90,20 @@ sectorperschool:
_controller: '\Drupal\epal\Controller\DirectorView::getSectorsPerSchool'
requirements:
_user_is_logged_in: 'TRUE'
specialityperschool:
path: '/epal/specialityperSchool/{epalId}/{sectorId}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::getSpecialPerSchool'
requirements:
_user_is_logged_in: 'TRUE'
studentperschool:
path: '/epal/studentperSchool/{epalId}/{selectId}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::getStudentPerSchool'
requirements:
_user_is_logged_in: 'TRUE'
......@@ -26,8 +26,6 @@ class DirectorView extends ControllerBase
}
public function getSectorsPerSchool(Request $request, $epalId)
{
......@@ -74,7 +72,115 @@ public function getSectorsPerSchool(Request $request, $epalId)
}
public function getSpecialPerSchool(Request $request, $epalId , $sectorId)
{
$authToken = $request->headers->get('PHP_AUTH_USER');
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken));
$epalUser = reset($epalUsers);
if ($epalUser) {
$userid = $epalUser -> user_id -> entity -> id();
$epalIdNew = intval($epalId);
$specialityPerSchool = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id'=> $epalIdNew));
$i = 0;
if ($specialityPerSchool) {
$list = array();
$SectorIdNew = intval($sectorId);
foreach ($specialityPerSchool as $object) {
$idSpecial = $object -> specialty_id -> entity -> id() ;
$specialityPerSector = $this->entityTypeManager->getStorage('eepal_specialty')->loadByProperties(array('id'=> $idSpecial,'sector_id' => $SectorIdNew ));
$specialPerSec = reset($specialityPerSector);
if ($specialPerSec)
{ $list[] = array(
'specialty_id' => $object -> specialty_id ->entity->get('name')->value ,
'id' => $object -> specialty_id -> entity -> id() );
$i++;
}
}
return $this->respondWithStatus(
$list
, Response::HTTP_OK);
}
else {
return $this->respondWithStatus([
'message' => t("School not found!!!"),
], Response::HTTP_FORBIDDEN);
}
} else {
return $this->respondWithStatus([
'message' => t("User not found!"),
], Response::HTTP_FORBIDDEN);
}
}
public function getStudentPerSchool(Request $request, $epalId , $selectId)
{
$authToken = $request->headers->get('PHP_AUTH_USER');
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken));
$epalUser = reset($epalUsers);
if ($epalUser) {
$userid = $epalUser -> user_id -> entity -> id();
$epalIdNew = intval($epalId);
$selectIdNew = intval($selectId);
$studentPerSchool = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('epal_id'=> $epalIdNew, 'specialization_id' => $selectIdNew ));
$i = 0;
if ($studentPerSchool) {
$list = array();
foreach ($studentPerSchool as $object)
{
$studentId = $object -> id() ;
$epalStudents = $this->entityTypeManager->getStorage('epal_student')->loadByProperties(array('id'=> $studentId));
$i = 0;
if ($epalStudents) {
$list[] = array(
'name' => $epalStudents -> name ->value,
'studentsurname' => $epalStudents -> studentsurname ->value,
'fatherfirstname' => $epalStudents -> fatherfirstname ->value,
'fathersurname' =>$epalStudents -> fathersurtname ->value,
'motherfirstname' => $epalStudents -> motherfirstname ->value,
'mothersurname' =>$epalStudents -> mothersurname ->value,
'birthdate' =>$epalStudents -> birthdate ->value,
);
$i++;
}
}
return $this->respondWithStatus(
$list
, Response::HTTP_OK);
}
else {
return $this->respondWithStatus([
'message' => t("No students found!!!"),
], Response::HTTP_FORBIDDEN);
}
}
else {
return $this->respondWithStatus([
'message' => t("User not found!"),
], Response::HTTP_FORBIDDEN);
}
}
......
......@@ -20,7 +20,7 @@ import {
selector: 'director-view',
template: `
<form [formGroup]="formGroup">
<form [formGroup]="formGroup">
<div class="form-group" >
<label for="name">Τάξη</label><br/>
<select #txoption [(ngModel)]="taxi" [ngModelOptions]="{standalone: true}" (change)="verifyclass(txoption)" >
......@@ -30,12 +30,23 @@ import {
</select>
<div>
<div class="form-group" *ngIf="(StudentSelected$ != {}) && (bclassenabled === true)">
<div class="form-group" *ngIf="StudentSelected$ != {}" >
<label for="tomeas">Τομέας</label><br/>
<select #tmop [(ngModel)]="tomeas" [ngModelOptions]="{standalone: true}" >
<select #tmop [(ngModel)]="tomeas" [ngModelOptions]="{standalone: true}" (change) ="checkbclass(tmop,txoption)" >
<option *ngFor="let SectorSelection$ of StudentSelected$ | async" [ngValue]="SectorSelection$.id">{{SectorSelection$.sector_id}}</option>
</select>
<div>
<div class="form-group" *ngIf="StudentSelectedSpecial$ != {}">
<label for="special">Ειδικότητα</label><br/>
<select #spop [(ngModel)]="specialit" [ngModelOptions]="{standalone: true}" >
<option *ngFor="let SpecialSelection$ of StudentSelectedSpecial$ | async" [ngValue]="SpecialSelection$.id">{{SpecialSelection$.specialty_id}}</option>
</select>
<div>
<button type="button" class="btn-primary btn-sm pull-right" (click)="findstudent()">
Αναζήτηση
</button>
`
})
......@@ -45,10 +56,13 @@ import {
public formGroup: FormGroup;
private StudentSelected$: BehaviorSubject<any>;
private StudentSelectedSub: Subscription;
private StudentSelectedSpecial$: BehaviorSubject<any>;
private StudentSelectedSpecialSub: Subscription;
public bClassEnabled: boolean;
public gClassEnabled: boolean;
private SchoolId = 12 ;
private SchoolId = 147 ;
constructor(private fb: FormBuilder,
private _hds: HelperDataService,
......@@ -56,9 +70,11 @@ import {
private router: Router )
{
this.StudentSelected$ = new BehaviorSubject([{}]);
this.StudentSelectedSpecial$ = new BehaviorSubject([{}]);
this.formGroup = this.fb.group({
taxi:[],
tomeas: []
tomeas: [],
specialit :[]
});
}
......@@ -66,6 +82,9 @@ import {
{
if (this.StudentSelectedSub)
this.StudentSelectedSub.unsubscribe();
if (this.StudentSelectedSpecialSub)
this.StudentSelectedSpecialSub.unsubscribe();
}
......@@ -73,7 +92,10 @@ import {
this.bClassEnabled = false;
this.gClassEnabled = false;
this.StudentSelectedSub = this._hds.getSectorPerSchool(this.SchoolId).subscribe(this.StudentSelected$);
this.StudentSelectedSub = this._hds.getSectorPerSchool(this.SchoolId).subscribe(this.StudentSelected$);
console.log(this.StudentSelected$);
}
......@@ -99,4 +121,25 @@ import {
}
checkbclass(tmop,txop)
{
const [id, sector] = tmop.value.split(': ');
var sectorint = +sector;
if (txop.value === "3")
{
this.StudentSelectedSpecialSub = this._hds.getSpecialityPerSchool(this.SchoolId, sectorint).subscribe(this.StudentSelectedSpecial$);
}
}
findstudent(tmop,txop)
{
let sectorint = 8;
{
this.StudentSelectedSpecialSub = this._hds.getStudentPerSchool(this.SchoolId, sectorint).subscribe(this.StudentSelectedSpecial$);
}
}
}
\ No newline at end of file
......@@ -473,6 +473,40 @@ transformUserSchema(userlogin:any,oauthtoken:string, oauthrole:string){
.map(response => response.json());
}
getSpecialityPerSchool(SchoolId, SectorId)
{
let SchoolIdNew = SchoolId.toString();
let SectorIdNew = SectorId.toString();
this.loginInfo$.forEach(loginInfoToken => {
this.authToken = loginInfoToken.get(0).auth_token;
});
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/specialityperSchool/`+SchoolIdNew+'/'+SectorIdNew, options )
.map(response => response.json());
}
getStudentPerSchool(SchoolId, SelectId)
{
let SchoolIdNew = SchoolId.toString();
let SelectIdNew = SelectId.toString();
this.loginInfo$.forEach(loginInfoToken => {
this.authToken = loginInfoToken.get(0).auth_token;
});
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/studentperSchool/`+SchoolIdNew+'/'+SelectIdNew, options )
.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