diff --git a/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php b/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php index bee62cb384d..957ea33f60c 100644 --- a/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php +++ b/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php @@ -1289,12 +1289,12 @@ class AskPriceSupplier extends CommonObject $soc->fetch($this->socid); // Define new ref - if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) + if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life { $num = $this->getNextNumRef($soc); } else - { + { $num = $this->ref; } $this->newref = $num; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 421b2506e73..bfbc45b613d 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1481,12 +1481,12 @@ class Propal extends CommonObject $soc->fetch($this->socid); // Define new ref - if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) + if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life { $num = $this->getNextNumRef($soc); } else - { + { $num = $this->ref; } $this->newref = $num; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 94d5c91c94f..db8b94d769a 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2006 Andre Cianfarani @@ -165,7 +165,7 @@ if (empty($reshook)) } } - // Suppression de la commande + // Remove order else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->commande->supprimer) { $result = $object->delete($user); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 767bf294d6f..e681bfc7726 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -263,14 +263,14 @@ class Commande extends CommonOrder // Protection if ($this->statut == self::STATUS_VALIDATED) { - dol_syslog(get_class($this)."::valid no draft status", LOG_WARNING); + dol_syslog(get_class($this)."::valid action abandonned: no draft status", LOG_WARNING); return 0; } if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate)))) { - $this->error='Permission denied'; + $this->error='ErrorPermissionDenied'; dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); return -1; } @@ -287,7 +287,7 @@ class Commande extends CommonOrder $result=$soc->set_as_client(); // Define new ref - if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) + if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life { $num = $this->getNextNumRef($soc); } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index f0668bb0987..80ca5e1f139 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1827,7 +1827,7 @@ class Facture extends CommonInvoice { $num = $force_number; } - else if (preg_match('/^[\(]?PROV/i', $this->ref)) + else if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life { if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index eea23be7ae8..e88f4c95d54 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -402,7 +402,7 @@ class Contrat extends CommonObject $result=$this->thirdparty->set_as_client(); // Define new ref - if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) + if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life { $num = $this->getNextNumRef($this->thirdparty); } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index edd8aa0cd39..b43afdfc206 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -589,7 +589,7 @@ class Expedition extends CommonObject $result=$soc->set_as_client(); // Define new ref - if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) + if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life { $numref = $this->getNextNumRef($soc); } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index d0bcee286d0..fe93bc42143 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -400,7 +400,7 @@ class Fichinter extends CommonObject $now=dol_now(); // Define new ref - if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) + if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life { $num = $this->getNextNumRef($this->thirdparty); } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 9d77deff3ee..54022429fb3 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -388,7 +388,7 @@ class CommandeFournisseur extends CommonOrder $soc->fetch($this->fourn_id); // Check if object has a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) + if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life { $num = $this->getNextNumRef($soc); } @@ -684,7 +684,7 @@ class CommandeFournisseur extends CommonOrder $soc->fetch($this->fourn_id); // Check if object has a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) + if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life { $num = $this->getNextNumRef($soc); } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 6a209174d9f..890772326ea 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -925,7 +925,7 @@ class FactureFournisseur extends CommonInvoice { $num = $force_number; } - else if (preg_match('/^[\(]?PROV/i', $this->ref)) + else if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life { $num = $this->getNextNumRef($this->client); } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index fccd2652ed3..50bcefc36b2 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1672,7 +1672,10 @@ elseif (! empty($object->id)) $object->date_commande=dol_now(); // We check if number is temporary number - if (preg_match('/^[\(]?PROV/i',$object->ref)) $newref = $object->getNextNumRef($object->thirdparty); + if (preg_match('/^[\(]?PROV/i',$object->ref) || empty($object->ref)) // empty should not happened, but when it occurs, the test save life + { + $newref = $object->getNextNumRef($object->thirdparty); + } else $newref = $object->ref; if ($newref < 0) diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index 3a1704f8d8d..175d20a3952 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -379,7 +379,7 @@ class Livraison extends CommonObject $soc = new Societe($this->db); $soc->fetch($this->socid); - if (preg_match('/^[\(]?PROV/i', $this->ref)) + if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life { $numref = $objMod->livraison_get_num($soc,$this); }