Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sucs-site
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexander Moras
sucs-site
Commits
59b2fb69
Commit
59b2fb69
authored
16 years ago
by
Graham Cole
Browse files
Options
Downloads
Patches
Plain Diff
rough attempt at cleaning up the junk interface. Needs a bit more work
parent
ff6ccef3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
components/junk.php
+25
-9
25 additions, 9 deletions
components/junk.php
templates/junk.tpl
+46
-47
46 additions, 47 deletions
templates/junk.tpl
with
71 additions
and
56 deletions
components/junk.php
+
25
−
9
View file @
59b2fb69
...
...
@@ -8,7 +8,7 @@ $admin_group="staff";
$admin
=
isset
(
$session
->
groups
[
$admin_group
]);
// If you
r
an admin and the path ends in Edit/ then a number put it into edit mode
// If you
're
an admin and the path ends in Edit/ then a number put it into edit mode
// create canedit rules
$canedit
=
isset
(
$pathlist
[(
$component
[
depth
]
/
2
)
+
1
]);
$canedit
=
$canedit
&&
isset
(
$pathlist
[(
$component
[
depth
]
/
2
)
+
2
]);
...
...
@@ -26,7 +26,7 @@ if ($canedit){
}
}
// If you
r
an admin and the path ends in Add put it into add mode
// If you
're
an admin and the path ends in Add put it into add mode
// create canadd rules
$canadd
=
isset
(
$pathlist
[(
$component
[
depth
]
/
2
)
+
1
]);
$canadd
=
$canadd
&&
$pathlist
[(
$component
[
depth
]
/
2
)
+
1
]
==
'Add'
;
...
...
@@ -35,7 +35,7 @@ $canadd=$canadd && $admin;
if
(
$canadd
){
$mode
=
"add"
;}
// Process actions before retriving the data
// Process actions before retri
e
ving the data
// List request data
if
(
$session
->
loggedin
&&
isset
(
$_REQUEST
[
'action'
]))
{
// Junk Requests
...
...
@@ -47,7 +47,7 @@ if ($session->loggedin && isset($_REQUEST['action'])) {
elseif
(
$_REQUEST
[
'action'
]
==
"Un-Request"
)
{
// Un-Request Item
if
(
$admin
){
// if you
r
admin just do it
// if you
're
admin just do it
$query
=
"UPDATE inventory SET requested_by=null, requested_on=null WHERE id=?"
;
$array
=
array
(
$_REQUEST
[
'item'
]);
}
...
...
@@ -59,22 +59,22 @@ if ($session->loggedin && isset($_REQUEST['action'])) {
$DB
->
Query
(
$query
,
$array
);
}
elseif
(
$_REQUEST
[
'action'
]
==
"Take"
&&
$admin
){
// Take item, if you
r
admin
// Take item, if you
're
admin
$query
=
"UPDATE inventory SET taken_on=now() WHERE id=? AND requested_by IS NOT NULL"
;
$DB
->
Query
(
$query
,
$_REQUEST
[
'item'
]);
}
elseif
(
$_REQUEST
[
'action'
]
==
"Remove"
&&
$admin
){
// Remove item, if you
r
admin and its been taken
// Remove item, if you
're
admin and its been taken
$query
=
"DELETE FROM inventory WHERE id=? AND taken_on IS NOT NULL"
;
$DB
->
Query
(
$query
,
$_REQUEST
[
'item'
]);
}
elseif
(
$_REQUEST
[
'action'
]
==
"Not Junk"
&&
$admin
){
// Mark item as not junk if its not been requested and you
r
admin
// Mark item as not junk if it
'
s not been requested and you
're
admin
$query
=
"UPDATE inventory SET status='unknown' WHERE id=? AND requested_by IS NULL"
;
$DB
->
Query
(
$query
,
$_REQUEST
[
'item'
]);
}
elseif
(
$_REQUEST
[
'action'
]
==
"Junk"
&&
$admin
){
// Mark item as junk, if you
r
admin
// Mark item as junk, if you
're
admin
$query
=
"UPDATE inventory SET status='junk' WHERE id=?"
;
$DB
->
Query
(
$query
,
$_REQUEST
[
'item'
]);
}
...
...
@@ -125,7 +125,23 @@ if ($mode == 'list'){
else
{
$junk
=
$DB
->
GetAll
(
"SELECT * FROM inventory WHERE status = 'junk' ORDER BY category, title, id"
);
}
$smarty
->
assign
(
"junk"
,
$junk
);
// group the junk by status then by category
foreach
(
$junk
as
$junkitem
)
{
if
(
$junkitem
[
'status'
]
!=
'junk'
)
{
$status
=
"unknown"
;
}
else
if
(
$junkitem
[
'requested_by'
]
==
null
)
{
$status
=
"available"
;
}
else
if
(
$junkitem
[
'taken_on'
]
==
null
)
{
$status
=
"requested"
;
}
else
{
$status
=
"taken"
;
}
$sortedjunk
[
$status
][
$junkitem
[
'category'
]][]
=
$junkitem
;
}
$smarty
->
assign
(
"junk"
,
$sortedjunk
);
// Check there is some junk
if
(
sizeof
(
$junk
)
<
1
)
{
...
...
This diff is collapsed.
Click to expand it.
templates/junk.tpl
+
46
−
47
View file @
59b2fb69
{
if
$mode
==
'list'
}
{
foreach
name
=
junk
from
=
$junk
item
=
junk
}
<div
class=
"box"
>
<div
class=
"boxhead"
>
<h3>
{
$junk.title
}
</h3>
</div>
{
foreach
name
=
junk
from
=
$junk
key
=
status
item
=
statusitems
}
<div
class=
"box"
>
<div
class=
"boxhead"
>
<h3>
{
$status
}
</h3></div>
<div
class=
"boxcontent"
>
<p>
<h3>
{
$junk.category
}
</h3>
{
$junk.description
}
{
if
$junk.donated_by
!=
null
}
<br
/><strong>
Donated by:
</strong>
{
$junk.donated_by
}
{
foreach
from
=
$statusitems
item
=
category
key
=
categoryname
}
<h3>
{
$categoryname
}
s
</h3>
<ul>
{
foreach
from
=
$category
item
=
item
}
<li>
{
$item.title
}
:
{
$item.description
}
{
if
$status
==
'requested'
}
<br
/><small>
Requested by
{
$item.requested_by
}
on
{
$item.requested_on
|
date_format
:
"%e %b %Y"
}
</small>
{
elseif
$status
==
"taken"
}
<br
/><small>
Taken by
{
$item.requested_by
}
on
{
$item.taken_on
|
date_format
:
"%e %b %Y"
}
</small>
{/
if
}
{
if
$item.donated_by
!=
null
}
<br
/><strong>
Donated by:
</strong>
{
$item.donated_by
}
{/
if
}
{
if
$session
->
loggedin
}
{
if
$admin
||
$junk.status
==
'junk'
}
<form
action=
"
{
$url
}
"
method=
"POST"
>
<input
type=
"hidden"
name=
"item"
value=
"
{
$junk.id
}
"
/>
{
if
$junk.status
==
'junk'
}
{
if
$junk.requested_by
==
null
}
<input
type=
"submit"
name=
"action"
value=
"Request"
/>
{
elseif
(
$junk.requested_by
==
$session
->
username
||
$admin
)
&&
$junk.taken_on
==
null
}
<input
type=
"submit"
name=
"action"
value=
"Un-Request"
/>
{/
if
}
{
if
$admin
}
{
if
$junk.requested_by
!=
null
&&
$junk.taken_on
==
null
}
<input
type=
"submit"
name=
"action"
value=
"Take"
/>
{
elseif
$junk.taken_on
!=
null
}
<input
type=
"submit"
name=
"action"
value=
"Remove"
/>
{
elseif
$junk.requested_by
==
null
}
<input
type=
"submit"
name=
"action"
value=
"Not Junk"
/>
{/
if
}
{
if
$admin
||
$item.status
==
'junk'
}
<form
action=
"
{
$url
}
"
method=
"POST"
>
<input
type=
"hidden"
name=
"item"
value=
"
{
$item.id
}
"
/>
{
if
$item.status
==
'junk'
}
{
if
$item.requested_by
==
null
}
<input
type=
"submit"
name=
"action"
value=
"Request"
/>
{
elseif
(
$item.requested_by
==
$session
->
username
||
$admin
)
&&
$item.taken_on
==
null
}
<input
type=
"submit"
name=
"action"
value=
"Un-Request"
/>
{/
if
}
{
if
$admin
}
{
if
$item.requested_by
!=
null
&&
$item.taken_on
==
null
}
<input
type=
"submit"
name=
"action"
value=
"Take"
/>
{
elseif
$item.taken_on
!=
null
}
<input
type=
"submit"
name=
"action"
value=
"Remove"
/>
{
elseif
$item.requested_by
==
null
}
<input
type=
"submit"
name=
"action"
value=
"Not Junk"
/>
{/
if
}
{/
if
}
{
elseif
$admin
}
<input
type=
"submit"
name=
"action"
value=
"Junk"
/>
{/
if
}
</form>
{/
if
}
{
elseif
$admin
}
<input
type=
"submit"
name=
"action"
value=
"Junk"
/>
{/
if
}
</form>
{/
if
}
{/
if
}
</
p
>
{
if
$admin
&&
$
junk
.requested_by
==
null
}
</
li
>
{
if
$admin
&&
$
item
.requested_by
==
null
}
<div
class=
"edit"
>
<a
href=
"
{
$componentpath
}
/Edit/
{
$
junk
.id
}
"
>
Edit
</a>
<a
href=
"
{
$componentpath
}
/Edit/
{
$
item
.id
}
"
>
Edit
</a>
<div
class=
"clear"
></div>
</div>
{/
if
}
{/
foreach
}
</ul>
{/
foreach
}
</div>
<div
class=
"boxfoot"
><p>
{
if
$junk.status
!=
'junk'
}
Not Junk
{
elseif
$junk.requested_by
==
null
}
Available
{
elseif
$junk.taken_on
==
null
}
Requested by
{
$junk.requested_by
}
on
{
$junk.requested_on
|
date_format
:
"%e %b %Y"
}
{
else
}
Taken by
{
$junk.requested_by
}
on
{
$junk.taken_on
|
date_format
:
"%e %b %Y"
}
{/
if
}
</p></div>
</div>
<div
class=
"hollowfoot"
><div><div></div></div></div>
</div>
{/
foreach
}
{
if
$admin
}
<div
class=
"edit"
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment