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