diff --git a/drupal/modules/epal/epal.routing.yml b/drupal/modules/epal/epal.routing.yml
index 7807d84b23616d9f0e924cafcefbc88615a1804d..0ea06fd5f2484f9951e3874d09ea4e2c00f53188 100644
--- a/drupal/modules/epal/epal.routing.yml
+++ b/drupal/modules/epal/epal.routing.yml
@@ -114,5 +114,12 @@ studentperschool:
_controller: '\Drupal\epal\Controller\DirectorView::getStudentPerSchool'
requirements:
_user_is_logged_in: 'TRUE'
-
+savecapacity:
+ path: '/epal/savecapacity/{taxi}/{tomeas}/{specialit}/{schoolid}'
+ options:
+ _auth: [ 'basic_auth' ]
+ defaults:
+ _controller: '\Drupal\epal\Controller\DirectorView::SaveCapacity'
+ requirements:
+ _user_is_logged_in: 'TRUE'
diff --git a/drupal/modules/epal/src/Controller/DirectorView.php b/drupal/modules/epal/src/Controller/DirectorView.php
index 3d538a1672211c1bfd6ca01365652847f4027054..afec8c9244dadcd10188c13717c54bb8c61978eb 100644
--- a/drupal/modules/epal/src/Controller/DirectorView.php
+++ b/drupal/modules/epal/src/Controller/DirectorView.php
@@ -247,6 +247,90 @@ public function getStudentPerSchool(Request $request, $epalId , $selectId, $clas
+
+
+public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid)
+ {
+
+ if (!$request->isMethod('POST')) {
+ return $this->respondWithStatus([
+ "message" => t("Method Not Allowed")
+ ], Response::HTTP_METHOD_NOT_ALLOWED);
+ }
+ $authToken = $request->headers->get('PHP_AUTH_USER');
+
+ $epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken));
+ $epalUser = reset($epalUsers);
+ if ($epalUser) {
+ $postData = null;
+
+ if ($content = $request->getContent())
+ {
+ $postData = json_decode($content);
+ $cap = $postData->capacity;
+ if (($tomeas == 0) || ($specialit == 0))
+ {
+ $CapacityPerClass = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id' => $schoolid ));
+ $classcapacity = reset($CapacityPerClass);
+ if ($classcapacity) {
+ $classcapacity->set('capacity_class_a', $cap);
+ $classcapacity->save();
+ }
+ }
+
+
+ if (($tomeas != 0) || ($specialit == 0))
+ {
+ $CapacityPerClass = $this->entityTypeManager->getStorage('eepal_sectors_in_epal')->loadByProperties(array('epal_id' => $schoolid, 'sector_id' => $tomeas ));
+ $classcapacity = reset($CapacityPerClass);
+ if ($classcapacity) {
+ $classcapacity->set('capacity_class_sector', $cap);
+ $classcapacity->save();
+ }
+ }
+
+
+ if (($tomeas != 0) || ($specialit != 0))
+ {
+ $CapacityPerClass = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $schoolid, 'specialty_id' => $specialit));
+ $classcapacity = reset($CapacityPerClass);
+ if ($classcapacity) {
+ $classcapacity->set('capacity_class_specialty', $cap);
+ $classcapacity->save();
+ }
+ }
+
+
+
+
+
+
+ return $this->respondWithStatus([
+ 'message' => t("saved"),
+ ], Response::HTTP_OK);
+ }
+ else
+ {
+ return $this->respondWithStatus([
+ 'message' => t("post with no data"),
+ ], Response::HTTP_BAD_REQUEST);
+ }
+
+ } else {
+ return $this->respondWithStatus([
+ 'message' => t("EPAL user not found"),
+ ], Response::HTTP_FORBIDDEN);
+ }
+ }
+
+
+
+
+
+
+
+
+
private function respondWithStatus($arr, $s) {
$res = new JsonResponse($arr);
$res->setStatusCode($s);
diff --git a/drupal/modules/epalreadydata/src/Entity/EepalSchool.php b/drupal/modules/epalreadydata/src/Entity/EepalSchool.php
index 320e49508ae0c686349c6e6444ef1afa8e9f9a44..eac62d64a73dc53cf18d8eedb10039ae77afe6f5 100644
--- a/drupal/modules/epalreadydata/src/Entity/EepalSchool.php
+++ b/drupal/modules/epalreadydata/src/Entity/EepalSchool.php
@@ -356,7 +356,7 @@ class EepalSchool extends ContentEntityBase implements EepalSchoolInterface {
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
- $fields['e-mail'] = BaseFieldDefinition::create('string')
+ $fields['maile'] = BaseFieldDefinition::create('string')
->setLabel(t('e-mail Σχολείου'))
->setDescription(t('Δώσε το e-mail Σχολείου'))
->setSettings(array(
diff --git a/source/components/director/director-classcapacity.ts b/source/components/director/director-classcapacity.ts
new file mode 100644
index 0000000000000000000000000000000000000000..b04fb81644c97713f8da21e9a62e8429fe6c346c
--- /dev/null
+++ b/source/components/director/director-classcapacity.ts
@@ -0,0 +1,168 @@
+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 {
+ FormBuilder,
+ FormGroup,
+ FormControl,
+ FormArray,
+ Validators,
+} from '@angular/forms';
+@Component({
+ selector: 'director-classcapacity',
+ template: `
+ <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>
+ </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()" formControlName="specialit">
+ <option *ngFor="let SpecialSelection$ of StudentSelectedSpecial$ | async; let i=index" [value] = "SpecialSelection$.id"> {{SpecialSelection$.specialty_id}} </option>
+ </select>
+ </div>
+ <strong>Δυναμική σε τμήματα:</strong>
+ <input type="number" formControlName="capacity" min="1" max="10">
+
+ <button type="button" class="btn-primary btn-sm pull-right" (click) ="saveCapacity()">
+ Αποθήκευση
+ </button>
+ `
+})
+
+@Injectable() export default class DirectorClassCapacity implements OnInit , OnDestroy{
+
+ public formGroup: FormGroup;
+ private StudentSelected$: BehaviorSubject<any>;
+ private StudentSelectedSub: Subscription;
+ private StudentSelectedSpecial$: BehaviorSubject<any>;
+ private StudentSelectedSpecialSub: Subscription;
+ private selectionBClass: BehaviorSubject<boolean>;
+ private selectionCClass: BehaviorSubject<boolean>;
+ private SchoolId = 147 ;
+ private currentclass: Number;
+
+
+
+ constructor( private fb: FormBuilder,
+ private _hds: HelperDataService,
+ private activatedRoute: ActivatedRoute,
+ private router: Router )
+ {
+ this.StudentSelected$ = new BehaviorSubject([{}]);
+ this.StudentSelectedSpecial$ = new BehaviorSubject([{}]);
+ this.selectionBClass = new BehaviorSubject(false);
+ this.selectionCClass = new BehaviorSubject(false);
+ this.formGroup = this.fb.group({
+ tomeas: ['', []],
+ taxi: ['', []],
+ specialit: ['', []],
+ capacity: ['', []],
+ });
+
+ }
+
+ ngOnDestroy()
+ {
+ if (this.StudentSelectedSub)
+ this.StudentSelectedSub.unsubscribe();
+ if (this.StudentSelectedSpecialSub)
+ this.StudentSelectedSpecialSub.unsubscribe();
+ if (this.selectionBClass)
+ this.selectionBClass.unsubscribe();
+ if (this.selectionCClass)
+ this.selectionCClass.unsubscribe();
+
+ }
+
+ ngOnInit() {
+
+ }
+
+
+ verifyclass(txop)
+ {
+
+ if (txop.value === "1")
+ {
+ this.selectionBClass.next(false);
+ this.selectionCClass.next(false);
+ this.formGroup.patchValue({
+ tomeas: '',
+ specialit: '',
+ });
+
+ }
+ else if (txop.value === "2")
+ {
+ this.formGroup.patchValue({
+ specialit: '',
+ });
+ this.selectionBClass.next(true);
+ this.selectionCClass.next(false);
+ this.StudentSelected$ = new BehaviorSubject([{}]);
+ this.StudentSelectedSub = this._hds.getSectorPerSchool(this.SchoolId).subscribe(this.StudentSelected$);
+ }
+ else if (txop.value === "3")
+ {
+ var sectorint = +this.formGroup.value.tomeas;
+ console.log(sectorint,"test");
+ if (this.formGroup.value.tomeas != '')
+ {
+ var sectorint = +this.formGroup.value.tomeas;
+ this.StudentSelectedSpecial$ = new BehaviorSubject([{}]);
+ this.StudentSelectedSpecialSub = this._hds.getSpecialityPerSchool(this.SchoolId, sectorint).subscribe(this.StudentSelectedSpecial$);
+ }
+ this.selectionBClass.next(true);
+ this.selectionCClass.next(true);
+ this.StudentSelected$ = new BehaviorSubject([{}]);
+ this.StudentSelectedSub = this._hds.getSectorPerSchool(this.SchoolId).subscribe(this.StudentSelected$);
+ }
+ }
+
+
+ checkbclass(tmop,txop)
+ {
+
+ var sectorint = +this.formGroup.value.tomeas;
+ console.log(sectorint,"tomeas");
+ if (txop.value === "3")
+ {
+ this.StudentSelectedSpecial$ = new BehaviorSubject([{}]);
+ this.StudentSelectedSpecialSub = this._hds.getSpecialityPerSchool(this.SchoolId, sectorint).subscribe(this.StudentSelectedSpecial$);
+ }
+ }
+
+
+
+
+saveCapacity()
+{
+
+ var tomeas = +this.formGroup.value.tomeas;
+ var specialit = +this.formGroup.value.specialit;
+ console.log(tomeas, specialit);
+ this._hds.saveCapacity(this.formGroup.value.taxi,tomeas,specialit, this.formGroup.value.capacity, this.SchoolId );
+
+}
+
+}
\ No newline at end of file
diff --git a/source/components/director/director-view.ts b/source/components/director/director-view.ts
index f53a31fc65f28bdd6bccd2530a181cb0178f7581..67e6fcdab02b01fce43e43a87b8dac5c4e3d1bc9 100644
--- a/source/components/director/director-view.ts
+++ b/source/components/director/director-view.ts
@@ -45,6 +45,8 @@ import {
</button>
<div *ngIf="(retrievedStudent | async)">
<div *ngFor="let StudentDetails$ of StudentInfo$ | async">
+ <br>
+ <br>
Όνομα: {{StudentDetails$.name}} <br>
Επώνυμο: {{StudentDetails$.studentsurname}}<br>
Όνομα ΠατÎÏα: {{StudentDetails$.fatherfirstname}}<br>
@@ -52,9 +54,10 @@ import {
Όνομα ΜητÎÏας: {{StudentDetails$.motherfirstname}}<br>
Επώνυμο ΜητÎÏας:{{StudentDetails$.mothersurname}}<br>
ΗμεÏομηνία ΓÎννησης: {{StudentDetails$.birthdate}}<br>
- <br>
- <input #cb type="checkbox" name="{{ StudentDetails$.id }}" (change)="updateCheckedOptions(StudentDetails$.id, $event)" >
-
+
+ <strong>Επιβεβαίωση ΕγγÏαφής: </strong>
+ <input #cb class="pull-right" type="checkbox" name="{{ StudentDetails$.id }}" (change)="updateCheckedOptions(StudentDetails$.id, $event)" >
+
</div>
</div>
<button type="button" class="btn-primary btn-sm pull-right" (click)="confirmStudent()">
@@ -109,6 +112,8 @@ import {
this.selectionBClass.unsubscribe();
if (this.selectionCClass)
this.selectionCClass.unsubscribe();
+ if (this.retrievedStudent)
+ this.retrievedStudent.unsubscribe();
}
ngOnInit() {
@@ -134,6 +139,14 @@ import {
}
else if (txop.value === "3")
{
+ var sectorint = +this.formGroup.value.tomeas;
+ console.log(sectorint,"test");
+ if (this.formGroup.value.tomeas != '')
+ {
+ var sectorint = +this.formGroup.value.tomeas;
+ this.StudentSelectedSpecial$ = new BehaviorSubject([{}]);
+ this.StudentSelectedSpecialSub = this._hds.getSpecialityPerSchool(this.SchoolId, sectorint).subscribe(this.StudentSelectedSpecial$);
+ }
this.selectionBClass.next(true);
this.selectionCClass.next(true);
this.StudentSelected$ = new BehaviorSubject([{}]);
@@ -171,7 +184,7 @@ import {
this.currentclass = 3;
}
this.retrievedStudent.next(true);
- this.retrievedStudent = new BehaviorSubject(false);
+ this.StudentInfo$ = new BehaviorSubject(false);
this.StudentInfoSub = this._hds.getStudentPerSchool(this.SchoolId, sectorint, this.currentclass).subscribe(this.StudentInfo$);
diff --git a/source/components/navbar/navbar.component.html b/source/components/navbar/navbar.component.html
index 4bbce497fc70d8001ecb522485bbd1af0677cff9..7caea8ae7abaf78a9c974f2e2a4fc423a62aa554 100644
--- a/source/components/navbar/navbar.component.html
+++ b/source/components/navbar/navbar.component.html
@@ -28,6 +28,10 @@
<a class="nav-link" [routerLink]="['/director-view']" [routerLinkActive]="['active']"><b>ΕπιλεχθÎντες ΜαθητÎÏ‚</b></a>
</div>
+ <div class="pull-right" class="nav-item" [ngClass]="{active: path=='director-classcapacity'}">
+ <a class="nav-link" [routerLink]="['/director-classcapacity']" [routerLinkActive]="['active']"><b>Δυναμική Σχολείου</b></a>
+ </div>
+
</div>
diff --git a/source/containers/main.routes.ts b/source/containers/main.routes.ts
index 5c68adc50ba0428399a9c8a66771dee4ec18d277..90cb09e58754a8a0a2863d9f4d644ab96fa23091 100644
--- a/source/containers/main.routes.ts
+++ b/source/containers/main.routes.ts
@@ -20,6 +20,7 @@ import ApplicationSubmit from '../components/student-application-form/applicatio
import SubmitedPreview from '../components/student-application-form/submited.aplication.preview';
import SubmitedPerson from '../components/student-application-form/submitedstudent.preview';
import DirectorView from '../components/director/director-view';
+import DirectorClassCapacity from '../components/director/director-classcapacity';
export const MainRoutes: Routes = [
{ path: '', component: Home },
@@ -37,6 +38,7 @@ export const MainRoutes: Routes = [
{ path: 'submited-preview', component: SubmitedPreview },
{ path: 'submited-person', component: SubmitedPerson },
{ path: 'director-view', component: DirectorView },
+ { path: 'director-classcapacity', component: DirectorClassCapacity },
];
export const MainDeclarations = [
@@ -56,5 +58,6 @@ export const MainDeclarations = [
ApplicationSubmit,
SubmitedPreview,
SubmitedPerson,
- DirectorView
+ DirectorView,
+ DirectorClassCapacity
];
diff --git a/source/services/helper-data-service.ts b/source/services/helper-data-service.ts
index 4afc0cc29fec98650a1fa9365974b60459a6d0e5..cb8909e36a2ad983d513918e8853cbe19920e6a1 100644
--- a/source/services/helper-data-service.ts
+++ b/source/services/helper-data-service.ts
@@ -537,4 +537,34 @@ export class HelperDataService {
+ saveCapacity(taxi,tomeas, specialit, capacity, schoolid)
+ {
+
+ console.log(taxi, capacity,"hds");
+ 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 new Promise((resolve, reject) => {
+ this.http.post(`${AppSettings.API_ENDPOINT}/epal/savecapacity/`+taxi+'/'+tomeas+'/'+specialit+'/'+schoolid, {capacity}, options)
+ .map(response => response.json())
+ .subscribe(data => {
+ resolve(data);
+ },
+ error => {
+ console.log("Error Saving Capacity");
+ reject("Error Saving Capacity");
+ },
+ () => console.log("Saving Capacity"));
+ });
+
+ }
+
+
+
+
}