deprecate formbarcode:select_barcode_type

This commit is contained in:
Frédéric FRANCE 2018-09-10 23:50:48 +02:00
parent d2c6c7ddff
commit 312a606345
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
4 changed files with 77 additions and 67 deletions

View File

@ -306,7 +306,7 @@ if (! empty($conf->product->enabled))
print '<tr class="oddeven">';
print '<td>'.$langs->trans("SetDefaultBarcodeTypeProducts").'</td>';
print '<td width="60" align="right">';
$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 '</td></tr>';
}
@ -317,7 +317,7 @@ if (! empty($conf->societe->enabled))
print '<tr class="oddeven">';
print '<td>'.$langs->trans("SetDefaultBarcodeTypeThirdParties").'</td>';
print '<td width="60" align="right">';
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 '</td></tr>';
}

View File

@ -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").' &nbsp; ';
print '</div><div class="tagtd" style="overflow: hidden; white-space: nowrap; max-width: 300px;">';
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 '</div></div>';
// Barcode value

View File

@ -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">&nbsp;</option>';
}
else
{
if ($useempty && $num > 0) {
$out .= '<select class="flat minwidth75imp" name="' . $htmlname . '" id="select_' . $htmlname . '">';
$out .= '<option value="0">&nbsp;</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>';
if ($selected == $obj->rowid) {
$out .= '<option value="' . $obj->rowid . '" selected>';
} else {
$out .= '<option value="' . $obj->rowid . '">';
}
else
{
print '<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>';

View File

@ -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 '</td><td>'.$langs->trans("BarcodeValue").'</td><td>';
$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 '</td><td>'.$langs->trans("BarcodeValue").'</td><td>';
$tmpcode=isset($_POST['barcode'])?GETPOST('barcode'):$object->barcode;
if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) $tmpcode=$modBarCodeProduct->getNextValue($object,$type);