diff --git a/drupal/modules/epal/src/Controller/DirectorView.php b/drupal/modules/epal/src/Controller/DirectorView.php
index f0ac29ee000094764a4526df4353a559799cc7e8..dcc95096ab4ff2acdbca69f64eeb826f30a655f8 100644
--- a/drupal/modules/epal/src/Controller/DirectorView.php
+++ b/drupal/modules/epal/src/Controller/DirectorView.php
@@ -144,17 +144,19 @@ public function getStudentPerSchool(Request $request, $epalId , $selectId)
{
$studentId = $object -> id() ;
$epalStudents = $this->entityTypeManager->getStorage('epal_student')->loadByProperties(array('id'=> $studentId));
+ $epalStudent = reset($epalStudents);
$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,
+ 'id' => $epalStudent -> id(),
+ 'name' => $epalStudent -> name ->value,
+ 'studentsurname' => $epalStudent -> studentsurname ->value,
+ 'fatherfirstname' => $epalStudent -> fatherfirstname ->value,
+ 'fathersurname' =>$epalStudent -> fathersurtname ->value,
+ 'motherfirstname' => $epalStudent -> motherfirstname ->value,
+ 'mothersurname' =>$epalStudent -> mothersurname ->value,
+ 'birthdate' =>$epalStudent -> birthdate ->value,
);
$i++;
@@ -184,6 +186,60 @@ public function getStudentPerSchool(Request $request, $epalId , $selectId)
+ public function ConfirmStudents(Request $request)
+ {
+
+ 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())
+ {
+ foreach ($content as &$value) {
+ $studentForConfirm = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('id' => &$value ));
+ if ($studentForConfirm) {
+
+ $studentForConfirm->set('directorconfirm', "yes");
+ $studentForConfirm->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/source/components/director/director-view.ts b/source/components/director/director-view.ts
index 2d8119714602df8b40df667e47738da320a0941b..5bffe6bbef298327f8e7f5e4306ef0c0df117b45 100644
--- a/source/components/director/director-view.ts
+++ b/source/components/director/director-view.ts
@@ -21,7 +21,7 @@ import {
selector: 'director-view',
template: `
-
+
<label for="taxi">΀άξη</label><br/>
<select #txoption [(ngModel)]="taxi" [ngModelOptions]="{standalone: false}" (ngModelChange)="verifyclass(txoption)" >
@@ -48,6 +48,24 @@ import {
<button type="button" class="btn-primary btn-sm pull-right" (click)="findstudent(tmop,txoption)">
ΞΞ½Ξ±ΞΆΞ�ΟΞ·ΟΞ·
</button>
+ <div *ngIf="StudentInfo$ != {} || (retrievedStudent | async)">
+ <div *ngFor="let StudentDetails$ of StudentInfo$ | async">
+ ΞΞ½ΞΏΞΌΞ±: {{StudentDetails$.name}} <br>
+ ΞΟΟΞ½Ο
ΞΌΞΏ: {{StudentDetails$.studentsurname}}<br>
+ ΞΞ½ΞΏΞΌΞ± Ξ Ξ±ΟΞΟΞ±: {{StudentDetails$.fatherfirstname}}<br>
+ ΞΟΟΞ½Ο
ΞΌΞΏ Ξ Ξ±ΟΞΟΞ±:{{StudentDetails$.fathersurname}}<br>
+ ΞΞ½ΞΏΞΌΞ± ΞΞ·ΟΞΟΞ±Ο: {{StudentDetails$.motherfirstname}}<br>
+ ΞΟΟΞ½Ο
ΞΌΞΏ ΞΞ·ΟΞΟΞ±Ο:{{StudentDetails$.mothersurname}}<br>
+ ΞΞΌΞ΅ΟΞΏΞΌΞ·Ξ½Ξ―Ξ± ΞΞΞ½Ξ½Ξ·ΟΞ·Ο: {{StudentDetails$.birthdate}}<br>
+ <br>
+ <input #cb type="checkbox" name="{{ StudentDetails$.id }}" (change)="updateCheckedOptions(StudentDetails$.id, $event)" >
+
+ </div>
+ </div>
+ <button type="button" class="btn-primary btn-sm pull-right" (click)="confirmStudent()">
+ ΞΟιβΡβαίΟΟΞ· ΞΞ³Ξ³ΟΞ±ΟΞ�Ο
+ </button>
+
`
})
@@ -57,12 +75,15 @@ import {
public formGroup: FormGroup;
private StudentSelected$: BehaviorSubject<any>;
private StudentSelectedSub: Subscription;
+ private StudentInfo$: BehaviorSubject<any>;
+ private StudentInfoSub: Subscription;
private StudentSelectedSpecial$: BehaviorSubject<any>;
private StudentSelectedSpecialSub: Subscription;
- private selectionAClass: BehaviorSubject<boolean>;
+ private retrievedStudent: BehaviorSubject<boolean>;
private selectionBClass: BehaviorSubject<boolean>;
private selectionCClass: BehaviorSubject<boolean>;
private SchoolId = 147 ;
+ private saved :Array<number> = new Array();
constructor( private fb: FormBuilder,
@@ -72,14 +93,11 @@ import {
{
this.StudentSelected$ = new BehaviorSubject([{}]);
this.StudentSelectedSpecial$ = new BehaviorSubject([{}]);
- this.selectionAClass = new BehaviorSubject(false);
+ this.StudentInfo$ = new BehaviorSubject([{}]);
+ this.retrievedStudent = new BehaviorSubject(false);
this.selectionBClass = new BehaviorSubject(false);
this.selectionCClass = new BehaviorSubject(false);
- this.formGroup = this.fb.group({
- taxi:[],
- tomeas: [],
- specialit :[]
- });
+
}
ngOnDestroy()
@@ -88,6 +106,10 @@ import {
this.StudentSelectedSub.unsubscribe();
if (this.StudentSelectedSpecialSub)
this.StudentSelectedSpecialSub.unsubscribe();
+ if (this.selectionBClass)
+ this.selectionBClass.unsubscribe();
+ if (this.selectionCClass)
+ this.selectionCClass.unsubscribe();
}
@@ -138,11 +160,40 @@ import {
const [id, sector] = tmop.value.split(': ');
var sectorint = +sector;
console.log(sectorint,"aaaaaa");
- this.StudentSelectedSpecialSub = this._hds.getStudentPerSchool(this.SchoolId, sectorint).subscribe(this.StudentSelectedSpecial$);
+ this.StudentInfoSub = this._hds.getStudentPerSchool(this.SchoolId, sectorint).subscribe(this.StudentInfo$);
+ this.retrievedStudent.next(true);
}
+updateCheckedOptions(id, event)
+{
+
+ let i = this.saved.length;
+
+
+ if (event.target.checked === false)
+ {
+ var count=this.saved.length;
+ for(var j=0;j<count;j++)
+ {
+ if(this.saved[j]===id)
+ {
+ this.saved.splice(j, 1);
+ }
+ }
+ }
+ else
+ {
+ this.saved[i] = id ;
+ }
+
+}
+confirmStudent()
+{
+
+ this._hds.saveConfirmStudents(this.saved);
+}
}
\ No newline at end of file
diff --git a/source/services/helper-data-service.ts b/source/services/helper-data-service.ts
index 5e45eb1b8c1d4b515cd07a9e0e2c076b54c0398d..368dc891b36265b6634aea2a66c237b90e0f8f4b 100644
--- a/source/services/helper-data-service.ts
+++ b/source/services/helper-data-service.ts
@@ -363,7 +363,7 @@ export class HelperDataService {
}
-transformUserSchema(userlogin:any,oauthtoken:string, oauthrole:string){
+ transformUserSchema(userlogin:any,oauthtoken:string, oauthrole:string){
let rsa = Array<ILoginInfoToken>();
rsa.push(<ILoginInfoToken>{'auth_token': oauthtoken, 'auth_role': oauthrole, 'cu_name':userlogin.name});
@@ -509,5 +509,32 @@ transformUserSchema(userlogin:any,oauthtoken:string, oauthrole:string){
+ saveConfirmStudents(students)
+ {
+ console.log(students,"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/confirmstudent`, {students: students}, options)
+ .map(response => response.json())
+ .subscribe(data => {
+ resolve(data);
+ },
+ error => {
+ console.log("Error Saving Profile");
+ reject("Error Saving Profile");
+ },
+ () => console.log("Saving Profile"));
+ });
+
+ }
+
+
}