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