Commit a4eb4c01 authored by Open Source Developer's avatar Open Source Developer

trans

parent 46bb7d7f
......@@ -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);
......
......@@ -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
......@@ -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"));
});
}
}
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