diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 248a45c629a..bbd189239c9 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2893,19 +2893,20 @@ class Commande extends CommonOrder * Classify the order as invoiced * * @param User $user Object user making the change - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int <0 if KO, >0 if OK + * @param int $notrigger 1=Does not execute triggers, 0=execute triggers + * @return int <0 if KO, 0 if already billed, >0 if OK */ public function classifyBilled(User $user, $notrigger = 0) { $error = 0; - $this->db->begin(); if ($this->billed) { return 0; } + $this->db->begin(); + $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET facture = 1'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 89737ca917f..2c897968320 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -401,6 +401,7 @@ class Paiement extends CommonObject if ($result < 0) { $this->error = $invoice->error; + $this->errors = $invoice->errors; $error++; } } diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index 19965250727..534d6b5803e 100644 --- a/htdocs/core/class/interfaces.class.php +++ b/htdocs/core/class/interfaces.class.php @@ -179,20 +179,29 @@ class Interfaces $objMod = new $modName($this->db); if ($objMod) { + $dblevelbefore = $this->db->transaction_opened; + $result = 0; - if (method_exists($objMod, 'runTrigger')) // New method to implement - { + if (method_exists($objMod, 'runTrigger')) { // New method to implement //dol_syslog(get_class($this)."::run_triggers action=".$action." Launch runTrigger for file '".$files[$key]."'", LOG_DEBUG); $result = $objMod->runTrigger($action, $object, $user, $langs, $conf); - } elseif (method_exists($objMod, 'run_trigger')) // Deprecated method - { + } elseif (method_exists($objMod, 'run_trigger')) { // Deprecated method dol_syslog(get_class($this)."::run_triggers action=".$action." Launch old method run_trigger (rename your trigger into runTrigger) for file '".$files[$key]."'", LOG_WARNING); $result = $objMod->run_trigger($action, $object, $user, $langs, $conf); } else { dol_syslog(get_class($this)."::run_triggers action=".$action." A trigger was declared for class ".get_class($objMod)." but method runTrigger was not found", LOG_ERR); } + $dblevelafter = $this->db->transaction_opened; + + if ($dblevelbefore != $dblevelafter) { + $errormessage = "Error, the balance begin/close of db transactions has been broken into trigger ".$modName." with action=".$action." before=".$dblevelbefore." after=".$dblevelafter; + $this->errors[] = $errormessage; + dol_syslog($errormessage, LOG_ERR); + $result = -1; + } + if ($result > 0) { // Action OK diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 5464116c1ed..ee8fa746107 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -891,11 +891,17 @@ class CommandeFournisseur extends CommonOrder * Class invoiced the supplier order * * @param User $user Object user making the change - * @return int <0 if KO, >0 if KO + * @return int <0 if KO, 0 if already billed, >0 if OK */ public function classifyBilled(User $user) { $error = 0; + + if ($this->billed) + { + return 0; + } + $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur SET billed = 1'; diff --git a/htdocs/install/check.php b/htdocs/install/check.php index daab7a7296a..0a3e49c9600 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -122,7 +122,7 @@ if (!function_exists("imagecreate")) print 'Error '.$langs->trans("ErrorPHPDoesNotSupportGD")."
\n"; // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { - print 'Ok '.$langs->trans("PHPSupportGD")."
\n"; + print 'Ok '.$langs->trans("PHPSupport", "GD")."
\n"; } @@ -133,7 +133,7 @@ if (!function_exists("curl_init")) print 'Error '.$langs->trans("ErrorPHPDoesNotSupportCurl")."
\n"; // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { - print 'Ok '.$langs->trans("PHPSupportCurl")."
\n"; + print 'Ok '.$langs->trans("PHPSupport", "Curl")."
\n"; } // Check if PHP calendar extension is available @@ -141,7 +141,7 @@ if (!function_exists("easter_date")) { print 'Error '.$langs->trans("ErrorPHPDoesNotSupportCalendar")."
\n"; } else { - print 'Ok '.$langs->trans("PHPSupportCalendar")."
\n"; + print 'Ok '.$langs->trans("PHPSupport", "Calendar")."
\n"; } @@ -152,7 +152,7 @@ if (!function_exists("utf8_encode")) print 'Error '.$langs->trans("ErrorPHPDoesNotSupportUTF8")."
\n"; // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { - print 'Ok '.$langs->trans("PHPSupportUTF8")."
\n"; + print 'Ok '.$langs->trans("PHPSupport", "UTF8")."
\n"; } @@ -165,7 +165,7 @@ if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@loc print 'Error '.$langs->trans("ErrorPHPDoesNotSupportIntl")."
\n"; // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { - print 'Ok '.$langs->trans("PHPSupportIntl")."
\n"; + print 'Ok '.$langs->trans("PHPSupport", "Intl")."
\n"; } } diff --git a/htdocs/projet/graph_opportunities.inc.php b/htdocs/projet/graph_opportunities.inc.php index 6d0bec6255d..9588951307a 100644 --- a/htdocs/projet/graph_opportunities.inc.php +++ b/htdocs/projet/graph_opportunities.inc.php @@ -68,7 +68,7 @@ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $listofstatus = array_keys($listofoppstatus); // Complete with values found into database and not into the dictionary - foreach($valsamount as $key => $val) { + foreach ($valsamount as $key => $val) { if (!in_array($key, $listofstatus)) { $listofstatus[] = $key; } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 14e2cbe3277..a6f8a9ff3fa 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3828,9 +3828,8 @@ class Societe extends CommonObject if (!empty($tmp[1])) { // If $conf->global->MAIN_INFO_SOCIETE_STATE is "id:code:label" $state_code = $tmp[1]; $state_label = $tmp[2]; - } else // For backward compatibility - { - dol_syslog("Your state setup use an old syntax. Reedit it using setup area.", LOG_ERR); + } else { // For backward compatibility + dol_syslog("Your state setup use an old syntax (entity=".$conf->entity."). Reedit it using setup area.", LOG_ERR); include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; $state_code = getState($state_id, 2, $this->db); // This need a SQL request, but it's the old feature that should not be used anymore $state_label = getState($state_id, 0, $this->db); // This need a SQL request, but it's the old feature that should not be used anymore