public static function getTotalsByRange($from, $to, $limit = 0) { $sr = new SalesReport(); $sr->setFromDate($from); $sr->setToDate($to); $sr->setLimit($limit); $total = 0; $productTotal = 0; $taxTotal = 0; $includedTaxTotal = 0; $shippingTotal = 0; foreach ($sr->getResults() as $order) { $total = $total + $order->getTotal(); $productTotal = $productTotal + $order->getSubTotal(); $taxTotal = $taxTotal + $order->getTaxTotal(); $includedTaxTotal = $includedTaxTotal + $order->getIncludedTaxTotal(); $shippingTotal = $shippingTotal + $order->getShippingTotal(); } $totals = array("total" => $total, "productTotal" => $productTotal, "taxTotal" => $taxTotal, "includedTaxTotal" => $includedTaxTotal, "shippingTotal" => $shippingTotal, "orders" => $sr); return $totals; }
<?php for ($i = 0; $i < 6; $i++) { $report = SalesReport::getByMonth($months[$i]->format('Y-M')); if ($i == 5) { echo "{meta: '" . t('Products') . "', value: " . $report['productTotal'] . "}"; } else { echo "{meta: '" . t('Products') . "', value: " . $report['productTotal'] . "},"; } } ?> ], [ <?php for ($i = 0; $i < 6; $i++) { $report = SalesReport::getByMonth($months[$i]->format('Y-M')); if ($i == 5) { echo "{meta: '" . t('Shipping') . "', value: " . $report['shippingTotal'] . "}"; } else { echo "{meta: '" . t('Shipping') . "', value: " . $report['shippingTotal'] . "},"; } } ?> ] ] }, { axisY: { offset: 80, labelInterpolationFnc: function(value) {