Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
jlopez
wicopa
Commits
ee8ea03d
Commit
ee8ea03d
authored
Apr 29, 2019
by
jlopez
Browse files
Update to 0.4
parent
e896c161
Changes
14
Hide whitespace changes
Inline
Side-by-side
action/action_container.php
View file @
ee8ea03d
...
...
@@ -13,6 +13,8 @@ require_once '../dao/DBquery.php';
$db
=
new
DBquery
();
$today
=
date
(
"Y-m-d G:i:s"
);
$action
=
NULL
;
$id
=
NULL
;
...
...
@@ -22,6 +24,7 @@ $type = NULL;
$visibility
=
"public"
;
$description
=
NULL
;
$author
=
0
;
$labels
=
array
();
if
(
isset
(
$_POST
[
'action'
]))
{
$action
=
$_POST
[
'action'
];
...
...
@@ -65,11 +68,23 @@ if(isset($_POST['description'])) {
$author
=
$_SESSION
[
'username'
];
$container
=
new
Container
(
$id
,
$name
,
$value
,
$type
,
$visibility
,
$description
,
$author
);
if
(
isset
(
$_POST
[
'labels'
]))
{
$labels
=
$_POST
[
'labels'
];
}
$container
=
new
Container
(
$id
,
$name
,
$value
,
$type
,
$visibility
,
$description
,
$author
,
$today
);
if
(
$action
==
"create"
)
{
$container
->
escape
(
$db
);
$db
->
create
(
$container
);
$last_id
=
mysqli_insert_id
(
$db
->
dbh
);
foreach
(
$labels
as
$lid
){
$contlab
=
new
ContainerLabel
(
0
,
$last_id
,
$lid
);
$db
->
create
(
$contlab
);
}
}
else
if
(
$action
==
"update"
)
{
$container
->
escape
(
$db
);
$db
->
update
(
$container
);
...
...
action/action_grade.php
0 → 100644
View file @
ee8ea03d
<?php
define
(
"PATH"
,
".."
);
define
(
"PAGE"
,
"actionGrade"
);
session_start
();
if
(
!
isset
(
$_SESSION
[
'username'
]))
{
header
(
"Location: ../login.php"
);
}
require_once
'../dao/DBquery.php'
;
$db
=
new
DBquery
();
$action
=
NULL
;
$id
=
NULL
;
$name
=
NULL
;
$level
=
NULL
;
if
(
isset
(
$_POST
[
'action'
]))
{
$action
=
$_POST
[
'action'
];
}
else
{
if
(
isset
(
$_GET
[
'action'
]))
{
$action
=
$_GET
[
'action'
];
}
else
{
$action
=
""
;
}
}
if
(
isset
(
$_POST
[
'gradeid'
]))
{
$id
=
$_POST
[
'gradeid'
];
}
else
{
if
(
isset
(
$_GET
[
'gradeid'
]))
{
$id
=
$_GET
[
'gradeid'
];
}
else
{
$id
=
-
1
;
}
}
if
(
isset
(
$_POST
[
'name'
]))
{
$name
=
$_POST
[
'name'
];
}
if
(
isset
(
$_POST
[
'level'
]))
{
$level
=
$_POST
[
'level'
];
}
$grade
=
new
Grade
(
$id
,
$name
,
$level
);
if
(
$action
==
"create"
)
{
$grade
->
escape
(
$db
);
$db
->
create
(
$grade
);
}
else
if
(
$action
==
"update"
)
{
$grade
->
escape
(
$db
);
$db
->
update
(
$grade
);
}
else
if
(
$action
==
"delete"
)
{
$db
->
delete
(
$grade
);
}
header
(
"Location: ../manage.php#grade"
);
action/action_label.php
0 → 100644
View file @
ee8ea03d
<?php
define
(
"PATH"
,
".."
);
define
(
"PAGE"
,
"actionLabel"
);
session_start
();
if
(
!
isset
(
$_SESSION
[
'username'
]))
{
header
(
"Location: ../login.php"
);
}
require_once
'../dao/DBquery.php'
;
$db
=
new
DBquery
();
$action
=
NULL
;
$id
=
NULL
;
$name
=
NULL
;
$color
=
NULL
;
$gradeId
=
NULL
;
if
(
isset
(
$_POST
[
'action'
]))
{
$action
=
$_POST
[
'action'
];
}
else
{
if
(
isset
(
$_GET
[
'action'
]))
{
$action
=
$_GET
[
'action'
];
}
else
{
$action
=
""
;
}
}
if
(
isset
(
$_POST
[
'labelid'
]))
{
$id
=
$_POST
[
'labelid'
];
}
else
{
if
(
isset
(
$_GET
[
'labelid'
]))
{
$id
=
$_GET
[
'labelid'
];
}
else
{
$id
=
-
1
;
}
}
if
(
isset
(
$_POST
[
'name'
]))
{
$name
=
$_POST
[
'name'
];
}
if
(
isset
(
$_POST
[
'color'
]))
{
$color
=
$_POST
[
'color'
];
}
if
(
isset
(
$_POST
[
'gradeId'
]))
{
$gradeId
=
$_POST
[
'gradeId'
];
}
$label
=
new
Label
(
$id
,
$name
,
$color
,
$gradeId
);
if
(
$action
==
"create"
)
{
$label
->
escape
(
$db
);
$db
->
create
(
$label
);
}
else
if
(
$action
==
"update"
)
{
$label
->
escape
(
$db
);
$db
->
update
(
$label
);
}
else
if
(
$action
==
"delete"
)
{
$db
->
delete
(
$label
);
}
header
(
"Location: ../manage.php#label"
);
action/action_user.php
0 → 100644
View file @
ee8ea03d
<?php
define
(
"PATH"
,
".."
);
define
(
"PAGE"
,
"actionUser"
);
session_start
();
if
(
!
isset
(
$_SESSION
[
'username'
]))
{
header
(
"Location: ../login.php"
);
}
require_once
'../dao/DBquery.php'
;
$db
=
new
DBquery
();
$action
=
NULL
;
$id
=
NULL
;
$login
=
NULL
;
$gradeId
=
NULL
;
if
(
isset
(
$_POST
[
'action'
]))
{
$action
=
$_POST
[
'action'
];
}
else
{
if
(
isset
(
$_GET
[
'action'
]))
{
$action
=
$_GET
[
'action'
];
}
else
{
$action
=
""
;
}
}
if
(
isset
(
$_POST
[
'userid'
]))
{
$id
=
$_POST
[
'userid'
];
}
else
{
if
(
isset
(
$_GET
[
'userid'
]))
{
$id
=
$_GET
[
'userid'
];
}
else
{
$id
=
-
1
;
}
}
if
(
isset
(
$_POST
[
'login'
]))
{
$login
=
$_POST
[
'login'
];
}
if
(
isset
(
$_POST
[
'gradeId'
]))
{
$gradeId
=
$_POST
[
'gradeId'
];
}
$user
=
new
User
(
$id
,
$login
,
$gradeId
);
if
(
$action
==
"create"
)
{
$user
->
escape
(
$db
);
$db
->
create
(
$user
);
}
else
if
(
$action
==
"update"
)
{
$user
->
escape
(
$db
);
$db
->
update
(
$user
);
}
else
if
(
$action
==
"delete"
)
{
$db
->
delete
(
$user
);
}
header
(
"Location: ../manage.php#user"
);
container.php
View file @
ee8ea03d
...
...
@@ -83,10 +83,9 @@ $containers = $db->getContainers();
<tr>
<th>
Name
</th>
<th>
Author
</th>
<th>
Type
</th>
<th>
Visibility
</th>
<th>
Description
</th>
<th>
Labels
</th>
<th>
Date
</th>
<th>
Description
</th>
<th>
Action
</th>
</tr>
</thead>
...
...
@@ -95,10 +94,17 @@ $containers = $db->getContainers();
foreach
(
$containers
as
$container
)
{
$container
->
escape2
(
$db
);
$visibility
=
"private"
;
$colorV
=
"e67e22"
;
if
(
$container
->
visibility
)
{
$visibility
=
"public"
;
$colorV
=
"f1c40f"
;
}
if
(
!
$container
->
visibility
)
{
...
...
@@ -107,13 +113,47 @@ $containers = $db->getContainers();
}
}
$typeC
=
"docker"
;
$colorT
=
"007bff"
;
if
(
$container
->
type
==
"Singularity"
)
{
$typeC
=
"singularity"
;
$colorT
=
"28a745"
;
}
echo
'<tr>'
;
echo
'<td>'
.
$container
->
name
.
'</td>'
;
echo
'<td>'
.
$container
->
author
.
'</td>'
;
echo
'<td>'
.
$container
->
type
.
'</td>'
;
echo
'<td>'
.
$visibility
.
'</td>'
;
$labels
=
$db
->
getLabelWithContainerId
(
$container
->
ID
);
echo
'<td>'
;
echo
'<span class="badge" style="background:#'
.
$colorT
.
'">'
.
$typeC
.
'</span>'
;
echo
'<span class="badge" style="background:#'
.
$colorV
.
'">'
.
$visibility
.
'</span>'
;
echo
'<br/>'
;
$index
=
0
;
foreach
(
$labels
as
$label
)
{
echo
'<span class="badge" style="background:#'
.
$label
->
color
.
'">'
.
$label
->
name
.
'</span>'
;
if
(
$index
==
1
)
{
echo
'<br/>'
;
$index
=
0
;
}
else
{
$index
++
;
}
}
echo
'</td>'
;
echo
'<td>'
.
$container
->
date
.
'</td>'
;
echo
'<td>'
.
$container
->
description
.
'</td>'
;
echo
'<td>'
.
""
.
'</td>'
;
echo
'<td>'
;
...
...
css/style.css
View file @
ee8ea03d
...
...
@@ -67,3 +67,7 @@
.custom-checkbox
.custom-control-input
:focus
~
.custom-control-indicator
{
box-shadow
:
none
!important
;
}
.badge
{
margin-right
:
5px
;
}
\ No newline at end of file
dao/DBquery.php
View file @
ee8ea03d
...
...
@@ -12,6 +12,10 @@ require_once(__DIR__.'/../model/Manager.php');
require_once
(
__DIR__
.
'/../model/Distribution.php'
);
require_once
(
__DIR__
.
'/../model/Package.php'
);
require_once
(
__DIR__
.
'/../model/Container.php'
);
require_once
(
__DIR__
.
'/../model/Grade.php'
);
require_once
(
__DIR__
.
'/../model/Label.php'
);
require_once
(
__DIR__
.
'/../model/User.php'
);
require_once
(
__DIR__
.
'/../model/ContainerLabel.php'
);
class
DBquery
{
...
...
@@ -80,23 +84,131 @@ class DBquery
return
$results
;
}
public
function
getUsers
()
{
$sql
=
"SELECT * FROM `User`;"
;
$result
=
mysqli_query
(
$this
->
dbh
,
$sql
);
$results
=
array
();
while
(
$row
=
mysqli_fetch_assoc
(
$result
)){
$u
=
new
User
(
$row
[
'ID'
],
$row
[
'login'
],
$row
[
'gradeId'
]);
array_push
(
$results
,
$u
);
}
return
$results
;
}
public
function
getGradeWithLogin
(
$login
)
{
$sql
=
"SELECT * FROM `User` WHERE `login` = '
$login
';"
;
$result
=
mysqli_query
(
$this
->
dbh
,
$sql
);
while
(
$row
=
mysqli_fetch_assoc
(
$result
)){
$u
=
new
User
(
$row
[
'ID'
],
$row
[
'login'
],
$row
[
'gradeId'
]);
return
$this
->
getGradeWithId
(
$u
->
gradeId
);
}
return
$this
->
getLowerGrades
();
}
public
function
getLabelsWithGrade
(
$grade
)
{
$labels
=
$this
->
getLabels
();
$results
=
array
();
foreach
(
$labels
as
$label
){
$grd
=
$this
->
getGradeWithId
(
$label
->
gradeId
);
if
(
$grd
->
level
>=
$grade
->
level
)
{
array_push
(
$results
,
$label
);
}
}
return
$results
;
}
public
function
getGrades
()
{
$sql
=
"SELECT * FROM `Grade` ORDER BY `level` ASC;"
;
$result
=
mysqli_query
(
$this
->
dbh
,
$sql
);
$results
=
array
();
while
(
$row
=
mysqli_fetch_assoc
(
$result
)){
$m
=
new
Grade
(
$row
[
'ID'
],
$row
[
'name'
],
$row
[
'level'
]);
array_push
(
$results
,
$m
);
}
return
$results
;
}
public
function
getGradeWithId
(
$ID
)
{
$sql
=
"SELECT * FROM `Grade` WHERE `ID` = '
$ID
';"
;
$result
=
mysqli_query
(
$this
->
dbh
,
$sql
);
$results
=
array
();
while
(
$row
=
mysqli_fetch_assoc
(
$result
)){
$m
=
new
Grade
(
$row
[
'ID'
],
$row
[
'name'
],
$row
[
'level'
]);
return
$m
;
}
return
$results
;
}
public
function
getLowerGrades
()
{
$sql
=
"SELECT * FROM `Grade` ORDER BY `level` DESC LIMIT 1;"
;
$result
=
mysqli_query
(
$this
->
dbh
,
$sql
);
$results
=
array
();
while
(
$row
=
mysqli_fetch_assoc
(
$result
)){
$m
=
new
Grade
(
$row
[
'ID'
],
$row
[
'name'
],
$row
[
'level'
]);
array_push
(
$results
,
$m
);
}
return
$results
;
}
public
function
getContainers
()
{
$sql
=
"SELECT * FROM `Container`;"
;
$result
=
mysqli_query
(
$this
->
dbh
,
$sql
);
$results
=
array
();
while
(
$row
=
mysqli_fetch_assoc
(
$result
)){
$cnt
=
new
Container
(
$row
[
'ID'
],
$row
[
'name'
],
$row
[
'value'
],
$row
[
'type'
],
$row
[
'visibility'
],
$row
[
'description'
],
$row
[
'author'
]);
$cnt
=
new
Container
(
$row
[
'ID'
],
$row
[
'name'
],
$row
[
'value'
],
$row
[
'type'
],
$row
[
'visibility'
],
$row
[
'description'
],
$row
[
'author'
]
,
$row
[
'date'
]
);
array_push
(
$results
,
$cnt
);
}
return
$results
;
}
public
function
getLabels
()
{
$sql
=
"SELECT * FROM `Label`;"
;
$result
=
mysqli_query
(
$this
->
dbh
,
$sql
);
$results
=
array
();
while
(
$row
=
mysqli_fetch_assoc
(
$result
)){
$l
=
new
Label
(
$row
[
'ID'
],
$row
[
'name'
],
$row
[
'color'
],
$row
[
'gradeId'
]);
array_push
(
$results
,
$l
);
}
return
$results
;
}
public
function
getLabelsWithId
(
$id
)
{
$sql
=
"SELECT * FROM `Label` WHERE `ID` =
$id
;"
;
$result
=
mysqli_query
(
$this
->
dbh
,
$sql
);
$results
=
array
();
while
(
$row
=
mysqli_fetch_assoc
(
$result
)){
$l
=
new
Label
(
$row
[
'ID'
],
$row
[
'name'
],
$row
[
'color'
],
$row
[
'gradeId'
]);
return
$l
;
}
return
$results
;
}
public
function
getMaxSectionArrangement
()
{
$sql
=
"SELECT MAX(arrangement) FROM `Section` WHERE `Section`.`parent` IS NULL;"
;
}
public
function
getLabelWithContainerId
(
$id
)
{
$sql
=
"SELECT * FROM `ContainerLabel` WHERE `containerId` =
$id
"
;
$result
=
mysqli_query
(
$this
->
dbh
,
$sql
);
$results
=
array
();
while
(
$row
=
mysqli_fetch_assoc
(
$result
)){
$l
=
$this
->
getLabelsWithId
(
$row
[
'labelId'
]);
array_push
(
$results
,
$l
);
}
return
$results
;
}
public
function
getAllActiveSectionParent
()
{
$sql
=
"SELECT * FROM `Section` WHERE `Section`.`parent` IS NULL AND active = 1 ORDER BY `Section`.`arrangement` ASC;"
;
$result
=
mysqli_query
(
$this
->
dbh
,
$sql
);
...
...
@@ -119,8 +231,6 @@ class DBquery
return
$results
;
}
public
function
getSectionWhithParent
(
$parent
)
{
$sql
=
"SELECT * FROM `Section` WHERE `Section`.`parent` = '
$parent
' AND active = 1 ORDER BY `Section`.`arrangement` ASC;"
;
$result
=
mysqli_query
(
$this
->
dbh
,
$sql
);
...
...
index.php
View file @
ee8ea03d
...
...
@@ -31,6 +31,10 @@ $data_section = $db->getActiveSection();
$section
=
array
();
$section_visual
=
array
();
$grade
=
$db
->
getGradeWithLogin
(
$_SESSION
[
'username'
]);
$labels
=
$db
->
getLabelsWithGrade
(
$grade
);
foreach
(
$db
->
getAllActiveSectionParent
()
as
$s
){
if
(
$s
->
active
==
1
)
{
array_push
(
$section
,
$s
->
name
);
...
...
@@ -430,7 +434,17 @@ function printPanel($name) {
<label
for=
"descriptionContainer"
>
Description :
</label>
<textarea
class=
"form-control"
rows=
"5"
id=
"descriptionContainer"
maxlength=
"500"
name =
"description"
required
></textarea>
</div>
<div
class=
"form-group"
>
<label
for=
"labelsContainer"
>
Labels :
</label>
<select
class=
"form-control"
id=
"labelsContainer"
name=
"labels[]"
multiple
>
<?php
foreach
(
$labels
as
$label
){
echo
'<option value="'
.
$label
->
ID
.
'">'
.
$label
->
name
.
'</option>'
;
}
?>
</select>
</div>
</div>
...
...
manage.php
View file @
ee8ea03d
...
...
@@ -23,6 +23,12 @@ $distribs = $db->getDistributions();
$managers
=
$db
->
getManagers
();
$grades
=
$db
->
getGrades
();
$labels
=
$db
->
getLabels
();
$users
=
$db
->
getUsers
();
$max_arrangement
=
0
;
foreach
(
$sections_parent
as
$section
)
{
...
...
@@ -32,6 +38,15 @@ foreach ($sections_parent as $section) {
}
}
$max_grade
=
0
;
foreach
(
$grades
as
$grade
)
{
if
(
$grade
->
level
>
$max_grade
)
{
$max_grade
=
$grade
->
level
;
}
}
?>
<!doctype html>
...
...
@@ -373,7 +388,7 @@ foreach ($sections_parent as $section) {
<th>
Name
</th>
<th>
Value
</th>
<th>
Updat
e
</th>
<th>
Sav
e
</th>
<th>
Delete
</th>
</tr>
</thead>
...
...
@@ -388,7 +403,7 @@ foreach ($sections_parent as $section) {
<input type="text" style="display: none;" name="managerid" value="'
.
$manager
->
ID
.
'">
<input class="form-control" type="text" name="name" value="'
.
$manager
->
name
.
'">'
.
'</td>'
;
echo
'<td>'
.
'<input class="form-control" type="text" name="value" value="'
.
$manager
->
value
.
'">'
.
'</td>'
;
echo
'<td>'
.
'<button type="submit" class="btn btn-
warning
btn-sm" >
updat
e</button>'
.
'</td>'
;
echo
'<td>'
.
'<button type="submit" class="btn btn-
info
btn-sm" >
sav
e</button>'
.
'</td>'
;
echo
'<td>'
.
'<a class="btn btn-danger btn-sm" href="./action/action_manager.php?action=delete&managerid='
.
$manager
->
ID
.
'" >x</a>'
.
'</td>'
;
echo
'</tr></form>'
;
}
...
...
@@ -432,6 +447,279 @@ foreach ($sections_parent as $section) {
</div>
</div>
<br/>
<div
class=
"row"
>
<div
class=
"col-12"
>
<div
class=
"card border border-dark"
>
<div
class=
"card-header bg-dark text-light"
id=
"grade"
>
Manage Grade :
</div>
<div
class=
"card-body"
>
<table
id=
"Table_Distrib"
class=
"table table-striped table-bordered"
>
<thead>
<tr>
<th>
Name
</th>
<th>
Level
</th>
<th>
Save
</th>
<th>
Delete
</th>
</tr>
</thead>
<tbody
id=
"TableSection"
>
<?php
foreach
(
$grades
as
$grade
)
{
echo
'<form action="./action/action_grade.php" method="post"><tr>'
;
echo
'<td>'
.
'
<input type="text" class="form-control" style="display: none;" placeholder="action" name="action" value="update">
<input type="text" style="display: none;" name="gradeid" value="'
.
$grade
->
ID
.
'">
<input class="form-control" type="text" name="name" value="'
.
$grade
->
name
.
'">'
.
'</td>'
;
echo
'<td>'
.
'<input class="form-control" type="text" name="level" value="'
.
$grade
->
level
.
'">'
.
'</td>'
;
echo
'<td>'
.
'<button type="submit" class="btn btn-info btn-sm" >save</button>'
.
'</td>'
;
echo
'<td>'
.
'<a class="btn btn-danger btn-sm" href="./action/action_grade.php?action=delete&gradeid='
.
$grade
->
ID
.
'" >x</a>'
.
'</td>'
;
echo
'</tr></form>'
;
}
?>
</tbody>
</table>
<!-- <button type="button" class="btn btn-primary" >Save change</button> -->
<br/>
<br/>
<br/>
<br/>
<form
action=
"./action/action_grade.php"
method=
"post"
>
<div
class=
"row"
>
<input
type=
"text"
class=
"form-control"
style=
"display: none;"
placeholder=
"action"
name=
"action"
value=
"create"
>
<div
class=
"col-2"
>
<label
for=
"nameGrade"
>
Name :
</label>
<input
type=
"text"
class=
"form-control"
id=
"nameGrade"
name=
"name"
>
</div>
<div
class=
"col-2"
>
<label
for=
"levelManager"
>
Level :
</label>
<input
type=
"number"
class=
"form-control"
id=
"levelManager"
name=
"level"
value=
"
<?php
echo
$max_grade
+
1
;
?>
"
>
</div>
<div
class=
"col-12"
>
<br/>
<button
type=
"submit"
class=
"btn btn-success"
>
Create
</button>
</div>