$totalwithouttax = 0; $totaltax = 0; $totalship = 0; $totaldisc = 0; if (count($orders)) { foreach ($orders as $val) { if ($val['status'] == 'paid') { $totalwithtax = $totalwithtax + $val['grandtotal']; $totalwithouttax = $totalwithouttax + $val['grandtotal'] - $val['tax']; $totaltax = $totaltax + $val['tax']; $totalship = $totalship + $val['shipping']; // $totaldisc = $totaldisc + $val['discount']; } } } $itemsales = $report->getSalesItem($data, $page, $offset); $inventorysold = 0; $inventorycost = 0; if (count($itemsales)) { foreach ($itemsales as $val) { $inventorysold = $inventorysold + $val['qty']; $inventorycost = $inventorycost + $val['total']; // $inventorycostwithouttax = $inventorycostwithouttax + $val['subtoal']; } } $smarty->assign('from', date('M d, Y', strtotime($data['from']))); $smarty->assign('to', date('M d, Y', strtotime($data['to']))); $smarty->assign('orders', $orders); $smarty->assign('totalwithtax', $totalwithtax); $smarty->assign('totalwithouttax', $totalwithouttax); $smarty->assign('totaltax', $totaltax);