Merged bugfixes upto [0000072] (version 2.0.3).
[fa-stable.git] / dimensions / includes / dimensions_ui.inc
1 <?php
2
3 include_once($path_to_root . "/includes/ui.inc");
4
5 //--------------------------------------------------------------------------------------
6
7 function display_dimension_payments($id)
8 {
9         global $path_to_root, $table_style;
10
11         $sql = "SELECT ".TB_PREF."gl_trans.*,".TB_PREF."chart_master.account_name  FROM
12                 ".TB_PREF."gl_trans,".TB_PREF."chart_master WHERE
13                 ".TB_PREF."gl_trans.account = ".TB_PREF."chart_master.account_code AND
14                 (dimension_id = $id OR dimension2_id = $id) ORDER BY account,tran_date";
15         $result = db_query($sql, "Transactions could not be calculated");
16
17     echo "<br>";
18
19     if (db_num_rows($result) == 0)
20     {
21         display_note(_("There are no transactions for this dimension."));
22     }
23     else
24     {
25                 display_heading2(_("Transactions for this Dimension"));
26                 start_table($table_style);
27                 $th = array(_("Type"), _("#"), _("Account"),
28                         _("Date"), _("Debit"), _("Credit"));
29                 table_header($th);
30
31         $total = $grand_total = $k = 0;
32                 $account = "";
33         while ($myrow = db_fetch($result))
34         {
35                         if ($account != $myrow["account"])
36                         {
37                                 if ($account != "")
38                                 {
39                                         start_row();
40                                         label_cell(_("Total"), "colspan=4");
41                                         display_debit_or_credit_cells($total);
42                                         end_row();
43                                         $total = 0;
44                                 }
45                                 $account = $myrow["account"];
46                         }
47
48                         alt_table_row_color($k);
49
50                 label_cell(systypes::name($myrow["type"]));
51                         label_cell(get_gl_view_str($myrow["type"], $myrow["type_no"], $myrow["type_no"], true));
52                         label_cell($myrow["account"]." ".$myrow['account_name']);
53                         label_cell(sql2date($myrow["tran_date"]));
54                         display_debit_or_credit_cells($myrow["amount"]);
55
56                         $total += $myrow["amount"];
57                         $grand_total += $myrow["amount"];
58
59                         end_row();
60                 }
61                 start_row();
62                 label_cell(_("Total"), "colspan=4");
63                 display_debit_or_credit_cells($total);
64                 end_row();
65
66                 start_row();
67                 label_cell(_("Grand Total"), "colspan=4");
68                 display_debit_or_credit_cells($grand_total);
69                 end_row();
70
71                 end_table();
72     }
73 }
74
75 //--------------------------------------------------------------------------------------
76
77 ?>