Skip to content
Snippets Groups Projects
Commit c3e2e30d authored by Graham Cole's avatar Graham Cole
Browse files

stop things exploding when there's no junk to list

parent 30916180
No related branches found
No related tags found
No related merge requests found
...@@ -136,28 +136,30 @@ if ($mode == 'list'){ ...@@ -136,28 +136,30 @@ if ($mode == 'list'){
else{ else{
$junk = $DB->GetAll("SELECT * FROM inventory WHERE status = 'junk' ORDER BY category, title, id"); $junk = $DB->GetAll("SELECT * FROM inventory WHERE status = 'junk' ORDER BY category, title, id");
} }
//
// 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 // Check there is some junk
if (sizeof($junk) < 1) { if (sizeof($junk) < 1) {
$mode = "nojunk"; $mode = "nojunk";
} else {
// 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);
} }
} else { } else {
$categories = $DB->GetCol("SELECT DISTINCT category FROM inventory ORDER BY category ASC"); $categories = $DB->GetCol("SELECT DISTINCT category FROM inventory ORDER BY category ASC");
$smarty->assign("categories", $categories); $smarty->assign("categories", $categories);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment