Merge branch 'stylesandmenus' into 'develop'

limits per school category

See merge request !109
parents 5933a60e bee210b2
...@@ -199,7 +199,7 @@ epal.ministry.storesettings: ...@@ -199,7 +199,7 @@ epal.ministry.storesettings:
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
regionview: regionview:
path: '/epal/ScoolperPerf/{perfectureId}' path: '/epal/ScoolperPerf'
options: options:
_auth: [ 'basic_auth' ] _auth: [ 'basic_auth' ]
defaults: defaults:
...@@ -246,5 +246,13 @@ gettypeofschool: ...@@ -246,5 +246,13 @@ gettypeofschool:
_controller: '\Drupal\epal\Controller\DirectorView::gettypeofschool' _controller: '\Drupal\epal\Controller\DirectorView::gettypeofschool'
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
getlimitspercourse:
path: '/epal/getlimitsperCourse/{classid}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::getlimitsperCourse'
requirements:
_user_is_logged_in: 'TRUE'
...@@ -786,6 +786,115 @@ public function gettypeofschool(Request $request) ...@@ -786,6 +786,115 @@ public function gettypeofschool(Request $request)
} }
public function getlimitsperCourse(Request $request, $classid)
{
$authToken = $request->headers->get('PHP_AUTH_USER');
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if ($user)
{
$schoolid = $user -> init -> value;
$list= array();
$SchoolCats = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id'=> $schoolid ));
$SchoolCat = reset($SchoolCats);
if ($SchoolCat){
$categ = $SchoolCat-> metathesis_region -> value;
$list = array();
if ($classid == 1)
{
$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;
}
$list[] = array(
'id' => '1',
'name' => 'Α Λυκείου',
'categ' => $categ,
'classes' => 1,
'limitdown' => $limit,
);
}
if ($classid == 2){
$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;
}
$list[] = array(
'name' => 'Β Λυκείου ',
'categ' => $categ,
'classes' => 2,
'limitdown' => $limit,
);
}
if ($classid == 3){
$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;
}
$list[] = array(
'categ' => $categ,
'classes' => 3,
'limitdown' => $limit,
);
}
return $this->respondWithStatus(
$list
, Response::HTTP_OK);
}
else
{
return $this->respondWithStatus([
'message' => t("Perfecture not found!"),
], Response::HTTP_FORBIDDEN);
}
}
else
{
return $this->respondWithStatus([
'message' => t("User not found!"),
], Response::HTTP_FORBIDDEN);
}
}
private function respondWithStatus($arr, $s) { private function respondWithStatus($arr, $s) {
$res = new JsonResponse($arr); $res = new JsonResponse($arr);
$res->setStatusCode($s); $res->setStatusCode($s);
......
...@@ -146,6 +146,7 @@ import { ...@@ -146,6 +146,7 @@ import {
</nav> </nav>
</div> </div>
</form> </form>
</div> </div>
...@@ -175,14 +176,18 @@ import { ...@@ -175,14 +176,18 @@ import {
private selectionBClass: BehaviorSubject<boolean>; private selectionBClass: BehaviorSubject<boolean>;
private selectiontype: BehaviorSubject<boolean>; private selectiontype: BehaviorSubject<boolean>;
private selectionCClass: BehaviorSubject<boolean>; private selectionCClass: BehaviorSubject<boolean>;
private limitsSub: Subscription;
private limits$: BehaviorSubject<any>;
private SchoolId ; private SchoolId ;
private currentclass: Number; private currentclass: Number;
private saved: Array<number> = new Array(); private saved: Array<number> = new Array();
private limitdown = 0; private limitdown = 0;
private limitup = 5; private limitup = 5;
private pageno = 1; private pageno = 1;
public totallimit;
private userActive = <number>-1; private userActive = <number>-1;
private type: Number; private type: Number;
public tot_pages: number;
@ViewChild('fileInput') fileInput: ElementRef; @ViewChild('fileInput') fileInput: ElementRef;
...@@ -198,9 +203,11 @@ import { ...@@ -198,9 +203,11 @@ import {
this.StudentsSize$ = new BehaviorSubject({}); this.StudentsSize$ = new BehaviorSubject({});
this.SavedStudents$ = new BehaviorSubject({}); this.SavedStudents$ = new BehaviorSubject({});
this.SubmitedDetails$ = new BehaviorSubject([{}]); this.SubmitedDetails$ = new BehaviorSubject([{}]);
this.limits$ = new BehaviorSubject([{}]);
this.retrievedStudent = new BehaviorSubject(false); this.retrievedStudent = new BehaviorSubject(false);
this.selectionBClass = new BehaviorSubject(false); this.selectionBClass = new BehaviorSubject(false);
this.selectionCClass = new BehaviorSubject(false); this.selectionCClass = new BehaviorSubject(false);
//this.outoflimits = new BehaviorSubject(false);
this.School$ = new BehaviorSubject([{}]); this.School$ = new BehaviorSubject([{}]);
this.selectiontype = new BehaviorSubject(true); this.selectiontype = new BehaviorSubject(true);
...@@ -215,6 +222,7 @@ import { ...@@ -215,6 +222,7 @@ import {
} }
ngOnDestroy() { ngOnDestroy() {
if (this.StudentSelectedSub) if (this.StudentSelectedSub)
this.StudentSelectedSub.unsubscribe(); this.StudentSelectedSub.unsubscribe();
...@@ -231,6 +239,7 @@ import { ...@@ -231,6 +239,7 @@ import {
} }
ngOnInit() { ngOnInit() {
...@@ -328,57 +337,96 @@ import { ...@@ -328,57 +337,96 @@ import {
findstudent(txop, pageno) { findstudent(txop, pageno) {
var tot_pages: number;
var sectorint = +this.formGroup.value.tomeas; var sectorint = +this.formGroup.value.tomeas;
if (txop.value === "1") { this.currentclass = +txop.value;
this.currentclass = 1;
}
else if (txop.value === "2") {
this.currentclass = 2;
}
else if (txop.value === "3") {
this.currentclass = 3;
}
else if (txop.value === "4") {
this.currentclass = 4;
}
this.formGroup.get('pageno').setValue(this.pageno); this.formGroup.get('pageno').setValue(this.pageno);
if (this.pageno == 1) { if (this.pageno == 1) {
console.log(this.SchoolId, sectorint, this.currentclass, "testaaaaaa");
console.log("mphkepage = 1");
this.StudentsSizeSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, 0, 0).subscribe(x => { this.StudentsSizeSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, 0, 0).subscribe(x => {
this.StudentsSize$.next(x); this.StudentsSize$.next(x);
tot_pages = x.id / 5; this.totallimit = x.id;
this.limitsSub = this._hds.getlimitsofcourse(this.currentclass).subscribe(data => {
this.limits$.next(data);
console.log(this.totallimit, data[0].limitdown, "oria");
this.tot_pages = x.id / 5;
if (x.id % 5 > 0) { if (x.id % 5 > 0) {
tot_pages = (x.id - (x.id % 5)) / 5 + 1; this.tot_pages = (x.id - (x.id % 5)) / 5 + 1;
} }
console.log(tot_pages,"totpages") console.log(this.tot_pages,"totpages")
if (isNaN(tot_pages)){ if (isNaN(this.tot_pages)){
this.retrievedStudent.next(false); this.retrievedStudent.next(false);
tot_pages = 0; this.tot_pages = 0;
} }
this.formGroup.get('maxpage').setValue(tot_pages); if ( (x.id < data[0].limitdown) || (isNaN(this.tot_pages)))
{
console.log("mphkeprwto!")
this.retrievedStudent.next(false);
this.tot_pages = 0;
this.formGroup.get('maxpage').setValue(this.tot_pages);
//this.outoflimits.next(true);
}
else
{
// this.outoflimits.next(false);
this.formGroup.get('maxpage').setValue(this.tot_pages);
console.log(this.tot_pages,"mazeuw mathites");
this.StudentInfoSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, this.limitdown, this.limitup).subscribe(data => {
this.StudentInfo$.next(data);
console.log("tot.pages", this.formGroup.value.maxpage, "max1", this.tot_pages);
this.retrievedStudent.next(true);
},
error => {
this.StudentInfo$.next([{}]);
console.log("Error Getting Students");
},
() => console.log("Getting Students"));
}
},
error => {
this.limits$.next([{}]);
console.log("Error Getting limits");
},
() => console.log("Getting limits"));
}); });
} }
console.log(this.limitdown, this.limitup,"mits"); else{
this.StudentInfoSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, this.limitdown, this.limitup).subscribe(data => { console.log("eisai edw", this.tot_pages);
this.StudentInfo$.next(data);
if (tot_pages === 0){
console.log("tot.pages", this.formGroup.value.maxpage); if (this.tot_pages == 0 ){
console.log("mphke1", this.formGroup.value.maxpage, this.tot_pages);
this.retrievedStudent.next(false); this.retrievedStudent.next(false);
} }
else else
{ {
console.log("tot.pages", this.formGroup.value.maxpage, "max", tot_pages); console.log(this.tot_pages,"mazeuw mathites");
this.StudentInfoSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, this.limitdown, this.limitup).subscribe(data => {
this.StudentInfo$.next(data);
console.log("tot.pages", this.formGroup.value.maxpage, "max1", this.tot_pages);
this.retrievedStudent.next(true); this.retrievedStudent.next(true);
}
}, },
error => { error => {
this.StudentInfo$.next([{}]); this.StudentInfo$.next([{}]);
console.log("Error Getting Students"); console.log("Error Getting Students");
}, },
() => console.log("Getting Students")); () => console.log("Getting Students"));
}
}
} }
......
...@@ -875,5 +875,21 @@ gettypeofschool(){ ...@@ -875,5 +875,21 @@ gettypeofschool(){
} }
getlimitsofcourse(classid){
this.loginInfo$.getValue().forEach(loginInfoToken => {
this.authToken = loginInfoToken.auth_token;
this.authRole = loginInfoToken.auth_role;
});
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/getlimitsperCourse/`+ classid , 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