Better vertical alignment of date picker icon.
[fa-stable.git] / includes / data_checks.inc
index 272584c3270c7b0e0ccee3d78d5757bf829efb4f..8449b5dd63bce2ea47ddf8062aee0a031ea87a9c 100644 (file)
@@ -118,22 +118,6 @@ function check_db_has_tax_groups($msg)
     }  
 }
 
-function db_has_movement_types()
-{
-       return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."movement_types");
-}
-
-function check_db_has_movement_types($msg)
-{
-       global $path_to_root;
-    if (!db_has_movement_types()) 
-    {
-       display_error($msg, true);
-       end_page();
-       exit;   
-    }  
-}
-
 function db_customer_has_branches($customer_id)
 {
        return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."cust_branch "
@@ -511,6 +495,22 @@ function check_is_closed($type, $type_no, $msg=null)
        }
 }
 
+function check_db_has_template_orders($msg)
+{
+       $sql  = "SELECT sorder.order_no 
+               FROM ".TB_PREF."sales_orders as sorder,"
+                       .TB_PREF."sales_order_details as line
+               WHERE sorder.order_no = line.order_no AND sorder.type = 1
+               GROUP BY line.order_no";
+
+    if (!check_empty_result($sql))
+    {
+       display_error($msg, true);
+       end_page();
+       exit;
+    }
+}
+
 function check_deferred_income_act($msg)
 {
        global $path_to_root;
@@ -540,3 +540,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;
+}