diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index 90bf948e215..2499176b58b 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -300,17 +300,17 @@ class dolReceiptPrinter extends Escpos function selectTypePrinter($selected='', $htmlname='printertypeid') { global $langs; - $error = 0; - $html = ''; - - $this->resprint = $html; - return $error; + + $options = array( + 1 => $langs->trans('CONNECTOR_DUMMY'), + 2 => $langs->trans('CONNECTOR_FILE_PRINT'), + 3 => $langs->trans('CONNECTOR_NETWORK_PRINT'), + 4 => $langs->trans('CONNECTOR_WINDOWS_PRINT') + ); + + $this->resprint = Form::selectarray($htmlname, $options, $selected); + + return 0; } @@ -324,17 +324,17 @@ class dolReceiptPrinter extends Escpos function selectProfilePrinter($selected='', $htmlname='printerprofileid') { global $langs; - $error = 0; - $html = ''; - - $this->profileresprint = $html; - return $error; + + $options = array( + 0 => $langs->trans('PROFILE_DEFAULT'), + 1 => $langs->trans('PROFILE_SIMPLE'), + 2 => $langs->trans('PROFILE_EPOSTEP'), + 3 => $langs->trans('PROFILE_P822D'), + 4 => $langs->trans('PROFILE_STAR') + ); + + $this->profileresprint = Form::selectarray($htmlname, $options, $selected); + return 0; } diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 9091b4aead0..d51765e2a16 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -146,9 +146,6 @@ class FormCompany print ''; print ''; print ''; diff --git a/htdocs/core/class/html.formmailing.class.php b/htdocs/core/class/html.formmailing.class.php index 3c47aceee8a..0c63049f9d8 100644 --- a/htdocs/core/class/html.formmailing.class.php +++ b/htdocs/core/class/html.formmailing.class.php @@ -27,22 +27,8 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php'; */ class FormMailing extends Form { - public $db; - public $error; public $errors=array(); - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - return 1; - } - /** * Output a select with destinaries status * @@ -59,26 +45,14 @@ class FormMailing extends Form require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; $mailing = new Mailing($this->db); - - $array = $mailing->statut_dest; - //Cannot use form->selectarray because empty value is defaulted to -1 in this method and we use here status -1... - - $out = ''; - return $out; + return Form::selectarray($htmlname, $options, $selectedid, 0, 0, 0, '', 1); } } diff --git a/htdocs/core/class/html.formorder.class.php b/htdocs/core/class/html.formorder.class.php index 4ecbef60b58..68fa96e03ee 100644 --- a/htdocs/core/class/html.formorder.class.php +++ b/htdocs/core/class/html.formorder.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2016 Marcos GarcĂ­a * * 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 @@ -21,29 +22,14 @@ * \brief File of predefined functions for HTML forms for order module */ +require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php'; /** * Class to manage HTML output components for orders * Before adding component here, check they are not into common part Form.class.php */ -class FormOrder +class FormOrder extends Form { - var $db; - var $error; - - - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - return 1; - } - /** * Return combo list of differents status of a orders @@ -53,51 +39,32 @@ class FormOrder * @param string $hmlname Name of HTML select element * @return void */ - function selectSupplierOrderStatus($selected='', $short=0, $hmlname='order_status') + public function selectSupplierOrderStatus($selected='', $short=0, $hmlname='order_status') { - $tmpsupplierorder=new CommandeFournisseur($db); - - print ''; + // 7 is same label than 6. 8 does not exists (billed is another field) + $statustohow = array( + '0' => '0', + '1' => '1', + '2' => '2', + '3' => '3', + '4' => '4', + '5' => '5', + '6' => '6,7', + '9' => '9' + ); + + $tmpsupplierorder = new CommandeFournisseur($this->db); + + foreach ($statustohow as $key => $value) { + $tmpsupplierorder->statut = $key; + $options[$value] = $tmpsupplierorder->getLibStatut($short); + } + + print Form::selectarray($hmlname, $options, $selected, 1); } - /** - * Return list of way to order - * - * @param string $selected Id of preselected order origin - * @param string $htmlname Name of HTML select list - * @param int $addempty 0=liste sans valeur nulle, 1=ajoute valeur inconnue - * @return array Tableau des sources de commandes - */ - function selectSourcesCommande($selected='',$htmlname='source_id',$addempty=0) - { - global $conf,$langs; - print ''; - } - - /** * Return list of input method (mode used to receive order, like order received by email, fax, online) * List found into table c_input_method. @@ -107,11 +74,9 @@ class FormOrder * @param int $addempty 0=list with no empty value, 1=list with empty value * @return array Tableau des sources de commandes */ - function selectInputMethod($selected='',$htmlname='source_id',$addempty=0) + public function selectInputMethod($selected='',$htmlname='source_id',$addempty=0) { - global $conf,$langs,$form; - - if (! is_object($form)) $form=new Form($this->db); + global $langs; $listofmethods=array(); @@ -121,24 +86,18 @@ class FormOrder dol_syslog(get_class($this)."::selectInputMethod", LOG_DEBUG); $resql=$this->db->query($sql); - if ($resql) - { - $i = 0; - $num = $this->db->num_rows($resql); - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - $listofmethods[$obj->rowid] = $langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):$obj->label; - $i++; - } - } - else - { + + if (!$resql) { dol_print_error($this->db); return -1; } - print $form->selectarray($htmlname,$listofmethods,$selected,$addempty); + while ($obj = $this->db->fetch_object($resql)) { + $listofmethods[$obj->rowid] = $langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : $obj->label; + } + + print Form::selectarray($htmlname,$listofmethods,$selected,$addempty); + return 1; } diff --git a/htdocs/margin/admin/margin.php b/htdocs/margin/admin/margin.php index 6e84b13e286..3a61ee0e72e 100644 --- a/htdocs/margin/admin/margin.php +++ b/htdocs/margin/admin/margin.php @@ -236,6 +236,12 @@ print ''; print ''; // GLOBAL DISCOUNT MANAGEMENT +$methods = array( + 1 => $langs->trans('UseDiscountAsProduct'), + 2 => $langs->trans('UseDiscountAsService'), + 3 => $langs->trans('UseDiscountOnTotal') +); + $var=!$var; print ''; print ''; @@ -243,20 +249,7 @@ print ""; print ''; print ''; print ''; print '
'; - print ''; print ''.$langs->trans('ForceBuyingPriceIfNullDetails').'
'.$langs->trans("MARGIN_METHODE_FOR_DISCOUNT").''; -print ''; +print Form::selectarray('MARGIN_METHODE_FOR_DISCOUNT', $methods, $conf->global->MARGIN_METHODE_FOR_DISCOUNT); print ''; print ''; diff --git a/htdocs/product/document.php b/htdocs/product/document.php index facff9f9a52..ca207f8429f 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -262,43 +262,11 @@ if ($object->id) print '
'; - $delauft_lang = (empty($lang_id)) ? $langs->getDefaultLang() : $lang_id; + $delauft_lang = empty($lang_id) ? $langs->getDefaultLang() : $lang_id; $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12); - print ''; + print Form::selectarray('lang_id', $langs_available, $delauft_lang, 0, 0, 0, '', 0, 0, 0, 'ASC'); if ($conf->global->MAIN_MULTILANGS) { print ''; diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index 782a7f070c4..74a05cba39d 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -439,12 +439,12 @@ abstract class ActionsCardCommon if ($modCodeClient->code_auto) $this->tpl['prefix_customercode'] = $modCodeClient->verif_prefixIsUsed(); // TODO create a function - $this->tpl['select_customertype'] = ''; + $this->tpl['select_customertype'] = Form::selectarray('client', array( + 0 => $langs->trans('NorProspectNorCustomer'), + 1 => $langs->trans('Customer'), + 2 => $langs->trans('Prospect'), + 3 => $langs->trans('ProspectCustomer') + ), $this->object->client); // Customer $this->tpl['customercode'] = $this->object->code_client;