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 render($id, $title) { global $path_to_root, $systypes_array; include_once $path_to_root . "/includes/ui.inc"; $start_date = add_days(Today(), -$this->days_past); $end_date = add_days(Today(), $this->days_future); $result = get_bank_trans_for_bank_account($this->bank_act, $start_date, $end_date); start_table(TABLESTYLE, 'width=98%'); $th = array(_("#"), _("Date"), _("Receipt"), _("Payment"), _("Balance"), _("Person/Item"), _("Memo"), ""); table_header($th); $bfw = get_balance_before_for_bank_account($this->bank_act, $start_date); $credit = $debit = 0; start_row("class='inquirybg' style='font-weight:bold'"); label_cell(_("Opening Balance") . " - " . $start_date, "colspan=4"); display_debit_or_credit_cells($bfw); label_cell(""); label_cell("", "colspan=2"); end_row(); $running_total = $bfw; if ($bfw > 0) { $debit += $bfw; } else { $credit += $bfw; } $j = 1; $k = 0; //row colour counter while ($myrow = db_fetch($result)) { alt_table_row_color($k); $running_total += $myrow["amount"]; label_cell(get_trans_view_str($myrow["type"], $myrow["trans_no"])); $trandate = sql2date($myrow["trans_date"]); label_cell($trandate); display_debit_or_credit_cells($myrow["amount"]); amount_cell($running_total); label_cell(payment_person_name($myrow["person_type_id"], $myrow["person_id"])); label_cell(get_comments_string($myrow["type"], $myrow["trans_no"])); label_cell(get_gl_view_str($myrow["type"], $myrow["trans_no"])); end_row(); if ($myrow["amount"] > 0) { $debit += $myrow["amount"]; } else { $credit += $myrow["amount"]; } if ($j == 12) { $j = 1; table_header($th); } $j++; } //end of while loop start_row("class='inquirybg' style='font-weight:bold'"); label_cell(_("Ending Balance") . " - " . $end_date, "colspan=4"); amount_cell($debit + $credit); label_cell(""); label_cell("", "colspan=2"); end_row(); end_table(2); }
function show_results() { global $path_to_root, $systypes_array; if (!isset($_POST["account"])) { $_POST["account"] = null; } $act_name = $_POST["account"] ? get_gl_account_name($_POST["account"]) : ""; $dim = get_company_pref('use_dimension'); /*Now get the transactions */ if (!isset($_POST['Dimension'])) { $_POST['Dimension'] = 0; } if (!isset($_POST['Dimension2'])) { $_POST['Dimension2'] = 0; } $result = get_gl_transactions($_POST['TransFromDate'], $_POST['TransToDate'], -1, $_POST["account"], $_POST['Dimension'], $_POST['Dimension2'], null, input_num('amount_min'), input_num('amount_max')); $colspan = $dim == 2 ? "6" : ($dim == 1 ? "5" : "4"); if ($_POST["account"] != null) { display_heading($_POST["account"] . " " . $act_name); } // Only show balances if an account is specified AND we're not filtering by amounts $show_balances = $_POST["account"] != null && input_num("amount_min") == 0 && input_num("amount_max") == 0; start_table(TABLESTYLE); $first_cols = array(_("Type"), _("#"), _("Date")); if ($_POST["account"] == null) { $account_col = array(_("Account")); } else { $account_col = array(); } if ($dim == 2) { $dim_cols = array(_("Dimension") . " 1", _("Dimension") . " 2"); } else { if ($dim == 1) { $dim_cols = array(_("Dimension")); } else { $dim_cols = array(); } } if ($show_balances) { $remaining_cols = array(_("Person/Item"), _("Debit"), _("Credit"), _("Balance"), _("Memo")); } else { $remaining_cols = array(_("Person/Item"), _("Debit"), _("Credit"), _("Memo")); } $th = array_merge($first_cols, $account_col, $dim_cols, $remaining_cols); table_header($th); if ($_POST["account"] != null && is_account_balancesheet($_POST["account"])) { $begin = ""; } else { $begin = get_fiscalyear_begin_for_date($_POST['TransFromDate']); if (date1_greater_date2($begin, $_POST['TransFromDate'])) { $begin = $_POST['TransFromDate']; } $begin = add_days($begin, -1); } $bfw = 0; if ($show_balances) { $bfw = get_gl_balance_from_to($begin, $_POST['TransFromDate'], $_POST["account"], $_POST['Dimension'], $_POST['Dimension2']); start_row("class='inquirybg'"); label_cell("<b>" . _("Opening Balance") . " - " . $_POST['TransFromDate'] . "</b>", "colspan={$colspan}"); display_debit_or_credit_cells($bfw, true); label_cell(""); label_cell(""); end_row(); } $running_total = $bfw; $j = 1; $k = 0; //row colour counter while ($myrow = db_fetch($result)) { alt_table_row_color($k); $running_total += $myrow["amount"]; $trandate = sql2date($myrow["tran_date"]); label_cell($systypes_array[$myrow["type"]]); label_cell(get_gl_view_str($myrow["type"], $myrow["type_no"], $myrow["type_no"], true)); label_cell($trandate); if ($_POST["account"] == null) { label_cell($myrow["account"] . ' ' . get_gl_account_name($myrow["account"])); } if ($dim >= 1) { label_cell(get_dimension_string($myrow['dimension_id'], true)); } if ($dim > 1) { label_cell(get_dimension_string($myrow['dimension2_id'], true)); } label_cell(payment_person_name($myrow["person_type_id"], $myrow["person_id"])); display_debit_or_credit_cells($myrow["amount"]); if ($show_balances) { amount_cell($running_total); } if ($myrow['memo_'] == "") { $myrow['memo_'] = get_comments_string($myrow['type'], $myrow['type_no']); } label_cell($myrow['memo_']); end_row(); $j++; if ($j == 12) { $j = 1; table_header($th); } } //end of while loop if ($show_balances) { start_row("class='inquirybg'"); label_cell("<b>" . _("Ending Balance") . " - " . $_POST['TransToDate'] . "</b>", "colspan={$colspan}"); display_debit_or_credit_cells($running_total, true); label_cell(""); label_cell(""); end_row(); } end_table(2); if (db_num_rows($result) == 0) { display_note(_("No general ledger transactions have been created for the specified criteria."), 0, 1); } }
} $preview_trans_str = get_trans_view_str($myrow["type"], $myrow["trans_no"]); label_cell(systypes::name($myrow["type"])); label_cell($preview_trans_str); label_cell($preview_order_str); label_cell($myrow["reference"]); label_cell($date, "nowrap"); label_cell($due_date_str, "nowrap"); if ($_POST['customer_id'] == reserved_words::get_all()) { label_cell($myrow["CustName"]); } label_cell($branch_name); if ($_POST['customer_id'] == reserved_words::get_all()) { label_cell($myrow["CustCurrCode"]); } display_debit_or_credit_cells($myrow['type'] == 11 || $myrow['type'] == 12 || $myrow['type'] == 2 ? -$myrow["TotalAmount"] : $myrow["TotalAmount"]); echo $gl_trans_str; label_cell($edit_page == '' ? '' : "<a href='{$edit_page}'>" . tr('Edit') . '</a>'); if ($myrow['type'] == 10 || $myrow['type'] == 11) { label_cell(print_document_link($myrow['trans_no'], tr("Print"), true, $myrow['type'])); } else { label_cell(""); } if ($credit_me_str != "") { label_cell($credit_me_str, "nowrap"); } else { label_cell(''); } end_row(); $j++; if ($j == 12) {
if (!$heading_shown) { display_gl_heading($myrow); start_table(TABLESTYLE, "width='95%'"); table_header($th); $heading_shown = true; } alt_table_row_color($k); label_cell($myrow['account']); label_cell($myrow['account_name']); if ($dim >= 1) { label_cell(get_dimension_string($myrow['dimension_id'], true)); } if ($dim > 1) { label_cell(get_dimension_string($myrow['dimension2_id'], true)); } display_debit_or_credit_cells($myrow['amount']); label_cell($myrow['memo_']); end_row(); if ($myrow['amount'] > 0) { $debit += $myrow['amount']; } else { $credit += $myrow['amount']; } } if ($heading_shown) { start_row("class='inquirybg' style='font-weight:bold'"); label_cell(_("Total"), "colspan=2"); if ($dim >= 1) { label_cell(''); } if ($dim > 1) {
function show_results() { global $path_to_root, $table_style; if (!isset($_POST["account"]) || $_POST["account"] == "") { return; } $act_name = get_gl_account_name($_POST["account"]); $dim = get_company_pref('use_dimension'); /*Now get the transactions */ if (!isset($_POST['Dimension'])) { $_POST['Dimension'] = 0; } if (!isset($_POST['Dimension2'])) { $_POST['Dimension2'] = 0; } $result = get_gl_transactions($_POST['TransFromDate'], $_POST['TransToDate'], -1, $_POST["account"], $_POST['Dimension'], $_POST['Dimension2']); $colspan = $dim == 2 ? "6" : ($dim == 1 ? "5" : "4"); //echo "\nDimension =". $_POST['Dimension']; display_heading($_POST["account"] . " " . $act_name); start_table($table_style); if ($dim == 2) { $th = array(tr("Type"), tr("#"), tr("Date"), tr("Dimension") . " 1", tr("Dimension") . " 2", tr("Person/Item"), tr("Debit"), tr("Credit"), tr("Balance"), tr("Memo")); } else { if ($dim == 1) { $th = array(tr("Type"), tr("#"), tr("Date"), tr("Dimension"), tr("Person/Item"), tr("Debit"), tr("Credit"), tr("Balance"), tr("Memo")); } else { $th = array(tr("Type"), tr("#"), tr("Date"), tr("Person/Item"), tr("Debit"), tr("Credit"), tr("Balance"), tr("Memo")); } } table_header($th); if (is_account_balancesheet($_POST["account"])) { $begin = ""; } else { $begin = begin_fiscalyear(); if ($_POST['TransFromDate'] < $begin) { $begin = $_POST['TransFromDate']; } $begin = add_days($begin, -1); } $bfw = get_gl_balance_from_to($begin, $_POST['TransFromDate'], $_POST["account"], $_POST['Dimension'], $_POST['Dimension2']); start_row("class='inquirybg'"); label_cell("<b>" . tr("Opening Balance") . " - " . $_POST['TransFromDate'] . "</b>", "colspan={$colspan}"); display_debit_or_credit_cells($bfw); label_cell(""); end_row(); //$running_total =0; $running_total = $bfw; $j = 1; $k = 0; //row colour counter while ($myrow = db_fetch($result)) { alt_table_row_color($k); $running_total += $myrow["amount"]; $trandate = sql2date($myrow["tran_date"]); label_cell(systypes::name($myrow["type"])); label_cell(get_gl_view_str($myrow["type"], $myrow["type_no"], $myrow["type_no"], true)); label_cell($trandate); if ($dim >= 1) { label_cell(get_dimension_string($myrow['dimension_id'], true)); } if ($dim > 1) { label_cell(get_dimension_string($myrow['dimension2_id'], true)); } label_cell(payment_person_types::person_name($myrow["person_type_id"], $myrow["person_id"])); display_debit_or_credit_cells($myrow["amount"]); amount_cell($running_total); label_cell($myrow['memo_']); end_row(); $j++; if ($j == 12) { $j = 1; table_header($th); } } //end of while loop start_row("class='inquirybg'"); label_cell("<b>" . tr("Ending Balance") . " - " . $_POST['TransToDate'] . "</b>", "colspan={$colspan}"); display_debit_or_credit_cells($running_total); label_cell(""); end_row(); end_table(2); if (db_num_rows($result) == 0) { display_note(tr("No general ledger transactions have been created for this account on the selected dates."), 0, 1); } }
$result = get_gl_transactions($begin, $end, -1, $account, 0, 0, null); $j = 0; $k = 1; while ($myrow = db_fetch($result)) { alt_table_row_color($k); $trandate = sql2date($myrow["tran_date"]); label_cell($systypes_array[$myrow["type"]]); $amount = price_format($myrow["amount"]); $str = "<a href='#' onclick='return WindowClose(\"{$amount}\", \"{$trandate}\");' >" . $myrow['type_no'] . "</a>"; label_cell($str); 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_name($myrow["person_type_id"], $myrow["person_id"])); display_debit_or_credit_cells($myrow["amount"]); label_cell($myrow['memo_']); end_row(); $j++; if ($j == 12) { $j = 1; table_header($th); } } //end of while loop //end of while loop end_table(1); end_page(true);
} if ($dim > 1) { label_cell(""); } display_debit_or_credit_cells($am0 * -1); label_cell($memo); alt_table_row_color($k); label_cell($date); label_cell($_POST['res_act'] . " " . get_gl_account_name($_POST['res_act'])); if ($dim > 0) { label_cell(get_dimension_string($_POST['dimension_id'], true)); } if ($dim > 1) { label_cell(get_dimension_string($_POST['dimension2_id'], true)); } display_debit_or_credit_cells($am0); label_cell($memo); } } if (isset($_POST['go'])) { commit_transaction(); display_notification_centered(_("Revenue / Cost Accruals have been processed.")); $_POST['date_'] = $_POST['amount'] = $_POST['periods'] = ""; } else { end_table(1); display_notification_centered(_("Showing GL Transactions.")); } } } } function frequency_list_row($label, $name, $selected = null)
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 . ')'); } }
/*its a receipt which could have an allocation*/ $allocations_str = $allocations; } elseif ($myrow["type"] == systypes::cust_payment() && $myrow['TotalAmount'] > 0) { /*its a negative receipt */ } label_cell(systypes::name($myrow["type"])); label_cell(get_customer_trans_view_str($myrow["type"], $myrow["trans_no"])); label_cell($myrow["reference"]); label_cell($preview_order_str); label_cell(sql2date($myrow["tran_date"]), "nowrap"); label_cell($due_date_str, "nowrap"); if ($_POST['customer_id'] == reserved_words::get_all()) { label_cell($myrow["CustName"]); label_cell($myrow["CustCurrCode"]); } display_debit_or_credit_cells($myrow["TotalAmount"]); amount_cell(abs($myrow["Allocated"])); amount_cell(abs($myrow["TotalAmount"]) - $myrow["Allocated"]); label_cell($allocations_str); end_row(); $j++; if ($j == 12) { $j = 1; table_header($th); } //end of page full new headings if } //end of while loop end_table(1); if ($over_due) { display_note(tr("Marked items are overdue."), 0, 1, "class='overduefg'");
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 . ')'); } }
$k = 0; //row colour counter while ($myrow = db_fetch($result)) { alt_table_row_color($k); $running_total += $myrow["amount"]; $trandate = sql2date($myrow["trans_date"]); label_cell(systypes::name($myrow["type"])); label_cell(get_trans_view_str($myrow["type"], $myrow["trans_no"])); label_cell(get_trans_view_str($myrow["type"], $myrow["trans_no"], $myrow['ref'])); label_cell($myrow["BankTransType"]); label_cell($trandate); display_debit_or_credit_cells($myrow["amount"]); amount_cell($running_total); label_cell(payment_person_types::person_name($myrow["person_type_id"], $myrow["person_id"])); label_cell(get_gl_view_str($myrow["type"], $myrow["trans_no"])); end_row(); if ($j == 12) { $j = 1; table_header($th); } $j++; } //end of while loop start_row("class='inquirybg'"); label_cell("<b>" . tr("Ending Balance") . " - " . $_POST['TransToDate'] . "</b>", "colspan=5"); display_debit_or_credit_cells($running_total); label_cell(""); end_row(); end_table(2); //------------------------------------------------------------------------------------------------ end_page();