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