Browse Source

MMIProduct : Add option to display one product line per supplier when looking for products to add to document

Mathieu Moulin 2 years ago
parent
commit
a734ad0c3a
2 changed files with 9 additions and 4 deletions
  1. 8 3
      htdocs/core/class/html.form.class.php
  2. 1 1
      htdocs/custom/mmiproduct

+ 8 - 3
htdocs/core/class/html.form.class.php

@@ -2597,7 +2597,7 @@ class Form
 		// include search in supplier ref
 		// Added by MMI Mathieu Moulin iProspective
 		// Hack : include search in supplier name
-		if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF) || !empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_LABEL)) {
+		if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_SHOW_MULTIPLE) || !empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF) || !empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_LABEL)) {
 			$sql .= " LEFT JOIN ".$this->db->prefix()."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
 		}
 		if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_LABEL)) {
@@ -2691,10 +2691,10 @@ class Form
 						$sql .= " OR pl.description LIKE '".$this->db->escape($prefix.$crit)."%'";
 					}
 				}
+				// Added by MMI Mathieu Moulin iProspective
 				if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) {
 					$sql .= " OR pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit)."%'";
 				}
-				// Added by MMI Mathieu Moulin iProspective
 				if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_LABEL)) {
 					$sql .= " OR pf.nom LIKE '".$this->db->escape($prefix.$crit)."%'";
 					$sql .= " OR pf.name_alias LIKE '".$this->db->escape($prefix.$crit)."%'";
@@ -2713,6 +2713,11 @@ class Form
 		if (count($warehouseStatusArray)) {
 			$sql .= " GROUP BY ".$selectFields;
 		}
+		// Added by MMI Mathieu Moulin iProspective
+		// @todo gérer le cas où on affiche plusieurs lignes par produit et on sélectionne => mettre le bon prix d'achat, etc.
+		elseif (empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_SHOW_MULTIPLE) && (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF) || !empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_LABEL))) {
+			$sql .= " GROUP BY p.rowid";
+		}
 
 		//Sort by category
 		if (!empty($conf->global->PRODUCT_SORT_BY_CATEGORY)) {
@@ -2851,7 +2856,7 @@ class Form
 	 * This define value for &$opt and &$optJson.
 	 * This function is called by select_produits_list().
 	 *
-	 * @param 	resource	$objp			    Resultset of fetch
+	 * @param 	resource|object	$objp			    Resultset of fetch
 	 * @param 	string		$opt			    Option (var used for returned value in string option format)
 	 * @param 	string		$optJson		    Option (var used for returned value in json format)
 	 * @param 	int			$price_level	    Price level

+ 1 - 1
htdocs/custom/mmiproduct

@@ -1 +1 @@
-Subproject commit 28b9a46fe689b2597ff066787655a462ba57fada
+Subproject commit ad9aade58a9323333511af2127a6bb859589c78d