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