Commit 6ab81ba5 authored by Open Source Developer's avatar Open Source Developer

dide view

parent bee210b2
......@@ -199,7 +199,7 @@ epal.ministry.storesettings:
requirements:
_user_is_logged_in: 'TRUE'
regionview:
path: '/epal/ScoolperPerf'
path: '/epal/ScoolperPerf/{check_status}'
options:
_auth: [ 'basic_auth' ]
defaults:
......
......@@ -427,7 +427,7 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit)
public function getSchoolsPerPerfetcure(Request $request)
public function getSchoolsPerPerfetcure(Request $request, $check_status)
{
$authToken = $request->headers->get('PHP_AUTH_USER');
......@@ -436,14 +436,20 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit)
$user = reset($users);
if ($user)
{
$perfectureId = $user -> init -> value;
$schools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('region_edu_admin_id'=> $perfectureId ));
$selectionId = $user -> init -> value;
if ($check_status == 1){
$schools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('region_edu_admin_id'=> $selectionId ));
}
else
{
$schools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('edu_admin_id'=> $selectionId ));
}
if ($schools)
{
$list = array();
foreach ($schools as $object) {
$status = $this->returnstatus(147);
$status = $this->returnstatus($object -> id());
$list[] = array(
'id' =>$object -> id(),
'name' => $object -> name ->value,
......@@ -595,10 +601,74 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit)
public function returnstatus($id)
{
if ($id == 147)
return true ;
return false;
$schoolid = $id;
$SchoolCats = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id'=> $schoolid ));
$SchoolCat = reset($SchoolCats);
if ($SchoolCat){
$categ = $SchoolCat-> metathesis_region -> value;
}
$CourseA = $this->entityTypeManager->getStorage('epal_student')->loadByProperties(array('id'=> $schoolid ));
if ($CourseA)
{
$limit_down = $this->entityTypeManager->getStorage('epal_class_limits')->loadByProperties(array('name'=> 1, 'category' => $categ ));
$limitdown = reset($limit_down);
if ($limitdown)
{
$limit = $limitdown -> limit_down -> value;
}
$studentPerSchool = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('currentepal'=> $schoolid, 'specialization_id' => -1, 'currentclass' => 1 ));
//foreach ($CourseA as $object) {
if (sizeof($studentPerSchool) < $limit){
return false;
exit;
}
} // }
$CourseB = $this->entityTypeManager->getStorage('eepal_sectors_in_epal')->loadByProperties(array('epal_id' => $schoolid ));
if ($CourseB)
{
$limit_down = $this->entityTypeManager->getStorage('epal_class_limits')->loadByProperties(array('name'=> 2, 'category' => $categ ));
$limitdown = reset($limit_down);
if ($limitdown)
{
$limit = $limitdown -> limit_down -> value;
}
foreach ($CourseB as $object) {
$sectorid = $object -> sector_id -> entity -> id();
$studentPerSchool = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('currentepal'=> $schoolid, 'specialization_id' => $sectorid, 'currentclass' => 2 ));
if (sizeof($studentPerSchool) < $limit){
return false;
exit;
}
}
}
$CourseC = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $schoolid ));
if ($CourseC)
{
$limit_down = $this->entityTypeManager->getStorage('epal_class_limits')->loadByProperties(array('name'=> 3, 'category' => $categ ));
$limitdown = reset($limit_down);
if ($limitdown)
{
$limit = $limitdown -> limit_down -> value;
}
foreach ($CourseC as $object) {
$specialityid = $object -> specialty_id -> entity -> id() ;
$studentPerSchool = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('currentepal'=> $schoolid, 'specialization_id' => $specialityid, 'currentclass' => 3 ));
if (sizeof($studentPerSchool) < $limit){
return false;
exit;
}
}
}
return true;
exit;
}
......
import { Component, OnInit, OnDestroy, ElementRef, ViewChild, Injectable} from "@angular/core";
import { AppSettings } from '../../app.settings';
import { HelperDataService } from '../../services/helper-data-service';
import {Observable} from "rxjs/Observable";
import {Http, Headers, RequestOptions} from '@angular/http';
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,
FormControl,
FormArray,
Validators,
} from '@angular/forms';
@Component({
selector: 'eduadmin-view',
template: `
<h3> Αριθμός Μαθητών ανα τμήμα σχολείου </h3>
<ul class="list-group main-view">
<div *ngFor="let SchoolNames$ of SchoolsPerPerf$ | async; let i=index; let isOdd=odd; let isEven=even" >
<li class="list-group-item isclickable" (click)="setActiveRegion(SchoolNames$.id)" [class.changelistcolor]= "SchoolNames$.status === false" [class.oddout]="isOdd" [class.evenout]="isEven" [class.selectedout]="regionActive === SchoolNames$.id" >
<h5> {{SchoolNames$.name}}</h5>
</li>
<div *ngFor="let CoursesNames$ of CoursesPerPerf$ | async; let j=index; let isOdd2=odd; let isEven2=even" [class.oddin]="isOdd2" [class.evenin]="isEven2" [class.changecolor]="calccolor(CoursesNames$.size,CoursesNames$.limitdown)" [hidden]="SchoolNames$.id !== regionActive" >
<div> {{CoursesNames$.name}}</div> <div class= "aastyle"><strong>Αριθμός Μαθητών:</strong>{{CoursesNames$.size}} </div>
</div>
</div>
</ul>
<div class="col-md-6">
<button type="button" class="btn-primary btn-lg pull-right" (click)="navigateToApplication()" >
<i class="fa fa-forward"></i>
</button>
</div>
`
})
@Injectable() export default class EduadminView implements OnInit, OnDestroy {
public formGroup: FormGroup;
private SchoolsPerPerf$: BehaviorSubject<any>;
private SchoolPerPerfSub: Subscription;
private LimitPerCateg$: BehaviorSubject<any>;
private LimitPerCategSub: Subscription;
private CoursesPerPerf$: BehaviorSubject<any>;
private CoursesPerPerfSub: Subscription;
private StudentsSize$: BehaviorSubject<any>;
private StudentsSizeSub: Subscription;
public perfecture ;
private regionActive = <number>-1;
private School$: BehaviorSubject<any>;
private SchoolSub: Subscription;
constructor(private fb: FormBuilder,
private router: Router,
private _hds: HelperDataService,
) {
this.SchoolsPerPerf$ = new BehaviorSubject([{}]);
this.LimitPerCateg$ = new BehaviorSubject([{}]);
this.CoursesPerPerf$ = new BehaviorSubject([{}]);
this.StudentsSize$ = new BehaviorSubject({});
this.School$ = new BehaviorSubject([{}]);
this.formGroup = this.fb.group({
});
}
ngOnDestroy() {
}
ngOnInit() {
this.SchoolSub = this._hds.getSchoolId().subscribe(x => {
this.School$.next(x);
console.log(x[0].id, "perfectureID");
this.perfecture = x[0].id;
this.SchoolPerPerfSub = this._hds.getSchoolPerPerfecture(0).subscribe(data => {
this.SchoolsPerPerf$.next(data);
},
error => {
this.SchoolsPerPerf$.next([{}]);
console.log("Error Getting Schools");
},
() => console.log("Getting Schools"));
},
error => {
this.School$.next([{}]);
console.log("Error Getting School");
},
() => console.log("Getting School "));
}
setActiveRegion(ind) {
if (ind === this.regionActive)
ind = -1;
this.regionActive = ind;
this.CoursesPerPerfSub = this._hds.getCoursePerPerfecture(this.regionActive).subscribe(data => {
this.CoursesPerPerf$.next(data);
},
error => {
this.CoursesPerPerf$.next([{}]);
console.log("Error Getting Courses");
},
() => console.log("Getting Courses Per Perf"));
}
navigateToApplication()
{
var id: string= String(this.regionActive);
this.router.navigate(['', {ids:id}]);
}
calccolor(size, limit)
{
if (size < limit)
return true;
else
return false;
}
}
......@@ -23,7 +23,7 @@ import {
<ul class="list-group main-view">
<div *ngFor="let SchoolNames$ of SchoolsPerPerf$ | async; let i=index; let isOdd=odd; let isEven=even" >
<li class="list-group-item isclickable" (click)="setActiveRegion(SchoolNames$.id)" [class.changelistcolor]= "SchoolNames$.status === true" [class.oddout]="isOdd" [class.evenout]="isEven" [class.selectedout]="regionActive === SchoolNames$.id" >
<li class="list-group-item isclickable" (click)="setActiveRegion(SchoolNames$.id)" [class.changelistcolor]= "SchoolNames$.status === false" [class.oddout]="isOdd" [class.evenout]="isEven" [class.selectedout]="regionActive === SchoolNames$.id" >
<h5> {{SchoolNames$.name}}</h5>
</li>
<div *ngFor="let CoursesNames$ of CoursesPerPerf$ | async; let j=index; let isOdd2=odd; let isEven2=even" [class.oddin]="isOdd2" [class.evenin]="isEven2" [class.changecolor]="calccolor(CoursesNames$.size,CoursesNames$.limitdown)" [hidden]="SchoolNames$.id !== regionActive" >
......@@ -85,7 +85,7 @@ import {
this.School$.next(x);
console.log(x[0].id, "perfectureID");
this.perfecture = x[0].id;
this.SchoolPerPerfSub = this._hds.getSchoolPerPerfecture().subscribe(data => {
this.SchoolPerPerfSub = this._hds.getSchoolPerPerfecture(1).subscribe(data => {
this.SchoolsPerPerf$.next(data);
},
error => {
......
......@@ -90,6 +90,9 @@ export default class SchoolHome implements OnInit, OnDestroy {
}
else if (this.authRole === 'pde')
this.router.navigate(['/school/perfecture-view']);
else if (this.authRole === 'dide')
this.router.navigate(['/school/eduadmin-view']);
}
return loginInfoToken;
}, {});
......
......@@ -25,6 +25,7 @@ import AfterSubmit from '../components/student-application-form/after.submit';
import DirectorView from '../components/director/director-view';
import DirectorButtons from '../components/director/director.buttons';
import PerfectureView from '../components/infoviews/perfecture-view';
import EduadminView from '../components/infoviews/eduadmin-view';
import DirectorClassCapacity from '../components/director/director-classcapacity';
import MinisterView from '../components/minister/minister-view';
import MinisterReports from '../components/minister/minister-reports';
......@@ -36,6 +37,8 @@ import MinisterSettings from '../components/minister/minister-settings';
import SchoolAuthGuard from '../guards/school.auth.guard';
import StudentAuthGuard from '../guards/student.auth.guard';
import RegionEduAuthGuard from '../guards/regionedu.auth.guard';
import EduAdminAuthGuard from '../guards/eduadmin.auth.guard';
import MinistryAuthGuard from '../guards/ministry.auth.guard';
import Breadcrumbs from '../components/main/breadcrumbs';
......@@ -72,6 +75,7 @@ export const MainRoutes: Routes = [
{ path: 'ministry/minister-informstudents', component: InformStudents, canActivate: [MinistryAuthGuard] },
{ path: 'ministry/minister-settings', component: MinisterSettings, canActivate: [MinistryAuthGuard] },
{ path: 'school/perfecture-view', component: PerfectureView, canActivate: [RegionEduAuthGuard] },
{ path: 'school/eduadmin-view', component: EduadminView, canActivate: [EduAdminAuthGuard] },
];
export const MainDeclarations = [
......@@ -105,5 +109,6 @@ export const MainDeclarations = [
MinisterSettings,
PerfectureView,
Breadcrumbs,
DirectorButtons
DirectorButtons,
EduadminView,
];
......@@ -654,7 +654,7 @@ export class HelperDataService implements OnInit, OnDestroy {
}
getSchoolPerPerfecture() {
getSchoolPerPerfecture(status) {
this.loginInfo$.getValue().forEach(loginInfoToken => {
this.authToken = loginInfoToken.auth_token;
......@@ -665,7 +665,7 @@ export class HelperDataService implements OnInit, OnDestroy {
});
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers });
return this.http.get(`${AppSettings.API_ENDPOINT}/epal/ScoolperPerf/` , options)
return this.http.get(`${AppSettings.API_ENDPOINT}/epal/ScoolperPerf/` + status , 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