+ $rep->TextCol(0, 1, $account['account_code']);
+ $rep->TextCol(1, 2, $account['account_name']);
+
+ $rep->AmountCol(2, 3, $prev_balance * $convert, $dec);
+ $rep->AmountCol(3, 4, $curr_balance * $convert, $dec);
+ $rep->AmountCol(4, 5, ($prev_balance + $curr_balance) * $convert, $dec);
+
+ $rep->NewLine();
+
+ $code_open_balance += $prev_balance;
+ $code_period_balance += $curr_balance;
+ }
+
+ //Get Account groups/types under this group/type
+ $result = get_account_types(false, false, $type);
+ while ($accounttype=db_fetch($result))
+ {
+ //Print Type Title if has sub types and not previously printed
+ if (!$printtitle)
+ {
+ $printtitle = 1;
+ $rep->row -= 4;
+ $rep->TextCol(0, 5, $typename);
+ $rep->row -= 4;
+ $rep->Line($rep->row);
+ $rep->NewLine();
+ }
+
+ $totals_arr = display_type($accounttype["id"], $accounttype["name"], $from, $to, $convert, $dec,
+ $rep, $dimension, $dimension2, $tags, $pg, $graphics, $labels, $serie1, $serie2);
+ $open_balance_total += $totals_arr[0];
+ $period_balance_total += $totals_arr[1];
+ }
+
+ //Display Type Summary if total is != 0 OR head is printed (Needed in case of unused hierarchical COA)
+ if (($code_open_balance + $open_balance_total + $code_period_balance + $period_balance_total) != 0 || $printtitle)
+ {
+ $rep->row += 6;
+ $rep->Line($rep->row);
+ $rep->NewLine();
+ $rep->TextCol(0, 2, _('Total') . " " . $typename);
+ $rep->AmountCol(2, 3, ($code_open_balance + $open_balance_total) * $convert, $dec);
+ $rep->AmountCol(3, 4, ($code_period_balance + $period_balance_total) * $convert, $dec);
+ $rep->AmountCol(4, 5, ($code_open_balance + $open_balance_total + $code_period_balance + $period_balance_total) * $convert, $dec);
+ if ($graphics)
+ {
+ $labels[] = $typename;
+ $serie1[] = abs(($code_period_balance + $period_balance_total) * $convert);
+ $serie2[] = abs(($code_open_balance + $open_balance_total + $code_period_balance + $period_balance_total) * $convert);
+ }
+ $rep->NewLine();
+ }
+
+ $totals_arr[0] = $code_open_balance + $open_balance_total;
+ $totals_arr[1] = $code_period_balance + $period_balance_total;
+ return $totals_arr;
+}
+
+print_balance_sheet();