+function systype_name($dummy, $type)
+{
+ return systypes::name($type);
+}
+
+function order_view($row)
+{
+ return $row['order_']>0 ?
+ get_customer_trans_view_str(systypes::sales_order(), $row['order_'])
+ : "";
+}
+
+function trans_view($trans)
+{
+ return get_trans_view_str($trans["type"], $trans["trans_no"]);
+}
+
+function due_date($row)
+{
+ return ($row["type"]==20 || $row["type"]==21)? sql2date($row["due_date"]) : '';
+}
+
+function fmt_balance($row)
+{
+ return price_format($row["TotalAmount"] - $row["Allocated"]);
+}
+
+function gl_view($row)
+{
+ return get_gl_view_str($row["type"], $row["trans_no"]);
+}
+
+function fmt_debit($row)
+{
+ $value =
+ $row['type']==11 || $row['type']==12 || $row['type']==2 ?
+ -$row["TotalAmount"] : $row["TotalAmount"];
+ return $value>=0 ? price_format($value) : '';
+
+}
+
+function fmt_credit($row)
+{
+ $value =
+ !($row['type']==11 || $row['type']==12 || $row['type']==2) ?
+ -$row["TotalAmount"] : $row["TotalAmount"];
+ return $value>0 ? price_format($value) : '';
+}
+
+function alloc_link($row)
+{
+ if ($row['type'] == 10)
+ if ($row["TotalAmount"] - $row["Allocated"] > 0)
+ return pager_link(_("Allocation"),
+ "/sales/allocations/customer_allocate.php"
+ ."?trans_no={$row['trans_no']}&trans_type="
+ .$row['type']);
+ return '';
+}
+
+function credit_link($row)
+{
+ return $row['type'] == 10 ?
+ pager_link(_("Credit This"),
+ "/sales/customer_credit_invoice.php?InvoiceNumber=".
+ $row['trans_no'])
+ : '';
+}
+
+function edit_link($row)
+{
+ $str = '';
+
+ switch($row['type']) {
+ case 10:
+ $str = "/sales/customer_invoice.php?ModifyInvoice=".$row['trans_no'];
+ break;
+ case 11:
+ if ($row['order_']==0) // free-hand credit note
+ $str = "/sales/credit_note_entry.php?ModifyCredit=".$row['trans_no'];
+ else // credit invoice
+ $str = "/sales/customer_credit_invoice.php?ModifyCredit=".$row['trans_no'];
+ break;
+ case 13:
+ $str = "/sales/customer_delivery.php?ModifyDelivery=".$row['trans_no'];
+ break;
+ }
+ return pager_link(_('Edit'), $str);
+}
+
+function prt_link($row)
+{
+ if ($row['type'] != 12) // customer payment printout not defined yet.
+ return print_document_link($row['trans_no'], _("Print"), true, $row['type']);
+}