From 312a606345a40b2164e024b485e88aa1416f0880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 10 Sep 2018 23:50:48 +0200 Subject: [PATCH 1/2] deprecate formbarcode:select_barcode_type --- htdocs/admin/barcode.php | 4 +- htdocs/barcode/printsheet.php | 28 ++--- htdocs/core/class/html.formbarcode.class.php | 108 ++++++++++--------- htdocs/product/card.php | 4 +- 4 files changed, 77 insertions(+), 67 deletions(-) diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index 4e0c683a73f..519f2b42938 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -306,7 +306,7 @@ if (! empty($conf->product->enabled)) print ''; print ''.$langs->trans("SetDefaultBarcodeTypeProducts").''; print ''; - $formbarcode->select_barcode_type($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE,"PRODUIT_DEFAULT_BARCODE_TYPE",1); + print $formbarcode->selectBarcodeType($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE, "PRODUIT_DEFAULT_BARCODE_TYPE", 1); print ''; } @@ -317,7 +317,7 @@ if (! empty($conf->societe->enabled)) print ''; print ''.$langs->trans("SetDefaultBarcodeTypeThirdParties").''; print ''; - print $formbarcode->select_barcode_type($conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY,"GENBARCODE_BARCODETYPE_THIRDPARTY",1); + print $formbarcode->selectBarcodeType($conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY, "GENBARCODE_BARCODETYPE_THIRDPARTY", 1); print ''; } diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index 6dd578993ca..a1f3632fd2f 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -178,19 +178,19 @@ if ($action == 'builddoc') { // List of values to scan for a replacement $substitutionarray = array ( - '%LOGIN%'=>$user->login, - '%COMPANY%'=>$mysoc->name, - '%ADDRESS%'=>$mysoc->address, - '%ZIP%'=>$mysoc->zip, - '%TOWN%'=>$mysoc->town, - '%COUNTRY%'=>$mysoc->country, - '%COUNTRY_CODE%'=>$mysoc->country_code, - '%EMAIL%'=>$mysoc->email, - '%YEAR%'=>$year, - '%MONTH%'=>$month, - '%DAY%'=>$day, - '%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT, - '%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/" + '%LOGIN%' => $user->login, + '%COMPANY%' => $mysoc->name, + '%ADDRESS%' => $mysoc->address, + '%ZIP%' => $mysoc->zip, + '%TOWN%' => $mysoc->town, + '%COUNTRY%' => $mysoc->country, + '%COUNTRY_CODE%' => $mysoc->country_code, + '%EMAIL%' => $mysoc->email, + '%YEAR%' => $year, + '%MONTH%' => $month, + '%DAY%' => $day, + '%DOL_MAIN_URL_ROOT%' => DOL_MAIN_URL_ROOT, + '%SERVER%' => "http://".$_SERVER["SERVER_NAME"]."/", ); complete_substitutions_array($substitutionarray, $langs); @@ -416,7 +416,7 @@ print $langs->trans("BarcodeType").'   '; print '
'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; $formbarcode = new FormBarCode($db); -$formbarcode->select_barcode_type($fk_barcode_type, 'fk_barcode_type', 1); +print $formbarcode->selectBarcodeType($fk_barcode_type, 'fk_barcode_type', 1); print '
'; // Barcode value diff --git a/htdocs/core/class/html.formbarcode.class.php b/htdocs/core/class/html.formbarcode.class.php index 6780f01735a..7b0f7bd06fe 100644 --- a/htdocs/core/class/html.formbarcode.class.php +++ b/htdocs/core/class/html.formbarcode.class.php @@ -1,21 +1,22 @@ - * Copyright (C) 2008-2012 Laurent Destailleur -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -*/ +/* Copyright (C) 2007-2012 Regis Houssin + * Copyright (C) 2008-2012 Laurent Destailleur + * Copyright (C) 2018 Frédéric France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ /** * \file htdocs/core/class/html.formbarcode.class.php @@ -32,11 +33,11 @@ class FormBarCode * @var DoliDB Database handler. */ public $db; - + /** - * @var string Error code (or message) - */ - public $error=''; + * @var string Error code (or message) + */ + public $error=''; /** @@ -104,17 +105,33 @@ class FormBarCode } /** - * Return form to select type of barcode + * Print form to select type of barcode * * @param int $selected Id code pre-selected * @param string $htmlname Name of HTML select field * @param int $useempty Affiche valeur vide dans liste * @return void + * @deprecated */ // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - function select_barcode_type($selected='',$htmlname='barcodetype_id',$useempty=0) + function select_barcode_type($selected='', $htmlname='barcodetype_id', $useempty=0) { - global $langs,$conf; + print $this->selectBarcodeType($selected, $htmlname, $useempty); + } + + /** + * Return html form to select type of barcode + * + * @param int $selected Id code pre-selected + * @param string $htmlname Name of HTML select field + * @param int $useempty Display empty value in select + * @return string + */ + function selectBarcodeType($selected='', $htmlname='barcodetype_id', $useempty=0) + { + global $langs, $conf; + + $out = ''; $sql = "SELECT rowid, code, libelle"; $sql.= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; @@ -123,44 +140,37 @@ class FormBarCode $sql.= " ORDER BY code"; $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $i = 0; - if ($useempty && $num > 0) - { - print ''; + $out .= ''; + } else { $langs->load("errors"); - print ''; + $out .= ''; } - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($result); - if ($selected == $obj->rowid) - { - print ''; + $out .= $obj->libelle; + $out .= ''; $i++; } - print ""; - print ajax_combobox("select_".$htmlname); + $out .= ""; + $out .= ajax_combobox("select_".$htmlname); } else { dol_print_error($this->db); } + return $out; } /** @@ -182,7 +192,7 @@ class FormBarCode print ''; print ''; print ''; print '
'; - $this->select_barcode_type($selected, $htmlname, 1); + print $this->selectBarcodeType($selected, $htmlname, 1); print ''; print '
'; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 52815c1303d..a252a1ccafa 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -977,7 +977,7 @@ else } require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; $formbarcode = new FormBarCode($db); - print $formbarcode->select_barcode_type($fk_barcode_type, 'fk_barcode_type', 1); + print $formbarcode->selectBarcodeType($fk_barcode_type, 'fk_barcode_type', 1); print ''.$langs->trans("BarcodeValue").''; $tmpcode=isset($_POST['barcode'])?GETPOST('barcode'):$object->barcode; if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) $tmpcode=$modBarCodeProduct->getNextValue($object,$type); @@ -1343,7 +1343,7 @@ else } require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; $formbarcode = new FormBarCode($db); - print $formbarcode->select_barcode_type($fk_barcode_type, 'fk_barcode_type', 1); + print $formbarcode->selectBarcodeType($fk_barcode_type, 'fk_barcode_type', 1); print ''.$langs->trans("BarcodeValue").''; $tmpcode=isset($_POST['barcode'])?GETPOST('barcode'):$object->barcode; if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) $tmpcode=$modBarCodeProduct->getNextValue($object,$type); From a36f41728f2ae61e67f05e993168d7fbfbb2f590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 10 Sep 2018 23:58:57 +0200 Subject: [PATCH 2/2] deprecate formbarcode:form_barcode_type --- htdocs/core/class/html.formbarcode.class.php | 39 ++++++++++++++------ htdocs/product/card.php | 2 +- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/htdocs/core/class/html.formbarcode.class.php b/htdocs/core/class/html.formbarcode.class.php index 7b0f7bd06fe..78bcb35d863 100644 --- a/htdocs/core/class/html.formbarcode.class.php +++ b/htdocs/core/class/html.formbarcode.class.php @@ -180,22 +180,37 @@ class FormBarCode * @param int $selected Id condition preselected * @param string $htmlname Nom du formulaire select * @return void + * @deprecated */ // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function form_barcode_type($page, $selected='', $htmlname='barcodetype_id') { - global $langs,$conf; - if ($htmlname != "none") - { - print '
'; - print ''; - print ''; - print ''; - print ''; - print '
'; - print $this->selectBarcodeType($selected, $htmlname, 1); - print ''; - print '
'; + print $this->formBarcodeType($page, $selected, $htmlname); + } + + /** + * Return html form to select type of barcode + * + * @param string $page Page + * @param int $selected Id condition preselected + * @param string $htmlname Nom du formulaire select + * @return string + */ + function formBarcodeType($page, $selected='', $htmlname='barcodetype_id') + { + global $langs, $conf; + $out = ''; + if ($htmlname != "none") { + $out .= '
'; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= '
'; + $out .= $this->selectBarcodeType($selected, $htmlname, 1); + $out .= ''; + $out .= '
'; } + return $out; } } diff --git a/htdocs/product/card.php b/htdocs/product/card.php index a252a1ccafa..d51a4fa494c 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1639,7 +1639,7 @@ else } if ($action == 'editbarcodetype') { - $formbarcode->form_barcode_type($_SERVER['PHP_SELF'].'?id='.$object->id,$object->barcode_type,'fk_barcode_type'); + print $formbarcode->formBarcodeType($_SERVER['PHP_SELF'].'?id='.$object->id, $object->barcode_type, 'fk_barcode_type'); } else {