dolibarr 21.0.0-beta
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) { // To process
495 //$sql.= ' AND c.fk_statut IN (1,2,3) AND c.facture = 0';
496 $sql .= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected
497 }
498 if ($search_status == -3) { // To bill
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)) OR (c.fk_statut = 3 AND c.facture = 0))'; // validated, in process or closed but not billed
502 }
503 if ($search_status == -4) { // "validate and in progress"
504 $sql .= ' AND (c.fk_statut IN (1,2))'; // validated, in process
505 }
506}
507
508if ($search_datecloture_start) {
509 $sql .= " AND c.date_cloture >= '".$db->idate($search_datecloture_start)."'";
510}
511if ($search_datecloture_end) {
512 $sql .= " AND c.date_cloture <= '".$db->idate($search_datecloture_end)."'";
513}
514if ($search_dateorder_start) {
515 $sql .= " AND c.date_commande >= '".$db->idate($search_dateorder_start)."'";
516}
517if ($search_dateorder_end) {
518 $sql .= " AND c.date_commande <= '".$db->idate($search_dateorder_end)."'";
519}
520if ($search_datedelivery_start) {
521 $sql .= " AND c.date_livraison >= '".$db->idate($search_datedelivery_start)."'";
522}
523if ($search_datedelivery_end) {
524 $sql .= " AND c.date_livraison <= '".$db->idate($search_datedelivery_end)."'";
525}
526if ($search_town) {
527 $sql .= natural_search('s.town', $search_town);
528}
529if ($search_zip) {
530 $sql .= natural_search("s.zip", $search_zip);
531}
532if ($search_state) {
533 $sql .= natural_search("state.nom", $search_state);
534}
535if ($search_country) {
536 $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
537}
538if ($search_type_thirdparty && $search_type_thirdparty != '-1') {
539 $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')';
540}
541if ($search_company) {
542 $sql .= natural_search('s.nom', $search_company);
543}
544if ($search_company_alias) {
545 $sql .= natural_search('s.name_alias', $search_company_alias);
546}
547if ($search_user > 0) {
548 $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);
549}
550if ($search_total_ht != '') {
551 $sql .= natural_search('cdet.total_ht', $search_total_ht, 1);
552}
553if ($search_total_vat != '') {
554 $sql .= natural_search('cdet.total_tva', $search_total_vat, 1);
555}
556if ($search_total_ttc != '') {
557 $sql .= natural_search('cdet.total_ttc', $search_total_ttc, 1);
558}
559if ($search_warehouse != '' && $search_warehouse > 0) {
560 $sql .= natural_search('c.fk_warehouse', $search_warehouse, 1);
561}
562if ($search_multicurrency_code != '') {
563 $sql .= " AND c.multicurrency_code = '".$db->escape($search_multicurrency_code)."'";
564}
565if ($search_multicurrency_tx != '') {
566 $sql .= natural_search('c.multicurrency_tx', $search_multicurrency_tx, 1);
567}
568if ($search_multicurrency_montant_ht != '') {
569 $sql .= natural_search('c.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
570}
571if ($search_multicurrency_montant_vat != '') {
572 $sql .= natural_search('c.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
573}
574if ($search_multicurrency_montant_ttc != '') {
575 $sql .= natural_search('c.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
576}
577if ($search_login) {
578 $sql .= natural_search(array("u.login", "u.firstname", "u.lastname"), $search_login);
579}
580if ($search_project_ref != '') {
581 $sql .= natural_search("p.ref", $search_project_ref);
582}
583if ($search_project != '') {
584 $sql .= natural_search("p.title", $search_project);
585}
586if ($search_categ_cus > 0) {
587 $sql .= " AND cc.fk_categorie = ".((int) $search_categ_cus);
588}
589if ($search_categ_cus == -2) {
590 $sql .= " AND cc.fk_categorie IS NULL";
591}
592if ($search_fk_cond_reglement > 0) {
593 $sql .= " AND c.fk_cond_reglement = ".((int) $search_fk_cond_reglement);
594}
595if ($search_fk_shipping_method > 0) {
596 $sql .= " AND c.fk_shipping_method = ".((int) $search_fk_shipping_method);
597}
598if ($search_fk_mode_reglement > 0) {
599 $sql .= " AND c.fk_mode_reglement = ".((int) $search_fk_mode_reglement);
600}
601if ($search_fk_input_reason > 0) {
602 $sql .= " AND c.fk_input_reason = ".((int) $search_fk_input_reason);
603}
604// Search on sale representative
605if ($search_sale && $search_sale != '-1') {
606 if ($search_sale == -2) {
607 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc)";
608 } elseif ($search_sale > 0) {
609 $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).")";
610 }
611}
612// Search for tag/category ($searchCategoryProductList is an array of ID)
613$searchCategoryProductList = $search_product_category_array;
614if (!empty($searchCategoryProductList)) {
615 $searchCategoryProjectSqlList = array();
616 $listofcategoryid = '';
617 foreach ($searchCategoryProductList as $searchCategoryProject) {
618 if (intval($searchCategoryProject) == -2) {
619 $searchCategoryProjectSqlList[] = "NOT EXISTS (SELECT cp.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as cp WHERE cdet.fk_product = cp.fk_product)";
620 } elseif (intval($searchCategoryProject) > 0) {
621 if ($searchCategoryProductOperator == 0) {
622 $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).")";
623 } else {
624 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProject);
625 }
626 }
627 }
628 if ($listofcategoryid) {
629 $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)."))";
630 }
631 if ($searchCategoryProductOperator == 1) {
632 if (!empty($searchCategoryProjectSqlList)) {
633 $sql .= " AND (".implode(' OR ', $searchCategoryProjectSqlList).")";
634 }
635 } else {
636 if (!empty($searchCategoryProjectSqlList)) {
637 $sql .= " AND (".implode(' AND ', $searchCategoryProjectSqlList).")";
638 }
639 }
640}
641
642// Add where from extra fields
643include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
644
645// Add where from hooks
646$parameters = array();
647$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
648$sql .= $hookmanager->resPrint;
649
650// Add HAVING from hooks
651$parameters = array();
652$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook
653$sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
654
655$sql .= $db->order($sortfield, $sortorder);
656
657// Count total nb of records
658$nbtotalofrecords = '';
659if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
660 $result = $db->query($sql);
661 $nbtotalofrecords = $db->num_rows($result);
662
663 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
664 $page = 0;
665 $offset = 0;
666 }
667}
668
669$sql .= $db->plimit($limit + 1, $offset);
670//print $sql;
671
672$resql = $db->query($sql);
673if ($resql) {
674 if ($socid > 0) {
675 $soc = new Societe($db);
676 $soc->fetch($socid);
677 $title = $langs->trans('ListOrderLigne').' - '.$soc->name;
678 if (empty($search_company)) {
679 $search_company = $soc->name;
680 }
681 } else {
682 $title = $langs->trans('ListOrderLigne');
683 }
684 if (strval($search_status) == '0') {
685 $title .= ' - '.$langs->trans('StatusOrderDraftShort');
686 }
687 if ($search_status == 1) {
688 $title .= ' - '.$langs->trans('StatusOrderValidatedShort');
689 }
690 if ($search_status == 2) {
691 $title .= ' - '.$langs->trans('StatusOrderSentShort');
692 }
693 if ($search_status == 3) {
694 $title .= ' - '.$langs->trans('StatusOrderToBillShort');
695 }
696 if ($search_status == -1) {
697 $title .= ' - '.$langs->trans('StatusOrderCanceledShort');
698 }
699 if ($search_status == -2) {
700 $title .= ' - '.$langs->trans('StatusOrderToProcessShort');
701 }
702 if ($search_status == -3) {
703 $title .= ' - '.$langs->trans('StatusOrderValidated').', '.(!isModEnabled('shipping') ? '' : $langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill');
704 }
705 if ($search_status == -4) {
706 $title .= ' - '.$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort");
707 }
708
709 $num = $db->num_rows($resql);
710
711 $arrayofselected = is_array($toselect) ? $toselect : array();
712
713 if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) {
714 $obj = $db->fetch_object($resql);
715 $id = $obj->rowid;
716 header("Location: ".DOL_URL_ROOT.'/commande/card.php?id='.$id);
717 exit;
718 }
719
720 llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-commande page-list_det');
721
722 $param = '';
723
724 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
725 $param .= '&contextpage='.urlencode($contextpage);
726 }
727 if ($limit > 0 && $limit != $conf->liste_limit) {
728 $param .= '&limit='.((int) $limit);
729 }
730 if ($search_all) {
731 $param .= '&search_all='.urlencode($search_all);
732 }
733 if ($socid > 0) {
734 $param .= '&socid='.urlencode((string) ($socid));
735 }
736 if ($search_id) {
737 $param .= '&search_id='.urlencode($search_id);
738 }
739 // Détail commande
740 if ($search_refProduct) {
741 $param .= '&search_refProduct='.urlencode($search_refProduct);
742 }
743 if ($search_descProduct) {
744 $param .= '&search_descProduct='.urlencode($search_descProduct);
745 }
746 if ($search_status != '') {
747 $param .= '&search_status='.urlencode($search_status);
748 }
749 if ($search_datecloture_start) {
750 $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');
751 }
752 if ($search_datecloture_end) {
753 $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');
754 }
755 if ($search_dateorder_start) {
756 $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');
757 }
758 if ($search_dateorder_end) {
759 $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');
760 }
761 if ($search_datedelivery_start) {
762 $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');
763 }
764 if ($search_datedelivery_end) {
765 $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');
766 }
767 if ($search_ref) {
768 $param .= '&search_ref='.urlencode($search_ref);
769 }
770 if ($search_company) {
771 $param .= '&search_company='.urlencode($search_company);
772 }
773 if ($search_company_alias) {
774 $param .= '&search_company_alias='.urlencode($search_company_alias);
775 }
776 if ($search_ref_customer) {
777 $param .= '&search_ref_customer='.urlencode($search_ref_customer);
778 }
779 if ($search_user > 0) {
780 $param .= '&search_user='.urlencode((string) ($search_user));
781 }
782 if ($search_sale > 0) {
783 $param .= '&search_sale='.urlencode($search_sale);
784 }
785 if ($search_total_ht != '') {
786 $param .= '&search_total_ht='.urlencode($search_total_ht);
787 }
788 if ($search_total_vat != '') {
789 $param .= '&search_total_vat='.urlencode($search_total_vat);
790 }
791 if ($search_total_ttc != '') {
792 $param .= '&search_total_ttc='.urlencode($search_total_ttc);
793 }
794 if ($search_warehouse != '') {
795 $param .= '&search_warehouse='.urlencode((string) ($search_warehouse));
796 }
797 if ($search_login) {
798 $param .= '&search_login='.urlencode($search_login);
799 }
800 if ($search_multicurrency_code != '') {
801 $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code);
802 }
803 if ($search_multicurrency_tx != '') {
804 $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
805 }
806 if ($search_multicurrency_montant_ht != '') {
807 $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
808 }
809 if ($search_multicurrency_montant_vat != '') {
810 $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
811 }
812 if ($search_multicurrency_montant_ttc != '') {
813 $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
814 }
815 if ($search_project_ref >= 0) {
816 $param .= "&search_project_ref=".urlencode($search_project_ref);
817 }
818 if ($search_town != '') {
819 $param .= '&search_town='.urlencode($search_town);
820 }
821 if ($search_zip != '') {
822 $param .= '&search_zip='.urlencode($search_zip);
823 }
824 if ($search_state != '') {
825 $param .= '&search_state='.urlencode($search_state);
826 }
827 if ($search_country != '') {
828 $param .= '&search_country='.urlencode((string) ($search_country));
829 }
830 if ($search_type_thirdparty && $search_type_thirdparty != '-1') {
831 $param .= '&search_type_thirdparty='.urlencode((string) ($search_type_thirdparty));
832 }
833 if (!empty($search_product_category_array)) {
834 foreach ($search_product_category_array as $tmpval) {
835 $param .= '&search_categegory_product_list[]='.urlencode($tmpval);
836 }
837 }
838 if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
839 $param .= '&search_categ_cus='.urlencode((string) ($search_categ_cus));
840 }
841 if ($show_files) {
842 $param .= '&show_files='.urlencode((string) ($show_files));
843 }
844 if ($optioncss != '') {
845 $param .= '&optioncss='.urlencode($optioncss);
846 }
847 if ($search_billed != '') {
848 $param .= '&search_billed='.urlencode($search_billed);
849 }
850 if ($search_fk_cond_reglement > 0) {
851 $param .= '&search_fk_cond_reglement='.urlencode((string) ($search_fk_cond_reglement));
852 }
853 if ($search_fk_shipping_method > 0) {
854 $param .= '&search_fk_shipping_method='.urlencode((string) ($search_fk_shipping_method));
855 }
856 if ($search_fk_mode_reglement > 0) {
857 $param .= '&search_fk_mode_reglement='.urlencode((string) ($search_fk_mode_reglement));
858 }
859 if ($search_fk_input_reason > 0) {
860 $param .= '&search_fk_input_reason='.urlencode((string) ($search_fk_input_reason));
861 }
862 if (!empty($productobuy)) {
863 $param .= '&productobuy='.urlencode($productobuy);
864 }
865 if (!empty($productonly)) {
866 $param .= '&productonly='.urlencode($productonly);
867 }
868 if (!empty($disablelinefree)) {
869 $param .= '&disablelinefree='.urlencode($disablelinefree);
870 }
871
872 // Add $param from extra fields
873 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
874
875 // Add $param from hooks
876 $parameters = array('param' => &$param);
877 $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
878 $param .= $hookmanager->resPrint;
879
880 // List of mass actions available
881 $arrayofmassactions = array(
882 // TODO add mass action here
883 // 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
884 );
885 // if ($permissiontovalidate) {
886 // $arrayofmassactions['prevalidate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate");
887 // }
888 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
889
890 $url = DOL_URL_ROOT.'/commande/card.php?action=create';
891 if (!empty($socid)) {
892 $url .= '&socid='.$socid;
893 }
894 $newcardbutton = '';//dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', $url, '', $contextpage == 'orderlistdet' && $permissiontoadd);
895
896 // Lines of title fields
897 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
898 if ($optioncss != '') {
899 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
900 }
901 print '<input type="hidden" name="token" value="'.newToken().'">';
902 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
903 print '<input type="hidden" name="action" value="list">';
904 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
905 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
906 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
907 print '<input type="hidden" name="search_status" value="'.$search_status.'">';
908 print '<input type="hidden" name="socid" value="'.$socid.'">';
909
910 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'order', 0, $newcardbutton, '', $limit, 0, 0, 1);
911
912 $topicmail = "SendOrderRef";
913 $modelmail = "order_send";
914 $objecttmp = new Commande($db);
915 $trackid = 'ord'.$object->id;
916 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
917
918 if ($search_all) {
919 foreach ($fieldstosearchall as $key => $val) {
920 $fieldstosearchall[$key] = $langs->trans($val);
921 }
922 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
923 }
924
925 $moreforfilter = '';
926
927 $moreforfilter .= '<div class="divsearchfield">';
928 $moreforfilter .= '<input type="checkbox" id="productobuy" name="productobuy"'.(!empty($productobuy) ? 'value="productobuychecked" checked' : '').'><label for="productobuy">'.$langs->trans("productobuy").'</label>';
929 $moreforfilter .= '</div>';
930 $moreforfilter .= '<div class="divsearchfield">';
931 $moreforfilter .= '<input type="checkbox" id="productonly" name="productonly"'.(!empty($productonly) ? 'value="productonlychecked" checked' : '').'><label for="productonly">'.$langs->trans("productonly").'</label>';
932 $moreforfilter .= '</div>';
933 $moreforfilter .= '<div class="divsearchfield">';
934 $moreforfilter .= '<input type="checkbox" id="disablelinefree" name="disablelinefree"'.(!empty($disablelinefree) ? 'value="disablelinefreechecked" checked' : '').'><label for="disablelinefree">'.$langs->trans("disablelinefree").'</label>';
935 $moreforfilter .= '</div><br>';
936
937 // If the user can view prospects other than his'
938 if ($user->hasRight('user', 'user', 'lire')) {
939 $langs->load("commercial");
940 $moreforfilter .= '<div class="divsearchfield">';
941 $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
942 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx');
943 $moreforfilter .= '</div>';
944 }
945 // If the user can view other users
946 if ($user->hasRight('user', 'user', 'lire')) {
947 $moreforfilter .= '<div class="divsearchfield">';
948 $tmptitle = $langs->trans('LinkedToSpecificUsers');
949 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
950 $moreforfilter .= '</div>';
951 }
952 // Filter on categories
953 if (isModEnabled("category") && $user->hasRight('categorie', 'lire') && ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire'))) {
954 $formcategory = new FormCategory($db);
955 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PRODUCT, $search_product_category_array, 'minwidth300imp minwidth300', $searchCategoryProductOperator ? $searchCategoryProductOperator : 0);
956 }
957 if (isModEnabled("category") && $user->hasRight('categorie', 'lire')) {
958 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
959 $moreforfilter .= '<div class="divsearchfield">';
960 $tmptitle = $langs->trans('CustomersProspectsCategoriesShort');
961 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $tmptitle, 'maxwidth300 widthcentpercentminusx');
962 $moreforfilter .= '</div>';
963 }
964 if (isModEnabled('stock') && getDolGlobalString('WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
965 require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
966 $formproduct = new FormProduct($db);
967 $moreforfilter .= '<div class="divsearchfield">';
968 $tmptitle = $langs->trans('Warehouse');
969 $moreforfilter .= img_picto($tmptitle, 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse, 'search_warehouse', '', 1, 0, 0, $tmptitle, 0, 0, array(), 'maxwidth250 widthcentpercentminusx');
970 $moreforfilter .= '</div>';
971 }
972
973
974 $parameters = array();
975 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
976 if (empty($reshook)) {
977 $moreforfilter .= $hookmanager->resPrint;
978 } else {
979 $moreforfilter = $hookmanager->resPrint;
980 }
981
982 if (!empty($moreforfilter)) {
983 print '<div class="liste_titre liste_titre_bydiv centpercent">';
984 print $moreforfilter;
985 print '</div>';
986 }
987
988 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
989 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
990 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
991
992 if (GETPOSTINT('autoselectall')) {
993 $selectedfields .= '<script>';
994 $selectedfields .= ' $(document).ready(function() {';
995 $selectedfields .= ' console.log("Autoclick on checkforselects");';
996 $selectedfields .= ' $("#checkforselects").click();';
997 $selectedfields .= ' $("#massaction").val("createbills").change();';
998 $selectedfields .= ' });';
999 $selectedfields .= '</script>';
1000 }
1001
1002 print '<div class="div-table-responsive">';
1003 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1004
1005 print '<tr class="liste_titre_filter">';
1006
1007 // Action column
1008 if (getDolGlobalInt('MAIN_CHECKBOX_LEFT_COLUMN')) {
1009 print '<td class="liste_titre" align="middle">';
1010 $searchpicto = $form->showFilterButtons('left');
1011 print $searchpicto;
1012 print '</td>';
1013 }
1014 // ID
1015 if (!empty($arrayfields['rowid']['checked'])) {
1016 print '<td class="liste_titre" data-key="id">';
1017 print '<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dol_escape_htmltag($search_id).'">';
1018 print '</td>';
1019 }
1020 // Détail commande
1021 if (!empty($arrayfields['pr.ref']['checked'])) {
1022 print '<td class="liste_titre">';
1023 print '<input class="flat" size="6" type="text" name="search_refProduct" value="'.dol_escape_htmltag($search_refProduct).'">';
1024 print '</td>';
1025 }
1026 // Product Description
1027 if (!empty($arrayfields['pr.desc']['checked'])) {
1028 print '<td class="liste_titre">';
1029 print '<input class="flat" size="6" type="text" name="search_descProduct" value="'.dol_escape_htmltag($search_descProduct).'">';
1030 print '</td>';
1031 }
1032 // Product QtyOrdered
1033 if (!empty($arrayfields['cdet.qty']['checked'])) {
1034 print '<td class="liste_titre"></td>';
1035 }
1036
1037 // Ref
1038 if (!empty($arrayfields['c.ref']['checked'])) {
1039 print '<td class="liste_titre">';
1040 print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
1041 print '</td>';
1042 }
1043 // Ref customer
1044 if (!empty($arrayfields['c.ref_client']['checked'])) {
1045 print '<td class="liste_titre" align="left">';
1046 print '<input class="flat" type="text" size="6" name="search_ref_customer" value="'.dol_escape_htmltag($search_ref_customer).'">';
1047 print '</td>';
1048 }
1049 // Project ref
1050 if (!empty($arrayfields['p.ref']['checked'])) {
1051 print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>';
1052 }
1053 // Project title
1054 if (!empty($arrayfields['p.title']['checked'])) {
1055 print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project" value="'.dol_escape_htmltag($search_project).'"></td>';
1056 }
1057 // Thirpdarty
1058 if (!empty($arrayfields['s.nom']['checked'])) {
1059 print '<td class="liste_titre" align="left">';
1060 print '<input class="flat maxwidth100" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
1061 print '</td>';
1062 }
1063 // Alias
1064 if (!empty($arrayfields['s.name_alias']['checked'])) {
1065 print '<td class="liste_titre" align="left">';
1066 print '<input class="flat maxwidth100" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).'">';
1067 print '</td>';
1068 }
1069 // Town
1070 if (!empty($arrayfields['s.town']['checked'])) {
1071 print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>';
1072 }
1073 // Zip
1074 if (!empty($arrayfields['s.zip']['checked'])) {
1075 print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>';
1076 }
1077 // State
1078 if (!empty($arrayfields['state.nom']['checked'])) {
1079 print '<td class="liste_titre">';
1080 print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
1081 print '</td>';
1082 }
1083 // Country
1084 if (!empty($arrayfields['country.code_iso']['checked'])) {
1085 print '<td class="liste_titre" align="center">';
1086 print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
1087 print '</td>';
1088 }
1089 // Company type
1090 if (!empty($arrayfields['typent.code']['checked'])) {
1091 print '<td class="liste_titre maxwidthonsmartphone" align="center">';
1092 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);
1093 print '</td>';
1094 }
1095 // Date order
1096 if (!empty($arrayfields['c.date_commande']['checked'])) {
1097 print '<td class="liste_titre center">';
1098 print '<div class="nowrapfordate">';
1099 print $form->selectDate($search_dateorder_start ? $search_dateorder_start : -1, 'search_dateorder_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1100 print '</div>';
1101 print '<div class="nowrapfordate">';
1102 print $form->selectDate($search_dateorder_end ? $search_dateorder_end : -1, 'search_dateorder_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1103 print '</div>';
1104 print '</td>';
1105 }
1106 if (!empty($arrayfields['c.date_delivery']['checked'])) {
1107 print '<td class="liste_titre center">';
1108 print '<div class="nowrapfordate">';
1109 print $form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1, 'search_datedelivery_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1110 print '</div>';
1111 print '<div class="nowrapfordate">';
1112 print $form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1, 'search_datedelivery_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1113 print '</div>';
1114 print '</td>';
1115 }
1116 // Shipping Method
1117 if (!empty($arrayfields['c.fk_shipping_method']['checked'])) {
1118 print '<td class="liste_titre">';
1119 $form->selectShippingMethod($search_fk_shipping_method, 'search_fk_shipping_method', '', 1, '', 1);
1120 print '</td>';
1121 }
1122 // Payment term
1123 if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) {
1124 print '<td class="liste_titre">';
1125 print $form->getSelectConditionsPaiements($search_fk_cond_reglement, 'search_fk_cond_reglement', 1, 1, 1);
1126 print '</td>';
1127 }
1128 // Payment mode
1129 if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) {
1130 print '<td class="liste_titre">';
1131 $form->select_types_paiements($search_fk_mode_reglement, 'search_fk_mode_reglement', '', 0, 1, 1, 0, -1);
1132 print '</td>';
1133 }
1134 // Channel
1135 if (!empty($arrayfields['c.fk_input_reason']['checked'])) {
1136 print '<td class="liste_titre">';
1137 $form->selectInputReason($search_fk_input_reason, 'search_fk_input_reason', '', 1, '', 1);
1138 print '</td>';
1139 }
1140 if (!empty($arrayfields['cdet.total_ht']['checked'])) {
1141 // Amount
1142 print '<td class="liste_titre right">';
1143 print '<input class="flat" type="text" size="4" name="search_total_ht" value="'.dol_escape_htmltag($search_total_ht).'">';
1144 print '</td>';
1145 }
1146 if (!empty($arrayfields['c.total_vat']['checked'])) {
1147 // Amount
1148 print '<td class="liste_titre right">';
1149 print '<input class="flat" type="text" size="4" name="search_total_vat" value="'.dol_escape_htmltag($search_total_vat).'">';
1150 print '</td>';
1151 }
1152 if (!empty($arrayfields['cdet.total_ttc']['checked'])) {
1153 // Amount
1154 print '<td class="liste_titre right">';
1155 print '<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.'">';
1156 print '</td>';
1157 }
1158 if (!empty($arrayfields['c.fk_warehouse']['checked'])) {
1159 // Warehouse
1160 print '<td class="liste_titre right"></td>';
1161 }
1162 if (!empty($arrayfields['c.multicurrency_code']['checked'])) {
1163 // Currency
1164 print '<td class="liste_titre">';
1165 print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1);
1166 print '</td>';
1167 }
1168 if (!empty($arrayfields['c.multicurrency_tx']['checked'])) {
1169 // Currency rate
1170 print '<td class="liste_titre">';
1171 print '<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).'">';
1172 print '</td>';
1173 }
1174 if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) {
1175 // Amount
1176 print '<td class="liste_titre right">';
1177 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).'">';
1178 print '</td>';
1179 }
1180 if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) {
1181 // Amount VAT
1182 print '<td class="liste_titre right">';
1183 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).'">';
1184 print '</td>';
1185 }
1186 if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) {
1187 // Amount
1188 print '<td class="liste_titre right">';
1189 print '<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).'">';
1190 print '</td>';
1191 }
1192 if (!empty($arrayfields['u.login']['checked'])) {
1193 // Author
1194 print '<td class="liste_titre" align="center">';
1195 print '<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
1196 print '</td>';
1197 }
1198 if (!empty($arrayfields['sale_representative']['checked'])) {
1199 print '<td class="liste_titre"></td>';
1200 }
1201 if (!empty($arrayfields['total_pa']['checked'])) {
1202 print '<td class="liste_titre right">';
1203 print '</td>';
1204 }
1205 if (!empty($arrayfields['total_margin']['checked'])) {
1206 print '<td class="liste_titre right">';
1207 print '</td>';
1208 }
1209 if (!empty($arrayfields['total_margin_rate']['checked'])) {
1210 print '<td class="liste_titre right">';
1211 print '</td>';
1212 }
1213 if (!empty($arrayfields['total_mark_rate']['checked'])) {
1214 print '<td class="liste_titre right">';
1215 print '</td>';
1216 }
1217 // Extra fields
1218 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1219 // Fields from hook
1220 $parameters = array('arrayfields' => $arrayfields);
1221 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
1222 print $hookmanager->resPrint;
1223 // Date creation
1224 if (!empty($arrayfields['c.datec']['checked'])) {
1225 print '<td class="liste_titre">';
1226 print '</td>';
1227 }
1228 // Date modification
1229 if (!empty($arrayfields['c.tms']['checked'])) {
1230 print '<td class="liste_titre">';
1231 print '</td>';
1232 }
1233 // Date cloture
1234 if (!empty($arrayfields['c.date_cloture']['checked'])) {
1235 print '<td class="liste_titre center">';
1236 print '<div class="nowrapfordate">';
1237 print $form->selectDate($search_datecloture_start ? $search_datecloture_start : -1, 'search_datecloture_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1238 print '</div>';
1239 print '<div class="nowrapfordate">';
1240 print $form->selectDate($search_datecloture_end ? $search_datecloture_end : -1, 'search_datecloture_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1241 print '</div>';
1242 print '</td>';
1243 }
1244 // Note public
1245 if (!empty($arrayfields['c.note_public']['checked'])) {
1246 print '<td class="liste_titre">';
1247 print '</td>';
1248 }
1249 // Note private
1250 if (!empty($arrayfields['c.note_private']['checked'])) {
1251 print '<td class="liste_titre">';
1252 print '</td>';
1253 }
1254 // Shippable
1255 if (!empty($arrayfields['shippable']['checked'])) {
1256 print '<td class="liste_titre maxwidthonsmartphone" align="center">';
1257 //print $form->selectyesno('search_shippable', $search_shippable, 1, 0, 1, 1);
1258 if (getDolGlobalString('ORDER_SHIPABLE_STATUS_DISABLED_BY_DEFAULT')) {
1259 print '<input type="checkbox" name="show_shippable_command" value="1"'.($show_shippable_command ? ' checked' : '').'>';
1260 print $langs->trans('ShowShippableStatus');
1261 } else {
1262 $show_shippable_command = 1;
1263 }
1264 print '</td>';
1265 }
1266 // Status billed
1267 if (!empty($arrayfields['c.facture']['checked'])) {
1268 print '<td class="liste_titre maxwidthonsmartphone" align="center">';
1269 print $form->selectyesno('search_billed', $search_billed, 1, 0, 1, 1);
1270 print '</td>';
1271 }
1272 // Import key
1273 if (!empty($arrayfields['c.import_key']['checked'])) {
1274 print '<td class="liste_titre maxwidthonsmartphone" align="center">';
1275 print '</td>';
1276 }
1277 // Status
1278 if (!empty($arrayfields['c.fk_statut']['checked'])) {
1279 print '<td class="liste_titre maxwidthonsmartphone center">';
1280 $liststatus = array(
1281 Commande::STATUS_DRAFT => $langs->trans("StatusOrderDraftShort"),
1282 Commande::STATUS_VALIDATED => $langs->trans("StatusOrderValidated"),
1283 Commande::STATUS_SHIPMENTONPROCESS => $langs->trans("StatusOrderSentShort"),
1284 -2 => $langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"),
1285 -3 => $langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"),
1286 Commande::STATUS_CLOSED => $langs->trans("StatusOrderDelivered"),
1287 Commande::STATUS_CANCELED => $langs->trans("StatusOrderCanceledShort")
1288 );
1289 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1290 print $form->selectarray('search_status', $liststatus, $search_status, -5, 0, 0, '', 0, 0, 0, '', 'maxwidth125', 1);
1291 print '</td>';
1292 }
1293 // Action column
1294 if (!getDolGlobalInt('MAIN_CHECKBOX_LEFT_COLUMN')) {
1295 print '<td class="liste_titre" align="middle">';
1296 $searchpicto = $form->showFilterButtons();
1297 print $searchpicto;
1298 print '</td>';
1299 }
1300 print "</tr>\n";
1301
1302 // Fields title
1303 print '<tr class="liste_titre">';
1304
1305 if (getDolGlobalInt('MAIN_CHECKBOX_LEFT_COLUMN')) {
1306 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center ');
1307 }
1308
1309 // Détail commande
1310 if (!empty($arrayfields['rowid']['checked'])) {
1311 // @phan-suppress-next-line PhanTypeInvalidDimOffset
1312 print_liste_field_titre($arrayfields['rowid']['label'], $_SERVER["PHP_SELF"], 'rowid', '', $param, '', $sortfield, $sortorder);
1313 '@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
1314 }
1315 if (!empty($arrayfields['pr.ref']['checked'])) {
1316 print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], 'pr.ref', '', $param, '', $sortfield, $sortorder);
1317 }
1318 if (!empty($arrayfields['pr.desc']['checked'])) {
1319 print_liste_field_titre($arrayfields['pr.desc']['label'], $_SERVER["PHP_SELF"], 'pr.desc', '', $param, '', $sortfield, $sortorder);
1320 }
1321 if (!empty($arrayfields['cdet.qty']['checked'])) {
1322 print_liste_field_titre($arrayfields['cdet.qty']['label'], $_SERVER["PHP_SELF"], 'cdet.qty', '', $param, '', $sortfield, $sortorder);
1323 }
1324
1325 if (!empty($arrayfields['c.ref']['checked'])) {
1326 print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], 'c.ref', '', $param, '', $sortfield, $sortorder);
1327 }
1328 if (!empty($arrayfields['c.ref_client']['checked'])) {
1329 print_liste_field_titre($arrayfields['c.ref_client']['label'], $_SERVER["PHP_SELF"], 'c.ref_client', '', $param, '', $sortfield, $sortorder);
1330 }
1331 if (!empty($arrayfields['p.ref']['checked'])) {
1332 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
1333 }
1334 if (!empty($arrayfields['p.title']['checked'])) {
1335 print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, '', $sortfield, $sortorder);
1336 }
1337 if (!empty($arrayfields['s.nom']['checked'])) {
1338 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
1339 }
1340 if (!empty($arrayfields['s.name_alias']['checked'])) {
1341 print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $param, '', $sortfield, $sortorder);
1342 }
1343 if (!empty($arrayfields['s.town']['checked'])) {
1344 print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
1345 }
1346 if (!empty($arrayfields['s.zip']['checked'])) {
1347 print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
1348 }
1349 if (!empty($arrayfields['state.nom']['checked'])) {
1350 print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
1351 }
1352 if (!empty($arrayfields['country.code_iso']['checked'])) {
1353 print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
1354 }
1355 if (!empty($arrayfields['typent.code']['checked'])) {
1356 print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
1357 }
1358 if (!empty($arrayfields['c.date_commande']['checked'])) {
1359 print_liste_field_titre($arrayfields['c.date_commande']['label'], $_SERVER["PHP_SELF"], 'c.date_commande', '', $param, '', $sortfield, $sortorder, 'center ');
1360 }
1361 if (!empty($arrayfields['c.date_delivery']['checked'])) {
1362 print_liste_field_titre($arrayfields['c.date_delivery']['label'], $_SERVER["PHP_SELF"], 'c.date_livraison', '', $param, '', $sortfield, $sortorder, 'center ');
1363 }
1364 if (!empty($arrayfields['c.fk_shipping_method']['checked'])) {
1365 print_liste_field_titre($arrayfields['c.fk_shipping_method']['label'], $_SERVER["PHP_SELF"], "c.fk_shipping_method", "", $param, '', $sortfield, $sortorder);
1366 }
1367 if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) {
1368 print_liste_field_titre($arrayfields['c.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_cond_reglement", "", $param, '', $sortfield, $sortorder);
1369 }
1370 if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) {
1371 print_liste_field_titre($arrayfields['c.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_mode_reglement", "", $param, '', $sortfield, $sortorder);
1372 }
1373 if (!empty($arrayfields['c.fk_input_reason']['checked'])) {
1374 print_liste_field_titre($arrayfields['c.fk_input_reason']['label'], $_SERVER["PHP_SELF"], "c.fk_input_reason", "", $param, '', $sortfield, $sortorder);
1375 }
1376 if (!empty($arrayfields['cdet.total_ht']['checked'])) {
1377 print_liste_field_titre($arrayfields['cdet.total_ht']['label'], $_SERVER["PHP_SELF"], 'cdet.total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
1378 }
1379 if (!empty($arrayfields['c.total_vat']['checked'])) {
1380 print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'cdet.total_tva', '', $param, '', $sortfield, $sortorder, 'right ');
1381 }
1382 if (!empty($arrayfields['cdet.total_ttc']['checked'])) {
1383 print_liste_field_titre($arrayfields['cdet.total_ttc']['label'], $_SERVER["PHP_SELF"], 'cdet.total_ttc', '', $param, '', $sortfield, $sortorder, 'right ');
1384 }
1385 if (!empty($arrayfields['c.fk_warehouse']['checked'])) {
1386 print_liste_field_titre($arrayfields['c.fk_warehouse']['label'], "", '', '', $param, '', $sortfield, $sortorder);
1387 }
1388 if (!empty($arrayfields['c.multicurrency_code']['checked'])) {
1389 print_liste_field_titre($arrayfields['c.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_code', '', $param, '', $sortfield, $sortorder);
1390 }
1391 if (!empty($arrayfields['c.multicurrency_tx']['checked'])) {
1392 print_liste_field_titre($arrayfields['c.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_tx', '', $param, '', $sortfield, $sortorder);
1393 }
1394 if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) {
1395 print_liste_field_titre($arrayfields['c.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
1396 }
1397 if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) {
1398 print_liste_field_titre($arrayfields['c.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder);
1399 }
1400 if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) {
1401 print_liste_field_titre($arrayfields['c.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
1402 }
1403 if (!empty($arrayfields['u.login']['checked'])) {
1404 print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder);
1405 }
1406 if (!empty($arrayfields['sale_representative']['checked'])) {
1407 print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder);
1408 }
1409 if (!empty($arrayfields['total_pa']['checked'])) {
1410 print_liste_field_titre($arrayfields['total_pa']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1411 }
1412 if (!empty($arrayfields['total_margin']['checked'])) {
1413 print_liste_field_titre($arrayfields['total_margin']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1414 }
1415 if (!empty($arrayfields['total_margin_rate']['checked'])) {
1416 print_liste_field_titre($arrayfields['total_margin_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1417 }
1418 if (!empty($arrayfields['total_mark_rate']['checked'])) {
1419 print_liste_field_titre($arrayfields['total_mark_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
1420 }
1421
1422 $totalarray = array(
1423 'nbfield' => 0,
1424 'val' => array(
1425 'cdet.total_ht' => 0,
1426 'cdet.total_tva' => 0,
1427 'cdet.total_ttc' => 0,
1428 ),
1429 'pos' => array(),
1430 );
1431 // Extra fields
1432 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1433 // Hook fields
1434 $parameters = array(
1435 'arrayfields' => $arrayfields,
1436 'param' => $param,
1437 'sortfield' => $sortfield,
1438 'sortorder' => $sortorder,
1439 'totalarray' => &$totalarray,
1440 );
1441 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
1442 print $hookmanager->resPrint;
1443 if (!empty($arrayfields['c.datec']['checked'])) {
1444 print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1445 }
1446 if (!empty($arrayfields['c.tms']['checked'])) {
1447 print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1448 }
1449 if (!empty($arrayfields['c.date_cloture']['checked'])) {
1450 print_liste_field_titre($arrayfields['c.date_cloture']['label'], $_SERVER["PHP_SELF"], "c.date_cloture", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1451 }
1452 if (!empty($arrayfields['c.note_public']['checked'])) {
1453 print_liste_field_titre($arrayfields['c.note_public']['label'], $_SERVER["PHP_SELF"], "c.note_public", "", $param, '', $sortfield, $sortorder, 'right ');
1454 }
1455 if (!empty($arrayfields['c.note_private']['checked'])) {
1456 print_liste_field_titre($arrayfields['c.note_private']['label'], $_SERVER["PHP_SELF"], "c.note_private", "", $param, '', $sortfield, $sortorder, 'right ');
1457 }
1458 if (!empty($arrayfields['shippable']['checked'])) {
1459 print_liste_field_titre($arrayfields['shippable']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
1460 }
1461 if (!empty($arrayfields['c.facture']['checked'])) {
1462 print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center ');
1463 }
1464 if (!empty($arrayfields['c.import_key']['checked'])) {
1465 print_liste_field_titre($arrayfields['c.import_key']['label'], $_SERVER["PHP_SELF"], "c.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1466 }
1467 if (!empty($arrayfields['c.fk_statut']['checked'])) {
1468 print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
1469 }
1470 if (!getDolGlobalInt('MAIN_CHECKBOX_LEFT_COLUMN')) {
1471 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center ');
1472 }
1473 print '</tr>'."\n";
1474
1475 $total = 0;
1476 $subtotal = 0;
1477 $productstat_cache = array();
1478 '@phan-var-force array<int,array{stats_order_customer?:float|int,stats_order_supplier?:float|int}> $product_sdtat_cache';
1479 $productstat_cachevirtual = array();
1480 $getNomUrl_cache = array();
1481
1482 $generic_commande = new Commande($db);
1483 $generic_product = new Product($db);
1484 $userstatic = new User($db);
1485 $i = 0;
1486
1487 $with_margin_info = false;
1488 if (isModEnabled('margin') && (
1489 !empty($arrayfields['total_pa']['checked'])
1490 || !empty($arrayfields['total_margin']['checked'])
1491 || !empty($arrayfields['total_margin_rate']['checked'])
1492 || !empty($arrayfields['total_mark_rate']['checked'])
1493 )
1494 ) {
1495 $with_margin_info = true;
1496 }
1497 $total_ht = 0;
1498 $total_margin = 0;
1499
1500
1501 // Détail commande
1502 $totalqty = 0;
1503 $oldref = null;
1504
1505 $totalarray = array();
1506 $totalarray['nbfield'] = 0;
1507 $subtotalarray = array();
1508 $subtotalarray['nbfield'] = 0;
1509 $totalarray['val']['cdet.total_tva'] = 0;
1510 $totalarray['val']['cdet.total_ttc'] = 0;
1511 $imaxinloop = ($limit ? min($num, $limit) : $num);
1512 while ($i < $imaxinloop) {
1513 $obj = $db->fetch_object($resql);
1514
1515 $notshippable = 0;
1516 $warning = 0;
1517 $text_info = '';
1518 $text_warning = '';
1519 $nbprod = 0;
1520
1521 // Print SubTotal
1522 if (empty($i)) {
1523 $oldref = $obj->product_ref;
1524 }
1525 if ($oldref != $obj->product_ref && $sortfield == 'pr.ref') {
1526 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_subtotal.tpl.php';
1527 $oldref = $obj->product_ref;
1528 }
1529
1530 $companystatic->id = $obj->socid;
1531 $companystatic->name = $obj->name;
1532 $companystatic->name_alias = $obj->alias;
1533 $companystatic->client = $obj->client;
1534 $companystatic->code_client = $obj->code_client;
1535 $companystatic->email = $obj->email;
1536 $companystatic->phone = $obj->phone;
1537 $companystatic->address = $obj->address;
1538 $companystatic->zip = $obj->zip;
1539 $companystatic->town = $obj->town;
1540 $companystatic->country_code = $obj->country_code;
1541 if (!isset($getNomUrl_cache[$obj->socid])) {
1542 $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer');
1543 }
1544
1545 $generic_commande->id = $obj->c_rowid;
1546 $generic_commande->ref = $obj->ref;
1547 $generic_commande->statut = $obj->fk_statut;
1548 $generic_commande->billed = $obj->billed;
1549 $generic_commande->date = $db->jdate($obj->date_commande);
1550 $generic_commande->delivery_date = $db->jdate($obj->date_delivery);
1551 $generic_commande->ref_client = $obj->ref_client;
1552 $generic_commande->total_ht = $obj->c_total_ht;
1553 $generic_commande->total_tva = $obj->c_total_tva;
1554 $generic_commande->total_ttc = $obj->c_total_ttc;
1555 $generic_commande->note_public = $obj->note_public;
1556 $generic_commande->note_private = $obj->note_private;
1557
1558 $projectstatic->id = $obj->project_id;
1559 $projectstatic->ref = $obj->project_ref;
1560 $projectstatic->title = $obj->project_label;
1561
1562 $marginInfo = array();
1563 if ($with_margin_info) {
1564 $generic_commande->fetch_lines();
1565 $marginInfo = $formmargin->getMarginInfosArray($generic_commande);
1566 $total_ht += $obj->total_ht;
1567 $total_margin += $marginInfo['total_margin'];
1568 }
1569
1570 print '<tr class="oddeven">';
1571
1572 // Action column
1573 if (getDolGlobalInt('MAIN_CHECKBOX_LEFT_COLUMN')) {
1574 print '<td class="nowrap center">';
1575 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1576 $selected = 0;
1577 if (in_array($obj->rowid, $arrayofselected)) {
1578 $selected = 1;
1579 }
1580 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1581 }
1582 print '</td>';
1583 if (!$i) {
1584 $totalarray['nbfield']++;
1585 }
1586 }
1587
1588 // Détail commande
1589 // ID
1590 if (!empty($arrayfields['rowid']['checked'])) {
1591 print '<td class="nowrap right">'.$obj->rowid.'</td>';
1592 if (!$i) {
1593 $totalarray['nbfield']++;
1594 }
1595 }
1596
1597 // Product Ref
1598 if (!empty($arrayfields['pr.ref']['checked'])) {
1599 if (!empty($obj->product_rowid)) {
1600 $generic_product->id = $obj->product_rowid;
1601 $generic_product->ref = $obj->product_ref;
1602 $generic_product->label = $obj->product_label;
1603 $generic_product->status = $obj->product_status;
1604 $generic_product->status_buy = $obj->product_status_buy;
1605 $generic_product->status_batch = $obj->product_batch;
1606 $generic_product->barcode = $obj->product_barcode;
1607 print '<td class="nowrap tdoverflowmax200">'.$generic_product->getNomUrl(1).'</td>';
1608 } else {
1609 print '<td class="nowrap tdoverflowmax200">Ligne libre</td>';
1610 }
1611 if (!$i) {
1612 $totalarray['nbfield']++;
1613 }
1614 }
1615 // Product Description
1616 if (!empty($arrayfields['pr.desc']['checked'])) {
1617 // print '<td class="nowrap tdoverflowmax200">'.$obj->description.'</td>';
1618 !empty($obj->product_label) ? $labelproduct = $obj->product_label : $labelproduct = $obj->description;
1619 print '<td class="nowrap tdoverflowmax200">';
1620 print dolGetFirstLineOfText(dolPrintHTML($labelproduct), 5);
1621 print '</td>';
1622
1623 if (!$i) {
1624 $totalarray['nbfield']++;
1625 }
1626 }
1627 // Product QtyOrdered
1628 if (!empty($arrayfields['cdet.qty']['checked'])) {
1629 print '<td class="nowrap right">'.$obj->qty.'</td>';
1630 if (isset($totalarray['val']['cdet.qty']) || isset($subtotalarray['val']['cdet.qty'])) {
1631 $totalarray['val']['cdet.qty'] += $obj->qty;
1632 $subtotalarray['val']['cdet.qty'] += $obj->qty;
1633 } else {
1634 $totalarray['val']['cdet.qty'] = $obj->qty;
1635 $subtotalarray['val']['cdet.qty'] = $obj->qty;
1636 }
1637 if (!$i) {
1638 $totalarray['nbfield']++;
1639 }
1640 if (!$i) {
1641 $totalarray['pos'][$totalarray['nbfield']] = 'cdet.qty';
1642 $totalarray['pos'][$subtotalarray['nbfield']] = 'cdet.qty';
1643 }
1644 }
1645
1646 // Ref
1647 if (!empty($arrayfields['c.ref']['checked'])) {
1648 print '<td class="nowraponall">';
1649 print $generic_commande->getNomUrl(1, ($search_status != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1);
1650
1651 $filename = dol_sanitizeFileName($obj->ref);
1652 $filedir = $conf->commande->multidir_output[$conf->entity].'/'.dol_sanitizeFileName($obj->ref);
1653 $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
1654 print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
1655
1656 print '</td>';
1657 if (!$i) {
1658 $totalarray['nbfield']++;
1659 }
1660 }
1661
1662 // Ref customer
1663 if (!empty($arrayfields['c.ref_client']['checked'])) {
1664 print '<td class="nowrap tdoverflowmax200">'.$obj->ref_client.'</td>';
1665 if (!$i) {
1666 $totalarray['nbfield']++;
1667 }
1668 }
1669
1670 // Project ref
1671 if (!empty($arrayfields['p.ref']['checked'])) {
1672 print '<td class="nowrap">';
1673 if ($obj->project_id > 0) {
1674 print $projectstatic->getNomUrl(1);
1675 }
1676 print '</td>';
1677 if (!$i) {
1678 $totalarray['nbfield']++;
1679 }
1680 }
1681
1682 // Project label
1683 if (!empty($arrayfields['p.title']['checked'])) {
1684 print '<td class="nowrap">';
1685 if ($obj->project_id > 0) {
1686 print $projectstatic->title;
1687 }
1688 print '</td>';
1689 if (!$i) {
1690 $totalarray['nbfield']++;
1691 }
1692 }
1693
1694 // Third party
1695 if (!empty($arrayfields['s.nom']['checked'])) {
1696 print '<td class="tdoverflowmax150">';
1697 print $getNomUrl_cache[$obj->socid];
1698
1699 // If module invoices enabled and user with invoice creation permissions
1700 if (isModEnabled('invoice') && getDolGlobalString('ORDER_BILLING_ALL_CUSTOMER')) {
1701 if ($user->hasRight('facture', 'creer')) {
1702 if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) {
1703 print '&nbsp;<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$companystatic->id.'&search_billed=0&autoselectall=1">';
1704 print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').'</a>';
1705 }
1706 }
1707 }
1708 print '</td>';
1709 if (!$i) {
1710 $totalarray['nbfield']++;
1711 }
1712 }
1713 // Alias name
1714 if (!empty($arrayfields['s.name_alias']['checked'])) {
1715 print '<td class="nocellnopadd">';
1716 print $obj->alias;
1717 print '</td>';
1718 if (!$i) {
1719 $totalarray['nbfield']++;
1720 }
1721 }
1722 // Town
1723 if (!empty($arrayfields['s.town']['checked'])) {
1724 print '<td class="nocellnopadd">';
1725 print $obj->town;
1726 print '</td>';
1727 if (!$i) {
1728 $totalarray['nbfield']++;
1729 }
1730 }
1731 // Zip
1732 if (!empty($arrayfields['s.zip']['checked'])) {
1733 print '<td class="nocellnopadd">';
1734 print $obj->zip;
1735 print '</td>';
1736 if (!$i) {
1737 $totalarray['nbfield']++;
1738 }
1739 }
1740 // State
1741 if (!empty($arrayfields['state.nom']['checked'])) {
1742 print "<td>".$obj->state_name."</td>\n";
1743 if (!$i) {
1744 $totalarray['nbfield']++;
1745 }
1746 }
1747 // Country
1748 if (!empty($arrayfields['country.code_iso']['checked'])) {
1749 print '<td class="center">';
1750 $tmparray = getCountry($obj->fk_pays, 'all');
1751 print $tmparray['label'];
1752 print '</td>';
1753 if (!$i) {
1754 $totalarray['nbfield']++;
1755 }
1756 }
1757 // Type ent
1758 if (!empty($arrayfields['typent.code']['checked'])) {
1759 print '<td class="center">';
1760 if (empty($typenArray)) {
1761 $typenArray = $formcompany->typent_array(1);
1762 }
1763 print $typenArray[$obj->typent_code];
1764 print '</td>';
1765 if (!$i) {
1766 $totalarray['nbfield']++;
1767 }
1768 }
1769
1770 // Order date
1771 if (!empty($arrayfields['c.date_commande']['checked'])) {
1772 print '<td class="center">';
1773 print dol_print_date($db->jdate($obj->date_commande), 'day');
1774 // Warning late icon and note
1775 if ($generic_commande->hasDelay()) {
1776 print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning");
1777 }
1778 print '</td>';
1779 if (!$i) {
1780 $totalarray['nbfield']++;
1781 }
1782 }
1783 // Plannned date of delivery
1784 if (!empty($arrayfields['c.date_delivery']['checked'])) {
1785 print '<td class="center" title="'.$langs->trans($arrayfields['c.date_delivery']['label']).': '.dol_print_date($db->jdate($obj->date_delivery), 'dayhour').'">';
1786 print dol_print_date($db->jdate($obj->date_delivery), 'day');
1787 print '</td>';
1788 if (!$i) {
1789 $totalarray['nbfield']++;
1790 }
1791 }
1792 // Shipping Method
1793 if (!empty($arrayfields['c.fk_shipping_method']['checked'])) {
1794 print '<td>';
1795 $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1);
1796 print '</td>';
1797 if (!$i) {
1798 $totalarray['nbfield']++;
1799 }
1800 }
1801 // Payment terms
1802 if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) {
1803 print '<td>';
1804 $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent);
1805 print '</td>';
1806 if (!$i) {
1807 $totalarray['nbfield']++;
1808 }
1809 }
1810 // Payment mode
1811 if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) {
1812 print '<td>';
1813 $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1);
1814 print '</td>';
1815 if (!$i) {
1816 $totalarray['nbfield']++;
1817 }
1818 }
1819 // Channel
1820 if (!empty($arrayfields['c.fk_input_reason']['checked'])) {
1821 print '<td>';
1822 $form->formInputReason($_SERVER['PHP_SELF'], $obj->fk_input_reason, 'none', 0);
1823 print '</td>';
1824 if (!$i) {
1825 $totalarray['nbfield']++;
1826 }
1827 }
1828 // Amount HT
1829 if (!empty($arrayfields['cdet.total_ht']['checked'])) {
1830 print '<td class="nowrap right"><span class="amount">'.price($obj->total_ht)."</span></td>\n";
1831 if (!$i) {
1832 $totalarray['nbfield']++;
1833 }
1834 if (!$i) {
1835 $totalarray['pos'][$totalarray['nbfield']] = 'cdet.total_ht';
1836 $totalarray['pos'][$subtotalarray['nbfield']] = 'cdet.total_ht';
1837 }
1838 if (isset($totalarray['val']['cdet.total_ht']) || isset($subtotalarray['val']['cdet.total_ht'])) {
1839 $totalarray['val']['cdet.total_ht'] += $obj->total_ht;
1840 $subtotalarray['val']['cdet.total_ht'] += $obj->total_ht;
1841 } else {
1842 $totalarray['val']['cdet.total_ht'] = $obj->total_ht;
1843 $subtotalarray['val']['cdet.total_ht'] = $obj->total_ht;
1844 }
1845 }
1846 // Amount VAT
1847 if (!empty($arrayfields['c.total_vat']['checked'])) {
1848 print '<td class="nowrap right"><span class="amount">'.price($obj->total_tva)."</span></td>\n";
1849 if (!$i) {
1850 $totalarray['nbfield']++;
1851 }
1852 if (!$i) {
1853 $totalarray['pos'][$totalarray['nbfield']] = 'cdet.total_tva';
1854 $totalarray['pos'][$subtotalarray['nbfield']] = 'cdet.total_tva';
1855 }
1856 $totalarray['val']['cdet.total_tva'] += $obj->total_tva;
1857 $subtotalarray['val']['cdet.total_tva'] += $obj->total_tva;
1858 }
1859 // Amount TTC
1860 if (!empty($arrayfields['cdet.total_ttc']['checked'])) {
1861 print '<td class="nowrap right"><span class="amount">'.price($obj->total_ttc)."</span></td>\n";
1862 if (!$i) {
1863 $totalarray['nbfield']++;
1864 }
1865 if (!$i) {
1866 $totalarray['pos'][$totalarray['nbfield']] = 'cdet.total_ttc';
1867 $subtotalarray['pos'][$totalarray['nbfield']] = 'cdet.total_ttc';
1868 }
1869 $totalarray['val']['cdet.total_ttc'] += $obj->total_ttc;
1870 $subtotalarray['val']['cdet.total_ttc'] += $obj->total_ttc;
1871 }
1872 // Warehouse
1873 if (!empty($arrayfields['c.fk_warehouse']['checked'])) {
1874 print '<td class="nowrap">';
1875 if ($obj->warehouse > 0) {
1876 print img_picto('', 'stock', 'class="paddingrightonly"');
1877 }
1878 $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'], $obj->warehouse, 'none');
1879 print "</td>\n";
1880 if (!$i) {
1881 $totalarray['nbfield']++;
1882 }
1883 }
1884 // Currency
1885 if (!empty($arrayfields['c.multicurrency_code']['checked'])) {
1886 print '<td class="nowrap">'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."</td>\n";
1887 if (!$i) {
1888 $totalarray['nbfield']++;
1889 }
1890 }
1891
1892 // Currency rate
1893 if (!empty($arrayfields['c.multicurrency_tx']['checked'])) {
1894 print '<td class="nowrap">';
1895 $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
1896 print "</td>\n";
1897 if (!$i) {
1898 $totalarray['nbfield']++;
1899 }
1900 }
1901 // Amount HT
1902 if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) {
1903 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht)."</span></td>\n";
1904 if (!$i) {
1905 $totalarray['nbfield']++;
1906 }
1907 }
1908 // Amount VAT
1909 if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) {
1910 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat)."</span></td>\n";
1911 if (!$i) {
1912 $totalarray['nbfield']++;
1913 }
1914 }
1915 // Amount TTC
1916 if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) {
1917 print '<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc)."</span></td>\n";
1918 if (!$i) {
1919 $totalarray['nbfield']++;
1920 }
1921 }
1922
1923 $userstatic->id = $obj->fk_user_author;
1924 $userstatic->login = $obj->login;
1925 $userstatic->lastname = $obj->lastname;
1926 $userstatic->firstname = $obj->firstname;
1927 $userstatic->email = $obj->user_email;
1928 $userstatic->status = $obj->user_statut;
1929 $userstatic->entity = $obj->entity;
1930 $userstatic->photo = $obj->photo;
1931 $userstatic->office_phone = $obj->office_phone;
1932 $userstatic->office_fax = $obj->office_fax;
1933 $userstatic->user_mobile = $obj->user_mobile;
1934 $userstatic->job = $obj->job;
1935 $userstatic->gender = $obj->gender;
1936
1937 // Author
1938 if (!empty($arrayfields['u.login']['checked'])) {
1939 print '<td class="tdoverflowmax200">';
1940 if ($userstatic->id) {
1941 print $userstatic->getNomUrl(-1);
1942 } else {
1943 print '&nbsp;';
1944 }
1945 print "</td>\n";
1946 if (!$i) {
1947 $totalarray['nbfield']++;
1948 }
1949 }
1950
1951 if (!empty($arrayfields['sale_representative']['checked'])) {
1952 // Sales representatives
1953 print '<td>';
1954 if ($obj->socid > 0) {
1955 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
1956 if ($listsalesrepresentatives < 0) {
1957 dol_print_error($db);
1958 }
1959 $nbofsalesrepresentative = count($listsalesrepresentatives);
1960 if ($nbofsalesrepresentative > 6) {
1961 // We print only number
1962 print $nbofsalesrepresentative;
1963 } elseif ($nbofsalesrepresentative > 0) {
1964 $j = 0;
1965 foreach ($listsalesrepresentatives as $val) {
1966 $userstatic->id = $val['id'];
1967 $userstatic->lastname = $val['lastname'];
1968 $userstatic->firstname = $val['firstname'];
1969 $userstatic->email = $val['email'];
1970 $userstatic->status = $val['statut'];
1971 $userstatic->entity = $val['entity'];
1972 $userstatic->photo = $val['photo'];
1973 $userstatic->login = $val['login'];
1974 $userstatic->office_phone = $val['office_phone'];
1975 $userstatic->office_fax = $val['office_fax'];
1976 $userstatic->user_mobile = $val['user_mobile'];
1977 $userstatic->job = $val['job'];
1978 $userstatic->gender = $val['gender'];
1979 //print '<div class="float">':
1980 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2);
1981 $j++;
1982 if ($j < $nbofsalesrepresentative) {
1983 print ' ';
1984 }
1985 //print '</div>';
1986 }
1987 }
1988 //else print $langs->trans("NoSalesRepresentativeAffected");
1989 } else {
1990 print '&nbsp;';
1991 }
1992 print '</td>';
1993 if (!$i) {
1994 $totalarray['nbfield']++;
1995 }
1996 }
1997
1998 // Total buying or cost price
1999 if (!empty($arrayfields['total_pa']['checked'])) {
2000 print '<td class="right nowrap">'.price($marginInfo['pa_total']).'</td>';
2001 if (!$i) {
2002 $totalarray['nbfield']++;
2003 }
2004 }
2005 // Total margin
2006 if (!empty($arrayfields['total_margin']['checked'])) {
2007 print '<td class="right nowrap">'.price($marginInfo['total_margin']).'</td>';
2008 if (!$i) {
2009 $totalarray['nbfield']++;
2010 }
2011 if (!$i) {
2012 $totalarray['pos'][$totalarray['nbfield']] = 'total_margin';
2013 $totalarray['pos'][$subtotalarray['nbfield']] = 'total_margin';
2014 }
2015 $totalarray['val']['total_margin'] += $marginInfo['total_margin'];
2016 $subtotalarray['val']['total_margin'] += $marginInfo['total_margin'];
2017 }
2018 // Total margin rate
2019 if (!empty($arrayfields['total_margin_rate']['checked'])) {
2020 print '<td class="right nowrap">'.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], 0, '', 0, 0, 2).'%').'</td>';
2021 if (!$i) {
2022 $totalarray['nbfield']++;
2023 }
2024 }
2025 // Total mark rate
2026 if (!empty($arrayfields['total_mark_rate']['checked'])) {
2027 print '<td class="right nowrap">'.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], 0, '', 0, 0, 2).'%').'</td>';
2028 if (!$i) {
2029 $totalarray['nbfield']++;
2030 }
2031 if (!$i) {
2032 $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate';
2033 $totalarray['pos'][$subtotalarray['nbfield']] = 'total_mark_rate';
2034 }
2035 if ($i >= $imaxinloop - 1) {
2036 if (!empty($total_ht)) {
2037 $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT');
2038 $subtotalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT');
2039 } else {
2040 $totalarray['val']['total_mark_rate'] = '';
2041 $subtotalarray['val']['total_mark_rate'] = '';
2042 }
2043 }
2044 }
2045
2046 // Extra fields
2047 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
2048 // Fields from hook
2049 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
2050 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2051 print $hookmanager->resPrint;
2052
2053 // Date creation
2054 if (!empty($arrayfields['c.datec']['checked'])) {
2055 print '<td align="center" class="nowrap">';
2056 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
2057 print '</td>';
2058 if (!$i) {
2059 $totalarray['nbfield']++;
2060 }
2061 }
2062
2063 // Date modification
2064 if (!empty($arrayfields['c.tms']['checked'])) {
2065 print '<td align="center" class="nowrap">';
2066 print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser');
2067 print '</td>';
2068 if (!$i) {
2069 $totalarray['nbfield']++;
2070 }
2071 }
2072
2073 // Date cloture
2074 if (!empty($arrayfields['c.date_cloture']['checked'])) {
2075 print '<td align="center" class="nowrap">';
2076 print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser');
2077 print '</td>';
2078 if (!$i) {
2079 $totalarray['nbfield']++;
2080 }
2081 }
2082
2083 // Note public
2084 if (!empty($arrayfields['c.note_public']['checked'])) {
2085 print '<td class="sensiblehtmlcontent center">';
2086 print dolPrintHTML($obj->note_public);
2087 print '</td>';
2088 if (!$i) {
2089 $totalarray['nbfield']++;
2090 }
2091 }
2092
2093 // Note private
2094 if (!empty($arrayfields['c.note_private']['checked'])) {
2095 print '<td class="center">';
2096 print dolPrintHTML($obj->note_private);
2097 print '</td>';
2098 if (!$i) {
2099 $totalarray['nbfield']++;
2100 }
2101 }
2102
2103 // Show shippable Icon (this creates subloops, so may be slow)
2104 if (!empty($arrayfields['shippable']['checked'])) {
2105 print '<td class="center">';
2106 if (!empty($show_shippable_command) && isModEnabled('stock')) {
2107 $text_icon = '';
2108 if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) {
2109 $generic_commande->loadExpeditions(); // Load array ->expeditions
2110
2111 if (isset($generic_commande->expeditions[$obj->rowid])) {
2112 $reliquat = $obj->qty - $generic_commande->expeditions[$obj->rowid];
2113 } else {
2114 $reliquat = $obj->qty;
2115 }
2116 if ($obj->product_type == 0 && $obj->fk_product > 0) { // If line is a product and not a service
2117 $nbprod++; // order contains real products
2118 $generic_product->id = $obj->fk_product;
2119
2120 // Get local and virtual stock and store it into cache
2121 if (empty($productstat_cache[$obj->fk_product])) {
2122 $generic_product->load_stock('nobatch'); // ->load_virtual_stock() is already included into load_stock()
2123 $productstat_cache[$obj->fk_product]['stock_reel'] = $generic_product->stock_reel;
2124 $productstat_cachevirtual[$obj->fk_product]['stock_reel'] = $generic_product->stock_theorique;
2125 } else {
2126 $generic_product->stock_reel = $productstat_cache[$obj->fk_product]['stock_reel'];
2127 $generic_product->stock_theorique = $productstat_cachevirtual[$obj->fk_product]['stock_reel'];
2128 }
2129
2130 if ($reliquat > $generic_product->stock_reel) {
2131 $notshippable++;
2132 }
2133 if (!getDolGlobalString('SHIPPABLE_ORDER_ICON_IN_LIST')) { // Default code. Default should be this case.
2134 $text_info .= $reliquat.' x '.$obj->product_ref.'&nbsp;'.dol_trunc($obj->product_label, 20);
2135 $text_info .= ' - '.$langs->trans("Stock").': <span class="'.($generic_product->stock_reel > 0 ? 'ok' : 'error').'">'.$generic_product->stock_reel.'</span>';
2136 $text_info .= ' - '.$langs->trans("VirtualStock").': <span class="'.($generic_product->stock_theorique > 0 ? 'ok' : 'error').'">'.$generic_product->stock_theorique.'</span>';
2137 $text_info .= ($reliquat != $obj->qty ? ' <span class="opacitymedium">('.$langs->trans("QtyInOtherShipments").' '.($obj->qty - $reliquat).')</span>' : '');
2138 $text_info .= '<br>';
2139 } else { // BUGGED CODE.
2140 // DOES NOT TAKE INTO ACCOUNT MANUFACTURING. THIS CODE SHOULD BE USELESS. PREVIOUS CODE SEEMS COMPLETE.
2141 // COUNT STOCK WHEN WE SHOULD ALREADY HAVE VALUE
2142 // Detailed virtual stock, looks bugged, incomplete and need heavy load.
2143 // stock order and stock order_supplier
2144 $stock_order = 0;
2145 $stock_order_supplier = 0;
2146 if (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT') || getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE')) { // What about other options ?
2147 if (isModEnabled('order')) {
2148 if (empty($productstat_cache[$obj->fk_product]['stats_order_customer'])) {
2149 $generic_product->load_stats_commande(0, '1,2');
2150 $productstat_cache[$obj->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty'];
2151 } else {
2152 $generic_product->stats_commande['qty'] = $productstat_cache[$obj->fk_product]['stats_order_customer'];
2153 }
2154 $stock_order = $generic_product->stats_commande['qty'];
2155 }
2156 if (isModEnabled('supplier_order')) {
2157 if (empty($productstat_cache[$obj->fk_product]['stats_order_supplier'])) {
2158 $generic_product->load_stats_commande_fournisseur(0, '3');
2159 $productstat_cache[$obj->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty'];
2160 } else {
2161 $generic_product->stats_commande_fournisseur['qty'] = $productstat_cache[$obj->fk_product]['stats_order_supplier'];
2162 }
2163 $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty'];
2164 }
2165 }
2166 $text_info .= $reliquat.' x '.$obj->product_ref.'&nbsp;'.dol_trunc($obj->product_label, 20);
2167 $text_stock_reel = $generic_product->stock_reel.'/'.$stock_order;
2168 if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $obj->qty)) {
2169 $warning++;
2170 $text_warning .= '<span class="warning">'.$langs->trans('Available').'&nbsp;:&nbsp;'.$text_stock_reel.'</span>';
2171 }
2172 if ($reliquat > $generic_product->stock_reel) {
2173 $text_info .= '<span class="warning">'.$langs->trans('Available').'&nbsp;:&nbsp;'.$text_stock_reel.'</span>';
2174 } else {
2175 $text_info .= '<span class="ok">'.$langs->trans('Available').'&nbsp;:&nbsp;'.$text_stock_reel.'</span>';
2176 }
2177 if (isModEnabled('supplier_order')) {
2178 $text_info .= '&nbsp;'.$langs->trans('SupplierOrder').'&nbsp;:&nbsp;'.$stock_order_supplier;
2179 }
2180 $text_info .= ($reliquat != $obj->qty ? ' <span class="opacitymedium">('.$langs->trans("QtyInOtherShipments").' '.($obj->qty - $reliquat).')</span>' : '');
2181 $text_info .= '<br>';
2182 }
2183 }
2184 if ($notshippable == 0) {
2185 $text_icon = img_picto('', 'dolly', '', 0, 0, 0, '', 'green paddingleft');
2186 $text_info = $text_icon.' '.$langs->trans('Shippable').'<br>'.$text_info;
2187 } else {
2188 $text_icon = img_picto('', 'dolly', '', 0, 0, 0, '', 'error paddingleft');
2189 $text_info = $text_icon.' '.$langs->trans('NonShippable').'<br>'.$text_info;
2190 }
2191 }
2192
2193 if ($nbprod) {
2194 print $form->textwithtooltip('', $text_info, 2, 1, $text_icon, '', 2);
2195 }
2196 if ($warning) { // Always false in default mode
2197 print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders').'<br>'.$text_warning, 2, 1, img_picto('', 'error'), '', 2);
2198 }
2199 }
2200 print '</td>';
2201 if (!$i) {
2202 $totalarray['nbfield']++;
2203 }
2204 }
2205
2206 // Billed
2207 if (!empty($arrayfields['c.facture']['checked'])) {
2208 print '<td class="center">';
2209 if ($obj->billed) {
2210 print yn($obj->billed, $langs->trans("Billed"));
2211 }
2212 print '</td>';
2213 if (!$i) {
2214 $totalarray['nbfield']++;
2215 }
2216 }
2217 // Import key
2218 if (!empty($arrayfields['c.import_key']['checked'])) {
2219 print '<td class="nowrap center">'.$obj->import_key.'</td>';
2220 if (!$i) {
2221 $totalarray['nbfield']++;
2222 }
2223 }
2224 // Status
2225 if (!empty($arrayfields['c.fk_statut']['checked'])) {
2226 print '<td class="nowrap center">'.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).'</td>';
2227 if (!$i) {
2228 $totalarray['nbfield']++;
2229 }
2230 }
2231
2232 // Action column
2233 if (!getDolGlobalInt('MAIN_CHECKBOX_LEFT_COLUMN')) {
2234 print '<td class="nowrap center">';
2235 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2236 $selected = 0;
2237 if (in_array($obj->rowid, $arrayofselected)) {
2238 $selected = 1;
2239 }
2240 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
2241 }
2242 print '</td>';
2243 if (!$i) {
2244 $totalarray['nbfield']++;
2245 }
2246 }
2247
2248 print "</tr>\n";
2249
2250 $total += $obj->total_ht;
2251 $subtotal += $obj->total_ht;
2252 $i++;
2253 }
2254 if ($sortfield == 'pr.ref') {
2255 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_subtotal.tpl.php';
2256 }
2257 // Show total line
2258 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
2259
2260 // If no record found
2261 if ($num == 0) {
2262 $colspan = 1;
2263 foreach ($arrayfields as $key => $val) {
2264 if (!empty($val['checked'])) {
2265 $colspan++;
2266 }
2267 }
2268 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
2269 }
2270
2271 $db->free($resql);
2272
2273 $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
2274 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
2275 print $hookmanager->resPrint;
2276
2277 print '</table>'."\n";
2278 print '</div>';
2279
2280 print '</form>'."\n";
2281
2282 $hidegeneratedfilelistifempty = 1;
2283 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
2284 $hidegeneratedfilelistifempty = 0;
2285 }
2286
2287 // Show list of available documents
2288 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
2289 $urlsource .= str_replace('&amp;', '&', $param);
2290
2291 $filedir = $diroutputmassaction;
2292 $genallowed = $permissiontoread;
2293 $delallowed = $permissiontoadd;
2294
2295 print $formfile->showdocuments('massfilesarea_orders', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
2296} else {
2297 dol_print_error($db);
2298}
2299
2300// End of page
2301llxFooter();
2302$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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.
llxFooter()
Footer empty.
Definition document.php:107
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)
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_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return 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.