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