From 41c663f03f8a09bef1b3b76e5ad93b0acec1143f Mon Sep 17 00:00:00 2001 From: Rui Strecht Date: Thu, 22 Feb 2018 12:22:31 +0000 Subject: [PATCH 1/2] Fixed issue with elementarray null if num_rows = 0 --- htdocs/projet/class/project.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 8dbce2790fa..c8096559c9c 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -584,10 +584,10 @@ class Project extends CommonObject $i++; } $this->db->free($result); - - /* Return array */ - return $elements; } + + /* Return array even if empty*/ + return $elements; } else { From 6793d826b704ad8e0468cbcf6ee5ef17d7f2c70f Mon Sep 17 00:00:00 2001 From: dolibarr95 <24292300+dolibarr95@users.noreply.github.com> Date: Fri, 23 Feb 2018 10:14:54 +0100 Subject: [PATCH 2/2] Dispatch if more than ordered If the constant SUPPLIER_ORDER_MORE_THAN_WISHED is set --- .../class/fournisseur.commande.class.php | 53 ++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 1bbde68172e..01114cf22c5 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2960,7 +2960,58 @@ class CommandeFournisseur extends CommonOrder } return 4; } - } + }elseif(! empty($conf->global->SUPPLIER_ORDER_MORE_THAN_WISHED) ) + {//set livraison to 'tot' if more products received than wished. (and if $closeopenorder is set to 1 of course...) + + $close=0; + + if( count($diff_array) > 0 ) + {//there are some difference between the two arrays + + //scan the array of results + foreach($diff_array as $key => $value) + {//if the quantity delivered is greater or equal to wish quantity + if($qtydelivered[$key] >= $qtywished[$key] ) + { + $close++; + } + + } + } + + + if($close == count($diff_array)) + {//all the products are received equal or more than the wished quantity + if ($closeopenorder) + { + $ret = $this->Livraison($user, $date_liv, 'tot', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + if ($ret<0) { + return -1; + } + return 5; + } + else + { + //Diff => received partially + $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + if ($ret<0) { + return -1; + } + return 4; + } + + + } + else + {//all the products are not received + $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + if ($ret<0) { + return -1; + } + return 4; + } + + } else { //Diff => received partially