36 require
'../main.inc.php';
37 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
45 if (!empty($conf->categorie->enabled)) {
46 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
50 $langs->loadLangs(array(
'products',
'stocks',
'suppliers',
'companies',
'margins'));
51 if (!empty($conf->productbatch->enabled)) {
52 $langs->load(
"productbatch");
55 $action =
GETPOST(
'action',
'aZ09');
56 $massaction =
GETPOST(
'massaction',
'alpha');
57 $show_files =
GETPOST(
'show_files',
'int');
58 $confirm =
GETPOST(
'confirm',
'alpha');
59 $toselect =
GETPOST(
'toselect',
'array');
61 $sall = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
62 $search_id =
GETPOST(
"search_id",
'alpha');
63 $search_ref =
GETPOST(
"search_ref",
'alpha');
64 $search_ref_supplier =
GETPOST(
"search_ref_supplier",
'alpha');
65 $search_barcode =
GETPOST(
"search_barcode",
'alpha');
66 $search_label =
GETPOST(
"search_label",
'alpha');
67 $search_type =
GETPOST(
"search_type",
'int');
68 $search_vatrate =
GETPOST(
"search_vatrate",
'alpha');
69 $searchCategoryProductOperator = 0;
71 $searchCategoryProductOperator =
GETPOST(
'search_category_product_operator',
'int');
72 } elseif (!empty($conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT)) {
73 $searchCategoryProductOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT;
75 $searchCategoryProductList =
GETPOST(
'search_category_product_list',
'array');
76 $search_tosell =
GETPOST(
"search_tosell",
'int');
77 $search_tobuy =
GETPOST(
"search_tobuy",
'int');
78 $search_country =
GETPOST(
"search_country",
'int');
79 $search_state =
GETPOST(
"state_id",
'int');
80 $fourn_id =
GETPOST(
"fourn_id",
'int');
81 $catid =
GETPOST(
'catid',
'int');
82 $search_tobatch =
GETPOST(
"search_tobatch",
'int');
83 $search_accountancy_code_sell =
GETPOST(
"search_accountancy_code_sell",
'alpha');
84 $search_accountancy_code_sell_intra =
GETPOST(
"search_accountancy_code_sell_intra",
'alpha');
85 $search_accountancy_code_sell_export =
GETPOST(
"search_accountancy_code_sell_export",
'alpha');
86 $search_accountancy_code_buy =
GETPOST(
"search_accountancy_code_buy",
'alpha');
87 $search_accountancy_code_buy_intra =
GETPOST(
"search_accountancy_code_buy_intra",
'alpha');
88 $search_accountancy_code_buy_export =
GETPOST(
"search_accountancy_code_buy_export",
'alpha');
89 $search_finished =
GETPOST(
"search_finished",
'int');
90 $optioncss =
GETPOST(
'optioncss',
'alpha');
94 if (!empty($conf->variants->enabled) && !empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
95 $show_childproducts =
GETPOST(
'search_show_childproducts');
97 $show_childproducts =
'';
100 $diroutputmassaction = $conf->product->dir_output.
'/temp/massgeneration/'.$user->id;
102 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
103 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
104 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
106 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
109 $offset = $limit * $page;
110 $pageprev = $page - 1;
111 $pagenext = $page + 1;
113 $sortfield =
"p.ref";
120 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'productservicelist';
121 if ((
string) $type ==
'1') {
122 $contextpage =
'servicelist';
if ($search_type ==
'') {
126 if ((
string) $type ==
'0') {
127 $contextpage =
'productlist';
if ($search_type ==
'') {
134 $hookmanager->initHooks(array(
'productservicelist'));
141 $extrafields->fetch_name_optionals_label($object->table_element);
142 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
144 if (empty($action)) {
151 if (!empty($canvas)) {
152 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
153 $objcanvas =
new Canvas($db, $action);
154 $objcanvas->getCanvas(
'product',
'list', $canvas);
158 $virtualdiffersfromphysical = 0;
159 if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)
160 || !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)
161 || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)
162 || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)
163 || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)
164 || !empty($conf->mrp->enabled)) {
165 $virtualdiffersfromphysical = 1;
169 $fieldstosearchall = array(
171 'p.label'=>
"ProductLabel",
172 'p.description'=>
"Description",
174 'pfp.ref_fourn'=>
"RefSupplier",
178 if (!empty($conf->global->MAIN_MULTILANGS)) {
179 $fieldstosearchall[
'pl.label'] =
'ProductLabelTranslated';
180 $fieldstosearchall[
'pl.description'] =
'ProductDescriptionTranslated';
181 $fieldstosearchall[
'pl.note'] =
'ProductNoteTranslated';
183 if (!empty($conf->barcode->enabled)) {
184 $fieldstosearchall[
'p.barcode'] =
'Gencod';
185 $fieldstosearchall[
'pfp.barcode'] =
'GencodBuyPrice';
188 if (!empty($conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS)) {
192 if (empty($conf->global->PRODUIT_MULTIPRICES)) {
193 $titlesellprice = $langs->trans(
"SellingPrice");
194 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
195 $titlesellprice =
$form->textwithpicto($langs->trans(
"SellingPrice"), $langs->trans(
"DefaultPriceRealPriceMayDependOnCustomer"));
201 $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ?
"p" :
"ppe";
204 $arrayfields = array(
205 'p.rowid'=>array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>1,
'visible'=>-2,
'noteditable'=>1,
'notnull'=> 1,
'index'=>1,
'position'=>1,
'comment'=>
'Id',
'css'=>
'left'),
206 'p.ref'=>array(
'label'=>
"Ref",
'checked'=>1,
'position'=>10),
208 'thumbnail'=>array(
'label'=>
'Photo',
'checked'=>0,
'position'=>10),
209 'p.label'=>array(
'label'=>
"Label",
'checked'=>1,
'position'=>10),
210 'p.fk_product_type'=>array(
'label'=>
"Type",
'checked'=>0,
'enabled'=>(!empty($conf->product->enabled) && !empty($conf->service->enabled)),
'position'=>11),
211 'p.barcode'=>array(
'label'=>
"Gencod",
'checked'=>1,
'enabled'=>(!empty($conf->barcode->enabled)),
'position'=>12),
212 'p.duration'=>array(
'label'=>
"Duration",
'checked'=>($contextpage !=
'productlist'),
'enabled'=>(!empty($conf->service->enabled) && (
string) $type ==
'1'),
'position'=>13),
213 'p.finished'=>array(
'label'=>
"Nature",
'checked'=>0,
'enabled'=>(!empty($conf->product->enabled) && $type !=
'1'),
'position'=>19),
214 'p.weight'=>array(
'label'=>
'Weight',
'checked'=>0,
'enabled'=>(!empty($conf->product->enabled) && $type !=
'1'),
'position'=>20),
215 'p.weight_units'=>array(
'label'=>
'WeightUnits',
'checked'=>0,
'enabled'=>(!empty($conf->product->enabled) && $type !=
'1'),
'position'=>21),
216 'p.length'=>array(
'label'=>
'Length',
'checked'=>0,
'enabled'=>(!empty($conf->product->enabled) && empty($conf->global->PRODUCT_DISABLE_SIZE) && $type !=
'1'),
'position'=>22),
217 'p.length_units'=>array(
'label'=>
'LengthUnits',
'checked'=>0,
'enabled'=>(!empty($conf->product->enabled) && empty($conf->global->PRODUCT_DISABLE_SIZE) && $type !=
'1'),
'position'=>23),
218 'p.width'=>array(
'label'=>
'Width',
'checked'=>0,
'enabled'=>(!empty($conf->product->enabled) && empty($conf->global->PRODUCT_DISABLE_SIZE) && $type !=
'1'),
'position'=>24),
219 'p.width_units'=>array(
'label'=>
'WidthUnits',
'checked'=>0,
'enabled'=>(!empty($conf->product->enabled) && empty($conf->global->PRODUCT_DISABLE_SIZE) && $type !=
'1'),
'position'=>25),
220 'p.height'=>array(
'label'=>
'Height',
'checked'=>0,
'enabled'=>(!empty($conf->product->enabled) && empty($conf->global->PRODUCT_DISABLE_SIZE) && $type !=
'1'),
'position'=>26),
221 'p.height_units'=>array(
'label'=>
'HeightUnits',
'checked'=>0,
'enabled'=>(!empty($conf->product->enabled) && empty($conf->global->PRODUCT_DISABLE_SIZE) && $type !=
'1'),
'position'=>27),
222 'p.surface'=>array(
'label'=>
'Surface',
'checked'=>0,
'enabled'=>(!empty($conf->product->enabled) && empty($conf->global->PRODUCT_DISABLE_SURFACE) && $type !=
'1'),
'position'=>28),
223 'p.surface_units'=>array(
'label'=>
'SurfaceUnits',
'checked'=>0,
'enabled'=>(!empty($conf->product->enabled) && empty($conf->global->PRODUCT_DISABLE_SURFACE) && $type !=
'1'),
'position'=>29),
224 'p.volume'=>array(
'label'=>
'Volume',
'checked'=>0,
'enabled'=>(!empty($conf->product->enabled) && empty($conf->global->PRODUCT_DISABLE_VOLUME) && $type !=
'1'),
'position'=>30),
225 'p.volume_units'=>array(
'label'=>
'VolumeUnits',
'checked'=>0,
'enabled'=>(!empty($conf->product->enabled) && empty($conf->global->PRODUCT_DISABLE_VOLUME) && $type !=
'1'),
'position'=>31),
226 'cu.label'=>array(
'label'=>
"DefaultUnitToShow",
'checked'=>0,
'enabled'=>(!empty($conf->product->enabled) && !empty($conf->global->PRODUCT_USE_UNITS)),
'position'=>32),
227 'p.sellprice'=>array(
'label'=>
"SellingPrice",
'checked'=>1,
'enabled'=>empty($conf->global->PRODUIT_MULTIPRICES),
'position'=>40),
228 'p.tva_tx'=>array(
'label'=>
"VATRate",
'checked'=>0,
'enabled'=>empty($conf->global->PRODUIT_MULTIPRICES),
'position'=>41),
229 'p.minbuyprice'=>array(
'label'=>
"BuyingPriceMinShort",
'checked'=>1,
'enabled'=>(!empty($user->rights->fournisseur->lire)),
'position'=>42),
230 'p.numbuyprice'=>array(
'label'=>
"BuyingPriceNumShort",
'checked'=>0,
'enabled'=>(!empty($user->rights->fournisseur->lire)),
'position'=>43),
231 'p.pmp'=>array(
'label'=>
"PMPValueShort",
'checked'=>0,
'enabled'=>(!empty($user->rights->fournisseur->lire)),
'position'=>44),
232 'p.cost_price'=>array(
'label'=>
"CostPrice",
'checked'=>0,
'enabled'=>(!empty($user->rights->fournisseur->lire)),
'position'=>45),
233 'p.seuil_stock_alerte'=>array(
'label'=>
"StockLimit",
'checked'=>0,
'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && ($contextpage !=
'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES))),
'position'=>50),
234 'p.desiredstock'=>array(
'label'=>
"DesiredStock",
'checked'=>1,
'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && ($contextpage !=
'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES))),
'position'=>51),
235 'p.stock'=>array(
'label'=>
"PhysicalStock",
'checked'=>1,
'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && ($contextpage !=
'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES))),
'position'=>52),
236 'stock_virtual'=>array(
'label'=>
"VirtualStock",
'checked'=>1,
'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && ($contextpage !=
'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) && $virtualdiffersfromphysical),
'position'=>53),
237 'p.tobatch'=>array(
'label'=>
"ManageLotSerial",
'checked'=>0,
'enabled'=>(!empty($conf->productbatch->enabled)),
'position'=>60),
238 'p.fk_country'=>array(
'label'=>
"Country",
'checked'=>0,
'position'=>100),
239 'p.fk_state'=>array(
'label'=>
"State",
'checked'=>0,
'position'=>101),
240 $alias_product_perentity .
'.accountancy_code_sell'=>array(
'label'=>
"ProductAccountancySellCode",
'checked'=>0,
'enabled'=>empty($conf->global->PRODUCT_DISABLE_ACCOUNTING),
'position'=>400),
241 $alias_product_perentity .
'.accountancy_code_sell_intra'=>array(
'label'=>
"ProductAccountancySellIntraCode",
'checked'=>0,
'enabled'=>$isInEEC && empty($conf->global->PRODUCT_DISABLE_ACCOUNTING),
'position'=>401),
242 $alias_product_perentity .
'.accountancy_code_sell_export'=>array(
'label'=>
"ProductAccountancySellExportCode",
'checked'=>0,
'enabled'=>empty($conf->global->PRODUCT_DISABLE_ACCOUNTING),
'position'=>402),
243 $alias_product_perentity .
'.accountancy_code_buy'=>array(
'label'=>
"ProductAccountancyBuyCode",
'checked'=>0,
'enabled'=>empty($conf->global->PRODUCT_DISABLE_ACCOUNTING),
'position'=>403),
244 $alias_product_perentity .
'.accountancy_code_buy_intra'=>array(
'label'=>
"ProductAccountancyBuyIntraCode",
'checked'=>0,
'enabled'=>$isInEEC && empty($conf->global->PRODUCT_DISABLE_ACCOUNTING),
'position'=>404),
245 $alias_product_perentity .
'.accountancy_code_buy_export'=>array(
'label'=>
"ProductAccountancyBuyExportCode",
'checked'=>0,
'enabled'=>empty($conf->global->PRODUCT_DISABLE_ACCOUNTING),
'position'=>405),
246 'p.datec'=>array(
'label'=>
"DateCreation",
'checked'=>0,
'position'=>500),
247 'p.tms'=>array(
'label'=>
"DateModificationShort",
'checked'=>0,
'position'=>500),
248 'p.tosell'=>array(
'label'=>$langs->transnoentitiesnoconv(
"Status").
' ('.$langs->transnoentitiesnoconv(
"Sell").
')',
'checked'=>1,
'position'=>1000),
249 'p.tobuy'=>array(
'label'=>$langs->transnoentitiesnoconv(
"Status").
' ('.$langs->transnoentitiesnoconv(
"Buy").
')',
'checked'=>1,
'position'=>1000)
266 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
267 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
268 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$i;
269 if (!empty($conf->global->$keyforlabel)) {
270 $labelp = $i.
' - '.$langs->transnoentitiesnoconv($conf->global->$keyforlabel);
272 $labelp = $langs->transnoentitiesnoconv(
"SellingPrice").
" ".$i;
274 $arrayfields[
'p.sellprice'.$i] = array(
'label'=>$labelp,
'checked'=>($i == 1 ? 1 : 0),
'enabled'=>$conf->global->PRODUIT_MULTIPRICES,
'position'=>floatval(
'40.'.sprintf(
'%03s', $i)));
275 $arraypricelevel[$i] = array($i);
281 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
287 if ($search_type ==
'0') {
288 $result =
restrictedArea($user,
'produit',
'',
'',
'',
'',
'', 0);
289 } elseif ($search_type ==
'1') {
290 $result =
restrictedArea($user,
'service',
'',
'',
'',
'',
'', 0);
292 $result =
restrictedArea($user,
'produit|service',
'',
'',
'',
'',
'', 0);
300 if (
GETPOST(
'cancel',
'alpha')) {
301 $action =
'list'; $massaction =
'';
303 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
307 $parameters = array();
308 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
313 $rightskey =
'produit';
315 $rightskey =
'service';
318 if (empty($reshook)) {
320 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
323 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
327 $search_ref_supplier =
"";
329 $search_barcode =
"";
330 $searchCategoryProductOperator = 0;
331 $searchCategoryProductList = array();
334 $search_tobatch =
'';
335 $search_country =
"";
337 $search_vatrate =
"";
338 $search_finished =
'';
341 $show_childproducts =
'';
342 $search_accountancy_code_sell =
'';
343 $search_accountancy_code_sell_intra =
'';
344 $search_accountancy_code_sell_export =
'';
345 $search_accountancy_code_buy =
'';
346 $search_accountancy_code_buy_intra =
'';
347 $search_accountancy_code_buy_export =
'';
348 $search_array_options = array();
352 $objectclass =
'Product';
353 if ((
string) $search_type ==
'1') {
354 $objectlabel =
'Services';
356 if ((
string) $search_type ==
'0') {
357 $objectlabel =
'Products';
360 $permissiontoread = $user->rights->{$rightskey}->lire;
361 $permissiontodelete = $user->rights->{$rightskey}->supprimer;
362 $permissiontoadd = $user->rights->{$rightskey}->creer;
363 $uploaddir = $conf->product->dir_output;
364 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
366 if (!$error && $massaction ==
'switchonsalestatus' && $permissiontoadd) {
368 foreach ($toselect as $toselectid) {
369 $result = $product->fetch($toselectid);
370 if ($result > 0 && $product->id > 0) {
371 $product->setStatut($product->status ? 0 : 1,
null,
'product',
'PRODUCT_MODIFY',
'tosell');
375 if (!$error && $massaction ==
'switchonpurchasestatus' && $permissiontoadd) {
377 foreach ($toselect as $toselectid) {
378 $result = $product->fetch($toselectid);
379 if ($result > 0 && $product->id > 0) {
380 $product->setStatut($product->status_buy ? 0 : 1,
null,
'product',
'PRODUCT_MODIFY',
'tobuy');
391 $title = $langs->trans(
"ProductsAndServices");
393 if ($search_type !=
'' && $search_type !=
'-1') {
394 if ($search_type == 1) {
395 $texte = $langs->trans(
"Services");
397 $texte = $langs->trans(
"Products");
400 $texte = $langs->trans(
"ProductsAndServices");
403 $sql =
'SELECT DISTINCT p.rowid, p.ref, p.label, p.fk_product_type, p.barcode, p.price, p.tva_tx, p.price_ttc, p.price_base_type, p.entity,';
404 $sql .=
' p.fk_product_type, p.duration, p.finished, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,';
405 $sql .=
' p.tobatch,';
406 if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
407 $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,";
409 $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,";
411 $sql .=
' p.datec as date_creation, p.tms as date_update, p.pmp, p.stock, p.cost_price,';
412 $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, fk_country, fk_state,';
413 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
414 $sql .=
' p.fk_unit, cu.label as cu_label,';
416 $sql .=
' MIN(pfp.unitprice) as minsellprice';
417 if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) {
418 $sql .=
', pac.rowid prod_comb_id';
421 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
422 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
423 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
427 $parameters = array();
428 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
429 $sql .= $hookmanager->resPrint;
433 $sql .=
' FROM '.MAIN_DB_PREFIX.
'product as p';
434 if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
435 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
437 if (!empty($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
438 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_extrafields as ef on (p.rowid = ef.fk_object)";
440 if (!empty($searchCategoryProductList) || !empty($catid)) {
441 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
"categorie_product as cp ON p.rowid = cp.fk_product";
443 $linktopfp =
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
446 if (!empty($conf->global->MAIN_MULTILANGS)) {
447 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_lang as pl ON pl.fk_product = p.rowid AND pl.lang = '".$db->escape($langs->getDefaultLang()).
"'";
450 if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) {
451 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_attribute_combination pac ON pac.fk_product_child = p.rowid";
453 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
454 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_units cu ON cu.rowid = p.fk_unit";
458 $sql .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
461 $newfieldstosearchall = $fieldstosearchall;
462 unset($newfieldstosearchall[
'pfp.ref_fourn']);
463 unset($newfieldstosearchall[
'pfp.barcode']);
466 $sql .=
natural_search(array_keys($newfieldstosearchall), $sall, 0, 1);
468 $sql .=
' OR EXISTS (SELECT rowid FROM '.MAIN_DB_PREFIX.
'product_fournisseur_price as pfp WHERE pfp.fk_product = p.rowid';
469 $sql .=
' AND ('.natural_search(
'pfp.ref_fourn', $sall, 0, 1);
472 $sql .=
' OR '.natural_search(
'pfp.barcode', $sall, 0, 1);
477 if (
dol_strlen($search_type) && $search_type !=
'-1') {
478 if ($search_type == 1) {
479 $sql .=
" AND p.fk_product_type = 1";
481 $sql .=
" AND p.fk_product_type <> 1";
485 if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) {
486 $sql .=
" AND pac.rowid IS NULL";
498 if ($search_barcode) {
501 if (isset($search_tosell) &&
dol_strlen($search_tosell) > 0 && $search_tosell != -1) {
502 $sql .=
" AND p.tosell = ".((int) $search_tosell);
504 if (isset($search_tobuy) &&
dol_strlen($search_tobuy) > 0 && $search_tobuy != -1) {
505 $sql .=
" AND p.tobuy = ".((int) $search_tobuy);
507 if (isset($search_tobatch) &&
dol_strlen($search_tobatch) > 0 && $search_tobatch != -1) {
508 $sql .=
" AND p.tobatch = ".((int) $search_tobatch);
510 if ($search_vatrate) {
514 $sql .=
" AND p.canvas = '".$db->escape($canvas).
"'";
517 $sql .=
" AND cp.fk_categorie = ".((int) $catid);
520 $sql .=
" AND cp.fk_categorie IS NULL";
522 $searchCategoryProductSqlList = array();
523 if ($searchCategoryProductOperator == 1) {
524 foreach ($searchCategoryProductList as $searchCategoryProduct) {
525 if (intval($searchCategoryProduct) == -2) {
526 $searchCategoryProductSqlList[] =
"cp.fk_categorie IS NULL";
527 } elseif (intval($searchCategoryProduct) > 0) {
528 $searchCategoryProductSqlList[] =
"cp.fk_categorie = ".$db->escape($searchCategoryProduct);
531 if (!empty($searchCategoryProductSqlList)) {
532 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
535 foreach ($searchCategoryProductList as $searchCategoryProduct) {
536 if (intval($searchCategoryProduct) == -2) {
537 $searchCategoryProductSqlList[] =
"cp.fk_categorie IS NULL";
538 } elseif (intval($searchCategoryProduct) > 0) {
539 $searchCategoryProductSqlList[] =
"p.rowid IN (SELECT fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product WHERE fk_categorie = ".((int) $searchCategoryProduct).
")";
542 if (!empty($searchCategoryProductSqlList)) {
543 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
547 $sql .=
" AND pfp.fk_soc = ".((int) $fourn_id);
549 if ($search_country) {
550 $sql .=
" AND p.fk_country = ".((int) $search_country);
553 $sql .=
" AND p.fk_state = ".((int) $search_state);
555 if ($search_finished >= 0 && $search_finished !==
'') {
556 $sql .=
" AND p.finished = ".((int) $search_finished);
558 if ($search_accountancy_code_sell) {
561 if ($search_accountancy_code_sell_intra) {
562 $sql .=
natural_search($alias_product_perentity .
'.accountancy_code_sell_intra',
clean_account($search_accountancy_code_sell_intra));
564 if ($search_accountancy_code_sell_export) {
565 $sql .=
natural_search($alias_product_perentity .
'.accountancy_code_sell_export',
clean_account($search_accountancy_code_sell_export));
567 if ($search_accountancy_code_buy) {
570 if ($search_accountancy_code_buy_intra) {
571 $sql .=
natural_search($alias_product_perentity .
'.accountancy_code_buy_intra',
clean_account($search_accountancy_code_buy_intra));
573 if ($search_accountancy_code_buy_export) {
574 $sql .=
natural_search($alias_product_perentity .
'.accountancy_code_buy_export',
clean_account($search_accountancy_code_buy_export));
578 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
580 $parameters = array();
581 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
582 $sql .= $hookmanager->resPrint;
583 $sql .=
" GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.tva_tx, p.price_ttc, p.price_base_type,";
584 $sql .=
" p.fk_product_type, p.duration, p.finished, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,";
585 $sql .=
' p.datec, p.tms, p.entity, p.tobatch, p.pmp, p.cost_price, p.stock,';
586 if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
587 $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,";
589 $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,";
591 $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, p.fk_country, p.fk_state';
592 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
593 $sql .=
', p.fk_unit, cu.label';
596 if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) {
597 $sql .=
', pac.rowid';
600 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
601 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
602 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key :
'');
606 $parameters = array();
607 $reshook = $hookmanager->executeHooks(
'printFieldSelect', $parameters, $object, $action);
608 $sql .= $hookmanager->resPrint;
610 $sql .= $db->order($sortfield, $sortorder);
612 $nbtotalofrecords =
'';
613 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
615 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
616 $sqlforcount = preg_replace(
'/'.preg_quote($linktopfp,
'/').
'/',
'', $sqlforcount);
617 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
619 $resql = $db->query($sqlforcount);
621 $objforcount = $db->fetch_object(
$resql);
622 $nbtotalofrecords = $objforcount->nbtotalofrecords;
632 if (($page * $limit) > $nbtotalofrecords) {
638 $sql .= $db->plimit($limit + 1, $offset);
640 $resql = $db->query($sql);
643 $num = $db->num_rows(
$resql);
645 $arrayofselected = is_array($toselect) ? $toselect : array();
647 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) {
648 $obj = $db->fetch_object(
$resql);
650 header(
"Location: ".DOL_URL_ROOT.
'/product/card.php?id='.$id);
655 if ($search_type !=
'') {
656 if ($search_type == 0) {
657 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
658 } elseif ($search_type == 1) {
659 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
664 foreach ($searchCategoryProductList as $searchCategoryProduct) {
665 $paramsCat .=
"&search_category_product_list[]=".urlencode($searchCategoryProduct);
669 llxHeader(
'', $title, $helpurl,
'', 0, 0, array(), array(), $paramsCat,
'');
677 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
678 $param .=
'&contextpage='.urlencode($contextpage);
680 if ($limit > 0 && $limit != $conf->liste_limit) {
681 $param .=
'&limit='.urlencode($limit);
684 $param .=
"&sall=".urlencode($sall);
686 if ($searchCategoryProductOperator == 1) {
687 $param .=
"&search_category_product_operator=".urlencode($searchCategoryProductOperator);
689 foreach ($searchCategoryProductList as $searchCategoryProduct) {
690 $param .=
"&search_category_product_list[]=".urlencode($searchCategoryProduct);
693 $param =
"&search_ref=".urlencode($search_ref);
695 if ($search_ref_supplier) {
696 $param =
"&search_ref_supplier=".urlencode($search_ref_supplier);
698 if ($search_barcode) {
699 $param .= ($search_barcode ?
"&search_barcode=".urlencode($search_barcode) :
"");
702 $param .=
"&search_label=".urlencode($search_label);
704 if ($search_tosell !=
'') {
705 $param .=
"&search_tosell=".urlencode($search_tosell);
707 if ($search_tobuy !=
'') {
708 $param .=
"&search_tobuy=".urlencode($search_tobuy);
710 if ($search_tobatch) {
711 $param =
"&search_tobatch=".urlencode($search_tobatch);
713 if ($search_country !=
'') {
714 $param .=
"&search_country=".urlencode($search_country);
716 if ($search_state !=
'') {
717 $param .=
"&search_state=".urlencode($search_state);
719 if ($search_vatrate) {
720 $param =
"&search_vatrate=".urlencode($search_vatrate);
723 $param .=
"&fourn_id=".urlencode($fourn_id);
726 if ($show_childproducts) {
727 $param .= ($show_childproducts ?
"&search_show_childproducts=".urlencode($show_childproducts) :
"");
730 $param .=
'&type='.urlencode($type);
732 if ($search_type !=
'') {
733 $param .=
'&search_type='.urlencode($search_type);
735 if ($optioncss !=
'') {
736 $param .=
'&optioncss='.urlencode($optioncss);
738 if ($search_accountancy_code_sell) {
739 $param =
"&search_accountancy_code_sell=".urlencode($search_accountancy_code_sell);
741 if ($search_accountancy_code_sell_intra) {
742 $param =
"&search_accountancy_code_sell_intra=".urlencode($search_accountancy_code_sell_intra);
744 if ($search_accountancy_code_sell_export) {
745 $param =
"&search_accountancy_code_sell_export=".urlencode($search_accountancy_code_sell_export);
747 if ($search_accountancy_code_buy) {
748 $param =
"&search_accountancy_code_buy=".urlencode($search_accountancy_code_buy);
750 if ($search_accountancy_code_buy_intra) {
751 $param =
"&search_accountancy_code_buy_intra=".urlencode($search_accountancy_code_buy_intra);
753 if ($search_accountancy_code_buy_export) {
754 $param =
"&search_accountancy_code_buy_export=".urlencode($search_accountancy_code_buy_export);
756 if ($search_finished) {
757 $param =
"&search_finished=".urlencode($search_finished);
760 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
763 $arrayofmassactions = array(
764 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
765 'edit_extrafields'=>
img_picto(
'',
'edit',
'class="pictofixedwidth"').$langs->trans(
"ModifyValueExtrafields"),
770 if ($user->rights->{$rightskey}->supprimer) {
771 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
773 if ($user->rights->{$rightskey}->creer) {
774 $arrayofmassactions[
'switchonsalestatus'] =
img_picto(
'',
'stop-circle',
'class="pictofixedwidth"').$langs->trans(
"SwitchOnSaleStatus");
775 $arrayofmassactions[
'switchonpurchasestatus'] =
img_picto(
'',
'stop-circle',
'class="pictofixedwidth"').$langs->trans(
"SwitchOnPurchaseStatus");
777 if (
isModEnabled(
'category') && $user->rights->{$rightskey}->creer) {
778 $arrayofmassactions[
'preaffecttag'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"AffectTag");
780 if (in_array($massaction, array(
'presend',
'predelete',
'preaffecttag',
'edit_extrafields'))) {
781 $arrayofmassactions = array();
783 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
787 $perm = ($user->rights->produit->creer || $user->rights->service->creer);
789 $perm = $user->rights->service->creer;
791 $perm = $user->rights->produit->creer;
796 $params[
'forcenohideoftext'] = 1;
799 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewProduct'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/product/card.php?action=create&type=0',
'', $perm, $params);
802 $label =
'NewProduct';
804 $label =
'NewService';
806 $newcardbutton .=
dolGetButtonTitle($langs->trans($label),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/product/card.php?action=create&type='.$type,
'', $perm, $params);
810 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" name="formulaire">';
811 if ($optioncss !=
'') {
812 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
814 print
'<input type="hidden" name="token" value="'.newToken().
'">';
815 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
816 print
'<input type="hidden" name="action" value="list">';
817 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
818 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
820 print
'<input type="hidden" name="type" value="'.$type.
'">';
821 if (empty($arrayfields[
'p.fk_product_type'][
'checked'])) {
822 print
'<input type="hidden" name="search_type" value="'.dol_escape_htmltag($search_type).
'">';
830 print_barre_liste($texte, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $newcardbutton,
'', $limit, 0, 0, 1);
832 $topicmail =
"Information";
833 $modelmail =
"product";
835 $trackid =
'prod'.$object->id;
836 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
838 if (!empty($catid)) {
839 print
"<div id='ways'>";
841 $ways = $c->print_all_ways(
' > ',
'product/list.php');
842 print
" > ".$ways[0].
"<br>\n";
848 foreach ($fieldstosearchall as $key => $val) {
849 $fieldstosearchall[$key] = $langs->trans($val);
850 $setupstring .= $key.
"=".$val.
";";
852 print
'<!-- Search done like if PRODUCT_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
853 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>'.
"\n";
858 if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
859 $moreforfilter .=
'<div class="divsearchfield">';
860 $moreforfilter .=
img_picto($langs->trans(
'Categories'),
'category',
'class="pictofixedwidth"');
861 $categoriesProductArr =
$form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'', 64, 0, 1);
862 $categoriesProductArr[-2] =
'- '.$langs->trans(
'NotCategorized').
' -';
863 $moreforfilter .=
Form::multiselectarray(
'search_category_product_list', $categoriesProductArr, $searchCategoryProductList, 0, 0,
'minwidth300');
864 $moreforfilter .=
' <input type="checkbox" class="valignmiddle" id="search_category_product_operator" name="search_category_product_operator" value="1"'.($searchCategoryProductOperator == 1 ?
' checked="checked"' :
'').
'/><label class="none valignmiddle" for="search_category_product_operator">'.$langs->trans(
'UseOrOperatorForCategories').
'</label>';
865 $moreforfilter .=
'</div>';
869 if (!empty($conf->variants->enabled) && !empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
870 $moreforfilter .=
'<div class="divsearchfield">';
871 $moreforfilter .=
'<input type="checkbox" id="search_show_childproducts" name="search_show_childproducts"'.($show_childproducts ?
'checked="checked"' :
'').
'>';
872 $moreforfilter .=
' <label for="search_show_childproducts">'.$langs->trans(
'ShowChildProducts').
'</label>';
873 $moreforfilter .=
'</div>';
876 $parameters = array();
877 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
878 if (empty($reshook)) {
879 $moreforfilter .= $hookmanager->resPrint;
881 $moreforfilter = $hookmanager->resPrint;
884 if ($moreforfilter) {
885 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
886 print $moreforfilter;
890 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
892 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
893 if ($massactionbutton) {
894 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
897 print
'<div class="div-table-responsive">';
898 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
901 print
'<tr class="liste_titre_filter">';
902 if (!empty($arrayfields[
'p.rowid'][
'checked'])) {
903 print
'<td class="liste_titre left">';
904 print
'<input class="flat" type="text" name="search_id" size="4" value="'.dol_escape_htmltag($search_id).
'">';
907 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
908 print
'<td class="liste_titre left">';
909 print
'<input class="flat" type="text" name="search_ref" size="8" value="'.dol_escape_htmltag($search_ref).
'">';
912 if (!empty($arrayfields[
'pfp.ref_fourn'][
'checked'])) {
913 print
'<td class="liste_titre left">';
914 print
'<input class="flat" type="text" name="search_ref_supplier" size="8" value="'.dol_escape_htmltag($search_ref_supplier).
'">';
918 if (!empty($arrayfields[
'thumbnail'][
'checked'])) {
919 print
'<td class="liste_titre center">';
922 if (!empty($arrayfields[
'p.label'][
'checked'])) {
923 print
'<td class="liste_titre left">';
924 print
'<input class="flat" type="text" name="search_label" size="12" value="'.dol_escape_htmltag($search_label).
'">';
928 if (!empty($arrayfields[
'p.fk_product_type'][
'checked'])) {
929 print
'<td class="liste_titre center">';
930 $array = array(
'-1'=>
' ',
'0'=>$langs->trans(
'Product'),
'1'=>$langs->trans(
'Service'));
931 print
$form->selectarray(
'search_type', $array, $search_type);
935 if (!empty($arrayfields[
'p.barcode'][
'checked'])) {
936 print
'<td class="liste_titre">';
937 print
'<input class="flat" type="text" name="search_barcode" size="6" value="'.dol_escape_htmltag($search_barcode).
'">';
941 if (!empty($arrayfields[
'p.duration'][
'checked'])) {
942 print
'<td class="liste_titre">';
947 if (!empty($arrayfields[
'p.finished'][
'checked'])) {
948 print
'<td class="liste_titre">';
949 print $formproduct->selectProductNature(
'search_finished', $search_finished);
953 if (!empty($arrayfields[
'p.weight'][
'checked'])) {
954 print
'<td class="liste_titre">';
958 if (!empty($arrayfields[
'p.weight_units'][
'checked'])) {
959 print
'<td class="liste_titre">';
963 if (!empty($arrayfields[
'p.length'][
'checked'])) {
964 print
'<td class="liste_titre">';
968 if (!empty($arrayfields[
'p.length_units'][
'checked'])) {
969 print
'<td class="liste_titre">';
973 if (!empty($arrayfields[
'p.width'][
'checked'])) {
974 print
'<td class="liste_titre">';
978 if (!empty($arrayfields[
'p.width_units'][
'checked'])) {
979 print
'<td class="liste_titre">';
983 if (!empty($arrayfields[
'p.height'][
'checked'])) {
984 print
'<td class="liste_titre">';
988 if (!empty($arrayfields[
'p.height_units'][
'checked'])) {
989 print
'<td class="liste_titre">';
993 if (!empty($arrayfields[
'p.surface'][
'checked'])) {
994 print
'<td class="liste_titre">';
998 if (!empty($arrayfields[
'p.surface_units'][
'checked'])) {
999 print
'<td class="liste_titre">';
1003 if (!empty($arrayfields[
'p.volume'][
'checked'])) {
1004 print
'<td class="liste_titre">';
1008 if (!empty($arrayfields[
'p.volume_units'][
'checked'])) {
1009 print
'<td class="liste_titre">';
1014 if (!empty($arrayfields[
'cu.label'][
'checked'])) {
1015 print
'<td class="liste_titre">';
1020 if (!empty($arrayfields[
'p.sellprice'][
'checked'])) {
1021 print
'<td class="liste_titre right">';
1026 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
1027 foreach ($arraypricelevel as $key => $value) {
1028 if (!empty($arrayfields[
'p.sellprice'.$key][
'checked'])) {
1029 print
'<td class="liste_titre right">';
1036 if (!empty($arrayfields[
'p.minbuyprice'][
'checked'])) {
1037 print
'<td class="liste_titre">';
1042 if (!empty($arrayfields[
'p.numbuyprice'][
'checked'])) {
1043 print
'<td class="liste_titre">';
1048 if (!empty($arrayfields[
'p.tva_tx'][
'checked'])) {
1049 print
'<td class="liste_titre right">';
1050 print
'<input class="right flat maxwidth50" placeholder="%" type="text" name="search_vatrate" size="1" value="'.dol_escape_htmltag($search_vatrate).
'">';
1054 if (!empty($arrayfields[
'p.pmp'][
'checked'])) {
1055 print
'<td class="liste_titre">';
1060 if (!empty($arrayfields[
'p.cost_price'][
'checked'])) {
1061 print
'<td class="liste_titre">';
1066 if (!empty($arrayfields[
'p.seuil_stock_alerte'][
'checked'])) {
1067 print
'<td class="liste_titre">';
1072 if (!empty($arrayfields[
'p.desiredstock'][
'checked'])) {
1073 print
'<td class="liste_titre">';
1078 if (!empty($arrayfields[
'p.stock'][
'checked'])) {
1079 print
'<td class="liste_titre"> </td>';
1082 if (!empty($arrayfields[
'stock_virtual'][
'checked'])) {
1083 print
'<td class="liste_titre"> </td>';
1086 if (!empty($arrayfields[
'p.tobatch'][
'checked'])) {
1087 print
'<td class="liste_titre center">';
1088 $statutarray = array(
1090 '0' => $langs->trans(
"ProductStatusNotOnBatchShort"),
1091 '1' => $langs->trans(
"ProductStatusOnBatchShort"),
1092 '2' => $langs->trans(
"ProductStatusOnSerialShort")
1094 print
$form->selectarray(
'search_tobatch', $statutarray, $search_tobatch);
1098 if (!empty($arrayfields[
'p.fk_country'][
'checked'])) {
1099 print
'<td class="liste_titre center">';
1100 print
$form->select_country($search_country,
'search_country',
'', 0);
1104 if (!empty($arrayfields[
'p.fk_state'][
'checked'])) {
1105 print
'<td class="liste_titre center">';
1106 print $formcompany->select_state($search_state, $search_country);
1110 if (!empty($arrayfields[$alias_product_perentity .
'.accountancy_code_sell'][
'checked'])) {
1111 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>';
1113 if (!empty($arrayfields[$alias_product_perentity .
'.accountancy_code_sell_intra'][
'checked'])) {
1114 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>';
1116 if (!empty($arrayfields[$alias_product_perentity .
'.accountancy_code_sell_export'][
'checked'])) {
1117 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>';
1120 if (!empty($arrayfields[$alias_product_perentity .
'.accountancy_code_buy'][
'checked'])) {
1121 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>';
1123 if (!empty($arrayfields[$alias_product_perentity .
'.accountancy_code_buy_intra'][
'checked'])) {
1124 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>';
1126 if (!empty($arrayfields[$alias_product_perentity .
'.accountancy_code_buy_export'][
'checked'])) {
1127 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>';
1130 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1132 $parameters = array(
'arrayfields'=>$arrayfields);
1133 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
1134 print $hookmanager->resPrint;
1136 if (!empty($arrayfields[
'p.datec'][
'checked'])) {
1137 print
'<td class="liste_titre">';
1141 if (!empty($arrayfields[
'p.tms'][
'checked'])) {
1142 print
'<td class="liste_titre">';
1145 if (!empty($arrayfields[
'p.tosell'][
'checked'])) {
1146 print
'<td class="liste_titre center">';
1147 print
$form->selectarray(
'search_tosell', array(
'0'=>$langs->trans(
'ProductStatusNotOnSellShort'),
'1'=>$langs->trans(
'ProductStatusOnSellShort')), $search_tosell, 1);
1150 if (!empty($arrayfields[
'p.tobuy'][
'checked'])) {
1151 print
'<td class="liste_titre center">';
1152 print
$form->selectarray(
'search_tobuy', array(
'0'=>$langs->trans(
'ProductStatusNotOnBuyShort'),
'1'=>$langs->trans(
'ProductStatusOnBuyShort')), $search_tobuy, 1);
1155 print
'<td class="liste_titre center maxwidthsearch">';
1156 $searchpicto =
$form->showFilterButtons();
1162 print
'<tr class="liste_titre">';
1163 if (!empty($arrayfields[
'p.rowid'][
'checked'])) {
1164 print_liste_field_titre($arrayfields[
'p.rowid'][
'label'], $_SERVER[
"PHP_SELF"],
"p.rowid",
"", $param,
"", $sortfield, $sortorder);
1166 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1167 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"p.ref",
"", $param,
"", $sortfield, $sortorder);
1169 if (!empty($arrayfields[
'pfp.ref_fourn'][
'checked'])) {
1170 print_liste_field_titre($arrayfields[
'pfp.ref_fourn'][
'label'], $_SERVER[
"PHP_SELF"],
"pfp.ref_fourn",
"", $param,
"", $sortfield, $sortorder);
1172 if (!empty($arrayfields[
'thumbnail'][
'checked'])) {
1173 print_liste_field_titre($arrayfields[
'thumbnail'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
1175 if (!empty($arrayfields[
'p.label'][
'checked'])) {
1176 print_liste_field_titre($arrayfields[
'p.label'][
'label'], $_SERVER[
"PHP_SELF"],
"p.label",
"", $param,
"", $sortfield, $sortorder);
1178 if (!empty($arrayfields[
'p.fk_product_type'][
'checked'])) {
1179 print_liste_field_titre($arrayfields[
'p.fk_product_type'][
'label'], $_SERVER[
"PHP_SELF"],
"p.fk_product_type",
"", $param,
"", $sortfield, $sortorder,
'center ');
1181 if (!empty($arrayfields[
'p.barcode'][
'checked'])) {
1182 print_liste_field_titre($arrayfields[
'p.barcode'][
'label'], $_SERVER[
"PHP_SELF"],
"p.barcode",
"", $param,
"", $sortfield, $sortorder);
1184 if (!empty($arrayfields[
'p.duration'][
'checked'])) {
1185 print_liste_field_titre($arrayfields[
'p.duration'][
'label'], $_SERVER[
"PHP_SELF"],
"p.duration",
"", $param,
'', $sortfield, $sortorder,
'center ');
1187 if (!empty($arrayfields[
'p.finished'][
'checked'])) {
1188 print_liste_field_titre($arrayfields[
'p.finished'][
'label'], $_SERVER[
"PHP_SELF"],
"p.finished",
"", $param,
'', $sortfield, $sortorder,
'center ');
1191 if (!empty($arrayfields[
'p.weight'][
'checked'])) {
1192 print_liste_field_titre($arrayfields[
'p.weight'][
'label'], $_SERVER[
'PHP_SELF'],
'p.weight',
'', $param,
'', $sortfield, $sortorder,
'center ');
1194 if (!empty($arrayfields[
'p.weight_units'][
'checked'])) {
1195 print_liste_field_titre($arrayfields[
'p.weight_units'][
'label'], $_SERVER[
'PHP_SELF'],
'p.weight_units',
'', $param,
'', $sortfield, $sortorder,
'center ');
1197 if (!empty($arrayfields[
'p.length'][
'checked'])) {
1198 print_liste_field_titre($arrayfields[
'p.length'][
'label'], $_SERVER[
'PHP_SELF'],
'p.length',
'', $param,
'', $sortfield, $sortorder,
'center ');
1200 if (!empty($arrayfields[
'p.length_units'][
'checked'])) {
1201 print_liste_field_titre($arrayfields[
'p.length_units'][
'label'], $_SERVER[
'PHP_SELF'],
'p.length_units',
'', $param,
'', $sortfield, $sortorder,
'center ');
1203 if (!empty($arrayfields[
'p.width'][
'checked'])) {
1204 print_liste_field_titre($arrayfields[
'p.width'][
'label'], $_SERVER[
'PHP_SELF'],
'p.width',
'', $param,
'', $sortfield, $sortorder,
'center ');
1206 if (!empty($arrayfields[
'p.width_units'][
'checked'])) {
1207 print_liste_field_titre($arrayfields[
'p.width_units'][
'label'], $_SERVER[
'PHP_SELF'],
'p.width_units',
'', $param,
'', $sortfield, $sortorder,
'center ');
1209 if (!empty($arrayfields[
'p.height'][
'checked'])) {
1210 print_liste_field_titre($arrayfields[
'p.height'][
'label'], $_SERVER[
'PHP_SELF'],
'p.height',
'', $param,
'', $sortfield, $sortorder,
'center ');
1212 if (!empty($arrayfields[
'p.height_units'][
'checked'])) {
1213 print_liste_field_titre($arrayfields[
'p.height_units'][
'label'], $_SERVER[
'PHP_SELF'],
'p.height_units',
'', $param,
'', $sortfield, $sortorder,
'center ');
1215 if (!empty($arrayfields[
'p.surface'][
'checked'])) {
1216 print_liste_field_titre($arrayfields[
'p.surface'][
'label'], $_SERVER[
'PHP_SELF'],
"p.surface",
'', $param,
'', $sortfield, $sortorder,
'center ');
1218 if (!empty($arrayfields[
'p.surface_units'][
'checked'])) {
1219 print_liste_field_titre($arrayfields[
'p.surface_units'][
'label'], $_SERVER[
'PHP_SELF'],
'p.surface_units',
'', $param,
'', $sortfield, $sortorder,
'center ');
1221 if (!empty($arrayfields[
'p.volume'][
'checked'])) {
1222 print_liste_field_titre($arrayfields[
'p.volume'][
'label'], $_SERVER[
'PHP_SELF'],
'p.volume',
'', $param,
'', $sortfield, $sortorder,
'center ');
1224 if (!empty($arrayfields[
'p.volume_units'][
'checked'])) {
1225 print_liste_field_titre($arrayfields[
'p.volume_units'][
'label'], $_SERVER[
'PHP_SELF'],
'p.volume_units',
'', $param,
'', $sortfield, $sortorder,
'center ');
1227 if (!empty($arrayfields[
'cu.label'][
'checked'])) {
1228 print_liste_field_titre($arrayfields[
'cu.label'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
1230 if (!empty($arrayfields[
'p.sellprice'][
'checked'])) {
1231 print_liste_field_titre($arrayfields[
'p.sellprice'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"", $param,
'', $sortfield, $sortorder,
'right ');
1235 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
1236 foreach ($arraypricelevel as $key => $value) {
1237 if (!empty($arrayfields[
'p.sellprice'.$key][
'checked'])) {
1238 print_liste_field_titre($arrayfields[
'p.sellprice'.$key][
'label'], $_SERVER[
"PHP_SELF"],
"",
"", $param,
'', $sortfield, $sortorder,
'right ');
1243 if (!empty($arrayfields[
'p.minbuyprice'][
'checked'])) {
1244 print_liste_field_titre($arrayfields[
'p.minbuyprice'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"", $param,
'', $sortfield, $sortorder,
'right ');
1246 if (!empty($arrayfields[
'p.numbuyprice'][
'checked'])) {
1247 print_liste_field_titre($arrayfields[
'p.numbuyprice'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"", $param,
'', $sortfield, $sortorder,
'right ');
1249 if (!empty($arrayfields[
'p.tva_tx'][
'checked'])) {
1250 print_liste_field_titre($arrayfields[
'p.tva_tx'][
'label'], $_SERVER[
"PHP_SELF"],
'p.tva_tx',
"", $param,
'', $sortfield, $sortorder,
'right ');
1252 if (!empty($arrayfields[
'p.pmp'][
'checked'])) {
1253 print_liste_field_titre($arrayfields[
'p.pmp'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"", $param,
'', $sortfield, $sortorder,
'right ');
1255 if (!empty($arrayfields[
'p.cost_price'][
'checked'])) {
1256 print_liste_field_titre($arrayfields[
'p.cost_price'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"", $param,
'', $sortfield, $sortorder,
'right ');
1258 if (!empty($arrayfields[
'p.seuil_stock_alerte'][
'checked'])) {
1259 print_liste_field_titre($arrayfields[
'p.seuil_stock_alerte'][
'label'], $_SERVER[
"PHP_SELF"],
"p.seuil_stock_alerte",
"", $param,
'', $sortfield, $sortorder,
'right ');
1261 if (!empty($arrayfields[
'p.desiredstock'][
'checked'])) {
1262 print_liste_field_titre($arrayfields[
'p.desiredstock'][
'label'], $_SERVER[
"PHP_SELF"],
"p.desiredstock",
"", $param,
'', $sortfield, $sortorder,
'right ');
1264 if (!empty($arrayfields[
'p.stock'][
'checked'])) {
1265 print_liste_field_titre($arrayfields[
'p.stock'][
'label'], $_SERVER[
"PHP_SELF"],
"p.stock",
"", $param,
'', $sortfield, $sortorder,
'right ');
1267 if (!empty($arrayfields[
'stock_virtual'][
'checked'])) {
1268 print_liste_field_titre($arrayfields[
'stock_virtual'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"", $param,
'', $sortfield, $sortorder,
'right ');
1270 if (!empty($arrayfields[
'p.tobatch'][
'checked'])) {
1271 print_liste_field_titre($arrayfields[
'p.tobatch'][
'label'], $_SERVER[
"PHP_SELF"],
"p.tobatch",
"", $param,
'', $sortfield, $sortorder,
'center ');
1273 if (!empty($arrayfields[
'p.fk_country'][
'checked'])) {
1274 print_liste_field_titre($arrayfields[
'p.fk_country'][
'label'], $_SERVER[
"PHP_SELF"],
"p.fk_country",
"", $param,
'', $sortfield, $sortorder);
1276 if (!empty($arrayfields[
'p.fk_state'][
'checked'])) {
1277 print_liste_field_titre($arrayfields[
'p.fk_state'][
'label'], $_SERVER[
"PHP_SELF"],
"p.fk_state",
"", $param,
'', $sortfield, $sortorder);
1279 if (!empty($arrayfields[$alias_product_perentity .
'.accountancy_code_sell'][
'checked'])) {
1280 print_liste_field_titre($arrayfields[$alias_product_perentity .
'.accountancy_code_sell'][
'label'], $_SERVER[
"PHP_SELF"], $alias_product_perentity .
".accountancy_code_sell",
"", $param,
'', $sortfield, $sortorder);
1282 if (!empty($arrayfields[$alias_product_perentity .
'.accountancy_code_sell_intra'][
'checked'])) {
1283 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);
1285 if (!empty($arrayfields[$alias_product_perentity .
'.accountancy_code_sell_export'][
'checked'])) {
1286 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);
1288 if (!empty($arrayfields[$alias_product_perentity .
'.accountancy_code_buy'][
'checked'])) {
1289 print_liste_field_titre($arrayfields[$alias_product_perentity .
'.accountancy_code_buy'][
'label'], $_SERVER[
"PHP_SELF"], $alias_product_perentity .
".accountancy_code_buy",
"", $param,
'', $sortfield, $sortorder);
1291 if (!empty($arrayfields[$alias_product_perentity .
'.accountancy_code_buy_intra'][
'checked'])) {
1292 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);
1294 if (!empty($arrayfields[$alias_product_perentity .
'.accountancy_code_buy_export'][
'checked'])) {
1295 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);
1298 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1300 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
1301 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1302 print $hookmanager->resPrint;
1303 if (!empty($arrayfields[
'p.datec'][
'checked'])) {
1304 print_liste_field_titre($arrayfields[
'p.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"p.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1306 if (!empty($arrayfields[
'p.tms'][
'checked'])) {
1307 print_liste_field_titre($arrayfields[
'p.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"p.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1309 if (!empty($arrayfields[
'p.tosell'][
'checked'])) {
1310 print_liste_field_titre($arrayfields[
'p.tosell'][
'label'], $_SERVER[
"PHP_SELF"],
"p.tosell",
"", $param,
'', $sortfield, $sortorder,
'center ');
1312 if (!empty($arrayfields[
'p.tobuy'][
'checked'])) {
1313 print_liste_field_titre($arrayfields[
'p.tobuy'][
'label'], $_SERVER[
"PHP_SELF"],
"p.tobuy",
"", $param,
'', $sortfield, $sortorder,
'center ');
1315 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1319 $product_static =
new Product($db);
1323 $totalarray = array();
1324 $totalarray[
'nbfield'] = 0;
1325 while ($i < min($num, $limit)) {
1326 $obj = $db->fetch_object(
$resql);
1329 if (!empty($conf->global->MAIN_MULTILANGS)) {
1330 $sql =
"SELECT label";
1331 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
1332 $sql .=
" WHERE fk_product = ".((int) $obj->rowid);
1333 $sql .=
" AND lang = '".$db->escape($langs->getDefaultLang()).
"'";
1336 $result = $db->query($sql);
1338 $objtp = $db->fetch_object($result);
1339 if (!empty($objtp->label)) {
1340 $obj->label = $objtp->label;
1345 $product_static->id = $obj->rowid;
1346 $product_static->ref = $obj->ref;
1347 $product_static->ref_fourn = empty($obj->ref_supplier) ?
'' : $obj->ref_supplier;
1348 $product_static->ref_supplier = empty($obj->ref_supplier) ?
'' : $obj->ref_supplier;
1349 $product_static->label = $obj->label;
1350 $product_static->finished = $obj->finished;
1351 $product_static->type = $obj->fk_product_type;
1352 $product_static->status_buy = $obj->tobuy;
1353 $product_static->status = $obj->tosell;
1354 $product_static->status_batch = $obj->tobatch;
1355 $product_static->entity = $obj->entity;
1356 $product_static->pmp = $obj->pmp;
1357 $product_static->accountancy_code_sell = $obj->accountancy_code_sell;
1358 $product_static->accountancy_code_sell_export = $obj->accountancy_code_sell_export;
1359 $product_static->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra;
1360 $product_static->accountancy_code_buy = $obj->accountancy_code_buy;
1361 $product_static->accountancy_code_buy_intra = $obj->accountancy_code_buy_intra;
1362 $product_static->accountancy_code_buy_export = $obj->accountancy_code_buy_export;
1363 $product_static->length = $obj->length;
1364 $product_static->length_units = $obj->length_units;
1365 $product_static->width = $obj->width;
1366 $product_static->width_units = $obj->width_units;
1367 $product_static->height = $obj->height;
1368 $product_static->height_units = $obj->height_units;
1369 $product_static->weight = $obj->weight;
1370 $product_static->weight_units = $obj->weight_units;
1371 $product_static->volume = $obj->volume;
1372 $product_static->volume_units = $obj->volume_units;
1373 $product_static->surface = $obj->surface;
1374 $product_static->surface_units = $obj->surface_units;
1375 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
1376 $product_static->fk_unit = $obj->fk_unit;
1380 if ((!empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || !empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) {
1381 if ($obj->fk_product_type != 1 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1382 $option =
'nobatch';
1383 if (empty($arrayfields[
'stock_virtual'][
'checked'])) {
1384 $option .=
',novirtual';
1386 $product_static->load_stock($option);
1390 print
'<tr class="oddeven">';
1393 if (!empty($arrayfields[
'p.rowid'][
'checked'])) {
1394 print
'<td class="nowraponall">';
1395 print $product_static->id;
1398 $totalarray[
'nbfield']++;
1403 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1404 print
'<td class="tdoverflowmax200">';
1405 print $product_static->getNomUrl(1);
1408 $totalarray[
'nbfield']++;
1413 if (!empty($arrayfields[
'pfp.ref_fourn'][
'checked'])) {
1414 print
'<td class="tdoverflowmax200">';
1415 print $product_static->getNomUrl(1);
1418 $totalarray[
'nbfield']++;
1423 if (!empty($arrayfields[
'thumbnail'][
'checked'])) {
1424 $product_thumbnail_html =
'';
1425 if (!empty($product_static->entity)) {
1426 $product_thumbnail = $product_static->show_photos(
'product', $conf->product->multidir_output[$product_static->entity], 1, 1, 0, 0, 0, 80);
1427 if ($product_static->nbphoto > 0) {
1428 $product_thumbnail_html = $product_thumbnail;
1432 print
'<td class="center">' . $product_thumbnail_html .
'</td>';
1434 $totalarray[
'nbfield']++;
1439 if (!empty($arrayfields[
'p.label'][
'checked'])) {
1440 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->label).
'">'.$obj->label.
'</td>';
1442 $totalarray[
'nbfield']++;
1447 if (!empty($arrayfields[
'p.fk_product_type'][
'checked'])) {
1448 print
'<td class="center">';
1450 if ($obj->fk_product_type == 0) {
1451 $s .=
img_picto($langs->trans(
"Product"),
'product',
'class="paddingleftonly paddingrightonly colorgrey"');
1453 $s .=
img_picto($langs->trans(
"Service"),
'service',
'class="paddingleftonly paddingrightonly colorgrey"');
1458 $totalarray[
'nbfield']++;
1463 if (!empty($arrayfields[
'p.barcode'][
'checked'])) {
1464 print
'<td>'.$obj->barcode.
'</td>';
1466 $totalarray[
'nbfield']++;
1471 if (!empty($arrayfields[
'p.duration'][
'checked'])) {
1472 print
'<td class="center nowraponall">';
1474 if (preg_match(
'/([^a-z]+)[a-z]$/i', $obj->duration)) {
1475 $duration_value = substr($obj->duration, 0,
dol_strlen($obj->duration) - 1);
1476 $duration_unit = substr($obj->duration, -1);
1478 if ((
float) $duration_value > 1) {
1479 $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"));
1480 } elseif ((
float) $duration_value > 0) {
1481 $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"));
1483 print $duration_value;
1484 print ((!empty($duration_unit) && isset($dur[$duration_unit]) && $duration_value !=
'') ?
' '.$langs->trans($dur[$duration_unit]) :
'');
1485 } elseif (!preg_match(
'/^[a-z]$/i', $obj->duration)) {
1486 print $obj->duration;
1491 $totalarray[
'nbfield']++;
1496 if (!empty($arrayfields[
'p.finished'][
'checked'])) {
1497 print
'<td class="center">';
1498 print $product_static->getLibFinished();
1501 $totalarray[
'nbfield']++;
1506 if (!empty($arrayfields[
'p.weight'][
'checked'])) {
1507 print
'<td class="center">';
1511 $totalarray[
'nbfield']++;
1515 if (!empty($arrayfields[
'p.weight_units'][
'checked'])) {
1516 print
'<td class="center">';
1517 if ($product_static->weight !=
'') {
1522 $totalarray[
'nbfield']++;
1526 if (!empty($arrayfields[
'p.length'][
'checked'])) {
1527 print
'<td class="center">';
1531 $totalarray[
'nbfield']++;
1535 if (!empty($arrayfields[
'p.length_units'][
'checked'])) {
1536 print
'<td class="center">';
1537 if ($product_static->length !=
'') {
1542 $totalarray[
'nbfield']++;
1546 if (!empty($arrayfields[
'p.width'][
'checked'])) {
1547 print
'<td align="center">';
1551 $totalarray[
'nbfield']++;
1555 if (!empty($arrayfields[
'p.width_units'][
'checked'])) {
1556 print
'<td class="center">';
1557 if ($product_static->width !=
'') {
1562 $totalarray[
'nbfield']++;
1566 if (!empty($arrayfields[
'p.height'][
'checked'])) {
1567 print
'<td align="center">';
1571 $totalarray[
'nbfield']++;
1575 if (!empty($arrayfields[
'p.height_units'][
'checked'])) {
1576 print
'<td class="center">';
1577 if ($product_static->height !=
'') {
1582 $totalarray[
'nbfield']++;
1586 if (!empty($arrayfields[
'p.surface'][
'checked'])) {
1587 print
'<td class="center">';
1588 print $obj->surface;
1591 $totalarray[
'nbfield']++;
1595 if (!empty($arrayfields[
'p.surface_units'][
'checked'])) {
1596 print
'<td class="center">';
1597 if ($product_static->surface !=
'') {
1602 $totalarray[
'nbfield']++;
1606 if (!empty($arrayfields[
'p.volume'][
'checked'])) {
1607 print
'<td class="center">';
1611 $totalarray[
'nbfield']++;
1615 if (!empty($arrayfields[
'p.volume_units'][
'checked'])) {
1616 print
'<td class="center">';
1617 if ($product_static->volume !=
'') {
1622 $totalarray[
'nbfield']++;
1626 if (!empty($arrayfields[
'cu.label'][
'checked'])) {
1627 print
'<td align="center">';
1628 if (!empty($obj->cu_label)) {
1629 print $langs->trans($obj->cu_label);
1633 $totalarray[
'nbfield']++;
1638 if (!empty($arrayfields[
'p.sellprice'][
'checked'])) {
1639 print
'<td class="right nowraponall">';
1641 if ($obj->price_base_type ==
'TTC') {
1642 print
'<span class="amount">'.price($obj->price_ttc).
' '.$langs->trans(
"TTC").
'</span>';
1644 print
'<span class="amount">'.price($obj->price).
' '.$langs->trans(
"HT").
'</span>';
1649 $totalarray[
'nbfield']++;
1655 if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
1656 if (! isset($productpricescache)) {
1657 $productpricescache=array();
1659 if (! isset($productpricescache[$obj->rowid])) {
1660 $productpricescache[$obj->rowid] = array();
1666 $sqlp =
"SELECT p.rowid, p.fk_product, p.price, p.price_ttc, p.price_level, p.date_price, p.price_base_type";
1667 $sqlp .=
" FROM ".MAIN_DB_PREFIX.
"product_price as p";
1668 $sqlp .=
" WHERE fk_product = ".((int) $obj->rowid);
1669 $sqlp .=
" ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC";
1670 $resultp = $db->query($sqlp);
1672 $nump = $db->num_rows($resultp);
1674 while ($j < $nump) {
1675 $objp = $db->fetch_object($resultp);
1677 if (empty($productpricescache[$obj->rowid][$objp->price_level])) {
1678 $productpricescache[$obj->rowid][$objp->price_level][
'price'] = $objp->price;
1679 $productpricescache[$obj->rowid][$objp->price_level][
'price_ttc'] = $objp->price_ttc;
1680 $productpricescache[$obj->rowid][$objp->price_level][
'price_base_type'] = $objp->price_base_type;
1686 $db->free($resultp);
1692 foreach ($arraypricelevel as $key => $value) {
1693 if (!empty($arrayfields[
'p.sellprice'.$key][
'checked'])) {
1694 print
'<td class="right nowraponall">';
1695 if (!empty($productpricescache[$obj->rowid])) {
1696 if ($productpricescache[$obj->rowid][$key][
'price_base_type'] ==
'TTC') {
1697 print
'<span class="amount">'.price($productpricescache[$obj->rowid][$key][
'price_ttc']).
' '.$langs->trans(
"TTC").
'</span>';
1699 print
'<span class="amount">'.price($productpricescache[$obj->rowid][$key][
'price']).
' '.$langs->trans(
"HT").
'</span>';
1704 $totalarray[
'nbfield']++;
1711 if (!empty($arrayfields[
'p.minbuyprice'][
'checked'])) {
1712 print
'<td class="right nowraponall">';
1713 if ($obj->tobuy && $obj->minsellprice !=
'') {
1715 if ($product_fourn->find_min_price_product_fournisseur($obj->rowid) > 0) {
1716 if ($product_fourn->product_fourn_price_id > 0) {
1717 if ((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (!empty($conf->supplier_order->enabled) && !empty($user->rights->supplier_order->lire)) || (!empty($conf->supplier_invoice->enabled) && !empty($user->rights->supplier_invoice->lire))) {
1718 $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1);
1719 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>';
1721 print
'<span class="amount">'.price($product_fourn->fourn_unitprice).
' '.$langs->trans(
"HT").
'</span>';
1728 $totalarray[
'nbfield']++;
1733 if (!empty($arrayfields[
'p.numbuyprice'][
'checked'])) {
1734 print
'<td class="right">';
1736 if (count($productFournList = $product_fourn->list_product_fournisseur_price($obj->rowid)) > 0) {
1737 $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList);
1738 print
$form->textwithpicto(count($productFournList), $htmltext);
1745 if (!empty($arrayfields[
'p.tva_tx'][
'checked'])) {
1746 print
'<td class="right">';
1747 print
vatrate($obj->tva_tx,
true);
1750 $totalarray[
'nbfield']++;
1755 if (!empty($arrayfields[
'p.pmp'][
'checked'])) {
1756 print
'<td class="nowrap right">';
1757 print
'<span class="amount">'.price($product_static->pmp, 1, $langs).
"</span>";
1761 if (!empty($arrayfields[
'p.cost_price'][
'checked'])) {
1762 print
'<td class="nowrap right">';
1764 print
'<span class="amount">'.price($obj->cost_price).
' '.$langs->trans(
"HT").
'</span>';
1769 if (!empty($arrayfields[
'p.seuil_stock_alerte'][
'checked'])) {
1770 print
'<td class="right">';
1771 if ($obj->fk_product_type != 1) {
1772 print $obj->seuil_stock_alerte;
1776 $totalarray[
'nbfield']++;
1780 if (!empty($arrayfields[
'p.desiredstock'][
'checked'])) {
1781 print
'<td class="right">';
1782 if ($obj->fk_product_type != 1) {
1783 print $obj->desiredstock;
1787 $totalarray[
'nbfield']++;
1791 if (!empty($arrayfields[
'p.stock'][
'checked'])) {
1792 print
'<td class="right">';
1793 if ($obj->fk_product_type != 1) {
1794 if ($obj->seuil_stock_alerte !=
'' && $product_static->stock_reel < (
float) $obj->seuil_stock_alerte) {
1795 print
img_warning($langs->trans(
"StockLowerThanLimit", $obj->seuil_stock_alerte)).
' ';
1797 print
price(
price2num($product_static->stock_reel,
'MS'), 0, $langs, 1, 0);
1801 $totalarray[
'nbfield']++;
1805 if (!empty($arrayfields[
'stock_virtual'][
'checked'])) {
1806 print
'<td class="right">';
1807 if ($obj->fk_product_type != 1) {
1808 if ($obj->seuil_stock_alerte !=
'' && $product_static->stock_theorique < (
float) $obj->seuil_stock_alerte) {
1809 print
img_warning($langs->trans(
"StockLowerThanLimit", $obj->seuil_stock_alerte)).
' ';
1811 print
price(
price2num($product_static->stock_theorique,
'MS'), 0, $langs, 1, 0);
1815 $totalarray[
'nbfield']++;
1819 if (!empty($arrayfields[
'p.tobatch'][
'checked'])) {
1820 print
'<td class="center">';
1821 print $product_static->getLibStatut(1, 2);
1824 $totalarray[
'nbfield']++;
1828 if (!empty($arrayfields[
'p.fk_country'][
'checked'])) {
1829 print
'<td>'.getCountry($obj->fk_country, 0, $db).
'</td>';
1831 $totalarray[
'nbfield']++;
1835 if (!empty($arrayfields[
'p.fk_state'][
'checked'])) {
1837 if (!empty($obj->fk_state)) {
1838 print
getState($obj->fk_state, 0, $db);
1842 $totalarray[
'nbfield']++;
1846 if (!empty($arrayfields[$alias_product_perentity .
'.accountancy_code_sell'][
'checked'])) {
1847 print
'<td>'.length_accountg($obj->accountancy_code_sell).
'</td>';
1849 $totalarray[
'nbfield']++;
1852 if (!empty($arrayfields[$alias_product_perentity .
'.accountancy_code_sell_intra'][
'checked'])) {
1853 print
'<td>'.length_accountg($obj->accountancy_code_sell_intra).
'</td>';
1855 $totalarray[
'nbfield']++;
1858 if (!empty($arrayfields[$alias_product_perentity .
'.accountancy_code_sell_export'][
'checked'])) {
1859 print
'<td>'.length_accountg($obj->accountancy_code_sell_export).
'</td>';
1861 $totalarray[
'nbfield']++;
1865 if (!empty($arrayfields[$alias_product_perentity .
'.accountancy_code_buy'][
'checked'])) {
1866 print
'<td>'.length_accountg($obj->accountancy_code_buy).
'</td>';
1868 $totalarray[
'nbfield']++;
1871 if (!empty($arrayfields[$alias_product_perentity .
'.accountancy_code_buy_intra'][
'checked'])) {
1872 print
'<td>'.length_accountg($obj->accountancy_code_buy_intra).
'</td>';
1874 $totalarray[
'nbfield']++;
1877 if (!empty($arrayfields[$alias_product_perentity .
'.accountancy_code_buy_export'][
'checked'])) {
1878 print
'<td>'.length_accountg($obj->accountancy_code_buy_export).
'</td>';
1880 $totalarray[
'nbfield']++;
1884 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1886 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1887 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1888 print $hookmanager->resPrint;
1890 if (!empty($arrayfields[
'p.datec'][
'checked'])) {
1891 print
'<td class="center nowraponall">';
1892 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
1895 $totalarray[
'nbfield']++;
1899 if (!empty($arrayfields[
'p.tms'][
'checked'])) {
1900 print
'<td class="center nowraponall">';
1901 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
1904 $totalarray[
'nbfield']++;
1909 if (!empty($arrayfields[
'p.tosell'][
'checked'])) {
1910 print
'<td class="center nowrap">';
1911 if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
1912 print
ajax_object_onoff($product_static,
'status',
'tosell',
'ProductStatusOnSell',
'ProductStatusNotOnSell');
1914 print $product_static->LibStatut($obj->tosell, 5, 0);
1918 $totalarray[
'nbfield']++;
1922 if (!empty($arrayfields[
'p.tobuy'][
'checked'])) {
1923 print
'<td class="center nowrap">';
1924 if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
1925 print
ajax_object_onoff($product_static,
'status_buy',
'tobuy',
'ProductStatusOnBuy',
'ProductStatusNotOnBuy');
1927 print $product_static->LibStatut($obj->tobuy, 5, 1);
1931 $totalarray[
'nbfield']++;
1936 print
'<td class="nowrap center">';
1937 if ($massactionbutton || $massaction) {
1939 if (in_array($obj->rowid, $arrayofselected)) {
1942 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1946 $totalarray[
'nbfield']++;
1958 foreach ($arrayfields as $key => $val) {
1959 if (!empty($val[
'checked'])) {
1963 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';