From 2cf433019e25ff0e9bfd8fa183b1797fb8bd3e20 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Thu, 3 Feb 2022 16:03:25 +0100 Subject: [PATCH] FormCategory : create method to select the product category --- htdocs/core/class/html.form.class.php | 1 - htdocs/core/class/html.formcategory.class.php | 40 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ea6d145641a..2b300b580cd 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3708,7 +3708,6 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load into cache list of payment terms diff --git a/htdocs/core/class/html.formcategory.class.php b/htdocs/core/class/html.formcategory.class.php index 1a2c02deb54..707b5d5d0ac 100644 --- a/htdocs/core/class/html.formcategory.class.php +++ b/htdocs/core/class/html.formcategory.class.php @@ -60,4 +60,44 @@ class FormCategory extends Form return $filter; } + + /** + * Prints a select form for products categories + * @param string $selected Id category pre-selection + * @param string $htmlname Name of HTML field + * @param int $showempty Add an empty field + * @return integer|null + */ + public function selectProductCategory($selected = 0, $htmlname = 'product_category_id', $showempty = 0) + { + global $conf; + + $sql = "SELECT cp.fk_categorie as cat_index, cat.label FROM `llx_categorie_product` as cp INNER JOIN llx_categorie as cat ON cat.rowid = cp.fk_categorie GROUP BY cp.fk_categorie;"; + + dol_syslog(get_class($this)."::selectProductCategory", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + print ''); + + return $num_rows; + } else { + dol_print_error($this->db); + } + } }