From 67cabebf35d258223dfb3859e71563d66b663a9b Mon Sep 17 00:00:00 2001 From: friol Date: Thu, 2 Jul 2020 18:58:25 +0200 Subject: [PATCH] Ability to sort prods in the lists page --- lists.php | 57 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/lists.php b/lists.php index e73166f..7d80396 100644 --- a/lists.php +++ b/lists.php @@ -103,6 +103,18 @@ function LoadFromDB() $s->Attach(array("list_items"=>"itemid"),array("prods as prod"=>"id")); $s->AddWhere(sprintf_esc("list_items.list=%d",$this->id)); $s->AddWhere("list_items.type='prod'"); + + $dir = "ASC"; + if ($_GET["reverse"]) + $dir = "DESC"; + switch($_GET["order"]) + { + case "type": $s->AddOrder("list_items_prod.type ".$dir); break; + case "name": $s->AddOrder("list_items_prod.name ".$dir); break; + case "party": $s->AddOrder("list_items_prod_party.name ".$dir); break; + case "release date": $s->AddOrder("list_items_prod_releaseDate ".$dir); break; + } + $this->prods = $s->perform(); $a = array(); @@ -193,29 +205,52 @@ function Render() if ($this->prods) { echo "

prods

"; - echo "