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