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