Commit f65b3633 authored by Open Source Developer's avatar Open Source Developer
Browse files

new capacity view

parent c67ef9d3
......@@ -268,6 +268,8 @@ epal.findcapacityperschool:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::FindCapacityPerSchool'
requirements:
_user_is_logged_in: 'TRUE'
epal.applicant.creationpdf:
path: '/epal/pdf-application'
options:
......
......@@ -43,7 +43,6 @@ public function getSectorsPerSchool(Request $request)
$user = reset($users);
if ($user) {
$epalId = $user -> init -> value;
$schools = $this->entityTypeManager->getStorage('eepal_school')->
loadByProperties(array('id' => $epalId));
$school = reset($schools);
......@@ -55,28 +54,36 @@ public function getSectorsPerSchool(Request $request)
$response->headers->set('Content-Type', 'application/json');
return $response;
}
$userRoles = $user->getRoles();
$userRole = '';
foreach ($userRoles as $tmpRole) {
if ($tmpRole === 'epal') {
$userRole = $tmpRole;
}
}
if ($userRole === '') {
return $this->respondWithStatus([
'error_code' => 4003,
], Response::HTTP_FORBIDDEN);
}
$userid = $user -> id();
//$epalIdNew = intval($epalId);
else if ($userRole === 'epal')
{
$sectorPerSchool = $this->entityTypeManager->getStorage('eepal_sectors_in_epal')->loadByProperties(array('epal_id'=> $epalId));
$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!!!"),
......@@ -114,8 +121,24 @@ public function getSpecialPerSchool(Request $request , $sectorId)
$response->headers->set('Content-Type', 'application/json');
return $response;
}
$userid = $user -> id();
//$epalIdNew = intval($epalId);
$userRoles = $user->getRoles();
$userRole = '';
foreach ($userRoles as $tmpRole) {
if ($tmpRole === 'epal') {
$userRole = $tmpRole;
}
}
if ($userRole === '') {
return $this->respondWithStatus([
'error_code' => 4003,
], Response::HTTP_FORBIDDEN);
}
else if ($userRole === 'epal')
{
$specialityPerSchool = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id'=> $epalId));
$i = 0;
......@@ -140,6 +163,7 @@ public function getSpecialPerSchool(Request $request , $sectorId)
$list
, Response::HTTP_OK);
}
}
else {
return $this->respondWithStatus([
'message' => t("School not found!!!"),
......@@ -178,9 +202,25 @@ public function getStudentPerSchool(Request $request , $selectId, $classId, $lim
return $response;
}
$userid = $user -> id();
//$epalIdNew = intval($epalId);
$selectIdNew = intval($selectId);
$userRoles = $user->getRoles();
$userRole = '';
foreach ($userRoles as $tmpRole) {
if ($tmpRole === 'epal') {
$userRole = $tmpRole;
}
}
if ($userRole === '') {
return $this->respondWithStatus([
'error_code' => 4003,
], Response::HTTP_FORBIDDEN);
}
else if ($userRole === 'epal')
{
$selectIdNew = $epalId;
if ($classId == 1)
{
$selectIdNew = -1;
......@@ -251,14 +291,16 @@ public function getStudentPerSchool(Request $request , $selectId, $classId, $lim
$list
, Response::HTTP_OK);
}
}
else {
$list = array();
return $this->respondWithStatus($list, Response::HTTP_OK);
}
}
}
else {
return $this->respondWithStatus([
......@@ -284,6 +326,21 @@ public function getStudentPerSchool(Request $request , $selectId, $classId, $lim
$user = reset($users);
if ($user) {
//
$userRoles = $user->getRoles();
$userRole = '';
foreach ($userRoles as $tmpRole) {
if ($tmpRole === 'epal') {
$userRole = $tmpRole;
}
}
if ($userRole === '') {
return $this->respondWithStatus([
'error_code' => 4003,
], Response::HTTP_FORBIDDEN);
}
else if ($userRole === 'epal')
{
$postData = null;
......@@ -310,6 +367,7 @@ public function getStudentPerSchool(Request $request , $selectId, $classId, $lim
return $this->respondWithStatus([
'message' => t("saved"),
], Response::HTTP_OK);
}
}
else
{
......@@ -356,6 +414,23 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit)
$response->headers->set('Content-Type', 'application/json');
return $response;
}
$userRoles = $user->getRoles();
$userRole = '';
foreach ($userRoles as $tmpRole) {
if ($tmpRole === 'epal') {
$userRole = $tmpRole;
}
}
if ($userRole === '') {
return $this->respondWithStatus([
'error_code' => 4003,
], Response::HTTP_FORBIDDEN);
}
else if ($userRole === 'epal')
{
$postData = null;
if ($content = $request->getContent())
......@@ -391,7 +466,7 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit)
}
if (($tomeas != 0) && ($specialit != 0) && ($taxi == 3))
if (($specialit != 0) && ($taxi == 3))
{
$CapacityPerClass = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $schoolid, 'specialty_id' => $specialit));
$classcapacity = reset($CapacityPerClass);
......@@ -402,7 +477,7 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit)
}
if (($tomeas != 0) && ($specialit != 0) && ($taxi == 4))
if (($specialit != 0) && ($taxi == 4))
{
$CapacityPerClass = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $schoolid, 'specialty_id' => $specialit));
$classcapacity = reset($CapacityPerClass);
......@@ -418,6 +493,7 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit)
'message' => t("saved"),
], Response::HTTP_OK);
}
}
else
{
return $this->respondWithStatus([
......@@ -727,6 +803,21 @@ public function findCapacity(Request $request,$taxi,$tomeas,$specialit)
$response->headers->set('Content-Type', 'application/json');
return $response;
}
$userRoles = $user->getRoles();
$userRole = '';
foreach ($userRoles as $tmpRole) {
if ($tmpRole === 'epal') {
$userRole = $tmpRole;
}
}
if ($userRole === '') {
return $this->respondWithStatus([
'error_code' => 4003,
], Response::HTTP_FORBIDDEN);
}
else if ($userRole === 'epal')
{
$list = array();
......@@ -795,16 +886,13 @@ public function findCapacity(Request $request,$taxi,$tomeas,$specialit)
}
}
return $this->respondWithStatus(
$list
, Response::HTTP_OK);
} else {
}
}
else {
return $this->respondWithStatus([
'message' => t("EPAL user not found"),
], Response::HTTP_FORBIDDEN);
......@@ -865,8 +953,22 @@ public function gettypeofschool(Request $request)
$response->headers->set('Content-Type', 'application/json');
return $response;
}
else
$userRoles = $user->getRoles();
$userRole = '';
foreach ($userRoles as $tmpRole) {
if ($tmpRole === 'epal') {
$userRole = $tmpRole;
}
}
if ($userRole === '') {
return $this->respondWithStatus([
'error_code' => 4003,
], Response::HTTP_FORBIDDEN);
}
else if ($userRole === 'epal')
{
$list = array();
$list[] = array(
'type' => $school -> operation_shift -> value,
......@@ -898,6 +1000,33 @@ public function gettypeofschool(Request $request)
if ($user)
{
$schoolid = $user -> init -> value;
$schools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array( 'id' => $schoolid));
$school = reset($schools);
if (!$school) {
$this->logger->warning("no access to this school=" . $user->id());
$response = new Response();
$response->setContent('No access to this school');
$response->setStatusCode(Response::HTTP_FORBIDDEN);
$response->headers->set('Content-Type', 'application/json');
return $response;
}
$userRoles = $user->getRoles();
$userRole = '';
foreach ($userRoles as $tmpRole) {
if ($tmpRole === 'epal') {
$userRole = $tmpRole;
}
}
if ($userRole === '') {
return $this->respondWithStatus([
'error_code' => 4003,
], Response::HTTP_FORBIDDEN);
}
else if ($userRole === 'epal')
{
$list= array();
$SchoolCats = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id'=> $schoolid ));
......@@ -977,6 +1106,7 @@ public function gettypeofschool(Request $request)
$list
, Response::HTTP_OK);
}
}
else
{
return $this->respondWithStatus([
......@@ -999,7 +1129,7 @@ public function gettypeofschool(Request $request)
public function FindCapacityPerSchool(Request $request)
{
$i = 0;
$authToken = $request->headers->get('PHP_AUTH_USER');
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
......@@ -1016,6 +1146,21 @@ public function gettypeofschool(Request $request)
$response->headers->set('Content-Type', 'application/json');
return $response;
}
$userRoles = $user->getRoles();
$userRole = '';
foreach ($userRoles as $tmpRole) {
if ($tmpRole === 'epal') {
$userRole = $tmpRole;
}
}
if ($userRole === '') {
return $this->respondWithStatus([
'error_code' => 4003,
], Response::HTTP_FORBIDDEN);
}
else if ($userRole === 'epal')
{
$list = array();
$CapacityPerClass = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id' => $schoolid ));
......@@ -1027,11 +1172,14 @@ public function gettypeofschool(Request $request)
$list[] = array(
'class' => 1,
'newsector' => 0,
'newspecialit' => 0,
'taxi' => 'Ά Λυκείου',
'capacity' => $classcapacity -> capacity_class_a -> value ,
'globalindex' => $i ,
);
}
$i++;
$CourseB = $this->entityTypeManager->getStorage('eepal_sectors_in_epal')->loadByProperties(array('epal_id' => $schoolid ));
if ($CourseB)
{
......@@ -1043,10 +1191,14 @@ public function gettypeofschool(Request $request)
if ($classcapacity) {
$list[] = array(
'class' => 2,
'newsector' => $object -> sector_id -> entity -> id(),
'newspecialit' => 0,
'taxi' => 'Β Λυκείου '.$object -> sector_id -> entity-> get('name')->value,
'capacity' => $classcapacity -> capacity_class_sector -> value ,
'globalindex' => $i ,
);
}
$i++;
}
}
$CourseC = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $schoolid ));
......@@ -1059,10 +1211,14 @@ public function gettypeofschool(Request $request)
if ($classcapacity) {
$list[] = array(
'class' => 3,
'newsector' => 0,
'newspecialit' => $object -> specialty_id -> entity -> id(),
'taxi' => 'Γ Λυκείου '.$object -> specialty_id -> entity-> get('name')->value,
'capacity' => $classcapacity -> capacity_class_specialty -> value ,
'globalindex' => $i ,
);
}
$i++;
}
}
......@@ -1076,18 +1232,22 @@ public function gettypeofschool(Request $request)
if ($classcapacity) {
$list[] = array(
'class' => 4,
'newsector' => 0,
'newspecialit' => $object -> specialty_id -> entity -> id(),
'taxi' => 'Δ Λυκείου '.$object -> specialty_id -> entity-> get('name')->value,
'capacity' => $classcapacity -> capacity_class_specialty_d -> value ,
'globalindex' => $i ,
);
}
$i++;
}
}
return $this->respondWithStatus(
$list
, Response::HTTP_OK);
}
} else {
return $this->respondWithStatus([
......
......@@ -27,75 +27,49 @@ import {
<div class = "loading" *ngIf="(showLoader | async) === true"></div>
<div style="min-height: 500px;">
<form [formGroup]="formGroup">
<label for="taxi">Τάξη</label><br/>
<div class="form-group">
<select #txoption class="form-control" (change)="verifyclass(txoption)" formControlName="taxi">
<option value="1" >Α' Λυκείου</option>
<option value="2" >Β' Λυκείου</option>
<option value="3" >Γ' Λυκείου</option>
<option *ngIf="(selectiontype | async)" value="4" >Δ' Λυκείου</option>
</select>
</div>
<div class="form-group">
<select #tmop class="form-control" *ngIf="(selectionBClass | async)" (change)="checkbclass(tmop,txoption)" formControlName="tomeas">
<option *ngFor="let SectorSelection$ of StudentSelected$ | async; let i=index" [value] = "SectorSelection$.id"> {{SectorSelection$.sector_id}} </option>
</select>
</div>
<div class="form-group">
<select #spop class="form-control" *ngIf="(selectionCClass | async)" (change)="checkcclass(tmop,txoption,spop)" formControlName="specialit">
<option *ngFor="let SpecialSelection$ of StudentSelectedSpecial$ | async; let i=index" [value] = "SpecialSelection$.id"> {{SpecialSelection$.specialty_id}} </option>
</select>
</div>
<p style="margin-top: 20px; line-height: 2em;"> Αλλάξτε παρακαλώ τον αριθμό των τμημάτων που μπορείτε να δημιουργήσετε στο σχολείο σας και πατήστε <i>Αποθήκευση</i>.</p>
<input type="number" formControlName="capacity" min="1" max="10" ng-min="1" ng-max="99" >
<div class="alert alert-danger" *ngIf="formGroup.get('capacity').touched && formGroup.get('capacity').hasError('maxValue')">
Παρακαλώ συμπληρώστε ένα μικρότερο αριθμό!
</div>
<div class="alert alert-danger" *ngIf="formGroup.get('capacity').touched && formGroup.get('capacity').hasError('minValue')">
Παρακαλώ συμπληρώστε ένα μεγαλύτερο αριθμό!
</div>
<div class="alert alert-danger" *ngIf="formGroup.get('capacity').touched && formGroup.get('capacity').hasError('required')">
Συμπληρώστε την διαθεσιμότητα σας σε τμήματα !
</div>
<button type="button" class="btn-primary btn-sm pull-right" (click) ="saveCapacity()">
Αποθήκευση
</button>
</form>
<br>
<br>
<p style="margin-top: 20px; line-height: 2em;"> Στην παρακάτω'λίστα βλέπετε τα τμήματα του σχολείου σας με την αντίστοιχη δυναμίκη τους σε αίθουσες. Παρακαλώ για να τροποποποιήσετε τη δυναμικήαυτή κάντε κλικ στον αντίστοιχο αριθμό,
επιλέξτε τη νέα δυναμική και πατήστε το σύμβολο <i>ok</i>. Προσοχή! Κανένα τμήμα δεν πρέπει να έχει δυναμική 0.</p>
<div class="row" style="margin-top: 20px; line-height: 2em;" > <b> Οι δηλώσεις σας </b></div>
<div *ngFor="let CapacityPerCourses$ of CapacityPerCourse$ | async; let i=index; let isOdd=odd; let isEven=even" >
<li *ngIf="(!(selectiontype | async) && (CapacityPerCourses$.class < 4)) ||((selectiontype | async) && (CapacityPerCourses$.class < 5))" class="list-group-item " [class.oddout]="isOdd" [class.evenout]="isEven" >
<h5 [class.changelistcolor]= "CapacityPerCourses$.capacity === null" >{{CapacityPerCourses$.taxi}}&nbsp; <b>{{CapacityPerCourses$.capacity}}</b></h5>
<div class="row">
<div class="col-md-5">
<h5 [class.changelistcolor]= "CapacityPerCourses$.capacity === 0" >{{CapacityPerCourses$.taxi}}&nbsp; <b></b></h5>
</div>
<div class="col-md-4" col-md-offset-2>
<label *ngIf="!isEdit" (click)="isEdit=true" (click)="setActive(i)"> {{CapacityPerCourses$.capacity}} </label>
<input *ngIf="isEdit && CapacityPerCourses$.globalindex === courseActive"
id="{{CapacityPerCourses$.globalindex}}" type="number"
name="{{CapacityPerCourses$.globalindex}}" value ={{CapacityPerCourses$.capacity}}
(change)="handleChange($event)">
</div>
<div class="col-md-1">
<button *ngIf="isEdit && CapacityPerCourses$.globalindex === courseActive" type="button" class="btn-primary pull-right"
(click)="isEdit=false" (click) ="saveCapacity(CapacityPerCourses$.newspecialit, CapacityPerCourses$.newsector, CapacityPerCourses$.class, CapacityPerCourses$.capacity)">
<i class="fa fa-check" aria-hidden="true"></i>
</button>
</div>
</div>
</li>
</div>
</form>
</div>
<div id="checksaved" (onHidden)="onHidden('#checksaved')"
class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header modal-header-danger">
<h3 class="modal-title pull-left"><i class="fa fa-check-square-o"></i>&nbsp;&nbsp;Πρέπει να συπληρώσετε όλα τα πεδία</h3>
<h3 class="modal-title pull-left"><i class="fa fa-check-square-o"></i>&nbsp;&nbsp;Πρέπει να συπληρώσετε σωστά τη δυναμική</h3>
<button type="button" class="close pull-right" aria-label="Close" (click)="hideModal('#checksaved')">
<span aria-hidden="true"><i class="fa fa-times"></i></span>
</button>
</div>
<div class="modal-body">
<p>Η αποθήκευση δε μπορεί να γίνει αν δεν συμπληρώσετε όλα τα στοιχεία της φόρμας!</p>
<p>Η αποθήκευση δε μπορεί να γίνει αν δεν συμπληρώσετε έναν αριθμό μεταξυ 1 και 10!</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">Κλείσιμο</button>
......@@ -105,25 +79,6 @@ import {
</div>
<div id="capacitysaved" (onHidden)="onHidden('#capacitysaved')"
class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header modal-header-success">
<h3 class="modal-title pull-left"><i class="fa fa-check-square-o"></i>&nbsp;&nbsp;Αποθήκευση Δυναμικής</h3>
<button type="button" class="close pull-right" aria-label="Close" (click)="hideModal('#capacitysaved')">
<span aria-hidden="true"><i class="fa fa-times"></i></span>
</button>
</div>
<div class="modal-body">
<p>Η επιλογή σας έχει αποθηκευτεί.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">Κλείσιμο</button>
</div>
</div>
</div>
</div>
......@@ -135,28 +90,18 @@ import {
@Injectable() export default class DirectorClassCapacity implements OnInit, OnDestroy {
public formGroup: FormGroup;
private StudentSelected$: BehaviorSubject<any>;
private StudentSelectedSub: Subscription;
private StudentSelectedSpecial$: BehaviorSubject<any>;
private StudentSelectedSpecialSub: Subscription;
private CapacityPerCourse$: BehaviorSubject<any>;
private CapacityPerCourseSub: Subscription;
private saveCapacitySub: Subscription;
private selectionBClass: BehaviorSubject<boolean>;
private selectiontype: BehaviorSubject<boolean>;
private selectionCClass: BehaviorSubject<boolean>;
private newvalue:number;
private isEdit: boolean;
private courseActive = <number>-1;
private showLoader: BehaviorSubject<boolean>;
private School$: BehaviorSubject<any>;
private SchoolSub: Subscription;
private CapacityPerCourse$: BehaviorSubject<any>;
private CapacityPerCourseSub: Subscription;
private selectiontype: BehaviorSubject<boolean>;
private SchoolId;
private currentclass: Number;
private classCapacity$: BehaviorSubject<any>;
private classCapacitySub: Subscription;
private retrievedStudent: BehaviorSubject<boolean>;
private modalTitle: BehaviorSubject<string>;
private modalText: BehaviorSubject<string>;
private modalHeader: BehaviorSubject<string>;
private showLoader: BehaviorSubject<boolean>;
......@@ -164,32 +109,20 @@ import {
private _hds: HelperDataService,
private activatedRoute: ActivatedRoute,
private router: Router) {
this.StudentSelected$ = new BehaviorSubject([{}]);
this.StudentSelectedSpecial$ = new BehaviorSubject([{}]);
this.classCapacity$ = new BehaviorSubject([{}]);
this.CapacityPerCourse$ = new BehaviorSubject([{}]);
this.selectionBClass = new BehaviorSubject(false);
this.selectiontype = new BehaviorSubject(true);
this.selectionCClass = new BehaviorSubject(false);
this.retrievedStudent = new BehaviorSubject(false);
this.School$ = new BehaviorSubject([{}]);
this.modalTitle = new BehaviorSubject("");
this.modalText = new BehaviorSubject("");
this.modalHeader = new BehaviorSubject("");
this.showLoader = new BehaviorSubject(false);
this.isEdit = false;
this.School$ = new BehaviorSubject([{}]);
this.selectiontype = new BehaviorSubject(true);
this.formGroup = this.fb.group({