Commit 88ffd174 authored by Open Source Developer's avatar Open Source Developer

Merge branch 'applicationpdf' of https://git.minedu.gov.gr/akatsi/e-epal into applicationpdf

parents 9919dde0 68594917
...@@ -15,11 +15,11 @@ current_user: ...@@ -15,11 +15,11 @@ current_user:
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
submitedapplications: submitedapplications:
path: '/epal/subapplic' path: '/epal/subapplic/{$studentid}'
options: options:
_auth: [ 'basic_auth' ] _auth: [ 'basic_auth' ]
defaults: defaults:
_controller: '\Drupal\epal\Controller\SubmittedApplication::getSubmittedApplications' _controller: '\Drupal\epal\Controller\SubmitedApplications::getSubmittedApplications'
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
epal.application_submit: epal.application_submit:
......
...@@ -9,7 +9,7 @@ use Drupal\Core\Controller\ControllerBase; ...@@ -9,7 +9,7 @@ use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
class SubmittedApplication extends ControllerBase class SubmitedApplications extends ControllerBase
{ {
protected $entityTypeManager; protected $entityTypeManager;
...@@ -29,9 +29,57 @@ class SubmittedApplication extends ControllerBase ...@@ -29,9 +29,57 @@ class SubmittedApplication extends ControllerBase
public function getSubmittedApplications(Request $request) public function getSubmittedApplications(Request $request)
{ {
return "aaaaaaaaaaaaaaaaa" ; $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();
$epalStudents = $this->entityTypeManager->getStorage('epal_student')->loadByProperties(array('user_id' => $userid));
$epalStudent = reset($epalStudents);
if ($epalStudent) {
return $this->respondWithStatus([
'name' => $epalStudent ->name->value,
'studentsurname' => $epalStudent ->studentsurname->value,
], Response::HTTP_OK);
}
else {
return $this->respondWithStatus([
'message' => t("EPAL user not found"),
], Response::HTTP_FORBIDDEN);
}
if ($studentid){
$StudentSelection = $this->entityTypeManager->getStorage('epal_student_epal_chosen')->loadByProperties(array('student_id' => $studentid, 'user_id' => $userid ));
$StudentSel = reset($StudentSelection);
if ($StudentSel) {
return $this->respondWithStatus([
'epal_id' => $epalStudent ->epal_id->entity->getEpal_id(),
], Response::HTTP_OK);
}
else {
return $this->respondWithStatus([
'message' => t("SpecificStudent not found"),
], Response::HTTP_FORBIDDEN);
}
}
} 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);
return $res;
}
} }
...@@ -11,52 +11,56 @@ import {Removetags} from '../../pipes/removehtmltags'; ...@@ -11,52 +11,56 @@ import {Removetags} from '../../pipes/removehtmltags';
import { NgRedux, select } from 'ng2-redux'; import { NgRedux, select } from 'ng2-redux';
import { IAppState } from '../../store/store'; import { IAppState } from '../../store/store';
import { ILoginInfo } from '../../store/logininfo/logininfo.types'; import { ILoginInfo } from '../../store/logininfo/logininfo.types';
import {Router, ActivatedRoute, Params} from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
@Component({ @Component({
selector: 'submited-preview', selector: 'submited-preview',
template: ` template: `
<div id = "target">
Έχετε ολοκληρώσει την αίτηση για εγγραφή στην επαγγελπατική εκπαίδευση των παρακάτω ατόμων: <h5 style="margin-top: 20px; line-height: 2em; ">Έχετε ολοκληρώσει την αίτηση για εγγραφή στην επαγγελπατική εκπαίδευση των παρακάτω ατόμων:</h5>
<div *ngFor="let userdata$ of submitedusers$ | async; "> <div *ngFor="let userdata$ of submitedapplic$ | async; ">
<br>
<br> <ul class="list-group left-side-view" style="margin-bottom: 20px;">
<strong>Στοιχεία υποψηφίου μαθητή: </strong> <br> <li class="list-group-item active">
<br> Μαθητής: {{userdata$.name}}
</li>
</ul>
</div>
</div> <button type="submit" (click)="studentpreview()"> Λεπτομέρειες
</div> </button>
<button type="button" (click)="createPdf()">Εξαγωγή σε PDF</button>
` `
}) })
@Injectable() export default class SubmitedPreview implements OnInit { @Injectable() export default class SubmitedPreview implements OnInit {
public submitedapplic$: any;
public submitedusers$:any;
public html2canvas: any; public html2canvas: any;
private loginInfo$: Observable<ILoginInfo>;
private user :string; private submitedapplic$: BehaviorSubject<any>;
private submitedusers$: Subscription;
public studentid = 1 ;
constructor(private _hds: HelperDataService, constructor(private _hds: HelperDataService,
public http: Http, public http: Http,
private _ngRedux: NgRedux<IAppState>,) private _ngRedux: NgRedux<IAppState>,
private activatedRoute: ActivatedRoute,
private router: Router )
{ {
this.submitedapplic$ = new BehaviorSubject({});
} }
ngOnInit() { ngOnInit() {
this.submitedusers$ = this._hds.getSubmittedPreviw(0).subscribe(this.submitedapplic$);
console.log("subscription", this.submitedusers$, "behavior", this.submitedapplic$);
} }
...@@ -74,4 +78,12 @@ import { ILoginInfo } from '../../store/logininfo/logininfo.types'; ...@@ -74,4 +78,12 @@ import { ILoginInfo } from '../../store/logininfo/logininfo.types';
); );
} }
studentpreview()
{
console.log(this.studentid);
this.router.navigate(['/submited-person', { id: this.studentid}]);
}
} }
\ No newline at end of file
import { Component, OnInit, ElementRef, ViewChild} from "@angular/core";
let jsPDF = require('jspdf');
import { Injectable } from "@angular/core";
import { AppSettings } from '../../app.settings';
import { HelperDataService } from '../../services/helper-data-service';
import {Observable} from "rxjs/Observable";
import {IStudentDataFields, IStudentDataField} from '../../store/studentdatafields';
import {Http, Headers, RequestOptions} from '@angular/http';
import * as html2canvas from "html2canvas"
import {Removetags} from '../../pipes/removehtmltags';
import { NgRedux, select } from 'ng2-redux';
import { IAppState } from '../../store/store';
import { ILoginInfo } from '../../store/logininfo/logininfo.types';
import {Router, ActivatedRoute, Params} from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
@Component({
selector: 'submited-person',
template: `
<h5 style="margin-top: 20px; line-height: 2em; ">Στοιχεία Μαθητή</h5>
<div *ngFor="let userdata$ of submitedapplic$ | async; ">
<ul class="list-group left-side-view" style="margin-bottom: 20px;">
<li class="list-group-item active">
Μαθητής: {{userdata$.name}}
</li>
</ul>
</div>
`
})
@Injectable() export default class SubmitedPerson implements OnInit {
public html2canvas: any;
private submitedapplic$: BehaviorSubject<any>;
private submitedusers$: Subscription;
public userid: number;
public authToken : string ;
constructor(private _hds: HelperDataService,
public http: Http,
private _ngRedux: NgRedux<IAppState>,
private activatedRoute: ActivatedRoute )
{
this.submitedapplic$ = new BehaviorSubject({});
}
ngOnInit() {
this.activatedRoute.queryParams.subscribe((params: Params) => {
if (params) {
this.userid = 1;
console.log("userid", this.userid, this.authToken);
}
});
this.submitedusers$ = this._hds.getSubmittedPreviw(this.userid).subscribe(this.submitedapplic$);
console.log("subscription", this.submitedusers$, "behavior", this.submitedapplic$);
}
createPdf()
{
html2canvas(document.getElementById("target")).then(function(canvas)
{
var img = canvas.toDataURL();
var doc = new jsPDF('p', 'mm');
doc.addImage(img, 'PNG', 10, 10);
doc.save('applications.pdf');
}
);
}
}
\ No newline at end of file
...@@ -18,7 +18,7 @@ import ApplicationPreview from '../components/student-application-form/applicati ...@@ -18,7 +18,7 @@ import ApplicationPreview from '../components/student-application-form/applicati
import SchoolsOrderSelect from '../components/student-application-form/schools-order-select'; import SchoolsOrderSelect from '../components/student-application-form/schools-order-select';
import ApplicationSubmit from '../components/student-application-form/application.submit'; import ApplicationSubmit from '../components/student-application-form/application.submit';
import SubmitedPreview from '../components/student-application-form/submited.aplication.preview'; import SubmitedPreview from '../components/student-application-form/submited.aplication.preview';
import SubmitedPerson from '../components/student-application-form/submitedstudent.preview';
export const MainRoutes: Routes = [ export const MainRoutes: Routes = [
{ path: '', component: Home }, { path: '', component: Home },
...@@ -34,6 +34,7 @@ export const MainRoutes: Routes = [ ...@@ -34,6 +34,7 @@ export const MainRoutes: Routes = [
{ path: 'schools-order-select', component: SchoolsOrderSelect }, { path: 'schools-order-select', component: SchoolsOrderSelect },
{ path: 'application-submit', component: ApplicationSubmit }, { path: 'application-submit', component: ApplicationSubmit },
{ path: 'submited-preview', component: SubmitedPreview }, { path: 'submited-preview', component: SubmitedPreview },
{ path: 'submited-person', component: SubmitedPerson },
]; ];
export const MainDeclarations = [ export const MainDeclarations = [
...@@ -52,4 +53,5 @@ export const MainDeclarations = [ ...@@ -52,4 +53,5 @@ export const MainDeclarations = [
SchoolsOrderSelect, SchoolsOrderSelect,
ApplicationSubmit, ApplicationSubmit,
SubmitedPreview, SubmitedPreview,
SubmitedPerson
]; ];
...@@ -331,4 +331,21 @@ transformUserSchema(userlogin:any,oauthtoken:string, oauthrole:string){ ...@@ -331,4 +331,21 @@ transformUserSchema(userlogin:any,oauthtoken:string, oauthrole:string){
} }
getSubmittedPreviw(stud_id) {
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/subapplic`, options , {params:{"param1": stud_id}})
.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