Fixed get_standard_cost() result for dummy items.
[fa-stable.git] / includes / errors.inc
index 1bbc71ff3ea917dc1af36380dd72109958100804..f2cfe1c0fc1b113c6fee2e58706969c0b2484b27 100644 (file)
@@ -84,9 +84,9 @@ function error_box() {
     global $before_box;
     
     echo "<div id='msgbox'>";
-       $before_box = ob_get_clean(); // save html content before error box 
+
 // Necessary restart instead of get_contents/clean calls due to a bug in php 4.3.2
-       register_shutdown_function('end_flush');
+       $before_box = ob_get_clean(); // save html content before error box 
     ob_start('output_html');
     echo "</div>";
 }
@@ -94,7 +94,12 @@ function error_box() {
        Helper to avoid sparse log notices.
 */
 function end_flush () {
-               if (ob_get_level()) ob_end_flush();
+       global $Ajax;
+
+       if (isset($Ajax))
+               $Ajax->run();
+       // flush all output buffers (works also with exit inside any div levels)
+       while(ob_get_level()) ob_end_flush();
 }
 
 function display_db_error($msg, $sql_statement=null, $exit=true)
@@ -130,15 +135,13 @@ function display_db_error($msg, $sql_statement=null, $exit=true)
                exit;
 }
 
-function frindly_db_error($db_error, $sql)
+function frindly_db_error($db_error)
 {
-       global $db_duplicate_error_code, $go_debug;
+       global $db_duplicate_error_code;
        
        if ($db_error == $db_duplicate_error_code) 
-       {       $msg = _("The entered information is a duplicate. Please go back and enter different values.");
-               if ($go_debug)
-                       $msg .= '<br>Sql that failed was :<br>'.$sql;
-               display_error($msg);
+       {       
+               display_error(_("The entered information is a duplicate. Please go back and enter different values."));
                return true;
        }
        
@@ -147,13 +150,13 @@ function frindly_db_error($db_error, $sql)
 
 function check_db_error($msg, $sql_statement, $exit_if_error=true, $rollback_if_error=true)
 {
-       global $db;
+       global $db, $go_debug;
        $db_error = db_error_no();
        
        if ($db_error != 0) 
        {
                
-               if (!frindly_db_error($db_error, $sql_statement)) {
+               if ($go_debug || !frindly_db_error($db_error)) {
                                display_db_error($msg, $sql_statement, false);
                }