- $res = getTransactions($category, $location, $date);
- $total = $grandtotal = 0.0;
- $catt = '';
- while ($trans=db_fetch($res))
- {
- if ($catt != $trans['cat_description'])
- {
- if ($catt != '')
- {
- if ($detail)
- {
- $rep->NewLine(2, 3);
- $rep->TextCol(0, 4, _('Total'));
- }
- $rep->AmountCol(5, 6, $total, $dec);
- if ($detail)
- {
- $rep->Line($rep->row - 2);
- $rep->NewLine();
- }
- $rep->NewLine();
- $total = 0.0;
- }
- $rep->TextCol(0, 1, $trans['category_id']);
- $rep->TextCol(1, 2, $trans['cat_description']);
- $catt = $trans['cat_description'];
- if ($detail)
- $rep->NewLine();
- }
- if (isset($use_costed_values) && $use_costed_values==1)
- {
- $UnitCost = getAverageCost($trans['stock_id'], $location, $date);
- $ItemTotal = $trans['QtyOnHand'] * $UnitCost;
- }
- else
- {
- $UnitCost = $trans['UnitCost'];
- $ItemTotal = $trans['ItemTotal'];
- }
- if ($detail)
- {
- $rep->NewLine();
- $rep->fontSize -= 2;
- $rep->TextCol(0, 1, $trans['stock_id']);
- $rep->TextCol(1, 2, $trans['description'].($trans['inactive']==1 ? " ("._("Inactive").")" : ""), -1);
- $rep->TextCol(2, 3, $trans['units']);
- $rep->AmountCol(3, 4, $trans['QtyOnHand'], get_qty_dec($trans['stock_id']));
- $dec2 = 0;
- price_decimal_format($UnitCost, $dec2);
- $rep->AmountCol(4, 5, $UnitCost, $dec2);
- $rep->AmountCol(5, 6, $ItemTotal, $dec);
- $rep->fontSize += 2;
- }
- $total += $ItemTotal;
- $grandtotal += $ItemTotal;
- }
- if ($detail)
- {
- $rep->NewLine(2, 3);
- $rep->TextCol(0, 4, _('Total'));
- }
- $rep->Amountcol(5, 6, $total, $dec);
- if ($detail)
- {
- $rep->Line($rep->row - 2);
- $rep->NewLine();
- }
- $rep->NewLine(2, 1);
- $rep->TextCol(0, 4, _('Grand Total'));
- $rep->AmountCol(5, 6, $grandtotal, $dec);
- $rep->Line($rep->row - 4);
- $rep->NewLine();
+
+ $res = getTransactions($category, $location, $date);
+ $total = $grandtotal = 0.0;
+ $catt = '';
+ while ($trans=db_fetch($res))
+ {
+ if ($catt != $trans['cat_description'])
+ {
+ if ($catt != '')
+ {
+ if ($detail)
+ {
+ $rep->NewLine(2, 3);
+ $rep->TextCol(0, 4, _('Total'));
+ }
+ $rep->AmountCol(5, 6, $total, $dec);
+ if ($detail)
+ {
+ $rep->Line($rep->row - 2);
+ $rep->NewLine();
+ }
+ $rep->NewLine();
+ $total = 0.0;
+ }
+ $rep->TextCol(0, 1, $trans['category_id']);
+ $rep->TextCol(1, 2, $trans['cat_description']);
+ $catt = $trans['cat_description'];
+ if ($detail)
+ $rep->NewLine();
+ }
+ if (isset($SysPrefs->use_costed_values) && $SysPrefs->use_costed_values==1)
+ {
+ $UnitCost = getAverageCost($trans['stock_id'], $location, $date);
+ $ItemTotal = $trans['QtyOnHand'] * $UnitCost;
+ }
+ else
+ {
+ $UnitCost = $trans['UnitCost'];
+ $ItemTotal = $trans['ItemTotal'];
+ }
+ if ($detail)
+ {
+ $rep->NewLine();
+ $rep->fontSize -= 2;
+ $rep->TextCol(0, 1, $trans['stock_id']);
+ $rep->TextCol(1, 2, $trans['description'].($trans['inactive']==1 ? " ("._("Inactive").")" : ""), -1);
+ $rep->TextCol(2, 3, $trans['units']);
+ $rep->AmountCol(3, 4, $trans['QtyOnHand'], get_qty_dec($trans['stock_id']));
+
+ $dec2 = 0;
+ price_decimal_format($UnitCost, $dec2);
+ $rep->AmountCol(4, 5, $UnitCost, $dec2);
+ $rep->AmountCol(5, 6, $ItemTotal, $dec);
+ $rep->fontSize += 2;
+ }
+ $total += $ItemTotal;
+ $grandtotal += $ItemTotal;
+ }
+ if ($detail)
+ {
+ $rep->NewLine(2, 3);
+ $rep->TextCol(0, 4, _('Total'));
+ }
+ $rep->Amountcol(5, 6, $total, $dec);
+ if ($detail)
+ {
+ $rep->Line($rep->row - 2);
+ $rep->NewLine();
+ }
+ $rep->NewLine(2, 1);
+ $rep->TextCol(0, 4, _('Grand Total'));
+ $rep->AmountCol(5, 6, $grandtotal, $dec);
+ $rep->Line($rep->row - 4);
+ $rep->NewLine();