Commit 1131f9c0 authored by Open Source Developer's avatar Open Source Developer

transf

parent 9744fe16
...@@ -82,3 +82,11 @@ epal.allocation: ...@@ -82,3 +82,11 @@ epal.allocation:
_controller: '\Drupal\epal\Controller\Distribution::createDistribution' _controller: '\Drupal\epal\Controller\Distribution::createDistribution'
requirements: requirements:
_access: 'TRUE' _access: 'TRUE'
sectorperschool:
path: '/epal/sectorperSchool/{epalId}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::getSectorsPerSchool'
requirements:
_user_is_logged_in: 'TRUE'
<?php
namespace Drupal\epal\Controller;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class DirectorView extends ControllerBase
{
protected $entityTypeManager;
public function __construct(EntityTypeManagerInterface $entityTypeManager)
{
$this->entityTypeManager = $entityTypeManager;
}
public static function create(ContainerInterface $container)
{
return new static(
$container->get('entity_type.manager')
);
}
public function getSectorsPerSchool(Request $request, $epalId)
{
$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();
$epalIdNew = intval($epalId);
$sectorPerSchool = $this->entityTypeManager->getStorage('eepal_sectors_in_epal')->loadByProperties(array('epal_id'=> $epalIdNew));
$i = 0;
if ($sectorPerSchool) {
$list = array();
foreach ($sectorPerSchool as $object) {
$list[] = array(
'sector_id' => $object -> sector_id ->entity->get('name')->value ,
'id' => $object -> sector_id -> entity -> id()
);
$i++;
}
return $this->respondWithStatus(
$list
, Response::HTTP_OK);
}
else {
return $this->respondWithStatus([
'message' => t("School not found!!!"),
], Response::HTTP_FORBIDDEN);
}
} else {
return $this->respondWithStatus([
'message' => t("User not found!"),
], Response::HTTP_FORBIDDEN);
}
}
private function respondWithStatus($arr, $s) {
$res = new JsonResponse($arr);
$res->setStatusCode($s);
return $res;
}
}
...@@ -8,6 +8,7 @@ import { NgRedux, select } from 'ng2-redux'; ...@@ -8,6 +8,7 @@ import { NgRedux, select } from 'ng2-redux';
import { IAppState } from '../../store/store'; import { IAppState } from '../../store/store';
import {Router, ActivatedRoute, Params} from '@angular/router'; import {Router, ActivatedRoute, Params} from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx'; import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import { ILoginInfo } from '../../store/logininfo/logininfo.types';
import { import {
FormBuilder, FormBuilder,
FormGroup, FormGroup,
...@@ -18,30 +19,24 @@ import { ...@@ -18,30 +19,24 @@ import {
@Component({ @Component({
selector: 'director-view', selector: 'director-view',
template: ` template: `
<form [formGroup]="formGroup"> <form [formGroup]="formGroup">
<div class="form-group" >
<div class="form-group" style= "margin-top: 50px; margin-bottom: 100px;">
<label for="name">Τάξη</label><br/> <label for="name">Τάξη</label><br/>
<select class="form-control" formControlName="name" (change)="verifyclass()"> <select class="form-control" formControlName="taxi" (change)="verifyclass()">
<option value="Α' Λυκείου">Α' Λυκείου</option> <option value="1" >Α' Λυκείου</option>
<option value="Β' Λυκείου">Β' Λυκείου</option> <option value="2" >Β' Λυκείου</option>
<option value="Γ' Λυκείου">Γ' Λυκείου</option> <option value="3" >Γ' Λυκείου</option>
</select> </select>
<div> <div>
<div class="form-group" *ngIf="(StudentSelected$ | async).size > 0" >
<div class="form-group" style= "margin-top: 50px; margin-bottom: 100px;"> <label for="tomeas">Τομέας</label><br/>
<label for="name1">Τάξη1</label><br/> <select #cblst [(ngModel)]="tomeas" [ngModelOptions]="{standalone: true}" (change)="verifyclass(cblst)" >
<select class="form-control" formControlName="name1" (change)="verifyclass()"> <option *ngFor="let SectorSelection$ of StudentSelected$ | async" [ngValue]="SectorSelection$.id">{{SectorSelection$.sector_id}}</option>
<option value="Α' Λυκείου">Α' Λυκείου</option>
<option value="Β' Λυκείου">Β' Λυκείου</option>
<option value="Γ' Λυκείου">Γ' Λυκείου</option>
</select> </select>
<div>
<div>
` `
}) })
...@@ -51,6 +46,9 @@ import { ...@@ -51,6 +46,9 @@ import {
private StudentSelected$: BehaviorSubject<any>; private StudentSelected$: BehaviorSubject<any>;
private StudentSelectedSub: Subscription; private StudentSelectedSub: Subscription;
public bClassEnabled: boolean; public bClassEnabled: boolean;
public gClassEnabled: boolean;
private SchoolId = 12 ;
constructor(private fb: FormBuilder, constructor(private fb: FormBuilder,
private _hds: HelperDataService, private _hds: HelperDataService,
...@@ -59,8 +57,8 @@ import { ...@@ -59,8 +57,8 @@ import {
{ {
this.StudentSelected$ = new BehaviorSubject([{}]); this.StudentSelected$ = new BehaviorSubject([{}]);
this.formGroup = this.fb.group({ this.formGroup = this.fb.group({
name:[], taxi:[],
name1 :[]
}); });
} }
...@@ -73,15 +71,30 @@ import { ...@@ -73,15 +71,30 @@ import {
ngOnInit() { ngOnInit() {
this.bClassEnabled = false; this.bClassEnabled = false;
this.gClassEnabled = false;
this.StudentSelectedSub = this._hds.getSectorPerSchool(this.SchoolId).subscribe(this.StudentSelected$);
console.log(this.StudentSelected$);
} }
verifyclass() verifyclass()
{ {
this.bClassEnabled = true;
if (this.formGroup.value.taxi === "1")
{ this.bClassEnabled = false;
this.gClassEnabled = false;
}
else if (this.formGroup.value.taxi === "2")
{
this.bClassEnabled = true;
this.gClassEnabled = false;
}
else if (this.formGroup.value.taxi === "3")
{ this.bClassEnabled = true;
this.gClassEnabled = true;
}
} }
......
...@@ -12,7 +12,7 @@ import { IAppState } from '../../store/store'; ...@@ -12,7 +12,7 @@ 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 {Router, ActivatedRoute, Params} from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx'; import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import * as html2canvas from "html2canvas"
...@@ -87,7 +87,13 @@ import { BehaviorSubject, Subscription } from 'rxjs/Rx'; ...@@ -87,7 +87,13 @@ import { BehaviorSubject, Subscription } from 'rxjs/Rx';
createPdf() 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');
});
} }
......
...@@ -458,5 +458,22 @@ transformUserSchema(userlogin:any,oauthtoken:string, oauthrole:string){ ...@@ -458,5 +458,22 @@ transformUserSchema(userlogin:any,oauthtoken:string, oauthrole:string){
} }
getSectorPerSchool(SchoolId)
{
let SchoolIdNew = SchoolId.toString();
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/sectorperSchool/`+SchoolIdNew, options )
.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