From: Joe Hunt Date: Fri, 5 Dec 2008 12:50:44 +0000 (+0000) Subject: Changed dimension view to show result instead of ledger trans X-Git-Tag: v2.4.2~19^2~1707 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=25d5046ec21d88b54257b5fa191ff73b63921146;p=fa-stable.git Changed dimension view to show result instead of ledger trans --- diff --git a/dimensions/includes/dimensions_ui.inc b/dimensions/includes/dimensions_ui.inc index ae69b98b..9f6bc005 100644 --- a/dimensions/includes/dimensions_ui.inc +++ b/dimensions/includes/dimensions_ui.inc @@ -1,71 +1,65 @@ . +***********************************************************************/ include_once($path_to_root . "/includes/ui.inc"); //-------------------------------------------------------------------------------------- -function display_dimension_payments($id) +function display_dimension_balance($id, $from, $to) { global $path_to_root, $table_style; - $sql = "SELECT ".TB_PREF."gl_trans.*,".TB_PREF."chart_master.account_name FROM + $from = date2sql($from); + $to = date2sql($to); + $sql = "SELECT account, ".TB_PREF."chart_master.account_name, sum(amount) AS amt FROM ".TB_PREF."gl_trans,".TB_PREF."chart_master WHERE ".TB_PREF."gl_trans.account = ".TB_PREF."chart_master.account_code AND - (dimension_id = $id OR dimension2_id = $id) ORDER BY account,tran_date"; + (dimension_id = $id OR dimension2_id = $id) AND + tran_date >= '$from' AND tran_date <= '$to' GROUP BY account"; $result = db_query($sql, "Transactions could not be calculated"); - echo "
"; - if (db_num_rows($result) == 0) { - display_note(_("There are no transactions for this dimension.")); + display_note(_("There are no transactions for this dimension for the selected period.")); } else { - display_heading2(_("Transactions for this Dimension")); + display_heading2(_("Balance for this Dimension")); + br(); start_table($table_style); - $th = array(_("Type"), _("#"), _("Account"), - _("Date"), _("Debit"), _("Credit")); + $th = array(_("Account"), _("Debit"), _("Credit")); table_header($th); - $total = $grand_total = $k = 0; - $account = ""; + $total = $k = 0; while ($myrow = db_fetch($result)) { - if ($account != $myrow["account"]) - { - if ($account != "") - { - start_row(); - label_cell(_("Total"), "colspan=4"); - display_debit_or_credit_cells($total); - end_row(); - $total = 0; - } - $account = $myrow["account"]; - } - alt_table_row_color($k); - label_cell(systypes::name($myrow["type"])); - label_cell(get_gl_view_str($myrow["type"], $myrow["type_no"], $myrow["type_no"], true)); label_cell($myrow["account"]." ".$myrow['account_name']); - label_cell(sql2date($myrow["tran_date"])); - display_debit_or_credit_cells($myrow["amount"]); - - $total += $myrow["amount"]; - $grand_total += $myrow["amount"]; - + display_debit_or_credit_cells($myrow["amt"]); + $total += $myrow["amt"]; end_row(); } start_row(); - label_cell(_("Total"), "colspan=4"); - display_debit_or_credit_cells($total); - end_row(); - - start_row(); - label_cell(_("Grand Total"), "colspan=4"); - display_debit_or_credit_cells($grand_total); + label_cell(""._("Balance").""); + if ($total >= 0) + { + amount_cell($total, true); + label_cell(""); + } + else + { + label_cell(""); + amount_cell(abs($total), true); + } end_row(); end_table(); diff --git a/dimensions/view/view_dimension.php b/dimensions/view/view_dimension.php index 843da185..d0a100a7 100644 --- a/dimensions/view/view_dimension.php +++ b/dimensions/view/view_dimension.php @@ -1,13 +1,22 @@ . +***********************************************************************/ $page_security = 10; $path_to_root="../.."; include_once($path_to_root . "/includes/session.inc"); $js = ""; -if ($use_popup_windows) - $js .= get_js_open_window(800, 500); +if ($use_date_picker) + $js .= get_js_date_picker(); page(_("View Dimension"), true, false, "", $js); include_once($path_to_root . "/includes/date_functions.inc"); @@ -18,11 +27,17 @@ include_once($path_to_root . "/dimensions/includes/dimensions_ui.inc"); //------------------------------------------------------------------------------------------------- -if ($_GET['trans_no'] != "") +if (isset($_GET['trans_no']) && $_GET['trans_no'] != "") { $id = $_GET['trans_no']; } +if (isset($_POST['Show'])) +{ + $id = $_POST['trans_no']; +} + + display_heading(systypes::name(systypes::dimension()) . " # " . $id); br(1); @@ -30,7 +45,7 @@ $myrow = get_dimension($id); if (strlen($myrow[0]) == 0) { - echo _("The work order number sent is not valid."); + echo _("The dimension number sent is not valid."); exit; } @@ -57,7 +72,26 @@ if ($myrow["closed"] == true) display_note(_("This dimension is closed.")); } -display_dimension_payments($id); +start_form(); + +start_table("class='tablestyle_noborder'"); +start_row(); + +if (!isset($_POST['TransFromDate'])) + $_POST['TransFromDate'] = begin_fiscalyear(); +if (!isset($_POST['TransToDate'])) + $_POST['TransToDate'] = Today(); +date_cells(_("from:"), 'TransFromDate'); +date_cells(_("to:"), 'TransToDate'); +submit_cells('Show',_("Show")); + +end_row(); + +end_table(); +hidden('trans_no', $id); +end_form(); + +display_dimension_balance($id, $_POST['TransFromDate'], $_POST['TransToDate']); br(1);