From b6f9500d4695b48f81d0150b4c97bdb0ea5f96dc Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 27 Jan 2022 12:00:55 +0100 Subject: [PATCH] FIX uniformize code and remove unused global --- htdocs/core/class/html.form.class.php | 112 ++++++++++++-------------- 1 file changed, 51 insertions(+), 61 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 6c4984eaff9..00a12ad9965 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -204,7 +204,7 @@ class Form */ public function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata = 'string', $editvalue = '', $extObject = null, $custommsg = null, $moreparam = '', $notabletag = 0, $formatfunc = '', $paramid = 'id') { - global $conf, $langs, $db; + global $conf, $langs; $ret = ''; @@ -1088,7 +1088,7 @@ class Form public function select_type_of_lines($selected = '', $htmlname = 'type', $showempty = 0, $hidetext = 0, $forceall = 0) { // phpcs:enable - global $db, $langs, $user, $conf; + global $langs, $conf; // If product & services are enabled or both disabled. if ($forceall == 1 || (empty($forceall) && !empty($conf->product->enabled) && !empty($conf->service->enabled)) @@ -2395,7 +2395,7 @@ class Form public function select_produits_list($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $filterkey = '', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '') { // phpcs:enable - global $langs, $conf, $user, $db; + global $langs, $conf; $out = ''; $outarray = array(); @@ -2498,7 +2498,7 @@ class Form $sql .= " LEFT JOIN ".$this->db->prefix()."product_lang as pl ON pl.fk_product = p.rowid "; if (!empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE) && !empty($socid)) { require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $soc = new Societe($db); + $soc = new Societe($this->db); $result = $soc->fetch($socid); if ($result > 0 && !empty($soc->default_lang)) { $sql .= " AND pl.lang = '".$this->db->escape($soc->default_lang)."'"; @@ -2712,7 +2712,7 @@ class Form } return $outarray; } else { - dol_print_error($db); + dol_print_error($this->db); } } @@ -2733,7 +2733,7 @@ class Form */ protected function constructProductListOption(&$objp, &$opt, &$optJson, $price_level, $selected, $hidepriceinlabel = 0, $filterkey = '', $novirtualstock = 0) { - global $langs, $conf, $user, $db; + global $langs, $conf, $user; $outkey = ''; $outval = ''; @@ -3110,7 +3110,7 @@ class Form public function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '', $showstockinlist = 0, $placeholder = '') { // phpcs:enable - global $langs, $conf, $db, $user; + global $langs, $conf, $user; $out = ''; $outarray = array(); @@ -4302,7 +4302,7 @@ class Form */ public function formSelectShippingMethod($page, $selected = '', $htmlname = 'shipping_method_id', $addempty = 0) { - global $langs, $db; + global $langs; $langs->load("deliveries"); @@ -4315,7 +4315,7 @@ class Form print ''; } else { if ($selected) { - $code = $langs->getLabelFromKey($db, $selected, 'c_shipment_mode', 'rowid', 'code'); + $code = $langs->getLabelFromKey($this->db, $selected, 'c_shipment_mode', 'rowid', 'code'); print $langs->trans("SendingMethod".strtoupper($code)); } else { print " "; @@ -4337,8 +4337,8 @@ class Form $langs->load('bills'); - $opt = ''; - $sql = 'SELECT rowid, ref, situation_cycle_ref, situation_counter, situation_final, fk_soc'; + $opt = ''; + $sql = "SELECT rowid, ref, situation_cycle_ref, situation_counter, situation_final, fk_soc"; $sql .= ' FROM '.$this->db->prefix().'facture'; $sql .= ' WHERE entity IN ('.getEntity('invoice').')'; $sql .= ' AND situation_counter >= 1'; @@ -4394,7 +4394,7 @@ class Form $return = ''; if ($useempty) { $out .= ''; } - while ($obj = $db->fetch_object($resql)) { + while ($obj = $this->db->fetch_object($resql)) { $out .= ''; } $out .= ''; @@ -9387,10 +9377,10 @@ class Form if (!empty($target)) { $sql = "SELECT c.id FROM ".$this->db->prefix()."c_type_fees as c WHERE c.code = 'EX_KME' AND c.active = 1"; - $resql = $db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - if ($db->num_rows($resql) > 0) { - $obj = $db->fetch_object($resql); + if ($this->db->num_rows($resql) > 0) { + $obj = $this->db->fetch_object($resql); $out .= '