After creating Sales Order - sending email: PDF without a name? Fixed.
[fa-stable.git] / dimensions / includes / dimensions_ui.inc
index bc56479fd88e946f7a1eb379fd4ed4a23f2df916..1dd0a56cbaf32a7ddad676cafeeccfc9a4282d4d 100644 (file)
@@ -1,54 +1,58 @@
 <?php
-
+/**********************************************************************
+    Copyright (C) FrontAccounting, LLC.
+       Released under the terms of the GNU General Public License, GPL, 
+       as published by the Free Software Foundation, either version 3 
+       of the License, or (at your option) any later version.
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
+***********************************************************************/
 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);
+       global $path_to_root;
 
-    echo "<br>";
+       $result = get_dimension_balance_all($id, $from, $to);
 
     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"));
-               start_table($table_style);
-               $th = array(_("Type"), _("#"), _("Reference"),
-                       _("Date"), _("Debit"), _("Credit"));
+               display_heading2(_("Balance for this Dimension"));
+               br();
+               start_table(TABLESTYLE);
+               $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("<b>"._("Balance")."</b>");
+               if ($total >= 0)
+               {
+                       amount_cell($total, true);
+                       label_cell("");
+               }
+               else
+               {
+                       label_cell("");
+                       amount_cell(abs($total), true);
+               }
                end_row();
 
                end_table();
@@ -57,4 +61,3 @@ function display_dimension_payments($id)
 
 //--------------------------------------------------------------------------------------
 
-?>
\ No newline at end of file