dolibarr 21.0.3
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2012-2016 Marcos García <marcosgdf@gmail.com>
6 * Copyright (C) 2013-2023 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2013-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
8 * Copyright (C) 2013 Jean Heimburger <jean@tiaris.info>
9 * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
10 * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
11 * Copyright (C) 2013 Adolfo segura <adolfo.segura@gmail.com>
12 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
13 * Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
14 * Copyright (C) 2020-2021 Open-DSI <support@open-dsi.fr>
15 * Copyright (C) 2022 Charlene Benke <charlene@patas-monkey.com>
16 * Copyright (C) 2020-2023 Alexandre Spangaro <aspangaro@easya.solutions>
17 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
18 * Copyright (C) 2024 Benjamin Falière <benjamin.faliere@altairis.fr>
19 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
20 *
21 * This program is free software; you can redistribute it and/or modify
22 * it under the terms of the GNU General Public License as published by
23 * the Free Software Foundation; either version 3 of the License, or
24 * (at your option) any later version.
25 *
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
30 *
31 * You should have received a copy of the GNU General Public License
32 * along with this program. If not, see <https://www.gnu.org/licenses/>.
33 */
34
42// Load Dolibarr environment
43require '../main.inc.php';
44require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
45require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
46require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
47require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
48require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
49require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
50require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
51require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
52
53if (isModEnabled('workstation')) {
54 require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php';
55}
56if (isModEnabled('category')) {
57 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
58 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
59}
60
70// Load translation files required by the page
71$langs->loadLangs(array('products', 'stocks', 'suppliers', 'companies', 'margins'));
72if (isModEnabled('productbatch')) {
73 $langs->load("productbatch");
74}
75
76
77// Get parameters
78$action = GETPOST('action', 'aZ09');
79$massaction = GETPOST('massaction', 'alpha');
80$show_files = GETPOSTINT('show_files');
81$confirm = GETPOST('confirm', 'alpha');
82$toselect = GETPOST('toselect', 'array');
83$optioncss = GETPOST('optioncss', 'alpha');
84$mode = GETPOST('mode', 'alpha');
85
86$fourn_id = GETPOSTINT("fourn_id");
87
88// Search Criteria
89$search_all = trim(GETPOST('search_all', 'alphanohtml'));
90$search_id = GETPOST("search_id", 'alpha');
91$search_ref = GETPOST("search_ref", 'alpha');
92$search_ref_ext = trim(GETPOST("search_ref_ext", 'alpha'));
93$search_ref_supplier = GETPOST("search_ref_supplier", 'alpha'); // ref of supplier price
94$search_barcode = GETPOST("search_barcode", 'alpha');
95$search_label = GETPOST("search_label", 'alpha');
96$search_default_workstation = GETPOST("search_default_workstation", 'alpha');
97$search_type = GETPOST("search_type", "int");
98$search_vatrate = GETPOST("search_vatrate", 'alpha');
99$searchCategoryProductOperator = 0;
100if (GETPOSTISSET('formfilteraction')) {
101 $searchCategoryProductOperator = GETPOSTINT('search_category_product_operator');
102} elseif (getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT')) {
103 $searchCategoryProductOperator = getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT');
104}
105$searchCategoryProductList = GETPOST('search_category_product_list', 'array');
106$catid = GETPOSTINT('catid');
107if (!empty($catid) && empty($searchCategoryProductList)) {
108 $searchCategoryProductList = array($catid);
109}
110$search_tosell = GETPOST("search_tosell");
111$search_tobuy = GETPOST("search_tobuy");
112$search_country = GETPOST("search_country", 'aZ09');
113$search_state = GETPOST("state_id", 'intcomma');
114$search_tobatch = GETPOST("search_tobatch");
115$search_accountancy_code_sell = GETPOST("search_accountancy_code_sell", 'alpha');
116$search_accountancy_code_sell_intra = GETPOST("search_accountancy_code_sell_intra", 'alpha');
117$search_accountancy_code_sell_export = GETPOST("search_accountancy_code_sell_export", 'alpha');
118$search_accountancy_code_buy = GETPOST("search_accountancy_code_buy", 'alpha');
119$search_accountancy_code_buy_intra = GETPOST("search_accountancy_code_buy_intra", 'alpha');
120$search_accountancy_code_buy_export = GETPOST("search_accountancy_code_buy_export", 'alpha');
121$search_import_key = GETPOST("search_import_key", 'alpha');
122$search_finished = GETPOST("search_finished");
123$search_units = GETPOST('search_units', 'int');
124$type = GETPOST("type", 'alpha');
125
126// Show/hide child product variants
127$show_childproducts = 0;
128if (isModEnabled('variants')) {
129 $show_childproducts = GETPOST('search_show_childproducts');
130}
131
132$diroutputmassaction = $conf->product->dir_output.'/temp/massgeneration/'.$user->id;
133
134// Load variable for pagination
135$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
136$sortfield = GETPOST('sortfield', 'aZ09comma');
137$sortorder = GETPOST('sortorder', 'aZ09comma');
138$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
139if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
140 // If $page is not defined, or '' or -1 or if we click on clear filters
141 $page = 0;
142}
143$offset = $limit * $page;
144$pageprev = $page - 1;
145$pagenext = $page + 1;
146if (!$sortfield) {
147 $sortfield = "p.ref";
148}
149if (!$sortorder) {
150 $sortorder = "ASC";
151}
152
153// Initialize context for list
154$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'productservicelist';
155if ((string) $type == '1') {
156 $contextpage = 'servicelist';
157 if ($search_type == '') {
158 $search_type = '1';
159 }
160}
161if ((string) $type == '0') {
162 $contextpage = 'productlist';
163 if ($search_type == '') {
164 $search_type = '0';
165 }
166}
167
168// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
169$object = new Product($db);
170$hookmanager->initHooks(array('productservicelist'));
171$extrafields = new ExtraFields($db);
172$form = new Form($db);
173$formcompany = new FormCompany($db);
174$formproduct = new FormProduct($db);
175
176// fetch optionals attributes and labels
177$extrafields->fetch_name_optionals_label($object->table_element);
178$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
179
180if (empty($action)) {
181 $action = 'list';
182}
183
184// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
185$canvas = GETPOST("canvas");
186$objcanvas = null;
187if (!empty($canvas)) {
188 require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
189 $objcanvas = new Canvas($db, $action);
190 $objcanvas->getCanvas('product', 'list', $canvas);
191}
192
193// Define virtualdiffersfromphysical
194$virtualdiffersfromphysical = 0;
195if (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT')
196 || getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER')
197 || getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE')
198 || getDolGlobalString('STOCK_CALCULATE_ON_RECEPTION')
199 || getDolGlobalString('STOCK_CALCULATE_ON_RECEPTION_CLOSE')
200 || isModEnabled('mrp')) {
201 $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs.
202}
203
204// List of fields to search into when doing a "search in all"
205$fieldstosearchall = array(
206 'p.ref' => "Ref",
207 'p.label' => "ProductLabel",
208 'p.description' => "Description",
209 "p.note" => "Note",
210 'pfp.ref_fourn' => 'RefSupplier'
211);
212// multilang
213if (getDolGlobalInt('MAIN_MULTILANGS')) {
214 $fieldstosearchall['pl.label'] = 'ProductLabelTranslated';
215 $fieldstosearchall['pl.description'] = 'ProductDescriptionTranslated';
216 $fieldstosearchall['pl.note'] = 'ProductNoteTranslated';
217}
218if (isModEnabled('barcode')) {
219 $fieldstosearchall['p.barcode'] = 'Gencod';
220 $fieldstosearchall['pfp.barcode'] = 'GencodBuyPrice';
221}
222// Personalized search criteria. Example: getDolGlobalString('PRODUCT_QUICKSEARCH_ON_FIELDS') = 'p.ref=ProductRef;p.label=ProductLabel;p.description=Description;p.note=Note;'
223if (getDolGlobalString('PRODUCT_QUICKSEARCH_ON_FIELDS')) {
224 $fieldstosearchall = dolExplodeIntoArray(getDolGlobalString('PRODUCT_QUICKSEARCH_ON_FIELDS'));
225}
226
227if (!getDolGlobalString('PRODUIT_MULTIPRICES')) {
228 $titlesellprice = $langs->trans("SellingPrice");
229 if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES')) {
230 $titlesellprice = $form->textwithpicto($langs->trans("SellingPrice"), $langs->trans("DefaultPriceRealPriceMayDependOnCustomer"));
231 }
232}
233
234$isInEEC = isInEEC($mysoc);
235
236$alias_product_perentity = !getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED') ? "p" : "ppe";
237
238$arraypricelevel = array();
239// Definition of array of fields for columns
240$arrayfields = array(
241 'p.rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -2, 'noteditable' => 1, 'notnull' => 1, 'index' => 1, 'position' => 1, 'comment' => 'Id', 'css' => 'left'),
242 'p.ref' => array('label' => 'ProductRef', 'checked' => 1, 'position' => 5),
243 'p.ref_ext' => array('label' => 'RefExt', 'checked' => 1, 'position' => 6, 'visible' => getDolGlobalInt('MAIN_LIST_SHOW_REF_EXT')),
244 //'pfp.ref_fourn'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1, 'enabled'=>(isModEnabled('barcode'))),
245 'thumbnail' => array('label' => 'Photo', 'checked' => 0, 'position' => 10),
246 'p.description' => array('label' => 'Description', 'checked' => 0, 'position' => 10),
247 'p.label' => array('label' => "Label", 'checked' => 1, 'position' => 10),
248 'p.fk_product_type' => array('label' => "Type", 'checked' => 0, 'enabled' => (isModEnabled("product") && isModEnabled("service")), 'position' => 11),
249 'p.barcode' => array('label' => "Gencod", 'checked' => 1, 'enabled' => (isModEnabled('barcode')), 'position' => 12),
250 'p.duration' => array('label' => "Duration", 'checked' => ($contextpage != 'productlist'), 'enabled' => (isModEnabled("service") && (string) $type == '1'), 'position' => 13),
251 'pac.fk_product_parent' => array('label' => "ParentProductOfVariant", 'checked' => -1, 'enabled' => (isModEnabled('variants')), 'position' => 14),
252 'p.finished' => array('label' => "Nature", 'checked' => 0, 'enabled' => (isModEnabled("product") && $type != '1'), 'position' => 19),
253 'p.weight' => array('label' => 'Weight', 'checked' => 0, 'enabled' => (isModEnabled("product") && $type != '1'), 'position' => 20),
254 'p.weight_units' => array('label' => 'WeightUnits', 'checked' => 0, 'enabled' => (isModEnabled("product") && $type != '1'), 'position' => 21),
255 'p.length' => array('label' => 'Length', 'checked' => 0, 'enabled' => (isModEnabled("product") && !getDolGlobalString('PRODUCT_DISABLE_SIZE') && $type != '1'), 'position' => 22),
256 'p.length_units' => array('label' => 'LengthUnits', 'checked' => 0, 'enabled' => (isModEnabled("product") && !getDolGlobalString('PRODUCT_DISABLE_SIZE') && $type != '1'), 'position' => 23),
257 'p.width' => array('label' => 'Width', 'checked' => 0, 'enabled' => (isModEnabled("product") && !getDolGlobalString('PRODUCT_DISABLE_SIZE') && $type != '1'), 'position' => 24),
258 'p.width_units' => array('label' => 'WidthUnits', 'checked' => 0, 'enabled' => (isModEnabled("product") && !getDolGlobalString('PRODUCT_DISABLE_SIZE') && $type != '1'), 'position' => 25),
259 'p.height' => array('label' => 'Height', 'checked' => 0, 'enabled' => (isModEnabled("product") && !getDolGlobalString('PRODUCT_DISABLE_SIZE') && $type != '1'), 'position' => 26),
260 'p.height_units' => array('label' => 'HeightUnits', 'checked' => 0, 'enabled' => (isModEnabled("product") && !getDolGlobalString('PRODUCT_DISABLE_SIZE') && $type != '1'), 'position' => 27),
261 'p.surface' => array('label' => 'Surface', 'checked' => 0, 'enabled' => (isModEnabled("product") && !getDolGlobalString('PRODUCT_DISABLE_SURFACE') && $type != '1'), 'position' => 28),
262 'p.surface_units' => array('label' => 'SurfaceUnits', 'checked' => 0, 'enabled' => (isModEnabled("product") && !getDolGlobalString('PRODUCT_DISABLE_SURFACE') && $type != '1'), 'position' => 29),
263 'p.volume' => array('label' => 'Volume', 'checked' => 0, 'enabled' => (isModEnabled("product") && !getDolGlobalString('PRODUCT_DISABLE_VOLUME') && $type != '1'), 'position' => 30),
264 'p.volume_units' => array('label' => 'VolumeUnits', 'checked' => 0, 'enabled' => (isModEnabled("product") && !getDolGlobalString('PRODUCT_DISABLE_VOLUME') && $type != '1'), 'position' => 31),
265 'cu.label' => array('label' => "DefaultUnitToShow", 'checked' => 0, 'enabled' => (isModEnabled("product") && getDolGlobalString('PRODUCT_USE_UNITS')), 'position' => 32),
266 'p.fk_default_workstation' => array('label' => 'DefaultWorkstation', 'checked' => 0, 'enabled' => isModEnabled('workstation') && $type == 1, 'position' => 33),
267 'p.sellprice' => array('label' => "SellingPrice", 'checked' => 1, 'enabled' => !getDolGlobalString('PRODUIT_MULTIPRICES'), 'position' => 40),
268 'p.tva_tx' => array('label' => "VATRate", 'checked' => 0, 'enabled' => !getDolGlobalString('PRODUIT_MULTIPRICES'), 'position' => 41),
269 'p.minbuyprice' => array('label' => "BuyingPriceMinShort", 'checked' => 1, 'enabled' => ($user->hasRight('fournisseur', 'lire')), 'position' => 42),
270 'p.numbuyprice' => array('label' => "BuyingPriceNumShort", 'checked' => 0, 'enabled' => ($user->hasRight('fournisseur', 'lire')), 'position' => 43),
271 'p.pmp' => array('label' => "PMPValueShort", 'checked' => 0, 'enabled' => ($user->hasRight('fournisseur', 'lire')), 'position' => 44),
272 'p.cost_price' => array('label' => "CostPrice", 'checked' => 0, 'enabled' => ($user->hasRight('fournisseur', 'lire')), 'position' => 45),
273 'p.seuil_stock_alerte' => array('label' => "StockLimit", 'checked' => 0, 'enabled' => (isModEnabled('stock') && $user->hasRight('stock', 'lire') && ($contextpage != 'servicelist' || getDolGlobalString('STOCK_SUPPORTS_SERVICES'))), 'position' => 50),
274 'p.desiredstock' => array('label' => "DesiredStock", 'checked' => 1, 'enabled' => (isModEnabled('stock') && $user->hasRight('stock', 'lire') && ($contextpage != 'servicelist' || getDolGlobalString('STOCK_SUPPORTS_SERVICES'))), 'position' => 51),
275 'p.stock' => array('label' => "PhysicalStock", 'checked' => 1, 'enabled' => (isModEnabled('stock') && $user->hasRight('stock', 'lire') && ($contextpage != 'servicelist' || getDolGlobalString('STOCK_SUPPORTS_SERVICES'))), 'position' => 52),
276 'stock_virtual' => array('label' => "VirtualStock", 'checked' => 1, 'enabled' => (isModEnabled('stock') && $user->hasRight('stock', 'lire') && ($contextpage != 'servicelist' || getDolGlobalString('STOCK_SUPPORTS_SERVICES')) && $virtualdiffersfromphysical), 'position' => 53),
277 'p.tobatch' => array('label' => "ManageLotSerial", 'checked' => 0, 'enabled' => (isModEnabled('productbatch')), 'position' => 60),
278 'p.fk_country' => array('label' => "Country", 'checked' => 0, 'position' => 100),
279 'p.fk_state' => array('label' => "State", 'checked' => 0, 'position' => 101),
280 $alias_product_perentity . '.accountancy_code_sell' => array('label' => "ProductAccountancySellCode", 'checked' => 0, 'enabled' => !getDolGlobalString('PRODUCT_DISABLE_ACCOUNTING'), 'position' => 400),
281 $alias_product_perentity . '.accountancy_code_sell_intra' => array('label' => "ProductAccountancySellIntraCode", 'checked' => 0, 'enabled' => $isInEEC && !getDolGlobalString('PRODUCT_DISABLE_ACCOUNTING'), 'position' => 401),
282 $alias_product_perentity . '.accountancy_code_sell_export' => array('label' => "ProductAccountancySellExportCode", 'checked' => 0, 'enabled' => !getDolGlobalString('PRODUCT_DISABLE_ACCOUNTING'), 'position' => 402),
283 $alias_product_perentity . '.accountancy_code_buy' => array('label' => "ProductAccountancyBuyCode", 'checked' => 0, 'enabled' => !getDolGlobalString('PRODUCT_DISABLE_ACCOUNTING'), 'position' => 403),
284 $alias_product_perentity . '.accountancy_code_buy_intra' => array('label' => "ProductAccountancyBuyIntraCode", 'checked' => 0, 'enabled' => $isInEEC && !getDolGlobalString('PRODUCT_DISABLE_ACCOUNTING'), 'position' => 404),
285 $alias_product_perentity . '.accountancy_code_buy_export' => array('label' => "ProductAccountancyBuyExportCode", 'checked' => 0, 'enabled' => !getDolGlobalString('PRODUCT_DISABLE_ACCOUNTING'), 'position' => 405),
286 'p.datec' => array('label' => "DateCreation", 'checked' => 0, 'position' => 500),
287 'p.tms' => array('label' => "DateModificationShort", 'checked' => 0, 'position' => 500),
288 'p.tosell' => array('label' => $langs->transnoentitiesnoconv("Status").' ('.$langs->transnoentitiesnoconv("Sell").')', 'checked' => 1, 'position' => 1000),
289 'p.tobuy' => array('label' => $langs->transnoentitiesnoconv("Status").' ('.$langs->transnoentitiesnoconv("Buy").')', 'checked' => 1, 'position' => 1000),
290 'p.import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -2, 'notnull' => -1, 'index' => 0, 'checked' => -1, 'position' => 1100),
291);
292/*foreach ($object->fields as $key => $val) {
293 // If $val['visible']==0, then we never show the field
294 if (!empty($val['visible'])) {
295 $visible = dol_eval($val['visible'], 1, 1, '1');
296 $arrayfields['p.'.$key] = array(
297 'label'=>$val['label'],
298 'checked'=>(($visible < 0) ? 0 : 1),
299 'enabled'=>(abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)),
300 'position'=>$val['position']
301 );
302 }
303}*/
304
305
306// MultiPrices
307if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
308 $produit_multiprices_limit = getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT');
309 for ($i = 1; $i <= $produit_multiprices_limit; $i++) {
310 $keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$i;
311 if (getDolGlobalString($keyforlabel)) {
312 $labelp = $i.' - '.$langs->transnoentitiesnoconv(getDolGlobalString($keyforlabel));
313 } else {
314 $labelp = $langs->transnoentitiesnoconv("SellingPrice")." ".$i;
315 }
316 $arrayfields['p.sellprice'.$i] = array('label' => $labelp, 'checked' => ($i == 1 ? 1 : 0), 'enabled' => getDolGlobalString('PRODUIT_MULTIPRICES'), 'position' => (float) ('40.'.sprintf('%03d', $i)));
317 $arraypricelevel[$i] = array($i);
318 }
319}
320
321// Extra fields
322include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
323
324$object->fields = dol_sort_array($object->fields, 'position');
325$arrayfields = dol_sort_array($arrayfields, 'position');
326'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
327
328// Security check
329if ($search_type == '0') {
330 $result = restrictedArea($user, 'produit', '', '', '', '', '', 0);
331} elseif ($search_type == '1') {
332 $result = restrictedArea($user, 'service', '', '', '', '', '', 0);
333} else {
334 $result = restrictedArea($user, 'produit|service', '', '', '', '', '', 0);
335}
336
337
338/*
339 * Actions
340 */
341$error = 0;
342
343if (GETPOST('cancel', 'alpha')) {
344 $action = 'list';
345 $massaction = '';
346}
347if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
348 $massaction = '';
349}
350$parameters = array('arrayfields' => &$arrayfields);
351$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
352if ($reshook < 0) {
353 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
354}
355
356$rightskey = 'produit';
357if ($type == Product::TYPE_SERVICE) {
358 $rightskey = 'service';
359}
360
361if (empty($reshook)) {
362 // Selection of new fields
363 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
364
365 // Purge search criteria
366 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
367 $search_all = "";
368 $search_id = '';
369 $search_ref = "";
370 $search_ref_ext = "";
371 $search_ref_supplier = "";
372 $search_label = "";
373 $search_default_workstation = "";
374 $search_barcode = "";
375 $searchCategoryProductOperator = 0;
376 $searchCategoryProductList = array();
377 $search_tosell = "";
378 $search_tobuy = "";
379 $search_tobatch = '';
380 $search_country = "";
381 $search_state = "";
382 $search_vatrate = "";
383 $search_finished = '';
384 //$search_type=''; // There is 2 types of list: a list of product and a list of services. No list with both. So when we clear search criteria, we must keep the filter on type.
385
386 $show_childproducts = '';
387 $search_import_key = '';
388 $search_accountancy_code_sell = '';
389 $search_accountancy_code_sell_intra = '';
390 $search_accountancy_code_sell_export = '';
391 $search_accountancy_code_buy = '';
392 $search_accountancy_code_buy_intra = '';
393 $search_accountancy_code_buy_export = '';
394 $search_array_options = array();
395 $search_units = '';
396 }
397
398 // Mass actions
399 $objectclass = 'Product';
400 if ((string) $search_type == '1') {
401 $objectlabel = 'Services';
402 }
403 if ((string) $search_type == '0') {
404 $objectlabel = 'Products';
405 }
406
407 $permissiontoread = $user->hasRight($rightskey, 'lire');
408 $permissiontodelete = $user->hasRight($rightskey, 'supprimer');
409 $permissiontoadd = $user->hasRight($rightskey, 'creer');
410 $uploaddir = $conf->product->dir_output;
411 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
412
413 if ($massaction == 'switchonsalestatus' && $permissiontoadd) {
414 $product = new Product($db);
415 foreach ($toselect as $toselectid) {
416 $result = $product->fetch($toselectid);
417 if ($result > 0 && $product->id > 0) {
418 if ($product->setStatut($product->status ? 0 : 1, null, 'product', 'PRODUCT_MODIFY', 'tosell') < 0) {
419 setEventMessages($product->error, $product->errors, 'errors');
420 }
421 }
422 }
423 }
424 if ($massaction == 'switchonpurchasestatus' && $permissiontoadd) {
425 $product = new Product($db);
426 foreach ($toselect as $toselectid) {
427 $result = $product->fetch($toselectid);
428 if ($result > 0 && $product->id > 0) {
429 if ($product->setStatut($product->status_buy ? 0 : 1, null, 'product', 'PRODUCT_MODIFY', 'tobuy') < 0) {
430 setEventMessages($product->error, $product->errors, 'errors');
431 }
432 }
433 }
434 }
435}
436
437
438/*
439 * View
440 */
441
442$product_static = new Product($db);
443if (isModEnabled('workstation')) {
444 $workstation_static = new Workstation($db);
445}
446$product_fourn = new ProductFournisseur($db);
447
448$title = $langs->trans("ProductsAndServices");
449
450if ($search_type != '' && $search_type != '-1') {
451 if ($search_type == 1) {
452 $title = $langs->trans("Services");
453 } else {
454 $title = $langs->trans("Products");
455 }
456}
457
458// Build and execute select
459// --------------------------------------------------------------------
460$sql = 'SELECT p.rowid, p.ref, p.ref_ext, p.description, p.label, p.fk_product_type, p.barcode, p.price, p.tva_tx, p.price_ttc, p.price_base_type, p.entity,';
461$sql .= ' p.fk_product_type, p.duration, p.finished, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,';
462$sql .= ' p.tobatch, ';
463if (isModEnabled('workstation')) {
464 $sql .= ' p.fk_default_workstation, ws.status as status_workstation, ws.ref as ref_workstation, ';
465}
466if (!getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
467 $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,";
468} else {
469 $sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export, ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,";
470}
471$sql .= ' p.datec as date_creation, p.tms as date_modification, p.pmp, p.stock, p.cost_price,';
472$sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units,';
473$sql .= ' p.fk_country, p.fk_state,';
474$sql .= ' p.import_key,';
475if (getDolGlobalString('PRODUCT_USE_UNITS')) {
476 $sql .= ' p.fk_unit, cu.label as cu_label,';
477}
478$sql .= ' MIN(pfp.unitprice) as bestpurchaseprice';
479if (isModEnabled('variants')) {
480 $sql .= ', pac.rowid as prod_comb_id';
481 $sql .= ', pac.fk_product_parent';
482}
483// Add fields from extrafields
484if (!empty($extrafields->attributes[$object->table_element]['label'])) {
485 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
486 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
487 }
488}
489// Add fields from hooks
490$parameters = array();
491$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
492$sql .= $hookmanager->resPrint;
493$sql = preg_replace('/,\s*$/', '', $sql);
494
495$sqlfields = $sql; // $sql fields to remove for count total
496
497$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p';
498if (isModEnabled('workstation')) {
499 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "workstation_workstation as ws ON (p.fk_default_workstation = ws.rowid)";
500}
501if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
502 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
503}
504if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
505 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_extrafields as ef on (p.rowid = ef.fk_object)";
506}
507$linktopfp = " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
508$sql .= $linktopfp;
509// multilang
510if (getDolGlobalInt('MAIN_MULTILANGS')) {
511 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang = '".$db->escape($langs->getDefaultLang())."'";
512}
513if (isModEnabled('variants')) {
514 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac.fk_product_child = p.rowid";
515}
516if (getDolGlobalString('PRODUCT_USE_UNITS')) {
517 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_units cu ON cu.rowid = p.fk_unit";
518}
519
520// Add table from hooks
521$parameters = array();
522$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
523$sql .= $hookmanager->resPrint;
524
525$sql .= ' WHERE p.entity IN ('.getEntity('product').')';
526if ($search_all) {
527 // Clean $fieldstosearchall
528 $newfieldstosearchall = $fieldstosearchall;
529 unset($newfieldstosearchall['pfp.ref_fourn']);
530 unset($newfieldstosearchall['pfp.barcode']);
531
532 $sql .= ' AND (';
533 $sql .= natural_search(array_keys($newfieldstosearchall), $search_all, 0, 1);
534 // Search also into a supplier reference 'pfp.ref_fourn'="RefSupplier"
535 $sql .= ' OR EXISTS (SELECT rowid FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp WHERE pfp.fk_product = p.rowid';
536 $sql .= ' AND ('.natural_search('pfp.ref_fourn', $search_all, 0, 1);
537 if (isModEnabled('barcode')) {
538 // Search also into a supplier barcode 'pfp.barcode'='GencodBuyPrice';
539 $sql .= ' OR '.natural_search('pfp.barcode', $search_all, 0, 1);
540 }
541 $sql .= ')))';
542}
543// if the type is not 1, we show all products (type = 0,2,3)
544if (dol_strlen($search_type) && $search_type != '-1') {
545 if ($search_type == 1) {
546 $sql .= " AND p.fk_product_type = 1";
547 } else {
548 $sql .= " AND p.fk_product_type <> 1";
549 }
550}
551
552if (isModEnabled('variants') && !$show_childproducts) {
553 $sql .= " AND pac.rowid IS NULL";
554}
555
556if ($search_id) {
557 $sql .= natural_search('p.rowid', $search_id, 1);
558}
559if ($search_ref) {
560 $sql .= natural_search('p.ref', $search_ref);
561}
562if ($search_ref_ext) {
563 $sql .= natural_search('p.ref_ext', $search_ref_ext);
564}
565if ($search_label) {
566 $sql .= natural_search('p.label', $search_label);
567}
568if ($search_default_workstation) {
569 $sql .= natural_search('ws.ref', $search_default_workstation);
570}
571if ($search_barcode) {
572 $sql .= natural_search('p.barcode', $search_barcode);
573}
574if ($search_import_key) {
575 $sql .= natural_search('p.import_key', $search_import_key);
576}
577if (isset($search_tosell) && dol_strlen($search_tosell) > 0 && $search_tosell != -1) {
578 $sql .= " AND p.tosell = ".((int) $search_tosell);
579}
580if (isset($search_tobuy) && dol_strlen($search_tobuy) > 0 && $search_tobuy != -1) {
581 $sql .= " AND p.tobuy = ".((int) $search_tobuy);
582}
583if (isset($search_tobatch) && dol_strlen($search_tobatch) > 0 && $search_tobatch != -1) {
584 $sql .= " AND p.tobatch = ".((int) $search_tobatch);
585}
586if ($search_vatrate) {
587 $sql .= natural_search('p.tva_tx', $search_vatrate, 1);
588}
589if (dol_strlen($canvas) > 0) {
590 $sql .= " AND p.canvas = '".$db->escape($canvas)."'";
591}
592
593// Search for tag/category ($searchCategoryProductList is an array of ID)
594if (!empty($searchCategoryProductList)) {
595 $searchCategoryProductSqlList = array();
596 $listofcategoryid = '';
597 foreach ($searchCategoryProductList as $searchCategoryProduct) {
598 if (intval($searchCategoryProduct) == -2) {
599 $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product)";
600 } elseif (intval($searchCategoryProduct) > 0) {
601 if ($searchCategoryProductOperator == 0) {
602 $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")";
603 } else {
604 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
605 }
606 }
607 }
608 if ($listofcategoryid) {
609 $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
610 }
611 if ($searchCategoryProductOperator == 1) {
612 if (!empty($searchCategoryProductSqlList)) {
613 $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
614 }
615 } else {
616 if (!empty($searchCategoryProductSqlList)) {
617 $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
618 }
619 }
620}
621if ($fourn_id > 0) {
622 $sql .= " AND pfp.fk_soc = ".((int) $fourn_id);
623}
624if ($search_country) {
625 $sql .= " AND p.fk_country = ".((int) $search_country);
626}
627if ($search_state) {
628 $sql .= " AND p.fk_state = ".((int) $search_state);
629}
630if ($search_finished >= 0 && $search_finished !== '') {
631 $sql .= " AND p.finished = ".((int) $search_finished);
632}
633if ($search_accountancy_code_sell) {
634 $sql .= natural_search($alias_product_perentity . '.accountancy_code_sell', clean_account($search_accountancy_code_sell));
635}
636if ($search_accountancy_code_sell_intra) {
637 $sql .= natural_search($alias_product_perentity . '.accountancy_code_sell_intra', clean_account($search_accountancy_code_sell_intra));
638}
639if ($search_accountancy_code_sell_export) {
640 $sql .= natural_search($alias_product_perentity . '.accountancy_code_sell_export', clean_account($search_accountancy_code_sell_export));
641}
642if ($search_accountancy_code_buy) {
643 $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy', clean_account($search_accountancy_code_buy));
644}
645if ($search_accountancy_code_buy_intra) {
646 $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy_intra', clean_account($search_accountancy_code_buy_intra));
647}
648if ($search_accountancy_code_buy_export) {
649 $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy_export', clean_account($search_accountancy_code_buy_export));
650}
651if (getDolGlobalString('PRODUCT_USE_UNITS') && !empty($search_units) && $search_units != '-1' && $search_units !== 'none') {
652 $sql .= natural_search('cu.rowid', $search_units);
653}
654
655// Add where from extra fields
656include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
657// Add where from hooks
658$parameters = array();
659$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
660$sql .= $hookmanager->resPrint;
661$sql .= " GROUP BY p.rowid, p.ref, p.ref_ext, p.description, p.label, p.barcode, p.price, p.tva_tx, p.price_ttc, p.price_base_type,";
662$sql .= " p.fk_product_type, p.duration, p.finished, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,";
663$sql .= ' p.datec, p.tms, p.entity, p.tobatch, p.pmp, p.cost_price, p.stock,';
664if (!getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
665 $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,";
666} else {
667 $sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export, ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,";
668}
669$sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units,';
670$sql .= ' p.fk_country, p.fk_state,';
671$sql .= ' p.import_key';
672if (getDolGlobalString('PRODUCT_USE_UNITS')) {
673 $sql .= ', p.fk_unit, cu.label';
674}
675if (isModEnabled('workstation')) {
676 $sql .= ', p.fk_default_workstation, ws.status, ws.ref';
677}
678if (isModEnabled('variants')) {
679 $sql .= ', pac.rowid';
680 $sql .= ', pac.fk_product_parent';
681}
682// Add fields from extrafields
683if (!empty($extrafields->attributes[$object->table_element]['label'])) {
684 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
685 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : '');
686 }
687}
688// Add groupby from hooks
689$parameters = array();
690$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
691$sql .= $hookmanager->resPrint;
692//if (GETPOST("toolowstock")) $sql.= " HAVING SUM(s.reel) < p.seuil_stock_alerte"; // Not used yet
693
694$nbtotalofrecords = '';
695if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
696 /* The fast and low memory method to get and count full list converts the sql into a sql count */
697 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
698 $sqlforcount = preg_replace('/'.preg_quote($linktopfp, '/').'/', '', $sqlforcount);
699 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
700
701 $resql = $db->query($sqlforcount);
702 if ($resql) {
703 $objforcount = $db->fetch_object($resql);
704 $nbtotalofrecords = $objforcount->nbtotalofrecords;
705 } else {
706 dol_print_error($db);
707 }
708
709 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
710 $page = 0;
711 $offset = 0;
712 }
713 $db->free($resql);
714}
715
716// Complete request and execute it with limit
717$sql .= $db->order($sortfield, $sortorder);
718if ($limit) {
719 $sql .= $db->plimit($limit + 1, $offset);
720}
721
722$resql = $db->query($sql);
723if (!$resql) {
724 dol_print_error($db);
725 exit;
726}
727
728$num = $db->num_rows($resql);
729
730
731// Direct jump if only one record found
732if ($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.'/product/card.php?id='.$id);
736 exit;
737}
738
739
740// Output page
741// --------------------------------------------------------------------
742
743$helpurl = '';
744if ($search_type != '') {
745 if ($search_type == 0) {
746 $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
747 } elseif ($search_type == 1) {
748 $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
749 }
750}
751
752$paramsCat = '';
753foreach ($searchCategoryProductList as $searchCategoryProduct) {
754 $paramsCat .= "&search_category_product_list[]=".urlencode($searchCategoryProduct);
755}
756
757//llxHeader('', $title, $helpurl, '', 0, 0, array(), array(), $paramsCat, 'classforhorizontalscrolloftabs');
758llxHeader('', $title, $helpurl, '', 0, 0, array(), array(), $paramsCat, 'bodyforlist mod-product page-list');
759
760$arrayofselected = is_array($toselect) ? $toselect : array();
761
762// Displays product removal confirmation
763if (GETPOST('delprod')) {
764 setEventMessages($langs->trans("ProductDeleted", GETPOST('delprod')), null, 'mesgs');
765}
766
767$param = '';
768if (!empty($mode)) {
769 $param .= '&mode='.urlencode($mode);
770}
771if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
772 $param .= '&contextpage='.urlencode($contextpage);
773}
774if ($limit > 0 && $limit != $conf->liste_limit) {
775 $param .= '&limit='.((int) $limit);
776}
777if ($optioncss != '') {
778 $param .= '&optioncss='.urlencode($optioncss);
779}
780if ($search_all) {
781 $param .= "&search_all=".urlencode($search_all);
782}
783if ($searchCategoryProductOperator == 1) {
784 $param .= "&search_category_product_operator=".urlencode((string) ($searchCategoryProductOperator));
785}
786foreach ($searchCategoryProductList as $searchCategoryProduct) {
787 $param .= "&search_category_product_list[]=".urlencode($searchCategoryProduct);
788}
789if ($search_ref) {
790 $param .= "&search_ref=".urlencode($search_ref);
791}
792if ($search_ref_ext) {
793 $param .= "&search_ref_ext=".urlencode($search_ref_ext);
794}
795if ($search_ref_supplier) {
796 $param .= "&search_ref_supplier=".urlencode($search_ref_supplier);
797}
798if ($search_barcode) {
799 $param .= ($search_barcode ? "&search_barcode=".urlencode($search_barcode) : "");
800}
801if ($search_import_key) {
802 $param .= "&search_import_key=".urlencode($search_import_key);
803}
804if ($search_label) {
805 $param .= "&search_label=".urlencode($search_label);
806}
807if ($search_default_workstation) {
808 $param .= "&search_default_workstation=".urlencode($search_default_workstation);
809}
810if ($search_tosell != '') {
811 $param .= "&search_tosell=".urlencode($search_tosell);
812}
813if ($search_tobuy != '') {
814 $param .= "&search_tobuy=".urlencode($search_tobuy);
815}
816if ($search_tobatch) {
817 $param .= "&search_tobatch=".urlencode($search_tobatch);
818}
819if ($search_country != '') {
820 $param .= "&search_country=".urlencode((string) ($search_country));
821}
822if ($search_state != '') {
823 $param .= "&search_state=".urlencode((string) ($search_state));
824}
825if ($search_vatrate) {
826 $param .= "&search_vatrate=".urlencode($search_vatrate);
827}
828if ($fourn_id > 0) {
829 $param .= "&fourn_id=".urlencode((string) ($fourn_id));
830}
831if ($show_childproducts) {
832 $param .= ($show_childproducts ? "&search_show_childproducts=".urlencode($show_childproducts) : "");
833}
834if ($type != '') {
835 $param .= '&type='.urlencode((string) ($type));
836}
837if ($search_type != '') {
838 $param .= '&search_type='.urlencode($search_type);
839}
840if ($search_accountancy_code_sell) {
841 $param .= "&search_accountancy_code_sell=".urlencode($search_accountancy_code_sell);
842}
843if ($search_accountancy_code_sell_intra) {
844 $param .= "&search_accountancy_code_sell_intra=".urlencode($search_accountancy_code_sell_intra);
845}
846if ($search_accountancy_code_sell_export) {
847 $param .= "&search_accountancy_code_sell_export=".urlencode($search_accountancy_code_sell_export);
848}
849if ($search_accountancy_code_buy) {
850 $param .= "&search_accountancy_code_buy=".urlencode($search_accountancy_code_buy);
851}
852if ($search_accountancy_code_buy_intra) {
853 $param .= "&search_accountancy_code_buy_intra=".urlencode($search_accountancy_code_buy_intra);
854}
855if ($search_accountancy_code_buy_export) {
856 $param .= "&search_accountancy_code_buy_export=".urlencode($search_accountancy_code_buy_export);
857}
858if ($search_finished) {
859 $param .= "&search_finished=".urlencode($search_finished);
860}
861// Add $param from extra fields
862include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
863
864// Add $param from hooks
865$parameters = array('param' => &$param);
866$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
867$param .= $hookmanager->resPrint;
868
869// List of mass actions available
870$arrayofmassactions = array(
871 'generate_doc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
872 'edit_extrafields' => img_picto('', 'edit', 'class="pictofixedwidth"').$langs->trans("ModifyValueExtrafields"),
873 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
874 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
875);
876if ($user->hasRight($rightskey, 'creer')) {
877 if (getDolGlobalString('PRODUCT_PRICE_UNIQ')
878 || getDolGlobalString('PRODUIT_CUSTOMER_PRICES')
879 || getDolGlobalString('PRODUIT_MULTIPRICES')) {
880 $arrayofmassactions['preupdateprice'] = img_picto('', 'edit', 'class="pictofixedwidth"').$langs->trans("UpdatePrice");
881 }
882
883 $arrayofmassactions['switchonsalestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnSaleStatus");
884 $arrayofmassactions['switchonpurchasestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnPurchaseStatus");
885}
886if (isModEnabled('category') && $user->hasRight($rightskey, 'creer')) {
887 $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
888}
889if (in_array($massaction, array('presend', 'predelete','preaffecttag', 'edit_extrafields', 'preupdateprice'))) {
890 $arrayofmassactions = array();
891}
892if ($user->hasRight($rightskey, 'supprimer')) {
893 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
894}
895$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
896
897$newcardbutton = '';
898$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition'));
899$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition'));
900
901if ($type === "") {
902 $perm = ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'));
903} elseif ($type == Product::TYPE_SERVICE) {
904 $perm = $user->hasRight('service', 'creer');
905} elseif ($type == Product::TYPE_PRODUCT) {
906 $perm = $user->hasRight('produit', 'creer');
907}
908$oldtype = $type;
909$params = array();
910if ($type === "") {
911 $params['forcenohideoftext'] = 1;
912}
913$newcardbutton .= dolGetButtonTitleSeparator();
914if ((isModEnabled('product') && $type === "") || $type == Product::TYPE_PRODUCT) {
915 $label = 'NewProduct';
916 $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type=0', '', $perm, $params);
917}
918if ((isModEnabled('service') && $type === "") || $type == Product::TYPE_SERVICE) {
919 $label = 'NewService';
920 $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type=1', '', $perm, $params);
921}
922
923print '<form id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" method="POST" name="formulaire">';
924if ($optioncss != '') {
925 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
926}
927print '<input type="hidden" name="token" value="'.newToken().'">';
928print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
929print '<input type="hidden" name="action" value="list">';
930print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
931print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
932//print '<input type="hidden" name="page" value="'.$page.'">';
933print '<input type="hidden" name="type" value="'.$type.'">';
934print '<input type="hidden" name="page_y" value="">';
935print '<input type="hidden" name="mode" value="'.$mode.'">';
936
937if (empty($arrayfields['p.fk_product_type']['checked'])) {
938 print '<input type="hidden" name="search_type" value="'.dol_escape_htmltag($search_type).'">';
939}
940
941$picto = 'product';
942if ($type == 1) {
943 $picto = 'service';
944}
945
946print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
947
948$topicmail = "Information";
949$modelmail = "product";
950$objecttmp = new Product($db);
951$trackid = 'prod'.$object->id;
952include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
953
954if (!empty($catid)) {
955 print "<div id='ways'>";
956 $c = new Categorie($db);
957 $ways = $c->print_all_ways(' &gt; ', 'product/list.php');
958 print " &gt; ".$ways[0]."<br>\n";
959 print "</div><br>";
960}
961
962if ($search_all) {
963 $setupstring = '';
964 foreach ($fieldstosearchall as $key => $val) {
965 $fieldstosearchall[$key] = $langs->trans($val);
966 $setupstring .= $key."=".$val.";";
967 }
968 print '<!-- Search done like if PRODUCT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
969 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
970}
971
972// Filter on categories
973$moreforfilter = '';
974if (isModEnabled('category') && $user->hasRight('categorie', 'read')) {
975 $formcategory = new FormCategory($db);
976 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PRODUCT, $searchCategoryProductList, 'minwidth300', $searchCategoryProductOperator ? $searchCategoryProductOperator : 0);
977}
978
979// Show/hide child variant products
980if (isModEnabled('variants')) {
981 $moreforfilter .= '<div class="divsearchfield">';
982 $moreforfilter .= '<input type="checkbox" id="search_show_childproducts" name="search_show_childproducts"'.($show_childproducts ? 'checked="checked"' : '').'>';
983 $moreforfilter .= ' <label for="search_show_childproducts">'.$langs->trans('ShowChildProducts').'</label>';
984 $moreforfilter .= '</div>';
985}
986
987$parameters = array();
988$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
989if (empty($reshook)) {
990 $moreforfilter .= $hookmanager->resPrint;
991} else {
992 $moreforfilter = $hookmanager->resPrint;
993}
994
995if (!empty($moreforfilter)) {
996 print '<div class="liste_titre liste_titre_bydiv centpercent">';
997 print $moreforfilter;
998 print '</div>';
999}
1000
1001$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1002$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields with user setup
1003$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
1004$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
1005
1006print '<div class="div-table-responsive">';
1007print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1008
1009// Fields title search
1010// --------------------------------------------------------------------
1011print '<tr class="liste_titre_filter">';
1012// Action column
1013if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1014 print '<td class="liste_titre center maxwidthsearch">';
1015 $searchpicto = $form->showFilterButtons('left');
1016 print $searchpicto;
1017 print '</td>';
1018}
1019if (!empty($arrayfields['p.rowid']['checked'])) {
1020 print '<td class="liste_titre left">';
1021 print '<input class="flat width50" type="text" name="search_id" value="'.dol_escape_htmltag($search_id).'">';
1022 print '</td>';
1023}
1024if (!empty($arrayfields['p.ref']['checked'])) {
1025 print '<td class="liste_titre left">';
1026 print '<input class="flat width75" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
1027 print '</td>';
1028}
1029if (!empty($arrayfields['p.ref_ext']['checked'])) {
1030 print '<td class="liste_titre left">';
1031 print '<input class="flat width75" type="text" name="search_ref_ext" value="'.dol_escape_htmltag($search_ref_ext).'">';
1032 print '</td>';
1033}
1034if (!empty($arrayfields['pfp.ref_fourn']['checked'])) {
1035 print '<td class="liste_titre left">';
1036 print '<input class="flat width75" type="text" name="search_ref_supplier" value="'.dol_escape_htmltag($search_ref_supplier).'">';
1037 print '</td>';
1038}
1039// Thumbnail
1040if (!empty($arrayfields['thumbnail']['checked'])) {
1041 print '<td class="liste_titre center">';
1042 print '</td>';
1043}
1044if (!empty($arrayfields['p.label']['checked'])) {
1045 print '<td class="liste_titre left">';
1046 print '<input class="flat width100" type="text" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
1047 print '</td>';
1048}
1049// Type
1050if (!empty($arrayfields['p.fk_product_type']['checked'])) {
1051 print '<td class="liste_titre center">';
1052 $array = array('-1' => '&nbsp;', '0' => $langs->trans('Product'), '1' => $langs->trans('Service'));
1053 print $form->selectarray('search_type', $array, $search_type);
1054 print '</td>';
1055}
1056// Description
1057if (!empty($arrayfields['p.description']['checked'])) {
1058 print '<td class="liste_titre left">';
1059 print '</td>';
1060}
1061// Barcode
1062if (!empty($arrayfields['p.barcode']['checked'])) {
1063 print '<td class="liste_titre">';
1064 print '<input class="flat" type="text" name="search_barcode" size="6" value="'.dol_escape_htmltag($search_barcode).'">';
1065 print '</td>';
1066}
1067// Duration
1068if (!empty($arrayfields['p.duration']['checked'])) {
1069 print '<td class="liste_titre">';
1070 print '</td>';
1071}
1072// Parent
1073if (!empty($arrayfields['pac.fk_product_parent']['checked'])) {
1074 print '<td class="liste_titre">';
1075 print '</td>';
1076}
1077// Finished
1078if (!empty($arrayfields['p.finished']['checked'])) {
1079 print '<td class="liste_titre">';
1080 print $formproduct->selectProductNature('search_finished', $search_finished);
1081 print '</td>';
1082}
1083// Weight
1084if (!empty($arrayfields['p.weight']['checked'])) {
1085 print '<td class="liste_titre">';
1086 print '</td>';
1087}
1088// Weight units
1089if (!empty($arrayfields['p.weight_units']['checked'])) {
1090 print '<td class="liste_titre">';
1091 print '</td>';
1092}
1093// Length
1094if (!empty($arrayfields['p.length']['checked'])) {
1095 print '<td class="liste_titre">';
1096 print '</td>';
1097}
1098// Length units
1099if (!empty($arrayfields['p.length_units']['checked'])) {
1100 print '<td class="liste_titre">';
1101 print '</td>';
1102}
1103// Width
1104if (!empty($arrayfields['p.width']['checked'])) {
1105 print '<td class="liste_titre">';
1106 print '</td>';
1107}
1108// Width units
1109if (!empty($arrayfields['p.width_units']['checked'])) {
1110 print '<td class="liste_titre">';
1111 print '</td>';
1112}
1113// Height
1114if (!empty($arrayfields['p.height']['checked'])) {
1115 print '<td class="liste_titre">';
1116 print '</td>';
1117}
1118// Height units
1119if (!empty($arrayfields['p.height_units']['checked'])) {
1120 print '<td class="liste_titre">';
1121 print '</td>';
1122}
1123// Surface
1124if (!empty($arrayfields['p.surface']['checked'])) {
1125 print '<td class="liste_titre">';
1126 print '</td>';
1127}
1128// Surface units
1129if (!empty($arrayfields['p.surface_units']['checked'])) {
1130 print '<td class="liste_titre">';
1131 print '</td>';
1132}
1133// Volume
1134if (!empty($arrayfields['p.volume']['checked'])) {
1135 print '<td class="liste_titre">';
1136 print '</td>';
1137}
1138// Volume units
1139if (!empty($arrayfields['p.volume_units']['checked'])) {
1140 print '<td class="liste_titre">';
1141 print '</td>';
1142}
1143
1144// Unit
1145if (!empty($arrayfields['cu.label']['checked'])) {
1146 print '<td class="liste_titre">';
1147 print $form->selectUnits($search_units, 'search_units', 1);
1148 print '</td>';
1149}
1150
1151// Default workstation
1152if (!empty($arrayfields['p.fk_default_workstation']['checked'])) {
1153 print '<td class="liste_titre">';
1154 print '<input class="flat width75" type="text" name="search_default_workstation" value="'.dol_escape_htmltag($search_default_workstation).'">';
1155 print '</td>';
1156}
1157
1158// Sell price
1159if (!empty($arrayfields['p.sellprice']['checked'])) {
1160 print '<td class="liste_titre right">';
1161 print '</td>';
1162}
1163
1164// Multiprice
1165if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
1166 foreach ($arraypricelevel as $key => $value) {
1167 if (!empty($arrayfields['p.sellprice'.$key]['checked'])) {
1168 print '<td class="liste_titre right">';
1169 print '</td>';
1170 }
1171 }
1172}
1173
1174// Minimum buying Price
1175if (!empty($arrayfields['p.minbuyprice']['checked'])) {
1176 print '<td class="liste_titre">';
1177 print '&nbsp;';
1178 print '</td>';
1179}
1180// Number buying Price
1181if (!empty($arrayfields['p.numbuyprice']['checked'])) {
1182 print '<td class="liste_titre">';
1183 print '&nbsp;';
1184 print '</td>';
1185}
1186// VAT or Sell Tax Rate
1187if (!empty($arrayfields['p.tva_tx']['checked'])) {
1188 print '<td class="liste_titre right">';
1189 print '<input class="right flat maxwidth50" placeholder="%" type="text" name="search_vatrate" size="1" value="'.dol_escape_htmltag($search_vatrate).'">';
1190 print '</td>';
1191}
1192// WAP
1193if (!empty($arrayfields['p.pmp']['checked'])) {
1194 print '<td class="liste_titre">';
1195 print '&nbsp;';
1196 print '</td>';
1197}
1198// cost_price
1199if (!empty($arrayfields['p.cost_price']['checked'])) {
1200 print '<td class="liste_titre">';
1201 print '&nbsp;';
1202 print '</td>';
1203}
1204// Limit for alert
1205if (!empty($arrayfields['p.seuil_stock_alerte']['checked'])) {
1206 print '<td class="liste_titre">';
1207 print '&nbsp;';
1208 print '</td>';
1209}
1210// Desired stock
1211if (!empty($arrayfields['p.desiredstock']['checked'])) {
1212 print '<td class="liste_titre">';
1213 print '&nbsp;';
1214 print '</td>';
1215}
1216// Stock
1217if (!empty($arrayfields['p.stock']['checked'])) {
1218 print '<td class="liste_titre">&nbsp;</td>';
1219}
1220// Stock
1221if (!empty($arrayfields['stock_virtual']['checked'])) {
1222 print '<td class="liste_titre">&nbsp;</td>';
1223}
1224// To batch
1225if (!empty($arrayfields['p.tobatch']['checked'])) {
1226 print '<td class="liste_titre center">';
1227 $statutarray = array(
1228 '-1' => '',
1229 '0' => $langs->trans("ProductStatusNotOnBatchShort"),
1230 '1' => $langs->trans("ProductStatusOnBatchShort"),
1231 '2' => $langs->trans("ProductStatusOnSerialShort")
1232 );
1233 print $form->selectarray('search_tobatch', $statutarray, $search_tobatch);
1234 print '</td>';
1235}
1236// Country
1237if (!empty($arrayfields['p.fk_country']['checked'])) {
1238 print '<td class="liste_titre center">';
1239 print $form->select_country($search_country, 'search_country', '', 0);
1240 print '</td>';
1241}
1242// State
1243if (!empty($arrayfields['p.fk_state']['checked'])) {
1244 print '<td class="liste_titre center">';
1245 print $formcompany->select_state($search_state, $search_country);
1246 print '</td>';
1247}
1248// Accountancy code sell
1249if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell']['checked'])) {
1250 print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_sell" value="'.dol_escape_htmltag($search_accountancy_code_sell).'"></td>';
1251}
1252if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_intra']['checked'])) {
1253 print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_sell_intra" value="'.dol_escape_htmltag($search_accountancy_code_sell_intra).'"></td>';
1254}
1255if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_export']['checked'])) {
1256 print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_sell_export" value="'.dol_escape_htmltag($search_accountancy_code_sell_export).'"></td>';
1257}
1258// Accountancy code buy
1259if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy']['checked'])) {
1260 print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_buy" value="'.dol_escape_htmltag($search_accountancy_code_buy).'"></td>';
1261}
1262if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_intra']['checked'])) {
1263 print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_buy_intra" value="'.dol_escape_htmltag($search_accountancy_code_buy_intra).'"></td>';
1264}
1265if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_export']['checked'])) {
1266 print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_buy_export" value="'.dol_escape_htmltag($search_accountancy_code_buy_export).'"></td>';
1267}
1268// Extra fields
1269include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1270// Fields from hook
1271$parameters = array('arrayfields' => $arrayfields);
1272$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1273print $hookmanager->resPrint;
1274// Date creation
1275if (!empty($arrayfields['p.datec']['checked'])) {
1276 print '<td class="liste_titre">';
1277 print '</td>';
1278}
1279// Date modification
1280if (!empty($arrayfields['p.tms']['checked'])) {
1281 print '<td class="liste_titre">';
1282 print '</td>';
1283}
1284if (!empty($arrayfields['p.import_key']['checked'])) {
1285 print '<td class="liste_titre center">';
1286 print '<input class="flat maxwidth75" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
1287 print '</td>';
1288}
1289if (!empty($arrayfields['p.tosell']['checked'])) {
1290 print '<td class="liste_titre center parentonrightofpage">';
1291 print $form->selectarray('search_tosell', array('0' => $langs->trans('ProductStatusNotOnSellShort'), '1' => $langs->trans('ProductStatusOnSellShort')), $search_tosell, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage');
1292 print '</td>';
1293}
1294if (!empty($arrayfields['p.tobuy']['checked'])) {
1295 print '<td class="liste_titre center parentonrightofpage">';
1296 print $form->selectarray('search_tobuy', array('0' => $langs->trans('ProductStatusNotOnBuyShort'), '1' => $langs->trans('ProductStatusOnBuyShort')), $search_tobuy, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage');
1297 print '</td>';
1298}
1299// Action column
1300if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1301 print '<td class="liste_titre center maxwidthsearch">';
1302 $searchpicto = $form->showFilterButtons();
1303 print $searchpicto;
1304 print '</td>';
1305}
1306print '</tr>'."\n";
1307
1308$totalarray = array();
1309$totalarray['nbfield'] = 0;
1310
1311// Fields title label
1312// --------------------------------------------------------------------
1313print '<tr class="liste_titre">';
1314// Action column
1315if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1316 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1317 $totalarray['nbfield']++;
1318}
1319if (!empty($arrayfields['p.rowid']['checked'])) {
1320 print_liste_field_titre($arrayfields['p.rowid']['label'], $_SERVER["PHP_SELF"], "p.rowid", "", $param, "", $sortfield, $sortorder);
1321 $totalarray['nbfield']++;
1322}
1323if (!empty($arrayfields['p.ref']['checked'])) {
1324 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder);
1325 $totalarray['nbfield']++;
1326}
1327if (!empty($arrayfields['p.ref_ext']['checked'])) {
1328 print_liste_field_titre($arrayfields['p.ref_ext']['label'], $_SERVER["PHP_SELF"], "p.ref_ext", "", $param, "", $sortfield, $sortorder);
1329 $totalarray['nbfield']++;
1330}
1331if (!empty($arrayfields['pfp.ref_fourn']['checked'])) {
1332 print_liste_field_titre($arrayfields['pfp.ref_fourn']['label'], $_SERVER["PHP_SELF"], "pfp.ref_fourn", "", $param, "", $sortfield, $sortorder);
1333 $totalarray['nbfield']++;
1334}
1335if (!empty($arrayfields['thumbnail']['checked'])) {
1336 print_liste_field_titre($arrayfields['thumbnail']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
1337 $totalarray['nbfield']++;
1338}
1339if (!empty($arrayfields['p.label']['checked'])) {
1340 print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"], "p.label", "", $param, "", $sortfield, $sortorder);
1341 $totalarray['nbfield']++;
1342}
1343if (!empty($arrayfields['p.fk_product_type']['checked'])) {
1344 // @phan-suppress-next-line PhanTypeInvalidDimOffset
1345 print_liste_field_titre($arrayfields['p.fk_product_type']['label'], $_SERVER["PHP_SELF"], "p.fk_product_type", "", $param, "", $sortfield, $sortorder, 'center ');
1346 $totalarray['nbfield']++;
1347}
1348if (!empty($arrayfields['p.description']['checked'])) {
1349 print_liste_field_titre($arrayfields['p.description']['label'], $_SERVER["PHP_SELF"], "p.description", "", $param, "", $sortfield, $sortorder);
1350 $totalarray['nbfield']++;
1351}
1352if (!empty($arrayfields['p.barcode']['checked'])) {
1353 print_liste_field_titre($arrayfields['p.barcode']['label'], $_SERVER["PHP_SELF"], "p.barcode", "", $param, "", $sortfield, $sortorder);
1354 $totalarray['nbfield']++;
1355}
1356if (!empty($arrayfields['p.duration']['checked'])) {
1357 print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"], "p.duration", "", $param, '', $sortfield, $sortorder, 'center ');
1358 $totalarray['nbfield']++;
1359}
1360if (!empty($arrayfields['pac.fk_product_parent']['checked'])) {
1361 print_liste_field_titre($arrayfields['pac.fk_product_parent']['label'], $_SERVER["PHP_SELF"], "pac.fk_product_parent", "", $param, '', $sortfield, $sortorder, '', empty($arrayfields['pac.fk_product_parent']['help']) ? '' : $arrayfields['pac.fk_product_parent']['help']);
1362 $totalarray['nbfield']++;
1363}
1364if (!empty($arrayfields['p.finished']['checked'])) {
1365 print_liste_field_titre($arrayfields['p.finished']['label'], $_SERVER["PHP_SELF"], "p.finished", "", $param, '', $sortfield, $sortorder, 'center ');
1366 $totalarray['nbfield']++;
1367}
1368if (!empty($arrayfields['p.weight']['checked'])) {
1369 print_liste_field_titre($arrayfields['p.weight']['label'], $_SERVER['PHP_SELF'], 'p.weight', '', $param, '', $sortfield, $sortorder, 'center ');
1370 $totalarray['nbfield']++;
1371}
1372if (!empty($arrayfields['p.weight_units']['checked'])) {
1373 print_liste_field_titre($arrayfields['p.weight_units']['label'], $_SERVER['PHP_SELF'], 'p.weight_units', '', $param, '', $sortfield, $sortorder, 'center ');
1374 $totalarray['nbfield']++;
1375}
1376if (!empty($arrayfields['p.length']['checked'])) {
1377 print_liste_field_titre($arrayfields['p.length']['label'], $_SERVER['PHP_SELF'], 'p.length', '', $param, '', $sortfield, $sortorder, 'center ');
1378 $totalarray['nbfield']++;
1379}
1380if (!empty($arrayfields['p.length_units']['checked'])) {
1381 print_liste_field_titre($arrayfields['p.length_units']['label'], $_SERVER['PHP_SELF'], 'p.length_units', '', $param, '', $sortfield, $sortorder, 'center ');
1382 $totalarray['nbfield']++;
1383}
1384if (!empty($arrayfields['p.width']['checked'])) {
1385 print_liste_field_titre($arrayfields['p.width']['label'], $_SERVER['PHP_SELF'], 'p.width', '', $param, '', $sortfield, $sortorder, 'center ');
1386 $totalarray['nbfield']++;
1387}
1388if (!empty($arrayfields['p.width_units']['checked'])) {
1389 print_liste_field_titre($arrayfields['p.width_units']['label'], $_SERVER['PHP_SELF'], 'p.width_units', '', $param, '', $sortfield, $sortorder, 'center ');
1390 $totalarray['nbfield']++;
1391}
1392if (!empty($arrayfields['p.height']['checked'])) {
1393 print_liste_field_titre($arrayfields['p.height']['label'], $_SERVER['PHP_SELF'], 'p.height', '', $param, '', $sortfield, $sortorder, 'center ');
1394 $totalarray['nbfield']++;
1395}
1396if (!empty($arrayfields['p.height_units']['checked'])) {
1397 print_liste_field_titre($arrayfields['p.height_units']['label'], $_SERVER['PHP_SELF'], 'p.height_units', '', $param, '', $sortfield, $sortorder, 'center ');
1398 $totalarray['nbfield']++;
1399}
1400if (!empty($arrayfields['p.surface']['checked'])) {
1401 print_liste_field_titre($arrayfields['p.surface']['label'], $_SERVER['PHP_SELF'], "p.surface", '', $param, '', $sortfield, $sortorder, 'center ');
1402 $totalarray['nbfield']++;
1403}
1404if (!empty($arrayfields['p.surface_units']['checked'])) {
1405 print_liste_field_titre($arrayfields['p.surface_units']['label'], $_SERVER['PHP_SELF'], 'p.surface_units', '', $param, '', $sortfield, $sortorder, 'center ');
1406 $totalarray['nbfield']++;
1407}
1408if (!empty($arrayfields['p.volume']['checked'])) {
1409 print_liste_field_titre($arrayfields['p.volume']['label'], $_SERVER['PHP_SELF'], 'p.volume', '', $param, '', $sortfield, $sortorder, 'center ');
1410 $totalarray['nbfield']++;
1411}
1412if (!empty($arrayfields['p.volume_units']['checked'])) {
1413 print_liste_field_titre($arrayfields['p.volume_units']['label'], $_SERVER['PHP_SELF'], 'p.volume_units', '', $param, '', $sortfield, $sortorder, 'center ');
1414 $totalarray['nbfield']++;
1415}
1416if (!empty($arrayfields['cu.label']['checked'])) {
1417 print_liste_field_titre($arrayfields['cu.label']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'center ');
1418 $totalarray['nbfield']++;
1419}
1420if (!empty($arrayfields['p.fk_default_workstation']['checked'])) {
1421 print_liste_field_titre($arrayfields['p.fk_default_workstation']['label'], $_SERVER['PHP_SELF'], 'ws.ref', '', $param, '', $sortfield, $sortorder);
1422 $totalarray['nbfield']++;
1423}
1424if (!empty($arrayfields['p.sellprice']['checked'])) {
1425 print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
1426 $totalarray['nbfield']++;
1427}
1428
1429// Multiprices
1430if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
1431 foreach ($arraypricelevel as $key => $value) {
1432 if (!empty($arrayfields['p.sellprice'.$key]['checked'])) {
1433 print_liste_field_titre($arrayfields['p.sellprice'.$key]['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
1434 $totalarray['nbfield']++;
1435 }
1436 }
1437}
1438
1439if (!empty($arrayfields['p.minbuyprice']['checked'])) {
1440 print_liste_field_titre($arrayfields['p.minbuyprice']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
1441 $totalarray['nbfield']++;
1442}
1443if (!empty($arrayfields['p.numbuyprice']['checked'])) {
1444 print_liste_field_titre($arrayfields['p.numbuyprice']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
1445 $totalarray['nbfield']++;
1446}
1447if (!empty($arrayfields['p.tva_tx']['checked'])) {
1448 print_liste_field_titre($arrayfields['p.tva_tx']['label'], $_SERVER["PHP_SELF"], 'p.tva_tx', "", $param, '', $sortfield, $sortorder, 'right ');
1449 $totalarray['nbfield']++;
1450}
1451if (!empty($arrayfields['p.pmp']['checked'])) {
1452 print_liste_field_titre($arrayfields['p.pmp']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
1453 $totalarray['nbfield']++;
1454}
1455if (!empty($arrayfields['p.cost_price']['checked'])) {
1456 print_liste_field_titre($arrayfields['p.cost_price']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
1457 $totalarray['nbfield']++;
1458}
1459if (!empty($arrayfields['p.seuil_stock_alerte']['checked'])) {
1460 print_liste_field_titre($arrayfields['p.seuil_stock_alerte']['label'], $_SERVER["PHP_SELF"], "p.seuil_stock_alerte", "", $param, '', $sortfield, $sortorder, 'right ');
1461 $totalarray['nbfield']++;
1462}
1463if (!empty($arrayfields['p.desiredstock']['checked'])) {
1464 print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"], "p.desiredstock", "", $param, '', $sortfield, $sortorder, 'right ');
1465 $totalarray['nbfield']++;
1466}
1467if (!empty($arrayfields['p.stock']['checked'])) {
1468 print_liste_field_titre($arrayfields['p.stock']['label'], $_SERVER["PHP_SELF"], "p.stock", "", $param, '', $sortfield, $sortorder, 'right ');
1469 $totalarray['nbfield']++;
1470}
1471if (!empty($arrayfields['stock_virtual']['checked'])) {
1472 print_liste_field_titre($arrayfields['stock_virtual']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ', 'VirtualStockDesc');
1473 $totalarray['nbfield']++;
1474}
1475if (!empty($arrayfields['p.tobatch']['checked'])) {
1476 print_liste_field_titre($arrayfields['p.tobatch']['label'], $_SERVER["PHP_SELF"], "p.tobatch", "", $param, '', $sortfield, $sortorder, 'center ');
1477 $totalarray['nbfield']++;
1478}
1479if (!empty($arrayfields['p.fk_country']['checked'])) {
1480 print_liste_field_titre($arrayfields['p.fk_country']['label'], $_SERVER["PHP_SELF"], "p.fk_country", "", $param, '', $sortfield, $sortorder);
1481 $totalarray['nbfield']++;
1482}
1483if (!empty($arrayfields['p.fk_state']['checked'])) {
1484 print_liste_field_titre($arrayfields['p.fk_state']['label'], $_SERVER["PHP_SELF"], "p.fk_state", "", $param, '', $sortfield, $sortorder);
1485 $totalarray['nbfield']++;
1486}
1487if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell']['checked'])) {
1488 print_liste_field_titre($arrayfields[$alias_product_perentity . '.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"], $alias_product_perentity . ".accountancy_code_sell", "", $param, '', $sortfield, $sortorder);
1489 $totalarray['nbfield']++;
1490}
1491if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_intra']['checked'])) {
1492 print_liste_field_titre($arrayfields[$alias_product_perentity . '.accountancy_code_sell_intra']['label'], $_SERVER["PHP_SELF"], $alias_product_perentity . ".accountancy_code_sell_intra", "", $param, '', $sortfield, $sortorder);
1493 $totalarray['nbfield']++;
1494}
1495if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_export']['checked'])) {
1496 print_liste_field_titre($arrayfields[$alias_product_perentity . '.accountancy_code_sell_export']['label'], $_SERVER["PHP_SELF"], $alias_product_perentity . ".accountancy_code_sell_export", "", $param, '', $sortfield, $sortorder);
1497 $totalarray['nbfield']++;
1498}
1499if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy']['checked'])) {
1500 print_liste_field_titre($arrayfields[$alias_product_perentity . '.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"], $alias_product_perentity . ".accountancy_code_buy", "", $param, '', $sortfield, $sortorder);
1501 $totalarray['nbfield']++;
1502}
1503if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_intra']['checked'])) {
1504 print_liste_field_titre($arrayfields[$alias_product_perentity . '.accountancy_code_buy_intra']['label'], $_SERVER["PHP_SELF"], $alias_product_perentity . ".accountancy_code_buy_intra", "", $param, '', $sortfield, $sortorder);
1505 $totalarray['nbfield']++;
1506}
1507if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_export']['checked'])) {
1508 print_liste_field_titre($arrayfields[$alias_product_perentity . '.accountancy_code_buy_export']['label'], $_SERVER["PHP_SELF"], $alias_product_perentity . ".accountancy_code_buy_export", "", $param, '', $sortfield, $sortorder);
1509 $totalarray['nbfield']++;
1510}
1511// Extra fields
1512include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1513// Hook fields
1514$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
1515$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1516print $hookmanager->resPrint;
1517if (!empty($arrayfields['p.datec']['checked'])) {
1518 print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1519 $totalarray['nbfield']++;
1520}
1521if (!empty($arrayfields['p.tms']['checked'])) {
1522 print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1523 $totalarray['nbfield']++;
1524}
1525if (!empty($arrayfields['p.import_key']['checked'])) {
1526 print_liste_field_titre($arrayfields['p.import_key']['label'], $_SERVER["PHP_SELF"], "p.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1527 $totalarray['nbfield']++;
1528}
1529if (!empty($arrayfields['p.tosell']['checked'])) {
1530 print_liste_field_titre($arrayfields['p.tosell']['label'], $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center ');
1531 $totalarray['nbfield']++;
1532}
1533if (!empty($arrayfields['p.tobuy']['checked'])) {
1534 print_liste_field_titre($arrayfields['p.tobuy']['label'], $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center ');
1535 $totalarray['nbfield']++;
1536}
1537// Action column
1538if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1539 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1540 $totalarray['nbfield']++;
1541}
1542print '</tr>'."\n";
1543
1544
1545// Loop on record
1546// --------------------------------------------------------------------
1547$i = 0;
1548$savnbfield = $totalarray['nbfield'];
1549$totalarray = array();
1550$totalarray['nbfield'] = 0;
1551$imaxinloop = ($limit ? min($num, $limit) : $num);
1552while ($i < $imaxinloop) {
1553 $obj = $db->fetch_object($resql);
1554 if (empty($obj)) {
1555 break; // Should not happen
1556 }
1557
1558 // Multilangs
1559 if (getDolGlobalInt('MAIN_MULTILANGS')) { // If multilang is enabled
1560 $sql = "SELECT label";
1561 $sql .= " FROM ".MAIN_DB_PREFIX."product_lang";
1562 $sql .= " WHERE fk_product = ".((int) $obj->rowid);
1563 $sql .= " AND lang = '".$db->escape($langs->getDefaultLang())."'";
1564 $sql .= " LIMIT 1";
1565
1566 $result = $db->query($sql);
1567 if ($result) {
1568 $objtp = $db->fetch_object($result);
1569 if (!empty($objtp->label)) {
1570 $obj->label = $objtp->label;
1571 }
1572 }
1573 }
1574
1575 $parameters = array('staticdata' => $obj);
1576 // Note that $action and $object may have been modified by hook
1577 // do product_static fetch in hook if wanted or anything else
1578 $reshook = $hookmanager->executeHooks('loadStaticObject', $parameters, $product_static, $action);
1579 if (empty($reshook)) {
1580 $product_static->id = $obj->rowid;
1581 $product_static->ref = $obj->ref;
1582 $product_static->ref_ext = $obj->ref_ext;
1583 $product_static->description = $obj->description;
1584 $product_static->ref_fourn = empty($obj->ref_supplier) ? '' : $obj->ref_supplier; // deprecated
1585 $product_static->ref_supplier = empty($obj->ref_supplier) ? '' : $obj->ref_supplier;
1586 $product_static->label = $obj->label;
1587 $product_static->barcode = $obj->barcode;
1588 $product_static->finished = $obj->finished;
1589 $product_static->type = $obj->fk_product_type;
1590 $product_static->status_buy = $obj->tobuy;
1591 $product_static->status = $obj->tosell;
1592 $product_static->status_batch = $obj->tobatch;
1593 $product_static->entity = $obj->entity;
1594 $product_static->pmp = $obj->pmp;
1595 $product_static->accountancy_code_sell = $obj->accountancy_code_sell;
1596 $product_static->accountancy_code_sell_export = $obj->accountancy_code_sell_export;
1597 $product_static->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra;
1598 $product_static->accountancy_code_buy = $obj->accountancy_code_buy;
1599 $product_static->accountancy_code_buy_intra = $obj->accountancy_code_buy_intra;
1600 $product_static->accountancy_code_buy_export = $obj->accountancy_code_buy_export;
1601 $product_static->length = $obj->length;
1602 $product_static->length_units = $obj->length_units;
1603 $product_static->width = $obj->width;
1604 $product_static->width_units = $obj->width_units;
1605 $product_static->height = $obj->height;
1606 $product_static->height_units = $obj->height_units;
1607 $product_static->weight = $obj->weight;
1608 $product_static->weight_units = $obj->weight_units;
1609 $product_static->volume = $obj->volume;
1610 $product_static->volume_units = $obj->volume_units;
1611 $product_static->surface = $obj->surface;
1612 $product_static->surface_units = $obj->surface_units;
1613 if (getDolGlobalString('PRODUCT_USE_UNITS')) {
1614 $product_static->fk_unit = $obj->fk_unit;
1615 }
1616 $product_static->import_key = $obj->import_key;
1617
1618 // STOCK_DISABLE_OPTIM_LOAD can be set to force load_stock whatever is permissions on stock.
1619 if ((isModEnabled('stock') && $user->hasRight('stock', 'lire') && $search_type != 1) || getDolGlobalString('STOCK_DISABLE_OPTIM_LOAD')) { // To optimize call of load_stock
1620 if ($product_static->type != 1 || getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { // Not a service
1621 $option = 'nobatch';
1622 if (empty($arrayfields['stock_virtual']['checked'])) {
1623 $option .= ',novirtual';
1624 }
1625 $product_static->load_stock($option); // Load stock_reel + stock_warehouse. This can also call load_virtual_stock()
1626 }
1627 }
1628 }
1629
1630 $product_static->price = $obj->price;
1631 $product_static->price_ttc = $obj->price_ttc; // Allows to use price_ttc in calculated extra fields (ex : price per kilo)
1632
1633 $object = $product_static;
1634
1635 $usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('product', 'product_advance', 'read_prices') : $user->hasRight('product', 'lire');
1636 if ($product_static->isService()) {
1637 $usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('service', 'service_advance', 'read_prices') : $user->hasRight('service', 'lire');
1638 }
1639
1640 if ($mode == 'kanban') {
1641 if ($i == 0) {
1642 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
1643 print '<div class="box-flex-container kanban">';
1644 }
1645
1646 // Output Kanban
1647 $selected = -1;
1648 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1649 $selected = 0;
1650 if (in_array($object->id, $arrayofselected)) {
1651 $selected = 1;
1652 }
1653 }
1654 print $object->getKanbanView('', array('selected' => $selected));
1655 if ($i == ($imaxinloop - 1)) {
1656 print '</div>';
1657 print '</td></tr>';
1658 }
1659 } else {
1660 // Show line of result
1661 $j = 0;
1662 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
1663
1664 // Action column
1665 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1666 print '<td class="nowrap center">';
1667 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1668 $selected = 0;
1669 if (in_array($object->id, $arrayofselected)) {
1670 $selected = 1;
1671 }
1672 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1673 }
1674 print '</td>';
1675 if (!$i) {
1676 $totalarray['nbfield']++;
1677 }
1678 }
1679 // Rowid
1680 if (!empty($arrayfields['p.rowid']['checked'])) {
1681 print '<td class="nowraponall">';
1682 print $product_static->id;
1683 print "</td>\n";
1684 if (!$i) {
1685 $totalarray['nbfield']++;
1686 }
1687 }
1688
1689 // Ref
1690 if (!empty($arrayfields['p.ref']['checked'])) {
1691 print '<td class="tdoverflowmax250">';
1692 print $product_static->getNomUrl(1);
1693 print "</td>\n";
1694 if (!$i) {
1695 $totalarray['nbfield']++;
1696 }
1697 }
1698
1699 // Ref ext
1700 if (!empty($arrayfields['p.ref_ext']['checked'])) {
1701 print '<td class="tdoverflowmax250" title="'.dolPrintHTMLForAttribute($product_static->ref_ext).'">';
1702 print dolPrintHTML($product_static->ref_ext);
1703 print "</td>\n";
1704 if (!$i) {
1705 $totalarray['nbfield']++;
1706 }
1707 }
1708
1709 // Ref supplier
1710 if (!empty($arrayfields['pfp.ref_fourn']['checked'])) {
1711 print '<td class="tdoverflowmax200">';
1712 print $product_static->getNomUrl(1);
1713 print "</td>\n";
1714 if (!$i) {
1715 $totalarray['nbfield']++;
1716 }
1717 }
1718
1719 // Thumbnail
1720 if (!empty($arrayfields['thumbnail']['checked'])) {
1721 $product_thumbnail_html = '';
1722 if (!empty($product_static->entity)) {
1723 $product_thumbnail = $product_static->show_photos('product', $conf->product->multidir_output[$product_static->entity], 1, 1, 0, 0, 0, 80);
1724 if ($product_static->nbphoto > 0) {
1725 $product_thumbnail_html = $product_thumbnail;
1726 }
1727 }
1728
1729 print '<td class="center">' . $product_thumbnail_html . '</td>';
1730 if (!$i) {
1731 $totalarray['nbfield']++;
1732 }
1733 }
1734
1735 // Label
1736 if (!empty($arrayfields['p.label']['checked'])) {
1737 print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($product_static->label).'">'.$product_static->label.'</td>';
1738 if (!$i) {
1739 $totalarray['nbfield']++;
1740 }
1741 }
1742
1743 // Type
1744 if (!empty($arrayfields['p.fk_product_type']['checked'])) {
1745 print '<td class="center">';
1746 $s = '';
1747 if ($product_static->type == 0) {
1748 $s .= img_picto($langs->trans("Product"), 'product', 'class="paddingleftonly paddingrightonly colorgrey"');
1749 } else {
1750 $s .= img_picto($langs->trans("Service"), 'service', 'class="paddingleftonly paddingrightonly colorgrey"');
1751 }
1752 print $s;
1753 print '</td>';
1754 if (!$i) {
1755 $totalarray['nbfield']++;
1756 }
1757 }
1758
1759 // Description
1760 if (!empty($arrayfields['p.description']['checked'])) {
1761 print '<td class="left">';
1762 // Since description can be very large (several pages of HTML-
1763 // code) we limit to the first two rows
1764 print dolGetFirstLineOfText($product_static->description, 2);
1765 print '</td>';
1766 if (!$i) {
1767 $totalarray['nbfield']++;
1768 }
1769 }
1770
1771 // Barcode
1772 if (!empty($arrayfields['p.barcode']['checked'])) {
1773 print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($product_static->barcode).'">'.dol_escape_htmltag($product_static->barcode).'</td>';
1774 if (!$i) {
1775 $totalarray['nbfield']++;
1776 }
1777 }
1778
1779 // Duration
1780 if (!empty($arrayfields['p.duration']['checked'])) {
1781 print '<td class="center nowraponall">';
1782
1783 if (preg_match('/([^a-z]+)[a-z]$/i', $obj->duration)) {
1784 $duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1);
1785 $duration_unit = substr($obj->duration, -1);
1786
1787 if ((float) $duration_value > 1) {
1788 $dur = array("i" => $langs->trans("Minutes"), "h" => $langs->trans("Hours"), "d" => $langs->trans("Days"), "w" => $langs->trans("Weeks"), "m" => $langs->trans("Months"), "y" => $langs->trans("Years"));
1789 } elseif ((float) $duration_value > 0) {
1790 $dur = array("i" => $langs->trans("Minute"), "h" => $langs->trans("Hour"), "d" => $langs->trans("Day"), "w" => $langs->trans("Week"), "m" => $langs->trans("Month"), "y" => $langs->trans("Year"));
1791 }
1792 print $duration_value;
1793 print((!empty($duration_unit) && isset($dur[$duration_unit]) && $duration_value != '') ? ' '.$langs->trans($dur[$duration_unit]) : '');
1794 } elseif (!preg_match('/^[a-z]$/i', $obj->duration)) { // If duration is a simple char (like 's' of 'm'), we do not show value
1795 print $obj->duration;
1796 }
1797
1798 print '</td>';
1799 if (!$i) {
1800 $totalarray['nbfield']++;
1801 }
1802 }
1803
1804 if (!empty($arrayfields['pac.fk_product_parent']['checked'])) {
1805 print '<td class="nowraponall">';
1806 if ($obj->fk_product_parent > 0) {
1807 if (!empty($conf->cache['product'][$obj->fk_product_parent])) {
1808 $product_parent_static = $conf->cache['product'][$obj->fk_product_parent];
1809 } else {
1810 $product_parent_static = new Product($db);
1811 $product_parent_static->fetch($obj->fk_product_parent);
1812 $conf->cache['product'][$obj->fk_product_parent] = $product_parent_static;
1813 }
1814 print $product_parent_static->getNomUrl(1);
1815 }
1816 print '</td>';
1817 if (!$i) {
1818 $totalarray['nbfield']++;
1819 }
1820 }
1821 // Finished
1822 if (!empty($arrayfields['p.finished']['checked'])) {
1823 print '<td class="center">';
1824 print $product_static->getLibFinished();
1825 print '</td>';
1826 if (!$i) {
1827 $totalarray['nbfield']++;
1828 }
1829 }
1830 // Weight
1831 if (!empty($arrayfields['p.weight']['checked'])) {
1832 print '<td class="center">';
1833 print $product_static->weight;
1834 print '</td>';
1835 if (!$i) {
1836 $totalarray['nbfield']++;
1837 }
1838 }
1839 // Weight units
1840 if (!empty($arrayfields['p.weight_units']['checked'])) {
1841 print '<td class="center">';
1842 if ($product_static->weight != '') {
1843 print measuringUnitString(0, 'weight', $product_static->weight_units);
1844 }
1845 print '</td>';
1846 if (!$i) {
1847 $totalarray['nbfield']++;
1848 }
1849 }
1850 // Length
1851 if (!empty($arrayfields['p.length']['checked'])) {
1852 print '<td class="center">';
1853 print $product_static->length;
1854 print '</td>';
1855 if (!$i) {
1856 $totalarray['nbfield']++;
1857 }
1858 }
1859 // Length units
1860 if (!empty($arrayfields['p.length_units']['checked'])) {
1861 print '<td class="center">';
1862 if ($product_static->length != '') {
1863 print measuringUnitString(0, 'size', $product_static->length_units);
1864 }
1865 print '</td>';
1866 if (!$i) {
1867 $totalarray['nbfield']++;
1868 }
1869 }
1870 // Width
1871 if (!empty($arrayfields['p.width']['checked'])) {
1872 print '<td align="center">';
1873 print $product_static->width;
1874 print '</td>';
1875 if (!$i) {
1876 $totalarray['nbfield']++;
1877 }
1878 }
1879 // Width units
1880 if (!empty($arrayfields['p.width_units']['checked'])) {
1881 print '<td class="center">';
1882 if ($product_static->width != '') {
1883 print measuringUnitString(0, 'size', $product_static->width_units);
1884 }
1885 print '</td>';
1886 if (!$i) {
1887 $totalarray['nbfield']++;
1888 }
1889 }
1890 // Height
1891 if (!empty($arrayfields['p.height']['checked'])) {
1892 print '<td align="center">';
1893 print $product_static->height;
1894 print '</td>';
1895 if (!$i) {
1896 $totalarray['nbfield']++;
1897 }
1898 }
1899 // Height units
1900 if (!empty($arrayfields['p.height_units']['checked'])) {
1901 print '<td class="center">';
1902 if ($product_static->height != '') {
1903 print measuringUnitString(0, 'size', $product_static->height_units);
1904 }
1905 print '</td>';
1906 if (!$i) {
1907 $totalarray['nbfield']++;
1908 }
1909 }
1910 // Surface
1911 if (!empty($arrayfields['p.surface']['checked'])) {
1912 print '<td class="center">';
1913 print $product_static->surface;
1914 print '</td>';
1915 if (!$i) {
1916 $totalarray['nbfield']++;
1917 }
1918 }
1919 // Surface units
1920 if (!empty($arrayfields['p.surface_units']['checked'])) {
1921 print '<td class="center">';
1922 if ($product_static->surface != '') {
1923 print measuringUnitString(0, 'surface', $product_static->surface_units);
1924 }
1925 print '</td>';
1926 if (!$i) {
1927 $totalarray['nbfield']++;
1928 }
1929 }
1930 // Volume
1931 if (!empty($arrayfields['p.volume']['checked'])) {
1932 print '<td class="center">';
1933 print $product_static->volume;
1934 print '</td>';
1935 if (!$i) {
1936 $totalarray['nbfield']++;
1937 }
1938 }
1939 // Volume units
1940 if (!empty($arrayfields['p.volume_units']['checked'])) {
1941 print '<td class="center">';
1942 if ($product_static->volume != '') {
1943 print measuringUnitString(0, 'volume', $product_static->volume_units);
1944 }
1945 print '</td>';
1946 if (!$i) {
1947 $totalarray['nbfield']++;
1948 }
1949 }
1950 // Unit
1951 if (!empty($arrayfields['cu.label']['checked'])) {
1952 print '<td align="center">';
1953 if (!empty($obj->cu_label)) {
1954 print $langs->trans($obj->cu_label);
1955 }
1956 print '</td>';
1957 if (!$i) {
1958 $totalarray['nbfield']++;
1959 }
1960 }
1961
1962 // Default Workstation
1963 if (!empty($arrayfields['p.fk_default_workstation']['checked'])) {
1964 print '<td align="left">';
1965 if (isModEnabled('workstation') && !empty($obj->fk_default_workstation)) {
1966 $workstation_static->id = $obj->fk_default_workstation;
1967 $workstation_static->ref = $obj->ref_workstation;
1968 $workstation_static->status = $obj->status_workstation;
1969
1970 print $workstation_static->getNomUrl(1);
1971 }
1972 print '</td>';
1973 if (!$i) {
1974 $totalarray['nbfield']++;
1975 }
1976 }
1977
1978 // Sell price
1979 if (!empty($arrayfields['p.sellprice']['checked'])) {
1980 print '<td class="right nowraponall">';
1981 if ($product_static->status && $usercancreadprice) {
1982 if ($obj->price_base_type == 'TTC') {
1983 print '<span class="amount">'.price($obj->price_ttc).' '.$langs->trans("TTC").'</span>';
1984 } else {
1985 print '<span class="amount">'.price($obj->price).' '.$langs->trans("HT").'</span>';
1986 }
1987 }
1988 print '</td>';
1989 if (!$i) {
1990 $totalarray['nbfield']++;
1991 }
1992 }
1993
1994 // Multiprices
1995 if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
1996 if (! isset($productpricescache)) {
1997 $productpricescache = array();
1998 }
1999 if (! isset($productpricescache[$obj->rowid])) {
2000 $productpricescache[$obj->rowid] = array();
2001 }
2002
2003 if ($product_static->status && $usercancreadprice) {
2004 // Make 1 request for all price levels (without filter on price_level) and saved result into an cache array
2005 // then reuse the cache array if we need prices for other price levels
2006 $sqlp = "SELECT p.rowid, p.fk_product, p.price, p.price_ttc, p.price_level, p.date_price, p.price_base_type";
2007 $sqlp .= " FROM ".MAIN_DB_PREFIX."product_price as p";
2008 $sqlp .= " WHERE fk_product = ".((int) $obj->rowid);
2009 $sqlp .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC";
2010 $resultp = $db->query($sqlp);
2011 if ($resultp) {
2012 $nump = $db->num_rows($resultp);
2013 $j = 0;
2014 while ($j < $nump) {
2015 $objp = $db->fetch_object($resultp);
2016
2017 if (empty($productpricescache[$obj->rowid][$objp->price_level])) {
2018 $productpricescache[$obj->rowid][$objp->price_level]['price'] = $objp->price;
2019 $productpricescache[$obj->rowid][$objp->price_level]['price_ttc'] = $objp->price_ttc;
2020 $productpricescache[$obj->rowid][$objp->price_level]['price_base_type'] = $objp->price_base_type;
2021 }
2022
2023 $j++;
2024 }
2025
2026 $db->free($resultp);
2027 } else {
2028 dol_print_error($db);
2029 }
2030 }
2031
2032 foreach ($arraypricelevel as $key => $value) {
2033 if (!empty($arrayfields['p.sellprice'.$key]['checked'])) {
2034 print '<td class="right nowraponall">';
2035 if (!empty($productpricescache[$obj->rowid]) && isset($productpricescache[$obj->rowid][$key]['price_base_type'])) {
2036 if ($productpricescache[$obj->rowid][$key]['price_base_type'] == 'TTC') {
2037 print '<span class="amount">'.price($productpricescache[$obj->rowid][$key]['price_ttc']).' '.$langs->trans("TTC").'</span>';
2038 } else {
2039 print '<span class="amount">'.price($productpricescache[$obj->rowid][$key]['price']).' '.$langs->trans("HT").'</span>';
2040 }
2041 }
2042 print '</td>';
2043 if (!$i) {
2044 $totalarray['nbfield']++;
2045 }
2046 }
2047 }
2048 }
2049
2050 // Better buy price
2051 if (!empty($arrayfields['p.minbuyprice']['checked'])) {
2052 print '<td class="right nowraponall">';
2053 if ($product_static->status_buy && $obj->bestpurchaseprice != '' && $usercancreadprice) {
2054 if ($product_fourn->find_min_price_product_fournisseur($obj->rowid) > 0) {
2055 if ($product_fourn->product_fourn_price_id > 0) {
2056 if ((isModEnabled("fournisseur") && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))) {
2057 $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1);
2058 print '<span class="amount">'.$form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent / 100) - $product_fourn->fourn_remise).' '.$langs->trans("HT"), $htmltext).'</span>';
2059 } else {
2060 print '<span class="amount">'.price($product_fourn->fourn_unitprice).' '.$langs->trans("HT").'</span>';
2061 }
2062 }
2063 }
2064 }
2065 print '</td>';
2066 if (!$i) {
2067 $totalarray['nbfield']++;
2068 }
2069 }
2070
2071 // Number of buy prices - Vendor prices
2072 if (!empty($arrayfields['p.numbuyprice']['checked'])) {
2073 print '<td class="right">';
2074 if ($product_static->status_buy && $usercancreadprice) {
2075 if (count($productFournList = $product_fourn->list_product_fournisseur_price($obj->rowid)) > 0) {
2076 $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList);
2077 print $form->textwithpicto(count($productFournList), $htmltext);
2078 }
2079 }
2080 print '</td>';
2081 if (!$i) {
2082 $totalarray['nbfield']++;
2083 }
2084 }
2085
2086 // VAT or Sell Tax Rate
2087 if (!empty($arrayfields['p.tva_tx']['checked'])) {
2088 print '<td class="right">';
2089 print vatrate($obj->tva_tx, true);
2090 print '</td>';
2091 if (!$i) {
2092 $totalarray['nbfield']++;
2093 }
2094 }
2095
2096 // WAP
2097 if (!empty($arrayfields['p.pmp']['checked'])) {
2098 print '<td class="nowrap right">';
2099 if ($usercancreadprice) {
2100 print '<span class="amount">'.price($product_static->pmp, 1, $langs)."</span>";
2101 }
2102 print '</td>';
2103 if (!$i) {
2104 $totalarray['nbfield']++;
2105 }
2106 }
2107 // Cost price
2108 if (!empty($arrayfields['p.cost_price']['checked'])) {
2109 print '<td class="nowrap right">';
2110 //print $obj->cost_price;
2111 if ($usercancreadprice) {
2112 print '<span class="amount">'.price($obj->cost_price).' '.$langs->trans("HT").'</span>';
2113 }
2114 print '</td>';
2115 if (!$i) {
2116 $totalarray['nbfield']++;
2117 }
2118 }
2119
2120 // Limit alert
2121 if (!empty($arrayfields['p.seuil_stock_alerte']['checked'])) {
2122 print '<td class="right">';
2123 if ($product_static->type != 1) {
2124 print $obj->seuil_stock_alerte;
2125 }
2126 print '</td>';
2127 if (!$i) {
2128 $totalarray['nbfield']++;
2129 }
2130 }
2131 // Desired stock
2132 if (!empty($arrayfields['p.desiredstock']['checked'])) {
2133 print '<td class="right">';
2134 if ($product_static->type != 1) {
2135 print $obj->desiredstock;
2136 }
2137 print '</td>';
2138 if (!$i) {
2139 $totalarray['nbfield']++;
2140 }
2141 }
2142 // Stock real
2143 if (!empty($arrayfields['p.stock']['checked'])) {
2144 print '<td class="right">';
2145 if ($product_static->type != 1) {
2146 if ($obj->seuil_stock_alerte != '' && $product_static->stock_reel < (float) $obj->seuil_stock_alerte) {
2147 print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' ';
2148 }
2149 if ($usercancreadprice) {
2150 if ($product_static->stock_reel < 0) {
2151 print '<span class="warning">';
2152 }
2153 print price(price2num($product_static->stock_reel, 'MS'), 0, $langs, 1, 0);
2154 if ($product_static->stock_reel < 0) {
2155 print '</span>';
2156 }
2157 }
2158 }
2159 print '</td>';
2160 if (!$i) {
2161 $totalarray['nbfield']++;
2162 }
2163 }
2164 // Stock virtual
2165 if (!empty($arrayfields['stock_virtual']['checked'])) {
2166 print '<td class="right">';
2167 if ($product_static->type != 1) {
2168 if ($obj->seuil_stock_alerte != '' && $product_static->stock_theorique < (float) $obj->seuil_stock_alerte) {
2169 print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' ';
2170 }
2171 if ($usercancreadprice) {
2172 if ($product_static->stock_theorique < 0) {
2173 print '<span class="warning">';
2174 }
2175 print price(price2num($product_static->stock_theorique, 'MS'), 0, $langs, 1, 0);
2176 if ($product_static->stock_theorique < 0) {
2177 print '</span>';
2178 }
2179 }
2180 }
2181 print '</td>';
2182 if (!$i) {
2183 $totalarray['nbfield']++;
2184 }
2185 }
2186 // Lot/Serial
2187 if (!empty($arrayfields['p.tobatch']['checked'])) {
2188 print '<td class="center">';
2189 print $product_static->getLibStatut(1, 2);
2190 print '</td>';
2191 if (!$i) {
2192 $totalarray['nbfield']++;
2193 }
2194 }
2195 // Country
2196 if (!empty($arrayfields['p.fk_country']['checked'])) {
2197 print '<td>'.getCountry($obj->fk_country, '', $db).'</td>';
2198 if (!$i) {
2199 $totalarray['nbfield']++;
2200 }
2201 }
2202 // State
2203 if (!empty($arrayfields['p.fk_state']['checked'])) {
2204 print '<td>';
2205 if (!empty($obj->fk_state)) {
2206 print getState($obj->fk_state, '0', $db);
2207 }
2208 print '</td>';
2209 if (!$i) {
2210 $totalarray['nbfield']++;
2211 }
2212 }
2213 // Accountancy code sell
2214 if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell']['checked'])) {
2215 print '<td>'.length_accountg($product_static->accountancy_code_sell).'</td>';
2216 if (!$i) {
2217 $totalarray['nbfield']++;
2218 }
2219 }
2220 if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_intra']['checked'])) {
2221 print '<td>'.length_accountg($product_static->accountancy_code_sell_intra).'</td>';
2222 if (!$i) {
2223 $totalarray['nbfield']++;
2224 }
2225 }
2226 if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_export']['checked'])) {
2227 print '<td>'.length_accountg($product_static->accountancy_code_sell_export).'</td>';
2228 if (!$i) {
2229 $totalarray['nbfield']++;
2230 }
2231 }
2232 // Accountancy code buy
2233 if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy']['checked'])) {
2234 print '<td>'.length_accountg($product_static->accountancy_code_buy).'</td>';
2235 if (!$i) {
2236 $totalarray['nbfield']++;
2237 }
2238 }
2239 if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_intra']['checked'])) {
2240 print '<td>'.length_accountg($product_static->accountancy_code_buy_intra).'</td>';
2241 if (!$i) {
2242 $totalarray['nbfield']++;
2243 }
2244 }
2245 if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_export']['checked'])) {
2246 print '<td>'.length_accountg($product_static->accountancy_code_buy_export).'</td>';
2247 if (!$i) {
2248 $totalarray['nbfield']++;
2249 }
2250 }
2251 // Extra fields
2252 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
2253 // Fields from hook
2254 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
2255 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2256 print $hookmanager->resPrint;
2257 // Date creation
2258 if (!empty($arrayfields['p.datec']['checked'])) {
2259 print '<td class="center nowraponall">';
2260 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
2261 print '</td>';
2262 if (!$i) {
2263 $totalarray['nbfield']++;
2264 }
2265 }
2266 // Date modification
2267 if (!empty($arrayfields['p.tms']['checked'])) {
2268 print '<td class="center nowraponall">';
2269 print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser');
2270 print '</td>';
2271 if (!$i) {
2272 $totalarray['nbfield']++;
2273 }
2274 }
2275
2276 // Import ID
2277 if (!empty($arrayfields['p.import_key']['checked'])) {
2278 print '<td class="center nowrap">';
2279 print dol_escape_htmltag($product_static->import_key);
2280 print '</td>';
2281 if (!$i) {
2282 $totalarray['nbfield']++;
2283 }
2284 }
2285
2286 // Status (to sell)
2287 if (!empty($arrayfields['p.tosell']['checked'])) {
2288 print '<td class="center nowrap">';
2289 if (!empty($conf->use_javascript_ajax) && $user->hasRight("produit", "creer") && getDolGlobalString('MAIN_DIRECT_STATUS_UPDATE')) {
2290 print ajax_object_onoff($product_static, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell');
2291 } else {
2292 print $product_static->LibStatut($product_static->status, 5, 0);
2293 }
2294 print '</td>';
2295 if (!$i) {
2296 $totalarray['nbfield']++;
2297 }
2298 }
2299 // Status (to buy)
2300 if (!empty($arrayfields['p.tobuy']['checked'])) {
2301 print '<td class="center nowrap">';
2302 if (!empty($conf->use_javascript_ajax) && $user->hasRight("produit", "creer") && getDolGlobalString('MAIN_DIRECT_STATUS_UPDATE')) {
2303 print ajax_object_onoff($product_static, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy');
2304 } else {
2305 print $product_static->LibStatut($product_static->status_buy, 5, 1);
2306 }
2307 print '</td>';
2308 if (!$i) {
2309 $totalarray['nbfield']++;
2310 }
2311 }
2312
2313 // Action column
2314 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
2315 print '<td class="nowrap center">';
2316 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2317 $selected = 0;
2318 if (in_array($object->id, $arrayofselected)) {
2319 $selected = 1;
2320 }
2321 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
2322 }
2323 print '</td>';
2324 if (!$i) {
2325 $totalarray['nbfield']++;
2326 }
2327 }
2328
2329 print '</tr>'."\n";
2330 }
2331
2332 $i++;
2333}
2334
2335// If no record found
2336if ($num == 0) {
2337 $colspan = 1;
2338 foreach ($arrayfields as $key => $val) {
2339 if (!empty($val['checked'])) {
2340 $colspan++;
2341 }
2342 }
2343 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
2344}
2345
2346$db->free($resql);
2347
2348print '</table>'."\n";
2349print '</div>'."\n";
2350
2351print '</form>'."\n";
2352
2353// End of page
2354llxFooter();
2355$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
clean_account($account)
Return accounting account without zero on the right.
ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input=array(), $morecss='', $htmlname='', $forcenojs=0, $moreparam='')
On/off button to change a property status of an object This uses the ajax service objectonoff....
Definition ajax.lib.php:750
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:87
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:71
$c
Definition line.php:327
Class to manage canvas.
Class to manage categories.
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 manage generation of HTML components Only common components must be here.
Class with static methods for building HTML components related to products Only components common to ...
Class to manage predefined suppliers products.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Class for Workstation.
getState($id, $withcode='0', $dbtouse=null, $withregion=0, $outputlangs=null, $entconv=1)
Return state translated from an id.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
dolExplodeIntoArray($string, $delimiter=';', $kv='=')
Split a string with 2 keys into key 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)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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 '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
measuringUnitString($unitid, $measuring_style='', $unitscale='', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
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.