Ejemplo n.º 1
0
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);
}
Ejemplo n.º 2
0
function can_process()
{
    if (!check_num('po_over_receive', 0, 100)) {
        display_error(_("The delivery over-receive allowance must be between 0 and 100."));
        set_focus('po_over_receive');
        return false;
    }
    if (!check_num('po_over_charge', 0, 100)) {
        display_error(_("The invoice over-charge allowance must be between 0 and 100."));
        set_focus('po_over_charge');
        return false;
    }
    if (!check_num('past_due_days', 0, 100)) {
        display_error(_("The past due days interval allowance must be between 0 and 100."));
        set_focus('past_due_days');
        return false;
    }
    $grn_act = get_company_pref('grn_clearing_act');
    if (get_post('grn_clearing_act') != $grn_act && db_num_rows(get_grn_items(0, '', true))) {
        display_error(_("Before GRN Clearing Account can be changed all GRNs have to be invoiced"));
        $_POST['grn_clearing_act'] = $grn_act;
        set_focus('grn_clearing_account');
        return false;
    }
    if (!is_account_balancesheet(get_post('retained_earnings_act')) || is_account_balancesheet(get_post('profit_loss_year_act'))) {
        display_error(_("The Retained Earnings Account should be a Balance Account or the Profit and Loss Year Account should be an Expense Account (preferred the last one in the Expense Class)"));
        return false;
    }
    return true;
}
Ejemplo n.º 3
0
function print_Chart_of_Accounts()
{
    global $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $showbalance = $_REQUEST['PARAM_0'];
    $comments = $_REQUEST['PARAM_1'];
    $dec = 0;
    $cols = array(0, 50, 300, 425, 500);
    $headers = array(tr('Account'), tr('Account Name'), tr('Account Code'), tr('Balance'));
    $aligns = array('left', 'left', 'left', 'right');
    $params = array(0 => $comments);
    $rep = new FrontReport(tr('Chart of Accounts'), "ChartOfAccounts.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    $classname = '';
    $group = '';
    $accounts = get_gl_accounts_all();
    while ($account = db_fetch($accounts)) {
        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);
        }
        if ($account['AccountTypeName'] != $group) {
            if ($classname != '') {
                $rep->row -= 4;
            }
            if ($account['AccountClassName'] != $classname) {
                $rep->Font('bold');
                $rep->TextCol(0, 4, $account['AccountClassName']);
                $rep->Font();
                $rep->row -= $rep->lineHeight + 4;
            }
            $group = $account['AccountTypeName'];
            $rep->TextCol(0, 4, $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']);
        $rep->TextCol(2, 3, $account['account_code2']);
        if ($showbalance == 1) {
            $rep->TextCol(3, 4, number_format2($balance, $dec));
        }
        $rep->NewLine();
        if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight) {
            $rep->Line($rep->row - 2);
            $rep->Header();
        }
    }
    $rep->Line($rep->row);
    $rep->End();
}
Ejemplo n.º 4
0
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);
    }
}
Ejemplo n.º 5
0
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();
}
Ejemplo n.º 6
0
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"] . "&nbsp;&nbsp;&nbsp;" . $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);
    }
}
Ejemplo n.º 7
0
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();
}
Ejemplo n.º 8
0
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"] . "&nbsp;&nbsp;&nbsp;" . $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);
    }
}
Ejemplo n.º 9
0
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();
}
Ejemplo n.º 10
0
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();
}