Moved all SQL statements from PHP files into relevant *_db.inc files.
[fa-stable.git] / gl / manage / currencies.php
index 9bf6a9cd9c6e6db2e4234e70fcc6926c49423826..99f80bdd2ccab620708c53d4f5f5fc0fad98e35f 100644 (file)
@@ -89,38 +89,26 @@ function check_can_delete()
        $curr = db_escape($selected_id);
 
        // PREVENT DELETES IF DEPENDENT RECORDS IN debtors_master
-       $sql= "SELECT COUNT(*) FROM ".TB_PREF."debtors_master WHERE curr_code = $curr";
-       $result = db_query($sql);
-       $myrow = db_fetch_row($result);
-       if ($myrow[0] > 0) 
+       if (currency_in_debtors($curr))
        {
                display_error(_("Cannot delete this currency, because customer accounts have been created referring to this currency."));
                return false;
        }
 
-       $sql= "SELECT COUNT(*) FROM ".TB_PREF."suppliers WHERE curr_code = $curr";
-       $result = db_query($sql);
-       $myrow = db_fetch_row($result);
-       if ($myrow[0] > 0) 
+       if (currency_in_suppliers($curr))
        {
                display_error(_("Cannot delete this currency, because supplier accounts have been created referring to this currency."));
                return false;
        }
-               
-       $sql= "SELECT COUNT(*) FROM ".TB_PREF."company WHERE curr_default = $curr";
-       $result = db_query($sql);
-       $myrow = db_fetch_row($result);
-       if ($myrow[0] > 0) 
+       
+       if (currency_in_company($curr))
        {
                display_error(_("Cannot delete this currency, because the company preferences uses this currency."));
                return false;
        }
        
        // see if there are any bank accounts that use this currency
-       $sql= "SELECT COUNT(*) FROM ".TB_PREF."bank_accounts WHERE bank_curr_code = $curr";
-       $result = db_query($sql);
-       $myrow = db_fetch_row($result);
-       if ($myrow[0] > 0) 
+       if (currenty_in_bank_accounts($curr))
        {
                display_error(_("Cannot delete this currency, because thre are bank accounts that use this currency."));
                return false;