Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Χάρης Παπαδόπουλος
e-epal
Commits
bee210b2
Commit
bee210b2
authored
May 29, 2017
by
Open Source Developer
Browse files
limits per school category
parent
8b180c9e
Changes
4
Hide whitespace changes
Inline
Side-by-side
drupal/modules/epal/epal.routing.yml
View file @
bee210b2
...
...
@@ -199,7 +199,7 @@ epal.ministry.storesettings:
requirements
:
_user_is_logged_in
:
'
TRUE'
regionview
:
path
:
'
/epal/ScoolperPerf
/{perfectureId}
'
path
:
'
/epal/ScoolperPerf'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
...
...
@@ -246,5 +246,13 @@ gettypeofschool:
_controller
:
'
\Drupal\epal\Controller\DirectorView::gettypeofschool'
requirements
:
_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'
drupal/modules/epal/src/Controller/DirectorView.php
View file @
bee210b2
...
...
@@ -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
)
{
$res
=
new
JsonResponse
(
$arr
);
$res
->
setStatusCode
(
$s
);
...
...
source/components/director/director-view.ts
View file @
bee210b2
...
...
@@ -146,6 +146,7 @@ import {
</nav>
</div>
</form>
</div>
...
...
@@ -175,14 +176,18 @@ import {
private
selectionBClass
:
BehaviorSubject
<
boolean
>
;
private
selectiontype
:
BehaviorSubject
<
boolean
>
;
private
selectionCClass
:
BehaviorSubject
<
boolean
>
;
private
limitsSub
:
Subscription
;
private
limits$
:
BehaviorSubject
<
any
>
;
private
SchoolId
;
private
currentclass
:
Number
;
private
saved
:
Array
<
number
>
=
new
Array
();
private
limitdown
=
0
;
private
limitup
=
5
;
private
pageno
=
1
;
public
totallimit
;
private
userActive
=
<
number
>-
1
;
private
type
:
Number
;
public
tot_pages
:
number
;
@
ViewChild
(
'
fileInput
'
)
fileInput
:
ElementRef
;
...
...
@@ -198,9 +203,11 @@ import {
this
.
StudentsSize$
=
new
BehaviorSubject
({});
this
.
SavedStudents$
=
new
BehaviorSubject
({});
this
.
SubmitedDetails$
=
new
BehaviorSubject
([{}]);
this
.
limits$
=
new
BehaviorSubject
([{}]);
this
.
retrievedStudent
=
new
BehaviorSubject
(
false
);
this
.
selectionBClass
=
new
BehaviorSubject
(
false
);
this
.
selectionCClass
=
new
BehaviorSubject
(
false
);
//this.outoflimits = new BehaviorSubject(false);
this
.
School$
=
new
BehaviorSubject
([{}]);
this
.
selectiontype
=
new
BehaviorSubject
(
true
);
...
...
@@ -215,6 +222,7 @@ import {
}
ngOnDestroy
()
{
if
(
this
.
StudentSelectedSub
)
this
.
StudentSelectedSub
.
unsubscribe
();
...
...
@@ -231,6 +239,7 @@ import {
}
ngOnInit
()
{
...
...
@@ -328,57 +337,96 @@ import {
findstudent
(
txop
,
pageno
)
{
var
tot_pages
:
number
;
var
sectorint
=
+
this
.
formGroup
.
value
.
tomeas
;
if
(
txop
.
value
===
"
1
"
)
{
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
.
currentclass
=
+
txop
.
value
;
this
.
formGroup
.
get
(
'
pageno
'
).
setValue
(
this
.
pageno
);
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
.
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
)
{
tot_pages
=
(
x
.
id
-
(
x
.
id
%
5
))
/
5
+
1
;
this
.
tot_pages
=
(
x
.
id
-
(
x
.
id
%
5
))
/
5
+
1
;
}
console
.
log
(
tot_pages
,
"
totpages
"
)
if
(
isNaN
(
tot_pages
)){
console
.
log
(
this
.
tot_pages
,
"
totpages
"
)
if
(
isNaN
(
this
.
tot_pages
)){
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
"
);
this
.
StudentInfoSub
=
this
.
_hds
.
getStudentPerSchool
(
sectorint
,
this
.
currentclass
,
this
.
limitdown
,
this
.
limitup
).
subscribe
(
data
=>
{
this
.
StudentInfo$
.
next
(
data
);
if
(
tot_pages
===
0
){
console
.
log
(
"
tot.pages
"
,
this
.
formGroup
.
value
.
maxpage
);
else
{
console
.
log
(
"
eisai edw
"
,
this
.
tot_pages
);
if
(
this
.
tot_pages
==
0
){
console
.
log
(
"
mphke1
"
,
this
.
formGroup
.
value
.
maxpage
,
this
.
tot_pages
);
this
.
retrievedStudent
.
next
(
false
);
}
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
);
}
},
},
error
=>
{
this
.
StudentInfo$
.
next
([{}]);
console
.
log
(
"
Error Getting Students
"
);
},
()
=>
console
.
log
(
"
Getting Students
"
));
}
}
}
...
...
source/services/helper-data-service.ts
View file @
bee210b2
...
...
@@ -876,5 +876,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
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment