From 435be30047efbd80f8d2695dec1fac03769fd560 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Mar 2015 00:35:17 +0100 Subject: [PATCH] Clean code --- htdocs/commande/class/commande.class.php | 13 +++++++------ test/phpunit/CommandeTest.php | 2 ++ test/phpunit/FactureTest.php | 1 + 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index b8d47ddf95c..1bcfa1ee7cb 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -777,15 +777,16 @@ class Commande extends CommonOrder } // update ref - if (empty($this->ref)) - { - $this->ref = '(PROV'.$this->id.')'; - } - $sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='".$this->ref."' WHERE rowid=".$this->id; + $initialref='(PROV'.$this->id.')'; + if (! empty($this->ref)) $initialref=$this->ref; + + $sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='".$this->db->escape($initialref)."' WHERE rowid=".$this->id; if ($this->db->query($sql)) { if ($this->id) { + $this->ref = $initialref; + // Add object linked if (is_array($this->linked_objects) && ! empty($this->linked_objects)) { @@ -803,7 +804,7 @@ class Commande extends CommonOrder { // On recupere les differents contact interne et externe $prop = new Propal($this->db); - $prop->fetch($origin_id); + $prop->fetch($origin_id); // We get ids of sales representatives of proposal $this->userid = $prop->getIdcontact('internal', 'SALESREPFOLL'); diff --git a/test/phpunit/CommandeTest.php b/test/phpunit/CommandeTest.php index 0bb7788d33f..aaba882cc87 100644 --- a/test/phpunit/CommandeTest.php +++ b/test/phpunit/CommandeTest.php @@ -77,6 +77,8 @@ class CommandeTest extends PHPUnit_Framework_TestCase global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + if (empty($conf->commande->enabled)) { print __METHOD__." module customer order must be enabled.\n"; die(); } + print __METHOD__."\n"; } diff --git a/test/phpunit/FactureTest.php b/test/phpunit/FactureTest.php index 3248be7104c..d2ad97454bf 100644 --- a/test/phpunit/FactureTest.php +++ b/test/phpunit/FactureTest.php @@ -76,6 +76,7 @@ class FactureTest extends PHPUnit_Framework_TestCase { global $conf,$user,$langs,$db; + if (empty($conf->facture->enabled)) { print __METHOD__." module customer invoice must be enabled.\n"; die(); } if (! empty($conf->ecotaxdeee->enabled)) { print __METHOD__." ecotaxdeee module must not be enabled.\n"; die(); } $db->begin(); // This is to have all actions inside a transaction even if test launched without suite.