|
@@ -1,21 +1,22 @@
|
|
|
<?php
|
|
|
-/* Copyright (C) 2007-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
|
|
- * Copyright (C) 2008-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
|
-*
|
|
|
-* 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 <http://www.gnu.org/licenses/>.
|
|
|
-*
|
|
|
-*/
|
|
|
+/* Copyright (C) 2007-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
|
|
+ * Copyright (C) 2008-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
|
+ * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
|
|
+ *
|
|
|
+ * 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 <http://www.gnu.org/licenses/>.
|
|
|
+ *
|
|
|
+ */
|
|
|
|
|
|
/**
|
|
|
* \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 '<select class="flat minwidth75imp" name="'.$htmlname.'" id="select_'.$htmlname.'">';
|
|
|
- print '<option value="0"> </option>';
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ if ($useempty && $num > 0) {
|
|
|
+ $out .= '<select class="flat minwidth75imp" name="' . $htmlname . '" id="select_' . $htmlname . '">';
|
|
|
+ $out .= '<option value="0"> </option>';
|
|
|
+ } else {
|
|
|
$langs->load("errors");
|
|
|
- print '<select disabled class="flat minwidth75imp" name="'.$htmlname.'" id="select_'.$htmlname.'">';
|
|
|
- print '<option value="0" selected>'.$langs->trans('ErrorNoActivatedBarcode').'</option>';
|
|
|
+ $out .= '<select disabled class="flat minwidth75imp" name="' . $htmlname . '" id="select_' . $htmlname . '">';
|
|
|
+ $out .= '<option value="0" selected>' . $langs->trans('ErrorNoActivatedBarcode') . '</option>';
|
|
|
}
|
|
|
|
|
|
- while ($i < $num)
|
|
|
- {
|
|
|
+ while ($i < $num) {
|
|
|
$obj = $this->db->fetch_object($result);
|
|
|
- if ($selected == $obj->rowid)
|
|
|
- {
|
|
|
- print '<option value="'.$obj->rowid.'" selected>';
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- print '<option value="'.$obj->rowid.'">';
|
|
|
+ if ($selected == $obj->rowid) {
|
|
|
+ $out .= '<option value="' . $obj->rowid . '" selected>';
|
|
|
+ } else {
|
|
|
+ $out .= '<option value="' . $obj->rowid . '">';
|
|
|
}
|
|
|
- print $obj->libelle;
|
|
|
- print '</option>';
|
|
|
+ $out .= $obj->libelle;
|
|
|
+ $out .= '</option>';
|
|
|
$i++;
|
|
|
}
|
|
|
- print "</select>";
|
|
|
- print ajax_combobox("select_".$htmlname);
|
|
|
+ $out .= "</select>";
|
|
|
+ $out .= ajax_combobox("select_".$htmlname);
|
|
|
}
|
|
|
else {
|
|
|
dol_print_error($this->db);
|
|
|
}
|
|
|
+ return $out;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -182,7 +192,7 @@ class FormBarCode
|
|
|
print '<input type="hidden" name="action" value="set'.$htmlname.'">';
|
|
|
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
|
|
|
print '<tr><td>';
|
|
|
- $this->select_barcode_type($selected, $htmlname, 1);
|
|
|
+ print $this->selectBarcodeType($selected, $htmlname, 1);
|
|
|
print '</td>';
|
|
|
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
|
|
print '</td></tr></table></form>';
|