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