From ea8e72aabd56f371b4f54b6e464d8bceb049cfb5 Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Mon, 9 Sep 2013 22:46:16 +0100 Subject: [PATCH] Report orders by parcel size. --- lib/report.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/report.php b/lib/report.php index b268440..05ca904 100644 --- a/lib/report.php +++ b/lib/report.php @@ -102,6 +102,31 @@ echo "\n"; } + function show_size_report(&$order_ids) { + global $parcel_sizes; + echo "

Orders by parcel size

\n"; + + $q = new OrderQuery; + $q->filterById($order_ids); + $q->withColumn(sprintf("parcel & %d", (1 << count($parcel_sizes)) - 1), 'size'); + $q->withColumn('count(*)', 'count'); + $q->addGroupByColumn('size')->addAscendingOrderByColumn('size'); + $rows = $q->find(); + $total = 0; + echo "\n"; + foreach ($rows as $row) { + echo "\n"; + $requester = get_contact_by_id($row->getRequesterId()); + printf(" \n", $row->getCount(), htmlspecialchars($parcel_sizes[$row->getSize() >> 1])); + $total += $row->getCount(); + echo "\n"; + } + echo "\n"; + echo " \n"; + echo "\n"; + echo "
%d%s
$totalTotal
\n"; + } + function show_requester_report(&$order_ids) { echo "

Orders by referrer

\n"; @@ -152,6 +177,7 @@ } show_order_report($order_state_ids); + show_size_report($order_ids); show_requester_report($order_ids); } -- 2.20.1