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: ` +
+
+
+ +
+
+ + +
+
+ +
+ Δυναμική σε τμήματα: + + + + ` +}) + +@Injectable() export default class DirectorClassCapacity implements OnInit , OnDestroy{ + + public formGroup: FormGroup; + private StudentSelected$: BehaviorSubject; + private StudentSelectedSub: Subscription; + private StudentSelectedSpecial$: BehaviorSubject; + private StudentSelectedSpecialSub: Subscription; + private selectionBClass: BehaviorSubject; + private selectionCClass: BehaviorSubject; + 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 {
+
+
Όνομα: {{StudentDetails$.name}}
Επώνυμο: {{StudentDetails$.studentsurname}}
Όνομα Πατέρα: {{StudentDetails$.fatherfirstname}}
@@ -52,9 +54,10 @@ import { Όνομα Μητέρας: {{StudentDetails$.motherfirstname}}
Επώνυμο Μητέρας:{{StudentDetails$.mothersurname}}
Ημερομηνία Γέννησης: {{StudentDetails$.birthdate}}
-
- - + + Επιβεβαίωση Εγγραφής: + +