X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=dimensions%2Fincludes%2Fdimensions_ui.inc;h=6ac85524fa968a2f25af1bca1ec5f37b0d94cf2f;hb=4a2b99e23da068a31623fc054dee234a63f50e6a;hp=bc56479fd88e946f7a1eb379fd4ed4a23f2df916;hpb=c09be0dad6b05131e240349a375af7a4b7bf3444;p=fa-stable.git diff --git a/dimensions/includes/dimensions_ui.inc b/dimensions/includes/dimensions_ui.inc index bc56479f..6ac85524 100644 --- a/dimensions/includes/dimensions_ui.inc +++ b/dimensions/includes/dimensions_ui.inc @@ -1,54 +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; - $result = get_bank_trans(null, null, payment_person_types::dimension(), $id); - - echo "
"; + $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) AND + tran_date >= '$from' AND tran_date <= '$to' GROUP BY account"; + $result = db_query($sql, "Transactions could not be calculated"); 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"), _("#"), _("Reference"), - _("Date"), _("Debit"), _("Credit")); + $th = array(_("Account"), _("Debit"), _("Credit")); table_header($th); $total = $k = 0; - while ($myrow = db_fetch($result)) { - alt_table_row_color($k); - // projects are always in home currency...get the home equivalent of the banktrans - // from it's gl postings - $home_value = get_gl_trans_value($myrow["bank_act"], $myrow["type"], $myrow["trans_no"]); - - label_cell(systypes::name($myrow["type"])); - label_cell(get_trans_view_str($myrow["type"], $myrow["trans_no"])); - label_cell($myrow["ref"]); - label_cell(sql2date($myrow["trans_date"])); - display_debit_or_credit_cells($home_value); - - $total += $home_value; - + label_cell($myrow["account"]." ".$myrow['account_name']); + 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); + label_cell(""._("Balance").""); + if ($total >= 0) + { + amount_cell($total, true); + label_cell(""); + } + else + { + label_cell(""); + amount_cell(abs($total), true); + } end_row(); end_table();