dolibarr 23.0.4
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
5 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
8 * Copyright (C) 2013 Cédric Salvado <csalvador@gpcsolutions.fr>
9 * Copyright (C) 2015-2025 Frédéric France <frederic.france@free.fr>
10 * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
11 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
12 * Copyright (C) 2016-2023 Ferran Marcet <fmarcet@2byte.es>
13 * Copyright (C) 2018-2023 Charlene Benke <charlene@patas-monkey.com>
14 * Copyright (C) 2021-2024 Anthony Berton <anthony.berton@bb2a.fr>
15 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
16 * Copyright (C) 2024 Noé Cendrier <noe.cendrier@altairis.fr>
17 * Copyright (C) 2024 Benjamin Falière <benjamin.faliere@altairis.fr>
18 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
19 * Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
20 * Copyright (C) 2025 Lenin Rivas <lenin.rivas777@gmail.com>
21 *
22 * This program is free software; you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License as published by
24 * the Free Software Foundation; either version 3 of the License, or
25 * (at your option) any later version.
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
31 *
32 * You should have received a copy of the GNU General Public License
33 * along with this program. If not, see <https://www.gnu.org/licenses/>.
34 */
35
43// Load Dolibarr environment
44require '../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
46require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
47require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
48require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
49require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
50require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
51if (isModEnabled('margin')) {
52 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php';
53}
54require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
55require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
56require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
57require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
58
59if (isModEnabled('category')) {
60 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
61 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
62}
63
72// Load translation files required by the page
73$langs->loadLangs(array('orders', 'sendings', 'companies', 'compta', 'bills', 'stocks', 'products'));
74
75// Get Parameters
76$action = GETPOST('action', 'aZ09');
77$massaction = GETPOST('massaction', 'alpha');
78$show_files = GETPOSTINT('show_files');
79$confirm = GETPOST('confirm', 'alpha');
80$toselect = GETPOST('toselect', 'array:int');
81$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'orderlist';
82$optioncss = GETPOST('optioncss', 'alpha');
83$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
84
85if (getDolGlobalInt('MAIN_SEE_SUBORDINATES')) {
86 $userschilds = $user->getAllChildIds();
87} else {
88 $userschilds = array();
89}
90
91// Search Parameters
92$search_datecloture_start = GETPOSTINT('search_datecloture_start');
93if (empty($search_datecloture_start)) {
94 $search_datecloture_start = dol_mktime(0, 0, 0, GETPOSTINT('search_datecloture_startmonth'), GETPOSTINT('search_datecloture_startday'), GETPOSTINT('search_datecloture_startyear'));
95}
96$search_datecloture_end = GETPOSTINT('search_datecloture_end');
97if (empty($search_datecloture_end)) {
98 $search_datecloture_end = dol_mktime(23, 59, 59, GETPOSTINT('search_datecloture_endmonth'), GETPOSTINT('search_datecloture_endday'), GETPOSTINT('search_datecloture_endyear'));
99}
100$search_dateorder_start = dol_mktime(0, 0, 0, GETPOSTINT('search_dateorder_start_month'), GETPOSTINT('search_dateorder_start_day'), GETPOSTINT('search_dateorder_start_year'));
101$search_dateorder_end = dol_mktime(23, 59, 59, GETPOSTINT('search_dateorder_end_month'), GETPOSTINT('search_dateorder_end_day'), GETPOSTINT('search_dateorder_end_year'));
102$search_datedelivery_start = dol_mktime(0, 0, 0, GETPOSTINT('search_datedelivery_start_month'), GETPOSTINT('search_datedelivery_start_day'), GETPOSTINT('search_datedelivery_start_year'));
103$search_datedelivery_end = dol_mktime(23, 59, 59, GETPOSTINT('search_datedelivery_end_month'), GETPOSTINT('search_datedelivery_end_day'), GETPOSTINT('search_datedelivery_end_year'));
104
105$socid = GETPOSTINT('socid');
106
107$search_all = trim(GETPOST('search_all', 'alphanohtml'));
108$searchCategoryOrderOperator = 0;
109if (GETPOSTISSET('formfilteraction')) {
110 $searchCategoryOrderOperator = GETPOSTINT('search_category_order_operator');
111} elseif (getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT')) {
112 $searchCategoryOrderOperator = getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT');
113}
114$searchCategoryOrderList = GETPOST('search_category_order_list', 'array');
115$search_product_category = GETPOST('search_product_category', 'intcomma');
116$search_id = GETPOST('search_id', 'int');
117$search_ref = GETPOST('search_ref', 'alpha') != '' ? GETPOST('search_ref', 'alpha') : GETPOST('sref', 'alpha');
118$search_ref_ext = GETPOST('search_ref_ext', 'alpha');
119$search_ref_customer = GETPOST('search_ref_customer', 'alpha');
120$search_company = GETPOST('search_company', 'alpha');
121$search_company_alias = GETPOST('search_company_alias', 'alpha');
122$search_parent_name = trim(GETPOST('search_parent_name', 'alphanohtml'));
123$search_town = GETPOST('search_town', 'alpha');
124$search_zip = GETPOST('search_zip', 'alpha');
125$search_state = GETPOST('search_state', 'alpha');
126$search_country = GETPOST('search_country', 'aZ09');
127$search_type_thirdparty = GETPOST('search_type_thirdparty', 'intcomma');
128$search_user = GETPOST('search_user', 'intcomma');
129$search_sale = GETPOST('search_sale', 'intcomma');
130$search_total_ht = GETPOST('search_total_ht', 'alpha');
131$search_total_vat = GETPOST('search_total_vat', 'alpha');
132$search_total_ttc = GETPOST('search_total_ttc', 'alpha');
133$search_warehouse = GETPOST('search_warehouse', 'intcomma');
134$search_note_public = GETPOST('search_note_public', 'alphanohtml');
135$search_note_private = GETPOST('search_note_private', 'alphanohtml');
136
137$search_module_source = GETPOST('search_module_source', 'alphanohtml');
138$search_pos_source = GETPOST('search_pos_source', 'alphanohtml');
139
140$search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
141$search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
142$search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
143$search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha');
144$search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
145
146$search_login = GETPOST('search_login', 'alpha');
147$search_categ_cus = GETPOST("search_categ_cus", 'intcomma');
148$search_billed = GETPOST('search_billed', 'intcomma');
149$search_status = GETPOST('search_status', 'intcomma');
150$search_project_ref = GETPOST('search_project_ref', 'alpha');
151$search_project = GETPOST('search_project', 'alpha');
152$search_shippable = GETPOST('search_shippable', 'aZ09');
153
154$search_fk_cond_reglement = GETPOST('search_fk_cond_reglement', 'intcomma');
155$search_fk_shipping_method = GETPOST('search_fk_shipping_method', 'intcomma');
156$search_fk_mode_reglement = GETPOST('search_fk_mode_reglement', 'intcomma');
157$search_fk_input_reason = GETPOST('search_fk_input_reason', 'intcomma');
158
159$search_option = GETPOST('search_option', 'alpha');
160if ($search_option == 'late') {
161 $search_status = '-2';
162}
163$search_orderday = '';
164$search_ordermonth = '';
165$search_orderyear = '';
166$search_deliveryday = '';
167$search_deliverymonth = '';
168$search_deliveryyear = '';
169
170$search_import_key = trim(GETPOST("search_import_key", "alpha"));
171
172$diroutputmassaction = $conf->order->multidir_output[$conf->entity].'/temp/massgeneration/'.$user->id;
173
174// Load variable for pagination
175$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
176$sortfield = GETPOST('sortfield', 'aZ09comma');
177$sortorder = GETPOST('sortorder', 'aZ09comma');
178$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
179if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
180 // If $page is not defined, or '' or -1 or if we click on clear filters
181 $page = 0;
182}
183$offset = $limit * $page;
184$pageprev = $page - 1;
185$pagenext = $page + 1;
186if (!$sortfield) {
187 $sortfield = 'c.ref';
188}
189if (!$sortorder) {
190 $sortorder = 'DESC';
191}
192
193$show_shippable_command = GETPOST('show_shippable_command', 'aZ09');
194
195// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
196$object = new Commande($db);
197$hookmanager->initHooks(array('orderlist'));
198$extrafields = new ExtraFields($db);
199
200// fetch optionals attributes and labels
201$extrafields->fetch_name_optionals_label($object->table_element);
202$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
203
204// List of fields to search into when doing a "search in all"
205$fieldstosearchall = array(
206 'c.ref' => 'Ref',
207 'c.ref_client' => 'RefCustomerOrder',
208 'pd.description' => 'ProductDescription',
209 's.nom' => "ThirdParty",
210 's.name_alias' => "AliasNameShort",
211 's.zip' => "Zip",
212 's.town' => "Town",
213 'c.note_public' => 'NotePublic',
214);
215if (empty($user->socid)) {
216 $fieldstosearchall["c.note_private"] = "NotePrivate";
217}
218
219// Show POS fields if cashdesk or takepos module enabled or if global configuration to show POS fields on order list is enabled
220$showpos = (isModEnabled('cashdesk') || isModEnabled('takepos') || getDolGlobalInt('ORDER_SHOW_POS')) ? '1' : '0';
221
222$checkedtypetiers = '0';
223$arrayfields = array(
224 'c.rowid' => array('label' => "ID", 'checked' => '1', 'enabled' => (string) getDolGlobalInt('MAIN_SHOW_TECHNICAL_ID'), 'position' => 1),
225 'c.ref' => array('label' => "Ref", 'checked' => '1', 'position' => 5, 'searchall' => 1),
226 'c.ref_ext' => array('label' => "RefExt", 'checked' => '1', 'position' => 5, 'visible' => 0, 'searchall' => 1),
227 'c.ref_client' => array('label' => "RefCustomerOrder", 'checked' => '-1', 'position' => 10, 'searchall' => 1),
228 'p.ref' => array('label' => "ProjectRef", 'langfile' => 'projects', 'checked' => '-1', 'enabled' => (!isModEnabled('project') ? '0' : '1'), 'position' => 20),
229 'p.title' => array('label' => "ProjectLabel", 'langfile' => 'projects', 'checked' => '0', 'enabled' => (!isModEnabled('project') ? '0' : '1'), 'position' => 25),
230 's.nom' => array('label' => "ThirdParty", 'checked' => '1', 'position' => 30, 'searchall' => 1),
231 's.name_alias' => array('label' => "AliasNameShort", 'checked' => '-1', 'position' => 31, 'searchall' => 1),
232 's2.nom' => array('label' => 'ParentCompany', 'position' => 32, 'checked' => '0'),
233 's.town' => array('label' => "Town", 'checked' => '-1', 'position' => 35, 'searchall' => 1),
234 's.zip' => array('label' => "Zip", 'checked' => '-1', 'position' => 40, 'searchall' => 1),
235 'state.nom' => array('label' => "StateShort", 'checked' => '0', 'position' => 45),
236 'country.code_iso' => array('label' => "Country", 'checked' => '0', 'position' => 50),
237 'typent.code' => array('label' => "ThirdPartyType", 'checked' => (string) $checkedtypetiers, 'position' => 55),
238 'c.date_commande' => array('label' => "OrderDateShort", 'checked' => '1', 'position' => 60, 'csslist' => 'nowraponall'),
239 'c.delivery_date' => array('label' => "DateDeliveryPlanned", 'checked' => '1', 'enabled' => (string) (int) !getDolGlobalString('ORDER_DISABLE_DELIVERY_DATE'), 'position' => 65, 'csslist' => 'nowraponall'),
240 'c.fk_shipping_method' => array('label' => "SendingMethod", 'checked' => '-1', 'position' => 66 , 'enabled' => (string) (int) isModEnabled("shipping")),
241 'c.fk_cond_reglement' => array('label' => "PaymentConditionsShort", 'checked' => '-1', 'position' => 67),
242 'c.fk_mode_reglement' => array('label' => "PaymentMode", 'checked' => '-1', 'position' => 68),
243 'c.fk_input_reason' => array('label' => "Origin", 'checked' => '-1', 'position' => 69),
244 'c.module_source' => array('label' => "POSModule", 'langfile' => 'cashdesk', 'checked' => ($contextpage == 'poslist' ? '1' : '0'), 'enabled' => $showpos, 'position' => 90),
245 'c.pos_source' => array('label' => "POSTerminal", 'langfile' => 'cashdesk', 'checked' => ($contextpage == 'poslist' ? '1' : '0'), 'enabled' => $showpos, 'position' => 91),
246 'c.total_ht' => array('label' => "AmountHT", 'checked' => '1', 'position' => 75),
247 'c.total_vat' => array('label' => "AmountVAT", 'checked' => '0', 'position' => 80),
248 'c.total_ttc' => array('label' => "AmountTTC", 'checked' => '0', 'position' => 85),
249 'c.multicurrency_code' => array('label' => 'Currency', 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1'), 'position' => 92),
250 'c.multicurrency_tx' => array('label' => 'CurrencyRate', 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1'), 'position' => 95),
251 'c.multicurrency_total_ht' => array('label' => 'MulticurrencyAmountHT', 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1'), 'position' => 100),
252 'c.multicurrency_total_vat' => array('label' => 'MulticurrencyAmountVAT', 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1'), 'position' => 105),
253 'c.multicurrency_total_ttc' => array('label' => 'MulticurrencyAmountTTC', 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1'), 'position' => 110),
254 'u.login' => array('label' => "Author", 'checked' => '-1', 'position' => 115),
255 'sale_representative' => array('label' => "SaleRepresentativesOfThirdParty", 'checked' => '0', 'position' => 116),
256 'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => '0', 'position' => 300, 'enabled' => (string) (int) (!isModEnabled('margin') || !$user->hasRight("margins", "liretous") ? 0 : 1)),
257 'total_margin' => array('label' => 'Margin', 'checked' => '0', 'position' => 301, 'enabled' => (string) (int) (!isModEnabled('margin') || !$user->hasRight("margins", "liretous") ? 0 : 1)),
258 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => '0', 'position' => 302, 'enabled' => (string) (int) (!isModEnabled('margin') || !$user->hasRight("margins", "liretous") || !getDolGlobalString('DISPLAY_MARGIN_RATES') ? 0 : 1)),
259 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => '0', 'position' => 303, 'enabled' => (string) (int) (!isModEnabled('margin') || !$user->hasRight("margins", "liretous") || !getDolGlobalString('DISPLAY_MARK_RATES') ? 0 : 1)),
260 'c.datec' => array('label' => "DateCreation", 'checked' => '0', 'position' => 120),
261 'c.tms' => array('label' => "DateModificationShort", 'checked' => '0', 'position' => 125),
262 'c.date_cloture' => array('label' => "DateClosing", 'checked' => '0', 'position' => 130),
263 'c.note_public' => array('label' => 'NotePublic', 'checked' => '0', 'enabled' => (string) (int) (!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES')), 'position' => 135, 'searchall' => 1),
264 'c.note_private' => array('label' => 'NotePrivate', 'checked' => '0', 'enabled' => (string) (int) (!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES')), 'position' => 140),
265 'shippable' => array('label' => "Shippable", 'checked' => '1','enabled' => (string) (int) (isModEnabled("shipping")), 'position' => 990),
266 'c.facture' => array('label' => "Billed", 'checked' => '1', 'enabled' => (string) (int) (!getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT')), 'position' => 995),
267 'c.import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => '1', 'visible' => -2, 'position' => 999),
268 'c.fk_statut' => array('label' => "Status", 'checked' => '1', 'position' => 1000)
269);
270if ($user->socid) {
271 unset($arrayfields['c.note_private']);
272}
273$parameters = array('fieldstosearchall' => $fieldstosearchall);
274$reshook = $hookmanager->executeHooks('completeFieldsToSearchAll', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
275if ($reshook > 0) {
276 $fieldstosearchall = empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall'];
277} elseif ($reshook == 0) {
278 $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall']);
279}
280
281// Extra fields
282include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
283
284$object->fields = dol_sort_array($object->fields, 'position');
285//$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right');
286$arrayfields = dol_sort_array($arrayfields, 'position');
287
288
289// Security check
290$id = GETPOSTINT('orderid', GETPOSTINT('id'));
291if ($user->socid) {
292 $socid = $user->socid;
293}
294
295$permissiontoreadallthirdparty = $user->hasRight('societe', 'client', 'voir');
296$permissiontoread = false;
297$permissiontovalidate = false;
298$permissiontoclose = false;
299$permissiontocancel = false;
300$permissiontosendbymail = false;
301$objectclass = null;
302
303
304$result = restrictedArea($user, 'commande', $id, '');
305
306$error = 0;
307
308
309/*
310 * Actions
311 */
312
313if (GETPOST('cancel', 'alpha')) {
314 $action = 'list';
315 $massaction = '';
316}
317if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') {
318 $massaction = '';
319}
320
321$parameters = array('socid' => $socid, 'arrayfields' => &$arrayfields);
322$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
323if ($reshook < 0) {
324 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
325}
326
327if (empty($reshook)) {
328 // Selection of new fields
329 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
330
331 // Purge search criteria
332 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
333 $search_user = '';
334 $search_sale = '';
335 $search_product_category = '';
336 $searchCategoryOrderList = array();
337 $search_id = '';
338 $search_ref = '';
339 $search_ref_ext = '';
340 $search_ref_customer = '';
341 $search_company = '';
342 $search_company_alias = '';
343 $search_parent_name = '';
344 $search_module_source = '';
345 $search_pos_source = '';
346 $search_town = '';
347 $search_zip = "";
348 $search_state = "";
349 $search_type = '';
350 $search_country = '';
351 $search_type_thirdparty = '';
352 $search_total_ht = '';
353 $search_total_vat = '';
354 $search_total_ttc = '';
355 $search_warehouse = '';
356 $search_note_public = '';
357 $search_note_private = '';
358 $search_multicurrency_code = '';
359 $search_multicurrency_tx = '';
360 $search_multicurrency_montant_ht = '';
361 $search_multicurrency_montant_vat = '';
362 $search_multicurrency_montant_ttc = '';
363 $search_login = '';
364 $search_dateorder_start = '';
365 $search_dateorder_end = '';
366 $search_datedelivery_start = '';
367 $search_datedelivery_end = '';
368 $search_project_ref = '';
369 $search_project = '';
370 $search_status = '';
371 $search_billed = '';
372 $search_datecloture_start = '';
373 $search_datecloture_end = '';
374 $search_fk_cond_reglement = '';
375 $search_fk_shipping_method = '';
376 $search_fk_mode_reglement = '';
377 $search_fk_input_reason = '';
378 $search_option = '';
379 $search_import_key = '';
380 $search_categ_cus = 0;
381
382 $search_all = '';
383 $toselect = array();
384 $search_array_options = array();
385 }
386 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
387 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
388 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
389 }
390
391 // Mass actions
392 $objectclass = 'Commande';
393 $objectlabel = 'Orders';
394 $permissiontoread = $user->hasRight("commande", "lire");
395 $permissiontoadd = $user->hasRight("commande", "creer");
396 $permissiontodelete = $user->hasRight("commande", "supprimer");
397 if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
398 $permissiontovalidate = $user->hasRight("commande", "order_advance", "validate");
399 $permissiontoclose = $user->hasRight("commande", "order_advance", "close");
400 $permissiontocancel = $user->hasRight("commande", "order_advance", "annuler");
401 $permissiontosendbymail = $user->hasRight("commande", "order_advance", "send");
402 } else {
403 $permissiontovalidate = $user->hasRight("commande", "creer");
404 $permissiontoclose = $user->hasRight("commande", "creer");
405 $permissiontocancel = $user->hasRight("commande", "creer");
406 $permissiontosendbymail = $user->hasRight("commande", "creer");
407 }
408 $uploaddir = $conf->order->multidir_output[$conf->entity];
409 $triggersendname = 'ORDER_SENTBYMAIL';
410 $year = "";
411 $month = "";
412 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
413
414 if ($massaction == 'confirm_createbills') { // Create bills from orders.
415 $orders = GETPOST('toselect', 'array:int');
416 $createbills_onebythird = GETPOSTINT('createbills_onebythird');
417 $validate_invoices = GETPOSTINT('validate_invoices');
418
419 $errors = array();
420
421 $TFact = array();
422 $TFactThird = array();
423 $TFactThirdNbLines = array();
424
425 $nb_bills_created = 0;
426 $lastid = 0;
427 $lastref = '';
428
429 $db->begin();
430
431 $nbOrders = is_array($orders) ? count($orders) : 1;
432
433 $currentIndex = 0;
434 foreach ($orders as $id_order) {
435 $cmd = new Commande($db);
436 if ($cmd->fetch($id_order) <= 0) {
437 continue;
438 }
439
440 // Skip orders that cannot be billed, to mirror the "CreateBill" button availability on the order card
441 // (card.php only shows it when status > STATUS_DRAFT and the order is not already billed): this excludes
442 // draft and canceled orders, as well as orders already classified as billed.
443 if ($cmd->status <= Commande::STATUS_DRAFT || !empty($cmd->billed)) {
444 setEventMessages($langs->trans('WarningOrderNotEligibleForInvoicing', $cmd->ref), null, 'warnings');
445 continue;
446 }
447
448 $cmd->fetch_thirdparty();
449
450 $objecttmp = new Facture($db);
451 if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
452 // If option "one bill per third" is set, and an invoice for this thirdparty was already created, we reuse it.
453 $currentIndex++;
454 $objecttmp = $TFactThird[$cmd->socid];
455 } else {
456 // If we want one invoice per order or if there is no first invoice yet for this thirdparty.
457 $objecttmp->socid = $cmd->socid;
458 $objecttmp->thirdparty = $cmd->thirdparty;
459
460 $objecttmp->type = $objecttmp::TYPE_STANDARD;
461 $objecttmp->cond_reglement_id = !empty($cmd->cond_reglement_id) ? $cmd->cond_reglement_id : $cmd->thirdparty->cond_reglement_id;
462 $objecttmp->mode_reglement_id = !empty($cmd->mode_reglement_id) ? $cmd->mode_reglement_id : $cmd->thirdparty->mode_reglement_id;
463 $objecttmp->demand_reason_id = !empty($cmd->demand_reason_id) ? $cmd->demand_reason_id : $cmd->thirdparty->demand_reason_id;
464
465 $objecttmp->fk_project = $cmd->fk_project;
466 $objecttmp->multicurrency_code = $cmd->multicurrency_code;
467 if (empty($createbills_onebythird)) {
468 $objecttmp->ref_client = $cmd->ref_client;
469 }
470
471 if (empty($objecttmp->note_public) && getDolGlobalInt("MAXREFONDOC", 10)>0) {
472 $objecttmp->note_public = $langs->transnoentities("Orders");
473 }
474
475 $datefacture = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
476 if (empty($datefacture)) {
477 $datefacture = dol_now();
478 }
479
480 $objecttmp->date = $datefacture;
481 $objecttmp->origin = 'commande';
482 $objecttmp->origin_id = (int) $id_order;
483
484 $objecttmp->array_options = $cmd->array_options; // Copy extrafields
485
486 $res = $objecttmp->create($user);
487
488 if ($res > 0) {
489 $nb_bills_created++;
490 $lastref = $objecttmp->ref;
491 $lastid = $objecttmp->id;
492
493 $TFactThird[$cmd->socid] = $objecttmp;
494 $TFactThirdNbLines[$cmd->socid] = 0; //init nblines to have lines ordered by expedition and rang
495 } else {
496 $langs->load("errors");
497 $errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->errors[0]);
498 $error++;
499 }
500 }
501
502 if ($objecttmp->id > 0) {
503 $res = $objecttmp->add_object_linked($objecttmp->origin, $id_order);
504
505 if ($res == 0) {
506 $errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->errors[0]);
507 $error++;
508 }
509
510 // Linked Expeditions
511 if (getDolGlobalString('ORDER_MASS_ACTION_BILLED_LINK_EXPEDITIONS')) {
512 $cmd->fetchObjectLinked();
513 // Add object linked
514 if (!$error && $cmd->id && !empty($cmd->linkedObjectsIds['shipping']) && is_array($cmd->linkedObjectsIds['shipping'])) {
515 $cmd->linked_objects = $cmd->linkedObjectsIds;
516 foreach ($cmd->linked_objects as $origin_type => $tmp_origin_id) {
517 // IF more of same type
518 if ($origin_type == 'shipping') {
519 if (is_array($tmp_origin_id)) { // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...))
520 foreach ($tmp_origin_id as $origin_id) {
521 $res = $objecttmp->add_object_linked($origin_type, $origin_id);
522 if (!$res) {
523 $errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->errors[0]);
524 $error++;
525 }
526 }
527 } else { // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1))
528 $origin_id = $tmp_origin_id;
529 $res = $objecttmp->add_object_linked($origin_type, $origin_id);
530 if (!$res) {
531 $errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->errors[0]);
532 $error++;
533 }
534 }
535 }
536 }
537 }
538 }
539
540 if (!$error) {
541 $lines = $cmd->lines;
542 if (empty($lines) && method_exists($cmd, 'fetch_lines')) {
543 $cmd->fetch_lines();
544 $lines = $cmd->lines;
545 }
546
547 $fk_parent_line = 0;
548 $num = count($lines);
549 $array_options = array();
550
551 for ($i = 0; $i < $num; $i++) {
552 $desc = ($lines[$i]->desc ? $lines[$i]->desc : '');
553 // If we build one invoice for several orders, we must put the ref of order on the invoice line
554 if (!empty($createbills_onebythird)) {
555 $desc = dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day'));
556 }
557
558 if ($lines[$i]->subprice < 0 && !getDolGlobalString('INVOICE_KEEP_DISCOUNT_LINES_AS_IN_ORIGIN')) {
559 // Negative line, we create a discount line
560 $discount = new DiscountAbsolute($db);
561 $discount->fk_soc = $objecttmp->socid;
562 $discount->socid = $objecttmp->socid;
563 $discount->amount_ht = abs($lines[$i]->total_ht);
564 $discount->amount_tva = abs($lines[$i]->total_tva);
565 $discount->amount_ttc = abs($lines[$i]->total_ttc);
566 $discount->tva_tx = $lines[$i]->tva_tx;
567 $discount->fk_user = $user->id;
568 $discount->description = $desc;
569 $discountid = $discount->create($user);
570 if ($discountid > 0) {
571 $result = $objecttmp->insert_discount($discountid);
572 //$result=$discount->link_to_invoice($lineid,$id);
573 } else {
574 setEventMessages($discount->error, $discount->errors, 'errors');
575 $error++;
576 break;
577 }
578 } else {
579 // Positive line
580 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
581 // Date start
582 $date_start = false;
583 if ($lines[$i]->date_debut_prevue) {
584 $date_start = $lines[$i]->date_debut_prevue;
585 }
586 if ($lines[$i]->date_debut_reel) {
587 $date_start = $lines[$i]->date_debut_reel;
588 }
589 if ($lines[$i]->date_start) {
590 $date_start = $lines[$i]->date_start;
591 }
592 //Date end
593 $date_end = false;
594 if ($lines[$i]->date_fin_prevue) {
595 $date_end = $lines[$i]->date_fin_prevue;
596 }
597 if ($lines[$i]->date_fin_reel) {
598 $date_end = $lines[$i]->date_fin_reel;
599 }
600 if ($lines[$i]->date_end) {
601 $date_end = $lines[$i]->date_end;
602 }
603 // Reset fk_parent_line for no child products and special product
604 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
605 $fk_parent_line = 0;
606 }
607
608 // Extrafields
609 if (method_exists($lines[$i], 'fetch_optionals')) {
610 $lines[$i]->fetch_optionals();
611 $array_options = $lines[$i]->array_options;
612 }
613
614 $objecttmp->context['createfromclone'] = 'createfromclone';
615
616 $rang = ($nbOrders > 1) ? -1 : $lines[$i]->rang;
617 //there may already be rows from previous orders
618 if (!empty($createbills_onebythird)) {
619 $TFactThirdNbLines[$cmd->socid]++;
620 $rang = $TFactThirdNbLines[$cmd->socid];
621 }
622
623 $result = $objecttmp->addline(
624 $desc,
625 $lines[$i]->subprice,
626 $lines[$i]->qty,
627 $lines[$i]->tva_tx,
628 $lines[$i]->localtax1_tx,
629 $lines[$i]->localtax2_tx,
630 $lines[$i]->fk_product,
631 $lines[$i]->remise_percent,
632 $date_start,
633 $date_end,
634 0,
635 $lines[$i]->info_bits,
636 $lines[$i]->fk_remise_except,
637 'HT',
638 0,
639 $product_type,
640 $rang,
641 $lines[$i]->special_code,
642 $objecttmp->origin,
643 $lines[$i]->rowid,
644 $fk_parent_line,
645 $lines[$i]->fk_fournprice,
646 $lines[$i]->pa_ht,
647 $lines[$i]->label,
648 $array_options,
649 100,
650 0,
651 $lines[$i]->fk_unit
652 );
653 if ($result > 0) {
654 if (!empty($lines[$i]->extraparams)) {
655 $factureLine = new FactureLigne($db);
656 $factureLine->id = $result;
657 $factureLine->extraparams = $lines[$i]->extraparams;
658 $factureLine->setExtraParameters();
659 }
660
661 $lineid = $result;
662 } else {
663 $lineid = 0;
664 $error++;
665 $errors[] = $objecttmp->error;
666 break;
667 }
668 // Defined the new fk_parent_line
669 if ($result > 0 && $lines[$i]->product_type == 9) {
670 $fk_parent_line = $result;
671 }
672 }
673 }
674 }
675 }
676
677 if ($currentIndex <= getDolGlobalInt("MAXREFONDOC", 10)) {
678 $objecttmp->note_public = dol_concatdesc($objecttmp->note_public, $langs->transnoentities($cmd->ref).(empty($cmd->ref_client) ? '' : ' ('.$cmd->ref_client.')'));
679 $objecttmp->update($user);
680 }
681
682 //$cmd->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module.
683
684 if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) {
685 $TFactThird[$cmd->socid] = $objecttmp;
686 } else {
687 $TFact[$objecttmp->id] = $objecttmp;
688 }
689 }
690
691 // Build doc with all invoices
692 $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
693 $toselect = array();
694
695 if (!$error && $validate_invoices) {
696 $massaction = $action = 'builddoc';
697
698 foreach ($TAllFact as &$objecttmp) {
699 $result = $objecttmp->validate($user);
700 if ($result <= 0) {
701 $error++;
702 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
703 break;
704 }
705
706 $id = $objecttmp->id; // For builddoc action
707 $lastref = $objecttmp->ref; // Refresh ref after validation (was the draft PROVxxxx ref set at creation)
708
709 // Builddoc
710 $donotredirect = 1;
711 $upload_dir = $conf->facture->dir_output;
712 $permissiontoadd = $user->hasRight('facture', 'creer');
713
714 // Call action to build doc
715 $savobject = $object;
716 $object = $objecttmp;
717 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
718 $object = $savobject;
719 }
720
721 $massaction = $action = 'confirm_createbills';
722 }
723
724 if (!$error) {
725 $db->commit();
726
727 if ($nb_bills_created == 1) {
728 if (getDolGlobalInt('MAIN_MASSACTION_CREATEBILLS_REDIRECT_IF_ONE') == 1) {
729 // Redirect to generated invoice if unique
730 header('Location: '.DOL_URL_ROOT.'/compta/facture/card.php?id='.urlencode((string) $lastid));
731 exit;
732 }
733 $texttoshow = $langs->trans('BillXCreated', '{s1}');
734 $texttoshow = str_replace('{s1}', '<a href="'.DOL_URL_ROOT.'/compta/facture/card.php?id='.urlencode((string) ($lastid)).'">'.$lastref.'</a>', $texttoshow);
735 setEventMessages($texttoshow, null, 'mesgs');
736 } else {
737 if (getDolGlobalInt('MAIN_MASSACTION_CREATEBILLS_REDIRECT_IF_MANY') == 1) {
738 // Redirect to invoice list
739 header("Location: ".DOL_URL_ROOT.'/compta/facture/list.php?mainmenu=billing&leftmenu=customers_bills');
740 exit;
741 }
742 setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs');
743 }
744
745 // Make a redirect to avoid to bill twice if we make a refresh or back
746 $param = '';
747 if (!empty($mode)) {
748 $param .= '&mode='.urlencode($mode);
749 }
750 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
751 $param .= '&contextpage='.urlencode($contextpage);
752 }
753 if ($limit > 0 && $limit != $conf->liste_limit) {
754 $param .= '&limit='.((int) $limit);
755 }
756 if ($optioncss != '') {
757 $param .= '&optioncss='.urlencode($optioncss);
758 }
759 if ($search_all) {
760 $param .= '&search_all='.urlencode($search_all);
761 }
762 if ($show_files) {
763 $param .= '&show_files='.urlencode((string) ($show_files));
764 }
765 if ($socid > 0) {
766 $param .= '&socid='.urlencode((string) ($socid));
767 }
768 if ($search_status != '') {
769 $param .= '&search_status='.urlencode($search_status);
770 }
771 if ($search_option) {
772 $param .= "&search_option=".urlencode($search_option);
773 }
774 if ($search_orderday) {
775 $param .= '&search_orderday='.urlencode($search_orderday);
776 }
777 if ($search_ordermonth) {
778 $param .= '&search_ordermonth='.urlencode($search_ordermonth);
779 }
780 if ($search_orderyear) {
781 $param .= '&search_orderyear='.urlencode($search_orderyear);
782 }
783 if ($search_deliveryday) {
784 $param .= '&search_deliveryday='.urlencode($search_deliveryday);
785 }
786 if ($search_deliverymonth) {
787 $param .= '&search_deliverymonth='.urlencode($search_deliverymonth);
788 }
789 if ($search_deliveryyear) {
790 $param .= '&search_deliveryyear='.urlencode($search_deliveryyear);
791 }
792 if ($search_id) {
793 $param .= '&search_id='.urlencode((string) $search_id);
794 }
795 if ($search_ref) {
796 $param .= '&search_ref='.urlencode($search_ref);
797 }
798 if ($search_ref_ext) {
799 $param .= '&search_ref_ext='.urlencode($search_ref_ext);
800 }
801 if ($search_company) {
802 $param .= '&search_company='.urlencode($search_company);
803 }
804 if ($search_ref_customer) {
805 $param .= '&search_ref_customer='.urlencode($search_ref_customer);
806 }
807 if ($search_user > 0) {
808 $param .= '&search_user='.urlencode((string) ($search_user));
809 }
810 if ($search_sale > 0) {
811 $param .= '&search_sale='.urlencode((string) ($search_sale));
812 }
813 if ($search_total_ht != '') {
814 $param .= '&search_total_ht='.urlencode($search_total_ht);
815 }
816 if ($search_total_vat != '') {
817 $param .= '&search_total_vat='.urlencode($search_total_vat);
818 }
819 if ($search_total_ttc != '') {
820 $param .= '&search_total_ttc='.urlencode($search_total_ttc);
821 }
822 if ($search_project_ref >= 0) {
823 $param .= "&search_project_ref=".urlencode($search_project_ref);
824 }
825 if ($search_project != '') {
826 $param .= "&search_project=".urlencode($search_project);
827 }
828 if ($search_billed != '') {
829 $param .= '&search_billed='.urlencode($search_billed);
830 }
831
832 header("Location: ".$_SERVER['PHP_SELF'].'?'.$param);
833 exit;
834 } else {
835 $db->rollback();
836
837 $action = 'create';
838 $_GET["origin"] = $_POST["origin"]; // Keep GET and POST here ?
839 $_GET["originid"] = $_POST["originid"]; // Keep GET and POST here ?
840 if (!empty($errors)) {
841 setEventMessages(null, $errors, 'errors');
842 } else {
843 setEventMessages("Error", null, 'errors');
844 }
845 $error++;
846 }
847 }
848}
849
850if ($action == 'validate' && $permissiontoadd && $objectclass !== null) {
851 if (GETPOST('confirm') == 'yes') {
853 $objecttmp = new $objectclass($db);
854 $db->begin();
855 $error = 0;
856 foreach ($toselect as $checked) {
857 if ($objecttmp->fetch($checked)) {
858 if ($objecttmp->status == $objecttmp::STATUS_DRAFT) {
859 if (!empty($objecttmp->fk_warehouse)) {
860 $idwarehouse = $objecttmp->fk_warehouse;
861 } else {
862 $idwarehouse = 0;
863 }
864 if ($objecttmp->valid($user, $idwarehouse) > 0) {
865 setEventMessages($langs->trans('hasBeenValidated', $objecttmp->ref), null, 'mesgs');
866 } else {
867 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
868 $error++;
869 }
870 } else {
871 $langs->load("errors");
872 setEventMessages($langs->trans('ErrorIsNotADraft', $objecttmp->ref), null, 'errors');
873 $error++;
874 }
875 } else {
876 dol_print_error($db);
877 $error++;
878 }
879 }
880 if ($error) {
881 $db->rollback();
882 } else {
883 $db->commit();
884 }
885 }
886}
887if ($action == 'shipped' && $permissiontoadd && $objectclass !== null) {
888 if (GETPOST('confirm') == 'yes') {
890 $objecttmp = new $objectclass($db);
891 $db->begin();
892 $error = 0;
893 foreach ($toselect as $checked) {
894 if ($objecttmp->fetch($checked)) {
895 if ($objecttmp->status == $objecttmp::STATUS_VALIDATED || $objecttmp->status == $objecttmp::STATUS_SHIPMENTONPROCESS || $objecttmp->status == $objecttmp::STATUS_CLOSED) {
896 $result = $objecttmp->cloture($user);
897 if ($result > 0) {
898 setEventMessages($langs->trans('StatusOrderDelivered', $objecttmp->ref), null, 'mesgs');
899 } elseif ($result < 0) {
900 setEventMessages($langs->trans('ErrorOrderStatusCantBeSetToDelivered'), null, 'errors');
901 $error++;
902 }
903 } else {
904 $langs->load("errors");
905 setEventMessages($langs->trans('ErrorObjectHasWrongStatus', $objecttmp->ref), null, 'errors');
906 $error++;
907 }
908 } else {
909 dol_print_error($db);
910 $error++;
911 }
912 }
913 if ($error) {
914 $db->rollback();
915 } else {
916 $db->commit();
917 }
918 }
919}
920
921// Closed records
922if (!$error && $massaction === 'setbilled' && $permissiontoclose && $objectclass !== null) {
923 $db->begin();
924
925 $objecttmp = new $objectclass($db);
926 $nbok = 0;
927 foreach ($toselect as $toselectid) {
928 $result = $objecttmp->fetch($toselectid);
929 if ($result > 0) {
930 $result = $objecttmp->classifyBilled($user, 0);
931 if ($result <= 0) {
932 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
933 $error++;
934 break;
935 } else {
936 $nbok++;
937 }
938 } else {
939 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
940 $error++;
941 break;
942 }
943 }
944
945 if (!$error) {
946 setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
947 $db->commit();
948 } else {
949 $db->rollback();
950 }
951}
952
953
954/*
955 * View
956 */
957
958$form = new Form($db);
959$formother = new FormOther($db);
960$formfile = new FormFile($db);
961$formmargin = null;
962if (isModEnabled('margin')) {
963 $formmargin = new FormMargin($db);
964}
965$companystatic = new Societe($db);
966$company_url_list = array();
967$formcompany = new FormCompany($db);
968$projectstatic = new Project($db);
969
970$now = dol_now();
971
972$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
973$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
974
975$title = $langs->trans("Orders");
976$help_url = "EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
977
978// Build and execute select
979// --------------------------------------------------------------------
980$sql = 'SELECT';
981$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client,';
982$sql .= " s.parent as fk_parent,";
983$sql .= " s2.nom as name2,";
984$sql .= " typent.code as typent_code,";
985$sql .= " state.code_departement as state_code, state.nom as state_name,";
986$sql .= " country.code as country_code,";
987$sql .= ' c.rowid, c.ref, c.ref_ext, c.total_ht, c.total_tva, c.total_ttc, c.ref_client, c.fk_user_author,';
988$sql .= ' c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva as multicurrency_total_vat, c.multicurrency_total_ttc,';
989$sql .= ' c.date_valid, c.date_commande, c.note_public, c.note_private, c.date_livraison as delivery_date, c.fk_statut, c.facture as billed,';
990$sql .= ' c.date_creation as date_creation, c.tms as date_modification, c.date_cloture as date_cloture,';
991$sql .= ' c.fk_cond_reglement,c.deposit_percent,c.fk_mode_reglement,c.fk_shipping_method,';
992$sql .= ' c.fk_input_reason, c.import_key,';
993$sql .= " c.module_source, c.pos_source,";
994$sql .= ' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
995$sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender';
996
997// Add fields from extrafields
998if (!empty($extrafields->attributes[$object->table_element]['label'])) {
999 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
1000 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
1001 }
1002}
1003
1004// Add fields from hooks
1005$parameters = array();
1006$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1007$sql .= $hookmanager->resPrint;
1008$sql = preg_replace('/,\s*$/', '', $sql);
1009
1010$sqlfields = $sql; // $sql fields to remove for count total
1011
1012$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
1013$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s2 ON s2.rowid = s.parent";
1014$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
1015$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
1016$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
1017$sql .= ', '.MAIN_DB_PREFIX.'commande as c';
1018if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
1019 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields as ef on (c.rowid = ef.fk_object)";
1020}
1021$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = c.fk_projet";
1022$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON c.fk_user_author = u.rowid';
1023// Add table from hooks
1024$parameters = array();
1025$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1026$sql .= $hookmanager->resPrint;
1027
1028$sql .= ' WHERE c.fk_soc = s.rowid';
1029$sql .= ' AND c.entity IN ('.getEntity('commande').')';
1030if ($socid > 0) {
1031 $sql .= ' AND s.rowid = '.((int) $socid);
1032}
1033// Restriction on sale representative
1034if (empty($user->socid) && !$permissiontoreadallthirdparty) {
1035 $sql .= " AND (EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc AND sc.fk_user = ".((int) $user->id).")";
1036 if (getDolGlobalInt('MAIN_SEE_SUBORDINATES') && $userschilds) {
1037 $sql .= " OR EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc AND sc.fk_user IN (".$db->sanitize(implode(',', $userschilds))."))";
1038 }
1039 $sql .= ")";
1040}
1041
1042if ($search_id > 0) {
1043 $sql .= natural_search('c.rowid', $search_id);
1044}
1045if ($search_ref) {
1046 $sql .= natural_search('c.ref', $search_ref);
1047}
1048if ($search_ref_ext) {
1049 $sql .= natural_search('c.ref_ext', $search_ref_ext);
1050}
1051if ($search_ref_customer) {
1052 $sql .= natural_search('c.ref_client', $search_ref_customer);
1053}
1054if ($search_billed != '' && $search_billed >= 0) {
1055 $sql .= ' AND c.facture = '.((int) $search_billed);
1056}
1057if ($search_status != '') {
1058 if ($search_status <= 3 && $search_status >= -1) { // status from -1 to 3 are real status (other are virtual combination)
1059 if ($search_status == 1 && !isModEnabled('shipping')) {
1060 $sql .= ' AND c.fk_statut IN (1,2)'; // If module expedition disabled, we include order with status "sent" into "validated"
1061 } else {
1062 $sql .= ' AND c.fk_statut = '.((int) $search_status); // draft, validated, in process or canceled
1063 }
1064 }
1065 if ($search_status == -2) { // "validated + in progress"
1066 //$sql.= ' AND c.fk_statut IN (1,2,3) AND c.facture = 0';
1067 $sql .= " AND (c.fk_statut IN (1,2))";
1068 }
1069 if ($search_status == -3) { // "validated + in progress + shipped"
1070 //$sql.= ' AND c.fk_statut in (1,2,3)';
1071 //$sql.= ' AND c.facture = 0'; // invoice not created
1072 $sql .= ' AND (c.fk_statut IN (1,2,3))'; // validated, in process or closed
1073 }
1074}
1075if ($search_option == 'late') {
1076 // Use delivery date if set and not disabled, otherwise use order date.
1077 if (!getDolGlobalString('ORDER_DISABLE_DELIVERY_DATE')) {
1078 $sql .= " AND ((c.date_livraison IS NOT NULL AND c.date_livraison < '".$db->idate(dol_now() - $conf->order->client->warning_delay)."') OR (c.date_livraison IS NULL AND c.date_commande < '".$db->idate(dol_now() - $conf->order->client->warning_delay)."'))";
1079 } else {
1080 $sql .= " AND c.date_commande < '".$db->idate(dol_now() - $conf->order->client->warning_delay)."'";
1081 }
1082}
1083if ($search_datecloture_start) {
1084 $sql .= " AND c.date_cloture >= '".$db->idate($search_datecloture_start)."'";
1085}
1086if ($search_datecloture_end) {
1087 $sql .= " AND c.date_cloture <= '".$db->idate($search_datecloture_end)."'";
1088}
1089if ($search_dateorder_start) {
1090 $sql .= " AND c.date_commande >= '".$db->idate($search_dateorder_start)."'";
1091}
1092if ($search_dateorder_end) {
1093 $sql .= " AND c.date_commande <= '".$db->idate($search_dateorder_end)."'";
1094}
1095if ($search_datedelivery_start) {
1096 $sql .= " AND c.date_livraison >= '".$db->idate($search_datedelivery_start)."'";
1097}
1098if ($search_datedelivery_end) {
1099 $sql .= " AND c.date_livraison <= '".$db->idate($search_datedelivery_end)."'";
1100}
1101if ($search_town) {
1102 $sql .= natural_search('s.town', $search_town);
1103}
1104if ($search_zip) {
1105 $sql .= natural_search("s.zip", $search_zip);
1106}
1107if ($search_state) {
1108 $sql .= natural_search("state.nom", $search_state);
1109}
1110if ($search_country) {
1111 $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
1112}
1113if ($search_type_thirdparty && $search_type_thirdparty != '-1') {
1114 $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')';
1115}
1116if (empty($arrayfields['s.name_alias']['checked']) && $search_company) {
1117 $sql .= natural_search(array("s.nom", "s.name_alias"), $search_company);
1118} else {
1119 if ($search_company) {
1120 $sql .= natural_search('s.nom', $search_company);
1121 }
1122 if ($search_company_alias) {
1123 $sql .= natural_search('s.name_alias', $search_company_alias);
1124 }
1125}
1126if ($search_parent_name) {
1127 $sql .= natural_search('s2.nom', $search_parent_name);
1128}
1129if ($search_total_ht != '') {
1130 $sql .= natural_search('c.total_ht', $search_total_ht, 1);
1131}
1132if ($search_total_vat != '') {
1133 $sql .= natural_search('c.total_tva', $search_total_vat, 1);
1134}
1135if ($search_total_ttc != '') {
1136 $sql .= natural_search('c.total_ttc', $search_total_ttc, 1);
1137}
1138if ($search_warehouse != '' && $search_warehouse > 0) {
1139 $sql .= natural_search('c.fk_warehouse', $search_warehouse, 1);
1140}
1141if ($search_note_public != '') {
1142 $sql .= natural_search('c.note_public', $search_note_public);
1143}
1144if ($search_note_private != '') {
1145 $sql .= natural_search('c.note_private', $search_note_private);
1146}
1147if ($search_multicurrency_code != '') {
1148 $sql .= " AND c.multicurrency_code = '".$db->escape($search_multicurrency_code)."'";
1149}
1150if ($search_multicurrency_tx != '') {
1151 $sql .= natural_search('c.multicurrency_tx', $search_multicurrency_tx, 1);
1152}
1153if ($search_multicurrency_montant_ht != '') {
1154 $sql .= natural_search('c.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
1155}
1156if ($search_multicurrency_montant_vat != '') {
1157 $sql .= natural_search('c.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
1158}
1159if ($search_multicurrency_montant_ttc != '') {
1160 $sql .= natural_search('c.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
1161}
1162if ($search_login) {
1163 $sql .= natural_search(array("u.login", "u.firstname", "u.lastname"), $search_login);
1164}
1165if ($search_project_ref != '') {
1166 $sql .= natural_search("p.ref", $search_project_ref);
1167}
1168if ($search_project != '') {
1169 $sql .= natural_search("p.title", $search_project);
1170}
1171if ($search_fk_cond_reglement > 0) {
1172 $sql .= " AND c.fk_cond_reglement = ".((int) $search_fk_cond_reglement);
1173}
1174if ($search_fk_shipping_method > 0) {
1175 $sql .= " AND c.fk_shipping_method = ".((int) $search_fk_shipping_method);
1176}
1177if ($search_fk_mode_reglement > 0) {
1178 $sql .= " AND c.fk_mode_reglement = ".((int) $search_fk_mode_reglement);
1179}
1180if ($search_fk_input_reason > 0) {
1181 $sql .= " AND c.fk_input_reason = ".((int) $search_fk_input_reason);
1182}
1183if ($search_module_source) {
1184 $sql .= natural_search("c.module_source", $search_module_source);
1185}
1186if ($search_pos_source) {
1187 $sql .= natural_search("c.pos_source", $search_pos_source);
1188}
1189if ($search_import_key) {
1190 $sql .= natural_search("c.import_key", $search_import_key);
1191}
1192// Search on user
1193if ($search_user > 0) {
1194 $sql .= " AND EXISTS (";
1195 $sql .= " SELECT ec.fk_c_type_contact, ec.element_id, ec.fk_socpeople";
1196 $sql .= " FROM ".MAIN_DB_PREFIX."element_contact as ec";
1197 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."c_type_contact as tc";
1198 $sql .= " ON ec.fk_c_type_contact = tc.rowid AND tc.element = 'commande' AND tc.source = 'internal'";
1199 $sql .= " WHERE ec.element_id = c.rowid AND ec.fk_socpeople = ".((int) $search_user).")";
1200}
1201// Search on sale representative
1202if ($search_sale && $search_sale != '-1') {
1203 if ($search_sale == -2) {
1204 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc)";
1205 } elseif ($search_sale > 0) {
1206 $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
1207 }
1208}
1209
1210// Search for tag/category ($searchCategoryOrderList is an array of ID)
1211if (!empty($searchCategoryOrderList)) {
1212 $searchCategoryOrderSqlList = array();
1213 $listofcategoryid = '';
1214 foreach ($searchCategoryOrderList as $searchCategoryOrder) {
1215 if (intval($searchCategoryOrder) == -2) {
1216 $searchCategoryOrderSqlList[] = "NOT EXISTS (SELECT ck.fk_order FROM ".MAIN_DB_PREFIX."categorie_order as ck WHERE c.rowid = ck.fk_order)";
1217 } elseif (intval($searchCategoryOrder) > 0) {
1218 if ($searchCategoryOrderOperator == 0) {
1219 $searchCategoryOrderSqlList[] = " EXISTS (SELECT ck.fk_order FROM ".MAIN_DB_PREFIX."categorie_order as ck WHERE c.rowid = ck.fk_order AND ck.fk_categorie = ".((int) $searchCategoryOrder).")";
1220 } else {
1221 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryOrder);
1222 }
1223 }
1224 }
1225 if ($listofcategoryid) {
1226 $searchCategoryOrderSqlList[] = " EXISTS (SELECT ck.fk_order FROM ".MAIN_DB_PREFIX."categorie_order as ck WHERE c.rowid = ck.fk_order AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
1227 }
1228 if ($searchCategoryOrderOperator == 1) {
1229 if (!empty($searchCategoryOrderSqlList)) {
1230 $sql .= " AND (".implode(' OR ', $searchCategoryOrderSqlList).")";
1231 }
1232 } else {
1233 if (!empty($searchCategoryOrderSqlList)) {
1234 $sql .= " AND (".implode(' AND ', $searchCategoryOrderSqlList).")";
1235 }
1236 }
1237}
1238
1239// Search for tag/category ($searchCategoryCustomerList is an array of ID)
1240$searchCategoryCustomerOperator = GETPOSTINT('search_category_customer_operator');
1241$searchCategoryCustomerList = array($search_categ_cus);
1242if (!empty($searchCategoryCustomerList)) {
1243 $searchCategoryCustomerSqlList = array();
1244 $listofcategoryid = '';
1245 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
1246 if (intval($searchCategoryCustomer) == -2) {
1247 $searchCategoryCustomerSqlList[] = "NOT EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE s.rowid = cs.fk_soc)";
1248 } elseif (intval($searchCategoryCustomer) > 0) {
1249 if ($searchCategoryCustomerOperator == 0) {
1250 $searchCategoryCustomerSqlList[] = " EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE s.rowid = cs.fk_soc AND cs.fk_categorie = ".((int) $searchCategoryCustomer).")";
1251 } else {
1252 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer);
1253 }
1254 }
1255 }
1256 if ($listofcategoryid) {
1257 $searchCategoryCustomerSqlList[] = " EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE s.rowid = cs.fk_soc AND cs.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
1258 }
1259 if ($searchCategoryCustomerOperator == 1) {
1260 if (!empty($searchCategoryCustomerSqlList)) {
1261 $sql .= " AND (".implode(' OR ', $searchCategoryCustomerSqlList).")";
1262 }
1263 } else {
1264 if (!empty($searchCategoryCustomerSqlList)) {
1265 $sql .= " AND (".implode(' AND ', $searchCategoryCustomerSqlList).")";
1266 }
1267 }
1268}
1269// Search for tag/category ($searchCategoryProductList is an array of ID)
1270$searchCategoryProductOperator = GETPOSTINT('search_category_product_operator');
1271$searchCategoryProductList = array($search_product_category);
1272if (!empty($searchCategoryProductList)) {
1273 $searchCategoryProductSqlList = array();
1274 $listofcategoryid = '';
1275 foreach ($searchCategoryProductList as $searchCategoryProduct) {
1276 if (intval($searchCategoryProduct) == -2) {
1277 $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."commandedet as cd WHERE cd.fk_commande = c.rowid AND cd.fk_product = ck.fk_product)";
1278 } elseif (intval($searchCategoryProduct) > 0) {
1279 if ($searchCategoryProductOperator == 0) {
1280 $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."commandedet as cd WHERE cd.fk_commande = c.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")";
1281 } else {
1282 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
1283 }
1284 }
1285 }
1286 if ($listofcategoryid) {
1287 $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."commandedet as cd WHERE cd.fk_commande = c.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
1288 }
1289 if ($searchCategoryProductOperator == 1) {
1290 if (!empty($searchCategoryProductSqlList)) {
1291 $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
1292 }
1293 } else {
1294 if (!empty($searchCategoryProductSqlList)) {
1295 $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
1296 }
1297 }
1298}
1299// Add where from extra fields
1300include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
1301// Add where from hooks
1302$parameters = array();
1303$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1304$sql .= $hookmanager->resPrint;
1305
1306if ($search_all) {
1307 // Prepare the $sqltoadd for fields pd.* that need a test by doing a "or exits"
1308 $sqltoadd = '';
1309 $fieldstosearchallwithoutpd = array();
1310 $fieldstosearchallwithpd = array();
1311 foreach ($fieldstosearchall as $key => $val) {
1312 if (!preg_match('/^pd\./', $key)) {
1313 $fieldstosearchallwithoutpd[$key] = $val;
1314 } else {
1315 $fieldstosearchallwithpd[$key] = $val;
1316 }
1317 }
1318
1319 if (count($fieldstosearchallwithpd) > 0) {
1320 $sqltoadd .= " OR EXISTS (SELECT pd.rowid FROM ".MAIN_DB_PREFIX."commandedet as pd WHERE pd.fk_commande = c.rowid";
1321 $sqltoadd .= natural_search(array_keys($fieldstosearchallwithpd), '__KEYTOSEARCH__');
1322 $sqltoadd .= ')';
1323 }
1324
1325 $sql .= natural_search(array_keys($fieldstosearchallwithoutpd), $search_all, 0, 0, $sqltoadd);
1326}
1327
1328// Add HAVING from hooks
1329$parameters = array();
1330$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1331if (empty($reshook)) {
1332 $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
1333} else {
1334 $sql = $hookmanager->resPrint;
1335}
1336//print $sql;
1337
1338// Count total nb of records
1339$nbtotalofrecords = '';
1340if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
1341 /* The fast and low memory method to get and count full list converts the sql into a sql count */
1342 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
1343 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
1344 $resql = $db->query($sqlforcount);
1345 if ($resql) {
1346 $objforcount = $db->fetch_object($resql);
1347 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1348 } else {
1349 dol_print_error($db);
1350 }
1351
1352 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
1353 $page = 0;
1354 $offset = 0;
1355 }
1356 $db->free($resql);
1357}
1358
1359// Complete request and execute it with limit
1360$sql .= $db->order($sortfield, $sortorder);
1361if ($limit) {
1362 $sql .= $db->plimit($limit + 1, $offset);
1363}
1364//print $sql;
1365
1366$resql = $db->query($sql);
1367if (!$resql) {
1368 dol_print_error($db);
1369 exit;
1370}
1371
1372if ($socid > 0) {
1373 $soc = new Societe($db);
1374 $soc->fetch($socid);
1375 $title = $langs->trans('CustomersOrders').' - '.$soc->name;
1376 if (empty($search_company)) {
1377 $search_company = $soc->name;
1378 }
1379} else {
1380 $title = $langs->trans('CustomersOrders');
1381}
1382if (strval($search_status) == '0') {
1383 $title .= ' - '.$langs->trans('StatusOrderDraftShort');
1384}
1385if ($search_status == 1) {
1386 $title .= ' - '.$langs->trans('StatusOrderValidatedShort');
1387}
1388if ($search_status == 2) {
1389 $title .= ' - '.$langs->trans('StatusOrderSentShort');
1390}
1391if ($search_status == 3) {
1392 $title .= ' - '.$langs->trans('StatusOrderToBillShort');
1393}
1394if ($search_status == -1) {
1395 $title .= ' - '.$langs->trans('StatusOrderCanceledShort');
1396}
1397if ($search_status == -2) {
1398 $title .= ' - '.$langs->trans('StatusOrderToProcessShort');
1399}
1400if ($search_status == -3) {
1401 $title .= ' - '.$langs->trans('StatusOrderValidated').', '.(!isModEnabled('shipping') ? '' : $langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill');
1402}
1403if ($search_status == -4) {
1404 $title .= ' - '.$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort");
1405}
1406
1407$num = $db->num_rows($resql);
1408
1409$arrayofselected = is_array($toselect) ? $toselect : array();
1410
1411if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) {
1412 $obj = $db->fetch_object($resql);
1413 $id = $obj->rowid;
1414 header("Location: ".DOL_URL_ROOT.'/commande/card.php?id='.$id);
1415 exit;
1416}
1417
1418// Output page
1419// --------------------------------------------------------------------
1420
1421llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'bodyforlist mod-order page-list');
1422
1423$arrayofselected = is_array($toselect) ? $toselect : array();
1424
1425$param = '';
1426if (!empty($mode)) {
1427 $param .= '&mode='.urlencode($mode);
1428}
1429if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
1430 $param .= '&contextpage='.urlencode($contextpage);
1431}
1432if ($limit > 0 && $limit != $conf->liste_limit) {
1433 $param .= '&limit='.((int) $limit);
1434}
1435if ($optioncss != '') {
1436 $param .= '&optioncss='.urlencode($optioncss);
1437}
1438if ($show_files) {
1439 $param .= '&show_files='.urlencode((string) ($show_files));
1440}
1441if ($search_all) {
1442 $param .= '&search_all='.urlencode($search_all);
1443}
1444if ($socid > 0) {
1445 $param .= '&socid='.((int) $socid);
1446}
1447if ($search_status != '') {
1448 $param .= '&search_status='.urlencode($search_status);
1449}
1450if ($search_option) {
1451 $param .= "&search_option=".urlencode($search_option);
1452}
1453if ($search_datecloture_start) {
1454 $param .= '&search_datecloture_startday='.dol_print_date($search_datecloture_start, '%d').'&search_datecloture_startmonth='.dol_print_date($search_datecloture_start, '%m').'&search_datecloture_startyear='.dol_print_date($search_datecloture_start, '%Y');
1455}
1456if ($search_datecloture_end) {
1457 $param .= '&search_datecloture_endday='.dol_print_date($search_datecloture_end, '%d').'&search_datecloture_endmonth='.dol_print_date($search_datecloture_end, '%m').'&search_datecloture_endyear='.dol_print_date($search_datecloture_end, '%Y');
1458}
1459if ($search_dateorder_start) {
1460 $param .= '&search_dateorder_start_day='.dol_print_date($search_dateorder_start, '%d').'&search_dateorder_start_month='.dol_print_date($search_dateorder_start, '%m').'&search_dateorder_start_year='.dol_print_date($search_dateorder_start, '%Y');
1461}
1462if ($search_dateorder_end) {
1463 $param .= '&search_dateorder_end_day='.dol_print_date($search_dateorder_end, '%d').'&search_dateorder_end_month='.dol_print_date($search_dateorder_end, '%m').'&search_dateorder_end_year='.dol_print_date($search_dateorder_end, '%Y');
1464}
1465if ($search_datedelivery_start) {
1466 $param .= '&search_datedelivery_start_day='.dol_print_date($search_datedelivery_start, '%d').'&search_datedelivery_start_month='.dol_print_date($search_datedelivery_start, '%m').'&search_datedelivery_start_year='.dol_print_date($search_datedelivery_start, '%Y');
1467}
1468if ($search_datedelivery_end) {
1469 $param .= '&search_datedelivery_end_day='.dol_print_date($search_datedelivery_end, '%d').'&search_datedelivery_end_month='.dol_print_date($search_datedelivery_end, '%m').'&search_datedelivery_end_year='.dol_print_date($search_datedelivery_end, '%Y');
1470}
1471if ($search_id) {
1472 $param .= '&search_id='.urlencode((string) $search_id);
1473}
1474if ($search_ref) {
1475 $param .= '&search_ref='.urlencode($search_ref);
1476}
1477if ($search_ref_ext) {
1478 $param .= '&search_ref_ext='.urlencode($search_ref_ext);
1479}
1480if ($search_company) {
1481 $param .= '&search_company='.urlencode($search_company);
1482}
1483if ($search_company_alias) {
1484 $param .= '&search_company_alias='.urlencode($search_company_alias);
1485}
1486if ($search_parent_name != '') {
1487 $param .= '&search_parent_name='.urlencode($search_parent_name);
1488}
1489if ($search_ref_customer) {
1490 $param .= '&search_ref_customer='.urlencode($search_ref_customer);
1491}
1492if ($search_user > 0) {
1493 $param .= '&search_user='.urlencode((string) ($search_user));
1494}
1495if ($search_sale > 0) {
1496 $param .= '&search_sale='.urlencode((string) ($search_sale));
1497}
1498if ($search_total_ht != '') {
1499 $param .= '&search_total_ht='.urlencode($search_total_ht);
1500}
1501if ($search_total_vat != '') {
1502 $param .= '&search_total_vat='.urlencode($search_total_vat);
1503}
1504if ($search_total_ttc != '') {
1505 $param .= '&search_total_ttc='.urlencode($search_total_ttc);
1506}
1507if ($search_warehouse != '') {
1508 $param .= '&search_warehouse='.urlencode((string) ($search_warehouse));
1509}
1510if ($search_login) {
1511 $param .= '&search_login='.urlencode($search_login);
1512}
1513if ($search_multicurrency_code != '') {
1514 $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
1515}
1516if ($search_multicurrency_tx != '') {
1517 $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1518}
1519if ($search_multicurrency_montant_ht != '') {
1520 $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1521}
1522if ($search_multicurrency_montant_vat != '') {
1523 $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
1524}
1525if ($search_multicurrency_montant_ttc != '') {
1526 $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1527}
1528if ($search_project_ref >= 0) {
1529 $param .= "&search_project_ref=".urlencode($search_project_ref);
1530}
1531if ($search_project != '') {
1532 $param .= "&search_project=".urlencode($search_project);
1533}
1534if ($search_town != '') {
1535 $param .= '&search_town='.urlencode($search_town);
1536}
1537if ($search_zip != '') {
1538 $param .= '&search_zip='.urlencode($search_zip);
1539}
1540if ($search_state != '') {
1541 $param .= '&search_state='.urlencode($search_state);
1542}
1543if ($search_country != '') {
1544 $param .= '&search_country='.urlencode((string) ($search_country));
1545}
1546if ($search_type_thirdparty && $search_type_thirdparty != '-1') {
1547 $param .= '&search_type_thirdparty='.urlencode((string) ($search_type_thirdparty));
1548}
1549if ($searchCategoryOrderOperator == 1) {
1550 $param .= "&search_category_order_operator=".urlencode((string) ($searchCategoryOrderOperator));
1551}
1552foreach ($searchCategoryOrderList as $searchCategoryOrder) {
1553 $param .= "&search_category_order_list[]=".urlencode($searchCategoryOrder);
1554}
1555if ($search_product_category != '') {
1556 $param .= '&search_product_category='.urlencode((string) ($search_product_category));
1557}
1558if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
1559 $param .= '&search_categ_cus='.urlencode((string) ($search_categ_cus));
1560}
1561if ($search_billed != '') {
1562 $param .= '&search_billed='.urlencode($search_billed);
1563}
1564if ($search_fk_cond_reglement > 0) {
1565 $param .= '&search_fk_cond_reglement='.urlencode((string) ($search_fk_cond_reglement));
1566}
1567if ($search_fk_shipping_method > 0) {
1568 $param .= '&search_fk_shipping_method='.urlencode((string) ($search_fk_shipping_method));
1569}
1570if ($search_fk_mode_reglement > 0) {
1571 $param .= '&search_fk_mode_reglement='.urlencode((string) ($search_fk_mode_reglement));
1572}
1573if ($search_fk_input_reason > 0) {
1574 $param .= '&search_fk_input_reason='.urlencode((string) ($search_fk_input_reason));
1575}
1576if ($search_module_source) {
1577 $param .= '&search_module_source='.urlencode($search_module_source);
1578}
1579if ($search_pos_source) {
1580 $param .= '&search_pos_source='.urlencode($search_pos_source);
1581}
1582if ($search_import_key != '') {
1583 $param .= '&search_import_key='.urlencode($search_import_key);
1584}
1585
1586// Add $param from extra fields
1587include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
1588
1589// Add $param from hooks
1590$parameters = array();
1591$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1592$param .= $hookmanager->resPrint;
1593
1594// List of mass actions available
1595$arrayofmassactions = array(
1596 'generate_doc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
1597 'builddoc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
1598);
1599if (isModEnabled('category') && $user->hasRight("commande", "lire")) {
1600 $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
1601}
1602if ($permissiontovalidate) {
1603 $arrayofmassactions['prevalidate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate");
1604}
1605if ($permissiontoclose) {
1606 $arrayofmassactions['preshipped'] = img_picto('', 'dolly', 'class="pictofixedwidth"').$langs->trans("ClassifyShipped");
1607}
1608if (isModEnabled('invoice') && $user->hasRight("facture", "creer")) {
1609 $arrayofmassactions['createbills'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("CreateInvoiceForThisCustomer");
1610}
1611if ($permissiontoclose) {
1612 $arrayofmassactions['setbilled'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("ClassifyBilled");
1613}
1614if ($permissiontocancel) {
1615 $arrayofmassactions['cancelorders'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("CancelOrder");
1616}
1617if (!empty($permissiontodelete)) {
1618 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
1619}
1620if ($permissiontosendbymail) {
1621 $arrayofmassactions['presend'] = img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail");
1622}
1623if (in_array($massaction, array('presend', 'predelete', 'createbills'))) {
1624 $arrayofmassactions = array();
1625}
1626$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
1627
1628$url = DOL_URL_ROOT.'/commande/card.php?action=create';
1629if (!empty($socid)) {
1630 $url .= '&socid='.$socid;
1631}
1632$newcardbutton = '';
1633$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition'));
1634$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition'));
1635$newcardbutton .= dolGetButtonTitleSeparator();
1636$newcardbutton .= dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', $url, '', (int) (($contextpage == 'orderlist' || $contextpage == 'billableorders') && $permissiontoadd));
1637
1638// Lines of title fields
1639print '<form method="POST" id="searchFormList" name="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
1640if ($optioncss != '') {
1641 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
1642}
1643print '<input type="hidden" name="token" value="'.newToken().'">';
1644print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1645print '<input type="hidden" name="action" value="list">';
1646print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
1647print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
1648print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
1649print '<input type="hidden" name="search_status" value="'.$search_status.'">';
1650print '<input type="hidden" name="socid" value="'.$socid.'">';
1651print '<input type="hidden" name="page_y" value="">';
1652print '<input type="hidden" name="mode" value="'.$mode.'">';
1653
1654
1655print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'order', 0, $newcardbutton, '', $limit, 0, 0, 1);
1656
1657$topicmail = "SendOrderRef";
1658$modelmail = "order_send";
1659$objecttmp = new Commande($db);
1660$trackid = 'ord'.$object->id;
1661include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
1662
1663if ($massaction == 'prevalidate') {
1664 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1);
1665}
1666if ($massaction == 'preshipped') {
1667 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("CloseOrder"), $langs->trans("ConfirmCloseOrder"), "shipped", null, '', 0, 200, 500, 1);
1668}
1669
1670if ($massaction == 'createbills') {
1671 print '<input type="hidden" name="massaction" value="confirm_createbills">';
1672
1673 print '<table class="noborder centpercent">';
1674 print '<tr>';
1675 print '<td>';
1676 print $langs->trans('DateInvoice');
1677 print '</td>';
1678 print '<td>';
1679 print $form->selectDate('', '', 0, 0, 0, '', 1, 1);
1680 print '</td>';
1681 print '</tr>';
1682 print '<tr>';
1683 print '<td>';
1684 print $langs->trans('CreateOneBillByThird');
1685 print '</td>';
1686 print '<td>';
1687 print $form->selectyesno('createbills_onebythird', getDolGlobalString('MAIN_ORDERLIST_CREATEBILLS_ONEBYTHIRD', 'no'), 1);
1688 print '</td>';
1689 print '</tr>';
1690 print '<tr>';
1691 print '<td>';
1692 print $langs->trans('ValidateInvoices');
1693 print '</td>';
1694 print '<td>';
1695 if (isModEnabled('stock') && getDolGlobalString('STOCK_CALCULATE_ON_BILL')) {
1696 print $form->selectyesno('validate_invoices', 0, 1, 1);
1697 $langs->load("errors");
1698 print ' ('.$langs->trans("WarningAutoValNotPossibleWhenStockIsDecreasedOnInvoiceVal").')';
1699 } else {
1700 print $form->selectyesno('validate_invoices', 0, 1);
1701 }
1702 if (!empty($conf->workflow->enabled) && getDolGlobalString('WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER')) {
1703 print ' &nbsp; &nbsp; <span class="opacitymedium">'.$langs->trans("IfValidateInvoiceIsNoOrderStayUnbilled").'</span>';
1704 } else {
1705 print ' &nbsp; &nbsp; <span class="opacitymedium">'.$langs->trans("OptionToSetOrderBilledNotEnabled").'</span>';
1706 }
1707 print '</td>';
1708 print '</tr>';
1709 print '</table>';
1710
1711 print '<div class="center">';
1712 print '<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans('CreateInvoiceForThisCustomer').'"> ';
1713 print '<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
1714 print '</div>';
1715 print '<br><br>';
1716}
1717
1718if ($search_all) {
1719 $setupstring = '';
1720 foreach ($fieldstosearchall as $key => $val) {
1721 $fieldstosearchall[$key] = $langs->trans($val);
1722 $setupstring .= $key."=".$val.";";
1723 }
1724 print '<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
1725 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
1726}
1727
1728$moreforfilter = '';
1729
1730if (isModEnabled('category') && $user->hasRight('categorie', 'read')) {
1731 $formcategory = new FormCategory($db);
1732 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_ORDER, $searchCategoryOrderList, 'minwidth300', $searchCategoryOrderOperator ? $searchCategoryOrderOperator : 0);
1733}
1734
1735// If the user can view prospects? sales other than his own
1736if ($user->hasRight("user", "user", "lire")) {
1737 $langs->load("commercial");
1738 $moreforfilter .= '<div class="divsearchfield">';
1739 $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
1740 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx');
1741 $moreforfilter .= '</div>';
1742}
1743// If the user can view other users
1744if ($user->hasRight("user", "user", "lire")) {
1745 $moreforfilter .= '<div class="divsearchfield">';
1746 $tmptitle = $langs->trans('LinkedToSpecificUsers');
1747 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, null, 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
1748 $moreforfilter .= '</div>';
1749}
1750
1751// If the user can view other products/services than his own
1752if (isModEnabled('category') && $user->hasRight("categorie", "lire") && ($user->hasRight("produit", "lire") || $user->hasRight("service", "lire"))) {
1753 include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1754 $moreforfilter .= '<div class="divsearchfield">';
1755 $tmptitle = $langs->trans('IncludingProductWithTag');
1756 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 0, array(), 1);
1757 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, '', 'maxwidth300 widthcentpercentminusx', 1);
1758 $moreforfilter .= '</div>';
1759}
1760// If Categories are enabled & user has rights to see
1761if (isModEnabled('category') && $user->hasRight("categorie", "lire")) {
1762 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1763 $moreforfilter .= '<div class="divsearchfield">';
1764 $tmptitle = $langs->trans('CustomersProspectsCategoriesShort');
1765 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $tmptitle, 'maxwidth300 widthcentpercentminusx');
1766 $moreforfilter .= '</div>';
1767}
1768// If Stock is enabled
1769if (isModEnabled('stock') && getDolGlobalString('WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
1770 require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
1771 $formproduct = new FormProduct($db);
1772 $moreforfilter .= '<div class="divsearchfield">';
1773 $tmptitle = $langs->trans('Warehouse');
1774 $moreforfilter .= img_picto($tmptitle, 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse, 'search_warehouse', '', 1, 0, 0, $tmptitle, 0, 0, array(), 'maxwidth250 widthcentpercentminusx');
1775 $moreforfilter .= '</div>';
1776}
1777
1778$parameters = array();
1779$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1780if (empty($reshook)) {
1781 $moreforfilter .= $hookmanager->resPrint;
1782} else {
1783 $moreforfilter = $hookmanager->resPrint;
1784}
1785
1786if (!empty($moreforfilter)) {
1787 print '<div class="liste_titre liste_titre_bydiv centpercent">';
1788 print $moreforfilter;
1789 print '</div>';
1790}
1791
1792$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1793$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields with user setup
1794$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
1795$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
1796
1797if (GETPOSTINT('autoselectall')) {
1798 $selectedfields .= '<script>';
1799 $selectedfields .= ' $(document).ready(function() {';
1800 $selectedfields .= ' console.log("Autoclick on checkforselects");';
1801 $selectedfields .= ' $("#checkforselects").click();';
1802 $selectedfields .= ' $("#massaction").val("createbills").change();';
1803 $selectedfields .= ' });';
1804 $selectedfields .= '</script>';
1805}
1806
1807print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
1808print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1809
1810// Fields title search
1811// --------------------------------------------------------------------
1812print '<tr class="liste_titre_filter">';
1813// Action column
1814if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1815 print '<td class="liste_titre center maxwidthsearch actioncolumn">';
1816 $searchpicto = $form->showFilterButtons('left');
1817 print $searchpicto;
1818 print '</td>';
1819}
1820
1821// Line numbering
1822if (!empty($arrayfields['c.rowid']['checked'])) {
1823 print '<td class="liste_titre">';
1824 print '<input class="flat" size="6" type="text" name="search_id" value="'.dol_escape_htmltag($search_id).'">';
1825 print '</td>';
1826}
1827
1828// Ref
1829if (!empty($arrayfields['c.ref']['checked'])) {
1830 print '<td class="liste_titre">';
1831 print '<input class="flat maxwidth50imp" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
1832 print '</td>';
1833}
1834// Ref ext
1835if (!empty($arrayfields['c.ref_ext']['checked'])) {
1836 print '<td class="liste_titre">';
1837 print '<input class="flat maxwidth50imp" type="text" name="search_ref_ext" value="'.dol_escape_htmltag($search_ref_ext).'">';
1838 print '</td>';
1839}
1840// Ref customer
1841if (!empty($arrayfields['c.ref_client']['checked'])) {
1842 print '<td class="liste_titre" align="left">';
1843 print '<input class="flat" type="text" size="6" name="search_ref_customer" value="'.dol_escape_htmltag($search_ref_customer).'">';
1844 print '</td>';
1845}
1846// Project ref
1847if (!empty($arrayfields['p.ref']['checked'])) {
1848 print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>';
1849}
1850// Project label
1851if (!empty($arrayfields['p.title']['checked'])) {
1852 print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project" value="'.dol_escape_htmltag($search_project).'"></td>';
1853}
1854// Thirdparty
1855if (!empty($arrayfields['s.nom']['checked'])) {
1856 print '<td class="liste_titre">';
1857 print '<input class="flat maxwidth75imp" type="text" name="search_company" value="'.dol_escape_htmltag((string) $search_company).'"'.(!empty($user->socid) ? " disabled" : "").'>';
1858 print '</td>';
1859}
1860// Alias
1861if (!empty($arrayfields['s.name_alias']['checked'])) {
1862 print '<td class="liste_titre">';
1863 print '<input class="flat maxwidth75imp" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).'">';
1864 print '</td>';
1865}
1866// Parent company
1867if (!empty($arrayfields['s2.nom']['checked'])) {
1868 print '<td class="liste_titre">';
1869 print '<input class="flat maxwidth100" type="text" name="search_parent_name" value="'.dol_escape_htmltag($search_parent_name).'">';
1870 print '</td>';
1871}
1872// Town
1873if (!empty($arrayfields['s.town']['checked'])) {
1874 print '<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>';
1875}
1876// Zip
1877if (!empty($arrayfields['s.zip']['checked'])) {
1878 print '<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>';
1879}
1880// State
1881if (!empty($arrayfields['state.nom']['checked'])) {
1882 print '<td class="liste_titre">';
1883 print '<input class="flat maxwidth50imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
1884 print '</td>';
1885}
1886// Country
1887if (!empty($arrayfields['country.code_iso']['checked'])) {
1888 print '<td class="liste_titre" align="center">';
1889 print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
1890 print '</td>';
1891}
1892// Company type
1893if (!empty($arrayfields['typent.code']['checked'])) {
1894 print '<td class="liste_titre maxwidthonsmartphone center">';
1895 print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (!getDolGlobalString('SOCIETE_SORT_ON_TYPEENT') ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
1896 print '</td>';
1897}
1898// Date order
1899if (!empty($arrayfields['c.date_commande']['checked'])) {
1900 print '<td class="liste_titre center">';
1901 print '<div class="nowrapfordate">';
1902 print $form->selectDate($search_dateorder_start ? $search_dateorder_start : -1, 'search_dateorder_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1903 print '</div>';
1904 print '<div class="nowrapfordate">';
1905 print $form->selectDate($search_dateorder_end ? $search_dateorder_end : -1, 'search_dateorder_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1906 print '</div>';
1907 print '</td>';
1908}
1909if (!empty($arrayfields['c.delivery_date']['checked'])) {
1910 print '<td class="liste_titre center">';
1911 print '<div class="nowrapfordate">';
1912 print $form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1, 'search_datedelivery_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1913 print '</div>';
1914 print '<div class="nowrapfordate">';
1915 print $form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1, 'search_datedelivery_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1916 print '</div>';
1917 print '</td>';
1918}
1919// Shipping Method
1920if (!empty($arrayfields['c.fk_shipping_method']['checked'])) {
1921 print '<td class="liste_titre">';
1922 $form->selectShippingMethod($search_fk_shipping_method, 'search_fk_shipping_method', '', 1, '', 1);
1923 print '</td>';
1924}
1925// Payment term
1926if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) {
1927 print '<td class="liste_titre">';
1928 print $form->getSelectConditionsPaiements((int) $search_fk_cond_reglement, 'search_fk_cond_reglement', 1, 1, 1);
1929 print '</td>';
1930}
1931// Payment mode
1932if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) {
1933 print '<td class="liste_titre">';
1934 print $form->select_types_paiements($search_fk_mode_reglement, 'search_fk_mode_reglement', '', 0, 1, 1, 0, -1, '', 1);
1935 print '</td>';
1936}
1937// Channel
1938if (!empty($arrayfields['c.fk_input_reason']['checked'])) {
1939 print '<td class="liste_titre">';
1940 $form->selectInputReason($search_fk_input_reason, 'search_fk_input_reason', '', 1, '', 1);
1941 print '</td>';
1942}
1943// Module source
1944if (!empty($arrayfields['c.module_source']['checked'])) {
1945 print '<td class="liste_titre">';
1946 print '<input class="flat maxwidth75" type="text" name="search_module_source" value="'.dol_escape_htmltag($search_module_source).'">';
1947 print '</td>';
1948}
1949// POS Terminal
1950if (!empty($arrayfields['c.pos_source']['checked'])) {
1951 print '<td class="liste_titre">';
1952 print '<input class="flat maxwidth50" type="text" name="search_pos_source" value="'.dol_escape_htmltag($search_pos_source).'">';
1953 print '</td>';
1954}
1955// Amount HT / net
1956if (!empty($arrayfields['c.total_ht']['checked'])) {
1957 print '<td class="liste_titre right">';
1958 print '<input class="flat" type="text" size="4" name="search_total_ht" value="'.dol_escape_htmltag($search_total_ht).'">';
1959 print '</td>';
1960}
1961// Amount of VAT
1962if (!empty($arrayfields['c.total_vat']['checked'])) {
1963 print '<td class="liste_titre right">';
1964 print '<input class="flat" type="text" size="4" name="search_total_vat" value="'.dol_escape_htmltag($search_total_vat).'">';
1965 print '</td>';
1966}
1967// Total Amount (TTC / gross)
1968if (!empty($arrayfields['c.total_ttc']['checked'])) {
1969 print '<td class="liste_titre right">';
1970 print '<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.'">';
1971 print '</td>';
1972}
1973// Currency
1974if (!empty($arrayfields['c.multicurrency_code']['checked'])) {
1975 print '<td class="liste_titre">';
1976 print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
1977 print '</td>';
1978}
1979// Currency rate
1980if (!empty($arrayfields['c.multicurrency_tx']['checked'])) {
1981 print '<td class="liste_titre">';
1982 print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
1983 print '</td>';
1984}
1985// Amount HT/net in foreign currency
1986if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) {
1987 print '<td class="liste_titre right">';
1988 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
1989 print '</td>';
1990}
1991// VAT in foreign currency
1992if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) {
1993 print '<td class="liste_titre right">';
1994 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
1995 print '</td>';
1996}
1997// Amount/Total (TTC / gross) in foreign currency
1998if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) {
1999 print '<td class="liste_titre right">';
2000 print '<input class="flat width75" type="text" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
2001 print '</td>';
2002}
2003// Author
2004if (!empty($arrayfields['u.login']['checked'])) {
2005 print '<td class="liste_titre">';
2006 print '<input class="flat width75" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
2007 print '</td>';
2008}
2009// Sales Representative
2010if (!empty($arrayfields['sale_representative']['checked'])) {
2011 print '<td class="liste_titre"></td>';
2012}
2013if (!empty($arrayfields['total_pa']['checked'])) {
2014 print '<td class="liste_titre right">';
2015 print '</td>';
2016}
2017if (!empty($arrayfields['total_margin']['checked'])) {
2018 print '<td class="liste_titre right">';
2019 print '</td>';
2020}
2021if (!empty($arrayfields['total_margin_rate']['checked'])) {
2022 print '<td class="liste_titre right">';
2023 print '</td>';
2024}
2025if (!empty($arrayfields['total_mark_rate']['checked'])) {
2026 print '<td class="liste_titre right">';
2027 print '</td>';
2028}
2029
2030// Date creation
2031if (!empty($arrayfields['c.datec']['checked'])) {
2032 print '<td class="liste_titre">';
2033 print '</td>';
2034}
2035// Date modification
2036if (!empty($arrayfields['c.tms']['checked'])) {
2037 print '<td class="liste_titre">';
2038 print '</td>';
2039}
2040// Date closing
2041if (!empty($arrayfields['c.date_cloture']['checked'])) {
2042 print '<td class="liste_titre center">';
2043 print '<div class="nowrapfordate">';
2044 print $form->selectDate($search_datecloture_start ? $search_datecloture_start : -1, 'search_datecloture_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
2045 print '</div>';
2046 print '<div class="nowrapfordate">';
2047 print $form->selectDate($search_datecloture_end ? $search_datecloture_end : -1, 'search_datecloture_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
2048 print '</div>';
2049 print '</td>';
2050}
2051// Note public
2052if (!empty($arrayfields['c.note_public']['checked'])) {
2053 print '<td class="liste_titre">';
2054 print '<input class="flat width75" type="text" name="search_note_public" value="'.dolPrintHTMLForAttribute($search_note_public).'">';
2055 print '</td>';
2056}
2057// Note private
2058if (!empty($arrayfields['c.note_private']['checked'])) {
2059 print '<td class="liste_titre">';
2060 print '<input class="flat width75" type="text" name="search_note_private" value="'.dolPrintHTMLForAttribute($search_note_private).'">';
2061 print '</td>';
2062}
2063// Shippable
2064if (!empty($arrayfields['shippable']['checked'])) {
2065 print '<td class="liste_titre maxwidthonsmartphone" align="center">';
2066 //print $form->selectyesno('search_shippable', $search_shippable, 1, 0, 1, 1);
2067 if (getDolGlobalString('ORDER_SHIPABLE_STATUS_DISABLED_BY_DEFAULT')) {
2068 print '<input type="checkbox" name="show_shippable_command" value="1"'.($show_shippable_command ? ' checked' : '').'>';
2069 print $langs->trans('ShowShippableStatus');
2070 } else {
2071 $show_shippable_command = 1;
2072 }
2073 print '</td>';
2074}
2075
2076// Extra fields
2077include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
2078
2079// Fields from hook
2080$parameters = array('arrayfields' => $arrayfields);
2081$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2082print $hookmanager->resPrint;
2083
2084// Status billed
2085if (!empty($arrayfields['c.facture']['checked'])) {
2086 print '<td class="liste_titre maxwidthonsmartphone center">';
2087 print $form->selectyesno('search_billed', $search_billed, 1, 0, 1, 1);
2088 print '</td>';
2089}
2090
2091// Import key
2092if (!empty($arrayfields['c.import_key']['checked'])) {
2093 print '<td class="liste_titre maxwidthonsmartphone center">';
2094 print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
2095 print '</td>';
2096}
2097
2098// Status
2099if (!empty($arrayfields['c.fk_statut']['checked'])) {
2100 print '<td class="liste_titre center parentonrightofpage">';
2101 $liststatus = array(
2102 Commande::STATUS_DRAFT => $langs->trans("StatusOrderDraftShort"),
2103 Commande::STATUS_VALIDATED => $langs->trans("StatusOrderValidated"),
2104 Commande::STATUS_SHIPMENTONPROCESS => $langs->trans("StatusOrderSentShort"),
2105 -2 => $langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"),
2106 -3 => $langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"),
2107 Commande::STATUS_CLOSED => $langs->trans("StatusOrderDelivered"),
2108 Commande::STATUS_CANCELED => $langs->trans("StatusOrderCanceledShort")
2109 );
2110 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
2111 print $form->selectarray('search_status', $liststatus, $search_status, -5, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1);
2112 print '</td>';
2113}
2114// Action column
2115if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
2116 print '<td class="liste_titre center maxwidthsearch">';
2117 $searchpicto = $form->showFilterButtons();
2118 print $searchpicto;
2119 print '</td>';
2120}
2121print '</tr>'."\n";
2122
2123$totalarray = array(
2124 'nbfield' => 0,
2125 'val' => array(
2126 'c.total_ht' => 0,
2127 'c.total_tva' => 0,
2128 'c.total_ttc' => 0,
2129 ),
2130 'pos' => array(),
2131);
2132
2133
2134// Fields title label
2135// --------------------------------------------------------------------
2136print '<tr class="liste_titre">';
2137
2138// Action column
2139if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
2140 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center ');
2141 $totalarray['nbfield']++;
2142}
2143if (!empty($arrayfields['c.rowid']['checked'])) {
2144 print_liste_field_titre($arrayfields['c.rowid']['label'], $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder, 'center ');
2145 $totalarray['nbfield']++;
2146}
2147if (!empty($arrayfields['c.ref']['checked'])) {
2148 print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], 'c.ref', '', $param, '', $sortfield, $sortorder);
2149 $totalarray['nbfield']++;
2150}
2151if (!empty($arrayfields['c.ref_ext']['checked'])) {
2152 print_liste_field_titre($arrayfields['c.ref_ext']['label'], $_SERVER["PHP_SELF"], 'c.ref_ext', '', $param, '', $sortfield, $sortorder);
2153 $totalarray['nbfield']++;
2154}
2155if (!empty($arrayfields['c.ref_client']['checked'])) {
2156 print_liste_field_titre($arrayfields['c.ref_client']['label'], $_SERVER["PHP_SELF"], 'c.ref_client', '', $param, '', $sortfield, $sortorder);
2157 $totalarray['nbfield']++;
2158}
2159if (!empty($arrayfields['p.ref']['checked'])) {
2160 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
2161 $totalarray['nbfield']++;
2162}
2163if (!empty($arrayfields['p.title']['checked'])) {
2164 print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, '', $sortfield, $sortorder);
2165 $totalarray['nbfield']++;
2166}
2167if (!empty($arrayfields['s.nom']['checked'])) {
2168 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
2169 $totalarray['nbfield']++;
2170}
2171if (!empty($arrayfields['s.name_alias']['checked'])) {
2172 // @phan-suppress-next-line PhanTypeInvalidDimOffset
2173 print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $param, '', $sortfield, $sortorder);
2174 $totalarray['nbfield']++;
2175}
2176if (!empty($arrayfields['s2.nom']['checked'])) {
2177 print_liste_field_titre($arrayfields['s2.nom']['label'], $_SERVER['PHP_SELF'], 's2.nom', '', $param, '', $sortfield, $sortorder);
2178 $totalarray['nbfield']++;
2179}
2180if (!empty($arrayfields['s.town']['checked'])) {
2181 print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
2182 $totalarray['nbfield']++;
2183}
2184if (!empty($arrayfields['s.zip']['checked'])) {
2185 print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
2186 $totalarray['nbfield']++;
2187}
2188if (!empty($arrayfields['state.nom']['checked'])) {
2189 print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
2190 $totalarray['nbfield']++;
2191}
2192if (!empty($arrayfields['country.code_iso']['checked'])) {
2193 print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
2194 $totalarray['nbfield']++;
2195}
2196if (!empty($arrayfields['typent.code']['checked'])) {
2197 print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
2198 $totalarray['nbfield']++;
2199}
2200if (!empty($arrayfields['c.date_commande']['checked'])) {
2201 print_liste_field_titre($arrayfields['c.date_commande']['label'], $_SERVER["PHP_SELF"], 'c.date_commande', '', $param, '', $sortfield, $sortorder, 'center ');
2202 $totalarray['nbfield']++;
2203}
2204if (!empty($arrayfields['c.delivery_date']['checked'])) {
2205 print_liste_field_titre($arrayfields['c.delivery_date']['label'], $_SERVER["PHP_SELF"], 'c.date_livraison', '', $param, '', $sortfield, $sortorder, 'center ');
2206 $totalarray['nbfield']++;
2207}
2208if (!empty($arrayfields['c.fk_shipping_method']['checked'])) {
2209 print_liste_field_titre($arrayfields['c.fk_shipping_method']['label'], $_SERVER["PHP_SELF"], "c.fk_shipping_method", "", $param, '', $sortfield, $sortorder);
2210 $totalarray['nbfield']++;
2211}
2212if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) {
2213 print_liste_field_titre($arrayfields['c.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_cond_reglement", "", $param, '', $sortfield, $sortorder);
2214 $totalarray['nbfield']++;
2215}
2216if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) {
2217 print_liste_field_titre($arrayfields['c.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_mode_reglement", "", $param, '', $sortfield, $sortorder);
2218 $totalarray['nbfield']++;
2219}
2220if (!empty($arrayfields['c.fk_input_reason']['checked'])) {
2221 print_liste_field_titre($arrayfields['c.fk_input_reason']['label'], $_SERVER["PHP_SELF"], "c.fk_input_reason", "", $param, '', $sortfield, $sortorder);
2222 $totalarray['nbfield']++;
2223}
2224if (!empty($arrayfields['c.module_source']['checked'])) {
2225 print_liste_field_titre($arrayfields['c.module_source']['label'], $_SERVER["PHP_SELF"], "f.module_source", "", $param, "", $sortfield, $sortorder);
2226 $totalarray['nbfield']++;
2227}
2228if (!empty($arrayfields['c.pos_source']['checked'])) {
2229 print_liste_field_titre($arrayfields['c.pos_source']['label'], $_SERVER["PHP_SELF"], "f.pos_source", "", $param, "", $sortfield, $sortorder);
2230 $totalarray['nbfield']++;
2231}
2232if (!empty($arrayfields['c.total_ht']['checked'])) {
2233 print_liste_field_titre($arrayfields['c.total_ht']['label'], $_SERVER["PHP_SELF"], 'c.total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
2234 $totalarray['nbfield']++;
2235}
2236if (!empty($arrayfields['c.total_vat']['checked'])) {
2237 print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'c.total_tva', '', $param, '', $sortfield, $sortorder, 'right ');
2238 $totalarray['nbfield']++;
2239}
2240if (!empty($arrayfields['c.total_ttc']['checked'])) {
2241 print_liste_field_titre($arrayfields['c.total_ttc']['label'], $_SERVER["PHP_SELF"], 'c.total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
2242 $totalarray['nbfield']++;
2243}
2244if (!empty($arrayfields['c.multicurrency_code']['checked'])) {
2245 print_liste_field_titre($arrayfields['c.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_code', '', $param, '', $sortfield, $sortorder);
2246 $totalarray['nbfield']++;
2247}
2248if (!empty($arrayfields['c.multicurrency_tx']['checked'])) {
2249 print_liste_field_titre($arrayfields['c.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
2250 $totalarray['nbfield']++;
2251}
2252if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) {
2253 print_liste_field_titre($arrayfields['c.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
2254 $totalarray['nbfield']++;
2255}
2256if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) {
2257 print_liste_field_titre($arrayfields['c.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
2258 $totalarray['nbfield']++;
2259}
2260if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) {
2261 print_liste_field_titre($arrayfields['c.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
2262 $totalarray['nbfield']++;
2263}
2264if (!empty($arrayfields['u.login']['checked'])) {
2265 print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, '', $sortfield, $sortorder);
2266 $totalarray['nbfield']++;
2267}
2268if (!empty($arrayfields['sale_representative']['checked'])) {
2269 print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder);
2270 $totalarray['nbfield']++;
2271}
2272if (!empty($arrayfields['total_pa']['checked'])) {
2273 print_liste_field_titre($arrayfields['total_pa']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
2274 $totalarray['nbfield']++;
2275}
2276if (!empty($arrayfields['total_margin']['checked'])) {
2277 print_liste_field_titre($arrayfields['total_margin']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
2278 $totalarray['nbfield']++;
2279}
2280if (!empty($arrayfields['total_margin_rate']['checked'])) {
2281 print_liste_field_titre($arrayfields['total_margin_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
2282 $totalarray['nbfield']++;
2283}
2284if (!empty($arrayfields['total_mark_rate']['checked'])) {
2285 print_liste_field_titre($arrayfields['total_mark_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
2286 $totalarray['nbfield']++;
2287}
2288
2289if (!empty($arrayfields['c.datec']['checked'])) {
2290 print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
2291 $totalarray['nbfield']++;
2292}
2293if (!empty($arrayfields['c.tms']['checked'])) {
2294 print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
2295 $totalarray['nbfield']++;
2296}
2297if (!empty($arrayfields['c.date_cloture']['checked'])) {
2298 print_liste_field_titre($arrayfields['c.date_cloture']['label'], $_SERVER["PHP_SELF"], "c.date_cloture", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
2299 $totalarray['nbfield']++;
2300}
2301if (!empty($arrayfields['c.note_public']['checked'])) {
2302 print_liste_field_titre($arrayfields['c.note_public']['label'], $_SERVER["PHP_SELF"], "c.note_public", "", $param, '', $sortfield, $sortorder, '');
2303 $totalarray['nbfield']++;
2304}
2305if (!empty($arrayfields['c.note_private']['checked'])) {
2306 print_liste_field_titre($arrayfields['c.note_private']['label'], $_SERVER["PHP_SELF"], "c.note_private", "", $param, '', $sortfield, $sortorder, '');
2307 $totalarray['nbfield']++;
2308}
2309if (!empty($arrayfields['shippable']['checked'])) {
2310 print_liste_field_titre($arrayfields['shippable']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
2311 $totalarray['nbfield']++;
2312}
2313// Extra fields
2314include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
2315
2316// Hook fields
2317$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
2318$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2319print $hookmanager->resPrint;
2320
2321// Status billed
2322if (!empty($arrayfields['c.facture']['checked'])) {
2323 print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center ');
2324 $totalarray['nbfield']++;
2325}
2326// Import key
2327if (!empty($arrayfields['c.import_key']['checked'])) {
2328 print_liste_field_titre($arrayfields['c.import_key']['label'], $_SERVER["PHP_SELF"], "c.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
2329 $totalarray['nbfield']++;
2330}
2331// Status
2332if (!empty($arrayfields['c.fk_statut']['checked'])) {
2333 print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
2334 $totalarray['nbfield']++;
2335}
2336// Action column
2337if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
2338 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center ');
2339 $totalarray['nbfield']++;
2340}
2341print '</tr>'."\n";
2342
2343$total = 0;
2344$subtotal = 0;
2345$productstat_cache = array();
2346$productstat_cachevirtual = array();
2347$getNomUrl_cache = array();
2348
2349$generic_commande = new Commande($db);
2350$generic_product = new Product($db);
2351$userstatic = new User($db);
2352
2353$with_margin_info = false;
2354if (isModEnabled('margin') && (
2355 !empty($arrayfields['total_pa']['checked'])
2356 || !empty($arrayfields['total_margin']['checked'])
2357 || !empty($arrayfields['total_margin_rate']['checked'])
2358 || !empty($arrayfields['total_mark_rate']['checked'])
2359)
2360) {
2361 $with_margin_info = true;
2362}
2363
2364$total_ht = 0;
2365$total_margin = 0;
2366
2367// Loop on record
2368// --------------------------------------------------------------------
2369$i = 0;
2370$savnbfield = $totalarray['nbfield'];
2371$totalarray = array();
2372$totalarray['nbfield'] = 0;
2373$imaxinloop = ($limit ? min($num, $limit) : $num);
2374while ($i < $imaxinloop) {
2375 $obj = $db->fetch_object($resql);
2376 if (empty($obj)) {
2377 break; // Should not happen
2378 }
2379
2380 $typenArray = $formcompany->typent_array(1);
2381
2382 $notshippable = 0;
2383 $warning = 0;
2384 $text_info = '';
2385 $text_warning = '';
2386 $nbprod = 0;
2387
2388 $companystatic->id = $obj->socid;
2389 $companystatic->name = $obj->name;
2390 $companystatic->name_alias = $obj->alias;
2391 $companystatic->client = $obj->client;
2392 $companystatic->fournisseur = $obj->fournisseur;
2393 $companystatic->code_client = $obj->code_client;
2394 $companystatic->email = $obj->email;
2395 $companystatic->phone = $obj->phone;
2396 $companystatic->address = $obj->address;
2397 $companystatic->zip = $obj->zip;
2398 $companystatic->town = $obj->town;
2399 $companystatic->country_code = $obj->country_code;
2400 if (!isset($getNomUrl_cache[$obj->socid])) {
2401 $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
2402 }
2403
2404 $generic_commande->id = $obj->rowid;
2405 $generic_commande->ref = $obj->ref;
2406 $generic_commande->status = $obj->fk_statut;
2407 $generic_commande->statut = $obj->fk_statut;
2408 $generic_commande->status = $obj->fk_statut;
2409 $generic_commande->billed = $obj->billed;
2410 $generic_commande->date = $db->jdate($obj->date_commande);
2411 $generic_commande->delivery_date = $db->jdate($obj->delivery_date);
2412 $generic_commande->ref_client = $obj->ref_client;
2413 $generic_commande->total_ht = $obj->total_ht;
2414 $generic_commande->total_tva = $obj->total_tva;
2415 $generic_commande->total_ttc = $obj->total_ttc;
2416 $generic_commande->note_public = $obj->note_public;
2417 $generic_commande->note_private = $obj->note_private;
2418
2419 $generic_commande->thirdparty = $companystatic;
2420
2421
2422 $projectstatic->id = $obj->project_id;
2423 $projectstatic->ref = $obj->project_ref;
2424 $projectstatic->title = $obj->project_label;
2425
2426 $marginInfo = array();
2427 if ($with_margin_info) {
2428 $generic_commande->fetch_lines();
2429 $marginInfo = $formmargin->getMarginInfosArray($generic_commande);
2430 $total_ht += $obj->total_ht;
2431 $total_margin += $marginInfo['total_margin'];
2432 }
2433
2434 if ($mode == 'kanban') {
2435 if ($i == 0) {
2436 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
2437 print '<div class="box-flex-container kanban">';
2438 }
2439
2440 // Output Kanban
2441 $selected = -1;
2442 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2443 $selected = 0;
2444 if (in_array($object->id, $arrayofselected)) {
2445 $selected = 1;
2446 }
2447 }
2448 print $generic_commande->getKanbanView('', array('selected' => $selected));
2449 if ($i == ($imaxinloop - 1)) {
2450 print '</div>';
2451 print '</td></tr>';
2452 }
2453 } else {
2454 // Show line of result
2455 $j = 0;
2456 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select status'.$generic_commande->status.((getDolGlobalInt('MAIN_FINISHED_LINES_OPACITY') == 1 && $obj->status > 1) ? ' opacitymedium' : '').'">';
2457
2458 // Action column
2459 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
2460 print '<td class="nowrap center">';
2461 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2462 $selected = 0;
2463 if (in_array($obj->rowid, $arrayofselected)) {
2464 $selected = 1;
2465 }
2466 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
2467 }
2468 print '</td>';
2469 if (!$i) {
2470 $totalarray['nbfield']++;
2471 }
2472 }
2473
2474 // Technical ID
2475 if (!empty($arrayfields['c.rowid']['checked'])) {
2476 print '<td class="center" data-key="id">'.$obj->rowid.'</td>';
2477 if (!$i) {
2478 $totalarray['nbfield']++;
2479 }
2480 }
2481
2482 // Ref
2483 if (!empty($arrayfields['c.ref']['checked'])) {
2484 print '<td class="nowraponall">';
2485 $getNomUrlOption = $search_status != 2 ? 0 : $obj->fk_statut;
2486 if (getDolGlobalInt('MAIN_LIST_ORDER_LINK_DONT_USE_STATUS')) {
2487 // TODO : This hidden conf must be added to the user's individual conf.
2488 // The user must be able to manage this behavior to adapt it to his use of the software, because depending on the employee's workstation, his use differs.
2489 // This hidden configuration ensures that users are not confused by keeping the same behavior of click, whatever the current filter.
2490 // If the aim is to use a different url when the filter is applied via the link in the left-hand menu, then this detection should be adapted instead.
2491 $getNomUrlOption = '';
2492 }
2493 print $generic_commande->getNomUrl(1, $getNomUrlOption, 0, 0, 0, 1, 1);
2494
2495 $filename = dol_sanitizeFileName($obj->ref);
2496 $filedir = $conf->order->multidir_output[$conf->entity].'/'.dol_sanitizeFileName($obj->ref);
2497 $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
2498 print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
2499
2500 print '</td>';
2501 if (!$i) {
2502 $totalarray['nbfield']++;
2503 }
2504 }
2505
2506 // Ref customer
2507 if (!empty($arrayfields['c.ref_ext']['checked'])) {
2508 print '<td class="nowrap tdoverflowmax75" title="'.dol_escape_htmltag($obj->ref_ext).'">';
2509 print dol_escape_htmltag($obj->ref_ext);
2510 print '</td>';
2511 if (!$i) {
2512 $totalarray['nbfield']++;
2513 }
2514 }
2515
2516 // Ref customer
2517 if (!empty($arrayfields['c.ref_client']['checked'])) {
2518 print '<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($obj->ref_client).'">';
2519 print dol_escape_htmltag($obj->ref_client);
2520 print '</td>';
2521 if (!$i) {
2522 $totalarray['nbfield']++;
2523 }
2524 }
2525
2526 // Project ref
2527 if (!empty($arrayfields['p.ref']['checked'])) {
2528 print '<td class="nocellnopadd nowraponall">';
2529 if ($obj->project_id > 0) {
2530 print $projectstatic->getNomUrl(1);
2531 }
2532 print '</td>';
2533 if (!$i) {
2534 $totalarray['nbfield']++;
2535 }
2536 }
2537
2538 // Project label
2539 if (!empty($arrayfields['p.title']['checked'])) {
2540 print '<td class="nowraponall">';
2541 if ($obj->project_id > 0) {
2542 print $projectstatic->title;
2543 }
2544 print '</td>';
2545 if (!$i) {
2546 $totalarray['nbfield']++;
2547 }
2548 }
2549
2550 // Third party
2551 if (!empty($arrayfields['s.nom']['checked'])) {
2552 print '<td class="tdoverflowmax150">';
2553 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
2554 print $companystatic->getNomUrl(1, 'customer', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
2555 } else {
2556 print $getNomUrl_cache[$obj->socid];
2557 }
2558
2559 // If module invoices enabled and user with invoice creation permissions
2560 if (isModEnabled('invoice') && getDolGlobalString('ORDER_BILLING_ALL_CUSTOMER')) {
2561 if ($user->hasRight('facture', 'creer')) {
2562 if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) {
2563 print '&nbsp;<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$companystatic->id.'&search_billed=0&autoselectall=1">';
2564 print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').'</a>';
2565 }
2566 }
2567 }
2568 print '</td>';
2569 if (!$i) {
2570 $totalarray['nbfield']++;
2571 }
2572 }
2573
2574 // Alias name
2575 if (!empty($arrayfields['s.name_alias']['checked'])) {
2576 print '<td class="nocellnopadd tdoverflowmax100" title="'.dolPrintHTMLForTextArea($obj->alias).'">';
2577 print dolPrintLabel($obj->alias);
2578 print '</td>';
2579 if (!$i) {
2580 $totalarray['nbfield']++;
2581 }
2582 }
2583
2584 // Parent company
2585 if (!empty($arrayfields['s2.nom']['checked'])) {
2586 print '<td class="tdoverflowmax200">';
2587 if ($obj->fk_parent > 0) {
2588 if (!isset($company_url_list[$obj->fk_parent])) {
2589 $companyparent = new Societe($db);
2590 $res = $companyparent->fetch($obj->fk_parent);
2591 if ($res > 0) {
2592 $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1);
2593 }
2594 }
2595 if (isset($company_url_list[$obj->fk_parent])) {
2596 print $company_url_list[$obj->fk_parent];
2597 }
2598 }
2599 print "</td>";
2600 if (!$i) {
2601 $totalarray['nbfield']++;
2602 }
2603 }
2604
2605 // Town
2606 if (!empty($arrayfields['s.town']['checked'])) {
2607 print '<td class="tdoverflowmax100" title="'.dolPrintHTMLForTextArea($obj->town).'">';
2608 print dolPrintLabel($obj->town);
2609 print '</td>';
2610 if (!$i) {
2611 $totalarray['nbfield']++;
2612 }
2613 }
2614
2615 // Zip
2616 if (!empty($arrayfields['s.zip']['checked'])) {
2617 print '<td class="tdoverflowmax100" title="'.dolPrintHTMLForTextArea($obj->zip).'">';
2618 print dolPrintLabel($obj->zip);
2619 print '</td>';
2620 if (!$i) {
2621 $totalarray['nbfield']++;
2622 }
2623 }
2624
2625 // State
2626 if (!empty($arrayfields['state.nom']['checked'])) {
2627 print '<td class="tdoverflowmax100" title="'.dolPrintHTMLForTextArea($obj->state_name).'">'.dolPrintLabel($obj->state_name)."</td>\n";
2628 if (!$i) {
2629 $totalarray['nbfield']++;
2630 }
2631 }
2632
2633 // Country
2634 if (!empty($arrayfields['country.code_iso']['checked'])) {
2635 $tmparray = getCountry($obj->fk_pays, 'all');
2636 print '<td class="center tdoverflowmax100" title="'.dolPrintHTMLForAttribute($tmparray['label']).'">';
2637 print dolPrintHTML($tmparray['label']);
2638 print '</td>';
2639 if (!$i) {
2640 $totalarray['nbfield']++;
2641 }
2642 }
2643
2644 // Type ent
2645 if (!empty($arrayfields['typent.code']['checked'])) {
2646 if (!is_array($typenArray) || count($typenArray) == 0) {
2647 $typenArray = $formcompany->typent_array(1);
2648 }
2649 if (!empty($obj->typent_code)) {
2650 print '<td class="center tdoverflowmax100" title="'.dolPrintHTMLForAttribute($typenArray[$obj->typent_code]).'">';
2651 print $typenArray[$obj->typent_code];
2652 } else {
2653 print '<td class="center tdoverflowmax100">';
2654 print '';
2655 }
2656 print '</td>';
2657 if (!$i) {
2658 $totalarray['nbfield']++;
2659 }
2660 }
2661
2662 // Order date
2663 if (!empty($arrayfields['c.date_commande']['checked'])) {
2664 print '<td class="center nowraponall">';
2665 print dol_print_date($db->jdate($obj->date_commande), 'day');
2666 // Warning late icon and note
2667 if ($generic_commande->hasDelay()) {
2668 print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning");
2669 }
2670 print '</td>';
2671 if (!$i) {
2672 $totalarray['nbfield']++;
2673 }
2674 }
2675
2676 // Plannned date of delivery
2677 if (!empty($arrayfields['c.delivery_date']['checked'])) {
2678 print '<td class="center nowraponall">';
2679 print dol_print_date($db->jdate($obj->delivery_date), 'dayhour');
2680 print '</td>';
2681 if (!$i) {
2682 $totalarray['nbfield']++;
2683 }
2684 }
2685
2686 // Shipping Method
2687 if (!empty($arrayfields['c.fk_shipping_method']['checked'])) {
2688 print '<td>';
2689 $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1);
2690 print '</td>';
2691 if (!$i) {
2692 $totalarray['nbfield']++;
2693 }
2694 }
2695
2696 // Payment terms
2697 if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) {
2698 print '<td>';
2699 $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent);
2700 print '</td>';
2701 if (!$i) {
2702 $totalarray['nbfield']++;
2703 }
2704 }
2705
2706 // Payment mode
2707 if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) {
2708 print '<td>';
2709 $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1);
2710 print '</td>';
2711 if (!$i) {
2712 $totalarray['nbfield']++;
2713 }
2714 }
2715
2716 // Channel
2717 if (!empty($arrayfields['c.fk_input_reason']['checked'])) {
2718 print '<td>';
2719 $form->formInputReason($_SERVER['PHP_SELF'], $obj->fk_input_reason, 'none', 0);
2720 print '</td>';
2721 if (!$i) {
2722 $totalarray['nbfield']++;
2723 }
2724 }
2725
2726 // Module Source
2727 if (!empty($arrayfields['c.module_source']['checked'])) {
2728 print '<td>';
2729 print dol_escape_htmltag($obj->module_source);
2730 print '</td>';
2731 if (!$i) {
2732 $totalarray['nbfield']++;
2733 }
2734 }
2735 // POS Terminal
2736 if (!empty($arrayfields['c.pos_source']['checked'])) {
2737 print '<td>';
2738 print dol_escape_htmltag($obj->pos_source);
2739 print '</td>';
2740 if (!$i) {
2741 $totalarray['nbfield']++;
2742 }
2743 }
2744
2745 // Amount HT/net
2746 if (!empty($arrayfields['c.total_ht']['checked'])) {
2747 print '<td class="nowraponall right"><span class="amount">'.price($obj->total_ht)."</span></td>\n";
2748 if (!$i) {
2749 $totalarray['nbfield']++;
2750 }
2751 if (!$i) {
2752 $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ht';
2753 }
2754 if (isset($totalarray['val']['c.total_ht'])) {
2755 $totalarray['val']['c.total_ht'] += $obj->total_ht;
2756 } else {
2757 $totalarray['val']['c.total_ht'] = $obj->total_ht;
2758 }
2759 }
2760
2761 // Amount VAT
2762 if (!empty($arrayfields['c.total_vat']['checked'])) {
2763 print '<td class="nowrap right"><span class="amount">'.price($obj->total_tva)."</span></td>\n";
2764 if (!$i) {
2765 $totalarray['nbfield']++;
2766 }
2767 if (!$i) {
2768 $totalarray['pos'][$totalarray['nbfield']] = 'c.total_tva';
2769 }
2770 if (isset($totalarray['val']['c.total_tva'])) {
2771 $totalarray['val']['c.total_tva'] += $obj->total_tva;
2772 } else {
2773 $totalarray['val']['c.total_tva'] = $obj->total_tva;
2774 }
2775 }
2776
2777 // Amount TTC / gross
2778 if (!empty($arrayfields['c.total_ttc']['checked'])) {
2779 print '<td class="nowrap right"><span class="amount">'.price($obj->total_ttc)."</span></td>\n";
2780 if (!$i) {
2781 $totalarray['nbfield']++;
2782 }
2783 if (!$i) {
2784 $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ttc';
2785 }
2786 if (isset($totalarray['val']['c.total_ttc'])) {
2787 $totalarray['val']['c.total_ttc'] += $obj->total_ttc;
2788 } else {
2789 $totalarray['val']['c.total_ttc'] = $obj->total_ttc;
2790 }
2791 }
2792
2793 // Currency
2794 if (!empty($arrayfields['c.multicurrency_code']['checked'])) {
2795 print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n";
2796 if (!$i) {
2797 $totalarray['nbfield']++;
2798 }
2799 }
2800
2801 // Currency rate
2802 if (!empty($arrayfields['c.multicurrency_tx']['checked'])) {
2803 print '<td class="nowrap">';
2804 $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
2805 print "</td>\n";
2806 if (!$i) {
2807 $totalarray['nbfield']++;
2808 }
2809 }
2810
2811 // Amount HT/net in foreign currency
2812 if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) {
2813 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht)."</span></td>\n";
2814 if (!$i) {
2815 $totalarray['nbfield']++;
2816 }
2817 }
2818 // Amount VAT in foreign currency
2819 if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) {
2820 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat)."</span></td>\n";
2821 if (!$i) {
2822 $totalarray['nbfield']++;
2823 }
2824 }
2825 // Amount TTC / gross in foreign currency
2826 if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) {
2827 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc)."</span></td>\n";
2828 if (!$i) {
2829 $totalarray['nbfield']++;
2830 }
2831 }
2832
2833 $userstatic->id = $obj->fk_user_author;
2834 $userstatic->login = $obj->login;
2835 $userstatic->lastname = $obj->lastname;
2836 $userstatic->firstname = $obj->firstname;
2837 $userstatic->email = $obj->user_email;
2838 $userstatic->status = $obj->user_statut;
2839 $userstatic->entity = $obj->entity;
2840 $userstatic->photo = $obj->photo;
2841 $userstatic->office_phone = $obj->office_phone;
2842 $userstatic->office_fax = $obj->office_fax;
2843 $userstatic->user_mobile = $obj->user_mobile;
2844 $userstatic->job = $obj->job;
2845 $userstatic->gender = $obj->gender;
2846
2847 // Author
2848 if (!empty($arrayfields['u.login']['checked'])) {
2849 print '<td class="tdoverflowmax125">';
2850 if ($userstatic->id) {
2851 print $userstatic->getNomUrl(-1);
2852 } else {
2853 print '&nbsp;';
2854 }
2855 print "</td>\n";
2856 if (!$i) {
2857 $totalarray['nbfield']++;
2858 }
2859 }
2860
2861 // Sales representatives
2862 if (!empty($arrayfields['sale_representative']['checked'])) {
2863 print '<td>';
2864 if ($obj->socid > 0) {
2865 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
2866 if ($listsalesrepresentatives < 0) {
2867 dol_print_error($db);
2868 }
2869 $nbofsalesrepresentative = count($listsalesrepresentatives);
2870 if ($nbofsalesrepresentative > 6) {
2871 // We print only number
2872 print $nbofsalesrepresentative;
2873 } elseif ($nbofsalesrepresentative > 0) {
2874 $j = 0;
2875 foreach ($listsalesrepresentatives as $val) {
2876 $userstatic->id = $val['id'];
2877 $userstatic->lastname = $val['lastname'];
2878 $userstatic->firstname = $val['firstname'];
2879 $userstatic->email = $val['email'];
2880 $userstatic->status = $val['statut'];
2881 $userstatic->entity = $val['entity'];
2882 $userstatic->photo = $val['photo'];
2883 $userstatic->login = $val['login'];
2884 $userstatic->office_phone = $val['office_phone'];
2885 $userstatic->office_fax = $val['office_fax'];
2886 $userstatic->user_mobile = $val['user_mobile'];
2887 $userstatic->job = $val['job'];
2888 $userstatic->gender = $val['gender'];
2889 //print '<div class="float">':
2890 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2);
2891 $j++;
2892 if ($j < $nbofsalesrepresentative) {
2893 print ' ';
2894 }
2895 //print '</div>';
2896 }
2897 }
2898 //else print $langs->trans("NoSalesRepresentativeAffected");
2899 } else {
2900 print '&nbsp;';
2901 }
2902 print '</td>';
2903 if (!$i) {
2904 $totalarray['nbfield']++;
2905 }
2906 }
2907
2908 // Total buying or cost price
2909 if (!empty($arrayfields['total_pa']['checked'])) {
2910 print '<td class="right nowrap">'.price($marginInfo['pa_total']).'</td>';
2911 if (!$i) {
2912 $totalarray['nbfield']++;
2913 }
2914 }
2915
2916 // Total margin
2917 if (!empty($arrayfields['total_margin']['checked'])) {
2918 print '<td class="right nowrap">'.price($marginInfo['total_margin']).'</td>';
2919 if (!$i) {
2920 $totalarray['nbfield']++;
2921 }
2922 if (!$i) {
2923 $totalarray['pos'][$totalarray['nbfield']] = 'total_margin';
2924 }
2925
2926 if (!isset($totalarray['val']['total_margin'])) {
2927 $totalarray['val']['total_margin'] = 0;
2928 }
2929
2930 $totalarray['val']['total_margin'] += $marginInfo['total_margin'];
2931 }
2932
2933 // Total margin rate
2934 if (!empty($arrayfields['total_margin_rate']['checked'])) {
2935 print '<td class="right nowrap">'.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], 0, '', 0, 0, 2).'%').'</td>';
2936 if (!$i) {
2937 $totalarray['nbfield']++;
2938 }
2939 }
2940
2941 // Total mark rate
2942 if (!empty($arrayfields['total_mark_rate']['checked'])) {
2943 print '<td class="right nowrap">'.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], 0, '', 0, 0, 2).'%').'</td>';
2944 if (!$i) {
2945 $totalarray['nbfield']++;
2946 }
2947 if (!$i) {
2948 $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate';
2949 }
2950 if ($i >= $imaxinloop - 1) {
2951 if (!empty($total_ht)) {
2952 $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT');
2953 } else {
2954 $totalarray['val']['total_mark_rate'] = '';
2955 }
2956 }
2957 }
2958
2959 // Date creation
2960 if (!empty($arrayfields['c.datec']['checked'])) {
2961 print '<td class="center nowraponall">';
2962 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuserrel');
2963 print '</td>';
2964 if (!$i) {
2965 $totalarray['nbfield']++;
2966 }
2967 }
2968
2969 // Date modification
2970 if (!empty($arrayfields['c.tms']['checked'])) {
2971 print '<td class="center nowraponall">';
2972 print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuserrel');
2973 print '</td>';
2974 if (!$i) {
2975 $totalarray['nbfield']++;
2976 }
2977 }
2978
2979 // Date cloture
2980 if (!empty($arrayfields['c.date_cloture']['checked'])) {
2981 print '<td class="center nowraponall">';
2982 print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuserrel');
2983 print '</td>';
2984 if (!$i) {
2985 $totalarray['nbfield']++;
2986 }
2987 }
2988
2989 // Note public
2990 if (!empty($arrayfields['c.note_public']['checked'])) {
2991 print '<td class="sensiblehtmlcontent maxwidth250imp classfortooltip" title="'.dolPrintHTMLForAttribute(dolGetFirstLineOfText($obj->note_public, 20)).'">';
2992 print '<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(dolGetFirstLineOfText($obj->note_public, 5)).'</div>';
2993 print '</td>';
2994 if (!$i) {
2995 $totalarray['nbfield']++;
2996 }
2997 }
2998
2999 // Note private
3000 if (!empty($arrayfields['c.note_private']['checked'])) {
3001 print '<td class="sensiblehtmlcontent maxwidth250imp classfortooltip" title="'.dolPrintHTMLForAttribute(dolGetFirstLineOfText($obj->note_private, 20)).'">';
3002 print '<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(dolGetFirstLineOfText($obj->note_private, 5)).'</div>';
3003 print '</td>';
3004 if (!$i) {
3005 $totalarray['nbfield']++;
3006 }
3007 }
3008
3009 // Show shippable Icon (this creates subloops, so may be slow)
3010 if (!empty($arrayfields['shippable']['checked'])) {
3011 print '<td class="center">';
3012 if (!empty($show_shippable_command) && isModEnabled('stock')) {
3013 $text_icon = '';
3014 if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) {
3015 $generic_commande->getLinesArray(); // Load array ->lines
3016 $generic_commande->loadExpeditions(); // Load array ->expeditions
3017
3018 $stock = [];
3019
3020 $numlines = count($generic_commande->lines); // Loop on each line of order
3021 for ($lig = 0; $lig < $numlines; $lig++) {
3022 $orderLine = $generic_commande->lines[$lig];
3023 '@phan-var-force OrderLine $orderLine';
3024 if (isset($generic_commande->expeditions[$orderLine->id])) {
3025 $reliquat = $orderLine->qty - $generic_commande->expeditions[$orderLine->id];
3026 } else {
3027 $reliquat = $orderLine->qty;
3028 }
3029 if ($orderLine->product_type == 0 && $orderLine->fk_product > 0) { // If line is a product and not a service
3030 $nbprod++; // order contains real products
3031 $generic_product->id = $orderLine->fk_product;
3032
3033 // Get local and virtual stock and store it into cache
3034 if (empty($productstat_cache[$orderLine->fk_product])) {
3035 $generic_product->load_stock('nobatch,warehouseopen'); // ->load_virtual_stock() is already included into load_stock()
3036 $productstat_cache[$orderLine->fk_product]['stock_reel'] = $generic_product->stock_reel;
3037 $productstat_cachevirtual[$orderLine->fk_product]['stock_reel'] = $generic_product->stock_theorique;
3038 } else {
3039 $generic_product->stock_reel = $productstat_cache[$orderLine->fk_product]['stock_reel'];
3040 // @phan-suppress-next-line PhanTypeInvalidDimOffset
3041 $generic_product->stock_theorique = $productstat_cachevirtual[$orderLine->fk_product]['stock_reel'];
3042 }
3043
3044 if (!array_key_exists($orderLine->fk_product, $stock)) {
3045 $stock[$orderLine->fk_product] = $generic_product->stock_reel;
3046 }
3047
3048 if ($reliquat > $stock[$orderLine->fk_product]) {
3049 $notshippable++;
3050 }
3051
3052 $stock[$orderLine->fk_product] = $stock[$orderLine->fk_product] - $reliquat;
3053 if (!getDolGlobalString('SHIPPABLE_ORDER_ICON_IN_LIST')) { // Default code. Default should be this case.
3054 $text_info .= $reliquat.' x '.$orderLine->product_ref.'&nbsp;'.dol_trunc($orderLine->product_label, 20);
3055 $text_info .= ' - '.$langs->trans("Stock").': <span class="'.($generic_product->stock_reel > 0 ? 'ok' : 'error').'">'.$generic_product->stock_reel.'</span>';
3056 $text_info .= ' - '.$langs->trans("VirtualStock").': <span class="'.($generic_product->stock_theorique > 0 ? 'ok' : 'error').'">'.$generic_product->stock_theorique.'</span>';
3057 $text_info .= ($reliquat != $orderLine->qty ? ' <span class="opacitymedium">('.$langs->trans("QtyInOtherShipments").' '.($orderLine->qty - $reliquat).')</span>' : '');
3058 $text_info .= '<br>';
3059 } else { // BUGGED CODE.
3060 // DOES NOT TAKE INTO ACCOUNT MANUFACTURING. THIS CODE SHOULD BE USELESS. PREVIOUS CODE SEEMS COMPLETE.
3061 // COUNT STOCK WHEN WE SHOULD ALREADY HAVE VALUE
3062 // Detailed virtual stock, looks bugged, incomplete and need heavy load.
3063 // stock order and stock order_supplier
3064 $stock_order = 0;
3065 $stock_order_supplier = 0;
3066 if (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT') || getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE')) { // What about other options ?
3067 if (isModEnabled('order')) {
3068 if (empty($productstat_cache[$orderLine->fk_product]['stats_order_customer'])) {
3069 $generic_product->load_stats_commande(0, '1,2');
3070 $productstat_cache[$orderLine->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty'];
3071 } else {
3072 // @phan-suppress-next-line PhanTypeInvalidDimOffset
3073 $generic_product->stats_commande['qty'] = $productstat_cache[$orderLine->fk_product]['stats_order_customer'];
3074 }
3075 $stock_order = $generic_product->stats_commande['qty'];
3076 }
3077 if (isModEnabled("supplier_order")) {
3078 if (empty($productstat_cache[$orderLine->fk_product]['stats_order_supplier'])) {
3079 $generic_product->load_stats_commande_fournisseur(0, '3');
3080 $productstat_cache[$orderLine->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty'];
3081 } else {
3082 // @phan-suppress-next-line PhanTypeInvalidDimOffset
3083 $generic_product->stats_commande_fournisseur['qty'] = $productstat_cache[$orderLine->fk_product]['stats_order_supplier'];
3084 }
3085 $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty'];
3086 }
3087 }
3088 $text_info .= $reliquat.' x '.$orderLine->ref.'&nbsp;'.dol_trunc($orderLine->product_label, 20);
3089 $text_stock_reel = $generic_product->stock_reel.'/'.$stock_order;
3090 if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $orderLine->qty)) {
3091 $warning++;
3092 $text_warning .= '<span class="warning">'.$langs->trans('Available').'&nbsp;:&nbsp;'.$text_stock_reel.'</span>';
3093 }
3094 if ($reliquat > $generic_product->stock_reel) {
3095 $text_info .= '<span class="warning">'.$langs->trans('Available').'&nbsp;:&nbsp;'.$text_stock_reel.'</span>';
3096 } else {
3097 $text_info .= '<span class="ok">'.$langs->trans('Available').'&nbsp;:&nbsp;'.$text_stock_reel.'</span>';
3098 }
3099 if (isModEnabled("supplier_order")) {
3100 $text_info .= '&nbsp;'.$langs->trans('SupplierOrder').'&nbsp;:&nbsp;'.$stock_order_supplier;
3101 }
3102 $text_info .= ($reliquat != $orderLine->qty ? ' <span class="opacitymedium">('.$langs->trans("QtyInOtherShipments").' '.($orderLine->qty - $reliquat).')</span>' : '');
3103 $text_info .= '<br>';
3104 }
3105 }
3106 }
3107 if ($notshippable == 0) {
3108 $text_icon = img_picto('', 'dolly', '', 0, 0, 0, '', 'green paddingleft');
3109 $text_info = $text_icon.' '.$langs->trans('Shippable').'<br>'.$text_info;
3110 } else {
3111 $text_icon = img_picto('', 'dolly', '', 0, 0, 0, '', 'error paddingleft');
3112 $text_info = $text_icon.' '.$langs->trans('NonShippable').'<br>'.$text_info;
3113 }
3114 }
3115
3116 if ($nbprod) { // If there is at least one product to ship, we show the shippable icon
3117 print '<a href="'.DOL_URL_ROOT.'/expedition/shipment.php?id='.((int) $obj->rowid).'">';
3118 print $form->textwithtooltip('', $text_info, 2, 1, $text_icon, '', 2);
3119 print '</a>';
3120 }
3121 if ($warning) { // Always false in default mode
3122 print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders').'<br>'.$text_warning, 2, 1, img_picto('', 'error'), '', 2);
3123 }
3124 }
3125 print '</td>';
3126 if (!$i) {
3127 $totalarray['nbfield']++;
3128 }
3129 }
3130
3131 // Extra fields
3132 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
3133 // Fields from hook
3134 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
3135 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
3136 print $hookmanager->resPrint;
3137
3138 // Billed
3139 if (!empty($arrayfields['c.facture']['checked'])) {
3140 print '<td class="center">';
3141 if ($obj->billed) {
3142 print yn($obj->billed, $langs->trans("Billed"));
3143 }
3144 print '</td>';
3145 if (!$i) {
3146 $totalarray['nbfield']++;
3147 }
3148 }
3149
3150 // Import key
3151 if (!empty($arrayfields['c.import_key']['checked'])) {
3152 print '<td class="nowrap center">'.dol_escape_htmltag($obj->import_key).'</td>';
3153 if (!$i) {
3154 $totalarray['nbfield']++;
3155 }
3156 }
3157
3158 // Status
3159 if (!empty($arrayfields['c.fk_statut']['checked'])) {
3160 print '<td class="nowrap center">'.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).'</td>';
3161 if (!$i) {
3162 $totalarray['nbfield']++;
3163 }
3164 }
3165
3166 // Action column
3167 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
3168 print '<td class="nowrap center">';
3169 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
3170 $selected = 0;
3171 if (in_array($obj->rowid, $arrayofselected)) {
3172 $selected = 1;
3173 }
3174 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
3175 }
3176 print '</td>';
3177 if (!$i) {
3178 $totalarray['nbfield']++;
3179 }
3180 }
3181
3182 print "</tr>\n";
3183
3184 $total += $obj->total_ht;
3185 $subtotal += $obj->total_ht;
3186 }
3187 $i++;
3188}
3189
3190// Show total line
3191include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
3192
3193// If no record found
3194if ($num == 0) {
3195 $colspan = 1;
3196 foreach ($arrayfields as $key => $val) {
3197 if (!empty($val['checked'])) {
3198 $colspan++;
3199 }
3200 }
3201 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
3202}
3203
3204$db->free($resql);
3205
3206$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
3207$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
3208print $hookmanager->resPrint;
3209
3210print '</table>'."\n";
3211print '</div>'."\n";
3212
3213print '</form>'."\n";
3214
3215if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
3216 $hidegeneratedfilelistifempty = 1;
3217 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
3218 $hidegeneratedfilelistifempty = 0;
3219 }
3220
3221 // Show list of available documents
3222 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
3223 $urlsource .= str_replace('&amp;', '&', $param);
3224
3225 $filedir = $diroutputmassaction;
3226 $genallowed = $permissiontoread;
3227 $delallowed = $permissiontoadd;
3228
3229 print $formfile->showdocuments('massfilesarea_orders', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
3230}
3231
3232// End of page
3233llxFooter();
3234$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition export.php:1216
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
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 absolute discounts.
Class to manage standard extra fields.
Class to manage invoices.
Class to manage invoice lines.
Class to manage forms for categories.
Class to build HTML component for third parties management Only common components are here.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class permettant la generation de composants html autre Only common components are here.
Class permettant la generation de composants html autre Only common components are here.
Class with static methods for building HTML components related to products Only components common to ...
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
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.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
dolPrintLabel($s, $escapeonlyhtmltags=0)
Return a string label (so on 1 line only and that should not contains any HTML) ready to be output on...
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.