Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gredu_labs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
itminedu
gredu_labs
Commits
c0263ac7
Commit
c0263ac7
authored
Feb 15, 2016
by
kanellov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implementing staff ui
parent
29fb0a3d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
150 additions
and
28 deletions
+150
-28
module/application/bootstrap.php
module/application/bootstrap.php
+1
-0
module/schools/bootstrap.php
module/schools/bootstrap.php
+1
-1
module/schools/src/Action/Staff.php
module/schools/src/Action/Staff.php
+1
-10
module/schools/src/Filter/Teacher.php
module/schools/src/Filter/Teacher.php
+90
-0
module/schools/src/Service/StaffService.php
module/schools/src/Service/StaffService.php
+36
-14
module/schools/templates/schools/index.twig
module/schools/templates/schools/index.twig
+17
-0
module/schools/templates/schools/staff.twig
module/schools/templates/schools/staff.twig
+4
-3
No files found.
module/application/bootstrap.php
View file @
c0263ac7
...
...
@@ -28,6 +28,7 @@ return function (Slim\App $app) {
$container
[
'settings'
][
'db'
][
'user'
],
$container
[
'settings'
][
'db'
][
'pass'
]
);
RedBeanPHP\R
::
freeze
();
$container
[
'view'
]
=
function
(
$c
)
{
$settings
=
$c
[
'settings'
];
...
...
module/schools/bootstrap.php
View file @
c0263ac7
...
...
@@ -60,7 +60,7 @@ return function (Slim\App $app) {
$container
[
'staffservice'
]
=
function
(
$c
)
{
return
new
GrEduLabs\Schools\Service\StaffService
(
$c
->
get
(
'schoolservice'
)
new
GrEduLabs\Schools\Filter\Teacher
(
)
);
};
...
...
module/schools/src/Action/Staff.php
View file @
c0263ac7
...
...
@@ -29,16 +29,7 @@ class Staff
$staff
=
$this
->
staffservice
->
getTeachersBySchoolId
(
1
);
return
$this
->
view
->
render
(
$res
,
'schools/staff.twig'
,
[
'staff'
=>
array_map
(
function
(
$employee
)
{
return
array_merge
(
$employee
->
export
(),
[
'branch'
=>
$employee
->
branch
->
name
,
]);
},
$staff
),
'positions'
=>
[
[
'value'
=>
1
,
'label'
=>
'Εκπαδευτικός'
],
[
'value'
=>
2
,
'label'
=>
'Διευθυντής σχολείου'
],
[
'value'
=>
3
,
'label'
=>
'Υπεύθυνος εργαστηρίου'
],
],
'staff'
=>
$staff
,
'branches'
=>
array_map
(
function
(
$branch
)
{
return
[
'value'
=>
$branch
[
'id'
],
'label'
=>
$branch
[
'name'
]];
},
$this
->
staffservice
->
getBranches
()),
...
...
module/schools/src/Filter/Teacher.php
0 → 100644
View file @
c0263ac7
<?php
/**
* gredu_labs
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace
GrEduLabs\Schools\Filter
;
use
InvalidArgumentException
;
class
Teacher
{
// private static $required = [
// 'school_id',
// 'branch_id',
// 'name',
// 'surname',
// 'email',
// 'telephone',
// ];
// private static $optional = [
// 'is_principle',
// 'is_responsible',
// ];
// private static $messageTemplates = [
// 'school_id' => 'Δεν ορίστηκε το σχολείο',
// 'branch_id' => 'Δεν ορίστηκε η ειδικότητα',
// 'name' => 'Δεν ορίστηκε το όνομα',
// 'surname' => 'Δεν ορίστηκε το επώνυμο',
// 'email'=> 'Δεν ορίστηκε το email',
// 'telephone' => 'Δεν ορίστηκε το τηλέφωνο',
// ];
private
static
$filter
=
[
'school_id'
=>
[
'filter'
=>
FILTER_VALIDATE_INT
,
'flags'
=>
FILTER_REQUIRE_SCALAR
,
],
'branch_id'
=>
[
'filter'
=>
FILTER_VALIDATE_INT
,
'flags'
=>
FILTER_REQUIRE_SCALAR
,
],
'name'
=>
[
'filter'
=>
FILTER_SANITIZE_STRING
,
'flags'
=>
FILTER_REQUIRE_SCALAR
,
],
'surname'
=>
[
'filter'
=>
FILTER_SANITIZE_STRING
,
'flags'
=>
FILTER_REQUIRE_SCALAR
,
],
'email'
=>
FILTER_VALIDATE_EMAIL
,
'telephone'
=>
FILTER_SANITIZE_NUMBER_INT
,
'is_principle'
=>
[
'filter'
=>
FILTER_VALIDATE_BOOLEAN
,
],
'is_responsible'
=>
[
'filter'
=>
FILTER_VALIDATE_BOOLEAN
,
],
];
public
function
__invoke
(
array
$data
,
$create
=
true
)
{
var_dump
(
filter_var_array
(
$data
,
self
::
$filter
,
$create
));
die
();
// $messages = [];
// $fields = array_merge(self::$required, self::$optional);
// $data = array_intersect_key($data, array_flip($fields));
// $filtered = array_map('trim', $data);
// foreach (self::$required as $required) {
// if (!isset($data[$required])|| empty($data[$required])) {
// $messages[$required][] = self::$messageTemplates[$required];
// }
// }
// if (filter_input_array(type))
// var_dump($messages);
// die();
}
}
\ No newline at end of file
module/schools/src/Service/StaffService.php
View file @
c0263ac7
...
...
@@ -13,14 +13,18 @@ use RedBeanPHP\R;
class
StaffService
implements
StaffServiceInterface
{
protected
$schoolService
;
public
function
__construct
(
SchoolServiceInterface
$schoolService
)
private
$filter
;
public
function
__construct
(
callable
$filter
)
{
$this
->
schoolService
=
$schoolService
;
$this
->
filter
=
$filter
;
}
public
function
createTeacher
(
array
$data
)
{
$data
=
call_user_func
(
$this
->
filter
,
$data
,
true
);
var_dump
(
$data
);
die
();
unset
(
$data
[
'id'
]);
$teacher
=
R
::
dispense
(
'teacher'
);
$required
=
[
'school_id'
,
'name'
,
'email'
,
'surname'
,
'telephone'
,
...
...
@@ -40,34 +44,52 @@ class StaffService implements StaffServiceInterface
public
function
updateTeacher
(
array
$data
,
$id
)
{
$teacher
=
R
::
load
(
'teacher'
,
$id
);
foreach
(
$data
as
$key
=>
$value
)
{
$teacher
[
$key
]
=
$value
;
}
$id
=
R
::
store
(
$teacher
);
try
{
$teacher
=
R
::
load
(
'teacher'
,
$id
);
foreach
(
$data
as
$key
=>
$value
)
{
$teacher
[
$key
]
=
$value
;
}
$id
=
R
::
store
(
$teacher
);
return
$id
;
return
$id
;
}
catch
(
\
Exception
$e
)
{
}
}
public
function
getTeacherById
(
$id
)
{
$teacher
=
R
::
load
(
'teacher'
,
$id
);
return
$t
eacher
;
return
$t
his
->
export
(
$teacher
)
;
}
public
function
getTeachersBySchoolId
(
$id
)
{
$school
=
$this
->
schoolService
->
getSchool
(
$id
);
$teachers
=
$school
->
ownTeacher
;
$teachers
=
R
::
findAll
(
'teacher'
,
'school_id = ?'
,
[
$id
]);
return
$teachers
;
return
array_map
([
$this
,
'export'
],
$teachers
)
;
}
public
function
getBranches
()
{
return
array_map
(
function
(
$branch
)
{
return
$branch
->
export
();
},
R
::
find
(
'branch'
,
'ORDER BY name ASC'
));
},
R
::
findAll
(
'branch'
,
'ORDER BY name ASC'
));
}
private
function
export
(
$teacherBean
)
{
$position
=
[];
if
(
$teacherBean
->
is_principle
)
{
$position
[]
=
'Διευθυντής'
;
}
if
(
$teacherBean
->
is_responsible
)
{
$position
[]
=
'Υπεύθυνος εργαστηρίου'
;
}
return
array_merge
(
$teacherBean
->
export
(),
[
'branch'
=>
$teacherBean
->
branch
->
name
,
'position'
=>
implode
(
', '
,
$position
),
]);
}
}
module/schools/templates/schools/index.twig
View file @
c0263ac7
...
...
@@ -14,6 +14,23 @@
</div>
{%
endmacro
%}
{%
macro
checkbox
(
name
,
label
,
checked
,
attributes
)
%}
<div
class=
"form-group"
>
<div
class=
"col-xs-12 col-sm-12 col-md-9 col-md-offset-3"
>
<div
class=
"checkbox"
>
<label>
<input
type=
"checkbox"
name=
"
{{
name
}}
"
id=
"el-
{{
name
}}
"
{%
if
checked
%}
checked
{%
endif
%}
{%
for
attr_name
,
attr_value
in
attributes
|
default
(
{}
)
%}
{{
attr_name
}}
="
{{
attr_value
}}
"
{%
endfor
%}
>
{{
label
|
raw
}}
</label>
</div>
</div>
</div>
{%
endmacro
%}
{%
macro
file
(
name
,
label
,
value
,
attributes
)
%}
<div
class=
"form-group"
>
<label
class=
"control-label hidden-xs hidden-sm col-md-3"
for=
"el-
{{
name
}}
"
>
{{
label
|
raw
}}
</label>
...
...
module/schools/templates/schools/staff.twig
View file @
c0263ac7
...
...
@@ -39,12 +39,12 @@
<a
href=
"mailto:
{{
employee.email
}}
"
>
{{
employee.email
}}
</a>
</td>
<td
class=
"branch"
>
{{
employee.branch
}}
</td>
<td
class=
"position
Label"
>
{{
employee.positionLabel
}}
</td>
<td
class=
"position
"
>
{{
employee.position
}}
</td>
</tr>
{%
else
%}
<tr>
<td
colspan=
"6"
class=
"text-center text-muted no-records"
>
Δεν έχ
ει καταχωρηθεί προσωπικό
.
Δεν έχ
ουν καταχωρηθεί εκπαιδευτικοί
.
</td>
</tr>
{%
endfor
%}
...
...
@@ -72,7 +72,8 @@
{{
macros.input
(
'telephone'
,
'Τηλέφωνο'
,
''
,
'tel'
,
{
'required'
:
''
}
)
}}
{{
macros.input
(
'email'
,
'Email'
,
''
,
'email'
,
{
'required'
:
''
}
)
}}
{{
macros.select
(
'branch_id'
,
'Ειδικότητα'
,
branches
,
''
,
{
'required'
:
''
}
)
}}
{{
macros.select
(
'position'
,
'Θέση'
,
positions
,
''
,
{
'multiple'
:
''
,
'required'
:
''
}
)
}}
{{
macros.checkbox
(
'is_principle'
,
'Διευθυντής'
)
}}
{{
macros.checkbox
(
'is_responsible'
,
'Υπεύθυνος εργαστηρίου'
)
}}
<input
type=
"hidden"
name=
"id"
value=
""
>
</div>
<div
class=
"modal-footer"
>
...
...
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