dolibarr 21.0.0-beta
html.formorder.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2008-2012 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2016 Marcos GarcĂ­a <marcosgdf@gmail.com>
4 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
27require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
28
33class FormOrder extends Form
34{
45 public function selectSupplierOrderStatus($selected = '', $short = 0, $htmlname = 'order_status', $morecss = '', $multi = 1)
46 {
47 $options = array();
48
49 // 7 is same label than 6. 8 does not exists (billed is another field)
50 $statustohow = array(
51 '0' => '0',
52 '1' => '1',
53 '2' => '2',
54 '3' => '3',
55 '4' => '4',
56 '5' => '5',
57 '6' => '6,7',
58 '9' => '9'
59 );
60
61 $tmpsupplierorder = new CommandeFournisseur($this->db);
62
63 foreach ($statustohow as $key => $value) {
64 $tmpsupplierorder->statut = $key;
65 $tmpsupplierorder->status = $key;
66 $options[$value] = $tmpsupplierorder->getLibStatut($short);
67 }
68
69 if (is_array($selected)) {
70 $selectedarray = $selected;
71 } else {
72 $selectedarray = explode(',', $selected);
73 }
74
75 if (!empty($selectedarray[6])) { // special case for status '6,7'
76 unset($selectedarray[6]);
77 unset($selectedarray[7]);
78 $selectedarray['6,7'] = '6,7';
79 }
80
81 if ($multi) {
82 print Form::multiselectarray($htmlname, $options, $selectedarray, 0, 0, $morecss, 0, 0);
83 } else {
84 print Form::selectarray($htmlname, $options, $selectedarray, 0, 0, 0, '', 0, 0, 0, '', $morecss); // $selectedarray is ok for $id param @phan-suppress-current-line PhanPluginSuspiciousParamOrder
85 }
86 }
87
96 public function selectOrderStatus($selected = '', $short = 0, $htmlname = 'order_status')
97 {
98 $options = array();
99
100 $statustohow = array(
106 );
107
108 $tmpsupplierorder = new Commande($this->db);
109
110 foreach ($statustohow as $value) {
111 $tmpsupplierorder->statut = $value;
112 $options[$value] = $tmpsupplierorder->getLibStatut($short);
113 }
114
115 if (is_array($selected)) {
116 $selectedarray = $selected;
117 } else {
118 $selectedarray = explode(',', $selected);
119 }
120
121 print Form::multiselectarray($htmlname, $options, $selectedarray, 0, 0, '', 0, 150);
122 }
123
133 public function selectInputMethod($selected = '', $htmlname = 'source_id', $addempty = 0)
134 {
135 global $langs;
136
137 $listofmethods = array();
138
139 $sql = "SELECT rowid, code, libelle as label";
140 $sql .= " FROM ".$this->db->prefix()."c_input_method";
141 $sql .= " WHERE active = 1";
142
143 dol_syslog(get_class($this)."::selectInputMethod", LOG_DEBUG);
144 $resql = $this->db->query($sql);
145
146 if (!$resql) {
147 dol_print_error($this->db);
148 return -1;
149 }
150
151 while ($obj = $this->db->fetch_object($resql)) {
152 $listofmethods[$obj->rowid] = $langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : $obj->label;
153 }
154
155 print Form::selectarray($htmlname, $listofmethods, $selected, $addempty);
156
157 return 1;
158 }
159}
Class to manage predefined suppliers products.
Class to manage customers orders.
const STATUS_SHIPMENTONPROCESS
Shipment on process.
const STATUS_CLOSED
Closed (Sent, billed or not)
const STATUS_CANCELED
Canceled status.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated status.
Class to manage generation of HTML components Only common components must be here.
static selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $moreparam='', $translate=0, $maxlen=0, $disabled=0, $sort='', $morecss='minwidth75', $addjscombo=1, $moreparamonempty='', $disablebademail=0, $nohtmlescape=0)
Return a HTML select string, built from an array of key+value.
static multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $morecss='', $translate=0, $width=0, $moreattrib='', $elemtype='', $placeholder='', $addjscombo=-1)
Show a multiselect form from an array.
Class to manage HTML output components for orders Before adding component here, check they are not in...
selectInputMethod($selected='', $htmlname='source_id', $addempty=0)
Return list of input method (mode used to receive order, like order received by email,...
selectOrderStatus($selected='', $short=0, $htmlname='order_status')
Return combo list of different status of orders.
selectSupplierOrderStatus($selected='', $short=0, $htmlname='order_status', $morecss='', $multi=1)
Return combo list of different statuses of orders.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.