From 28788e6702987ebe3234e6af29575d595997a324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20H=C3=A4usler?= Date: Fri, 14 Aug 2015 14:16:09 +0200 Subject: [PATCH] put shirt statistics into one table --- includes/pages/admin_active.php | 58 +++++++++++++-------------------- 1 file changed, 22 insertions(+), 36 deletions(-) diff --git a/includes/pages/admin_active.php b/includes/pages/admin_active.php index 78796391..e3fa0996 100644 --- a/includes/pages/admin_active.php +++ b/includes/pages/admin_active.php @@ -145,26 +145,22 @@ function admin_active() { $matched_users[] = $usr; } - - $given_shirt_statistics = sql_select(" - SELECT `Size`, count(`Size`) AS `count` - FROM `User` - WHERE `Tshirt`=1 - GROUP BY `Size` - ORDER BY `Size` DESC"); - $given_shirt_statistics[] = array( - 'Size' => '' . _("Sum") . '', - 'count' => '' . sql_select_single_cell("SELECT count(*) FROM `User` WHERE `Tshirt`=1") . '' - ); - $needed_shirt_statistics = sql_select(" - SELECT `Size`, count(`Size`) AS `count` - FROM `User` - GROUP BY `Size` - ORDER BY `Size` DESC"); - $needed_shirt_statistics[] = array( - 'Size' => '' . _("Sum") . '', - 'count' => '' . sql_select_single_cell("SELECT count(*) FROM `User` WHERE `Tshirt`=1") . '' - ); + + $shirt_statistics = []; + foreach ($tshirt_sizes as $size => $_) { + if ($size != '') { + $shirt_statistics[] = [ + 'size' => $size, + 'needed' => sql_select_single_cell("SELECT count(*) FROM `User` WHERE `Size`='" . sql_escape($size) . "' AND `Gekommen`=1"), + 'given' => sql_select_single_cell("SELECT count(*) FROM `User` WHERE `Size`='" . sql_escape($size) . "' AND `Tshirt`=1") + ]; + } + } + $shirt_statistics[] = [ + 'size' => '' . _("Sum") . '', + 'needed' => '' . User_arrived_count() . '', + 'given' => '' . sql_select_single_cell("SELECT count(*) FROM `User` WHERE `Tshirt`=1") . '' + ]; return page_with_title(admin_active_title(), array( form(array( @@ -187,22 +183,12 @@ function admin_active() { 'tshirt' => _("T-shirt?"), 'actions' => "" ), $matched_users), - div('row', [ - div('col-md-6', [ - '

' . _("Needed shirts") . '

' , - table(array( - 'Size' => _("Size"), - 'count' => _("Count") - ), $needed_shirt_statistics) - ]), - div('col-md-6', [ - '

' . _("Given shirts") . '

', - table(array( - 'Size' => _("Size"), - 'count' => _("Count") - ), $given_shirt_statistics) - ]) - ]) + '

' . _("Shirt statistics") . '

', + table(array( + 'size' => _("Size"), + 'needed' => _("Needed shirts"), + 'given' => _("Given shirts") + ), $shirt_statistics) )); } ?>