dolibarr 20.0.5
list_det.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 Salvador <csalvador@gpcsolutions.fr>
9 * Copyright (C) 2015-2024 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-2021 Ferran Marcet <fmarcet@2byte.es>
13 * Copyright (C) 2018-2023 Charlene Benke <charlene@patas-monkey.com>
14 * Copyright (C) 2021-2023 Anthony Berton <anthony.berton@bb2a.fr>
15 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
16 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 3 of the License, or
21 * (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program. If not, see <https://www.gnu.org/licenses/>.
30 */
31
38require '../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
40require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
41require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
42require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
43require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
44require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
45if (isModEnabled('margin')) {
46 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php';
47}
48require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
49require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
50require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
51require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
52
53if (isModEnabled('category')) {
54 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
55 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
56}
57
58// Load translation files required by the page
59$langs->loadLangs(array("orders", 'sendings', 'deliveries', 'companies', 'compta', 'bills', 'stocks', 'products'));
60
61$action = GETPOST('action', 'aZ09');
62$massaction = GETPOST('massaction', 'alpha');
63$show_files = GETPOSTINT('show_files');
64$confirm = GETPOST('confirm', 'alpha');
65$toselect = GETPOST('toselect', 'array');
66$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'orderlistdet';
67$optioncss = GETPOST('optioncss', 'alpha');
68
69$productobuy = GETPOST('productobuy', 'alpha');
70$productonly = GETPOST('productonly', 'alpha');
71$disablelinefree = GETPOST('disablelinefree', 'alpha');
72
73$search_datecloture_start = GETPOSTINT('search_datecloture_start');
74if (empty($search_datecloture_start)) {
75 $search_datecloture_start = dol_mktime(0, 0, 0, GETPOSTINT('search_datecloture_startmonth'), GETPOSTINT('search_datecloture_startday'), GETPOSTINT('search_datecloture_startyear'));
76}
77$search_datecloture_end = GETPOSTINT('search_datecloture_end');
78if (empty($search_datecloture_end)) {
79 $search_datecloture_end = dol_mktime(23, 59, 59, GETPOSTINT('search_datecloture_endmonth'), GETPOSTINT('search_datecloture_endday'), GETPOSTINT('search_datecloture_endyear'));
80}
81$search_dateorder_start = dol_mktime(0, 0, 0, GETPOSTINT('search_dateorder_start_month'), GETPOSTINT('search_dateorder_start_day'), GETPOSTINT('search_dateorder_start_year'));
82$search_dateorder_end = dol_mktime(23, 59, 59, GETPOSTINT('search_dateorder_end_month'), GETPOSTINT('search_dateorder_end_day'), GETPOSTINT('search_dateorder_end_year'));
83$search_datedelivery_start = dol_mktime(0, 0, 0, GETPOSTINT('search_datedelivery_start_month'), GETPOSTINT('search_datedelivery_start_day'), GETPOSTINT('search_datedelivery_start_year'));
84$search_datedelivery_end = dol_mktime(23, 59, 59, GETPOSTINT('search_datedelivery_end_month'), GETPOSTINT('search_datedelivery_end_day'), GETPOSTINT('search_datedelivery_end_year'));
85
86if (isModEnabled('category')) {
87 $search_product_category_array = GETPOST("search_category_".Categorie::TYPE_PRODUCT."_list", "array");
88 $searchCategoryProductOperator = 0;
89 if (GETPOSTISSET('formfilteraction')) {
90 $searchCategoryProductOperator = GETPOSTINT('search_category_product_operator');
91 } elseif (getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT')) {
92 $searchCategoryProductOperator = getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT');
93 }
94}
95
96$socid = GETPOSTINT('socid');
97
98// Search filters
99$search_id = GETPOST('search_id', 'alpha');
100$search_refProduct = GETPOST('search_refProduct', 'alpha');
101$search_descProduct = GETPOST('search_descProduct', 'alpha');
102
103$search_ref = GETPOST('search_ref', 'alpha') != '' ? GETPOST('search_ref', 'alpha') : GETPOST('sref', 'alpha');
104$search_ref_customer = GETPOST('search_ref_customer', 'alpha');
105$search_company = GETPOST('search_company', 'alpha');
106$search_company_alias = GETPOST('search_company_alias', 'alpha');
107$search_town = GETPOST('search_town', 'alpha');
108$search_zip = GETPOST('search_zip', 'alpha');
109$search_state = GETPOST("search_state", 'alpha');
110$search_country = GETPOST("search_country", 'aZ09');
111$search_type_thirdparty = GETPOST("search_type_thirdparty", 'intcomma');
112$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
113$search_user = GETPOST('search_user', 'intcomma');
114$search_sale = GETPOST('search_sale', 'intcomma');
115$search_total_ht = GETPOST('search_total_ht', 'alpha');
116$search_total_vat = GETPOST('search_total_vat', 'alpha');
117$search_total_ttc = GETPOST('search_total_ttc', 'alpha');
118$search_warehouse = GETPOST('search_warehouse', 'intcomma');
119$search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
120$search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
121$search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
122$search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha');
123$search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
124$search_login = GETPOST('search_login', 'alpha');
125$search_categ_cus = GETPOST("search_categ_cus", 'intcomma');
126$search_billed = GETPOST('search_billed', 'intcomma') ? GETPOST('search_billed', 'intcomma') : GETPOST('billed', 'intcomma');
127$search_status = GETPOST('search_status', 'intcomma');
128$search_project_ref = GETPOST('search_project_ref', 'alpha');
129$search_project = GETPOST('search_project', 'alpha');
130$search_shippable = GETPOST('search_shippable', 'aZ09');
131$search_fk_cond_reglement = GETPOSTINT("search_fk_cond_reglement");
132$search_fk_shipping_method = GETPOSTINT("search_fk_shipping_method");
133$search_fk_mode_reglement = GETPOSTINT("search_fk_mode_reglement");
134$search_fk_input_reason = GETPOSTINT("search_fk_input_reason");
135
136$diroutputmassaction = $conf->commande->multidir_output[$conf->entity].'/temp/massgeneration/'.$user->id;
137
138// Load variable for pagination
139$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
140$sortfield = GETPOST('sortfield', 'aZ09comma');
141$sortorder = GETPOST('sortorder', 'aZ09comma');
142$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
143if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
144 $page = 0;
145} // If $page is not defined, or '' or -1 or if we click on clear filters
146$offset = $limit * $page;
147$pageprev = $page - 1;
148$pagenext = $page + 1;
149if (!$sortfield) {
150 $sortfield = 'pr.ref';
151}
152if (!$sortorder) {
153 $sortorder = 'ASC';
154}
155
156$show_shippable_command = GETPOST('show_shippable_command', 'aZ09');
157
158// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
159$object = new Commande($db);
160$hookmanager->initHooks(array('orderlistdetail'));
161$extrafields = new ExtraFields($db);
162
163// fetch optionals attributes and labels
164$extrafields->fetch_name_optionals_label($object->table_element);
165$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
166
167// List of fields to search into when doing a "search in all"
168$fieldstosearchall = array(
169 'c.ref' => 'Ref',
170 'c.ref_client' => 'RefCustomerOrder',
171 'cdet.description' => 'Description',
172 's.nom' => "ThirdParty",
173 's.name_alias' => "AliasNameShort",
174 's.zip' => "Zip",
175 's.town' => "Town",
176 'c.note_public' => 'NotePublic',
177);
178if (empty($user->socid)) {
179 $fieldstosearchall["c.note_private"] = "NotePrivate";
180}
181
182$checkedtypetiers = 0;
183$arrayfields = array(
184 // Détail commande
185 'rowid' => array('label' => 'TechnicalID', 'checked' => 1, 'position' => 1, 'enabled' => (getDolGlobalInt('MAIN_SHOW_TECHNICAL_ID') ? 1 : 0)),
186 'pr.ref' => array('label' => 'ProductRef', 'checked' => 1, 'position' => 1),
187 'pr.desc' => array('label' => 'ProductDescription', 'checked' => -1, 'position' => 1),
188 'cdet.qty' => array('label' => 'QtyOrdered', 'checked' => 1, 'position' => 1),
189 'c.ref' => array('label' => "Ref", 'checked' => 1, 'position' => 5),
190 'c.ref_client' => array('label' => "RefCustomerOrder", 'checked' => -1, 'position' => 10),
191 'p.ref' => array('label' => "ProjectRef", 'checked' => -1, 'enabled' => (empty($conf->project->enabled) ? 0 : 1), 'position' => 20),
192 'p.title' => array('label' => "ProjectLabel", 'checked' => 0, 'enabled' => (empty($conf->project->enabled) ? 0 : 1), 'position' => 25),
193 's.nom' => array('label' => "ThirdParty", 'checked' => 1, 'position' => 30),
194 's.name_alias' => array('label' => "AliasNameShort", 'checked' => -1, 'position' => 31),
195 's.town' => array('label' => "Town", 'checked' => -1, 'position' => 35),
196 's.zip' => array('label' => "Zip", 'checked' => -1, 'position' => 40),
197 'state.nom' => array('label' => "StateShort", 'checked' => 0, 'position' => 45),
198 'country.code_iso' => array('label' => "Country", 'checked' => 0, 'position' => 50),
199 'typent.code' => array('label' => "ThirdPartyType", 'checked' => $checkedtypetiers, 'position' => 55),
200 'c.date_commande' => array('label' => "OrderDateShort", 'checked' => 1, 'position' => 60),
201 'c.date_delivery' => array('label' => "DateDeliveryPlanned", 'checked' => 1, 'enabled' => !getDolGlobalString('ORDER_DISABLE_DELIVERY_DATE'), 'position' => 65),
202 'c.fk_shipping_method' => array('label' => "SendingMethod", 'checked' => -1, 'position' => 66 , 'enabled' => isModEnabled('shipping')),
203 'c.fk_cond_reglement' => array('label' => "PaymentConditionsShort", 'checked' => -1, 'position' => 67),
204 'c.fk_mode_reglement' => array('label' => "PaymentMode", 'checked' => -1, 'position' => 68),
205 'c.fk_input_reason' => array('label' => "Channel", 'checked' => -1, 'position' => 69),
206 'cdet.total_ht' => array('label' => "AmountHT", 'checked' => 1, 'position' => 75),
207 'c.total_vat' => array('label' => "AmountVAT", 'checked' => 0, 'position' => 80),
208 'cdet.total_ttc' => array('label' => "AmountTTC", 'checked' => 0, 'position' => 85),
209 'c.multicurrency_code' => array('label' => 'Currency', 'checked' => 0, 'enabled' => (empty($conf->multicurrency->enabled) ? 0 : 1), 'position' => 90),
210 'c.multicurrency_tx' => array('label' => 'CurrencyRate', 'checked' => 0, 'enabled' => (empty($conf->multicurrency->enabled) ? 0 : 1), 'position' => 95),
211 'c.multicurrency_total_ht' => array('label' => 'MulticurrencyAmountHT', 'checked' => 0, 'enabled' => (empty($conf->multicurrency->enabled) ? 0 : 1), 'position' => 100),
212 'c.multicurrency_total_vat' => array('label' => 'MulticurrencyAmountVAT', 'checked' => 0, 'enabled' => (empty($conf->multicurrency->enabled) ? 0 : 1), 'position' => 105),
213 'c.multicurrency_total_ttc' => array('label' => 'MulticurrencyAmountTTC', 'checked' => 0, 'enabled' => (empty($conf->multicurrency->enabled) ? 0 : 1), 'position' => 110),
214 'c.fk_warehouse' => array('label' => 'Warehouse', 'checked' => 0, 'enabled' => (!isModEnabled('stock') && !getDolGlobalString('WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER') ? 0 : 1), 'position' => 110),
215 'u.login' => array('label' => "Author", 'checked' => 1, 'position' => 115),
216 'sale_representative' => array('label' => "SaleRepresentativesOfThirdParty", 'checked' => 0, 'position' => 116),
217 'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') ? 0 : 1)),
218 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') ? 0 : 1)),
219 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') || !getDolGlobalString('DISPLAY_MARGIN_RATES') ? 0 : 1)),
220 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') || !getDolGlobalString('DISPLAY_MARK_RATES') ? 0 : 1)),
221 'c.datec' => array('label' => "DateCreation", 'checked' => 0, 'position' => 120),
222 'c.tms' => array('label' => "DateModificationShort", 'checked' => 0, 'position' => 125),
223 'c.date_cloture' => array('label' => "DateClosing", 'checked' => 0, 'position' => 130),
224 'c.note_public' => array('label' => 'NotePublic', 'checked' => 0, 'enabled' => (!getDolGlobalString('MAIN_LIST_ALLOW_PUBLIC_NOTES')), 'position' => 135),
225 'c.note_private' => array('label' => 'NotePrivate', 'checked' => 0, 'enabled' => (!getDolGlobalString('MAIN_LIST_ALLOW_PRIVATE_NOTES')), 'position' => 140),
226 'shippable' => array('label' => "Shippable", 'checked' => 1,'enabled' => (isModEnabled('shipping')), 'position' => 990),
227 'c.facture' => array('label' => "Billed", 'checked' => 1, 'enabled' => (!getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT')), 'position' => 995),
228 'c.import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -2, 'position' => 999),
229 'c.fk_statut' => array('label' => "Status", 'checked' => 1, 'position' => 1000)
230);
231
232// Extra fields
233include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
234
235$object->fields = dol_sort_array($object->fields, 'position');
236$arrayfields = dol_sort_array($arrayfields, 'position');
237'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
238
239if (!$user->hasRight('societe', 'client', 'voir')) {
240 $search_sale = $user->id;
241}
242
243// Security check
244$id = (GETPOST('orderid') ? GETPOSTINT('orderid') : GETPOSTINT('id'));
245if ($user->socid) {
246 $socid = $user->socid;
247}
248$result = restrictedArea($user, 'commande', $id, '');
249
250
251/*
252 * Actions
253 */
254
255if (GETPOST('cancel', 'alpha')) {
256 $action = 'list';
257 $massaction = '';
258}
259if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') {
260 $massaction = '';
261}
262
263$parameters = array('socid' => $socid);
264$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
265if ($reshook < 0) {
266 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
267}
268
269if (empty($reshook)) {
270 // Selection of new fields
271 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
272
273 // Purge search criteria
274 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
275 $productobuy = '';
276 $productonly = '';
277 $disablelinefree = '';
278 $search_categ = '';
279 $search_user = '';
280 $search_sale = '';
281 $search_product_category_array = array();
282 $searchCategoryProductOperator = 0;
283 $search_id = '';
284 $search_refProduct = '';
285 $search_descProduct = '';
286 $search_ref = '';
287 $search_ref_customer = '';
288 $search_company = '';
289 $search_company_alias = '';
290 $search_town = '';
291 $search_zip = "";
292 $search_state = "";
293 $search_type = '';
294 $search_country = '';
295 $search_type_thirdparty = '';
296 $search_total_ht = '';
297 $search_total_vat = '';
298 $search_total_ttc = '';
299 $search_warehouse = '';
300 $search_multicurrency_code = '';
301 $search_multicurrency_tx = '';
302 $search_multicurrency_montant_ht = '';
303 $search_multicurrency_montant_vat = '';
304 $search_multicurrency_montant_ttc = '';
305 $search_login = '';
306 $search_dateorder_start = '';
307 $search_dateorder_end = '';
308 $search_datedelivery_start = '';
309 $search_datedelivery_end = '';
310 $search_project_ref = '';
311 $search_project = '';
312 $search_status = '';
313 $search_billed = '';
314 $toselect = array();
315 $search_array_options = array();
316 $search_categ_cus = 0;
317 $search_datecloture_start = '';
318 $search_datecloture_end = '';
319 $search_fk_cond_reglement = '';
320 $search_fk_shipping_method = '';
321 $search_fk_mode_reglement = '';
322 $search_fk_input_reason = '';
323 }
324 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
325 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
326 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
327 }
328
329 // Mass actions
330 $objectclass = 'Commande';
331 $objectlabel = 'Orders';
332 $permissiontoread = $user->hasRight("commande", "lire");
333 $permissiontoadd = $user->hasRight("commande", "creer");
334 $permissiontodelete = $user->hasRight("commande", "supprimer");
335 $permissiontoexport = $user->hasRight("commande", "commande", "export");
336 if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
337 $permissiontovalidate = $user->hasRight("commande", "order_advance", "validate");
338 $permissiontoclose = $user->hasRight("commande", "order_advance", "close");
339 $permissiontocancel = $user->hasRight("commande", "order_advance", "annuler");
340 $permissiontosendbymail = $user->hasRight("commande", "order_advance", "send");
341 } else {
342 $permissiontovalidate = $user->hasRight("commande", "creer");
343 $permissiontoclose = $user->hasRight("commande", "creer");
344 $permissiontocancel = $user->hasRight("commande", "creer");
345 $permissiontosendbymail = $user->hasRight("commande", "creer");
346 }
347 $uploaddir = $conf->commande->multidir_output[$conf->entity];
348 $triggersendname = 'ORDER_SENTBYMAIL';
349 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
350}
351
352// Closed records
353// if (!$error && $massaction === 'setbilled' && $permissiontoclose) {
354
355// }
356
357/*
358 * View
359 */
360
361$now = dol_now();
362
363$form = new Form($db);
364$formother = new FormOther($db);
365$formfile = new FormFile($db);
366$formmargin = null;
367if (isModEnabled('margin')) {
368 $formmargin = new FormMargin($db);
369}
370$companystatic = new Societe($db);
371$formcompany = new FormCompany($db);
372$projectstatic = new Project($db);
373
374$title = $langs->trans("Orders");
375$help_url = "EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
376// llxHeader('',$title,$help_url);
377
378$sql = 'SELECT';
379if ($search_all || $search_product_category_array > 0 || $search_user > 0) {
380 $sql = 'SELECT DISTINCT';
381}
382$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.code_client,';
383$sql .= " typent.code as typent_code,";
384$sql .= " state.code_departement as state_code, state.nom as state_name,";
385$sql .= " country.code as country_code,";
386$sql .= ' c.rowid as c_rowid, c.ref, c.ref_client, c.fk_user_author,';
387$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,';
388$sql .= ' c.total_ht as c_total_ht, c.total_tva as c_total_tva, c.total_ttc as c_total_ttc, c.fk_warehouse as warehouse,';
389$sql .= ' c.date_valid, c.date_commande, c.note_public, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,';
390$sql .= ' c.date_creation as date_creation, c.tms as date_modification, c.date_cloture as date_cloture,';
391$sql .= ' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
392$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,';
393$sql .= ' c.fk_cond_reglement,c.deposit_percent,c.fk_mode_reglement,c.fk_shipping_method,';
394$sql .= ' c.fk_input_reason, c.import_key,';
395// Lines or order
396$sql .= ' cdet.rowid, cdet.description, cdet.qty, cdet.product_type, cdet.fk_product, cdet.total_ht, cdet.total_tva, cdet.total_ttc,';
397$sql .= ' pr.rowid as product_rowid, pr.ref as product_ref, pr.label as product_label, pr.barcode as product_barcode, pr.tobatch as product_batch, pr.tosell as product_status, pr.tobuy as product_status_buy';
398
399if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
400 $sql .= ", cc.fk_categorie, cc.fk_soc";
401}
402// Add fields from extrafields
403if (!empty($extrafields->attributes[$object->table_element]['label'])) {
404 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
405 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
406 }
407}
408// Add fields from hooks
409$parameters = array();
410$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
411$sql .= $hookmanager->resPrint;
412$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
413$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
414$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
415$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
416if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
417 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ
418}
419
420// Détail commande
421$sql .= ', '.MAIN_DB_PREFIX.'commandedet as cdet';
422$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande as c ON cdet.fk_commande=c.rowid';
423$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as pr ON pr.rowid=cdet.fk_product';
424
425if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
426 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields as ef on (c.rowid = ef.fk_object)";
427}
428$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = c.fk_projet";
429$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON c.fk_user_author = u.rowid';
430if ($search_user > 0) {
431 $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
432 $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
433}
434// Add table from hooks
435$parameters = array();
436$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
437$sql .= $hookmanager->resPrint;
438
439$sql .= ' WHERE c.fk_soc = s.rowid';
440$sql .= ' AND c.entity IN ('.getEntity('commande').')';
441$sql .= ' AND cdet.product_type <> 9';
442
443if (!empty($productobuy)) {
444 $sql .= " AND pr.tobuy = 1";
445}
446if (!empty($productonly)) {
447 $sql .= " AND (cdet.product_type = 0 OR cdet.product_type = 1)";
448}
449if (!empty($disablelinefree)) {
450 $sql .= " AND cdet.fk_product IS NOT NULL";
451}
452if ($socid > 0) {
453 $sql .= ' AND s.rowid = '.((int) $socid);
454}
455if ($search_id) {
456 $sql .= natural_search('cdet.rowid', $search_id);
457}
458if ($search_refProduct) {
459 $sql .= natural_search('pr.ref', $search_refProduct);
460}
461if ($search_descProduct) {
462 $sql .= natural_search(array('pr.label','cdet.description'), $search_descProduct);
463}
464if ($search_ref) {
465 $sql .= natural_search('c.ref', $search_ref);
466}
467if ($search_ref_customer) {
468 $sql .= natural_search('c.ref_client', $search_ref_customer);
469}
470if ($search_all) {
471 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
472}
473if ($search_billed != '' && $search_billed >= 0) {
474 $sql .= ' AND c.facture = '.((int) $search_billed);
475}
476if ($search_status != '') {
477 if ($search_status <= 3 && $search_status >= -1) { // status from -1 to 3 are real status (other are virtual combination)
478 if ($search_status == 1 && !isModEnabled('shipping')) {
479 $sql .= ' AND c.fk_statut IN (1,2)'; // If module expedition disabled, we include order with status "sent" into "validated"
480 } else {
481 $sql .= ' AND c.fk_statut = '.((int) $search_status); // draft, validated, in process or canceled
482 }
483 }
484 if ($search_status == -2) { // "validated + in progress"
485 //$sql.= ' AND c.fk_statut IN (1,2,3) AND c.facture = 0';
486 $sql .= " AND c.fk_statut IN (1,2)";
487 }
488 if ($search_status == -3) { // "validated + in progress + shipped"
489 //$sql.= ' AND c.fk_statut in (1,2,3)';
490 //$sql.= ' AND c.facture = 0'; // invoice not created
491 $sql .= ' AND c.fk_statut IN (1,2,3)'; // validated, in process or closed
492 }
493}
494
495if ($search_datecloture_start) {
496 $sql .= " AND c.date_cloture >= '".$db->idate($search_datecloture_start)."'";
497}
498if ($search_datecloture_end) {
499 $sql .= " AND c.date_cloture <= '".$db->idate($search_datecloture_end)."'";
500}
501if ($search_dateorder_start) {
502 $sql .= " AND c.date_commande >= '".$db->idate($search_dateorder_start)."'";
503}
504if ($search_dateorder_end) {
505 $sql .= " AND c.date_commande <= '".$db->idate($search_dateorder_end)."'";
506}
507if ($search_datedelivery_start) {
508 $sql .= " AND c.date_livraison >= '".$db->idate($search_datedelivery_start)."'";
509}
510if ($search_datedelivery_end) {
511 $sql .= " AND c.date_livraison <= '".$db->idate($search_datedelivery_end)."'";
512}
513if ($search_town) {
514 $sql .= natural_search('s.town', $search_town);
515}
516if ($search_zip) {
517 $sql .= natural_search("s.zip", $search_zip);
518}
519if ($search_state) {
520 $sql .= natural_search("state.nom", $search_state);
521}
522if ($search_country) {
523 $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
524}
525if ($search_type_thirdparty && $search_type_thirdparty != '-1') {
526 $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')';
527}
528if ($search_company) {
529 $sql .= natural_search('s.nom', $search_company);
530}
531if ($search_company_alias) {
532 $sql .= natural_search('s.name_alias', $search_company_alias);
533}
534if ($search_user > 0) {
535 $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".((int) $search_user);
536}
537if ($search_total_ht != '') {
538 $sql .= natural_search('cdet.total_ht', $search_total_ht, 1);
539}
540if ($search_total_vat != '') {
541 $sql .= natural_search('cdet.total_tva', $search_total_vat, 1);
542}
543if ($search_total_ttc != '') {
544 $sql .= natural_search('cdet.total_ttc', $search_total_ttc, 1);
545}
546if ($search_warehouse != '' && $search_warehouse > 0) {
547 $sql .= natural_search('c.fk_warehouse', $search_warehouse, 1);
548}
549if ($search_multicurrency_code != '') {
550 $sql .= " AND c.multicurrency_code = '".$db->escape($search_multicurrency_code)."'";
551}
552if ($search_multicurrency_tx != '') {
553 $sql .= natural_search('c.multicurrency_tx', $search_multicurrency_tx, 1);
554}
555if ($search_multicurrency_montant_ht != '') {
556 $sql .= natural_search('c.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
557}
558if ($search_multicurrency_montant_vat != '') {
559 $sql .= natural_search('c.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
560}
561if ($search_multicurrency_montant_ttc != '') {
562 $sql .= natural_search('c.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
563}
564if ($search_login) {
565 $sql .= natural_search(array("u.login", "u.firstname", "u.lastname"), $search_login);
566}
567if ($search_project_ref != '') {
568 $sql .= natural_search("p.ref", $search_project_ref);
569}
570if ($search_project != '') {
571 $sql .= natural_search("p.title", $search_project);
572}
573if ($search_categ_cus > 0) {
574 $sql .= " AND cc.fk_categorie = ".((int) $search_categ_cus);
575}
576if ($search_categ_cus == -2) {
577 $sql .= " AND cc.fk_categorie IS NULL";
578}
579if ($search_fk_cond_reglement > 0) {
580 $sql .= " AND c.fk_cond_reglement = ".((int) $search_fk_cond_reglement);
581}
582if ($search_fk_shipping_method > 0) {
583 $sql .= " AND c.fk_shipping_method = ".((int) $search_fk_shipping_method);
584}
585if ($search_fk_mode_reglement > 0) {
586 $sql .= " AND c.fk_mode_reglement = ".((int) $search_fk_mode_reglement);
587}
588if ($search_fk_input_reason > 0) {
589 $sql .= " AND c.fk_input_reason = ".((int) $search_fk_input_reason);
590}
591// Search on sale representative
592if ($search_sale && $search_sale != '-1') {
593 if ($search_sale == -2) {
594 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc)";
595 } elseif ($search_sale > 0) {
596 $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).")";
597 }
598}
599// Search for tag/category ($searchCategoryProductList is an array of ID)
600$searchCategoryProductList = $search_product_category_array;
601if (!empty($searchCategoryProductList)) {
602 $searchCategoryProjectSqlList = array();
603 $listofcategoryid = '';
604 foreach ($searchCategoryProductList as $searchCategoryProject) {
605 if (intval($searchCategoryProject) == -2) {
606 $searchCategoryProjectSqlList[] = "NOT EXISTS (SELECT cp.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as cp WHERE cdet.fk_product = cp.fk_product)";
607 } elseif (intval($searchCategoryProject) > 0) {
608 if ($searchCategoryProductOperator == 0) {
609 $searchCategoryProjectSqlList[] = " EXISTS (SELECT cp.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as cp WHERE cdet.fk_product = cp.fk_product AND cp.fk_categorie = ".((int) $searchCategoryProject).")";
610 } else {
611 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProject);
612 }
613 }
614 }
615 if ($listofcategoryid) {
616 $searchCategoryProjectSqlList[] = " EXISTS (SELECT cp.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as cp WHERE cdet.fk_product = cp.fk_product AND cp.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
617 }
618 if ($searchCategoryProductOperator == 1) {
619 if (!empty($searchCategoryProjectSqlList)) {
620 $sql .= " AND (".implode(' OR ', $searchCategoryProjectSqlList).")";
621 }
622 } else {
623 if (!empty($searchCategoryProjectSqlList)) {
624 $sql .= " AND (".implode(' AND ', $searchCategoryProjectSqlList).")";
625 }
626 }
627}
628
629// Add where from extra fields
630include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
631
632// Add where from hooks
633$parameters = array();
634$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
635$sql .= $hookmanager->resPrint;
636
637// Add HAVING from hooks
638$parameters = array();
639$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook
640$sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
641
642$sql .= $db->order($sortfield, $sortorder);
643
644// Count total nb of records
645$nbtotalofrecords = '';
646if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
647 $result = $db->query($sql);
648 $nbtotalofrecords = $db->num_rows($result);
649
650 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
651 $page = 0;
652 $offset = 0;
653 }
654}
655
656$sql .= $db->plimit($limit + 1, $offset);
657//print $sql;
658
659$resql = $db->query($sql);
660if ($resql) {
661 if ($socid > 0) {
662 $soc = new Societe($db);
663 $soc->fetch($socid);
664 $title = $langs->trans('ListOrderLigne').' - '.$soc->name;
665 if (empty($search_company)) {
666 $search_company = $soc->name;
667 }
668 } else {
669 $title = $langs->trans('ListOrderLigne');
670 }
671 if (strval($search_status) == '0') {
672 $title .= ' - '.$langs->trans('StatusOrderDraftShort');
673 }
674 if ($search_status == 1) {
675 $title .= ' - '.$langs->trans('StatusOrderValidatedShort');
676 }
677 if ($search_status == 2) {
678 $title .= ' - '.$langs->trans('StatusOrderSentShort');
679 }
680 if ($search_status == 3) {
681 $title .= ' - '.$langs->trans('StatusOrderToBillShort');
682 }
683 if ($search_status == -1) {
684 $title .= ' - '.$langs->trans('StatusOrderCanceledShort');
685 }
686 if ($search_status == -2) {
687 $title .= ' - '.$langs->trans('StatusOrderToProcessShort');
688 }
689 if ($search_status == -3) {
690 $title .= ' - '.$langs->trans('StatusOrderValidated').', '.(!isModEnabled('shipping') ? '' : $langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill');
691 }
692
693 $num = $db->num_rows($resql);
694
695 $arrayofselected = is_array($toselect) ? $toselect : array();
696
697 if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) {
698 $obj = $db->fetch_object($resql);
699 $id = $obj->rowid;
700 header("Location: ".DOL_URL_ROOT.'/commande/card.php?id='.$id);
701 exit;
702 }
703
704 llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-commande page-list_det');
705
706 $param = '';
707
708 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
709 $param .= '&contextpage='.urlencode($contextpage);
710 }
711 if ($limit > 0 && $limit != $conf->liste_limit) {
712 $param .= '&limit='.((int) $limit);
713 }
714 if ($search_all) {
715 $param .= '&search_all='.urlencode($search_all);
716 }
717 if ($socid > 0) {
718 $param .= '&socid='.urlencode((string) ($socid));
719 }
720 if ($search_id) {
721 $param .= '&search_id='.urlencode($search_id);
722 }
723 // Détail commande
724 if ($search_refProduct) {
725 $param .= '&search_refProduct='.urlencode($search_refProduct);
726 }
727 if ($search_descProduct) {
728 $param .= '&search_descProduct='.urlencode($search_descProduct);
729 }
730 if ($search_status != '') {
731 $param .= '&search_status='.urlencode($search_status);
732 }
733 if ($search_datecloture_start) {
734 $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');
735 }
736 if ($search_datecloture_end) {
737 $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');
738 }
739 if ($search_dateorder_start) {
740 $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');
741 }
742 if ($search_dateorder_end) {
743 $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');
744 }
745 if ($search_datedelivery_start) {
746 $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');
747 }
748 if ($search_datedelivery_end) {
749 $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');
750 }
751 if ($search_ref) {
752 $param .= '&search_ref='.urlencode($search_ref);
753 }
754 if ($search_company) {
755 $param .= '&search_company='.urlencode($search_company);
756 }
757 if ($search_company_alias) {
758 $param .= '&search_company_alias='.urlencode($search_company_alias);
759 }
760 if ($search_ref_customer) {
761 $param .= '&search_ref_customer='.urlencode($search_ref_customer);
762 }
763 if ($search_user > 0) {
764 $param .= '&search_user='.urlencode((string) ($search_user));
765 }
766 if ($search_sale > 0) {
767 $param .= '&search_sale='.urlencode($search_sale);
768 }
769 if ($search_total_ht != '') {
770 $param .= '&search_total_ht='.urlencode($search_total_ht);
771 }
772 if ($search_total_vat != '') {
773 $param .= '&search_total_vat='.urlencode($search_total_vat);
774 }
775 if ($search_total_ttc != '') {
776 $param .= '&search_total_ttc='.urlencode($search_total_ttc);
777 }
778 if ($search_warehouse != '') {
779 $param .= '&search_warehouse='.urlencode((string) ($search_warehouse));
780 }
781 if ($search_login) {
782 $param .= '&search_login='.urlencode($search_login);
783 }
784 if ($search_multicurrency_code != '') {
785 $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
786 }
787 if ($search_multicurrency_tx != '') {
788 $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
789 }
790 if ($search_multicurrency_montant_ht != '') {
791 $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
792 }
793 if ($search_multicurrency_montant_vat != '') {
794 $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
795 }
796 if ($search_multicurrency_montant_ttc != '') {
797 $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
798 }
799 if ($search_project_ref >= 0) {
800 $param .= "&search_project_ref=".urlencode($search_project_ref);
801 }
802 if ($search_town != '') {
803 $param .= '&search_town='.urlencode($search_town);
804 }
805 if ($search_zip != '') {
806 $param .= '&search_zip='.urlencode($search_zip);
807 }
808 if ($search_state != '') {
809 $param .= '&search_state='.urlencode($search_state);
810 }
811 if ($search_country != '') {
812 $param .= '&search_country='.urlencode((string) ($search_country));
813 }
814 if ($search_type_thirdparty && $search_type_thirdparty != '-1') {
815 $param .= '&search_type_thirdparty='.urlencode((string) ($search_type_thirdparty));
816 }
817 if (!empty($search_product_category_array)) {
818 foreach ($search_product_category_array as $tmpval) {
819 $param .= '&search_categegory_product_list[]='.urlencode($tmpval);
820 }
821 }
822 if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
823 $param .= '&search_categ_cus='.urlencode((string) ($search_categ_cus));
824 }
825 if ($show_files) {
826 $param .= '&show_files='.urlencode((string) ($show_files));
827 }
828 if ($optioncss != '') {
829 $param .= '&optioncss='.urlencode($optioncss);
830 }
831 if ($search_billed != '') {
832 $param .= '&search_billed='.urlencode($search_billed);
833 }
834 if ($search_fk_cond_reglement > 0) {
835 $param .= '&search_fk_cond_reglement='.urlencode((string) ($search_fk_cond_reglement));
836 }
837 if ($search_fk_shipping_method > 0) {
838 $param .= '&search_fk_shipping_method='.urlencode((string) ($search_fk_shipping_method));
839 }
840 if ($search_fk_mode_reglement > 0) {
841 $param .= '&search_fk_mode_reglement='.urlencode((string) ($search_fk_mode_reglement));
842 }
843 if ($search_fk_input_reason > 0) {
844 $param .= '&search_fk_input_reason='.urlencode((string) ($search_fk_input_reason));
845 }
846 if (!empty($productobuy)) {
847 $param .= '&productobuy='.urlencode($productobuy);
848 }
849 if (!empty($productonly)) {
850 $param .= '&productonly='.urlencode($productonly);
851 }
852 if (!empty($disablelinefree)) {
853 $param .= '&disablelinefree='.urlencode($disablelinefree);
854 }
855
856 // Add $param from extra fields
857 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
858
859 // Add $param from hooks
860 $parameters = array('param' => &$param);
861 $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
862 $param .= $hookmanager->resPrint;
863
864 // List of mass actions available
865 $arrayofmassactions = array(
866 // TODO add mass action here
867 // 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
868 );
869 // if ($permissiontovalidate) {
870 // $arrayofmassactions['prevalidate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate");
871 // }
872 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
873
874 $url = DOL_URL_ROOT.'/commande/card.php?action=create';
875 if (!empty($socid)) {
876 $url .= '&socid='.$socid;
877 }
878 $newcardbutton = '';//dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', $url, '', $contextpage == 'orderlistdet' && $permissiontoadd);
879
880 // Lines of title fields
881 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
882 if ($optioncss != '') {
883 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
884 }
885 print '<input type="hidden" name="token" value="'.newToken().'">';
886 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
887 print '<input type="hidden" name="action" value="list">';
888 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
889 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
890 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
891 print '<input type="hidden" name="search_status" value="'.$search_status.'">';
892 print '<input type="hidden" name="socid" value="'.$socid.'">';
893
894 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'order', 0, $newcardbutton, '', $limit, 0, 0, 1);
895
896 $topicmail = "SendOrderRef";
897 $modelmail = "order_send";
898 $objecttmp = new Commande($db);
899 $trackid = 'ord'.$object->id;
900 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
901
902 if ($search_all) {
903 foreach ($fieldstosearchall as $key => $val) {
904 $fieldstosearchall[$key] = $langs->trans($val);
905 }
906 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
907 }
908
909 $moreforfilter = '';
910
911 $moreforfilter .= '<div class="divsearchfield">';
912 $moreforfilter .= '<input type="checkbox" id="productobuy" name="productobuy"'.(!empty($productobuy) ? 'value="productobuychecked" checked' : '').'><label for="productobuy">'.$langs->trans("productobuy").'</label>';
913 $moreforfilter .= '</div>';
914 $moreforfilter .= '<div class="divsearchfield">';
915 $moreforfilter .= '<input type="checkbox" id="productonly" name="productonly"'.(!empty($productonly) ? 'value="productonlychecked" checked' : '').'><label for="productonly">'.$langs->trans("productonly").'</label>';
916 $moreforfilter .= '</div>';
917 $moreforfilter .= '<div class="divsearchfield">';
918 $moreforfilter .= '<input type="checkbox" id="disablelinefree" name="disablelinefree"'.(!empty($disablelinefree) ? 'value="disablelinefreechecked" checked' : '').'><label for="disablelinefree">'.$langs->trans("disablelinefree").'</label>';
919 $moreforfilter .= '</div><br>';
920
921 // If the user can view prospects other than his'
922 if ($user->hasRight('user', 'user', 'lire')) {
923 $langs->load("commercial");
924 $moreforfilter .= '<div class="divsearchfield">';
925 $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
926 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx');
927 $moreforfilter .= '</div>';
928 }
929 // If the user can view other users
930 if ($user->hasRight('user', 'user', 'lire')) {
931 $moreforfilter .= '<div class="divsearchfield">';
932 $tmptitle = $langs->trans('LinkedToSpecificUsers');
933 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
934 $moreforfilter .= '</div>';
935 }
936 // Filter on categories
937 if (isModEnabled("category") && $user->hasRight('categorie', 'lire') && ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire'))) {
938 $formcategory = new FormCategory($db);
939 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PRODUCT, $search_product_category_array, 'minwidth300imp minwidth300', $searchCategoryProductOperator ? $searchCategoryProductOperator : 0);
940 }
941 if (isModEnabled("category") && $user->hasRight('categorie', 'lire')) {
942 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
943 $moreforfilter .= '<div class="divsearchfield">';
944 $tmptitle = $langs->trans('CustomersProspectsCategoriesShort');
945 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $tmptitle, 'maxwidth300 widthcentpercentminusx');
946 $moreforfilter .= '</div>';
947 }
948 if (isModEnabled('stock') && getDolGlobalString('WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
949 require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
950 $formproduct = new FormProduct($db);
951 $moreforfilter .= '<div class="divsearchfield">';
952 $tmptitle = $langs->trans('Warehouse');
953 $moreforfilter .= img_picto($tmptitle, 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse, 'search_warehouse', '', 1, 0, 0, $tmptitle, 0, 0, array(), 'maxwidth250 widthcentpercentminusx');
954 $moreforfilter .= '</div>';
955 }
956
957
958 $parameters = array();
959 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
960 if (empty($reshook)) {
961 $moreforfilter .= $hookmanager->resPrint;
962 } else {
963 $moreforfilter = $hookmanager->resPrint;
964 }
965
966 if (!empty($moreforfilter)) {
967 print '<div class="liste_titre liste_titre_bydiv centpercent">';
968 print $moreforfilter;
969 print '</div>';
970 }
971
972 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
973 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
974 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
975
976 if (GETPOSTINT('autoselectall')) {
977 $selectedfields .= '<script>';
978 $selectedfields .= ' $(document).ready(function() {';
979 $selectedfields .= ' console.log("Autoclick on checkforselects");';
980 $selectedfields .= ' $("#checkforselects").click();';
981 $selectedfields .= ' $("#massaction").val("createbills").change();';
982 $selectedfields .= ' });';
983 $selectedfields .= '</script>';
984 }
985
986 print '<div class="div-table-responsive">';
987 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
988
989 print '<tr class="liste_titre_filter">';
990
991 // Action column
992 if (getDolGlobalInt('MAIN_CHECKBOX_LEFT_COLUMN')) {
993 print '<td class="liste_titre" align="middle">';
994 $searchpicto = $form->showFilterButtons('left');
995 print $searchpicto;
996 print '</td>';
997 }
998 // ID
999 if (!empty($arrayfields['rowid']['checked'])) {
1000 print '<td class="liste_titre" data-key="id">';
1001 print '<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dol_escape_htmltag($search_id).'">';
1002 print '</td>';
1003 }
1004 // Détail commande
1005 if (!empty($arrayfields['pr.ref']['checked'])) {
1006 print '<td class="liste_titre">';
1007 print '<input class="flat" size="6" type="text" name="search_refProduct" value="'.dol_escape_htmltag($search_refProduct).'">';
1008 print '</td>';
1009 }
1010 // Product Description
1011 if (!empty($arrayfields['pr.desc']['checked'])) {
1012 print '<td class="liste_titre">';
1013 print '<input class="flat" size="6" type="text" name="search_descProduct" value="'.dol_escape_htmltag($search_descProduct).'">';
1014 print '</td>';
1015 }
1016 // Product QtyOrdered
1017 if (!empty($arrayfields['cdet.qty']['checked'])) {
1018 print '<td class="liste_titre"></td>';
1019 }
1020
1021 // Ref
1022 if (!empty($arrayfields['c.ref']['checked'])) {
1023 print '<td class="liste_titre">';
1024 print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
1025 print '</td>';
1026 }
1027 // Ref customer
1028 if (!empty($arrayfields['c.ref_client']['checked'])) {
1029 print '<td class="liste_titre" align="left">';
1030 print '<input class="flat" type="text" size="6" name="search_ref_customer" value="'.dol_escape_htmltag($search_ref_customer).'">';
1031 print '</td>';
1032 }
1033 // Project ref
1034 if (!empty($arrayfields['p.ref']['checked'])) {
1035 print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>';
1036 }
1037 // Project title
1038 if (!empty($arrayfields['p.title']['checked'])) {
1039 print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project" value="'.dol_escape_htmltag($search_project).'"></td>';
1040 }
1041 // Thirpdarty
1042 if (!empty($arrayfields['s.nom']['checked'])) {
1043 print '<td class="liste_titre" align="left">';
1044 print '<input class="flat maxwidth100" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
1045 print '</td>';
1046 }
1047 // Alias
1048 if (!empty($arrayfields['s.name_alias']['checked'])) {
1049 print '<td class="liste_titre" align="left">';
1050 print '<input class="flat maxwidth100" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).'">';
1051 print '</td>';
1052 }
1053 // Town
1054 if (!empty($arrayfields['s.town']['checked'])) {
1055 print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>';
1056 }
1057 // Zip
1058 if (!empty($arrayfields['s.zip']['checked'])) {
1059 print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>';
1060 }
1061 // State
1062 if (!empty($arrayfields['state.nom']['checked'])) {
1063 print '<td class="liste_titre">';
1064 print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
1065 print '</td>';
1066 }
1067 // Country
1068 if (!empty($arrayfields['country.code_iso']['checked'])) {
1069 print '<td class="liste_titre" align="center">';
1070 print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
1071 print '</td>';
1072 }
1073 // Company type
1074 if (!empty($arrayfields['typent.code']['checked'])) {
1075 print '<td class="liste_titre maxwidthonsmartphone" align="center">';
1076 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);
1077 print '</td>';
1078 }
1079 // Date order
1080 if (!empty($arrayfields['c.date_commande']['checked'])) {
1081 print '<td class="liste_titre center">';
1082 print '<div class="nowrapfordate">';
1083 print $form->selectDate($search_dateorder_start ? $search_dateorder_start : -1, 'search_dateorder_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1084 print '</div>';
1085 print '<div class="nowrapfordate">';
1086 print $form->selectDate($search_dateorder_end ? $search_dateorder_end : -1, 'search_dateorder_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1087 print '</div>';
1088 print '</td>';
1089 }
1090 if (!empty($arrayfields['c.date_delivery']['checked'])) {
1091 print '<td class="liste_titre center">';
1092 print '<div class="nowrapfordate">';
1093 print $form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1, 'search_datedelivery_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1094 print '</div>';
1095 print '<div class="nowrapfordate">';
1096 print $form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1, 'search_datedelivery_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1097 print '</div>';
1098 print '</td>';
1099 }
1100 // Shipping Method
1101 if (!empty($arrayfields['c.fk_shipping_method']['checked'])) {
1102 print '<td class="liste_titre">';
1103 $form->selectShippingMethod($search_fk_shipping_method, 'search_fk_shipping_method', '', 1, '', 1);
1104 print '</td>';
1105 }
1106 // Payment term
1107 if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) {
1108 print '<td class="liste_titre">';
1109 print $form->getSelectConditionsPaiements($search_fk_cond_reglement, 'search_fk_cond_reglement', 1, 1, 1);
1110 print '</td>';
1111 }
1112 // Payment mode
1113 if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) {
1114 print '<td class="liste_titre">';
1115 $form->select_types_paiements($search_fk_mode_reglement, 'search_fk_mode_reglement', '', 0, 1, 1, 0, -1);
1116 print '</td>';
1117 }
1118 // Channel
1119 if (!empty($arrayfields['c.fk_input_reason']['checked'])) {
1120 print '<td class="liste_titre">';
1121 $form->selectInputReason($search_fk_input_reason, 'search_fk_input_reason', '', 1, '', 1);
1122 print '</td>';
1123 }
1124 if (!empty($arrayfields['cdet.total_ht']['checked'])) {
1125 // Amount
1126 print '<td class="liste_titre right">';
1127 print '<input class="flat" type="text" size="4" name="search_total_ht" value="'.dol_escape_htmltag($search_total_ht).'">';
1128 print '</td>';
1129 }
1130 if (!empty($arrayfields['c.total_vat']['checked'])) {
1131 // Amount
1132 print '<td class="liste_titre right">';
1133 print '<input class="flat" type="text" size="4" name="search_total_vat" value="'.dol_escape_htmltag($search_total_vat).'">';
1134 print '</td>';
1135 }
1136 if (!empty($arrayfields['cdet.total_ttc']['checked'])) {
1137 // Amount
1138 print '<td class="liste_titre right">';
1139 print '<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.'">';
1140 print '</td>';
1141 }
1142 if (!empty($arrayfields['c.fk_warehouse']['checked'])) {
1143 // Warehouse
1144 print '<td class="liste_titre right"></td>';
1145 }
1146 if (!empty($arrayfields['c.multicurrency_code']['checked'])) {
1147 // Currency
1148 print '<td class="liste_titre">';
1149 print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
1150 print '</td>';
1151 }
1152 if (!empty($arrayfields['c.multicurrency_tx']['checked'])) {
1153 // Currency rate
1154 print '<td class="liste_titre">';
1155 print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
1156 print '</td>';
1157 }
1158 if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) {
1159 // Amount
1160 print '<td class="liste_titre right">';
1161 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
1162 print '</td>';
1163 }
1164 if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) {
1165 // Amount VAT
1166 print '<td class="liste_titre right">';
1167 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
1168 print '</td>';
1169 }
1170 if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) {
1171 // Amount
1172 print '<td class="liste_titre right">';
1173 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
1174 print '</td>';
1175 }
1176 if (!empty($arrayfields['u.login']['checked'])) {
1177 // Author
1178 print '<td class="liste_titre" align="center">';
1179 print '<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
1180 print '</td>';
1181 }
1182 if (!empty($arrayfields['sale_representative']['checked'])) {
1183 print '<td class="liste_titre"></td>';
1184 }
1185 if (!empty($arrayfields['total_pa']['checked'])) {
1186 print '<td class="liste_titre right">';
1187 print '</td>';
1188 }
1189 if (!empty($arrayfields['total_margin']['checked'])) {
1190 print '<td class="liste_titre right">';
1191 print '</td>';
1192 }
1193 if (!empty($arrayfields['total_margin_rate']['checked'])) {
1194 print '<td class="liste_titre right">';
1195 print '</td>';
1196 }
1197 if (!empty($arrayfields['total_mark_rate']['checked'])) {
1198 print '<td class="liste_titre right">';
1199 print '</td>';
1200 }
1201 // Extra fields
1202 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1203 // Fields from hook
1204 $parameters = array('arrayfields' => $arrayfields);
1205 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
1206 print $hookmanager->resPrint;
1207 // Date creation
1208 if (!empty($arrayfields['c.datec']['checked'])) {
1209 print '<td class="liste_titre">';
1210 print '</td>';
1211 }
1212 // Date modification
1213 if (!empty($arrayfields['c.tms']['checked'])) {
1214 print '<td class="liste_titre">';
1215 print '</td>';
1216 }
1217 // Date cloture
1218 if (!empty($arrayfields['c.date_cloture']['checked'])) {
1219 print '<td class="liste_titre center">';
1220 print '<div class="nowrapfordate">';
1221 print $form->selectDate($search_datecloture_start ? $search_datecloture_start : -1, 'search_datecloture_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1222 print '</div>';
1223 print '<div class="nowrapfordate">';
1224 print $form->selectDate($search_datecloture_end ? $search_datecloture_end : -1, 'search_datecloture_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1225 print '</div>';
1226 print '</td>';
1227 }
1228 // Note public
1229 if (!empty($arrayfields['c.note_public']['checked'])) {
1230 print '<td class="liste_titre">';
1231 print '</td>';
1232 }
1233 // Note private
1234 if (!empty($arrayfields['c.note_private']['checked'])) {
1235 print '<td class="liste_titre">';
1236 print '</td>';
1237 }
1238 // Shippable
1239 if (!empty($arrayfields['shippable']['checked'])) {
1240 print '<td class="liste_titre maxwidthonsmartphone" align="center">';
1241 //print $form->selectyesno('search_shippable', $search_shippable, 1, 0, 1, 1);
1242 if (getDolGlobalString('ORDER_SHIPABLE_STATUS_DISABLED_BY_DEFAULT')) {
1243 print '<input type="checkbox" name="show_shippable_command" value="1"'.($show_shippable_command ? ' checked' : '').'>';
1244 print $langs->trans('ShowShippableStatus');
1245 } else {
1246 $show_shippable_command = 1;
1247 }
1248 print '</td>';
1249 }
1250 // Status billed
1251 if (!empty($arrayfields['c.facture']['checked'])) {
1252 print '<td class="liste_titre maxwidthonsmartphone" align="center">';
1253 print $form->selectyesno('search_billed', $search_billed, 1, 0, 1, 1);
1254 print '</td>';
1255 }
1256 // Import key
1257 if (!empty($arrayfields['c.import_key']['checked'])) {
1258 print '<td class="liste_titre maxwidthonsmartphone" align="center">';
1259 print '</td>';
1260 }
1261 // Status
1262 if (!empty($arrayfields['c.fk_statut']['checked'])) {
1263 print '<td class="liste_titre maxwidthonsmartphone center">';
1264 $liststatus = array(
1265 Commande::STATUS_DRAFT => $langs->trans("StatusOrderDraftShort"),
1266 Commande::STATUS_VALIDATED => $langs->trans("StatusOrderValidated"),
1267 Commande::STATUS_SHIPMENTONPROCESS => $langs->trans("StatusOrderSentShort"),
1268 -2 => $langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"),
1269 -3 => $langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"),
1270 Commande::STATUS_CLOSED => $langs->trans("StatusOrderDelivered"),
1271 Commande::STATUS_CANCELED => $langs->trans("StatusOrderCanceledShort")
1272 );
1273 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1274 print $form->selectarray('search_status', $liststatus, $search_status, -5, 0, 0, '', 0, 0, 0, '', 'maxwidth125', 1);
1275 print '</td>';
1276 }
1277 // Action column
1278 if (!getDolGlobalInt('MAIN_CHECKBOX_LEFT_COLUMN')) {
1279 print '<td class="liste_titre" align="middle">';
1280 $searchpicto = $form->showFilterButtons();
1281 print $searchpicto;
1282 print '</td>';
1283 }
1284 print "</tr>\n";
1285
1286 // Fields title
1287 print '<tr class="liste_titre">';
1288
1289 if (getDolGlobalInt('MAIN_CHECKBOX_LEFT_COLUMN')) {
1290 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center ');
1291 }
1292
1293 // Détail commande
1294 if (!empty($arrayfields['rowid']['checked'])) {
1295 print_liste_field_titre($arrayfields['rowid']['label'], $_SERVER["PHP_SELF"], 'rowid', '', $param, '', $sortfield, $sortorder);
1296 '@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
1297 }
1298 if (!empty($arrayfields['pr.ref']['checked'])) {
1299 print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], 'pr.ref', '', $param, '', $sortfield, $sortorder);
1300 }
1301 if (!empty($arrayfields['pr.desc']['checked'])) {
1302 print_liste_field_titre($arrayfields['pr.desc']['label'], $_SERVER["PHP_SELF"], 'pr.desc', '', $param, '', $sortfield, $sortorder);
1303 }
1304 if (!empty($arrayfields['cdet.qty']['checked'])) {
1305 print_liste_field_titre($arrayfields['cdet.qty']['label'], $_SERVER["PHP_SELF"], 'cdet.qty', '', $param, '', $sortfield, $sortorder);
1306 }
1307
1308 if (!empty($arrayfields['c.ref']['checked'])) {
1309 print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], 'c.ref', '', $param, '', $sortfield, $sortorder);
1310 }
1311 if (!empty($arrayfields['c.ref_client']['checked'])) {
1312 print_liste_field_titre($arrayfields['c.ref_client']['label'], $_SERVER["PHP_SELF"], 'c.ref_client', '', $param, '', $sortfield, $sortorder);
1313 }
1314 if (!empty($arrayfields['p.ref']['checked'])) {
1315 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
1316 }
1317 if (!empty($arrayfields['p.title']['checked'])) {
1318 print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, '', $sortfield, $sortorder);
1319 }
1320 if (!empty($arrayfields['s.nom']['checked'])) {
1321 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
1322 }
1323 if (!empty($arrayfields['s.name_alias']['checked'])) {
1324 print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $param, '', $sortfield, $sortorder);
1325 }
1326 if (!empty($arrayfields['s.town']['checked'])) {
1327 print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
1328 }
1329 if (!empty($arrayfields['s.zip']['checked'])) {
1330 print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
1331 }
1332 if (!empty($arrayfields['state.nom']['checked'])) {
1333 print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
1334 }
1335 if (!empty($arrayfields['country.code_iso']['checked'])) {
1336 print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
1337 }
1338 if (!empty($arrayfields['typent.code']['checked'])) {
1339 print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
1340 }
1341 if (!empty($arrayfields['c.date_commande']['checked'])) {
1342 print_liste_field_titre($arrayfields['c.date_commande']['label'], $_SERVER["PHP_SELF"], 'c.date_commande', '', $param, '', $sortfield, $sortorder, 'center ');
1343 }
1344 if (!empty($arrayfields['c.date_delivery']['checked'])) {
1345 print_liste_field_titre($arrayfields['c.date_delivery']['label'], $_SERVER["PHP_SELF"], 'c.date_livraison', '', $param, '', $sortfield, $sortorder, 'center ');
1346 }
1347 if (!empty($arrayfields['c.fk_shipping_method']['checked'])) {
1348 print_liste_field_titre($arrayfields['c.fk_shipping_method']['label'], $_SERVER["PHP_SELF"], "c.fk_shipping_method", "", $param, '', $sortfield, $sortorder);
1349 }
1350 if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) {
1351 print_liste_field_titre($arrayfields['c.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_cond_reglement", "", $param, '', $sortfield, $sortorder);
1352 }
1353 if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) {
1354 print_liste_field_titre($arrayfields['c.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_mode_reglement", "", $param, '', $sortfield, $sortorder);
1355 }
1356 if (!empty($arrayfields['c.fk_input_reason']['checked'])) {
1357 print_liste_field_titre($arrayfields['c.fk_input_reason']['label'], $_SERVER["PHP_SELF"], "c.fk_input_reason", "", $param, '', $sortfield, $sortorder);
1358 }
1359 if (!empty($arrayfields['cdet.total_ht']['checked'])) {
1360 print_liste_field_titre($arrayfields['cdet.total_ht']['label'], $_SERVER["PHP_SELF"], 'cdet.total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
1361 }
1362 if (!empty($arrayfields['c.total_vat']['checked'])) {
1363 print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'cdet.total_tva', '', $param, '', $sortfield, $sortorder, 'right ');
1364 }
1365 if (!empty($arrayfields['cdet.total_ttc']['checked'])) {
1366 print_liste_field_titre($arrayfields['cdet.total_ttc']['label'], $_SERVER["PHP_SELF"], 'cdet.total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
1367 }
1368 if (!empty($arrayfields['c.fk_warehouse']['checked'])) {
1369 print_liste_field_titre($arrayfields['c.fk_warehouse']['label'], "", '', '', $param, '', $sortfield, $sortorder);
1370 }
1371 if (!empty($arrayfields['c.multicurrency_code']['checked'])) {
1372 print_liste_field_titre($arrayfields['c.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_code', '', $param, '', $sortfield, $sortorder);
1373 }
1374 if (!empty($arrayfields['c.multicurrency_tx']['checked'])) {
1375 print_liste_field_titre($arrayfields['c.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
1376 }
1377 if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) {
1378 print_liste_field_titre($arrayfields['c.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
1379 }
1380 if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) {
1381 print_liste_field_titre($arrayfields['c.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
1382 }
1383 if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) {
1384 print_liste_field_titre($arrayfields['c.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
1385 }
1386 if (!empty($arrayfields['u.login']['checked'])) {
1387 print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder);
1388 }
1389 if (!empty($arrayfields['sale_representative']['checked'])) {
1390 print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder);
1391 }
1392 if (!empty($arrayfields['total_pa']['checked'])) {
1393 print_liste_field_titre($arrayfields['total_pa']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1394 }
1395 if (!empty($arrayfields['total_margin']['checked'])) {
1396 print_liste_field_titre($arrayfields['total_margin']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1397 }
1398 if (!empty($arrayfields['total_margin_rate']['checked'])) {
1399 print_liste_field_titre($arrayfields['total_margin_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1400 }
1401 if (!empty($arrayfields['total_mark_rate']['checked'])) {
1402 print_liste_field_titre($arrayfields['total_mark_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1403 }
1404
1405 $totalarray = array(
1406 'nbfield' => 0,
1407 'val' => array(
1408 'cdet.total_ht' => 0,
1409 'cdet.total_tva' => 0,
1410 'cdet.total_ttc' => 0,
1411 ),
1412 'pos' => array(),
1413 );
1414 // Extra fields
1415 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1416 // Hook fields
1417 $parameters = array(
1418 'arrayfields' => $arrayfields,
1419 'param' => $param,
1420 'sortfield' => $sortfield,
1421 'sortorder' => $sortorder,
1422 'totalarray' => &$totalarray,
1423 );
1424 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
1425 print $hookmanager->resPrint;
1426 if (!empty($arrayfields['c.datec']['checked'])) {
1427 print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1428 }
1429 if (!empty($arrayfields['c.tms']['checked'])) {
1430 print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1431 }
1432 if (!empty($arrayfields['c.date_cloture']['checked'])) {
1433 print_liste_field_titre($arrayfields['c.date_cloture']['label'], $_SERVER["PHP_SELF"], "c.date_cloture", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1434 }
1435 if (!empty($arrayfields['c.note_public']['checked'])) {
1436 print_liste_field_titre($arrayfields['c.note_public']['label'], $_SERVER["PHP_SELF"], "c.note_public", "", $param, '', $sortfield, $sortorder, 'right ');
1437 }
1438 if (!empty($arrayfields['c.note_private']['checked'])) {
1439 print_liste_field_titre($arrayfields['c.note_private']['label'], $_SERVER["PHP_SELF"], "c.note_private", "", $param, '', $sortfield, $sortorder, 'right ');
1440 }
1441 if (!empty($arrayfields['shippable']['checked'])) {
1442 print_liste_field_titre($arrayfields['shippable']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
1443 }
1444 if (!empty($arrayfields['c.facture']['checked'])) {
1445 print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center ');
1446 }
1447 if (!empty($arrayfields['c.import_key']['checked'])) {
1448 print_liste_field_titre($arrayfields['c.import_key']['label'], $_SERVER["PHP_SELF"], "c.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1449 }
1450 if (!empty($arrayfields['c.fk_statut']['checked'])) {
1451 print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
1452 }
1453 if (!getDolGlobalInt('MAIN_CHECKBOX_LEFT_COLUMN')) {
1454 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center ');
1455 }
1456 print '</tr>'."\n";
1457
1458 $total = 0;
1459 $subtotal = 0;
1460 $productstat_cache = array();
1461 $productstat_cachevirtual = array();
1462 $getNomUrl_cache = array();
1463
1464 $generic_commande = new Commande($db);
1465 $generic_product = new Product($db);
1466 $userstatic = new User($db);
1467 $i = 0;
1468
1469 $with_margin_info = false;
1470 if (isModEnabled('margin') && (
1471 !empty($arrayfields['total_pa']['checked'])
1472 || !empty($arrayfields['total_margin']['checked'])
1473 || !empty($arrayfields['total_margin_rate']['checked'])
1474 || !empty($arrayfields['total_mark_rate']['checked'])
1475 )
1476 ) {
1477 $with_margin_info = true;
1478 }
1479 $total_ht = 0;
1480 $total_margin = 0;
1481
1482
1483 // Détail commande
1484 $totalqty = 0;
1485
1486 $totalarray = array();
1487 $totalarray['nbfield'] = 0;
1488 $subtotalarray = array();
1489 $subtotalarray['nbfield'] = 0;
1490 $totalarray['val']['cdet.total_tva'] = 0;
1491 $totalarray['val']['cdet.total_ttc'] = 0;
1492 $imaxinloop = ($limit ? min($num, $limit) : $num);
1493 while ($i < $imaxinloop) {
1494 $obj = $db->fetch_object($resql);
1495
1496 $notshippable = 0;
1497 $warning = 0;
1498 $text_info = '';
1499 $text_warning = '';
1500 $nbprod = 0;
1501
1502 // Print SubTotal
1503 if (empty($i)) {
1504 $oldref = $obj->product_ref;
1505 }
1506 if ($oldref != $obj->product_ref && $sortfield == 'pr.ref') {
1507 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_subtotal.tpl.php';
1508 $oldref = $obj->product_ref;
1509 }
1510
1511 $companystatic->id = $obj->socid;
1512 $companystatic->name = $obj->name;
1513 $companystatic->name_alias = $obj->alias;
1514 $companystatic->client = $obj->client;
1515 $companystatic->code_client = $obj->code_client;
1516 $companystatic->email = $obj->email;
1517 $companystatic->phone = $obj->phone;
1518 $companystatic->address = $obj->address;
1519 $companystatic->zip = $obj->zip;
1520 $companystatic->town = $obj->town;
1521 $companystatic->country_code = $obj->country_code;
1522 if (!isset($getNomUrl_cache[$obj->socid])) {
1523 $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer');
1524 }
1525
1526 $generic_commande->id = $obj->c_rowid;
1527 $generic_commande->ref = $obj->ref;
1528 $generic_commande->statut = $obj->fk_statut;
1529 $generic_commande->billed = $obj->billed;
1530 $generic_commande->date = $db->jdate($obj->date_commande);
1531 $generic_commande->delivery_date = $db->jdate($obj->date_delivery);
1532 $generic_commande->ref_client = $obj->ref_client;
1533 $generic_commande->total_ht = $obj->c_total_ht;
1534 $generic_commande->total_tva = $obj->c_total_tva;
1535 $generic_commande->total_ttc = $obj->c_total_ttc;
1536 $generic_commande->note_public = $obj->note_public;
1537 $generic_commande->note_private = $obj->note_private;
1538
1539 $projectstatic->id = $obj->project_id;
1540 $projectstatic->ref = $obj->project_ref;
1541 $projectstatic->title = $obj->project_label;
1542
1543 $marginInfo = array();
1544 if ($with_margin_info === true) {
1545 $generic_commande->fetch_lines();
1546 $marginInfo = $formmargin->getMarginInfosArray($generic_commande);
1547 $total_ht += $obj->total_ht;
1548 $total_margin += $marginInfo['total_margin'];
1549 }
1550
1551 print '<tr class="oddeven">';
1552
1553 // Action column
1554 if (getDolGlobalInt('MAIN_CHECKBOX_LEFT_COLUMN')) {
1555 print '<td class="nowrap center">';
1556 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1557 $selected = 0;
1558 if (in_array($obj->rowid, $arrayofselected)) {
1559 $selected = 1;
1560 }
1561 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1562 }
1563 print '</td>';
1564 if (!$i) {
1565 $totalarray['nbfield']++;
1566 }
1567 }
1568
1569 // Détail commande
1570 // ID
1571 if (!empty($arrayfields['rowid']['checked'])) {
1572 print '<td class="nowrap right">'.$obj->rowid.'</td>';
1573 if (!$i) {
1574 $totalarray['nbfield']++;
1575 }
1576 }
1577
1578 // Product Ref
1579 if (!empty($arrayfields['pr.ref']['checked'])) {
1580 if (!empty($obj->product_rowid)) {
1581 $generic_product->id = $obj->product_rowid;
1582 $generic_product->ref = $obj->product_ref;
1583 $generic_product->label = $obj->product_label;
1584 $generic_product->status = $obj->product_status;
1585 $generic_product->status_buy = $obj->product_status_buy;
1586 $generic_product->status_batch = $obj->product_batch;
1587 $generic_product->barcode = $obj->product_barcode;
1588 print '<td class="nowrap tdoverflowmax200">'.$generic_product->getNomUrl(1).'</td>';
1589 } else {
1590 print '<td class="nowrap tdoverflowmax200">Ligne libre</td>';
1591 }
1592 if (!$i) {
1593 $totalarray['nbfield']++;
1594 }
1595 }
1596 // Product Description
1597 if (!empty($arrayfields['pr.desc']['checked'])) {
1598 // print '<td class="nowrap tdoverflowmax200">'.$obj->description.'</td>';
1599 !empty($obj->product_label) ? $labelproduct = $obj->product_label : $labelproduct = $obj->description;
1600 print '<td class="nowrap tdoverflowmax200">';
1601 print dolGetFirstLineOfText(dolPrintHTML($labelproduct), 5);
1602 print '</td>';
1603
1604 if (!$i) {
1605 $totalarray['nbfield']++;
1606 }
1607 }
1608 // Product QtyOrdered
1609 if (!empty($arrayfields['cdet.qty']['checked'])) {
1610 print '<td class="nowrap right">'.$obj->qty.'</td>';
1611 if (isset($totalarray['val']['cdet.qty']) || isset($subtotalarray['val']['cdet.qty'])) {
1612 $totalarray['val']['cdet.qty'] += $obj->qty;
1613 $subtotalarray['val']['cdet.qty'] += $obj->qty;
1614 } else {
1615 $totalarray['val']['cdet.qty'] = $obj->qty;
1616 $subtotalarray['val']['cdet.qty'] = $obj->qty;
1617 }
1618 if (!$i) {
1619 $totalarray['nbfield']++;
1620 }
1621 if (!$i) {
1622 $totalarray['pos'][$totalarray['nbfield']] = 'cdet.qty';
1623 $totalarray['pos'][$subtotalarray['nbfield']] = 'cdet.qty';
1624 }
1625 }
1626
1627 // Ref
1628 if (!empty($arrayfields['c.ref']['checked'])) {
1629 print '<td class="nowraponall">';
1630 print $generic_commande->getNomUrl(1, ($search_status != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1);
1631
1632 $filename = dol_sanitizeFileName($obj->ref);
1633 $filedir = $conf->commande->multidir_output[$conf->entity].'/'.dol_sanitizeFileName($obj->ref);
1634 $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
1635 print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
1636
1637 print '</td>';
1638 if (!$i) {
1639 $totalarray['nbfield']++;
1640 }
1641 }
1642
1643 // Ref customer
1644 if (!empty($arrayfields['c.ref_client']['checked'])) {
1645 print '<td class="nowrap tdoverflowmax200">'.$obj->ref_client.'</td>';
1646 if (!$i) {
1647 $totalarray['nbfield']++;
1648 }
1649 }
1650
1651 // Project ref
1652 if (!empty($arrayfields['p.ref']['checked'])) {
1653 print '<td class="nowrap">';
1654 if ($obj->project_id > 0) {
1655 print $projectstatic->getNomUrl(1);
1656 }
1657 print '</td>';
1658 if (!$i) {
1659 $totalarray['nbfield']++;
1660 }
1661 }
1662
1663 // Project label
1664 if (!empty($arrayfields['p.title']['checked'])) {
1665 print '<td class="nowrap">';
1666 if ($obj->project_id > 0) {
1667 print $projectstatic->title;
1668 }
1669 print '</td>';
1670 if (!$i) {
1671 $totalarray['nbfield']++;
1672 }
1673 }
1674
1675 // Third party
1676 if (!empty($arrayfields['s.nom']['checked'])) {
1677 print '<td class="tdoverflowmax200">';
1678 print $getNomUrl_cache[$obj->socid];
1679
1680 // If module invoices enabled and user with invoice creation permissions
1681 if (isModEnabled('invoice') && getDolGlobalString('ORDER_BILLING_ALL_CUSTOMER')) {
1682 if ($user->hasRight('facture', 'creer')) {
1683 if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) {
1684 print '&nbsp;<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$companystatic->id.'&search_billed=0&autoselectall=1">';
1685 print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').'</a>';
1686 }
1687 }
1688 }
1689 print '</td>';
1690 if (!$i) {
1691 $totalarray['nbfield']++;
1692 }
1693 }
1694 // Alias name
1695 if (!empty($arrayfields['s.name_alias']['checked'])) {
1696 print '<td class="nocellnopadd">';
1697 print $obj->alias;
1698 print '</td>';
1699 if (!$i) {
1700 $totalarray['nbfield']++;
1701 }
1702 }
1703 // Town
1704 if (!empty($arrayfields['s.town']['checked'])) {
1705 print '<td class="nocellnopadd">';
1706 print $obj->town;
1707 print '</td>';
1708 if (!$i) {
1709 $totalarray['nbfield']++;
1710 }
1711 }
1712 // Zip
1713 if (!empty($arrayfields['s.zip']['checked'])) {
1714 print '<td class="nocellnopadd">';
1715 print $obj->zip;
1716 print '</td>';
1717 if (!$i) {
1718 $totalarray['nbfield']++;
1719 }
1720 }
1721 // State
1722 if (!empty($arrayfields['state.nom']['checked'])) {
1723 print "<td>".$obj->state_name."</td>\n";
1724 if (!$i) {
1725 $totalarray['nbfield']++;
1726 }
1727 }
1728 // Country
1729 if (!empty($arrayfields['country.code_iso']['checked'])) {
1730 print '<td class="center">';
1731 $tmparray = getCountry($obj->fk_pays, 'all');
1732 print $tmparray['label'];
1733 print '</td>';
1734 if (!$i) {
1735 $totalarray['nbfield']++;
1736 }
1737 }
1738 // Type ent
1739 if (!empty($arrayfields['typent.code']['checked'])) {
1740 print '<td class="center">';
1741 if (empty($typenArray)) {
1742 $typenArray = $formcompany->typent_array(1);
1743 }
1744 print $typenArray[$obj->typent_code];
1745 print '</td>';
1746 if (!$i) {
1747 $totalarray['nbfield']++;
1748 }
1749 }
1750
1751 // Order date
1752 if (!empty($arrayfields['c.date_commande']['checked'])) {
1753 print '<td class="center">';
1754 print dol_print_date($db->jdate($obj->date_commande), 'day');
1755 // Warning late icon and note
1756 if ($generic_commande->hasDelay()) {
1757 print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning");
1758 }
1759 print '</td>';
1760 if (!$i) {
1761 $totalarray['nbfield']++;
1762 }
1763 }
1764 // Plannned date of delivery
1765 if (!empty($arrayfields['c.date_delivery']['checked'])) {
1766 print '<td class="center">';
1767 print dol_print_date($db->jdate($obj->date_delivery), 'dayhour');
1768 print '</td>';
1769 if (!$i) {
1770 $totalarray['nbfield']++;
1771 }
1772 }
1773 // Shipping Method
1774 if (!empty($arrayfields['c.fk_shipping_method']['checked'])) {
1775 print '<td>';
1776 $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1);
1777 print '</td>';
1778 if (!$i) {
1779 $totalarray['nbfield']++;
1780 }
1781 }
1782 // Payment terms
1783 if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) {
1784 print '<td>';
1785 $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent);
1786 print '</td>';
1787 if (!$i) {
1788 $totalarray['nbfield']++;
1789 }
1790 }
1791 // Payment mode
1792 if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) {
1793 print '<td>';
1794 $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1);
1795 print '</td>';
1796 if (!$i) {
1797 $totalarray['nbfield']++;
1798 }
1799 }
1800 // Channel
1801 if (!empty($arrayfields['c.fk_input_reason']['checked'])) {
1802 print '<td>';
1803 $form->formInputReason($_SERVER['PHP_SELF'], $obj->fk_input_reason, 'none', '');
1804 print '</td>';
1805 if (!$i) {
1806 $totalarray['nbfield']++;
1807 }
1808 }
1809 // Amount HT
1810 if (!empty($arrayfields['cdet.total_ht']['checked'])) {
1811 print '<td class="nowrap right"><span class="amount">'.price($obj->total_ht)."</span></td>\n";
1812 if (!$i) {
1813 $totalarray['nbfield']++;
1814 }
1815 if (!$i) {
1816 $totalarray['pos'][$totalarray['nbfield']] = 'cdet.total_ht';
1817 $totalarray['pos'][$subtotalarray['nbfield']] = 'cdet.total_ht';
1818 }
1819 if (isset($totalarray['val']['cdet.total_ht']) || isset($subtotalarray['val']['cdet.total_ht'])) {
1820 $totalarray['val']['cdet.total_ht'] += $obj->total_ht;
1821 $subtotalarray['val']['cdet.total_ht'] += $obj->total_ht;
1822 } else {
1823 $totalarray['val']['cdet.total_ht'] = $obj->total_ht;
1824 $subtotalarray['val']['cdet.total_ht'] = $obj->total_ht;
1825 }
1826 }
1827 // Amount VAT
1828 if (!empty($arrayfields['c.total_vat']['checked'])) {
1829 print '<td class="nowrap right"><span class="amount">'.price($obj->total_tva)."</span></td>\n";
1830 if (!$i) {
1831 $totalarray['nbfield']++;
1832 }
1833 if (!$i) {
1834 $totalarray['pos'][$totalarray['nbfield']] = 'cdet.total_tva';
1835 $totalarray['pos'][$subtotalarray['nbfield']] = 'cdet.total_tva';
1836 }
1837 $totalarray['val']['cdet.total_tva'] += $obj->total_tva;
1838 $subtotalarray['val']['cdet.total_tva'] += $obj->total_tva;
1839 }
1840 // Amount TTC
1841 if (!empty($arrayfields['cdet.total_ttc']['checked'])) {
1842 print '<td class="nowrap right"><span class="amount">'.price($obj->total_ttc)."</span></td>\n";
1843 if (!$i) {
1844 $totalarray['nbfield']++;
1845 }
1846 if (!$i) {
1847 $totalarray['pos'][$totalarray['nbfield']] = 'cdet.total_ttc';
1848 $subtotalarray['pos'][$totalarray['nbfield']] = 'cdet.total_ttc';
1849 }
1850 $totalarray['val']['cdet.total_ttc'] += $obj->total_ttc;
1851 $subtotalarray['val']['cdet.total_ttc'] += $obj->total_ttc;
1852 }
1853 // Warehouse
1854 if (!empty($arrayfields['c.fk_warehouse']['checked'])) {
1855 print '<td class="nowrap">';
1856 if ($obj->warehouse > 0) {
1857 print img_picto('', 'stock', 'class="paddingrightonly"');
1858 }
1859 $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'], $obj->warehouse, 'none');
1860 print "</td>\n";
1861 if (!$i) {
1862 $totalarray['nbfield']++;
1863 }
1864 }
1865 // Currency
1866 if (!empty($arrayfields['c.multicurrency_code']['checked'])) {
1867 print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n";
1868 if (!$i) {
1869 $totalarray['nbfield']++;
1870 }
1871 }
1872
1873 // Currency rate
1874 if (!empty($arrayfields['c.multicurrency_tx']['checked'])) {
1875 print '<td class="nowrap">';
1876 $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
1877 print "</td>\n";
1878 if (!$i) {
1879 $totalarray['nbfield']++;
1880 }
1881 }
1882 // Amount HT
1883 if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) {
1884 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht)."</span></td>\n";
1885 if (!$i) {
1886 $totalarray['nbfield']++;
1887 }
1888 }
1889 // Amount VAT
1890 if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) {
1891 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat)."</span></td>\n";
1892 if (!$i) {
1893 $totalarray['nbfield']++;
1894 }
1895 }
1896 // Amount TTC
1897 if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) {
1898 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc)."</span></td>\n";
1899 if (!$i) {
1900 $totalarray['nbfield']++;
1901 }
1902 }
1903
1904 $userstatic->id = $obj->fk_user_author;
1905 $userstatic->login = $obj->login;
1906 $userstatic->lastname = $obj->lastname;
1907 $userstatic->firstname = $obj->firstname;
1908 $userstatic->email = $obj->user_email;
1909 $userstatic->status = $obj->user_statut;
1910 $userstatic->entity = $obj->entity;
1911 $userstatic->photo = $obj->photo;
1912 $userstatic->office_phone = $obj->office_phone;
1913 $userstatic->office_fax = $obj->office_fax;
1914 $userstatic->user_mobile = $obj->user_mobile;
1915 $userstatic->job = $obj->job;
1916 $userstatic->gender = $obj->gender;
1917
1918 // Author
1919 if (!empty($arrayfields['u.login']['checked'])) {
1920 print '<td class="tdoverflowmax200">';
1921 if ($userstatic->id) {
1922 print $userstatic->getNomUrl(-1);
1923 } else {
1924 print '&nbsp;';
1925 }
1926 print "</td>\n";
1927 if (!$i) {
1928 $totalarray['nbfield']++;
1929 }
1930 }
1931
1932 if (!empty($arrayfields['sale_representative']['checked'])) {
1933 // Sales representatives
1934 print '<td>';
1935 if ($obj->socid > 0) {
1936 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
1937 if ($listsalesrepresentatives < 0) {
1938 dol_print_error($db);
1939 }
1940 $nbofsalesrepresentative = count($listsalesrepresentatives);
1941 if ($nbofsalesrepresentative > 6) {
1942 // We print only number
1943 print $nbofsalesrepresentative;
1944 } elseif ($nbofsalesrepresentative > 0) {
1945 $j = 0;
1946 foreach ($listsalesrepresentatives as $val) {
1947 $userstatic->id = $val['id'];
1948 $userstatic->lastname = $val['lastname'];
1949 $userstatic->firstname = $val['firstname'];
1950 $userstatic->email = $val['email'];
1951 $userstatic->status = $val['statut'];
1952 $userstatic->entity = $val['entity'];
1953 $userstatic->photo = $val['photo'];
1954 $userstatic->login = $val['login'];
1955 $userstatic->office_phone = $val['office_phone'];
1956 $userstatic->office_fax = $val['office_fax'];
1957 $userstatic->user_mobile = $val['user_mobile'];
1958 $userstatic->job = $val['job'];
1959 $userstatic->gender = $val['gender'];
1960 //print '<div class="float">':
1961 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2);
1962 $j++;
1963 if ($j < $nbofsalesrepresentative) {
1964 print ' ';
1965 }
1966 //print '</div>';
1967 }
1968 }
1969 //else print $langs->trans("NoSalesRepresentativeAffected");
1970 } else {
1971 print '&nbsp;';
1972 }
1973 print '</td>';
1974 if (!$i) {
1975 $totalarray['nbfield']++;
1976 }
1977 }
1978
1979 // Total buying or cost price
1980 if (!empty($arrayfields['total_pa']['checked'])) {
1981 print '<td class="right nowrap">'.price($marginInfo['pa_total']).'</td>';
1982 if (!$i) {
1983 $totalarray['nbfield']++;
1984 }
1985 }
1986 // Total margin
1987 if (!empty($arrayfields['total_margin']['checked'])) {
1988 print '<td class="right nowrap">'.price($marginInfo['total_margin']).'</td>';
1989 if (!$i) {
1990 $totalarray['nbfield']++;
1991 }
1992 if (!$i) {
1993 $totalarray['pos'][$totalarray['nbfield']] = 'total_margin';
1994 $totalarray['pos'][$subtotalarray['nbfield']] = 'total_margin';
1995 }
1996 $totalarray['val']['total_margin'] += $marginInfo['total_margin'];
1997 $subtotalarray['val']['total_margin'] += $marginInfo['total_margin'];
1998 }
1999 // Total margin rate
2000 if (!empty($arrayfields['total_margin_rate']['checked'])) {
2001 print '<td class="right nowrap">'.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], 0, '', 0, 0, 2).'%').'</td>';
2002 if (!$i) {
2003 $totalarray['nbfield']++;
2004 }
2005 }
2006 // Total mark rate
2007 if (!empty($arrayfields['total_mark_rate']['checked'])) {
2008 print '<td class="right nowrap">'.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], 0, '', 0, 0, 2).'%').'</td>';
2009 if (!$i) {
2010 $totalarray['nbfield']++;
2011 }
2012 if (!$i) {
2013 $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate';
2014 $totalarray['pos'][$subtotalarray['nbfield']] = 'total_mark_rate';
2015 }
2016 if ($i >= $imaxinloop - 1) {
2017 if (!empty($total_ht)) {
2018 $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT');
2019 $subtotalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT');
2020 } else {
2021 $totalarray['val']['total_mark_rate'] = '';
2022 $subtotalarray['val']['total_mark_rate'] = '';
2023 }
2024 }
2025 }
2026
2027 // Extra fields
2028 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
2029 // Fields from hook
2030 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
2031 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2032 print $hookmanager->resPrint;
2033
2034 // Date creation
2035 if (!empty($arrayfields['c.datec']['checked'])) {
2036 print '<td align="center" class="nowrap">';
2037 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
2038 print '</td>';
2039 if (!$i) {
2040 $totalarray['nbfield']++;
2041 }
2042 }
2043
2044 // Date modification
2045 if (!empty($arrayfields['c.tms']['checked'])) {
2046 print '<td align="center" class="nowrap">';
2047 print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser');
2048 print '</td>';
2049 if (!$i) {
2050 $totalarray['nbfield']++;
2051 }
2052 }
2053
2054 // Date cloture
2055 if (!empty($arrayfields['c.date_cloture']['checked'])) {
2056 print '<td align="center" class="nowrap">';
2057 print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser');
2058 print '</td>';
2059 if (!$i) {
2060 $totalarray['nbfield']++;
2061 }
2062 }
2063
2064 // Note public
2065 if (!empty($arrayfields['c.note_public']['checked'])) {
2066 print '<td class="sensiblehtmlcontent center">';
2067 print dolPrintHTML($obj->note_public);
2068 print '</td>';
2069 if (!$i) {
2070 $totalarray['nbfield']++;
2071 }
2072 }
2073
2074 // Note private
2075 if (!empty($arrayfields['c.note_private']['checked'])) {
2076 print '<td class="center">';
2077 print dolPrintHTML($obj->note_private);
2078 print '</td>';
2079 if (!$i) {
2080 $totalarray['nbfield']++;
2081 }
2082 }
2083
2084 // Show shippable Icon (this creates subloops, so may be slow)
2085 if (!empty($arrayfields['shippable']['checked'])) {
2086 print '<td class="center">';
2087 if (!empty($show_shippable_command) && isModEnabled('stock')) {
2088 if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) {
2089 $generic_commande->loadExpeditions(); // Load array ->expeditions
2090
2091 if (isset($generic_commande->expeditions[$obj->rowid])) {
2092 $reliquat = $obj->qty - $generic_commande->expeditions[$obj->rowid];
2093 } else {
2094 $reliquat = $obj->qty;
2095 }
2096 if ($obj->product_type == 0 && $obj->fk_product > 0) { // If line is a product and not a service
2097 $nbprod++; // order contains real products
2098 $generic_product->id = $obj->fk_product;
2099
2100 // Get local and virtual stock and store it into cache
2101 if (empty($productstat_cache[$obj->fk_product])) {
2102 $generic_product->load_stock('nobatch'); // ->load_virtual_stock() is already included into load_stock()
2103 $productstat_cache[$obj->fk_product]['stock_reel'] = $generic_product->stock_reel;
2104 $productstat_cachevirtual[$obj->fk_product]['stock_reel'] = $generic_product->stock_theorique;
2105 } else {
2106 $generic_product->stock_reel = $productstat_cache[$obj->fk_product]['stock_reel'];
2107 $generic_product->stock_theorique = $productstat_cachevirtual[$obj->fk_product]['stock_reel'];
2108 }
2109
2110 if ($reliquat > $generic_product->stock_reel) {
2111 $notshippable++;
2112 }
2113 if (!getDolGlobalString('SHIPPABLE_ORDER_ICON_IN_LIST')) { // Default code. Default should be this case.
2114 $text_info .= $reliquat.' x '.$obj->product_ref.'&nbsp;'.dol_trunc($obj->product_label, 20);
2115 $text_info .= ' - '.$langs->trans("Stock").': <span class="'.($generic_product->stock_reel > 0 ? 'ok' : 'error').'">'.$generic_product->stock_reel.'</span>';
2116 $text_info .= ' - '.$langs->trans("VirtualStock").': <span class="'.($generic_product->stock_theorique > 0 ? 'ok' : 'error').'">'.$generic_product->stock_theorique.'</span>';
2117 $text_info .= ($reliquat != $obj->qty ? ' <span class="opacitymedium">('.$langs->trans("QtyInOtherShipments").' '.($obj->qty - $reliquat).')</span>' : '');
2118 $text_info .= '<br>';
2119 } else { // BUGGED CODE.
2120 // DOES NOT TAKE INTO ACCOUNT MANUFACTURING. THIS CODE SHOULD BE USELESS. PREVIOUS CODE SEEMS COMPLETE.
2121 // COUNT STOCK WHEN WE SHOULD ALREADY HAVE VALUE
2122 // Detailed virtual stock, looks bugged, incomplete and need heavy load.
2123 // stock order and stock order_supplier
2124 $stock_order = 0;
2125 $stock_order_supplier = 0;
2126 if (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT') || getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE')) { // What about other options ?
2127 if (isModEnabled('order')) {
2128 if (empty($productstat_cache[$obj->fk_product]['stats_order_customer'])) {
2129 $generic_product->load_stats_commande(0, '1,2');
2130 $productstat_cache[$obj->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty'];
2131 } else {
2132 $generic_product->stats_commande['qty'] = $productstat_cache[$obj->fk_product]['stats_order_customer'];
2133 }
2134 $stock_order = $generic_product->stats_commande['qty'];
2135 }
2136 if (isModEnabled('supplier_order')) {
2137 if (empty($productstat_cache[$obj->fk_product]['stats_order_supplier'])) {
2138 $generic_product->load_stats_commande_fournisseur(0, '3');
2139 $productstat_cache[$obj->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty'];
2140 } else {
2141 $generic_product->stats_commande_fournisseur['qty'] = $productstat_cache[$obj->fk_product]['stats_order_supplier'];
2142 }
2143 $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty'];
2144 }
2145 }
2146 $text_info .= $reliquat.' x '.$obj->product_ref.'&nbsp;'.dol_trunc($obj->product_label, 20);
2147 $text_stock_reel = $generic_product->stock_reel.'/'.$stock_order;
2148 if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $obj->qty)) {
2149 $warning++;
2150 $text_warning .= '<span class="warning">'.$langs->trans('Available').'&nbsp;:&nbsp;'.$text_stock_reel.'</span>';
2151 }
2152 if ($reliquat > $generic_product->stock_reel) {
2153 $text_info .= '<span class="warning">'.$langs->trans('Available').'&nbsp;:&nbsp;'.$text_stock_reel.'</span>';
2154 } else {
2155 $text_info .= '<span class="ok">'.$langs->trans('Available').'&nbsp;:&nbsp;'.$text_stock_reel.'</span>';
2156 }
2157 if (isModEnabled('supplier_order')) {
2158 $text_info .= '&nbsp;'.$langs->trans('SupplierOrder').'&nbsp;:&nbsp;'.$stock_order_supplier;
2159 }
2160 $text_info .= ($reliquat != $obj->qty ? ' <span class="opacitymedium">('.$langs->trans("QtyInOtherShipments").' '.($obj->qty - $reliquat).')</span>' : '');
2161 $text_info .= '<br>';
2162 }
2163 }
2164 if ($notshippable == 0) {
2165 $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'green paddingleft');
2166 $text_info = $text_icon.' '.$langs->trans('Shippable').'<br>'.$text_info;
2167 } else {
2168 $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'error paddingleft');
2169 $text_info = $text_icon.' '.$langs->trans('NonShippable').'<br>'.$text_info;
2170 }
2171 }
2172
2173 if ($nbprod) {
2174 print $form->textwithtooltip('', $text_info, 2, 1, $text_icon, '', 2);
2175 }
2176 if ($warning) { // Always false in default mode
2177 print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders').'<br>'.$text_warning, 2, 1, img_picto('', 'error'), '', 2);
2178 }
2179 }
2180 print '</td>';
2181 if (!$i) {
2182 $totalarray['nbfield']++;
2183 }
2184 }
2185
2186 // Billed
2187 if (!empty($arrayfields['c.facture']['checked'])) {
2188 print '<td class="center">'.yn($obj->billed).'</td>';
2189 if (!$i) {
2190 $totalarray['nbfield']++;
2191 }
2192 }
2193 // Import key
2194 if (!empty($arrayfields['c.import_key']['checked'])) {
2195 print '<td class="nowrap center">'.$obj->import_key.'</td>';
2196 if (!$i) {
2197 $totalarray['nbfield']++;
2198 }
2199 }
2200 // Status
2201 if (!empty($arrayfields['c.fk_statut']['checked'])) {
2202 print '<td class="nowrap center">'.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).'</td>';
2203 if (!$i) {
2204 $totalarray['nbfield']++;
2205 }
2206 }
2207
2208 // Action column
2209 if (!getDolGlobalInt('MAIN_CHECKBOX_LEFT_COLUMN')) {
2210 print '<td class="nowrap center">';
2211 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2212 $selected = 0;
2213 if (in_array($obj->rowid, $arrayofselected)) {
2214 $selected = 1;
2215 }
2216 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
2217 }
2218 print '</td>';
2219 if (!$i) {
2220 $totalarray['nbfield']++;
2221 }
2222 }
2223
2224 print "</tr>\n";
2225
2226 $total += $obj->total_ht;
2227 $subtotal += $obj->total_ht;
2228 $i++;
2229 }
2230 if ($sortfield == 'pr.ref') {
2231 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_subtotal.tpl.php';
2232 }
2233 // Show total line
2234 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
2235
2236 // If no record found
2237 if ($num == 0) {
2238 $colspan = 1;
2239 foreach ($arrayfields as $key => $val) {
2240 if (!empty($val['checked'])) {
2241 $colspan++;
2242 }
2243 }
2244 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
2245 }
2246
2247 $db->free($resql);
2248
2249 $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
2250 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
2251 print $hookmanager->resPrint;
2252
2253 print '</table>'."\n";
2254 print '</div>';
2255
2256 print '</form>'."\n";
2257
2258 $hidegeneratedfilelistifempty = 1;
2259 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
2260 $hidegeneratedfilelistifempty = 0;
2261 }
2262
2263 // Show list of available documents
2264 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
2265 $urlsource .= str_replace('&amp;', '&', $param);
2266
2267 $filedir = $diroutputmassaction;
2268 $genallowed = $permissiontoread;
2269 $delallowed = $permissiontoadd;
2270
2271 print $formfile->showdocuments('massfilesarea_orders', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
2272} else {
2273 dol_print_error($db);
2274}
2275
2276// End of page
2277llxFooter();
2278$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
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 standard extra fields.
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_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...
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
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 '.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
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.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $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, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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 dolibarr global constant string value.
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.