function print_list_of_journal_entries() { global $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $from = $_REQUEST['PARAM_0']; $to = $_REQUEST['PARAM_1']; $systype = $_REQUEST['PARAM_2']; $comments = $_REQUEST['PARAM_3']; $dec = user_price_dec(); $cols = array(0, 100, 240, 300, 400, 460, 520, 580); $headers = array(tr('Type/Account'), tr('Account Name'), tr('Date/Dim.'), tr('Person/Item/Memo'), tr('Debit'), tr('Credit')); $aligns = array('left', 'left', 'left', 'left', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Type'), 'from' => systypes::name($systype), 'to' => '')); $rep = new FrontReport(tr('List of Journal Entries'), "JournalEntries.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); if ($systype == -1) { $systype = null; } $trans = get_gl_transactions($from, $to, -1, null, 0, $systype); $typeno = 0; while ($myrow = db_fetch($trans)) { if ($typeno != $myrow['type_no']) { if ($typeno != 0) { $rep->Line($rep->row + 4); $rep->NewLine(); } $typeno = $myrow['type_no']; $TransName = systypes::name($myrow['type']); $rep->TextCol(0, 2, $TransName . " # " . $myrow['type_no']); $rep->TextCol(2, 3, sql2date($myrow['tran_date'])); $coms = payment_person_types::person_name($myrow["person_type_id"], $myrow["person_id"]); $memo = get_comments_string($myrow['type'], $myrow['type_no']); if ($memo != '') { $coms .= $coms != "" ? "/" : "" . $memo; } $rep->TextCol(3, 6, $coms); $rep->NewLine(2); } $rep->TextCol(0, 1, $myrow['account']); $rep->TextCol(1, 2, $myrow['account_name']); $dim_str = get_dimension_string($myrow['dimension_id']); $dim_str2 = get_dimension_string($myrow['dimension2_id']); if ($dim_str2 != "") { $dim_str .= "/" . $dim_str2; } $rep->TextCol(2, 3, $dim_str); $rep->TextCol(3, 4, $myrow['memo_']); if ($myrow['amount'] > 0.0) { $rep->TextCol(4, 5, number_format2(abs($myrow['amount']), $dec)); } else { $rep->TextCol(5, 6, number_format2(abs($myrow['amount']), $dec)); } $rep->NewLine(1, 2); } $rep->Line($rep->row + 4); $rep->End(); }
function print_dimension_summary() { global $path_to_root; $fromdim = $_POST['PARAM_0']; $todim = $_POST['PARAM_1']; $showbal = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; $orientation = $_POST['PARAM_4']; $destination = $_POST['PARAM_5']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; $cols = array(0, 50, 210, 250, 320, 395, 465, 515); $headers = array(_('Reference'), _('Name'), _('Type'), _('Date'), _('Due Date'), _('Closed'), _('YTD')); $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'right'); $params = array(0 => $comments, 1 => array('text' => _('Dimension'), 'from' => get_dimension_string($fromdim), 'to' => get_dimension_string($todim))); $rep = new FrontReport(_('Dimension Summary'), "DimensionSummary", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $res = getTransactions($fromdim, $todim); while ($trans = db_fetch($res)) { $rep->TextCol(0, 1, $trans['reference']); $rep->TextCol(1, 2, $trans['name']); $rep->TextCol(2, 3, $trans['type_']); $rep->DateCol(3, 4, $trans['date_'], true); $rep->DateCol(4, 5, $trans['due_date'], true); if ($trans['closed']) { $str = _('Yes'); } else { $str = _('No'); } $rep->TextCol(5, 6, $str); if ($showbal) { $balance = getYTD($trans['id']); $rep->AmountCol(6, 7, $balance, 0); } $rep->NewLine(1, 2); } $rep->Line($rep->row); $rep->End(); }
function print_profit_and_loss_statement() { global $comp_path, $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; $from = $_REQUEST['PARAM_0']; $to = $_REQUEST['PARAM_1']; $compare = $_REQUEST['PARAM_2']; if ($dim == 2) { $dimension = $_REQUEST['PARAM_3']; $dimension2 = $_REQUEST['PARAM_4']; $graphics = $_REQUEST['PARAM_5']; $comments = $_REQUEST['PARAM_6']; } else { if ($dim == 1) { $dimension = $_REQUEST['PARAM_3']; $graphics = $_REQUEST['PARAM_4']; $comments = $_REQUEST['PARAM_5']; } else { $graphics = $_REQUEST['PARAM_3']; $comments = $_REQUEST['PARAM_4']; } } if ($graphics) { include_once $path_to_root . "reporting/includes/class.graphic.inc"; $pg = new graph(); } $dec = 0; $pdec = user_percent_dec(); $cols = array(0, 50, 200, 350, 425, 500); //------------0--1---2----3----4----5-- $headers = array(tr('Account'), tr('Account Name'), tr('Period'), tr('Accumulated'), tr('Achieved %')); $aligns = array('left', 'left', 'right', 'right', 'right'); if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => tr('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to)); } } if ($compare == 0 || $compare == 2) { $end = $to; if ($compare == 2) { $begin = $from; $headers[3] = tr('Budget'); } else { $begin = begin_fiscalyear(); } } elseif ($compare == 1) { $begin = add_months($from, -12); $end = add_months($to, -12); $headers[3] = tr('Period Y-1'); } $rep = new FrontReport(tr('Profit and Loss Statement'), "ProfitAndLoss.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $classname = ''; $group = ''; $totalper = 0.0; $totalacc = 0.0; $classper = 0.0; $classacc = 0.0; $salesper = 0.0; $salesacc = 0.0; $accounts = get_gl_accounts_all(0); while ($account = db_fetch($accounts)) { $per_balance = get_gl_trans_from_to($from, $to, $account["account_code"], $dimension, $dimension2); if ($compare == 2) { $acc_balance = get_budget_trans_from_to($begin, $end, $account["account_code"], $dimension, $dimension2); } else { $acc_balance = get_gl_trans_from_to($begin, $end, $account["account_code"], $dimension, $dimension2); } if (!$per_balance && !$acc_balance) { continue; } if ($account['AccountClassName'] != $classname) { if ($classname != '') { $closeclass = true; } } if ($account['AccountTypeName'] != $group) { if ($group != '') { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->TextCol(0, 2, tr('Total') . " " . $group); $rep->TextCol(2, 3, number_format2($totalper, $dec)); $rep->TextCol(3, 4, number_format2($totalacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($totalper, $totalacc), $pdec)); if ($graphics) { $pg->x[] = $group; $pg->y[] = abs($totalper); $pg->z[] = abs($totalacc); } $totalper = $totalacc = 0.0; $rep->row -= $rep->lineHeight + 4; if ($closeclass) { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->Font('bold'); $rep->TextCol(0, 2, tr('Total') . " " . $classname); $rep->TextCol(2, 3, number_format2($classper, $dec)); $rep->TextCol(3, 4, number_format2($classacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($classper, $classacc), $pdec)); $rep->Font(); $salesper += $classper; $salesacc += $classacc; $classper = $classacc = 0.0; $rep->NewLine(3); $closeclass = false; } } if ($account['AccountClassName'] != $classname) { $rep->Font('bold'); $rep->TextCol(0, 5, $account['AccountClassName']); $rep->Font(); $rep->row -= $rep->lineHeight + 4; } $group = $account['AccountTypeName']; $rep->TextCol(0, 5, $account['AccountTypeName']); $rep->Line($rep->row - 4); $rep->row -= $rep->lineHeight + 4; } $classname = $account['AccountClassName']; $per_balance *= -1; $acc_balance *= -1; $totalper += $per_balance; $totalacc += $acc_balance; $classper += $per_balance; $classacc += $acc_balance; $rep->TextCol(0, 1, $account['account_code']); $rep->TextCol(1, 2, $account['account_name']); $rep->TextCol(2, 3, number_format2($per_balance, $dec)); $rep->TextCol(3, 4, number_format2($acc_balance, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($per_balance, $acc_balance), $pdec)); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->Header(); } } if ($account['AccountClassName'] != $classname) { if ($classname != '') { $closeclass = true; } } if ($account['AccountTypeName'] != $group) { if ($group != '') { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->TextCol(0, 2, tr('Total') . " " . $group); $rep->TextCol(2, 3, number_format2($totalper, $dec)); $rep->TextCol(3, 4, number_format2($totalacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($totalper, $totalacc), $pdec)); if ($graphics) { $pg->x[] = $group; $pg->y[] = abs($totalper); $pg->z[] = abs($totalacc); } $rep->row -= $rep->lineHeight + 4; if ($closeclass) { $rep->Line($rep->row + 6); $calculateper = $salesper + $classper; $calculateacc = $salesacc + $classacc; $rep->row -= 6; $rep->Font('bold'); $rep->TextCol(0, 2, tr('Total') . " " . $classname); $rep->TextCol(2, 3, number_format2($classper, $dec)); $rep->TextCol(3, 4, number_format2($classacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($classper, $classacc), $pdec)); $rep->row -= $rep->lineHeight + 8; $rep->TextCol(0, 2, tr('Calculated Return')); $rep->TextCol(2, 3, number_format2($calculateper, $dec)); $rep->TextCol(3, 4, number_format2($calculateacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($calculateper, $calculateacc), $pdec)); if ($graphics) { $pg->x[] = tr('Calculated Return'); $pg->y[] = abs($calculateper); $pg->z[] = abs($calculateacc); } $rep->Font(); $rep->NewLine(); } } } $rep->Line($rep->row); if ($graphics) { global $decseps, $graph_skin; $pg->title = $rep->title; $pg->axis_x = tr("Group"); $pg->axis_y = tr("Amount"); $pg->graphic_1 = $headers[2]; $pg->graphic_2 = $headers[3]; $pg->type = $graphics; $pg->skin = $graph_skin; $pg->built_in = false; $pg->fontfile = $path_to_root . "reporting/fonts/Vera.ttf"; $pg->latin_notation = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != "."; $filename = $comp_path . '/' . user_company() . "/pdf_files/test.png"; $pg->display($filename, true); $w = $pg->width / 1.5; $h = $pg->height / 1.5; $x = ($rep->pageWidth - $w) / 2; $rep->NewLine(2); if ($rep->row - $h < $rep->bottomMargin) { $rep->Header(); } $rep->AddImage($filename, $x, $rep->row - $h, $w, $h); } $rep->End(); }
function print_trial_balance() { global $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; $from = $_REQUEST['PARAM_0']; $to = $_REQUEST['PARAM_1']; $zero = $_REQUEST['PARAM_2']; if ($dim == 2) { $dimension = $_REQUEST['PARAM_3']; $dimension2 = $_REQUEST['PARAM_4']; $comments = $_REQUEST['PARAM_5']; } else { if ($dim == 1) { $dimension = $_REQUEST['PARAM_3']; $comments = $_REQUEST['PARAM_4']; } else { $comments = $_REQUEST['PARAM_3']; } } $dec = user_price_dec(); $cols2 = array(0, 50, 230, 330, 430, 530); //-------------0--1---2----3----4----5-- $headers2 = array('', '', tr('Brought Forward'), tr('This Period'), tr('Balance')); $aligns2 = array('left', 'left', 'left', 'left', 'left'); $cols = array(0, 50, 200, 250, 300, 350, 400, 450, 500, 550); //------------0--1---2----3----4----5----6----7----8----9-- $headers = array(tr('Account'), tr('Account Name'), tr('Debit'), tr('Credit'), tr('Debit'), tr('Credit'), tr('Debit'), tr('Credit')); $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right', 'right'); if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => tr('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to)); } } $rep = new FrontReport(tr('Trial Balance'), "TrialBalance.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2); $rep->Header(); $accounts = get_gl_accounts(); while ($account = db_fetch($accounts)) { if (is_account_balancesheet($account["account_code"])) { $begin = ""; } else { if ($from < $begin) { $begin = add_days($from, -1); } else { $begin = add_days(begin_fiscalyear(), -1); } } $prev_balance = get_gl_balance_from_to($begin, $from, $account["account_code"], $dimension, $dimension2); $curr_balance = get_gl_trans_from_to($from, $to, $account["account_code"], $dimension, $dimension2); if ($zero == 0 && !$prev_balance && !$curr_balance) { continue; } $rep->TextCol(0, 1, $account['account_code']); $rep->TextCol(1, 2, $account['account_name']); if ($prev_balance > 0.0) { $rep->TextCol(2, 3, number_format2(abs($prev_balance), $dec)); } else { $rep->TextCol(3, 4, number_format2(abs($prev_balance), $dec)); } if ($curr_balance > 0.0) { $rep->TextCol(4, 5, number_format2(abs($curr_balance), $dec)); } else { $rep->TextCol(5, 6, number_format2(abs($curr_balance), $dec)); } if ($curr_balance + $prev_balance > 0.0) { $rep->TextCol(6, 7, number_format2(abs($curr_balance + $prev_balance), $dec)); } else { $rep->TextCol(7, 8, number_format2(abs($curr_balance + $prev_balance), $dec)); } $rep->NewLine(); if ($rep->row < $rep->bottomMargin + $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->Header(); } } $rep->Line($rep->row); $rep->End(); }
function print_trial_balance() { global $path_to_root; global $pdeb, $pcre, $cdeb, $ccre, $tdeb, $tcre, $pbal, $cbal, $tbal; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $zero = $_POST['PARAM_2']; $balances = $_POST['PARAM_3']; if ($dim == 2) { $dimension = $_POST['PARAM_4']; $dimension2 = $_POST['PARAM_5']; $comments = $_POST['PARAM_6']; $orientation = $_POST['PARAM_7']; $destination = $_POST['PARAM_8']; } else { if ($dim == 1) { $dimension = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; $orientation = $_POST['PARAM_6']; $destination = $_POST['PARAM_7']; } else { $comments = $_POST['PARAM_4']; $orientation = $_POST['PARAM_5']; $destination = $_POST['PARAM_6']; } } if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $cols2 = array(0, 50, 190, 310, 430, 530); //-------------0--1---2----3----4----5-- $headers2 = array('', '', _('Brought Forward'), _('This Period'), _('Balance')); $aligns2 = array('left', 'left', 'left', 'left', 'left'); $cols = array(0, 50, 150, 210, 270, 330, 390, 450, 510, 570); //------------0--1---2----3----4----5----6----7----8-- $headers = array(_('Account'), _('Account Name'), _('Debit'), _('Credit'), _('Debit'), _('Credit'), _('Debit'), _('Credit')); $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right', 'right'); if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => _('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to)); } } $rep = new FrontReport(_('Trial Balance'), "TrialBalance", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); recalculate_cols($cols2); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2); $rep->NewPage(); $classresult = get_account_classes(false); while ($class = db_fetch($classresult)) { $rep->Font('bold'); $rep->TextCol(0, 1, $class['cid']); $rep->TextCol(1, 4, $class['class_name']); $rep->Font(); $rep->NewLine(); //Get Account groups/types under this group/type with no parents $typeresult = get_account_types(false, $class['cid'], -1); while ($accounttype = db_fetch($typeresult)) { display_type($accounttype["id"], $accounttype["name"], $dec, $rep, $from, $to, $zero, $balances, $dimension, $dimension2); } $rep->NewLine(); } $rep->Line($rep->row); $rep->NewLine(); $rep->Font('bold'); if ($balances == 0) { $rep->TextCol(0, 2, _("Total")); $rep->AmountCol(2, 3, $pdeb, $dec); $rep->AmountCol(3, 4, $pcre, $dec); $rep->AmountCol(4, 5, $cdeb, $dec); $rep->AmountCol(5, 6, $ccre, $dec); $rep->AmountCol(6, 7, $tdeb, $dec); $rep->AmountCol(7, 8, $tcre, $dec); $rep->NewLine(); } $rep->TextCol(0, 2, _("Ending Balance")); if ($pbal >= 0.0) { $rep->AmountCol(2, 3, $pbal, $dec); } else { $rep->AmountCol(3, 4, abs($pbal), $dec); } if ($cbal >= 0.0) { $rep->AmountCol(4, 5, $cbal, $dec); } else { $rep->AmountCol(5, 6, abs($cbal), $dec); } if ($tbal >= 0.0) { $rep->AmountCol(6, 7, $tbal, $dec); } else { $rep->AmountCol(7, 8, abs($tbal), $dec); } $rep->NewLine(); $rep->Line($rep->row + 10); if (($pbal = round2($pbal, $dec)) != 0.0 && $dimension == 0 && $dimension2 == 0) { $rep->NewLine(2); $rep->Font(); $rep->TextCol(0, 8, _("The Opening Balance is not in balance, probably due to a non closed Previous Fiscalyear.")); } $rep->End(); }
continue; } if (!$heading_shown) { display_gl_heading($myrow); start_table(TABLESTYLE, "width='95%'"); table_header($th); $heading_shown = true; } alt_table_row_color($k); label_cell($myrow['account']); label_cell($myrow['account_name']); if ($dim >= 1) { label_cell(get_dimension_string($myrow['dimension_id'], true)); } if ($dim > 1) { label_cell(get_dimension_string($myrow['dimension2_id'], true)); } display_debit_or_credit_cells($myrow['amount']); label_cell($myrow['memo_']); end_row(); if ($myrow['amount'] > 0) { $debit += $myrow['amount']; } else { $credit += $myrow['amount']; } } if ($heading_shown) { start_row("class='inquirybg' style='font-weight:bold'"); label_cell(_("Total"), "colspan=2"); if ($dim >= 1) { label_cell('');
function print_balance_sheet() { global $comp_path, $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; $from = $_REQUEST['PARAM_0']; $to = $_REQUEST['PARAM_1']; if ($dim == 2) { $dimension = $_REQUEST['PARAM_2']; $dimension2 = $_REQUEST['PARAM_3']; $graphics = $_REQUEST['PARAM_4']; $comments = $_REQUEST['PARAM_5']; } else { if ($dim == 1) { $dimension = $_REQUEST['PARAM_2']; $graphics = $_REQUEST['PARAM_3']; $comments = $_REQUEST['PARAM_4']; } else { $graphics = $_REQUEST['PARAM_2']; $comments = $_REQUEST['PARAM_3']; } } if ($graphics) { include_once $path_to_root . "reporting/includes/class.graphic.inc"; $pg = new graph(); } $dec = 0; $cols = array(0, 50, 200, 350, 425, 500); //------------0--1---2----3----4----5-- $headers = array(tr('Account'), tr('Account Name'), tr('Open Balance'), tr('Period'), tr('Close Balance')); $aligns = array('left', 'left', 'right', 'right', 'right'); if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => tr('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to)); } } $rep = new FrontReport(tr('Balance Sheet'), "BalanceSheet.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $classname = ''; $group = ''; $totalopen = 0.0; $totalperiod = 0.0; $totalclose = 0.0; $classopen = 0.0; $classperiod = 0.0; $classclose = 0.0; $assetsopen = 0.0; $assetsperiod = 0.0; $assetsclose = 0.0; $closeclass = false; $accounts = get_gl_accounts_all(1); while ($account = db_fetch($accounts)) { $prev_balance = get_gl_balance_from_to("", $from, $account["account_code"], $dimension, $dimension2); $curr_balance = get_gl_trans_from_to($from, $to, $account["account_code"], $dimension, $dimension2); if (!$prev_balance && !$curr_balance) { continue; } if ($account['AccountClassName'] != $classname) { if ($classname != '') { $closeclass = true; } } if ($account['AccountTypeName'] != $group) { if ($group != '') { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->TextCol(0, 2, tr('Total') . " " . $group); $rep->TextCol(2, 3, number_format2($totalopen, $dec)); $rep->TextCol(3, 4, number_format2($totalperiod, $dec)); $rep->TextCol(4, 5, number_format2($totalclose, $dec)); if ($graphics) { $pg->x[] = $group; $pg->y[] = abs($totalclose); } $totalopen = $totalperiod = $totalclose = 0.0; $rep->row -= $rep->lineHeight + 4; if ($closeclass) { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->Font('bold'); $rep->TextCol(0, 2, tr('Total') . " " . $classname); $rep->TextCol(2, 3, number_format2($classopen, $dec)); $rep->TextCol(3, 4, number_format2($classperiod, $dec)); $rep->TextCol(4, 5, number_format2($classclose, $dec)); $rep->Font(); $assetsopen += $classopen; $assetsperiod += $classperiod; $assetsclose += $classclose; $classopen = $classperiod = $classclose = 0.0; $rep->NewLine(3); $closeclass = false; } } if ($account['AccountClassName'] != $classname) { $rep->Font('bold'); $rep->TextCol(0, 5, $account['AccountClassName']); $rep->Font(); $rep->row -= $rep->lineHeight + 4; } $group = $account['AccountTypeName']; $rep->TextCol(0, 5, $account['AccountTypeName']); $rep->Line($rep->row - 4); $rep->row -= $rep->lineHeight + 4; } $classname = $account['AccountClassName']; $totalopen += $prev_balance; $totalperiod += $curr_balance; $totalclose = $totalopen + $totalperiod; $classopen += $prev_balance; $classperiod += $curr_balance; $classclose = $classopen + $classperiod; $rep->TextCol(0, 1, $account['account_code']); $rep->TextCol(1, 2, $account['account_name']); $rep->TextCol(2, 3, number_format2($prev_balance, $dec)); $rep->TextCol(3, 4, number_format2($curr_balance, $dec)); $rep->TextCol(4, 5, number_format2($curr_balance + $prev_balance, $dec)); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->Header(); } } if ($account['AccountClassName'] != $classname) { if ($classname != '') { $closeclass = true; } } if ($account['AccountTypeName'] != $group) { if ($group != '') { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->TextCol(0, 2, tr('Total') . " " . $group); $rep->TextCol(2, 3, number_format2($totalopen, $dec)); $rep->TextCol(3, 4, number_format2($totalperiod, $dec)); $rep->TextCol(4, 5, number_format2($totalclose, $dec)); if ($graphics) { $pg->x[] = $group; $pg->y[] = abs($totalclose); } $rep->row -= $rep->lineHeight + 4; if ($closeclass) { $rep->Line($rep->row + 6); $calculateopen = -$assetsopen - $classopen; $calculateperiod = -$assetsperiod - $classperiod; $calculateclose = -$assetsclose - $classclose; $rep->row -= 6; $rep->TextCol(0, 2, tr('Calculated Return')); $rep->TextCol(2, 3, number_format2($calculateopen, $dec)); $rep->TextCol(3, 4, number_format2($calculateperiod, $dec)); $rep->TextCol(4, 5, number_format2($calculateclose, $dec)); if ($graphics) { $pg->x[] = tr('Calculated Return'); $pg->y[] = abs($calculateclose); } $rep->row -= $rep->lineHeight + 4; $rep->Font('bold'); $rep->TextCol(0, 2, tr('Total') . " " . $classname); $rep->TextCol(2, 3, number_format2(-$assetsopen, $dec)); $rep->TextCol(3, 4, number_format2(-$assetsperiod, $dec)); $rep->TextCol(4, 5, number_format2(-$assetsclose, $dec)); $rep->Font(); $rep->NewLine(); } } } $rep->Line($rep->row); if ($graphics) { global $decseps, $graph_skin; $pg->title = $rep->title; $pg->axis_x = tr("Group"); $pg->axis_y = tr("Amount"); $pg->graphic_1 = $to; $pg->type = $graphics; $pg->skin = $graph_skin; $pg->built_in = false; $pg->fontfile = $path_to_root . "reporting/fonts/Vera.ttf"; $pg->latin_notation = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != "."; $filename = $comp_path . '/' . user_company() . "/pdf_files/test.png"; $pg->display($filename, true); $w = $pg->width / 1.5; $h = $pg->height / 1.5; $x = ($rep->pageWidth - $w) / 2; $rep->NewLine(2); if ($rep->row - $h < $rep->bottomMargin) { $rep->Header(); } $rep->AddImage($filename, $x, $rep->row - $h, $w, $h); } $rep->End(); }
function print_GL_transactions() { global $path_to_root, $systypes_array; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $fromacc = $_POST['PARAM_2']; $toacc = $_POST['PARAM_3']; if ($dim == 2) { $dimension = $_POST['PARAM_4']; $dimension2 = $_POST['PARAM_5']; $comments = $_POST['PARAM_6']; $orientation = $_POST['PARAM_7']; $destination = $_POST['PARAM_8']; } else { if ($dim == 1) { $dimension = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; $orientation = $_POST['PARAM_6']; $destination = $_POST['PARAM_7']; } else { $comments = $_POST['PARAM_4']; $orientation = $_POST['PARAM_5']; $destination = $_POST['PARAM_6']; } } if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; $rep = new FrontReport(_('GL Account Transactions'), "GLAccountTransactions", user_pagesize(), 9, $orientation); $dec = 2; //$cols = array(0, 80, 100, 150, 210, 280, 340, 400, 450, 510, 570); $cols = array(0, 65, 105, 125, 175, 230, 290, 345, 405, 465, 525); //------------0--1---2---3----4----5----6----7----8----9----10------- //-----------------------dim1-dim2----------------------------------- //-----------------------dim1---------------------------------------- //------------------------------------------------------------------- $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'left', 'right', 'right', 'right'); if ($dim == 2) { $headers = array(_('Type'), _('Ref'), _('#'), _('Date'), _('Dimension') . " 1", _('Dimension') . " 2", _('Person/Item'), _('Debit'), _('Credit'), _('Balance')); } elseif ($dim == 1) { $headers = array(_('Type'), _('Ref'), _('#'), _('Date'), _('Dimension'), "", _('Person/Item'), _('Debit'), _('Credit'), _('Balance')); } else { $headers = array(_('Type'), _('Ref'), _('#'), _('Date'), "", "", _('Person/Item'), _('Debit'), _('Credit'), _('Balance')); } if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $toacc), 3 => array('text' => _('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 4 => array('text' => _('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $toacc), 3 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $toacc)); } } if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $accounts = get_gl_accounts($fromacc, $toacc); while ($account = db_fetch($accounts)) { if (is_account_balancesheet($account["account_code"])) { $begin = ""; } else { $begin = get_fiscalyear_begin_for_date($from); if (date1_greater_date2($begin, $from)) { $begin = $from; } $begin = add_days($begin, -1); } $prev_balance = get_gl_balance_from_to($begin, $from, $account["account_code"], $dimension, $dimension2); $trans = get_gl_transactions($from, $to, -1, $account['account_code'], $dimension, $dimension2); $rows = db_num_rows($trans); if ($prev_balance == 0.0 && $rows == 0) { continue; } $rep->Font('bold'); $rep->TextCol(0, 4, $account['account_code'] . " " . $account['account_name'], -2); $rep->TextCol(4, 6, _('Opening Balance')); if ($prev_balance > 0.0) { $rep->AmountCol(7, 8, abs($prev_balance), $dec); } else { $rep->AmountCol(8, 9, abs($prev_balance), $dec); } $rep->Font(); $total = $prev_balance; $rep->NewLine(2); if ($rows > 0) { while ($myrow = db_fetch($trans)) { $total += $myrow['amount']; $type_name = $systypes_array[$myrow["type"]]; if ($type_name == "Customer Payment") { $rep->TextCol(0, 1, "CRB", -2); } if ($type_name == "Cash Disbursement/Check Voucher") { $rep->TextCol(0, 1, "CDB", -2); } if ($type_name == "Journal Entry") { $rep->TextCol(0, 1, "JB", -2); } if ($type_name == "Customer Credit Note") { $type_name = "Credit Memo"; } if ($type_name == "Sales Invoice") { $type_name = "Invoice"; } else { if ($type_name != "Customer Payment" && $type_name != "Cash Disbursement/Check Voucher" && $type_name != "Journal Entry") { $rep->TextCol(0, 1, $type_name, -2); } } $reference = get_reference($myrow["type"], $myrow["type_no"]); $rep->TextCol(1, 2, $reference); $rep->TextCol(2, 3, $myrow['type_no'], -2); $rep->DateCol(3, 4, $myrow["tran_date"], true); if ($dim >= 1) { $rep->TextCol(4, 5, get_dimension_string($myrow['dimension_id'])); } if ($dim > 1) { $rep->TextCol(5, 6, get_dimension_string($myrow['dimension2_id'])); } $txt = payment_person_name($myrow["person_type_id"], $myrow["person_id"], false); $memo = $myrow['memo_']; if ($txt != "") { if ($memo != "") { $txt = $txt . "/" . $memo; } } else { $txt = $memo; } $rep->TextCol(6, 7, $txt, -2); if ($myrow['amount'] > 0.0) { $rep->AmountCol(7, 8, abs($myrow['amount']), $dec); } else { $rep->AmountCol(8, 9, abs($myrow['amount']), $dec); } $rep->TextCol(9, 10, number_format2($total, $dec)); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->NewPage(); } } $rep->NewLine(); } $rep->Font('bold'); $rep->TextCol(4, 6, _("Ending Balance")); if ($total > 0.0) { $rep->AmountCol(7, 8, abs($total), $dec); } else { $rep->AmountCol(8, 9, abs($total), $dec); } $rep->Font(); $rep->Line($rep->row - $rep->lineHeight + 4); $rep->NewLine(2, 1); } $rep->End(); }
function print_balance_sheet() { global $path_to_root; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; if ($dim == 2) { $dimension = $_POST['PARAM_2']; $dimension2 = $_POST['PARAM_3']; $tags = isset($_POST['PARAM_4']) ? $_POST['PARAM_4'] : -1; $decimals = $_POST['PARAM_5']; $graphics = $_POST['PARAM_6']; $comments = $_POST['PARAM_7']; $orientation = $_POST['PARAM_8']; $destination = $_POST['PARAM_9']; } else { if ($dim == 1) { $dimension = $_POST['PARAM_2']; $tags = isset($_POST['PARAM_3']) ? $_POST['PARAM_3'] : -1; $decimals = $_POST['PARAM_4']; $graphics = $_POST['PARAM_5']; $comments = $_POST['PARAM_6']; $orientation = $_POST['PARAM_7']; $destination = $_POST['PARAM_8']; } else { $tags = isset($_POST['PARAM_2']) ? $_POST['PARAM_2'] : -1; $decimals = $_POST['PARAM_3']; $graphics = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; $orientation = $_POST['PARAM_6']; $destination = $_POST['PARAM_7']; } } if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; if ($graphics) { include_once $path_to_root . "/reporting/includes/class.graphic.inc"; $pg = new graph(); } if (!$decimals) { $dec = 0; } else { $dec = user_price_dec(); } $cols = array(0, 50, 200, 350, 425, 500); //------------0--1---2----3----4----5-- $headers = array(_('Account'), _('Account Name'), _('Open Balance'), _('Period'), _('Close Balance')); $aligns = array('left', 'left', 'right', 'right', 'right'); if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => _('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => ''), 4 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => '')); } } $rep = new FrontReport(_('Balance Sheet'), "BalanceSheet", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $calc_open = $calc_period = 0.0; $equity_open = $equity_period = 0.0; $liability_open = $liability_period = 0.0; $econvert = $lconvert = 0; $classresult = get_account_classes(false, 1); while ($class = db_fetch($classresult)) { $class_open_total = 0; $class_period_total = 0; $convert = get_class_type_convert($class["ctype"]); //Print Class Name $rep->Font('bold'); $rep->TextCol(0, 5, $class["class_name"]); $rep->Font(); $rep->NewLine(); //Get Account groups/types under this group/type with no parents $typeresult = get_account_types(false, $class['cid'], -1); while ($accounttype = db_fetch($typeresult)) { $classtotal = display_type($accounttype["id"], $accounttype["name"], $from, $to, $convert, $dec, $rep, $dimension, $dimension2, $tags, $pg, $graphics); $class_open_total += $classtotal[0]; $class_period_total += $classtotal[1]; } //Print Class Summary $rep->row += 6; $rep->Line($rep->row); $rep->NewLine(); $rep->Font('bold'); $rep->TextCol(0, 2, _('Total') . " " . $class["class_name"]); $rep->AmountCol(2, 3, $class_open_total * $convert, $dec); $rep->AmountCol(3, 4, $class_period_total * $convert, $dec); $rep->AmountCol(4, 5, ($class_open_total + $class_period_total) * $convert, $dec); $rep->Font(); $rep->NewLine(2); $calc_open += $class_open_total; $calc_period += $class_period_total; if ($class['ctype'] == CL_EQUITY) { $equity_open += $class_open_total; $equity_period += $class_period_total; $econvert = $convert; } elseif ($class['ctype'] == CL_LIABILITIES) { $liability_open += $class_open_total; $liability_period += $class_period_total; $lconvert = $convert; } } $rep->Font(); $rep->TextCol(0, 2, _('Calculated Return')); if ($lconvert == 1) { $calc_open *= -1; $calc_period *= -1; } $rep->AmountCol(2, 3, $calc_open, $dec); // never convert $rep->AmountCol(3, 4, $calc_period, $dec); $rep->AmountCol(4, 5, $calc_open + $calc_period, $dec); $rep->NewLine(2); $rep->Font('bold'); $rep->TextCol(0, 2, _('Total') . " " . _('Liabilities') . _(' and ') . _('Equities')); $topen = $equity_open * $econvert + $liability_open * $lconvert + $calc_open; $tperiod = $equity_period * $econvert + $liability_period * $lconvert + $calc_period; $tclose = $topen + $tperiod; $rep->AmountCol(2, 3, $topen, $dec); $rep->AmountCol(3, 4, $tperiod, $dec); $rep->AmountCol(4, 5, $tclose, $dec); $rep->Font(); $rep->NewLine(); $rep->Line($rep->row); if ($graphics) { $pg->x[] = _('Calculated Return'); $pg->y[] = abs($calc_open); $pg->z[] = abs($calc_period); global $decseps, $graph_skin; $pg->title = $rep->title; $pg->axis_x = _("Group"); $pg->axis_y = _("Amount"); $pg->graphic_1 = $headers[2]; $pg->graphic_2 = $headers[3]; $pg->type = $graphics; $pg->skin = $graph_skin; $pg->built_in = false; $pg->latin_notation = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != "."; $filename = company_path() . "/pdf_files/" . uniqid("") . ".png"; $pg->display($filename, true); $w = $pg->width / 1.5; $h = $pg->height / 1.5; $x = ($rep->pageWidth - $w) / 2; $rep->NewLine(2); if ($rep->row - $h < $rep->bottomMargin) { $rep->NewPage(); } $rep->AddImage($filename, $x, $rep->row - $h, $w, $h); } $rep->End(); }
function print_GL_transactions() { global $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $rep = new FrontReport(tr('GL Account Transactions'), "GLAccountTransactions.pdf", user_pagesize()); $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; $from = $_REQUEST['PARAM_0']; $to = $_REQUEST['PARAM_1']; $fromacc = $_REQUEST['PARAM_2']; $toacc = $_REQUEST['PARAM_3']; if ($dim == 2) { $dimension = $_REQUEST['PARAM_4']; $dimension2 = $_REQUEST['PARAM_5']; $comments = $_REQUEST['PARAM_6']; } else { if ($dim == 1) { $dimension = $_REQUEST['PARAM_4']; $comments = $_REQUEST['PARAM_5']; } else { $comments = $_REQUEST['PARAM_4']; } } $dec = user_price_dec(); $cols = array(0, 70, 90, 140, 210, 280, 340, 400, 450, 510, 570); //------------0--1---2---3----4----5----6----7----8----9----10------- //-----------------------dim1-dim2----------------------------------- //-----------------------dim1---------------------------------------- //------------------------------------------------------------------- $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'right', 'right', 'right'); if ($dim == 2) { $headers = array(tr('Type'), tr('#'), tr('Date'), tr('Dimension') . " 1", tr('Dimension') . " 2", tr('Person/Item'), tr('Debit'), tr('Credit'), tr('Balance')); } else { if ($dim == 1) { $headers = array(tr('Type'), tr('#'), tr('Date'), tr('Dimension'), "", tr('Person/Item'), tr('Debit'), tr('Credit'), tr('Balance')); } else { $headers = array(tr('Type'), tr('#'), tr('Date'), "", "", tr('Person/Item'), tr('Debit'), tr('Credit'), tr('Balance')); } } if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Accounts'), 'from' => $fromacc, 'to' => $toacc), 3 => array('text' => tr('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 4 => array('text' => tr('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Accounts'), 'from' => $fromacc, 'to' => $toacc), 3 => array('text' => tr('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Accounts'), 'from' => $fromacc, 'to' => $toacc)); } } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $accounts = get_gl_accounts($fromacc, $toacc); while ($account = db_fetch($accounts)) { if (is_account_balancesheet($account["account_code"])) { $begin = ""; } else { if ($from < $begin) { $begin = add_days($from, -1); } else { $begin = add_days(begin_fiscalyear(), -1); } } $prev_balance = get_gl_balance_from_to($begin, $from, $account["account_code"], $dimension, $dimension2); $trans = get_gl_transactions($from, $to, -1, $account['account_code'], $dimension, $dimension2); $rows = db_num_rows($trans); if ($prev_balance == 0.0 && $rows == 0) { continue; } $rep->Font('bold'); $rep->TextCol(0, 3, $account['account_code'] . " " . $account['account_name']); $rep->TextCol(3, 5, tr('Opening Balance')); if ($prev_balance > 0.0) { $rep->TextCol(6, 7, number_format2(abs($prev_balance), $dec)); } else { $rep->TextCol(7, 8, number_format2(abs($prev_balance), $dec)); } $rep->Font(); $total = $prev_balance; $rep->NewLine(2); if ($rows > 0) { while ($myrow = db_fetch($trans)) { $total += $myrow['amount']; $rep->TextCol(0, 1, systypes::name($myrow["type"])); $rep->TextCol(1, 2, $myrow['type_no']); $rep->TextCol(2, 3, sql2date($myrow["tran_date"])); if ($dim >= 1) { $rep->TextCol(3, 4, get_dimension_string($myrow['dimension_id'])); } if ($dim > 1) { $rep->TextCol(4, 5, get_dimension_string($myrow['dimension2_id'])); } $rep->TextCol(5, 6, payment_person_types::person_name($myrow["person_type_id"], $myrow["person_id"], false)); if ($myrow['amount'] > 0.0) { $rep->TextCol(6, 7, number_format2(abs($myrow['amount']), $dec)); } else { $rep->TextCol(7, 8, number_format2(abs($myrow['amount']), $dec)); } $rep->TextCol(8, 9, number_format2($total, $dec)); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->Header(); } } $rep->NewLine(); } $rep->Font('bold'); $rep->TextCol(3, 5, tr("Ending Balance")); if ($total > 0.0) { $rep->TextCol(6, 7, number_format2(abs($total), $dec)); } else { $rep->TextCol(7, 8, number_format2(abs($total), $dec)); } $rep->Font(); $rep->Line($rep->row - $rep->lineHeight + 4); $rep->NewLine(2, 1); } $rep->End(); }
function print_annual_expense_breakdown() { global $path_to_root, $date_system; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; if ($dim == 2) { $year = $_POST['PARAM_0']; $dimension = $_POST['PARAM_1']; $dimension2 = $_POST['PARAM_2']; $tags = isset($_POST['PARAM_3']) ? $_POST['PARAM_3'] : -1; $comments = $_POST['PARAM_4']; $orientation = $_POST['PARAM_5']; $destination = $_POST['PARAM_6']; } else { if ($dim == 1) { $year = $_POST['PARAM_0']; $dimension = $_POST['PARAM_1']; $tags = isset($_POST['PARAM_2']) ? $_POST['PARAM_2'] : -1; $comments = $_POST['PARAM_3']; $orientation = $_POST['PARAM_4']; $destination = $_POST['PARAM_5']; } else { $year = $_POST['PARAM_0']; $tags = isset($_POST['PARAM_1']) ? $_POST['PARAM_1'] : -1; $comments = $_POST['PARAM_2']; $orientation = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; } } if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; $dec = 1; //$pdec = user_percent_dec(); $cols = array(0, 40, 150, 180, 210, 240, 270, 300, 330, 360, 390, 420, 450, 480, 510); //------------0--1---2----3----4----5----6----7----8----10---11---12---13---14---15- //$yr = date('Y'); //$mo = date('m'): // from now $sql = "SELECT begin, end, YEAR(end) AS yr, MONTH(end) AS mo FROM " . TB_PREF . "fiscal_year WHERE id=" . db_escape($year); $result = db_query($sql, "could not get fiscal year"); $row = db_fetch($result); $year = sql2date($row['begin']) . " - " . sql2date($row['end']); $yr = $row['yr']; $mo = $row['mo']; $da = 1; if ($date_system == 1) { list($yr, $mo, $da) = jalali_to_gregorian($yr, $mo, $da); } elseif ($date_system == 2) { list($yr, $mo, $da) = islamic_to_gregorian($yr, $mo, $da); } $per12 = strftime('%b', mktime(0, 0, 0, $mo, $da, $yr)); $per11 = strftime('%b', mktime(0, 0, 0, $mo - 1, $da, $yr)); $per10 = strftime('%b', mktime(0, 0, 0, $mo - 2, $da, $yr)); $per09 = strftime('%b', mktime(0, 0, 0, $mo - 3, $da, $yr)); $per08 = strftime('%b', mktime(0, 0, 0, $mo - 4, $da, $yr)); $per07 = strftime('%b', mktime(0, 0, 0, $mo - 5, $da, $yr)); $per06 = strftime('%b', mktime(0, 0, 0, $mo - 6, $da, $yr)); $per05 = strftime('%b', mktime(0, 0, 0, $mo - 7, $da, $yr)); $per04 = strftime('%b', mktime(0, 0, 0, $mo - 8, $da, $yr)); $per03 = strftime('%b', mktime(0, 0, 0, $mo - 9, $da, $yr)); $per02 = strftime('%b', mktime(0, 0, 0, $mo - 10, $da, $yr)); $per01 = strftime('%b', mktime(0, 0, 0, $mo - 11, $da, $yr)); $headers = array(_('Account'), _('Account Name'), $per01, $per02, $per03, $per04, $per05, $per06, $per07, $per08, $per09, $per10, $per11, $per12); $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => _("Year"), 'from' => $year, 'to' => ''), 2 => array('text' => _("Dimension") . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => _("Dimension") . " 2", 'from' => get_dimension_string($dimension2), 'to' => ''), 4 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => ''), 5 => array('text' => _('Info'), 'from' => _('Amounts in thousands'), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => _("Year"), 'from' => $year, 'to' => ''), 2 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => ''), 4 => array('text' => _('Info'), 'from' => _('Amounts in thousands'), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => _("Year"), 'from' => $year, 'to' => ''), 2 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => ''), 3 => array('text' => _('Info'), 'from' => _('Amounts in thousands'), 'to' => '')); } } $rep = new FrontReport(_('Annual Expense Breakdown'), "AnnualBreakDown", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $sales = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $classresult = get_account_classes(false, 0); while ($class = db_fetch($classresult)) { $ctotal = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $convert = get_class_type_convert($class["ctype"]); //Print Class Name $rep->Font('bold'); $rep->TextCol(0, 5, $class["class_name"]); $rep->Font(); $rep->NewLine(); //Get Account groups/types under this group/type with no parents $typeresult = get_account_types(false, $class['cid'], -1); while ($accounttype = db_fetch($typeresult)) { $classtotal = display_type($accounttype["id"], $accounttype["name"], $yr, $mo, $convert, $dec, $rep, $dimension, $dimension2, $tags); for ($i = 1; $i <= 12; $i++) { $ctotal[$i] += $classtotal[$i]; } } //Print Class Summary $rep->row += 6; $rep->Line($rep->row); $rep->NewLine(); $rep->Font('bold'); $rep->TextCol(0, 2, _('Total') . " " . $class["class_name"]); for ($i = 1; $i <= 12; $i++) { $rep->AmountCol($i + 1, $i + 2, $ctotal[$i] * $convert, $dec); $sales[$i] += $ctotal[$i]; } $rep->Font(); $rep->NewLine(2); } $rep->Font('bold'); $rep->TextCol(0, 2, _("Calculated Return")); for ($i = 1; $i <= 12; $i++) { $rep->AmountCol($i + 1, $i + 2, $sales[$i] * -1, $dec); } $rep->Font(); $rep->NewLine(); $rep->Line($rep->row); $rep->NewLine(2); $rep->End(); }
function print_list_of_journal_entries() { global $path_to_root, $systypes_array; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $systype = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; $orientation = $_POST['PARAM_4']; $destination = $_POST['PARAM_5']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $cols = array(0, 100, 240, 300, 400, 460, 520, 580); $headers = array(_('Type/Account'), _('Reference') . '/' . _('Account Name'), _('Date/Dim.'), _('Person/Item/Memo'), _('Debit'), _('Credit')); $aligns = array('left', 'left', 'left', 'left', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Type'), 'from' => $systype == -1 ? _('All') : $systypes_array[$systype], 'to' => '')); $rep = new FrontReport(_('List of Journal Entries'), "JournalEntries", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); if ($systype == -1) { $systype = null; } $trans = get_gl_transactions($from, $to, -1, null, 0, 0, $systype); $typeno = $type = 0; $debit = $credit = 0.0; $totdeb = $totcre = 0.0; while ($myrow = db_fetch($trans)) { if ($type != $myrow['type'] || $typeno != $myrow['type_no']) { if ($typeno != 0) { $rep->Line($rep->row += 6); $rep->NewLine(); $rep->AmountCol(4, 5, $debit, $dec); $rep->AmountCol(5, 6, abs($credit), $dec); $totdeb += $debit; $totcre += $credit; $debit = $credit = 0.0; $rep->Line($rep->row -= 4); $rep->NewLine(); } $typeno = $myrow['type_no']; $type = $myrow['type']; $TransName = $systypes_array[$myrow['type']]; $rep->TextCol(0, 1, $TransName . " # " . $myrow['type_no']); $rep->TextCol(1, 2, get_reference($myrow['type'], $myrow['type_no'])); $rep->DateCol(2, 3, $myrow['tran_date'], true); $coms = payment_person_name($myrow["person_type_id"], $myrow["person_id"]); $memo = get_comments_string($myrow['type'], $myrow['type_no']); if ($memo != '') { if ($coms == "") { $coms = $memo; } else { $coms .= " / " . $memo; } } $rep->TextColLines(3, 6, $coms); $rep->NewLine(); } $rep->TextCol(0, 1, $myrow['account']); $rep->TextCol(1, 2, $myrow['account_name']); $dim_str = get_dimension_string($myrow['dimension_id']); $dim_str2 = get_dimension_string($myrow['dimension2_id']); if ($dim_str2 != "") { $dim_str .= "/" . $dim_str2; } $rep->TextCol(2, 3, $dim_str); $rep->TextCol(3, 4, $myrow['memo_']); if ($myrow['amount'] > 0.0) { $debit += $myrow['amount']; $rep->AmountCol(4, 5, abs($myrow['amount']), $dec); } else { $credit += $myrow['amount']; $rep->AmountCol(5, 6, abs($myrow['amount']), $dec); } $rep->NewLine(1, 2); } if ($typeno != 0) { $rep->Line($rep->row += 6); $rep->NewLine(); $rep->AmountCol(4, 5, $debit, $dec); $rep->AmountCol(5, 6, abs($credit), $dec); $totdeb += $debit; $totcre += $credit; $rep->Line($rep->row -= 4); $rep->NewLine(); $rep->TextCol(0, 4, _("Total")); $rep->AmountCol(4, 5, $totdeb, $dec); $rep->AmountCol(5, 6, abs($totcre), $dec); $rep->Line($rep->row -= 4); } $rep->End(); }
function print_cash_flow_statement() { global $path_to_root, $date_system, $comp_path; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; if ($dim == 2) { $date = $_POST['PARAM_0']; $dimension = $_POST['PARAM_1']; $dimension2 = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; } else { if ($dim == 1) { $date = $_POST['PARAM_0']; $dimension = $_POST['PARAM_1']; $comments = $_POST['PARAM_2']; $destination = $_POST['PARAM_3']; } else { $date = $_POST['PARAM_0']; $comments = $_POST['PARAM_1']; $destination = $_POST['PARAM_2']; } } if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } if ($comments) { $comments .= ". - "; } $comments .= _("Balances in Home Currency"); $title = _("Cash Flow Statement"); $output_filename = "CashFlowStatement"; $fontsize = 7; $page_size = user_pagesize(); $page_orientation = 'L'; $margins = array('top' => 30, 'bottom' => 34, 'left' => 16, 'right' => 10); $excelColWidthFactor = 5; $rep = new FrontReport($title, $output_filename, $page_size, $fontsize, $page_orientation, $margins, $excelColWidthFactor); $enddate = end_month($date); $dec = user_price_dec(); // Lay out the columns for this report //$cols2 = array(0, 70, 127, 184, 232, 280, 328, 376, 424, 472, 520, 568, 616, 664, 712, 760); //-------------0--1---2----3----4----5----6----7----8----9----10---11---12---13---14---15- $cols2 = array(0 => 0, 70); $endline = $rep->endLine - 20; $wi = ($endline - $cols2[1]) / 14; // 14 amount columns for ($i = 2; $i < 17; $i++) { $cols2[$i] = $cols2[$i - 1] + $wi; } $cols = $cols2; //---------------------------------------------------------------------------------------- $aligns2 = array('left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $headers2 = array(); //$cols = array(0, 70, 127, 184, 232, 280, 328, 376, 424, 472, 520, 568, 616, 664, 712, 760); //-------------0--1---2----3----4----5----6----7----8----9----10---11---12---13---14---15- //---------------------------------------------------------------------------------------- $aligns = array('left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $headers = array(); $date = begin_month($date); $date = add_months($date, -11); list($da, $mo, $yr) = explode_date_to_dmy($date); if ($date_system == 1) { list($yr, $mo, $da) = jalali_to_gregorian($yr, $mo, $da); } elseif ($date_system == 2) { list($yr, $mo, $da) = islamic_to_gregorian($yr, $mo, $da); } $headers2[0] = 'Account'; $headers[0] = ''; for ($i = 0; $i < 12; $i++) { $header_row[$i] = $rep->DatePrettyPrint($date, 0, 1); // Wrap at space between month & year $wrap_point = strpos($header_row[$i], ' '); if ($wrap_point) { $headers2[] = substr($header_row[$i], 0, $wrap_point); $headers[] = substr($header_row[$i], $wrap_point + 1); } else { $headers2[] = ''; $headers[] = $header_row[$i]; } $date = add_months($date, 1); } $header_row[] = _("Fiscal YTD"); $header_row[] = _("12 Mo. to Date"); for ($i = 12; $i < 14; $i++) { $wrapped_header_text = $rep->TextWrapCalc($header_row[$i], $cols[$i + 2] - $cols[$i + 1], true); $headers2[] = trim($wrapped_header_text[0]); $headers[] = trim($wrapped_header_text[1]); } if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate)), 2 => array('text' => '', 'from' => '', 'to' => ''), 3 => array('text' => '', 'from' => '', 'to' => ''), 4 => array('text' => _("Dimension 1"), 'from' => get_dimension_string($dimension), 'to' => ''), 5 => array('text' => _("Dimension 2"), 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate)), 2 => array('text' => '', 'from' => '', 'to' => ''), 3 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate))); } } // Company logo setting $companylogoenable = true; // Footer Settings $footerenable = true; $footertext = _('For Management Purposes Only'); $rep->Font(); $rep->SetFillColor(240, 240, 240); $rep->scaleLogoWidth = true; $rep->lineHeight = 8; $rep->SetCellPadding(4); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2, $companylogoenable, $footerenable, $footertext); $rep->SetHeaderType('Header3'); $rep->NewPage(); $rep->SetDrawColor(0, 0, 0); $rep->SetLineWidth(0.1); $rep->row += 8; display_bank_trans($yr, $mo, $dec, $rep, $dimension, $dimension2, $enddate); $rep->Font(); $rep->End(); }
function print_annual_expense_breakdown() { global $path_to_root, $date_system; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; if ($dim == 2) { $year = $_REQUEST['PARAM_0']; $dimension = $_REQUEST['PARAM_1']; $dimension2 = $_REQUEST['PARAM_2']; $comments = $_REQUEST['PARAM_3']; } else { if ($dim == 1) { $year = $_REQUEST['PARAM_0']; $dimension = $_REQUEST['PARAM_1']; $comments = $_REQUEST['PARAM_2']; } else { $year = $_REQUEST['PARAM_0']; $comments = $_REQUEST['PARAM_1']; } } $dec = 1; //$pdec = user_percent_dec(); $cols = array(0, 40, 150, 180, 210, 240, 270, 300, 330, 360, 390, 420, 450, 480, 510); //------------0--1---2----3----4----5----6----7----8----10---11---12---13---14---15- //$yr = date('Y'); //$mo = date('m'): // from now $yr = $year; $mo = 12; $da = 1; if ($date_system == 1) { list($yr, $mo, $da) = jalali_to_gregorian($yr, $mo, $da); } elseif ($date_system == 2) { list($yr, $mo, $da) = islamic_to_gregorian($yr, $mo, $da); } $per12 = strftime('%b', mktime(0, 0, 0, $mo, $da, $yr)); $per11 = strftime('%b', mktime(0, 0, 0, $mo - 1, $da, $yr)); $per10 = strftime('%b', mktime(0, 0, 0, $mo - 2, $da, $yr)); $per09 = strftime('%b', mktime(0, 0, 0, $mo - 3, $da, $yr)); $per08 = strftime('%b', mktime(0, 0, 0, $mo - 4, $da, $yr)); $per07 = strftime('%b', mktime(0, 0, 0, $mo - 5, $da, $yr)); $per06 = strftime('%b', mktime(0, 0, 0, $mo - 6, $da, $yr)); $per05 = strftime('%b', mktime(0, 0, 0, $mo - 7, $da, $yr)); $per04 = strftime('%b', mktime(0, 0, 0, $mo - 8, $da, $yr)); $per03 = strftime('%b', mktime(0, 0, 0, $mo - 9, $da, $yr)); $per02 = strftime('%b', mktime(0, 0, 0, $mo - 10, $da, $yr)); $per01 = strftime('%b', mktime(0, 0, 0, $mo - 11, $da, $yr)); $headers = array(tr('Account'), tr('Account Name'), $per01, $per02, $per03, $per04, $per05, $per06, $per07, $per08, $per09, $per10, $per11, $per12); $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => tr("Year"), 'from' => $year, 'to' => ''), 2 => array('text' => tr("Dimension") . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => tr("Dimension") . " 2", 'from' => get_dimension_string($dimension2), 'to' => ''), 4 => array('text' => tr('Info'), 'from' => tr('Amounts in thousands'), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => tr("Year"), 'from' => $year, 'to' => ''), 2 => array('text' => tr('Dimension'), 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => tr('Info'), 'from' => tr('Amounts in thousands'), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => tr("Year"), 'from' => $year, 'to' => ''), 2 => array('text' => tr('Info'), 'from' => tr('Amounts in thousands'), 'to' => '')); } } $rep = new FrontReport(tr('Annual Expense Breakdown'), "AnnualBreakDown.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $classname = ''; $group = ''; $total = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $total2 = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $sales = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $calc = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $accounts = get_gl_accounts_all(0); while ($account = db_fetch($accounts)) { $bal = getPeriods($year, $account["account_code"], $dimension, $dimension2); if (!$bal['per01'] && !$bal['per02'] && !$bal['per03'] && !$bal['per04'] && !$bal['per05'] && !$bal['per06'] && !$bal['per07'] && !$bal['per08'] && !$bal['per09'] && !$bal['per10'] && !$bal['per11'] && !$bal['per12']) { continue; } $balance = array(1 => $bal['per01'], $bal['per02'], $bal['per03'], $bal['per04'], $bal['per05'], $bal['per06'], $bal['per07'], $bal['per08'], $bal['per09'], $bal['per10'], $bal['per11'], $bal['per12']); if ($account['AccountClassName'] != $classname) { if ($classname != '') { $closeclass = true; } } if ($account['AccountTypeName'] != $group) { if ($group != '') { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->TextCol(0, 2, tr('Total') . " " . $group); for ($i = 1; $i <= 12; $i++) { $rep->TextCol($i + 1, $i + 2, number_format2($total[$i], $dec)); } $total = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $rep->row -= $rep->lineHeight + 4; if ($closeclass) { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->Font('bold'); $rep->TextCol(0, 2, tr('Total') . " " . $classname); for ($i = 1; $i <= 12; $i++) { $rep->TextCol($i + 1, $i + 2, number_format2($total2[$i], $dec)); $sales[$i] += $total2[$i]; } $rep->Font(); $total2 = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $rep->NewLine(3); $closeclass = false; } } if ($account['AccountClassName'] != $classname) { $rep->Font('bold'); $rep->TextCol(0, 5, $account['AccountClassName']); $rep->Font(); $rep->row -= $rep->lineHeight + 4; } $group = $account['AccountTypeName']; $rep->TextCol(0, 5, $account['AccountTypeName']); $rep->Line($rep->row - 4); $rep->row -= $rep->lineHeight + 4; } $classname = $account['AccountClassName']; $rep->TextCol(0, 1, $account['account_code']); $rep->TextCol(1, 2, $account['account_name']); for ($i = 1; $i <= 12; $i++) { $rep->TextCol($i + 1, $i + 2, number_format2($balance[$i], $dec)); $total[$i] += $balance[$i]; $total2[$i] += $balance[$i]; } $rep->NewLine(); if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->Header(); } } if ($account['AccountClassName'] != $classname) { if ($classname != '') { $closeclass = true; } } if ($account['AccountTypeName'] != $group) { if ($group != '') { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->TextCol(0, 2, tr('Total') . " " . $group); for ($i = 1; $i <= 12; $i++) { $rep->TextCol($i + 1, $i + 2, number_format2($total[$i], $dec)); } $rep->row -= $rep->lineHeight + 4; if ($closeclass) { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->Font('bold'); $rep->TextCol(0, 2, tr('Total') . " " . $classname); for ($i = 1; $i <= 12; $i++) { $rep->TextCol($i + 1, $i + 2, number_format2($total2[$i], $dec)); $calc[$i] = $sales[$i] + $total2[$i]; } $rep->row -= $rep->lineHeight + 8; $rep->TextCol(0, 2, tr('Calculated Return')); for ($i = 1; $i <= 12; $i++) { $rep->TextCol($i + 1, $i + 2, number_format2($calc[$i], $dec)); } $rep->Font(); $rep->NewLine(); } } } $rep->Line($rep->row); $rep->End(); }
function show_results() { global $path_to_root, $systypes_array; if (!isset($_POST["account"])) { $_POST["account"] = null; } $act_name = $_POST["account"] ? get_gl_account_name($_POST["account"]) : ""; $dim = get_company_pref('use_dimension'); /*Now get the transactions */ if (!isset($_POST['Dimension'])) { $_POST['Dimension'] = 0; } if (!isset($_POST['Dimension2'])) { $_POST['Dimension2'] = 0; } $result = get_gl_transactions($_POST['TransFromDate'], $_POST['TransToDate'], -1, $_POST["account"], $_POST['Dimension'], $_POST['Dimension2'], null, input_num('amount_min'), input_num('amount_max')); $colspan = $dim == 2 ? "6" : ($dim == 1 ? "5" : "4"); if ($_POST["account"] != null) { display_heading($_POST["account"] . " " . $act_name); } // Only show balances if an account is specified AND we're not filtering by amounts $show_balances = $_POST["account"] != null && input_num("amount_min") == 0 && input_num("amount_max") == 0; start_table(TABLESTYLE); $first_cols = array(_("Type"), _("#"), _("Date")); if ($_POST["account"] == null) { $account_col = array(_("Account")); } else { $account_col = array(); } if ($dim == 2) { $dim_cols = array(_("Dimension") . " 1", _("Dimension") . " 2"); } else { if ($dim == 1) { $dim_cols = array(_("Dimension")); } else { $dim_cols = array(); } } if ($show_balances) { $remaining_cols = array(_("Person/Item"), _("Debit"), _("Credit"), _("Balance"), _("Memo")); } else { $remaining_cols = array(_("Person/Item"), _("Debit"), _("Credit"), _("Memo")); } $th = array_merge($first_cols, $account_col, $dim_cols, $remaining_cols); table_header($th); if ($_POST["account"] != null && is_account_balancesheet($_POST["account"])) { $begin = ""; } else { $begin = get_fiscalyear_begin_for_date($_POST['TransFromDate']); if (date1_greater_date2($begin, $_POST['TransFromDate'])) { $begin = $_POST['TransFromDate']; } $begin = add_days($begin, -1); } $bfw = 0; if ($show_balances) { $bfw = get_gl_balance_from_to($begin, $_POST['TransFromDate'], $_POST["account"], $_POST['Dimension'], $_POST['Dimension2']); start_row("class='inquirybg'"); label_cell("<b>" . _("Opening Balance") . " - " . $_POST['TransFromDate'] . "</b>", "colspan={$colspan}"); display_debit_or_credit_cells($bfw, true); label_cell(""); label_cell(""); end_row(); } $running_total = $bfw; $j = 1; $k = 0; //row colour counter while ($myrow = db_fetch($result)) { alt_table_row_color($k); $running_total += $myrow["amount"]; $trandate = sql2date($myrow["tran_date"]); label_cell($systypes_array[$myrow["type"]]); label_cell(get_gl_view_str($myrow["type"], $myrow["type_no"], $myrow["type_no"], true)); label_cell($trandate); if ($_POST["account"] == null) { label_cell($myrow["account"] . ' ' . get_gl_account_name($myrow["account"])); } if ($dim >= 1) { label_cell(get_dimension_string($myrow['dimension_id'], true)); } if ($dim > 1) { label_cell(get_dimension_string($myrow['dimension2_id'], true)); } label_cell(payment_person_name($myrow["person_type_id"], $myrow["person_id"])); display_debit_or_credit_cells($myrow["amount"]); if ($show_balances) { amount_cell($running_total); } if ($myrow['memo_'] == "") { $myrow['memo_'] = get_comments_string($myrow['type'], $myrow['type_no']); } label_cell($myrow['memo_']); end_row(); $j++; if ($j == 12) { $j = 1; table_header($th); } } //end of while loop if ($show_balances) { start_row("class='inquirybg'"); label_cell("<b>" . _("Ending Balance") . " - " . $_POST['TransToDate'] . "</b>", "colspan={$colspan}"); display_debit_or_credit_cells($running_total, true); label_cell(""); label_cell(""); end_row(); } end_table(2); if (db_num_rows($result) == 0) { display_note(_("No general ledger transactions have been created for the specified criteria."), 0, 1); } }
if ($dim > 0) { label_cell(""); } if ($dim > 1) { label_cell(""); } display_debit_or_credit_cells($am0 * -1); label_cell($memo); alt_table_row_color($k); label_cell($date); label_cell($_POST['res_act'] . " " . get_gl_account_name($_POST['res_act'])); if ($dim > 0) { label_cell(get_dimension_string($_POST['dimension_id'], true)); } if ($dim > 1) { label_cell(get_dimension_string($_POST['dimension2_id'], true)); } display_debit_or_credit_cells($am0); label_cell($memo); } } if (isset($_POST['go'])) { commit_transaction(); display_notification_centered(_("Revenue / Cost Accruals have been processed.")); $_POST['date_'] = $_POST['amount'] = $_POST['periods'] = ""; } else { end_table(1); display_notification_centered(_("Showing GL Transactions.")); } } }
function print_annual_balance_breakdown_detail() { global $path_to_root, $date_system; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; if ($dim == 2) { $date = $_POST['PARAM_0']; $dimension = $_POST['PARAM_1']; $dimension2 = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; } else { if ($dim == 1) { $date = $_POST['PARAM_0']; $dimension = $_POST['PARAM_1']; $comments = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; } else { $date = $_POST['PARAM_0']; $comments = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; } } if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $title = _("Annual Balance Breakdown - Detailed"); $output_filename = "AnnualBalanceBreakDownDetail"; $fontsize = 7; $page_size = user_pagesize(); $page_orientation = 'L'; $margins = array('top' => 30, 'bottom' => 34, 'left' => 16, 'right' => 10); $excelColWidthFactor = 5; $rep = new FrontReport($title, $output_filename, $page_size, $fontsize, $page_orientation, $margins, $excelColWidthFactor); $enddate = end_month($date); $dec = user_price_dec(); // Lay out the columns for this report //$cols2 = array(0, 70, 127, 184, 232, 280, 328, 376, 424, 472, 520, 568, 616, 664, 712, 760); //-------------0--1---2----3----4----5----6----7----8----9----10---11---12---13---14---15- $cols2 = array(0 => 0, 70); $endline = $rep->endLine - 20; $wi = ($endline - $cols2[1]) / 12; // 12 amount columns for ($i = 2; $i < 15; $i++) { $cols2[$i] = $cols2[$i - 1] + $wi; } $cols = $cols2; //---------------------------------------------------------------------------------------- $aligns2 = array('left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $headers2 = array(); //$cols = array(0, 70, 127, 184, 232, 280, 328, 376, 424, 472, 520, 568, 616, 664, 712, 760); //-------------0--1---2----3----4----5----6----7----8----9----10---11---12---13---14---15- //---------------------------------------------------------------------------------------- $aligns = array('left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $headers = array(); $date = begin_month($date); $date = add_months($date, -11); list($da, $mo, $yr) = explode_date_to_dmy($date); if ($date_system == 1) { list($yr, $mo, $da) = jalali_to_gregorian($yr, $mo, $da); } elseif ($date_system == 2) { list($yr, $mo, $da) = islamic_to_gregorian($yr, $mo, $da); } $headers2[0] = 'Account'; $headers[0] = ''; for ($i = 0; $i < 12; $i++) { $header_row[$i] = $rep->DatePrettyPrint($date, 0, 1); // Wrap at space between month & year $wrap_point = strpos($header_row[$i], ' '); if ($wrap_point) { $headers2[] = substr($header_row[$i], 0, $wrap_point); $headers[] = substr($header_row[$i], $wrap_point + 1); } else { $headers2[] = ''; $headers[] = $header_row[$i]; } $date = add_months($date, 1); } /* $header_row[] = "Fiscal Year Begin"; $header_row[] = "Fiscal YTD"; for ($i = 12; $i < 14; $i++) { $wrapped_header_text = $rep->TextWrapCalc($header_row[$i], $cols[$i+2] - $cols[$i+1], true); $headers2[] = trim($wrapped_header_text[0]); $headers[] = trim($wrapped_header_text[1]); } */ if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate)), 2 => array('text' => '', 'from' => '', 'to' => ''), 3 => array('text' => '', 'from' => '', 'to' => ''), 4 => array('text' => _("Dimension 1"), 'from' => get_dimension_string($dimension), 'to' => ''), 5 => array('text' => _("Dimension 2"), 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate)), 2 => array('text' => '', 'from' => '', 'to' => ''), 3 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate))); } } // Company logo setting $companylogoenable = true; // Footer Settings $footerenable = true; $footertext = _('For Management Purposes Only'); $rep->Font(); $rep->SetFillColor(240, 240, 240); $rep->scaleLogoWidth = true; $rep->lineHeight = 8; $rep->SetCellPadding(4); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2, $companylogoenable, $footerenable, $footertext); $rep->SetHeaderType('Header3'); $rep->NewPage(); $rep->SetDrawColor(0, 0, 0); $rep->SetLineWidth(0.1); $sales = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $classresult = get_account_classes(false, 1); while ($class = db_fetch($classresult)) { $ctotal = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $convert = get_class_type_convert($class["ctype"]); //Print Class Name $rep->NewLine(); $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $oldFontSize = $rep->fontSize; $rep->fontSize = 12; $rep->Font('b'); $rep->TextCol(0, 5, $class["class_name"]); $rep->Font(); $rep->fontSize = $oldFontSize; $rep->SetCellPadding($oldcMargin); $rep->NewLine(); //Get Account groups/types under this group/type with no parents $typeresult = get_account_types(false, $class['cid'], -1); while ($accounttype = db_fetch($typeresult)) { $classtotal = display_type($accounttype["id"], $accounttype["name"], $yr, $mo, $convert, $dec, $rep, $dimension, $dimension2); for ($i = 1; $i <= 12; $i++) { $ctotal[$i] += $classtotal[$i]; } } //Print Class Summary $rep->row += 5; $rep->Line($rep->row - 3); $rep->NewLine(); $rep->Font('b'); $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $fill = 0; $rep->TextCol(0, 1, _('Total') . " " . $class["class_name"], 0, 4, 0, $fill, NULL, 1); $rep->SetCellPadding($oldcMargin); for ($i = 1; $i <= 12; $i++) { $rep->AmountCol2($i, $i + 1, $ctotal[$i] * $convert, $dec, 0, 4, 0, $fill, NULL, 1, true); $sales[$i] += $ctotal[$i]; } $rep->Font(); $rep->NewLine(2); } $rep->Font('bold'); $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $rep->TextCol(0, 1, _('Net Assets (Liabilities)'), 0, 4, 0, $fill, NULL, 1); $rep->SetCellPadding($oldcMargin); for ($i = 1; $i <= 12; $i++) { $rep->AmountCol2($i, $i + 1, $sales[$i] * -1, $dec, 0, 4, 0, $fill, NULL, 1, true); } $rep->Font(); $rep->NewLine(); $rep->Line($rep->row); $rep->NewLine(2); $calc = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $total = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $classresult = get_account_classes(false, 0); while ($class = db_fetch($classresult)) { $convert = get_class_type_convert($class["ctype"]); //Print Class Name $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $rep->Font('b'); $rep->TextCol(0, 1, _("Total ") . $class["class_name"], 0, 4, 0, $fill, NULL, 1); $rep->SetCellPadding($oldcMargin); $typeresult = get_account_types(false, $class['cid']); while ($accounttype = db_fetch($typeresult)) { $result = get_gl_accounts(null, null, $accounttype['id']); while ($account = db_fetch($result)) { $bal = getPeriods($yr, $mo, $account["account_code"], $dimension, $dimension2); $balance = array(1 => $bal['per01'], $bal['per02'], $bal['per03'], $bal['per04'], $bal['per05'], $bal['per06'], $bal['per07'], $bal['per08'], $bal['per09'], $bal['per10'], $bal['per11'], $bal['per12']); for ($i = 1; $i <= 12; $i++) { $total[$i] += $balance[$i]; } } } for ($i = 1; $i <= 12; $i++) { $rep->AmountCol2($i, $i + 1, $total[$i] * $convert, $dec, 0, 4, 0, $fill, NULL, 1, true); $calc[$i] += $total[$i]; $total[$i] = 0; } $rep->NewLine(2); } $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $rep->TextCol(0, 1, _('Total Profit/Loss'), 0, 4, 0, $fill, NULL, 1); $rep->SetCellPadding($oldcMargin); for ($i = 1; $i <= 12; $i++) { $rep->AmountCol2($i, $i + 1, -$calc[$i], $dec, 0, 4, 0, $fill, NULL, 1, true); // no convert } $rep->Font(); $rep->End(); }
function show_results() { global $path_to_root, $table_style; if (!isset($_POST["account"]) || $_POST["account"] == "") { return; } $act_name = get_gl_account_name($_POST["account"]); $dim = get_company_pref('use_dimension'); /*Now get the transactions */ if (!isset($_POST['Dimension'])) { $_POST['Dimension'] = 0; } if (!isset($_POST['Dimension2'])) { $_POST['Dimension2'] = 0; } $result = get_gl_transactions($_POST['TransFromDate'], $_POST['TransToDate'], -1, $_POST["account"], $_POST['Dimension'], $_POST['Dimension2']); $colspan = $dim == 2 ? "6" : ($dim == 1 ? "5" : "4"); //echo "\nDimension =". $_POST['Dimension']; display_heading($_POST["account"] . " " . $act_name); start_table($table_style); if ($dim == 2) { $th = array(tr("Type"), tr("#"), tr("Date"), tr("Dimension") . " 1", tr("Dimension") . " 2", tr("Person/Item"), tr("Debit"), tr("Credit"), tr("Balance"), tr("Memo")); } else { if ($dim == 1) { $th = array(tr("Type"), tr("#"), tr("Date"), tr("Dimension"), tr("Person/Item"), tr("Debit"), tr("Credit"), tr("Balance"), tr("Memo")); } else { $th = array(tr("Type"), tr("#"), tr("Date"), tr("Person/Item"), tr("Debit"), tr("Credit"), tr("Balance"), tr("Memo")); } } table_header($th); if (is_account_balancesheet($_POST["account"])) { $begin = ""; } else { $begin = begin_fiscalyear(); if ($_POST['TransFromDate'] < $begin) { $begin = $_POST['TransFromDate']; } $begin = add_days($begin, -1); } $bfw = get_gl_balance_from_to($begin, $_POST['TransFromDate'], $_POST["account"], $_POST['Dimension'], $_POST['Dimension2']); start_row("class='inquirybg'"); label_cell("<b>" . tr("Opening Balance") . " - " . $_POST['TransFromDate'] . "</b>", "colspan={$colspan}"); display_debit_or_credit_cells($bfw); label_cell(""); end_row(); //$running_total =0; $running_total = $bfw; $j = 1; $k = 0; //row colour counter while ($myrow = db_fetch($result)) { alt_table_row_color($k); $running_total += $myrow["amount"]; $trandate = sql2date($myrow["tran_date"]); label_cell(systypes::name($myrow["type"])); label_cell(get_gl_view_str($myrow["type"], $myrow["type_no"], $myrow["type_no"], true)); label_cell($trandate); if ($dim >= 1) { label_cell(get_dimension_string($myrow['dimension_id'], true)); } if ($dim > 1) { label_cell(get_dimension_string($myrow['dimension2_id'], true)); } label_cell(payment_person_types::person_name($myrow["person_type_id"], $myrow["person_id"])); display_debit_or_credit_cells($myrow["amount"]); amount_cell($running_total); label_cell($myrow['memo_']); end_row(); $j++; if ($j == 12) { $j = 1; table_header($th); } } //end of while loop start_row("class='inquirybg'"); label_cell("<b>" . tr("Ending Balance") . " - " . $_POST['TransToDate'] . "</b>", "colspan={$colspan}"); display_debit_or_credit_cells($running_total); label_cell(""); end_row(); end_table(2); if (db_num_rows($result) == 0) { display_note(tr("No general ledger transactions have been created for this account on the selected dates."), 0, 1); } }
$th = array(_("Account Code"), _("Account Description"), _("Dimension"), _("Amount"), _("Memo")); } else { $th = array(_("Account Code"), _("Account Description"), _("Amount"), _("Memo")); } } table_header($th); $k = 0; //row colour counter $total_amount = 0; while ($item = db_fetch($items)) { if ($item["account"] != $to_trans["account_code"]) { alt_table_row_color($k); label_cell($item["account"]); label_cell($item["account_name"]); if ($dim >= 1) { label_cell(get_dimension_string($item['dimension_id'], true)); } if ($dim > 1) { label_cell(get_dimension_string($item['dimension2_id'], true)); } amount_cell(-$item["amount"]); label_cell($item["memo_"]); end_row(); $total_amount += $item["amount"]; } } label_row(_("Total"), number_format2(-$total_amount, user_price_dec()), "colspan=" . (2 + $dim) . " align=right", "align=right"); end_table(1); display_allocations_from($to_trans['person_type_id'], $to_trans['person_id'], 2, $trans_no, $to_trans['settled_amount']); } end_page(true, false, false, ST_BANKDEPOSIT, $trans_no);
function print_profit_and_loss_statement() { global $path_to_root; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $compare = $_POST['PARAM_2']; if ($dim == 2) { $dimension = $_POST['PARAM_3']; $dimension2 = $_POST['PARAM_4']; $tags = isset($_POST['PARAM_5']) ? $_POST['PARAM_5'] : -1; $decimals = $_POST['PARAM_6']; $graphics = $_POST['PARAM_7']; $comments = $_POST['PARAM_8']; $orientation = $_POST['PARAM_9']; $destination = $_POST['PARAM_10']; } else { if ($dim == 1) { $dimension = $_POST['PARAM_3']; $tags = isset($_POST['PARAM_4']) ? $_POST['PARAM_4'] : -1; $decimals = $_POST['PARAM_5']; $graphics = $_POST['PARAM_6']; $comments = $_POST['PARAM_7']; $orientation = $_POST['PARAM_8']; $destination = $_POST['PARAM_9']; } else { $tags = isset($_POST['PARAM_3']) ? $_POST['PARAM_3'] : -1; $decimals = $_POST['PARAM_4']; $graphics = $_POST['PARAM_5']; $comments = $_POST['PARAM_6']; $orientation = $_POST['PARAM_7']; $destination = $_POST['PARAM_8']; } } if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; if ($graphics) { include_once $path_to_root . "/reporting/includes/class.graphic.inc"; $pg = new graph(); } if (!$decimals) { $dec = 0; } else { $dec = user_price_dec(); } $pdec = user_percent_dec(); $cols = array(0, 50, 200, 350, 425, 500); //------------0--1---2----3----4----5-- $headers = array(_('Account'), _('Account Name'), _('Period'), _('Accumulated'), _('Achieved %')); $aligns = array('left', 'left', 'right', 'right', 'right'); if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => _('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => ''), 4 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => '')); } } if ($compare == 0 || $compare == 2) { $end = $to; if ($compare == 2) { $begin = $from; $headers[3] = _('Budget'); } else { $begin = begin_fiscalyear(); } } elseif ($compare == 1) { $begin = add_months($from, -12); $end = add_months($to, -12); $headers[3] = _('Period Y-1'); } $rep = new FrontReport(_('Profit and Loss Statement'), "ProfitAndLoss", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $salesper = 0.0; $salesacc = 0.0; $classresult = get_account_classes(false, 0); while ($class = db_fetch($classresult)) { $class_per_total = 0; $class_acc_total = 0; $convert = get_class_type_convert($class["ctype"]); //Print Class Name $rep->Font('bold'); $rep->TextCol(0, 5, $class["class_name"]); $rep->Font(); $rep->NewLine(); //Get Account groups/types under this group/type with no parents $typeresult = get_account_types(false, $class['cid'], -1); while ($accounttype = db_fetch($typeresult)) { $classtotal = display_type($accounttype["id"], $accounttype["name"], $from, $to, $begin, $end, $compare, $convert, $dec, $pdec, $rep, $dimension, $dimension2, $tags, $pg, $graphics); $class_per_total += $classtotal[0]; $class_acc_total += $classtotal[1]; } //Print Class Summary $rep->row += 6; $rep->Line($rep->row); $rep->NewLine(); $rep->Font('bold'); $rep->TextCol(0, 2, _('Total') . " " . $class["class_name"]); $rep->AmountCol(2, 3, $class_per_total * $convert, $dec); $rep->AmountCol(3, 4, $class_acc_total * $convert, $dec); $rep->AmountCol(4, 5, Achieve($class_per_total, $class_acc_total), $pdec); $rep->Font(); $rep->NewLine(2); $salesper += $class_per_total; $salesacc += $class_acc_total; } $rep->Font('bold'); $rep->TextCol(0, 2, _('Calculated Return')); $rep->AmountCol(2, 3, $salesper * -1, $dec); // always convert $rep->AmountCol(3, 4, $salesacc * -1, $dec); $rep->AmountCol(4, 5, Achieve($salesper, $salesacc), $pdec); if ($graphics) { $pg->x[] = _('Calculated Return'); $pg->y[] = abs($salesper); $pg->z[] = abs($salesacc); } $rep->Font(); $rep->NewLine(); $rep->Line($rep->row); if ($graphics) { global $decseps, $graph_skin; $pg->title = $rep->title; $pg->axis_x = _("Group"); $pg->axis_y = _("Amount"); $pg->graphic_1 = $headers[2]; $pg->graphic_2 = $headers[3]; $pg->type = $graphics; $pg->skin = $graph_skin; $pg->built_in = false; $pg->latin_notation = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != "."; $filename = company_path() . "/pdf_files/" . uniqid("") . ".png"; $pg->display($filename, true); $w = $pg->width / 1.5; $h = $pg->height / 1.5; $x = ($rep->pageWidth - $w) / 2; $rep->NewLine(2); if ($rep->row - $h < $rep->bottomMargin) { $rep->NewPage(); } $rep->AddImage($filename, $x, $rep->row - $h, $w, $h); } $rep->End(); }