function display_trial_balance() { global $table_style, $path_to_root; start_table($table_style); $tableheader = "<tr>\n <td rowspan=2 class='tableheader'>" . tr("Account") . "</td>\n <td rowspan=2 class='tableheader'>" . tr("Account Name") . "</td>\n\t\t<td colspan=2 class='tableheader'>" . tr("Brought Forward") . "</td>\n\t\t<td colspan=2 class='tableheader'>" . tr("This Period") . "</td>\n\t\t<td colspan=2 class='tableheader'>" . tr("Balance") . "</td>\n\t\t</tr><tr>\n\t\t<td class='tableheader'>" . tr("Debit") . "</td>\n <td class='tableheader'>" . tr("Credit") . "</td>\n\t\t<td class='tableheader'>" . tr("Debit") . "</td>\n\t\t<td class='tableheader'>" . tr("Credit") . "</td>\n <td class='tableheader'>" . tr("Debit") . "</td>\n <td class='tableheader'>" . tr("Credit") . "</td>\n </tr>"; echo $tableheader; $k = 0; $accounts = get_gl_accounts(); while ($account = db_fetch($accounts)) { if (is_account_balancesheet($account["account_code"])) { $begin = null; } else { $begin = begin_fiscalyear(); if ($_POST['TransFromDate'] < $begin) { $begin = $_POST['TransFromDate']; } $begin = add_days($begin, -1); } $prev_balance = get_balance($account["account_code"], $begin, $_POST['TransFromDate'], false, false); $curr_balance = get_balance($account["account_code"], $_POST['TransFromDate'], $_POST['TransToDate']); if (check_value("NoZero") && !$prev_balance && !$curr_balance) { continue; } alt_table_row_color($k); $url = "<a href='{$path_to_root}/gl/inquiry/gl_account_inquiry.php?" . SID . "TransFromDate=" . $_POST["TransFromDate"] . "&TransToDate=" . $_POST["TransToDate"] . "&account=" . $account["account_code"] . "'>" . $account["account_code"] . "</a>"; label_cell($url); label_cell($account["account_name"]); display_debit_or_credit_cells($prev_balance); display_debit_or_credit_cells($curr_balance); display_debit_or_credit_cells($prev_balance + $curr_balance); end_row(); } end_table(1); }
function display_type($type, $typename, &$dec, &$rep, $showbalance, $level) { $printtitle = 0; //Flag for printing type name //Get Accounts directly under this group/type $result = get_gl_accounts(null, null, $type); while ($account = db_fetch($result)) { //Print Type Title if it has atleast one non-zero account if (!$printtitle) { $prefix = ''; for ($sp = 1; $sp <= $level; $sp++) { $prefix .= ' '; } $printtitle = 1; $rep->row -= 4; $rep->TextCol(0, 1, $type); $rep->TextCol(1, 4, $prefix . $typename); $rep->row -= 4; $rep->Line($rep->row); $rep->NewLine(); } if ($showbalance == 1) { $begin = begin_fiscalyear(); if (is_account_balancesheet($account["account_code"])) { $begin = ""; } $balance = get_gl_trans_from_to($begin, ToDay(), $account["account_code"], 0); } $rep->TextCol(0, 1, $account['account_code']); $rep->TextCol(1, 2, $prefix . $account['account_name']); $rep->TextCol(2, 3, $account['account_code2']); if ($showbalance == 1) { $rep->AmountCol(3, 4, $balance, $dec); } $rep->NewLine(); } //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, 1, $type); $rep->TextCol(1, 4, $typename); $rep->row -= 4; $rep->Line($rep->row); $rep->NewLine(); } $nextlevel = $level + 1; display_type($accounttype["id"], $accounttype["name"] . ' (' . $typename . ')', $dec, $rep, $showbalance, $nextlevel); } }
function display_type($type, $typename, $from, $to, $convert, $dimension, $dimension2, $drilldown, $path_to_root) { global $levelptr, $k; $acctstotal = 0; $typestotal = 0; //Get Accounts directly under this group/type $result = get_gl_accounts(null, null, $type); while ($account = db_fetch($result)) { $net_balance = get_gl_trans_from_to("", $to, $account["account_code"], $dimension, $dimension2); if (!$net_balance) { continue; } if ($drilldown && $levelptr == 0) { $url = "<a href='{$path_to_root}/gl/inquiry/gl_account_inquiry.php?TransFromDate=" . $from . "&TransToDate=" . $to . "&Dimension=" . $dimension . "&Dimension2=" . $dimension2 . "&account=" . $account['account_code'] . "'>" . $account['account_code'] . " " . $account['account_name'] . "</a>"; start_row("class='stockmankobg'"); label_cell($url); amount_cell($net_balance * $convert); end_row(); } $acctstotal += $net_balance; } $levelptr = 1; //Get Account groups/types under this group/type $result = get_account_types(false, false, $type); while ($accounttype = db_fetch($result)) { $typestotal += display_type($accounttype["id"], $accounttype["name"], $from, $to, $convert, $dimension, $dimension2, $drilldown, $path_to_root); } //Display Type Summary if total is != 0 if ($acctstotal + $typestotal != 0) { if ($drilldown && $type == $_POST["AccGrp"]) { start_row("class='inquirybg' style='font-weight:bold'"); label_cell(_('Total') . " " . $typename); amount_cell(($acctstotal + $typestotal) * $convert); end_row(); } //START Patch#1 : Display only direct child types $acctype1 = get_account_type($type); $parent1 = $acctype1["parent"]; if ($drilldown && $parent1 == $_POST["AccGrp"]) { $url = "<a href='{$path_to_root}/gl/inquiry/balance_sheet.php?TransFromDate=" . $from . "&TransToDate=" . $to . "&Dimension=" . $dimension . "&Dimension2=" . $dimension2 . "&AccGrp=" . $type . "'>" . $type . " " . $typename . "</a>"; alt_table_row_color($k); label_cell($url); amount_cell(($acctstotal + $typestotal) * $convert); end_row(); } } return $acctstotal + $typestotal; }
function display_type($type, $typename, $from, $to, $begin, $end, $compare, $convert, &$dec, &$pdec, &$rep, $dimension = 0, $dimension2 = 0, $drilldown, $path_to_root) { global $levelptr, $k; $code_per_balance = 0; $code_acc_balance = 0; $per_balance_total = 0; $acc_balance_total = 0; unset($totals_arr); $totals_arr = array(); //Get Accounts directly under this group/type $result = get_gl_accounts(null, null, $type); while ($account = db_fetch($result)) { $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 ($drilldown && $levelptr == 0) { $url = "<a href='{$path_to_root}/gl/inquiry/gl_account_inquiry.php?TransFromDate=" . $from . "&TransToDate=" . $to . "&Dimension=" . $dimension . "&Dimension2=" . $dimension2 . "&account=" . $account['account_code'] . "'>" . $account['account_code'] . " " . $account['account_name'] . "</a>"; start_row("class='stockmankobg'"); label_cell($url); amount_cell($per_balance * $convert); amount_cell($acc_balance * $convert); amount_cell(Achieve($per_balance, $acc_balance)); end_row(); } $code_per_balance += $per_balance; $code_acc_balance += $acc_balance; } $levelptr = 1; //Get Account groups/types under this group/type $result = get_account_types(false, false, $type); while ($accounttype = db_fetch($result)) { $totals_arr = display_type($accounttype["id"], $accounttype["name"], $from, $to, $begin, $end, $compare, $convert, $dec, $pdec, $rep, $dimension, $dimension2, $drilldown, $path_to_root); $per_balance_total += $totals_arr[0]; $acc_balance_total += $totals_arr[1]; } //Display Type Summary if total is != 0 if ($code_per_balance + $per_balance_total + $code_acc_balance + $acc_balance_total != 0) { if ($drilldown && $type == $_POST["AccGrp"]) { start_row("class='inquirybg' style='font-weight:bold'"); label_cell(_('Total') . " " . $typename); amount_cell(($code_per_balance + $per_balance_total) * $convert); amount_cell(($code_acc_balance + $acc_balance_total) * $convert); amount_cell(Achieve($code_per_balance + $per_balance_total, $code_acc_balance + $acc_balance_total)); end_row(); } //START Patch#1 : Display only direct child types $acctype1 = get_account_type($type); $parent1 = $acctype1["parent"]; if ($drilldown && $parent1 == $_POST["AccGrp"]) { $url = "<a href='{$path_to_root}/gl/inquiry/profit_loss.php?TransFromDate=" . $from . "&TransToDate=" . $to . "&Compare=" . $compare . "&Dimension=" . $dimension . "&Dimension2=" . $dimension2 . "&AccGrp=" . $type . "'>" . $type . " " . $typename . "</a>"; alt_table_row_color($k); label_cell($url); amount_cell(($code_per_balance + $per_balance_total) * $convert); amount_cell(($code_acc_balance + $acc_balance_total) * $convert); amount_cell(Achieve($code_per_balance + $per_balance_total, $code_acc_balance + $acc_balance_total)); end_row(); } } $totals_arr[0] = $code_per_balance + $per_balance_total; $totals_arr[1] = $code_acc_balance + $acc_balance_total; return $totals_arr; }
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 display_type($type, $typename, &$dec, &$rep, $from, $to, $zero, $balances, $dimension, $dimension2) { global $pdeb, $pcre, $cdeb, $ccre, $tdeb, $tcre, $pbal, $cbal, $tbal, $clear_trial_balance_opening; $printtitle = 0; //Flag for printing type name //Get Accounts directly under this group/type $accounts = get_gl_accounts(null, null, $type); $begin = get_fiscalyear_begin_for_date($from); if (date1_greater_date2($begin, $from)) { $begin = $from; } $begin = add_days($begin, -1); while ($account = db_fetch($accounts)) { //Print Type Title if it has atleast one non-zero account if (!$printtitle) { $rep->row -= 4; $rep->TextCol(0, 8, _("Group") . " - " . $type . " - " . $typename); $printtitle = 1; $rep->row -= 4; $rep->Line($rep->row); $rep->NewLine(); } // FA doesn't really clear the closed year, therefore the brought forward balance includes all the transactions from the past, even though the balance is null. // If we want to remove the balanced part for the past years, this option removes the common part from from the prev and tot figures. if (@$clear_trial_balance_opening) { $open = get_balance($account["account_code"], $dimension, $dimension2, $begin, $begin, false, true); $offset = min($open['debit'], $open['credit']); } else { $offset = 0; } $prev = get_balance($account["account_code"], $dimension, $dimension2, $begin, $from, false, false); $curr = get_balance($account["account_code"], $dimension, $dimension2, $from, $to, true, true); $tot = get_balance($account["account_code"], $dimension, $dimension2, $begin, $to, false, true); if ($zero == 0 && !$prev['balance'] && !$curr['balance'] && !$tot['balance']) { continue; } $rep->TextCol(0, 1, $account['account_code']); $rep->TextCol(1, 2, $account['account_name']); if ($balances != 0) { if ($prev['balance'] >= 0.0) { $rep->AmountCol(2, 3, $prev['balance'], $dec); } else { $rep->AmountCol(3, 4, abs($prev['balance']), $dec); } if ($curr['balance'] >= 0.0) { $rep->AmountCol(4, 5, $curr['balance'], $dec); } else { $rep->AmountCol(5, 6, abs($curr['balance']), $dec); } if ($tot['balance'] >= 0.0) { $rep->AmountCol(6, 7, $tot['balance'], $dec); } else { $rep->AmountCol(7, 8, abs($tot['balance']), $dec); } } else { $rep->AmountCol(2, 3, $prev['debit'] - $offset, $dec); $rep->AmountCol(3, 4, $prev['credit'] - $offset, $dec); $rep->AmountCol(4, 5, $curr['debit'], $dec); $rep->AmountCol(5, 6, $curr['credit'], $dec); $rep->AmountCol(6, 7, $tot['debit'] - $offset, $dec); $rep->AmountCol(7, 8, $tot['credit'] - $offset, $dec); $pdeb += $prev['debit'] - $offset; $pcre += $prev['credit'] - $offset; $cdeb += $curr['debit']; $ccre += $curr['credit']; $tdeb += $tot['debit'] - $offset; $tcre += $tot['credit'] - $offset; } $pbal += $prev['balance']; $cbal += $curr['balance']; $tbal += $tot['balance']; $rep->NewLine(); if ($rep->row < $rep->bottomMargin + $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->NewPage(); } } //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) { $rep->row -= 4; $rep->TextCol(0, 8, _("Group") . " - " . $type . " - " . $typename); $printtitle = 1; $rep->row -= 4; $rep->Line($rep->row); $rep->NewLine(); } display_type($accounttype["id"], $accounttype["name"] . ' (' . $typename . ')', $dec, $rep, $from, $to, $zero, $balances, $dimension, $dimension2); } }
function print_check_voucher() { global $path_to_root, $systypes_array; $trans_no = $_POST['PARAM_0']; $trans_num = $_POST['PARAM_1']; $orientation = $_POST['PARAM_2']; $destination = $_POST['PARAM_3']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report2.inc"; } $orientation = $orientation ? 'L' : 'P'; $rep = new FrontReport(_('JOURNAL VOUCHER'), "JournalVoucher", user_pagesize(), 9, $orientation); $dec = user_price_dec(); $cols = array(0, 65, 105, 125, 175, 210, 250, 300, 360, 370); $aligns = array('left', 'left', 'left', 'center', 'right', 'right', 'right', 'right', 'right'); $rep->SetHeaderType(0); $rep->Font(); $rep->Info(null, $cols, null, $aligns); $rep->NewPage(); $res = get_transaction($trans_no); $myrow = db_fetch($res); $credit = $debit = 0; $res2 = get_gl_trans(0, $trans_num); $res3 = get_gl_trans(0, $trans_num); $fiscal = get_year(); //to be use $year_no = substr(sql2date($fiscal['begin']), 8); //to be use $transtype = ST_JOURNAL; $ser = db_fetch(get_used_series($year_no, $transtype)); $num = substr($ser['year'], 2); $rep->Font('bold'); //$rep->TextCol(7,11, _("ST. MATTHEW'S PUBLISHING CORPORATION")); $rep->Font(); $rep->NewLine(); // $rep->TextCol(7,11, _("Tel. Nos. 426-5611 * 433-5385 Telefax: 426-1274")); $rep->NewLine(3); //$rep->Font('bold'); //$rep->SetFontSize(14); //$rep->TextCol(3,8, _("JOURNAL VOUCHER")); $rep->NewLine(5); $rep->SetFontSize(10); $rep->TextCol(0, 2, $myrow['tranDate']); $rep->SetFontSize(12); $rep->TextCol(6, 8, $num . "-" . str_pad($myrow['customized_no'], 4, 0, STR_PAD_LEFT)); $rep->NewLine(2); //$rep->Line($rep->row - -10); // $rep->TextCol(7,8, _("DEBIT")); //$rep->TextCol(9,10, _("CREDIT")); //$rep->TextCol(5,7, _("ACCOUNT CODE")); $rep->SetFontSize(10); $rep->Font(); //$rep->Line($rep->row - 4); $rep->NewLine(2); while ($myrow3 = db_fetch($res3)) { $accounts = get_gl_accounts($myrow3['account']); $account = db_fetch($accounts); if ($myrow3['amount'] > 0) { $rep->TextCol(0, 3, $account['account_name']); $rep->TextCol(4, 5, $account['account_code']); $rep->AmountCol(5, 7, $myrow3['amount'], 2); $rep->NewLine(); $debit += $myrow3['amount']; } else { $rep->TextCol(0, 3, $account['account_name']); $rep->TextCol(4, 5, $account['account_code']); $rep->AmountCol(7, 9, abs($myrow3['amount']), 2); $rep->NewLine(); $credit += abs($myrow3['amount']); } } // $rep->Line($rep->row - -4); $rep->NewLine(17); $rep->Font('bold'); //$rep->TextCol(0,4, _("Total")); $rep->AmountCol(5, 7, $debit, 2); $rep->AmountCol(7, 9, $credit, 2); $rep->NewLine(2); $rep->Font(); $comment = get_comments_string($transtype, $trans_num); $rep->TextCol(0, 9, $comment); // $rep->Line($rep->row - 4); $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 display_type($type, $typename, $yr, $mo, $convert, &$dec, &$rep, $dimension, $dimension2, $tags) { $ctotal = array(1 => 0, 0, 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, 0, 0); $totals_arr = array(); $printtitle = 0; //Flag for printing type name //Get Accounts directly under this group/type $result = get_gl_accounts(null, null, $type); while ($account = db_fetch($result)) { if ($tags != -1 && is_array($tags) && $tags[0] != false) { if (!is_record_in_tags($tags, TAG_ACCOUNT, $account['account_code'])) { continue; } } $bal = getPeriods($yr, $mo, $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; } //Print Type Title if it has atleast one non-zero account if (!$printtitle) { $printtitle = 1; $rep->row -= 4; $rep->TextCol(0, 5, $typename); $rep->row -= 4; $rep->Line($rep->row); $rep->NewLine(); } $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']); $rep->TextCol(0, 1, $account['account_code']); $rep->TextCol(1, 2, $account['account_name']); for ($i = 1; $i <= 12; $i++) { $rep->AmountCol($i + 1, $i + 2, $balance[$i] * $convert, $dec); $ctotal[$i] += $balance[$i]; } $rep->NewLine(); } //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"], $yr, $mo, $convert, $dec, $rep, $dimension, $dimension2, $tags); for ($i = 1; $i <= 12; $i++) { $total[$i] += $totals_arr[$i]; } } //Display Type Summary if total is != 0 OR head is printed (Needed in case of unused hierarchical COA) if ($printtitle) { $rep->row += 6; $rep->Line($rep->row); $rep->NewLine(); $rep->TextCol(0, 2, _('Total') . " " . $typename); for ($i = 1; $i <= 12; $i++) { $rep->AmountCol($i + 1, $i + 2, ($total[$i] + $ctotal[$i]) * $convert, $dec); } $rep->NewLine(); } for ($i = 1; $i <= 12; $i++) { $totals_arr[$i] = $total[$i] + $ctotal[$i]; } return $totals_arr; }
function display_trial_balance($type, $typename) { global $path_to_root; global $k, $pdeb, $pcre, $cdeb, $ccre, $tdeb, $tcre, $pbal, $cbal, $tbal; $printtitle = 0; //Flag for printing type name $k = 0; //$accounts = get_gl_accounts(); //Get Accounts directly under this group/type $accounts = get_gl_accounts(null, null, $type); $begin = get_fiscalyear_begin_for_date($_POST['TransFromDate']); //$begin = begin_fiscalyear(); if (date1_greater_date2($begin, $_POST['TransFromDate'])) { $begin = $_POST['TransFromDate']; } $begin = add_days($begin, -1); while ($account = db_fetch($accounts)) { //Print Type Title if it has atleast one non-zero account if ($type == 3502) { continue; } if (!$printtitle) { start_row("class='inquirybg' style='font-weight:bold'"); label_cell(_("Group") . " - " . $type . " - " . $typename, "colspan=8"); end_row(); $printtitle = 1; } $prev = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $begin, $_POST['TransFromDate'], false, false); $curr = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $_POST['TransFromDate'], $_POST['TransToDate'], true, true); $tot = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $begin, $_POST['TransToDate'], false, true); if (check_value("NoZero") && !$prev['balance'] && !$curr['balance'] && !$tot['balance']) { continue; } alt_table_row_color($k); $url = "<a href='{$path_to_root}/gl/inquiry/gl_account_inquiry.php?TransFromDate=" . $_POST["TransFromDate"] . "&TransToDate=" . $_POST["TransToDate"] . "&account=" . $account["account_code"] . "&Dimension=" . $_POST["Dimension"] . "&Dimension2=" . $_POST["Dimension2"] . "'>" . $account["account_code"] . "</a>"; label_cell($url); label_cell($account["account_name"]); if (check_value('Balance')) { display_debit_or_credit_cells($prev['balance']); display_debit_or_credit_cells($curr['balance']); display_debit_or_credit_cells($tot['balance']); } else { amount_cell($prev['debit']); amount_cell($prev['credit']); amount_cell($curr['debit']); amount_cell($curr['credit']); amount_cell($tot['debit']); amount_cell($tot['credit']); $pdeb += $prev['debit']; $pcre += $prev['credit']; $cdeb += $curr['debit']; $ccre += $curr['credit']; $tdeb += $tot['debit']; $tcre += $tot['credit']; } $pbal += $prev['balance']; $cbal += $curr['balance']; $tbal += $tot['balance']; end_row(); } //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) { start_row("class='inquirybg' style='font-weight:bold'"); label_cell(_("Group") . " - " . $type . " - " . $typename, "colspan=8"); end_row(); $printtitle = 1; } display_trial_balance($accounttype["id"], $accounttype["name"] . ' (' . $typename . ')'); } }
function display_trial_balance($type, $typename) { global $path_to_root, $clear_trial_balance_opening; global $k, $pdeb, $pcre, $cdeb, $ccre, $tdeb, $tcre, $pbal, $cbal, $tbal; $printtitle = 0; //Flag for printing type name $k = 0; //$accounts = get_gl_accounts(); //Get Accounts directly under this group/type $accounts = get_gl_accounts(null, null, $type); $begin = get_fiscalyear_begin_for_date($_POST['TransFromDate']); //$begin = begin_fiscalyear(); if (date1_greater_date2($begin, $_POST['TransFromDate'])) { $begin = $_POST['TransFromDate']; } $begin = add_days($begin, -1); while ($account = db_fetch($accounts)) { //Print Type Title if it has atleast one non-zero account if (!$printtitle) { start_row("class='inquirybg' style='font-weight:bold'"); label_cell(_("Group") . " - " . $type . " - " . $typename, "colspan=8"); end_row(); $printtitle = 1; } // FA doesn't really clear the closed year, therefore the brought forward balance includes all the transactions from the past, even though the balance is null. // If we want to remove the balanced part for the past years, this option removes the common part from from the prev and tot figures. if (@$clear_trial_balance_opening) { $open = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $begin, $begin, false, true); $offset = min($open['debit'], $open['credit']); } else { $offset = 0; } $prev = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $begin, $_POST['TransFromDate'], false, false); $curr = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $_POST['TransFromDate'], $_POST['TransToDate'], true, true); $tot = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $begin, $_POST['TransToDate'], false, true); if (check_value("NoZero") && !$prev['balance'] && !$curr['balance'] && !$tot['balance']) { continue; } alt_table_row_color($k); $url = "<a href='{$path_to_root}/gl/inquiry/gl_account_inquiry.php?TransFromDate=" . $_POST["TransFromDate"] . "&TransToDate=" . $_POST["TransToDate"] . "&account=" . $account["account_code"] . "&Dimension=" . $_POST["Dimension"] . "&Dimension2=" . $_POST["Dimension2"] . "'>" . $account["account_code"] . "</a>"; label_cell($url); label_cell($account["account_name"]); if (check_value('Balance')) { display_debit_or_credit_cells($prev['balance']); display_debit_or_credit_cells($curr['balance']); display_debit_or_credit_cells($tot['balance']); } else { amount_cell($prev['debit'] - $offset); amount_cell($prev['credit'] - $offset); amount_cell($curr['debit']); amount_cell($curr['credit']); amount_cell($tot['debit'] - $offset); amount_cell($tot['credit'] - $offset); $pdeb += $prev['debit']; $pcre += $prev['credit']; $cdeb += $curr['debit']; $ccre += $curr['credit']; $tdeb += $tot['debit']; $tcre += $tot['credit']; } $pbal += $prev['balance']; $cbal += $curr['balance']; $tbal += $tot['balance']; end_row(); } //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) { start_row("class='inquirybg' style='font-weight:bold'"); label_cell(_("Group") . " - " . $type . " - " . $typename, "colspan=8"); end_row(); $printtitle = 1; } display_trial_balance($accounttype["id"], $accounttype["name"] . ' (' . $typename . ')'); } }
function display_type($type, $typename, &$dec, &$rep, $from, $to, $zero, $balances, $dimension, $dimension2) { global $pdeb, $pcre, $cdeb, $ccre, $tdeb, $tcre, $pbal, $cbal, $tbal; $printtitle = 0; //Flag for printing type name //Get Accounts directly under this group/type $accounts = get_gl_accounts(null, null, $type); $begin = get_fiscalyear_begin_for_date($from); if (date1_greater_date2($begin, $from)) { $begin = $from; } $begin = add_days($begin, -1); while ($account = db_fetch($accounts)) { //Print Type Title if it has atleast one non-zero account if (!$printtitle) { $rep->row -= 4; $rep->TextCol(0, 8, _("Group") . " - " . $type . " - " . $typename); $printtitle = 1; $rep->row -= 4; $rep->Line($rep->row); $rep->NewLine(); } $prev = get_balance($account["account_code"], $dimension, $dimension2, $begin, $from, false, false); $curr = get_balance($account["account_code"], $dimension, $dimension2, $from, $to, true, true); $tot = get_balance($account["account_code"], $dimension, $dimension2, $begin, $to, false, true); if ($zero == 0 && !$prev['balance'] && !$curr['balance'] && !$tot['balance']) { continue; } $rep->TextCol(0, 1, $account['account_code']); $rep->TextCol(1, 2, $account['account_name']); if ($balances != 0) { if ($prev['balance'] >= 0.0) { $rep->AmountCol(2, 3, $prev['balance'], $dec); } else { $rep->AmountCol(3, 4, abs($prev['balance']), $dec); } if ($curr['balance'] >= 0.0) { $rep->AmountCol(4, 5, $curr['balance'], $dec); } else { $rep->AmountCol(5, 6, abs($curr['balance']), $dec); } if ($tot['balance'] >= 0.0) { $rep->AmountCol(6, 7, $tot['balance'], $dec); } else { $rep->AmountCol(7, 8, abs($tot['balance']), $dec); } } else { $rep->AmountCol(2, 3, $prev['debit'], $dec); $rep->AmountCol(3, 4, $prev['credit'], $dec); $rep->AmountCol(4, 5, $curr['debit'], $dec); $rep->AmountCol(5, 6, $curr['credit'], $dec); $rep->AmountCol(6, 7, $tot['debit'], $dec); $rep->AmountCol(7, 8, $tot['credit'], $dec); $pdeb += $prev['debit']; $pcre += $prev['credit']; $cdeb += $curr['debit']; $ccre += $curr['credit']; $tdeb += $tot['debit']; $tcre += $tot['credit']; } $pbal += $prev['balance']; $cbal += $curr['balance']; $tbal += $tot['balance']; $rep->NewLine(); if ($rep->row < $rep->bottomMargin + $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->NewPage(); } } //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) { $rep->row -= 4; $rep->TextCol(0, 8, _("Group") . " - " . $type . " - " . $typename); $printtitle = 1; $rep->row -= 4; $rep->Line($rep->row); $rep->NewLine(); } display_type($accounttype["id"], $accounttype["name"] . ' (' . $typename . ')', $dec, $rep, $from, $to, $zero, $balances, $dimension, $dimension2); } }
function print_subsidiary_ledger() { 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']; $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_report2.inc"; } $orientation = $orientation ? 'L' : 'P'; $rep = new FrontReport(_('Subsidiary Ledger Report'), "SubsidiaryLedger", user_pagesize(), 9, $orientation); $dec = user_price_dec(); //$headers = array(_('Type'), _('Ref'), _('#'), _('Date'), _('Dimension')." 1", _('Dimension')." 2", // _('Person/Item'), _('Debit'), _('Credit'), _('Balance')); //$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', 'center', 'left', 'left', 'left', 'right', 'right', 'right', 'right'); $headers = array(_('Account Name'), '', '', '', '', '', _('Debit'), _('Credit'), '', _('Balance')); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $fromacc)); if ($orientation == 'L') { recalculate_cols($cols); } $rep->SetHeaderType('Header_custom'); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $accounts = get_gl_accounts($fromacc, $fromacc); 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) { $previous = ''; while ($myrow = db_fetch($trans)) { $total += $myrow['amount']; $txt = payment_person_name($myrow["person_type_id"], $myrow["person_id"], false); $current = $txt; $memo = $myrow['memo_']; if ($txt != "") { if ($previous == $current) { $txt = ''; } else { $rep->NewLine(1); $rep->Line($rep->row - $rep->lineHeight + 4); $rep->NewLine(2, 0); $rep->TextCol(3, 8, $txt, -2); $rep->Line($rep->row - $rep->lineHeight + 4); $rep->NewLine(2, 1); $rep->NewLine(1); } $previous = $current; } $rep->TextCol(0, 3, $systypes_array[$myrow["type"]], -2); $rep->DateCol(4, 6, $myrow["tran_date"], true); if ($myrow['amount'] > 0.0) { $rep->AmountCol(6, 7, abs($myrow['amount']), $dec); } else { $rep->AmountCol(7, 8, abs($myrow['amount']), $dec); } $rep->TextCol(8, 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->End(); }
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 display_type($type, $typename, $from, $to, $convert, &$dec, &$rep, $dimension, $dimension2, $tags, &$pg, $graphics) { $code_open_balance = 0; $code_period_balance = 0; $open_balance_total = 0; $period_balance_total = 0; $totals_arr = array(); $printtitle = 0; //Flag for printing type name //Get Accounts directly under this group/type $result = get_gl_accounts(null, null, $type); while ($account = db_fetch($result)) { if ($tags != -1 && is_array($tags) && $tags[0] != false) { if (!is_record_in_tags($tags, TAG_ACCOUNT, $account['account_code'])) { continue; } } $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; } //Print Type Title if it has atleast one non-zero account if (!$printtitle) { $printtitle = 1; $rep->row -= 4; $rep->TextCol(0, 5, $typename); $rep->row -= 4; $rep->Line($rep->row); $rep->NewLine(); } $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); $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) { $pg->x[] = $typename; $pg->y[] = abs($code_open_balance + $open_balance_total); $pg->z[] = abs($code_period_balance + $period_balance_total); } $rep->NewLine(); } $totals_arr[0] = $code_open_balance + $open_balance_total; $totals_arr[1] = $code_period_balance + $period_balance_total; return $totals_arr; }
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_check_voucher() { global $path_to_root, $systypes_array; $trans_no = $_POST['PARAM_0']; $trans_num = $_POST['PARAM_1']; $cv_no = $_POST['PARAM_2']; $account = $_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_report2.inc"; } $orientation = $orientation ? 'L' : 'P'; $rep = new FrontReport(_('CHECK VOUCHER'), "CheckVoucher", user_pagesize(), '', $orientation); $dec = user_price_dec(); $cols = array(0, 30, 50, 125, 175, 200, 265, 285, 360, 425, 460, 542, 550); $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'left', 'left', 'right', 'right', 'right'); $rep->SetHeaderType(0); $rep->Font(); $rep->Info(null, $cols, null, $aligns); $rep->NewPage(); $ty = explode("-", $trans_no); $t_type = $ty[1]; if ($t_type != 0) { $res = get_transaction($trans_no, $t_type); $res1 = get_heading($trans_no, $t_type); } else { $res = get_transaction($trans_no, ST_DISBURSEMENT); $res1 = get_heading($trans_no, ST_DISBURSEMENT); } $myrow = db_fetch($res); $myrow1 = db_fetch($res1); $credit = $debit = 0; //$transtype = ST_DISBURSEMENT; if ($t_type != 0 || $t_type != '') { $res2 = get_gl_trans($t_type, $trans_num); $res3 = get_gl_trans($t_type, $trans_num); } else { $res2 = get_gl_trans(ST_DISBURSEMENT, $trans_num); $res3 = get_gl_trans(ST_DISBURSEMENT, $trans_num); } $new_ret = 0; $return = 0; //$fiscal = get_year(); //to be use // $year_no = substr(sql2date($fiscal['begin']), 8); //to be use // $ser = db_fetch(get_used_series($year_no, $transtype)); // $num = substr($ser['year'], 2); /* $rep->Font('bold'); $rep->TextCol(7,11, _("ST. MATTHEW'S PUBLISHING CORPORATION")); $rep->Font(); $rep->NewLine(); $rep->TextCol(7,11, _("Tel. Nos. 426-5611 * 433-5385 Telefax: 426-1274")); $rep->NewLine(3); $rep->Font('bold'); $rep->SetFontSize(14); $rep->TextCol(5,8, _("CHECK VOUCHER"));*/ $rep->NewLine(7); $rep->SetFontSize(12); $num = substr($myrow['yearDate'], 2); $name = payment_person_name($myrow["person_type_id"], $myrow["person_id"]); $rep->TextCol(2, 6, $name); $rep->TextCol(9, 11, $num . "-" . str_pad($myrow1['customized_no'], 4, 0, STR_PAD_LEFT)); $rep->NewLine(); if ($myrow1['customized_field'] != 0 || $myrow1['customized_field'] != '') { $rep->TextCol(0, 4, $myrow1['customized_field']); } else { $rep->TextCol(0, 4, _("")); } $rep->NewLine(1); $rep->TextCol(8, 10, $myrow['sqldate']); $rep->NewLine(5); // $rep->Line($rep->row - -10); // $rep->TextCol(4,6, _("PARTICULARS")); // $rep->TextCol(9,10, _("AMOUNT")); // $rep->Line($rep->row - 4); $var = array(); $pos = array(); $neg = array(); $pos_amt = array(); $neg_amt = array(); $tots = 0; $comment = get_comments_string($cv_no, $trans_num); while ($myrow2 = db_fetch($res2)) { $tots = 0; if (is_bank_account($myrow2['account'])) { $var = array($myrow2['account']); $rep->TextCol(1, 8, $comment); $tots += abs($myrow2['amount']); } } $rep->AmountCol(9, 11, $tots, 2); $rep->NewLine(2); // $rep->Line($rep->row - -10); // $rep->TextCol(1,3, _("DEBIT")); // $rep->TextCol(7,8, _("CREDIT")); // $rep->Line($rep->row - 4); $rep->NewLine(5); $rep->SetFontSize(12); while ($myrow3 = db_fetch($res3)) { $accounts = get_gl_accounts($myrow3['account']); $account = db_fetch($accounts); if ($myrow3['amount'] > 0) { // $rep->Line($rep->row - -10); //$rep->TextCol(0,4, $account['account_name']); // $rep->AmountCol(5,6, $myrow3['amount'],2); // $rep->NewLine(); // $rep->Line($rep->row + 8); array_push($pos, $account['account_name']); array_push($pos_amt, $myrow3['amount']); $debit += $myrow3['amount']; } else { array_push($neg, $account['account_name']); array_push($neg_amt, $myrow3['amount']); // $rep->Line($rep->row - 4); // $rep->TextCol(6,8, $account['account_name']); // $rep->AmountCol(9,11, abs($myrow3['amount']), 2); // $rep->NewLine(); // $rep->Line($rep->row - 4); } } $result = array_merge($pos, $neg); $new = array(); for ($i = 0; $i < count($result); $i++) { $new[] = $pos[$i]; $new[] = $neg[$i]; } $result2 = array_merge($pos_amt, $neg_amt); $new2 = array(); for ($j = 0; $j < count($result2); $j++) { $new2[] = $pos_amt[$j]; $new2[] = $neg_amt[$j]; } $final_res = array_merge($new, $new2); $final_array = array(); $final = array(); for ($k = 0; $k < count($final_res); $k++) { $final[] = $new[$k]; $final[] = $new2[$k]; } $enter = 0; for ($i = 0; $i <= count($final_res); $i++) { //if ($final[$i] != 0) //{ $rep->TextCol(0, 4, $pos[$i]); if ($pos_amt[$i] != 0) { $rep->AmountCol(4, 6, $pos_amt[$i], 2); } $rep->TextCol(7, 9, $neg[$i]); if ($neg_amt[$i] != 0) { $rep->AmountCol(9, 11, abs($neg_amt[$i]), 2); } if ($pos[$i] != "") { $rep->NewLine(); $enter++; } // } } $return = 11 - $enter; //$rep->Line($rep->row - 4); $rep->NewLine($return); //$rep->TextCol(0,2, count($final_res)); //$rep->TextCol(4,5, $enter); //else // $rep->NewLine($return); $rep->SetFontSize(10); // $rep->TextCol(0,2, _("Cash")); $words = price_in_words($tots, ST_CHEQUE); $_word = strlen($words); $first_word = substr($words, 0, 34); $second_word = substr($words, 34); // if ($words != "") // { //$rep->TextCol(5,7, _("Received the sum of :")); // $oldrow = $rep->row; $rep->TextColLines(8, 11, $first_word . "-", -2); //$newrow = $rep->row; // $rep->row = $oldrow; // } $rep->SetFontSize(10); $rep->TextCol(1, 3, $myrow1['check_num']); $tots_dec = price_format($tots); $rep->TextCol(3, 7, " " . $tots_dec); $rep->SetFontSize(10); $rep->TextCol(7, 11, $second_word); //$rep->TextCol(7,10, _("as payment of the above particulars.")); $rep->NewLine(); $rep->SetFontSize(10); //$rep->TextCol(0,10, _("Bank/Branch: ")); foreach ($var as $vars) { // $bank_name = get_bank_name($vars); $rep->TextCol(2, 10, get_bank_name($vars) . " "); } // $rep->TextCol(1,5, $myrow['bank_address']); $rep->TextCol(7, 9, " " . $tots_dec); $rep->End(); }