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

transf

parent 9744fe16
......@@ -82,3 +82,11 @@ epal.allocation:
_controller: '\Drupal\epal\Controller\Distribution::createDistribution'
requirements:
_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';
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,
......@@ -18,30 +19,24 @@ import {
@Component({
selector: 'director-view',
template: `
<form [formGroup]="formGroup">
<div class="form-group" style= "margin-top: 50px; margin-bottom: 100px;">
<div class="form-group" >
<label for="name">Τάξη</label><br/>
<select class="form-control" formControlName="name" (change)="verifyclass()">
<option value="Α' Λυκείου">Α' Λυκείου</option>
<option value="Β' Λυκείου">Β' Λυκείου</option>
<option value="Γ' Λυκείου">Γ' Λυκείου</option>
<select class="form-control" formControlName="taxi" (change)="verifyclass()">
<option value="1" >Α' Λυκείου</option>
<option value="2" >Β' Λυκείου</option>
<option value="3" >Γ' Λυκείου</option>
</select>
<div>
<div class="form-group" style= "margin-top: 50px; margin-bottom: 100px;">
<label for="name1">Τάξη1</label><br/>
<select class="form-control" formControlName="name1" (change)="verifyclass()">
<option value="Α' Λυκείου">Α' Λυκείου</option>
<option value="Β' Λυκείου">Β' Λυκείου</option>
<option value="Γ' Λυκείου">Γ' Λυκείου</option>
<div>
<div class="form-group" *ngIf="(StudentSelected$ | async).size > 0" >
<label for="tomeas">Τομέας</label><br/>
<select #cblst [(ngModel)]="tomeas" [ngModelOptions]="{standalone: true}" (change)="verifyclass(cblst)" >
<option *ngFor="let SectorSelection$ of StudentSelected$ | async" [ngValue]="SectorSelection$.id">{{SectorSelection$.sector_id}}</option>
</select>
<div>
<div>
`
})
......@@ -51,6 +46,9 @@ import {
private StudentSelected$: BehaviorSubject<any>;
private StudentSelectedSub: Subscription;
public bClassEnabled: boolean;
public gClassEnabled: boolean;
private SchoolId = 12 ;
constructor(private fb: FormBuilder,
private _hds: HelperDataService,
......@@ -59,8 +57,8 @@ import {
{
this.StudentSelected$ = new BehaviorSubject([{}]);
this.formGroup = this.fb.group({
name:[],
name1 :[]
taxi:[],
});
}
......@@ -73,15 +71,30 @@ import {
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()
{
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';
import { ILoginInfo } from '../../store/logininfo/logininfo.types';
import {Router, ActivatedRoute, Params} from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import * as html2canvas from "html2canvas"
......@@ -87,7 +87,13 @@ import { BehaviorSubject, Subscription } from 'rxjs/Rx';
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){
}
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