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