+function exist_transaction($type, $type_no)
+{
+ $void_entry = get_voided_entry($type, $type_no);
+
+ if ($void_entry != null)
+ return false;
+
+ switch ($type)
+ {
+ case ST_JOURNAL : // it's a journal entry
+ if (!exists_gl_trans($type, $type_no))
+ return false;
+ break;
+
+ case ST_BANKPAYMENT : // it's a payment
+ case ST_BANKDEPOSIT : // it's a deposit
+ case ST_BANKTRANSFER : // it's a transfer
+ if (!exists_bank_trans($type, $type_no))
+ return false;
+ break;
+
+ case ST_SALESINVOICE : // it's a customer invoice
+ case ST_CUSTCREDIT : // it's a customer credit note
+ case ST_CUSTPAYMENT : // it's a customer payment
+ case ST_CUSTDELIVERY : // it's a customer dispatch
+ if (!exists_customer_trans($type, $type_no))
+ return false;
+ break;
+
+ case ST_LOCTRANSFER : // it's a stock transfer
+ if (get_stock_transfer_items($type_no) == null)
+ return false;
+ break;
+
+ case ST_INVADJUST : // it's a stock adjustment
+ if (get_stock_adjustment_items($type_no) == null)
+ return false;
+ break;
+
+ case ST_PURCHORDER : // it's a PO
+ return false;
+
+ case ST_SUPPRECEIVE : // it's a GRN
+ if (!exists_grn($type_no))
+ return false;
+ break;
+
+ case ST_SUPPINVOICE : // it's a suppler invoice
+ case ST_SUPPCREDIT : // it's a supplier credit note
+ case ST_SUPPAYMENT : // it's a supplier payment
+ if (!exists_supp_trans($type, $type_no))
+ return false;
+ break;
+
+ case ST_WORKORDER : // it's a work order
+ if (!get_work_order($type_no, true))
+ return false;
+ break;
+
+ case ST_MANUISSUE : // it's a work order issue
+ if (!exists_work_order_issue($type_no))
+ return false;
+ break;
+
+ case ST_MANURECEIVE : // it's a work order production
+ if (!exists_work_order_produce($type_no))
+ return false;
+ break;
+
+ case ST_SALESORDER: // it's a sales order
+ case ST_SALESQUOTE: // it's a sales quotation
+ return false;
+ case ST_COSTUPDATE : // it's a stock cost update
+ return false;
+ }
+
+ return true;
+}
+
+function view_link($trans)
+{
+ if (!isset($trans['type']))
+ $trans['type'] = $_POST['filterType'];
+ return get_trans_view_str($trans["type"], $trans["trans_no"]);
+}
+
+function select_link($row)
+{
+ if (!isset($row['type']))
+ $row['type'] = $_POST['filterType'];
+ if (!is_date_in_fiscalyear($row['trans_date'], true))
+ return _("N/A");
+ return button('Edit'.$row["trans_no"], _("Select"), _("Select"), ICON_EDIT);
+}
+
+function gl_view($row)
+{
+ if (!isset($row['type']))
+ $row['type'] = $_POST['filterType'];
+ return get_gl_view_str($row["type"], $row["trans_no"]);
+}
+
+function date_view($row)
+{
+ return $row['trans_date'];
+}
+
+function ref_view($row)
+{
+ return $row['ref'];
+}