From e40bffb0d54e85eef649f97a1034493cf2369f11 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Oct 2017 20:21:47 +0200 Subject: [PATCH] Fix bug reported by scrutinizer --- .../adherents/class/adherent_type.class.php | 4 ++-- htdocs/api/class/api_documents.class.php | 4 ++-- htdocs/compta/bank/class/account.class.php | 7 ++----- htdocs/fichinter/class/fichinter.class.php | 2 ++ .../class/fournisseur.commande.class.php | 20 +++++++++---------- htdocs/product/class/product.class.php | 7 ++----- 6 files changed, 19 insertions(+), 25 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 5537730e678..f5f6a161ec5 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -55,9 +55,9 @@ class AdherentType extends CommonObject * @since 5.0 */ public $subscription; - /** @var string Public note */ + /** @var string Public note */ public $note; - /** @var bool Can vote*/ + /** @var integer Can vote */ public $vote; /** @var string Email sent during validation */ public $mail_valid; diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 9ac5b643476..52ed728a769 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -68,7 +68,7 @@ class Documents extends DolibarrApi */ public function index($module_part, $original_file='', $regeneratedoc=0) { - global $conf; + global $conf, $langs; if (empty($module_part)) { throw new RestException(400, 'bad value for parameter modulepart'); @@ -108,7 +108,7 @@ class Documents extends DolibarrApi if( ! $result ) { throw new RestException(404, 'Invoice not found'); } - $result = $this->invoice->generateDocument($this->invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $this->invoice->generateDocument($this->invoice->modelpdf, $langs, $hidedetails, $hidedesc, $hideref); if( $result <= 0 ) { throw new RestException(500, 'Error generating document'); } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 0167b725dfd..23818d4aa9d 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1306,11 +1306,8 @@ class Account extends CommonObject } $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; - if (empty($mode)) - { - $url = DOL_URL_ROOT.'/compta/bank/card.php?id='.$this->id; - } - else if ($mode == 'transactions') + $url = DOL_URL_ROOT.'/compta/bank/card.php?id='.$this->id; + if ($mode == 'transactions') { $url = DOL_URL_ROOT.'/compta/bank/bankentries_list.php?id='.$this->id; } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index f9b6bddf80c..68096eea8e9 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1562,6 +1562,8 @@ class FichinterLigne extends CommonObjectLine { global $langs,$conf; + $error=0; + if ($this->statut == 0) { dol_syslog(get_class($this)."::deleteline lineid=".$this->rowid); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 760caf8f385..0b8d45b18ad 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1981,10 +1981,16 @@ class CommandeFournisseur extends CommonOrder if ($user->rights->fournisseur->commande->receptionner) { + // Define the new status if ($type == 'par') $statut = self::STATUS_RECEIVED_PARTIALLY; - if ($type == 'tot') $statut = self::STATUS_RECEIVED_COMPLETELY; - if ($type == 'nev') $statut = self::STATUS_CANCELED_AFTER_ORDER; - if ($type == 'can') $statut = self::STATUS_CANCELED_AFTER_ORDER; + elseif ($type == 'tot') $statut = self::STATUS_RECEIVED_COMPLETELY; + elseif ($type == 'nev') $statut = self::STATUS_CANCELED_AFTER_ORDER; + elseif ($type == 'can') $statut = self::STATUS_CANCELED_AFTER_ORDER; + else { + $error++; + dol_syslog(get_class($this)."::Livraison Error -2", LOG_ERR); + return -2; + } // Some checks to accept the record if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) @@ -2018,14 +2024,6 @@ class CommandeFournisseur extends CommonOrder // TODO LDR01 Add a control test to accept only if ALL predefined products are received (same qty). - // $statut is the new statut after reception - if (! $error && ! ($statut == self::STATUS_RECEIVED_PARTIALLY || $statut == self::STATUS_RECEIVED_COMPLETELY || $statut == self::STATUS_CANCELED_AFTER_ORDER)) - { - $error++; - dol_syslog(get_class($this)."::Livraison Error -2", LOG_ERR); - $result = -2; - } - if (! $error) { $this->db->begin(); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index d2c52ec4255..17bbc1c8009 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3596,14 +3596,11 @@ class Product extends CommonObject case 2: return $this->LibStatut($status,3,2).' '.$this->LibStatut($status,1,2); case 3: - if ($status == 0 ) + if ($status == 0) { return img_picto($langs->trans('ProductStatusNotOnBatch'),'statut5'); } - else - { - return img_picto($langs->trans('ProductStatusOnBatch'),'statut4'); - } + return img_picto($langs->trans('ProductStatusOnBatch'),'statut4'); case 4: return $this->LibStatut($status,3,2).' '.$this->LibStatut($status,0,2); case 5: