*** empty log message ***
[fa-stable.git] / dimensions / includes / dimensions_ui.inc
index 7683712af7fc3552dffb0a31f415d48c95196d85..25ddb2b8e2c24211983f0f4ca8fcfcff1efa44ec 100644 (file)
@@ -8,49 +8,66 @@ function display_dimension_payments($id)
 {
        global $path_to_root, $table_style;
 
-    $result = get_bank_trans(null, null, payment_person_types::dimension(), $id);
+       $sql = "SELECT ".TB_PREF."gl_trans.*,".TB_PREF."chart_master.account_name  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";
+       $result = db_query($sql, "Transactions could not be calculated");
 
     echo "<br>";
 
     if (db_num_rows($result) == 0)
     {
-       echo _("There are no transactions for this dimension.") . "<br>";
-    } 
-    else 
+       display_note(_("There are no transactions for this dimension."));
+    }
+    else
     {
                display_heading2(_("Transactions for this Dimension"));
                start_table($table_style);
-               $th = array(_("Type"), _("#"), _("Reference"),
+               $th = array(_("Type"), _("#"), _("Account"),
                        _("Date"), _("Debit"), _("Credit"));
-               table_header($th);      
-
-        $total = $k = 0;
+               table_header($th);
 
-        while ($myrow = db_fetch($result)) 
+        $total = $grand_total = $k = 0;
+               $account = "";
+        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);
 
-                       // 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);
+                       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 += $home_value;
+                       $total += $myrow["amount"];
+                       $grand_total += $myrow["amount"];
 
                        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);
+               end_row();
+
                end_table();
     }
 }