dolibarr 24.0.0-beta
webportalorder.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2023-2024 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2023-2024 Lionel Vessiller <lvessiller@easya.solutions>
4 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Put here all includes required by your class file
28require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
29
34{
38 public $module = 'webportal';
39
43 const ARRAY_STATUS_LABEL = array(
44 Commande::STATUS_DRAFT => 'StatusOrderDraftShort',
45 Commande::STATUS_VALIDATED => 'StatusOrderValidated',
46 Commande::STATUS_SHIPMENTONPROCESS => 'StatusOrderSentShort',
47 Commande::STATUS_CLOSED => 'StatusOrderDelivered',
48 Commande::STATUS_CANCELED => 'StatusOrderCanceledShort',
49 );
50
54 protected $order_static = null;
55
95 // BEGIN MODULEBUILDER PROPERTIES
99 public $fields = array(
100 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => 0, 'notnull' => 1, 'position' => 10,),
101 'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => '1', 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 20, 'index' => 1,),
102 'ref' => array('type' => 'varchar(30)', 'label' => 'Ref', 'enabled' => 1, 'visible' => 2, 'notnull' => 1, 'showoncombobox' => 1, 'position' => 25,),
103 'date_commande' => array('type' => 'date', 'label' => 'Date', 'enabled' => 1, 'visible' => 2, 'position' => 60,),
104 'date_livraison' => array('type' => 'date', 'label' => 'DateDeliveryPlanned', 'enabled' => 1, 'visible' => 2, 'position' => 70,),
105 'total_ht' => array('type' => 'price', 'label' => 'TotalHT', 'enabled' => 1, 'visible' => 2, 'position' => 125, 'isameasure' => 1,),
106 'total_tva' => array('type' => 'price', 'label' => 'VAT', 'enabled' => 1, 'visible' => 2, 'position' => 130, 'isameasure' => 1,),
107 'total_ttc' => array('type' => 'price', 'label' => 'TotalTTC', 'enabled' => 1, 'visible' => 2, 'position' => 145, 'isameasure' => 1,),
108 'multicurrency_total_ht' => array('type' => 'price', 'label' => 'MulticurrencyAmountHT', 'enabled' => 'isModEnabled("multicurrency")', 'visible' => -2, 'position' => 255, 'isameasure' => 1,),
109 'multicurrency_total_tva' => array('type' => 'price', 'label' => 'MulticurrencyAmountVAT', 'enabled' => 'isModEnabled("multicurrency")', 'visible' => -2, 'position' => 260, 'isameasure' => 1,),
110 'multicurrency_total_ttc' => array('type' => 'price', 'label' => 'MulticurrencyAmountTTC', 'enabled' => 'isModEnabled("multicurrency")', 'visible' => -2, 'position' => 265, 'isameasure' => 1,),
111 'fk_statut' => array('type' => 'smallint(6)', 'label' => 'Status', 'enabled' => 1, 'visible' => 2, 'position' => 500, 'notnull' => -1, 'arrayofkeyval' => self::ARRAY_STATUS_LABEL,),
112 );
113 //public $rowid;
114 //public $ref;
115 //public $date_commande;
116 //public $date_livraison;
117 //public $total_ht;
118 //public $total_tva;
119 //public $total_ttc;
120 //public $multicurrency_total_ht;
121 //public $multicurrency_total_tva;
122 //public $multicurrency_total_ttc;
123
127 public $fk_statut;
128 // END MODULEBUILDER PROPERTIES
129
130
136 protected function getOrderStatic()
137 {
138 if (!$this->order_static) {
139 $this->order_static = new Commande($this->db);
140 }
141
142 return $this->order_static;
143 }
144
150 public function __construct(DoliDB $db)
151 {
152 global $langs;
153
154 $this->db = $db;
155
156 $this->isextrafieldmanaged = 0;
157
158 $this->getOrderStatic();
159 }
160
167 public function getTooltipContentArray($params)
168 {
169 global $langs;
170
171 $datas = [];
172
173 if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER')) {
174 return ['optimize' => $langs->trans("WebPortalOrder")];
175 }
176 $datas['picto'] = img_picto('', $this->picto) . ' <u>' . $langs->trans("WebPortalOrder") . '</u>';
177 $datas['picto'] .= ' ' . $this->getLibStatut(5);
178
179 $datas['ref'] = '<br><b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
180
181 return $datas;
182 }
183
197 public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $notooltip = 0, $save_lastsearch_value = -1, $addlinktonotes = 0, $target = '')
198 {
199 global $conf, $langs, $hookmanager;
200
201 if (!empty($conf->dol_no_mouse_hover)) {
202 $notooltip = 1; // Force disable tooltips
203 }
204
205 $result = '';
206
207 $url = '';
208
209 $option = 'nolink';
210
211 if ($short) {
212 return $url;
213 }
214 $params = [
215 'id' => $this->id,
216 'objecttype' => $this->element,
217 'option' => $option,
218 'nofetch' => 1,
219 ];
220 $classfortooltip = 'classfortooltip';
221 $dataparams = '';
222 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
223 $classfortooltip = 'classforajaxtooltip';
224 $dataparams = ' data-params="' . dol_escape_htmltag(json_encode($params)) . '"';
225 $label = '';
226 } else {
227 $label = implode($this->getTooltipContentArray($params));
228 }
229
230 $linkclose = '';
231
232 $linkstart = '<a href="' . $url . '"';
233 $linkstart .= $linkclose . '>';
234 $linkend = '</a>';
235
236 if ($option === 'nolink') {
237 $linkstart = '';
238 $linkend = '';
239 }
240
241 $result .= $linkstart;
242 if ($withpicto) {
243 $result .= img_object(($notooltip ? '' : $label), $this->picto, (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
244 }
245 if ($withpicto != 2) {
246 $result .= $this->ref;
247 }
248 $result .= $linkend;
249
250 global $action;
251 $hookmanager->initHooks(array($this->element . 'dao'));
252 $parameters = array('id' => $this->id, 'getnomurl' => &$result);
253 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
254 if ($reshook > 0) {
255 $result = $hookmanager->resPrint;
256 } else {
257 $result .= $hookmanager->resPrint;
258 }
259 return $result;
260 }
261
269 public function getKanbanView($option = '', $arraydata = null)
270 {
271 global $langs, $conf;
272
273 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
274
275 $return = '<div class="box-flex-item box-flex-grow-zero">';
276 $return .= '<div class="info-box info-box-sm">';
277 $return .= '<div class="info-box-icon bg-infobox-action">';
278 $return .= img_picto('', 'order');
279 $return .= '</div>';
280 $return .= '<div class="info-box-content">';
281 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">' . (method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref) . '</span>';
282 $return .= '<input id="cb' . $this->id . '" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="' . $this->id . '"' . ($selected ? ' checked="checked"' : '') . '>';
283
284 if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) {
285 $return .= '<br><div class="info-box-ref tdoverflowmax150">' . $this->thirdparty->getNomUrl(1) . '</div>';
286 }
287 if (property_exists($this, 'total_ht')) {
288 $return .= '<div class="info-box-ref amount">' . price($this->total_ht, 0, $langs, 0, -1, -1, getDolCurrency()) . ' ' . $langs->trans('HT') . '</div>';
289 }
290 if (method_exists($this, 'getLibStatut')) {
291 $return .= '<div class="info-box-status margintoponly">' . $this->getLibStatut(5) . '</div>';
292 }
293 $return .= '</div>';
294 $return .= '</div>';
295 $return .= '</div>';
296
297 return $return;
298 }
299
306 public function getLabelStatus($mode = 0)
307 {
308 return $this->LibStatut($this->fk_statut, $this->billed, $mode);
309 }
310
317 public function getLibStatut($mode = 0)
318 {
319 return $this->LibStatut($this->fk_statut, $this->billed, $mode);
320 }
321
322 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
332 public function LibStatut($status, $billed, $mode, $donotshowbilled = 0)
333 {
334 // phpcs:enable
335 return $this->getOrderStatic()->LibStatut($status, $billed, $mode, $donotshowbilled);
336 }
337}
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 Dolibarr database access.
Class for WebPortalOrder.
getOrderStatic()
Get order for static method.
getTooltipContentArray($params)
getTooltipContentArray
getLabelStatus($mode=0)
Return the label of the status.
getKanbanView($option='', $arraydata=null)
Return clickable link of object (with eventually picto)
getLibStatut($mode=0)
Return the label of the status.
LibStatut($status, $billed, $mode, $donotshowbilled=0)
Return label of status.
getNomUrl($withpicto=0, $option='', $max=0, $short=0, $notooltip=0, $save_lastsearch_value=-1, $addlinktonotes=0, $target='')
Return clickable link of object (with eventually picto)
__construct(DoliDB $db)
Constructor.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getDolCurrency()
Return the main currency ('EUR', 'USD', ...)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...