From: Iain Patterson Date: Mon, 9 Sep 2013 21:46:16 +0000 (+0100) Subject: Report orders by parcel size. X-Git-Tag: 2013-09-11~1 X-Git-Url: http://git.iain.cx/?p=readifood.git;a=commitdiff_plain;h=ea8e72aabd56f371b4f54b6e464d8bceb049cfb5 Report orders by parcel size. --- 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); }