Transaction references extended with parametrized patterns, added check_reference...
[fa-stable.git] / includes / data_checks.inc
index 7ce8d668adced13db154009c9bca372e8d77edc6..7243e43fe937be460c3650d47028ade5939d7a33 100644 (file)
@@ -524,3 +524,17 @@ function check_is_editable($trans_type, $trans_no, $msg=null)
                check_is_closed($trans_type, $trans_no, $msg);
 }
 
+function check_reference($reference, $trans_type, $trans_no=0, $context=null, $line=null)
+{
+       global $Refs;
+
+       if (!$Refs->is_valid($reference, $trans_type, $context, $line))
+       {
+               display_error(_("The entered reference is invalid.")); return false;
+       }
+       elseif (!$Refs->is_new_reference($reference, $trans_type, $trans_no))
+       {
+               display_error( _("The entered reference is already in use.")); return false;
+       }
+       return true;
+}