-$result = db_query($sql,"could not query dimensions");
-
-div_start('dim_table');
-start_table("$table_style width=80%");
-
-if (!$outstanding_only)
- $th = array(_("#"), _("Reference"), _("Name"), _("Type"), _("Date"),
- _("Due Date"), _("Closed"), _("Balance"));
-else
- $th = array(_("#"), _("Reference"), _("Name"), _("Type"), _("Date"),
- _("Due Date"), _("Balance"));
-table_header($th);
-$j = 1;
-$k = 0;
-
-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'];
- $res = db_query($sql, "Transactions could not be calculated");
- $row = db_fetch_row($res);
-
- if ($k == 1)
- {
- $row_text = "class='oddrow'";
- $k = 0;
- }
- else
- {
- $row_text = "class='evenrow'";
- $k++;
- }
+$cols = array(
+ _("#") => array('fun'=>'view_link'),
+ _("Reference"),
+ _("Name"),
+ _("Type"),
+ _("Date") =>'date',
+ _("Due Date") => array('date', 'ord'=>'asc'),
+ _("Closed") => array('fun'=>'is_closed'),
+ _("Balance") => array('type'=>'amount', 'insert'=>true, 'fun'=>'sum_dimension'),
+ array('insert'=>true, 'fun'=>'edit_link')
+);
+
+if ($outstanding_only) {
+ $cols[_("Closed")] = 'skip';
+}