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
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
George Henry Woolley
sucs-site
Commits
bb3f4d46
Commit
bb3f4d46
authored
16 years ago
by
Graham Cole
Browse files
Options
Downloads
Patches
Plain Diff
allow junk item categories to be selected from a drop-down list
parent
132df0ed
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
+14
-3
14 additions, 3 deletions
components/junk.php
templates/junk.tpl
+14
-3
14 additions, 3 deletions
templates/junk.tpl
with
28 additions
and
6 deletions
components/junk.php
+
14
−
3
View file @
bb3f4d46
...
...
@@ -82,8 +82,16 @@ if ($session->loggedin && isset($_REQUEST['action'])) {
}
// Update/Add item
if
(
$session
->
loggedin
&&
$admin
&&
(
isset
(
$_REQUEST
[
'update'
])
||
isset
(
$_REQUEST
[
'add'
])))
{
// try to guess which category field the user meant us to see
// ideally we'd use an html combo box, but since they don't exist...
if
(
$_REQUEST
[
'categorymenu'
]
==
""
)
{
$category
=
$_REQUEST
[
'category'
];
}
else
{
$category
=
$_REQUEST
[
'categorymenu'
];
}
// Update/Add item if title and category are filled in else error
if
(
$_REQUEST
[
'title'
]
!=
""
&&
$
_REQUEST
[
'
category
'
]
!=
""
)
{
if
(
$_REQUEST
[
'title'
]
!=
""
&&
$category
!=
""
)
{
// if the description is blank, return null
if
(
$_REQUEST
[
'description'
]
==
""
){
$description
=
null
;
...
...
@@ -101,12 +109,12 @@ if ($session->loggedin && $admin && (isset($_REQUEST['update']) || isset($_REQUE
// run the query
if
(
isset
(
$_REQUEST
[
'update'
])){
$query
=
"UPDATE inventory SET title=?, category=?, description=?, donated_by=?, status=? WHERE id=?"
;
$array
=
array
(
$_REQUEST
[
'title'
],
$
_REQUEST
[
'
category
'
]
,
$description
,
$donated_by
,
$_REQUEST
[
'status'
],
$_REQUEST
[
'id'
]);
$array
=
array
(
$_REQUEST
[
'title'
],
$category
,
$description
,
$donated_by
,
$_REQUEST
[
'status'
],
$_REQUEST
[
'id'
]);
message_flash
(
"Item Updated"
);
}
elseif
(
isset
(
$_REQUEST
[
'add'
])){
$query
=
"INSERT INTO inventory (title, category, description, donated_by, status) VALUES (?, ?, ?, ?, ?)"
;
$array
=
array
(
$_REQUEST
[
'title'
],
$
_REQUEST
[
'
category
'
]
,
$description
,
$donated_by
,
$_REQUEST
[
'status'
]);
$array
=
array
(
$_REQUEST
[
'title'
],
$category
,
$description
,
$donated_by
,
$_REQUEST
[
'status'
]);
message_flash
(
"Item Added"
);
}
$DB
->
Query
(
$query
,
$array
);
...
...
@@ -150,6 +158,9 @@ if ($mode == 'list'){
if
(
sizeof
(
$junk
)
<
1
)
{
$mode
=
"nojunk"
;
}
}
else
{
$categories
=
$DB
->
GetCol
(
"SELECT DISTINCT category FROM inventory ORDER BY category ASC"
);
$smarty
->
assign
(
"categories"
,
$categories
);
}
// Generate output
...
...
This diff is collapsed.
Click to expand it.
templates/junk.tpl
+
14
−
3
View file @
bb3f4d46
...
...
@@ -10,7 +10,7 @@
<li>
<strong>
{
$item.title
}
:
</strong>
{
$item.description
}
{
if
$item.donated_by
!=
null
}
<br
/><s
trong
>
Donated by
:
</strong>
{
$item.donated_by
}
<br
/><s
mall
>
Donated by
{
$item.donated_by
}
</small>
{/
if
}
{
if
$status
==
'requested'
}
<br
/><small>
Requested by
{
$item.requested_by
}
on
{
$item.requested_on
|
date_format
:
"%e %b %Y"
}
</small>
...
...
@@ -73,7 +73,18 @@
</div>
<div
class=
"row"
>
<label
for=
"category"
>
Category*
</label>
<span
class=
"textinput"
><input
type=
"text"
name=
"category"
{
if
$mode
==
'edit'
}
value=
"
{
$item.category
}
"
{/
if
}
/></span>
<span
class=
"textinput"
>
<select
name=
"categorymenu"
>
<option
value=
""
>
Other...
</option>
{
foreach
name
=
categories
from
=
$categories
item
=
category
}
<option
{
if
(
$category
==
$item.category
)
&&
(
$mode
==
'edit'
)
}
selected=
"selected"
{/
if
}
>
{
$category
}
</option>
{/
foreach
}
</select>
</span>
<span
class=
"textinput"
>
<div
class=
"note"
>
If none of the existing categories apply, enter one below:
</div>
<input
type=
"text"
name=
"category"
/>
</span>
</div>
<div
class=
"row"
>
<label
for=
"description"
>
Description
</label>
...
...
@@ -97,7 +108,7 @@
</div>
<div
class=
"row"
>
<span
class=
"textinput"
><input
type=
"submit"
name=
"
{
if
$mode
==
'edit'
}
update
{
else
}
add
{/
if
}
"
value=
"
{
if
$mode
==
'edit'
}
Update
{
else
}
Add
{/
if
}
"
/></span>
<div
class=
"note row"
>
* denotes require fields
</div>
<div
class=
"note row"
>
* denotes require
d
fields
</div>
</div>
<div
class=
"clear"
></div>
</form>
...
...
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