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