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