*** empty log message ***
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Sun, 21 Sep 2008 08:59:18 +0000 (08:59 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Sun, 21 Sep 2008 08:59:18 +0000 (08:59 +0000)
dimensions/includes/dimensions_ui.inc
dimensions/inquiry/search_dimensions.php

index 9355c99992e573e3afb700188401acd6ae802ae9..25ddb2b8e2c24211983f0f4ca8fcfcff1efa44ec 100644 (file)
@@ -8,8 +8,10 @@ function display_dimension_payments($id)
 {
        global $path_to_root, $table_style;
 
-       $sql = "SELECT * FROM ".TB_PREF."gl_trans WHERE dimension_id = $id OR dimension2_id = $id
-               ORDER BY account,tran_date";
+       $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>";
@@ -26,29 +28,46 @@ function display_dimension_payments($id)
                        _("Date"), _("Debit"), _("Credit"));
                table_header($th);
 
-        $total = $k = 0;
-
+        $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);
 
                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"]);
+                       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"];
 
                        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();
     }
 }
index a263905c4b94cc257a5902e171c5ea38591b382c..4dd105dcaf8ce2a182d7a157981f4d7cdbd194ba 100644 (file)
@@ -26,10 +26,10 @@ else
 //-----------------------------------------------------------------------------------
 // Ajax updates
 //
-if (get_post('SearchOrders')) 
+if (get_post('SearchOrders'))
 {
        $Ajax->activate('dim_table');
-} elseif (get_post('_OrderNumber_changed')) 
+} elseif (get_post('_OrderNumber_changed'))
 {
        $disable = get_post('OrderNumber') !== '';
 
@@ -136,8 +136,8 @@ while ($myrow = db_fetch($result))
 {
        $sql = "SELECT SUM(amount) FROM ".TB_PREF."gl_trans WHERE tran_date >= '" .
                date2sql($_POST['FromDate']) . "' AND
-               tran_date <= '" . date2sql($_POST['ToDate']) . "' AND dimension_id = " .
-               $myrow['id'];
+               tran_date <= '" . date2sql($_POST['ToDate']) . "' AND (dimension_id = " .
+               $myrow['id']." OR dimension2_id = " .$myrow['id']);
        $res = db_query($sql, "Transactions could not be calculated");
        $row = db_fetch_row($res);
 
@@ -171,7 +171,7 @@ while ($myrow = db_fetch($result))
        if (!$outstanding_only)
                label_cell(($myrow["closed"] ? _("Yes") : _("No")));
        amount_cell($row[0]);
-       
+
        label_cell($myrow["closed"] == 0 ? ("<a href='$mpage'>" . _("Edit") . "</a>") :'');
        end_row();