2004-10-20 22:06:49 +02:00
< ? php
2015-05-23 18:52:31 +02:00
/* Copyright ( C ) 2001 - 2006 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2019-04-01 19:27:34 +02:00
* Copyright ( C ) 2004 - 2019 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2016-07-23 16:37:21 +02:00
* Copyright ( C ) 2012 - 2016 Marcos García < marcosgdf @ gmail . com >
2019-05-09 20:59:22 +02:00
* Copyright ( C ) 2013 - 2019 Juanjo Menent < jmenent @ 2 byte . es >
2015-05-23 18:52:31 +02:00
* Copyright ( C ) 2013 - 2015 Raphaël Doursenaud < rdoursenaud @ gpcsolutions . fr >
* Copyright ( C ) 2013 Jean Heimburger < jean @ tiaris . info >
* Copyright ( C ) 2013 Cédric Salvador < csalvador @ gpcsolutions . fr >
* Copyright ( C ) 2013 Florian Henry < florian . henry @ open - concept . pro >
* Copyright ( C ) 2013 Adolfo segura < adolfo . segura @ gmail . com >
* Copyright ( C ) 2015 Jean - François Ferry < jfefe @ aternatik . fr >
2016-03-16 16:30:59 +01:00
* Copyright ( C ) 2016 Ferran Marcet < fmarcet @ 2 byte . es >
2020-03-01 05:09:57 +01:00
* Copyright ( C ) 2020 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2003-09-04 11:59:59 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2003-09-04 11:59:59 +02:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2003-09-04 11:59:59 +02:00
*/
2004-10-23 01:34:25 +02:00
2005-01-19 22:40:03 +01:00
/**
2014-09-18 20:33:37 +02:00
* \file htdocs / product / list . php
2008-11-17 19:59:02 +01:00
* \ingroup produit
* \brief Page to list products and services
*/
2004-10-23 01:34:25 +02:00
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php' ;
2019-04-28 00:49:21 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php' ;
2020-02-28 11:16:39 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php' ;
2019-11-12 09:46:08 +01:00
if ( ! empty ( $conf -> categorie -> enabled ))
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
2003-09-04 11:59:59 +02:00
2018-05-26 23:52:52 +02:00
// Load translation files required by the page
2020-07-24 13:40:06 +02:00
$langs -> loadLangs ( array ( 'products' , 'stocks' , 'suppliers' , 'companies' , 'margins' ));
2019-11-12 09:46:08 +01:00
if ( ! empty ( $conf -> productbatch -> enabled )) $langs -> load ( " productbatch " );
2004-08-13 23:25:54 +02:00
2019-11-12 09:46:08 +01:00
$action = GETPOST ( 'action' , 'alpha' );
$massaction = GETPOST ( 'massaction' , 'alpha' );
$show_files = GETPOST ( 'show_files' , 'int' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
2017-04-09 15:02:55 +02:00
$toselect = GETPOST ( 'toselect' , 'array' );
2019-11-12 09:46:08 +01:00
$sall = trim (( GETPOST ( 'search_all' , 'alphanohtml' ) != '' ) ? GETPOST ( 'search_all' , 'alphanohtml' ) : GETPOST ( 'sall' , 'alphanohtml' ));
$search_ref = GETPOST ( " search_ref " , 'alpha' );
$search_barcode = GETPOST ( " search_barcode " , 'alpha' );
$search_label = GETPOST ( " search_label " , 'alpha' );
2018-10-11 15:44:23 +02:00
$search_type = GETPOST ( " search_type " , 'int' );
2019-05-11 16:50:31 +02:00
$search_sale = GETPOST ( " search_sale " , 'int' );
2019-11-12 09:46:08 +01:00
$search_vatrate = GETPOST ( " search_vatrate " , 'alpha' );
2019-09-13 12:23:34 +02:00
$searchCategoryProductOperator = ( GETPOST ( 'search_category_product_operator' , 'int' ) ? GETPOST ( 'search_category_product_operator' , 'int' ) : 0 );
$searchCategoryProductList = GETPOST ( 'search_category_product_list' , 'array' );
2017-09-11 00:10:23 +02:00
$search_tosell = GETPOST ( " search_tosell " , 'int' );
$search_tobuy = GETPOST ( " search_tobuy " , 'int' );
2019-01-27 11:55:16 +01:00
$fourn_id = GETPOST ( " fourn_id " , 'int' );
$catid = GETPOST ( 'catid' , 'int' );
$search_tobatch = GETPOST ( " search_tobatch " , 'int' );
$search_accountancy_code_sell = GETPOST ( " search_accountancy_code_sell " , 'alpha' );
2019-04-25 01:16:29 +02:00
$search_accountancy_code_sell_intra = GETPOST ( " search_accountancy_code_sell_intra " , 'alpha' );
$search_accountancy_code_sell_export = GETPOST ( " search_accountancy_code_sell_export " , 'alpha' );
2019-01-27 11:55:16 +01:00
$search_accountancy_code_buy = GETPOST ( " search_accountancy_code_buy " , 'alpha' );
2020-03-01 04:52:12 +01:00
$search_accountancy_code_buy_intra = GETPOST ( " search_accountancy_code_buy_intra " , 'alpha' );
$search_accountancy_code_buy_export = GETPOST ( " search_accountancy_code_buy_export " , 'alpha' );
2019-01-27 11:55:16 +01:00
$optioncss = GETPOST ( 'optioncss' , 'alpha' );
2019-11-12 09:46:08 +01:00
$type = GETPOST ( " type " , " int " );
2010-06-13 23:05:57 +02:00
2018-10-11 15:44:23 +02:00
//Show/hide child products
2019-11-12 09:46:08 +01:00
if ( ! empty ( $conf -> variants -> enabled ) && ! empty ( $conf -> global -> PRODUIT_ATTRIBUTES_HIDECHILD )) {
2018-10-15 11:48:55 +02:00
$show_childproducts = GETPOST ( 'search_show_childproducts' );
2016-07-23 16:37:21 +02:00
} else {
2018-10-11 15:44:23 +02:00
$show_childproducts = '' ;
2016-07-23 16:37:21 +02:00
}
2019-11-12 09:46:08 +01:00
$diroutputmassaction = $conf -> product -> dir_output . '/temp/massgeneration/' . $user -> id ;
2017-04-09 15:02:55 +02:00
2019-11-12 09:46:08 +01:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2019-01-27 11:55:16 +01:00
$sortfield = GETPOST ( " sortfield " , 'alpha' );
$sortorder = GETPOST ( " sortorder " , 'alpha' );
2020-03-17 03:31:58 +01:00
$page = GETPOSTISSET ( 'pageplusone' ) ? ( GETPOST ( 'pageplusone' ) - 1 ) : GETPOST ( " page " , 'int' );
if ( empty ( $page ) || $page < 0 || GETPOST ( 'button_search' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) { $page = 0 ; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
2015-12-16 15:42:24 +01:00
$offset = $limit * $page ;
2010-11-20 14:08:44 +01:00
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2019-11-12 09:46:08 +01:00
if ( ! $sortfield ) $sortfield = " p.ref " ;
if ( ! $sortorder ) $sortorder = " ASC " ;
2010-11-20 14:08:44 +01:00
2016-06-07 14:06:00 +02:00
// Initialize context for list
2019-11-12 09:46:08 +01:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'productservicelist' ;
if (( string ) $type == '1' ) { $contextpage = 'servicelist' ; if ( $search_type == '' ) $search_type = '1' ; }
if (( string ) $type == '0' ) { $contextpage = 'productlist' ; if ( $search_type == '' ) $search_type = '0' ; }
2004-10-31 17:02:47 +01:00
2017-06-09 09:45:22 +02:00
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
2019-11-12 09:46:08 +01:00
$object = new Product ( $db );
2018-03-31 18:48:27 +02:00
$hookmanager -> initHooks ( array ( 'productservicelist' ));
2015-10-29 22:12:11 +01:00
$extrafields = new ExtraFields ( $db );
2019-11-12 09:46:08 +01:00
$form = new Form ( $db );
2015-10-29 22:12:11 +01:00
// fetch optionals attributes and labels
2020-08-04 12:47:09 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
2019-11-12 09:46:08 +01:00
$search_array_options = $extrafields -> getOptionalsFromPost ( $object -> table_element , '' , 'search_' );
2010-02-27 18:30:17 +01:00
2019-11-12 09:46:08 +01:00
if ( empty ( $action )) $action = 'list' ;
2010-02-27 18:30:17 +01:00
2011-04-06 18:40:11 +02:00
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
2019-11-12 09:46:08 +01:00
$canvas = GETPOST ( " canvas " );
$objcanvas = null ;
if ( ! empty ( $canvas ))
2011-04-06 18:40:11 +02:00
{
2017-10-13 13:28:26 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/canvas.class.php' ;
2019-01-27 11:55:16 +01:00
$objcanvas = new Canvas ( $db , $action );
$objcanvas -> getCanvas ( 'product' , 'list' , $canvas );
2011-04-06 18:40:11 +02:00
}
2010-03-16 21:05:44 +01:00
2011-09-13 14:00:37 +02:00
// Security check
2019-11-12 09:46:08 +01:00
if ( $search_type == '0' ) $result = restrictedArea ( $user , 'produit' , '' , '' , '' , '' , '' , $objcanvas );
elseif ( $search_type == '1' ) $result = restrictedArea ( $user , 'service' , '' , '' , '' , '' , '' , $objcanvas );
else $result = restrictedArea ( $user , 'produit|service' , '' , '' , '' , '' , '' , $objcanvas );
2011-09-13 14:00:37 +02:00
2016-04-28 15:22:38 +02:00
// Define virtualdiffersfromphysical
2019-11-12 09:46:08 +01:00
$virtualdiffersfromphysical = 0 ;
2020-06-05 10:27:34 +02:00
if ( ! empty ( $conf -> global -> STOCK_CALCULATE_ON_SHIPMENT )
|| ! empty ( $conf -> global -> STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER )
|| ! empty ( $conf -> global -> STOCK_CALCULATE_ON_SHIPMENT_CLOSE )
|| ! empty ( $conf -> global -> STOCK_CALCULATE_ON_RECEPTION )
|| ! empty ( $conf -> global -> STOCK_CALCULATE_ON_RECEPTION_CLOSE )
|| ! empty ( $conf -> mrp -> enabled ))
2016-04-28 15:22:38 +02:00
{
2019-11-12 09:46:08 +01:00
$virtualdiffersfromphysical = 1 ; // According to increase/decrease stock options, virtual and physical stock may differs.
2016-04-28 15:22:38 +02:00
}
2015-10-17 00:14:36 +02:00
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array (
'p.ref' => " Ref " ,
2017-10-13 13:28:26 +02:00
'pfp.ref_fourn' => " RefSupplier " ,
2015-10-17 00:14:36 +02:00
'p.label' => " ProductLabel " ,
'p.description' => " Description " ,
2017-10-13 13:28:26 +02:00
" p.note " => " Note " ,
2019-07-23 16:51:08 +02:00
2015-10-17 00:14:36 +02:00
);
// multilang
2019-11-12 09:46:08 +01:00
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS ))
2015-10-17 00:14:36 +02:00
{
2019-11-12 09:46:08 +01:00
$fieldstosearchall [ 'pl.label' ] = 'ProductLabelTranslated' ;
$fieldstosearchall [ 'pl.description' ] = 'ProductDescriptionTranslated' ;
$fieldstosearchall [ 'pl.note' ] = 'ProductNoteTranslated' ;
2015-10-17 00:14:36 +02:00
}
2019-11-12 09:46:08 +01:00
if ( ! empty ( $conf -> barcode -> enabled )) {
$fieldstosearchall [ 'p.barcode' ] = 'Gencod' ;
2020-09-07 10:18:17 +02:00
$fieldstosearchall [ 'pfp.barcode' ] = 'GencodBuyPrice' ;
2015-10-17 00:14:36 +02:00
}
2019-07-26 14:16:54 +02:00
// Personalized search criterias. Example: $conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS = 'p.ref=ProductRef;p.label=ProductLabel'
2019-11-12 09:46:08 +01:00
if ( ! empty ( $conf -> global -> PRODUCT_QUICKSEARCH_ON_FIELDS )) $fieldstosearchall = dolExplodeIntoArray ( $conf -> global -> PRODUCT_QUICKSEARCH_ON_FIELDS );
2015-10-17 00:14:36 +02:00
2016-03-16 16:30:59 +01:00
if ( empty ( $conf -> global -> PRODUIT_MULTIPRICES ))
{
2019-11-12 09:46:08 +01:00
$titlesellprice = $langs -> trans ( " SellingPrice " );
if ( ! empty ( $conf -> global -> PRODUIT_CUSTOMER_PRICES ))
2016-03-16 16:30:59 +01:00
{
2019-11-12 09:46:08 +01:00
$titlesellprice = $form -> textwithpicto ( $langs -> trans ( " SellingPrice " ), $langs -> trans ( " DefaultPriceRealPriceMayDependOnCustomer " ));
2016-03-16 16:30:59 +01:00
}
}
2019-11-12 09:46:08 +01:00
$isInEEC = isInEEC ( $mysoc );
2019-04-25 01:16:29 +02:00
2015-11-11 17:05:18 +01:00
// Definition of fields for lists
2019-11-12 09:46:08 +01:00
$arrayfields = array (
2017-10-13 13:28:26 +02:00
'p.ref' => array ( 'label' => $langs -> trans ( " Ref " ), 'checked' => 1 ),
//'pfp.ref_fourn'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))),
2020-01-21 10:33:27 +01:00
'p.label' => array ( 'label' => $langs -> trans ( " Label " ), 'checked' => 1 , 'position' => 10 ),
'p.fk_product_type' => array ( 'label' => $langs -> trans ( " Type " ), 'checked' => 0 , 'enabled' => ( ! empty ( $conf -> product -> enabled ) && ! empty ( $conf -> service -> enabled )), 'position' => 11 ),
'p.barcode' => array ( 'label' => $langs -> trans ( " Gencod " ), 'checked' => 1 , 'enabled' => ( ! empty ( $conf -> barcode -> enabled )), 'position' => 12 ),
'p.duration' => array ( 'label' => $langs -> trans ( " Duration " ), 'checked' => ( $contextpage != 'productlist' ), 'enabled' => ( ! empty ( $conf -> service -> enabled ) && ( string ) $type == '1' ), 'position' => 13 ),
2020-02-10 15:54:46 +01:00
'p.finished' => array ( 'label' => $langs -> trans ( " Nature " ), 'checked' => 0 , 'enabled' => ( ! empty ( $conf -> product -> enabled ) && $type != '1' ), 'position' => 19 ),
2020-02-10 14:34:00 +01:00
'p.weight' => array ( 'label' => $langs -> trans ( 'Weight' ), 'checked' => 0 , 'enabled' => ( ! empty ( $conf -> product -> enabled ) && $type != '1' ), 'position' => 20 ),
2020-01-21 17:29:45 +01:00
'p.weight_units' => array ( 'label' => $langs -> trans ( 'WeightUnits' ), 'checked' => 0 , 'enabled' => ( ! empty ( $conf -> product -> enabled ) && $type != '1' ), 'position' => 21 ),
2020-09-07 10:18:17 +02:00
'p.length' => array ( 'label' => $langs -> trans ( 'Length' ), 'checked' => 0 , 'enabled' => ( ! empty ( $conf -> product -> enabled ) && empty ( $conf -> global -> PRODUCT_DISABLE_SIZE ) && $type != '1' ), 'position' => 22 ),
2020-01-21 17:29:45 +01:00
'p.length_units' => array ( 'label' => $langs -> trans ( 'LengthUnits' ), 'checked' => 0 , 'enabled' => ( ! empty ( $conf -> product -> enabled ) && empty ( $conf -> global -> PRODUCT_DISABLE_SIZE ) && $type != '1' ), 'position' => 23 ),
'p.width' => array ( 'label' => $langs -> trans ( 'Width' ), 'checked' => 0 , 'enabled' => ( ! empty ( $conf -> product -> enabled ) && empty ( $conf -> global -> PRODUCT_DISABLE_SIZE ) && $type != '1' ), 'position' => 24 ),
'p.width_units' => array ( 'label' => $langs -> trans ( 'WidthUnits' ), 'checked' => 0 , 'enabled' => ( ! empty ( $conf -> product -> enabled ) && empty ( $conf -> global -> PRODUCT_DISABLE_SIZE ) && $type != '1' ), 'position' => 25 ),
2020-09-07 10:18:17 +02:00
'p.height' => array ( 'label' => $langs -> trans ( 'Height' ), 'checked' => 0 , 'enabled' => ( ! empty ( $conf -> product -> enabled ) && empty ( $conf -> global -> PRODUCT_DISABLE_SIZE ) && $type != '1' ), 'position' => 26 ),
2020-01-21 17:29:45 +01:00
'p.height_units' => array ( 'label' => $langs -> trans ( 'HeightUnits' ), 'checked' => 0 , 'enabled' => ( ! empty ( $conf -> product -> enabled ) && empty ( $conf -> global -> PRODUCT_DISABLE_SIZE ) && $type != '1' ), 'position' => 27 ),
2020-09-07 10:18:17 +02:00
'p.surface' => array ( 'label' => $langs -> trans ( 'Surface' ), 'checked' => 0 , 'enabled' => ( ! empty ( $conf -> product -> enabled ) && empty ( $conf -> global -> PRODUCT_DISABLE_SURFACE ) && $type != '1' ), 'position' => 28 ),
2020-01-21 17:29:45 +01:00
'p.surface_units' => array ( 'label' => $langs -> trans ( 'SurfaceUnits' ), 'checked' => 0 , 'enabled' => ( ! empty ( $conf -> product -> enabled ) && empty ( $conf -> global -> PRODUCT_DISABLE_SURFACE ) && $type != '1' ), 'position' => 29 ),
2020-09-07 10:18:17 +02:00
'p.volume' => array ( 'label' => $langs -> trans ( 'Volume' ), 'checked' => 0 , 'enabled' => ( ! empty ( $conf -> product -> enabled ) && empty ( $conf -> global -> PRODUCT_DISABLE_VOLUME ) && $type != '1' ), 'position' => 30 ),
2020-01-21 17:29:45 +01:00
'p.volume_units' => array ( 'label' => $langs -> trans ( 'VolumeUnits' ), 'checked' => 0 , 'enabled' => ( ! empty ( $conf -> product -> enabled ) && empty ( $conf -> global -> PRODUCT_DISABLE_VOLUME ) && $type != '1' ), 'position' => 31 ),
2020-09-07 10:18:17 +02:00
'cu.label' => array ( 'label' => $langs -> trans ( " DefaultUnitToShow " ), 'checked' => 0 , 'enabled' => ( ! empty ( $conf -> product -> enabled ) && ! empty ( $conf -> global -> PRODUCT_USE_UNITS )), 'position' => 32 ),
'p.sellprice' => array ( 'label' => $langs -> trans ( " SellingPrice " ), 'checked' => 1 , 'enabled' => empty ( $conf -> global -> PRODUIT_MULTIPRICES ), 'position' => 40 ),
2020-01-21 10:33:27 +01:00
'p.minbuyprice' => array ( 'label' => $langs -> trans ( " BuyingPriceMinShort " ), 'checked' => 1 , 'enabled' => ( ! empty ( $user -> rights -> fournisseur -> lire )), 'position' => 41 ),
'p.numbuyprice' => array ( 'label' => $langs -> trans ( " BuyingPriceNumShort " ), 'checked' => 0 , 'enabled' => ( ! empty ( $user -> rights -> fournisseur -> lire )), 'position' => 42 ),
2020-09-07 10:18:17 +02:00
'p.tva_tx' => array ( 'label' => $langs -> trans ( " VATRate " ), 'checked' => 0 , 'enabled' => ( ! empty ( $user -> rights -> fournisseur -> lire )), 'position' => 43 ),
'p.pmp' => array ( 'label' => $langs -> trans ( " PMPValueShort " ), 'checked' => 0 , 'enabled' => ( ! empty ( $user -> rights -> fournisseur -> lire )), 'position' => 44 ),
2020-07-24 13:40:06 +02:00
'p.cost_price' => array ( 'label' => $langs -> trans ( " CostPrice " ), 'checked' => 0 , 'enabled' => ( ! empty ( $user -> rights -> fournisseur -> lire )), 'position' => 45 ),
2020-01-21 10:33:27 +01:00
'p.seuil_stock_alerte' => array ( 'label' => $langs -> trans ( " StockLimit " ), 'checked' => 0 , 'enabled' => ( ! empty ( $conf -> stock -> enabled ) && $user -> rights -> stock -> lire && $contextpage != 'service' ), 'position' => 50 ),
2020-01-30 01:48:28 +01:00
'p.desiredstock' => array ( 'label' => $langs -> trans ( " DesiredStock " ), 'checked' => 1 , 'enabled' => ( ! empty ( $conf -> stock -> enabled ) && $user -> rights -> stock -> lire && $contextpage != 'service' ), 'position' => 51 ),
2020-01-21 10:33:27 +01:00
'p.stock' => array ( 'label' => $langs -> trans ( " PhysicalStock " ), 'checked' => 1 , 'enabled' => ( ! empty ( $conf -> stock -> enabled ) && $user -> rights -> stock -> lire && $contextpage != 'service' ), 'position' => 52 ),
'stock_virtual' => array ( 'label' => $langs -> trans ( " VirtualStock " ), 'checked' => 1 , 'enabled' => ( ! empty ( $conf -> stock -> enabled ) && $user -> rights -> stock -> lire && $contextpage != 'service' && $virtualdiffersfromphysical ), 'position' => 53 ),
'p.tobatch' => array ( 'label' => $langs -> trans ( " ManageLotSerial " ), 'checked' => 0 , 'enabled' => ( ! empty ( $conf -> productbatch -> enabled )), 'position' => 60 ),
2019-04-25 01:16:29 +02:00
'p.accountancy_code_sell' => array ( 'label' => $langs -> trans ( " ProductAccountancySellCode " ), 'checked' => 0 , 'position' => 400 ),
2020-09-07 10:18:17 +02:00
'p.accountancy_code_sell_intra' => array ( 'label' => $langs -> trans ( " ProductAccountancySellIntraCode " ), 'checked' => 0 , 'enabled' => $isInEEC , 'position' => 401 ),
'p.accountancy_code_sell_export' => array ( 'label' => $langs -> trans ( " ProductAccountancySellExportCode " ), 'checked' => 0 , 'position' => 402 ),
'p.accountancy_code_buy' => array ( 'label' => $langs -> trans ( " ProductAccountancyBuyCode " ), 'checked' => 0 , 'position' => 403 ),
'p.accountancy_code_buy_intra' => array ( 'label' => $langs -> trans ( " ProductAccountancyBuyIntraCode " ), 'checked' => 0 , 'enabled' => $isInEEC , 'position' => 404 ),
'p.accountancy_code_buy_export' => array ( 'label' => $langs -> trans ( " ProductAccountancyBuyExportCode " ), 'checked' => 0 , 'position' => 405 ),
2015-11-11 17:05:18 +01:00
'p.datec' => array ( 'label' => $langs -> trans ( " DateCreation " ), 'checked' => 0 , 'position' => 500 ),
2017-10-13 13:28:26 +02:00
'p.tms' => array ( 'label' => $langs -> trans ( " DateModificationShort " ), 'checked' => 0 , 'position' => 500 ),
'p.tosell' => array ( 'label' => $langs -> trans ( " Status " ) . ' (' . $langs -> trans ( " Sell " ) . ')' , 'checked' => 1 , 'position' => 1000 ),
'p.tobuy' => array ( 'label' => $langs -> trans ( " Status " ) . ' (' . $langs -> trans ( " Buy " ) . ')' , 'checked' => 1 , 'position' => 1000 )
2015-11-11 17:05:18 +01:00
);
2020-05-08 22:41:49 +02:00
// MultiPrices
if ( $conf -> global -> PRODUIT_MULTIPRICES ){
for ( $i = 1 ; $i <= $conf -> global -> PRODUIT_MULTIPRICES_LIMIT ; $i ++ )
{
2020-05-09 00:28:23 +02:00
$keyforlabel = 'PRODUIT_MULTIPRICES_LABEL' . $i ;
2020-05-26 01:16:18 +02:00
if ( ! empty ( $conf -> global -> $keyforlabel )) {
2020-05-09 00:28:23 +02:00
$labelp = $i . ' - ' . $langs -> trans ( $conf -> global -> $keyforlabel );
2020-05-26 01:16:18 +02:00
} else {
2020-05-09 00:28:23 +02:00
$labelp = $langs -> trans ( " SellingPrice " ) . " " . $i ;
}
$arrayfields [ 'p.sellprice' . $i ] = array ( 'label' => $labelp , 'checked' => 1 , 'enabled' => $conf -> global -> PRODUIT_MULTIPRICES , 'position' => 40 );
2020-05-08 22:41:49 +02:00
$arraypricelevel [ $i ] = array ( $i );
}
}
//var_dump($arraypricelevel);
2015-11-11 17:05:18 +01:00
// Extra fields
2018-04-12 23:16:23 +02:00
if ( is_array ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]) && count ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]))
2015-11-11 17:05:18 +01:00
{
2019-11-12 09:46:08 +01:00
foreach ( $extrafields -> attributes [ $object -> table_element ][ 'label' ] as $key => $val )
2018-03-31 17:51:36 +02:00
{
2019-11-12 09:46:08 +01:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'list' ][ $key ]))
$arrayfields [ " ef. " . $key ] = array ( 'label' => $extrafields -> attributes [ $object -> table_element ][ 'label' ][ $key ], 'checked' => (( $extrafields -> attributes [ $object -> table_element ][ 'list' ][ $key ] < 0 ) ? 0 : 1 ), 'position' => $extrafields -> attributes [ $object -> table_element ][ 'pos' ][ $key ], 'enabled' => ( abs ( $extrafields -> attributes [ $object -> table_element ][ 'list' ][ $key ]) != 3 && $extrafields -> attributes [ $object -> table_element ][ 'perms' ][ $key ]));
2018-03-31 17:51:36 +02:00
}
2015-11-11 17:05:18 +01:00
}
2018-03-31 17:51:36 +02:00
$object -> fields = dol_sort_array ( $object -> fields , 'position' );
$arrayfields = dol_sort_array ( $arrayfields , 'position' );
2009-08-12 15:07:49 +02:00
2016-04-28 15:22:38 +02:00
2016-07-23 16:37:21 +02:00
2009-03-09 22:59:29 +01:00
/*
* Actions
*/
2019-11-12 09:46:08 +01:00
if ( GETPOST ( 'cancel' , 'alpha' )) { $action = 'list' ; $massaction = '' ; }
if ( ! GETPOST ( 'confirmmassaction' , 'alpha' ) && $massaction != 'presend' && $massaction != 'confirm_presend' ) { $massaction = '' ; }
2015-10-29 22:12:11 +01:00
2019-11-12 09:46:08 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2016-11-02 12:48:50 +01:00
if ( $reshook < 0 ) setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
2015-10-29 22:12:11 +01:00
2016-11-02 12:48:50 +01:00
if ( empty ( $reshook ))
2005-08-24 23:06:25 +02:00
{
2017-10-13 13:28:26 +02:00
// Selection of new fields
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
// Purge search criteria
2019-01-27 11:55:16 +01:00
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
2017-10-13 13:28:26 +02:00
{
2019-11-12 09:46:08 +01:00
$sall = " " ;
$search_ref = " " ;
$search_label = " " ;
$search_barcode = " " ;
2020-09-07 10:18:17 +02:00
$searchCategoryProductOperator = 0 ;
$searchCategoryProductList = array ();
2019-11-12 09:46:08 +01:00
$search_tosell = " " ;
$search_tobuy = " " ;
$search_vatrate = " " ;
$search_tobatch = '' ;
2018-04-12 23:42:06 +02:00
//$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.
2018-10-11 15:44:23 +02:00
$show_childproducts = '' ;
2019-11-12 09:46:08 +01:00
$search_accountancy_code_sell = '' ;
$search_accountancy_code_sell_intra = '' ;
$search_accountancy_code_sell_export = '' ;
$search_accountancy_code_buy = '' ;
2020-03-01 04:52:12 +01:00
$search_accountancy_code_buy_intra = '' ;
$search_accountancy_code_buy_export = '' ;
2019-11-12 09:46:08 +01:00
$search_array_options = array ();
2017-10-13 13:28:26 +02:00
}
// Mass actions
2019-11-12 09:46:08 +01:00
$objectclass = 'Product' ;
if (( string ) $search_type == '1' ) { $objectlabel = 'Services' ; }
if (( string ) $search_type == '0' ) { $objectlabel = 'Products' ; }
2017-10-13 13:28:26 +02:00
2019-11-04 15:33:49 +01:00
$permissiontoread = $user -> rights -> produit -> lire ;
$permissiontodelete = $user -> rights -> produit -> supprimer ;
2017-10-13 13:28:26 +02:00
$uploaddir = $conf -> product -> dir_output ;
include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php' ;
2004-10-31 17:02:47 +01:00
}
2009-08-12 15:07:49 +02:00
2004-08-13 23:25:54 +02:00
/*
2009-08-12 15:07:49 +02:00
* View
2004-08-13 23:25:54 +02:00
*/
2019-11-12 09:46:08 +01:00
$htmlother = new FormOther ( $db );
2010-03-16 21:05:44 +01:00
2019-11-12 09:46:08 +01:00
$title = $langs -> trans ( " ProductsAndServices " );
2018-06-22 14:51:47 +02:00
if ( $search_type != '' && $search_type != '-1' )
2006-12-09 12:37:36 +01:00
{
2018-06-22 14:51:47 +02:00
if ( $search_type == 1 )
{
$texte = $langs -> trans ( " Services " );
2020-05-21 15:05:19 +02:00
} else {
2018-06-22 14:51:47 +02:00
$texte = $langs -> trans ( " Products " );
}
2020-05-21 15:05:19 +02:00
} else {
2018-06-22 14:51:47 +02:00
$texte = $langs -> trans ( " ProductsAndServices " );
}
2019-06-19 21:35:35 +02:00
$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,' ;
2020-02-10 14:34:00 +01:00
$sql .= ' p.fk_product_type, p.duration, p.finished, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,' ;
2020-03-01 04:52:12 +01:00
$sql .= ' p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,' ;
$sql .= ' p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,' ;
2020-07-24 13:40:06 +02:00
$sql .= ' p.datec as date_creation, p.tms as date_update, p.pmp, p.stock, p.cost_price,' ;
2020-01-15 16:24:04 +01:00
$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,' ;
2019-11-20 14:21:35 +01:00
if ( ! empty ( $conf -> global -> PRODUCT_USE_UNITS )) $sql .= ' p.fk_unit, cu.label as cu_label,' ;
2019-11-12 09:46:08 +01:00
$sql .= ' MIN(pfp.unitprice) as minsellprice' ;
if ( ! empty ( $conf -> variants -> enabled ) && ( ! empty ( $conf -> global -> PRODUIT_ATTRIBUTES_HIDECHILD ) && ! $show_childproducts )) {
2018-06-22 14:51:47 +02:00
$sql .= ', pac.rowid prod_comb_id' ;
}
// Add fields from extrafields
2019-11-12 09:46:08 +01:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
foreach ( $extrafields -> attributes [ $object -> table_element ][ 'label' ] as $key => $val ) $sql .= ( $extrafields -> attributes [ $object -> table_element ][ 'type' ][ $key ] != 'separate' ? " , ef. " . $key . ' as options_' . $key : '' );
2018-06-22 14:51:47 +02:00
}
// Add fields from hooks
2019-11-12 09:46:08 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListSelect' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'product as p' ;
if ( is_array ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]) && count ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " product_extrafields as ef on (p.rowid = ef.fk_object) " ;
if ( ! empty ( $searchCategoryProductList ) || ! empty ( $catid )) $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . " categorie_product as cp ON p.rowid = cp.fk_product " ; // We'll need this table joined to the select in order to filter by categ
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " product_fournisseur_price as pfp ON p.rowid = pfp.fk_product " ;
2018-06-22 14:51:47 +02:00
// multilang
2019-11-12 09:46:08 +01:00
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS )) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " product_lang as pl ON pl.fk_product = p.rowid AND pl.lang = ' " . $langs -> getDefaultLang () . " ' " ;
2018-06-22 14:51:47 +02:00
2019-11-12 09:46:08 +01:00
if ( ! empty ( $conf -> variants -> enabled ) && ( ! empty ( $conf -> global -> PRODUIT_ATTRIBUTES_HIDECHILD ) && ! $show_childproducts )) {
2018-10-11 12:36:10 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " product_attribute_combination pac ON pac.fk_product_child = p.rowid " ;
}
2020-01-30 01:48:28 +01:00
if ( ! empty ( $conf -> global -> PRODUCT_USE_UNITS )) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " c_units cu ON cu.rowid = p.fk_unit " ;
2018-10-11 12:36:10 +02:00
2019-11-12 09:46:08 +01:00
$sql .= ' WHERE p.entity IN (' . getEntity ( 'product' ) . ')' ;
2018-06-22 14:51:47 +02:00
if ( $sall ) $sql .= natural_search ( array_keys ( $fieldstosearchall ), $sall );
// if the type is not 1, we show all products (type = 0,2,3)
if ( dol_strlen ( $search_type ) && $search_type != '-1' )
{
2019-11-12 09:46:08 +01:00
if ( $search_type == 1 ) $sql .= " AND p.fk_product_type = 1 " ;
else $sql .= " AND p.fk_product_type <> 1 " ;
2018-06-22 14:51:47 +02:00
}
2006-12-09 12:37:36 +01:00
2019-11-12 09:46:08 +01:00
if ( ! empty ( $conf -> variants -> enabled ) && ( ! empty ( $conf -> global -> PRODUIT_ATTRIBUTES_HIDECHILD ) && ! $show_childproducts )) {
2018-10-11 12:36:10 +02:00
$sql .= " AND pac.rowid IS NULL " ;
}
2018-06-22 14:51:47 +02:00
if ( $search_ref ) $sql .= natural_search ( 'p.ref' , $search_ref );
if ( $search_label ) $sql .= natural_search ( 'p.label' , $search_label );
if ( $search_barcode ) $sql .= natural_search ( 'p.barcode' , $search_barcode );
2019-11-12 09:46:08 +01:00
if ( isset ( $search_tosell ) && dol_strlen ( $search_tosell ) > 0 && $search_tosell != - 1 ) $sql .= " AND p.tosell = " . $db -> escape ( $search_tosell );
if ( isset ( $search_tobuy ) && dol_strlen ( $search_tobuy ) > 0 && $search_tobuy != - 1 ) $sql .= " AND p.tobuy = " . $db -> escape ( $search_tobuy );
2019-06-19 21:35:35 +02:00
if ( $search_vatrate ) $sql .= natural_search ( 'p.tva_tx' , $search_vatrate );
2019-11-12 09:46:08 +01:00
if ( dol_strlen ( $canvas ) > 0 ) $sql .= " AND p.canvas = ' " . $db -> escape ( $canvas ) . " ' " ;
if ( $catid > 0 ) $sql .= " AND cp.fk_categorie = " . $catid ;
if ( $catid == - 2 ) $sql .= " AND cp.fk_categorie IS NULL " ;
2019-09-13 12:23:34 +02:00
$searchCategoryProductSqlList = array ();
if ( $searchCategoryProductOperator == 1 ) {
2020-09-07 10:18:17 +02:00
foreach ( $searchCategoryProductList as $searchCategoryProduct ) {
if ( intval ( $searchCategoryProduct ) == - 2 ) {
$searchCategoryProductSqlList [] = " cp.fk_categorie IS NULL " ;
} elseif ( intval ( $searchCategoryProduct ) > 0 ) {
$searchCategoryProductSqlList [] = " cp.fk_categorie = " . $db -> escape ( $searchCategoryProduct );
}
}
if ( ! empty ( $searchCategoryProductSqlList )) {
$sql .= " AND ( " . implode ( ' OR ' , $searchCategoryProductSqlList ) . " ) " ;
}
2019-09-13 12:23:34 +02:00
} else {
2020-09-07 10:18:17 +02:00
foreach ( $searchCategoryProductList as $searchCategoryProduct ) {
if ( intval ( $searchCategoryProduct ) == - 2 ) {
$searchCategoryProductSqlList [] = " cp.fk_categorie IS NULL " ;
} elseif ( intval ( $searchCategoryProduct ) > 0 ) {
$searchCategoryProductSqlList [] = " p.rowid IN (SELECT fk_product FROM " . MAIN_DB_PREFIX . " categorie_product WHERE fk_categorie = " . $searchCategoryProduct . " ) " ;
}
}
if ( ! empty ( $searchCategoryProductSqlList )) {
$sql .= " AND ( " . implode ( ' AND ' , $searchCategoryProductSqlList ) . " ) " ;
}
2019-09-13 12:23:34 +02:00
}
2019-11-12 09:46:08 +01:00
if ( $fourn_id > 0 ) $sql .= " AND pfp.fk_soc = " . $fourn_id ;
if ( $search_tobatch != '' && $search_tobatch >= 0 ) $sql .= " AND p.tobatch = " . $db -> escape ( $search_tobatch );
if ( $search_accountancy_code_sell ) $sql .= natural_search ( 'p.accountancy_code_sell' , $search_accountancy_code_sell );
if ( $search_accountancy_code_sell_intra ) $sql .= natural_search ( 'p.accountancy_code_sell_intra' , $search_accountancy_code_sell_intra );
if ( $search_accountancy_code_sell_export ) $sql .= natural_search ( 'p.accountancy_code_sell_export' , $search_accountancy_code_sell_export );
if ( $search_accountancy_code_buy ) $sql .= natural_search ( 'p.accountancy_code_buy' , $search_accountancy_code_buy );
2020-03-01 04:52:12 +01:00
if ( $search_accountancy_code_buy_intra ) $sql .= natural_search ( 'p.accountancy_code_buy_intra' , $search_accountancy_code_buy_intra );
if ( $search_accountancy_code_buy_export ) $sql .= natural_search ( 'p.accountancy_code_buy_export' , $search_accountancy_code_buy_export );
2018-10-11 15:44:23 +02:00
2018-06-22 14:51:47 +02:00
// Add where from extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php' ;
// Add where from hooks
2019-11-12 09:46:08 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhere' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
$sql .= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.tva_tx, p.price_ttc, p.price_base_type, " ;
2020-02-10 14:34:00 +01:00
$sql .= " p.fk_product_type, p.duration, p.finished, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock, " ;
2020-03-01 04:52:12 +01:00
$sql .= ' p.datec, p.tms, p.entity, p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,' ;
2020-07-24 13:40:06 +02:00
$sql .= ' p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export, p.pmp, p.cost_price, p.stock,' ;
2020-01-15 16:24:04 +01:00
$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' ;
2019-11-20 15:00:34 +01:00
if ( ! empty ( $conf -> global -> PRODUCT_USE_UNITS )) $sql .= ', p.fk_unit, cu.label' ;
2019-11-12 09:46:08 +01:00
if ( ! empty ( $conf -> variants -> enabled ) && ( ! empty ( $conf -> global -> PRODUIT_ATTRIBUTES_HIDECHILD ) && ! $show_childproducts )) {
2018-10-11 15:44:23 +02:00
$sql .= ', pac.rowid' ;
}
2018-06-22 14:51:47 +02:00
// Add fields from extrafields
2019-11-12 09:46:08 +01:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
foreach ( $extrafields -> attributes [ $object -> table_element ][ 'label' ] as $key => $val ) $sql .= ( $extrafields -> attributes [ $object -> table_element ][ 'type' ][ $key ] != 'separate' ? " , ef. " . $key : '' );
2018-06-22 14:51:47 +02:00
}
// Add fields from hooks
2019-11-12 09:46:08 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldSelect' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
2018-06-22 14:51:47 +02:00
//if (GETPOST("toolowstock")) $sql.= " HAVING SUM(s.reel) < p.seuil_stock_alerte"; // Not used yet
2019-11-12 09:46:08 +01:00
$sql .= $db -> order ( $sortfield , $sortorder );
2006-12-09 12:37:36 +01:00
2018-06-22 14:51:47 +02:00
$nbtotalofrecords = '' ;
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST ))
{
$result = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $result );
if (( $page * $limit ) > $nbtotalofrecords ) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0 ;
$offset = 0 ;
}
}
2019-11-12 09:46:08 +01:00
$sql .= $db -> plimit ( $limit + 1 , $offset );
2018-06-22 14:51:47 +02:00
$resql = $db -> query ( $sql );
2018-11-29 13:44:10 +01:00
2018-06-22 14:51:47 +02:00
if ( $resql )
{
$num = $db -> num_rows ( $resql );
2019-11-12 09:46:08 +01:00
$arrayofselected = is_array ( $toselect ) ? $toselect : array ();
2018-06-22 14:51:47 +02:00
2019-11-12 09:46:08 +01:00
if ( $num == 1 && ! empty ( $conf -> global -> MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE ) && $sall )
2009-03-09 22:59:29 +01:00
{
2018-06-22 14:51:47 +02:00
$obj = $db -> fetch_object ( $resql );
$id = $obj -> rowid ;
header ( " Location: " . DOL_URL_ROOT . '/product/card.php?id=' . $id );
exit ;
}
2019-11-12 09:46:08 +01:00
$helpurl = '' ;
2018-06-22 14:51:47 +02:00
if ( $search_type != '' )
2009-03-09 22:59:29 +01:00
{
2018-06-22 14:51:47 +02:00
if ( $search_type == 0 )
2010-03-22 17:58:14 +01:00
{
2019-11-12 09:46:08 +01:00
$helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos' ;
2020-05-21 15:05:19 +02:00
} elseif ( $search_type == 1 )
2010-03-22 17:58:14 +01:00
{
2019-11-12 09:46:08 +01:00
$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios' ;
2010-03-22 17:58:14 +01:00
}
}
2005-11-27 22:41:30 +01:00
2019-01-27 11:55:16 +01:00
llxHeader ( '' , $title , $helpurl , '' );
2018-06-22 14:51:47 +02:00
// Displays product removal confirmation
2019-11-12 09:46:08 +01:00
if ( GETPOST ( 'delprod' )) {
2018-06-22 14:51:47 +02:00
setEventMessages ( $langs -> trans ( " ProductDeleted " , GETPOST ( 'delprod' )), null , 'mesgs' );
2016-07-23 16:37:21 +02:00
}
2019-11-12 09:46:08 +01:00
$param = '' ;
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) $param .= '&contextpage=' . urlencode ( $contextpage );
if ( $limit > 0 && $limit != $conf -> liste_limit ) $param .= '&limit=' . urlencode ( $limit );
if ( $sall ) $param .= " &sall= " . urlencode ( $sall );
2020-09-07 10:18:17 +02:00
if ( $searchCategoryProductOperator == 1 ) $param .= " &search_category_product_operator= " . urlencode ( $searchCategoryProductOperator );
foreach ( $searchCategoryProductList as $searchCategoryProduct ) {
$param .= " &search_category_product_list[]= " . urlencode ( $searchCategoryProduct );
}
2019-11-12 09:46:08 +01:00
if ( $search_ref ) $param = " &search_ref= " . urlencode ( $search_ref );
if ( $search_ref_supplier ) $param = " &search_ref_supplier= " . urlencode ( $search_ref_supplier );
if ( $search_barcode ) $param .= ( $search_barcode ? " &search_barcode= " . urlencode ( $search_barcode ) : " " );
if ( $search_label ) $param .= " &search_label= " . urlencode ( $search_label );
if ( $search_tosell != '' ) $param .= " &search_tosell= " . urlencode ( $search_tosell );
if ( $search_tobuy != '' ) $param .= " &search_tobuy= " . urlencode ( $search_tobuy );
2020-09-07 10:18:17 +02:00
if ( $search_vatrate ) $sql .= natural_search ( 'p.tva_tx' , $search_vatrate );
2019-11-12 09:46:08 +01:00
if ( $fourn_id > 0 ) $param .= ( $fourn_id ? " &fourn_id= " . $fourn_id : " " );
2019-09-13 12:23:34 +02:00
//if ($seach_categ) $param.=($search_categ?"&search_categ=".urlencode($search_categ):"");
2019-11-12 09:46:08 +01:00
if ( $show_childproducts ) $param .= ( $show_childproducts ? " &search_show_childproducts= " . urlencode ( $show_childproducts ) : " " );
if ( $type != '' ) $param .= '&type=' . urlencode ( $type );
if ( $search_type != '' ) $param .= '&search_type=' . urlencode ( $search_type );
if ( $optioncss != '' ) $param .= '&optioncss=' . urlencode ( $optioncss );
if ( $search_tobatch ) $param = " &search_ref_supplier= " . urlencode ( $search_ref_supplier );
if ( $search_accountancy_code_sell ) $param = " &search_accountancy_code_sell= " . urlencode ( $search_accountancy_code_sell );
if ( $search_accountancy_code_sell_intra ) $param = " &search_accountancy_code_sell_intra= " . urlencode ( $search_accountancy_code_sell_intra );
if ( $search_accountancy_code_sell_export ) $param = " &search_accountancy_code_sell_export= " . urlencode ( $search_accountancy_code_sell_export );
if ( $search_accountancy_code_buy ) $param = " &search_accountancy_code_buy= " . urlencode ( $search_accountancy_code_buy );
2020-03-01 04:52:12 +01:00
if ( $search_accountancy_code_buy_intra ) $param = " &search_accountancy_code_buy_intra= " . urlencode ( $search_accountancy_code_buy_intra );
if ( $search_accountancy_code_buy_export ) $param = " &search_accountancy_code_buy_export= " . urlencode ( $search_accountancy_code_buy_export );
2018-06-22 14:51:47 +02:00
// Add $param from extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php' ;
// List of mass actions available
2019-11-12 09:46:08 +01:00
$arrayofmassactions = array (
2019-05-10 19:32:46 +02:00
'generate_doc' => $langs -> trans ( " ReGeneratePDF " ),
2020-09-07 10:18:17 +02:00
//'builddoc'=>$langs->trans("PDFMerge"),
//'presend'=>$langs->trans("SendByMail"),
2018-06-22 14:51:47 +02:00
);
2020-09-07 10:18:17 +02:00
$rightskey = 'produit' ;
2020-01-30 01:48:28 +01:00
if ( $type == Product :: TYPE_SERVICE ) $rightskey = 'service' ;
2020-01-10 14:25:26 +01:00
if ( $user -> rights -> { $rightskey } -> supprimer ) $arrayofmassactions [ 'predelete' ] = " <span class='fa fa-trash paddingrightonly'></span> " . $langs -> trans ( " Delete " );
2020-01-30 01:48:28 +01:00
if ( in_array ( $massaction , array ( 'presend' , 'predelete' ))) $arrayofmassactions = array ();
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
2019-11-12 09:46:08 +01:00
$newcardbutton = '' ;
2019-12-04 15:09:20 +01:00
if ( $type === " " ) $perm = ( $user -> rights -> produit -> creer || $user -> rights -> service -> creer );
elseif ( $type == Product :: TYPE_SERVICE ) $perm = $user -> rights -> service -> creer ;
elseif ( $type == Product :: TYPE_PRODUCT ) $perm = $user -> rights -> produit -> creer ;
if ( $perm )
2010-03-22 17:58:14 +01:00
{
2019-11-12 09:46:08 +01:00
$oldtype = $type ;
2019-12-04 15:09:20 +01:00
$params = array ();
2019-12-06 09:26:49 +01:00
if ( $type === " " ) $params [ 'forcenohideoftext' ] = 1 ;
2019-08-15 22:21:31 +02:00
if ( $type === " " ) {
2019-12-04 15:09:20 +01:00
$newcardbutton .= dolGetButtonTitle ( $langs -> trans ( 'NewProduct' ), '' , 'fa fa-plus-circle' , DOL_URL_ROOT . '/product/card.php?action=create&type=0' , '' , 1 , $params );
2019-08-15 22:21:31 +02:00
$type = Product :: TYPE_SERVICE ;
}
2019-11-12 09:46:08 +01:00
$label = 'NewProduct' ;
if ( $type == Product :: TYPE_SERVICE ) $label = 'NewService' ;
2019-12-04 15:09:20 +01:00
$newcardbutton .= dolGetButtonTitle ( $langs -> trans ( $label ), '' , 'fa fa-plus-circle' , DOL_URL_ROOT . '/product/card.php?action=create&type=' . $type , '' , 1 , $params );
2019-10-23 04:04:32 +02:00
2020-09-07 10:18:17 +02:00
$type = $oldtype ;
}
2005-11-27 22:41:30 +01:00
2018-06-22 14:51:47 +02:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="post" name="formulaire">' ;
if ( $optioncss != '' ) print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2018-06-22 14:51:47 +02:00
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
2020-03-17 03:31:58 +01:00
//print '<input type="hidden" name="page" value="'.$page.'">';
2018-06-22 14:51:47 +02:00
print '<input type="hidden" name="type" value="' . $type . '">' ;
if ( empty ( $arrayfields [ 'p.fk_product_type' ][ 'checked' ])) print '<input type="hidden" name="search_type" value="' . dol_escape_htmltag ( $search_type ) . '">' ;
2020-04-12 21:45:43 +02:00
$picto = 'product' ;
if ( $type == 1 ) $picto = 'service' ;
print_barre_liste ( $texte , $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , $picto , 0 , $newcardbutton , '' , $limit , 0 , 0 , 1 );
2018-06-22 14:51:47 +02:00
2019-11-12 09:46:08 +01:00
$topicmail = " Information " ;
$modelmail = " product " ;
$objecttmp = new Product ( $db );
$trackid = 'prod' . $object -> id ;
2018-06-22 14:51:47 +02:00
include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php' ;
2019-11-12 09:46:08 +01:00
if ( ! empty ( $catid ))
2018-06-22 14:51:47 +02:00
{
print " <div id='ways'> " ;
$c = new Categorie ( $db );
2019-01-27 11:55:16 +01:00
$ways = $c -> print_all_ways ( ' > ' , 'product/list.php' );
2018-06-22 14:51:47 +02:00
print " > " . $ways [ 0 ] . " <br> \n " ;
print " </div><br> " ;
2016-07-23 16:37:21 +02:00
}
2018-06-22 14:51:47 +02:00
2018-06-22 15:43:22 +02:00
if ( $sall )
2015-10-29 22:12:11 +01:00
{
2019-11-12 09:46:08 +01:00
foreach ( $fieldstosearchall as $key => $val ) $fieldstosearchall [ $key ] = $langs -> trans ( $val );
print '<div class="divsearchfieldfilter">' . $langs -> trans ( " FilterOnInto " , $sall ) . join ( ', ' , $fieldstosearchall ) . '</div>' ;
2018-06-22 15:43:22 +02:00
}
// Filter on categories
2019-11-12 09:46:08 +01:00
$moreforfilter = '' ;
if ( ! empty ( $conf -> categorie -> enabled ))
2018-06-22 15:43:22 +02:00
{
2019-11-12 09:46:08 +01:00
$moreforfilter .= '<div class="divsearchfield">' ;
$moreforfilter .= $langs -> trans ( 'Categories' ) . ': ' ;
2019-09-13 12:23:34 +02:00
$categoriesProductArr = $form -> select_all_categories ( Categorie :: TYPE_PRODUCT , '' , '' , 64 , 0 , 1 );
2020-09-07 10:18:17 +02:00
$categoriesProductArr [ - 2 ] = '- ' . $langs -> trans ( 'NotCategorized' ) . ' -' ;
$moreforfilter .= Form :: multiselectarray ( 'search_category_product_list' , $categoriesProductArr , $searchCategoryProductList , 0 , 0 , 'minwidth300' );
$moreforfilter .= ' <input type="checkbox" class="valignmiddle" name="search_category_product_operator" value="1"' . ( $searchCategoryProductOperator == 1 ? ' checked="checked"' : '' ) . '/> ' . $langs -> trans ( 'UseOrOperatorForCategories' );
$moreforfilter .= '</div>' ;
2018-06-22 15:43:22 +02:00
}
2017-10-13 13:28:26 +02:00
2018-06-22 15:43:22 +02:00
//Show/hide child products. Hidden by default
2019-02-10 10:45:49 +01:00
if ( ! empty ( $conf -> variants -> enabled ) && ! empty ( $conf -> global -> PRODUIT_ATTRIBUTES_HIDECHILD )) {
2019-11-12 09:46:08 +01:00
$moreforfilter .= '<div class="divsearchfield">' ;
$moreforfilter .= '<input type="checkbox" id="search_show_childproducts" name="search_show_childproducts"' . ( $show_childproducts ? 'checked="checked"' : '' ) . '>' ;
$moreforfilter .= ' <label for="search_show_childproducts">' . $langs -> trans ( 'ShowChildProducts' ) . '</label>' ;
$moreforfilter .= '</div>' ;
2018-06-22 14:51:47 +02:00
}
2018-06-22 15:43:22 +02:00
2019-11-12 09:46:08 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldPreListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
if ( empty ( $reshook )) $moreforfilter .= $hookmanager -> resPrint ;
else $moreforfilter = $hookmanager -> resPrint ;
2018-06-22 15:43:22 +02:00
if ( $moreforfilter )
2014-05-12 11:00:58 +02:00
{
2018-06-22 15:43:22 +02:00
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
print $moreforfilter ;
print '</div>' ;
}
2017-10-13 13:28:26 +02:00
2019-11-12 09:46:08 +01:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
if ( $massactionbutton ) $selectedfields .= $form -> showCheckAddButtons ( 'checkforselect' , 1 );
2017-10-13 13:28:26 +02:00
2018-06-22 15:43:22 +02:00
print '<div class="div-table-responsive">' ;
2019-11-12 09:46:08 +01:00
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
2017-10-13 13:28:26 +02:00
2018-06-22 15:43:22 +02:00
// Lines with input filters
print '<tr class="liste_titre_filter">' ;
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.ref' ][ 'checked' ]))
2018-06-22 15:43:22 +02:00
{
2019-02-24 11:18:55 +01:00
print '<td class="liste_titre left">' ;
2018-06-22 15:43:22 +02:00
print '<input class="flat" type="text" name="search_ref" size="8" value="' . dol_escape_htmltag ( $search_ref ) . '">' ;
print '</td>' ;
}
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'pfp.ref_fourn' ][ 'checked' ]))
2018-06-22 15:43:22 +02:00
{
2019-02-24 11:18:55 +01:00
print '<td class="liste_titre left">' ;
2018-06-22 15:43:22 +02:00
print '<input class="flat" type="text" name="search_ref_supplier" size="8" value="' . dol_escape_htmltag ( $search_ref_supplier ) . '">' ;
print '</td>' ;
}
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.label' ][ 'checked' ]))
2018-06-22 15:43:22 +02:00
{
2019-02-24 11:18:55 +01:00
print '<td class="liste_titre left">' ;
2018-06-22 15:43:22 +02:00
print '<input class="flat" type="text" name="search_label" size="12" value="' . dol_escape_htmltag ( $search_label ) . '">' ;
print '</td>' ;
}
// Type
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.fk_product_type' ][ 'checked' ]))
2018-06-22 15:43:22 +02:00
{
2020-08-07 20:10:31 +02:00
print '<td class="liste_titre center">' ;
2019-11-12 09:46:08 +01:00
$array = array ( '-1' => ' ' , '0' => $langs -> trans ( 'Product' ), '1' => $langs -> trans ( 'Service' ));
2018-06-22 15:43:22 +02:00
print $form -> selectarray ( 'search_type' , $array , $search_type );
print '</td>' ;
}
// Barcode
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.barcode' ][ 'checked' ]))
2018-06-22 15:43:22 +02:00
{
print '<td class="liste_titre">' ;
print '<input class="flat" type="text" name="search_barcode" size="6" value="' . dol_escape_htmltag ( $search_barcode ) . '">' ;
print '</td>' ;
}
// Duration
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.duration' ][ 'checked' ]))
2018-06-22 15:43:22 +02:00
{
print '<td class="liste_titre">' ;
print '</td>' ;
}
2019-04-04 17:13:52 +02:00
2020-02-10 14:34:00 +01:00
// Finished
if ( ! empty ( $arrayfields [ 'p.finished' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '</td>' ;
}
2019-04-04 17:13:52 +02:00
// Weight
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.weight' ][ 'checked' ]))
2019-04-04 17:13:52 +02:00
{
2020-09-07 10:18:17 +02:00
print '<td class="liste_titre">' ;
print '</td>' ;
2019-04-04 17:13:52 +02:00
}
2020-01-21 10:33:27 +01:00
// Weight units
if ( ! empty ( $arrayfields [ 'p.weight_units' ][ 'checked' ])) {
print '<td class="liste_titre">' ;
print '</td>' ;
}
2019-04-04 17:13:52 +02:00
// Length
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.length' ][ 'checked' ]))
2019-04-04 17:13:52 +02:00
{
2020-09-07 10:18:17 +02:00
print '<td class="liste_titre">' ;
print '</td>' ;
2019-04-04 17:13:52 +02:00
}
2020-01-21 10:33:27 +01:00
// Length units
if ( ! empty ( $arrayfields [ 'p.length_units' ][ 'checked' ])) {
print '<td class="liste_titre">' ;
print '</td>' ;
}
2020-09-07 10:18:17 +02:00
// Width
if ( ! empty ( $arrayfields [ 'p.width' ][ 'checked' ])) {
print '<td class="liste_titre">' ;
print '</td>' ;
}
2020-01-21 10:33:27 +01:00
// Width units
if ( ! empty ( $arrayfields [ 'p.width_units' ][ 'checked' ])) {
print '<td class="liste_titre">' ;
print '</td>' ;
}
2020-09-07 10:18:17 +02:00
// Height
if ( ! empty ( $arrayfields [ 'p.height' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '</td>' ;
}
2020-01-21 10:33:27 +01:00
// Height units
if ( ! empty ( $arrayfields [ 'p.height_units' ][ 'checked' ])) {
print '<td class="liste_titre">' ;
print '</td>' ;
}
2019-04-04 17:13:52 +02:00
// Surface
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.surface' ][ 'checked' ]))
2019-04-04 17:13:52 +02:00
{
2020-09-07 10:18:17 +02:00
print '<td class="liste_titre">' ;
print '</td>' ;
2019-04-04 17:13:52 +02:00
}
2020-01-21 10:33:27 +01:00
// Surface units
if ( ! empty ( $arrayfields [ 'p.surface_units' ][ 'checked' ])) {
print '<td class="liste_titre">' ;
print '</td>' ;
}
2019-04-04 17:13:52 +02:00
// Volume
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.volume' ][ 'checked' ]))
2019-04-04 17:13:52 +02:00
{
2020-09-07 10:18:17 +02:00
print '<td class="liste_titre">' ;
print '</td>' ;
2019-04-04 17:13:52 +02:00
}
2020-01-21 10:33:27 +01:00
// Volume units
if ( ! empty ( $arrayfields [ 'p.volume_units' ][ 'checked' ])) {
print '<td class="liste_titre">' ;
print '</td>' ;
}
2019-04-04 17:13:52 +02:00
2019-11-20 14:21:35 +01:00
// Unit
2020-09-07 10:18:17 +02:00
if ( ! empty ( $arrayfields [ 'cu.label' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '</td>' ;
}
2019-11-20 14:21:35 +01:00
2018-06-22 15:43:22 +02:00
// Sell price
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.sellprice' ][ 'checked' ]))
2018-06-22 15:43:22 +02:00
{
2019-02-24 11:18:55 +01:00
print '<td class="liste_titre right">' ;
2018-06-22 15:43:22 +02:00
print '</td>' ;
}
2020-05-08 22:41:49 +02:00
// Multiprice
if ( $conf -> global -> PRODUIT_MULTIPRICES ){
foreach ( $arraypricelevel as $key => $value )
{
if ( ! empty ( $arrayfields [ 'p.sellprice' . $key ][ 'checked' ]))
{
print '<td class="liste_titre right">' ;
print '</td>' ;
}
}
}
2018-06-22 15:43:22 +02:00
// Minimum buying Price
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.minbuyprice' ][ 'checked' ]))
2018-06-22 15:43:22 +02:00
{
print '<td class="liste_titre">' ;
print ' ' ;
print '</td>' ;
}
// Number buying Price
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.numbuyprice' ][ 'checked' ]))
2018-06-22 15:43:22 +02:00
{
print '<td class="liste_titre">' ;
print ' ' ;
print '</td>' ;
}
2020-09-07 10:18:17 +02:00
// Sell price
if ( ! empty ( $arrayfields [ 'p.tva_tx' ][ 'checked' ]))
{
print '<td class="liste_titre right">' ;
print '<input class="right flat maxwidth50" placeholder="%" type="text" name="search_vatrate" size="1" value="' . dol_escape_htmltag ( $search_vatrate ) . '">' ;
print '</td>' ;
}
2018-06-22 15:43:22 +02:00
// WAP
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.pmp' ][ 'checked' ]))
2018-06-22 15:43:22 +02:00
{
print '<td class="liste_titre">' ;
print ' ' ;
print '</td>' ;
}
2020-07-24 13:40:06 +02:00
// cost_price
if ( ! empty ( $arrayfields [ 'p.cost_price' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print ' ' ;
print '</td>' ;
2020-07-24 13:42:18 +02:00
}
2018-06-22 15:43:22 +02:00
// Limit for alert
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.seuil_stock_alerte' ][ 'checked' ]))
2018-06-22 15:43:22 +02:00
{
print '<td class="liste_titre">' ;
print ' ' ;
print '</td>' ;
}
// Desired stock
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.desiredstock' ][ 'checked' ]))
2018-06-22 15:43:22 +02:00
{
print '<td class="liste_titre">' ;
print ' ' ;
print '</td>' ;
}
// Stock
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.stock' ][ 'checked' ])) print '<td class="liste_titre"> </td>' ;
2018-06-22 15:43:22 +02:00
// Stock
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'stock_virtual' ][ 'checked' ])) print '<td class="liste_titre"> </td>' ;
2018-06-22 15:43:22 +02:00
// To batch
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.tobatch' ][ 'checked' ])) print '<td class="liste_titre center">' . $form -> selectyesno ( $search_tobatch , '' , '' , '' , 1 ) . '</td>' ;
2018-06-22 15:43:22 +02:00
// Accountancy code sell
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.accountancy_code_sell' ][ 'checked' ])) 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>' ;
if ( ! empty ( $arrayfields [ 'p.accountancy_code_sell_intra' ][ 'checked' ])) 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>' ;
if ( ! empty ( $arrayfields [ 'p.accountancy_code_sell_export' ][ 'checked' ])) 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>' ;
2019-04-25 01:16:29 +02:00
// Accountancy code buy
2020-03-01 04:52:12 +01:00
if ( ! empty ( $arrayfields [ 'p.accountancy_code_buy' ][ 'checked' ])) 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>' ;
if ( ! empty ( $arrayfields [ 'p.accountancy_code_buy_intra' ][ 'checked' ])) 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>' ;
if ( ! empty ( $arrayfields [ 'p.accountancy_code_buy_export' ][ 'checked' ])) 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>' ;
2018-06-22 15:43:22 +02:00
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php' ;
// Fields from hook
2019-11-12 09:46:08 +01:00
$parameters = array ( 'arrayfields' => $arrayfields );
$reshook = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters ); // Note that $action and $object may have been modified by hook
2018-06-22 15:43:22 +02:00
print $hookmanager -> resPrint ;
// Date creation
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.datec' ][ 'checked' ]))
2018-06-22 15:43:22 +02:00
{
print '<td class="liste_titre">' ;
print '</td>' ;
}
// Date modification
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.tms' ][ 'checked' ]))
2018-06-22 15:43:22 +02:00
{
print '<td class="liste_titre">' ;
print '</td>' ;
}
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.tosell' ][ 'checked' ]))
2018-06-22 15:43:22 +02:00
{
2019-02-24 11:18:55 +01:00
print '<td class="liste_titre right">' ;
2019-11-12 09:46:08 +01:00
print $form -> selectarray ( 'search_tosell' , array ( '0' => $langs -> trans ( 'ProductStatusNotOnSellShort' ), '1' => $langs -> trans ( 'ProductStatusOnSellShort' )), $search_tosell , 1 );
2018-06-22 15:43:22 +02:00
print '</td >' ;
}
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.tobuy' ][ 'checked' ]))
2018-06-22 15:43:22 +02:00
{
2019-02-24 11:18:55 +01:00
print '<td class="liste_titre right">' ;
2019-11-12 09:46:08 +01:00
print $form -> selectarray ( 'search_tobuy' , array ( '0' => $langs -> trans ( 'ProductStatusNotOnBuyShort' ), '1' => $langs -> trans ( 'ProductStatusOnBuyShort' )), $search_tobuy , 1 );
2018-06-22 15:43:22 +02:00
print '</td>' ;
}
2019-05-19 13:51:47 +02:00
print '<td class="liste_titre center maxwidthsearch">' ;
2019-11-12 09:46:08 +01:00
$searchpicto = $form -> showFilterButtons ();
2018-06-22 15:43:22 +02:00
print $searchpicto ;
print '</td>' ;
print '</tr>' ;
print '<tr class="liste_titre">' ;
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.ref' ][ 'checked' ])) {
2020-09-07 10:18:17 +02:00
print_liste_field_titre ( $arrayfields [ 'p.ref' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.ref " , " " , $param , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'pfp.ref_fourn' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'pfp.ref_fourn' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " pfp.ref_fourn " , " " , $param , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'p.label' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.label' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.label " , " " , $param , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'p.fk_product_type' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.fk_product_type' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.fk_product_type " , " " , $param , " " , $sortfield , $sortorder , 'center ' );
}
if ( ! empty ( $arrayfields [ 'p.barcode' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.barcode' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.barcode " , " " , $param , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'p.duration' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.duration' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.duration " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
}
2020-02-10 14:34:00 +01:00
if ( ! empty ( $arrayfields [ 'p.finished' ][ 'checked' ])) {
2020-09-07 10:18:17 +02:00
print_liste_field_titre ( $arrayfields [ 'p.finished' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.finished " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
2020-02-10 14:34:00 +01:00
}
2020-01-21 10:33:27 +01:00
if ( ! empty ( $arrayfields [ 'p.weight' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.weight' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 'p.weight' , '' , $param , '' , $sortfield , $sortorder , 'center ' );
if ( ! empty ( $arrayfields [ 'p.weight_units' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.weight_units' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 'p.weight_units' , '' , $param , '' , $sortfield , $sortorder , 'center ' );
if ( ! empty ( $arrayfields [ 'p.length' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.length' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 'p.length' , '' , $param , '' , $sortfield , $sortorder , 'center ' );
if ( ! empty ( $arrayfields [ 'p.length_units' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.length_units' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 'p.length_units' , '' , $param , '' , $sortfield , $sortorder , 'center ' );
if ( ! empty ( $arrayfields [ 'p.width' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.width' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 'p.width' , '' , $param , '' , $sortfield , $sortorder , 'center ' );
if ( ! empty ( $arrayfields [ 'p.width_units' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.width_units' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 'p.width_units' , '' , $param , '' , $sortfield , $sortorder , 'center ' );
if ( ! empty ( $arrayfields [ 'p.height' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.height' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 'p.height' , '' , $param , '' , $sortfield , $sortorder , 'center ' );
if ( ! empty ( $arrayfields [ 'p.height_units' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.height_units' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 'p.height_units' , '' , $param , '' , $sortfield , $sortorder , 'center ' );
if ( ! empty ( $arrayfields [ 'p.surface' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.surface' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], " p.surface " , '' , $param , '' , $sortfield , $sortorder , 'center ' );
if ( ! empty ( $arrayfields [ 'p.surface_units' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.surface_units' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 'p.surface_units' , '' , $param , '' , $sortfield , $sortorder , 'center ' );
if ( ! empty ( $arrayfields [ 'p.volume' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.volume' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 'p.volume' , '' , $param , '' , $sortfield , $sortorder , 'center ' );
if ( ! empty ( $arrayfields [ 'p.volume_units' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.volume_units' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 'p.volume_units' , '' , $param , '' , $sortfield , $sortorder , 'center ' );
2020-09-07 10:18:17 +02:00
if ( ! empty ( $arrayfields [ 'cu.label' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'cu.label' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], '' , '' , $param , '' , $sortfield , $sortorder , 'center ' );
if ( ! empty ( $arrayfields [ 'p.sellprice' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.sellprice' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
2020-05-08 22:41:49 +02:00
// Multiprices
if ( $conf -> global -> PRODUIT_MULTIPRICES ){
foreach ( $arraypricelevel as $key => $value )
{
if ( ! empty ( $arrayfields [ 'p.sellprice' . $key ][ 'checked' ]))
{
print_liste_field_titre ( $arrayfields [ 'p.sellprice' . $key ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
}
}
2020-09-07 10:18:17 +02:00
if ( ! empty ( $arrayfields [ 'p.minbuyprice' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.minbuyprice' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
if ( ! empty ( $arrayfields [ 'p.numbuyprice' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.numbuyprice' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
if ( ! empty ( $arrayfields [ 'p.tva_tx' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.tva_tx' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
if ( ! empty ( $arrayfields [ 'p.pmp' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.pmp' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
if ( ! empty ( $arrayfields [ 'p.cost_price' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.cost_price' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
if ( ! empty ( $arrayfields [ 'p.seuil_stock_alerte' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.seuil_stock_alerte' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.seuil_stock_alerte " , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
if ( ! empty ( $arrayfields [ 'p.desiredstock' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.desiredstock' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.desiredstock " , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
if ( ! empty ( $arrayfields [ 'p.stock' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.stock' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.stock " , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'stock_virtual' ][ 'checked' ])) {
2020-09-07 10:18:17 +02:00
print_liste_field_titre ( $arrayfields [ 'stock_virtual' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.tobatch' ][ 'checked' ])) {
2020-09-07 10:18:17 +02:00
print_liste_field_titre ( $arrayfields [ 'p.tobatch' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.tobatch " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
}
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.accountancy_code_sell' ][ 'checked' ])) {
2020-09-07 10:18:17 +02:00
print_liste_field_titre ( $arrayfields [ 'p.accountancy_code_sell' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.accountancy_code_sell " , " " , $param , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'p.accountancy_code_sell_intra' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.accountancy_code_sell_intra' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.accountancy_code_sell_intra " , " " , $param , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'p.accountancy_code_sell_export' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.accountancy_code_sell_export' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.accountancy_code_sell_export " , " " , $param , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'p.accountancy_code_buy' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.accountancy_code_buy' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.accountancy_code_buy " , " " , $param , '' , $sortfield , $sortorder );
}
2020-03-01 04:52:12 +01:00
if ( ! empty ( $arrayfields [ 'p.accountancy_code_buy_intra' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.accountancy_code_buy_intra' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.accountancy_code_buy_intra " , " " , $param , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'p.accountancy_code_buy_export' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.accountancy_code_buy_export' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.accountancy_code_buy_export " , " " , $param , '' , $sortfield , $sortorder );
}
2018-06-22 15:43:22 +02:00
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php' ;
// Hook fields
2019-11-12 09:46:08 +01:00
$parameters = array ( 'arrayfields' => $arrayfields , 'param' => $param , 'sortfield' => $sortfield , 'sortorder' => $sortorder );
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
2018-06-22 15:43:22 +02:00
print $hookmanager -> resPrint ;
2020-09-07 10:18:17 +02:00
if ( ! empty ( $arrayfields [ 'p.datec' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.datec' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.datec " , " " , $param , '' , $sortfield , $sortorder , 'center nowrap ' );
}
if ( ! empty ( $arrayfields [ 'p.tms' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.tms' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.tms " , " " , $param , '' , $sortfield , $sortorder , 'center nowrap ' );
}
if ( ! empty ( $arrayfields [ 'p.tosell' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.tosell' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.tosell " , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
if ( ! empty ( $arrayfields [ 'p.tobuy' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.tobuy' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.tobuy " , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , '' , $sortfield , $sortorder , 'center maxwidthsearch ' );
print " </tr> \n " ;
2019-02-24 11:18:55 +01:00
$product_static = new Product ( $db );
$product_fourn = new ProductFournisseur ( $db );
2018-06-22 15:43:22 +02:00
$i = 0 ;
2019-11-12 09:46:08 +01:00
$totalarray = array ();
2019-01-27 11:55:16 +01:00
while ( $i < min ( $num , $limit ))
2018-06-22 15:43:22 +02:00
{
$obj = $db -> fetch_object ( $resql );
2016-07-23 16:37:21 +02:00
2018-06-22 15:43:22 +02:00
// Multilangs
2019-11-29 11:42:08 +01:00
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS )) // If multilang is enabled
2018-03-30 16:54:38 +02:00
{
2018-06-22 15:43:22 +02:00
$sql = " SELECT label " ;
2019-11-12 09:46:08 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " product_lang " ;
$sql .= " WHERE fk_product= " . $obj -> rowid ;
$sql .= " AND lang=' " . $db -> escape ( $langs -> getDefaultLang ()) . " ' " ;
$sql .= " LIMIT 1 " ;
2018-06-22 15:43:22 +02:00
$result = $db -> query ( $sql );
if ( $result )
{
$objtp = $db -> fetch_object ( $result );
2019-11-12 09:46:08 +01:00
if ( ! empty ( $objtp -> label )) $obj -> label = $objtp -> label ;
2018-06-22 15:43:22 +02:00
}
2018-03-30 16:54:38 +02:00
}
2017-10-26 17:02:40 +02:00
2018-06-22 15:43:22 +02:00
$product_static -> id = $obj -> rowid ;
$product_static -> ref = $obj -> ref ;
2019-12-06 09:26:49 +01:00
$product_static -> ref_fourn = $obj -> ref_supplier ; // deprecated
2019-11-29 11:32:09 +01:00
$product_static -> ref_supplier = $obj -> ref_supplier ;
2018-06-22 15:43:22 +02:00
$product_static -> label = $obj -> label ;
2020-02-10 14:34:00 +01:00
$product_static -> finished = $obj -> finished ;
2018-06-22 15:43:22 +02:00
$product_static -> type = $obj -> fk_product_type ;
$product_static -> status_buy = $obj -> tobuy ;
$product_static -> status = $obj -> tosell ;
$product_static -> status_batch = $obj -> tobatch ;
$product_static -> entity = $obj -> entity ;
$product_static -> pmp = $obj -> pmp ;
$product_static -> accountancy_code_sell = $obj -> accountancy_code_sell ;
$product_static -> accountancy_code_sell_export = $obj -> accountancy_code_sell_export ;
$product_static -> accountancy_code_sell_intra = $obj -> accountancy_code_sell_intra ;
$product_static -> accountancy_code_buy = $obj -> accountancy_code_buy ;
2020-03-01 04:52:12 +01:00
$product_static -> accountancy_code_buy_intra = $obj -> accountancy_code_buy_intra ;
$product_static -> accountancy_code_buy_export = $obj -> accountancy_code_buy_export ;
2019-01-22 12:42:02 +01:00
$product_static -> length = $obj -> length ;
$product_static -> length_units = $obj -> length_units ;
$product_static -> width = $obj -> width ;
$product_static -> width_units = $obj -> width_units ;
$product_static -> height = $obj -> height ;
$product_static -> height_units = $obj -> height_units ;
$product_static -> weight = $obj -> weight ;
$product_static -> weight_units = $obj -> weight_units ;
$product_static -> volume = $obj -> volume ;
$product_static -> volume_units = $obj -> volume_units ;
$product_static -> surface = $obj -> surface ;
$product_static -> surface_units = $obj -> surface_units ;
2020-09-07 10:18:17 +02:00
if ( ! empty ( $conf -> global -> PRODUCT_USE_UNITS )) {
$product_static -> fk_unit = $obj -> fk_unit ;
}
2018-06-22 15:43:22 +02:00
2019-11-29 11:32:09 +01:00
// STOCK_DISABLE_OPTIM_LOAD can be set to force load_stock whatever is permissions on stock.
2019-11-12 09:46:08 +01:00
if (( ! empty ( $conf -> stock -> enabled ) && $user -> rights -> stock -> lire && $search_type != 1 ) || ! empty ( $conf -> global -> STOCK_DISABLE_OPTIM_LOAD )) // To optimize call of load_stock
2018-06-22 15:43:22 +02:00
{
2019-11-12 09:46:08 +01:00
if ( $obj -> fk_product_type != 1 || ! empty ( $conf -> global -> STOCK_SUPPORTS_SERVICES )) // Not a service
2017-10-26 17:02:40 +02:00
{
2019-11-29 11:32:09 +01:00
$option = 'nobatch' ;
if ( empty ( $arrayfields [ 'stock_virtual' ][ 'checked' ])) $option .= ',novirtual' ;
2019-12-06 09:26:49 +01:00
$product_static -> load_stock ( $option ); // Load stock_reel + stock_warehouse. This can also call load_virtual_stock()
2018-06-22 15:43:22 +02:00
}
}
2018-06-22 14:51:47 +02:00
2018-06-22 15:43:22 +02:00
print '<tr class="oddeven">' ;
// Ref
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.ref' ][ 'checked' ]))
2017-10-13 13:28:26 +02:00
{
2018-06-22 15:43:22 +02:00
print '<td class="tdoverflowmax200">' ;
print $product_static -> getNomUrl ( 1 );
print " </td> \n " ;
2019-11-12 09:46:08 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2017-10-13 13:28:26 +02:00
}
2019-11-29 11:32:09 +01:00
2018-06-22 15:43:22 +02:00
// Ref supplier
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'pfp.ref_fourn' ][ 'checked' ]))
2017-10-13 13:28:26 +02:00
{
2018-06-22 15:43:22 +02:00
print '<td class="tdoverflowmax200">' ;
print $product_static -> getNomUrl ( 1 );
print " </td> \n " ;
2019-11-12 09:46:08 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2017-10-13 13:28:26 +02:00
}
2019-11-29 11:32:09 +01:00
2018-06-22 15:43:22 +02:00
// Label
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.label' ][ 'checked' ]))
2017-10-13 13:28:26 +02:00
{
2019-04-04 17:45:02 +02:00
print '<td class="tdoverflowmax200">' . dol_trunc ( $obj -> label , 80 ) . '</td>' ;
2019-11-12 09:46:08 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2018-06-22 14:51:47 +02:00
}
2018-06-22 15:43:22 +02:00
2018-06-22 14:51:47 +02:00
// Type
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.fk_product_type' ][ 'checked' ]))
2018-06-22 14:51:47 +02:00
{
2020-08-07 20:10:31 +02:00
print '<td class="center">' ;
$s = '' ;
if ( $obj -> fk_product_type == 0 )
{
2020-08-07 20:44:49 +02:00
//$s .= '<a class="product-type-back" title="'.$langs->trans("Product").'">';
$s .= img_picto ( $langs -> trans ( " Product " ), 'product' , 'class="paddingleftonly paddingrightonly colorgrey"' );
//$s .= dol_substr($langs->trans("Product"), 0, 1);
//$s .= '</a>';
2020-08-07 20:10:31 +02:00
} else {
2020-08-07 20:44:49 +02:00
//$s .= '<span class="service-type-back" title="'.$langs->trans("Service").'">';
$s .= img_picto ( $langs -> trans ( " Service " ), 'service' , 'class="paddingleftonly paddingrightonly colorgrey"' );
//$s .= dol_substr($langs->trans("Service"), 0, 1);
//$s .= '</a>';
2020-08-07 20:10:31 +02:00
}
print $s ;
2020-01-21 20:50:58 +01:00
print '</td>' ;
2019-11-12 09:46:08 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2018-06-22 14:51:47 +02:00
}
2018-06-22 15:43:22 +02:00
2018-06-22 14:51:47 +02:00
// Barcode
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.barcode' ][ 'checked' ]))
2018-06-22 14:51:47 +02:00
{
2018-06-22 15:43:22 +02:00
print '<td>' . $obj -> barcode . '</td>' ;
2019-11-12 09:46:08 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2018-06-22 14:51:47 +02:00
}
2018-06-22 15:43:22 +02:00
2018-11-29 13:44:10 +01:00
// Duration
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.duration' ][ 'checked' ]))
2018-11-29 13:44:10 +01:00
{
2019-03-07 21:57:03 +01:00
print '<td class="center nowraponall">' ;
2018-11-29 13:44:10 +01:00
2019-01-27 11:55:16 +01:00
if ( preg_match ( '/([^a-z]+)[a-z]$/i' , $obj -> duration ))
2015-10-29 22:12:11 +01:00
{
2019-11-12 09:46:08 +01:00
$duration_value = substr ( $obj -> duration , 0 , dol_strlen ( $obj -> duration ) - 1 );
$duration_unit = substr ( $obj -> duration , - 1 );
2018-08-21 20:12:27 +02:00
2018-11-29 13:44:10 +01:00
if (( float ) $duration_value > 1 )
2018-08-21 12:10:05 +02:00
{
2020-09-07 10:18:17 +02:00
$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 " ));
2020-05-21 15:05:19 +02:00
} elseif (( float ) $duration_value > 0 )
2016-04-28 10:24:43 +02:00
{
2020-09-07 10:18:17 +02:00
$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 " ));
2016-04-28 10:24:43 +02:00
}
2018-10-24 03:35:44 +02:00
print $duration_value ;
2019-11-12 09:46:08 +01:00
print (( ! empty ( $duration_unit ) && isset ( $dur [ $duration_unit ]) && $duration_value != '' ) ? ' ' . $langs -> trans ( $dur [ $duration_unit ]) : '' );
2020-05-21 15:05:19 +02:00
} elseif ( ! preg_match ( '/^[a-z]$/i' , $obj -> duration )) // If duration is a simple char (like 's' of 'm'), we do not show value
2018-10-24 03:35:44 +02:00
{
print $obj -> duration ;
2018-06-22 15:43:22 +02:00
}
2019-04-04 17:13:52 +02:00
2018-06-22 14:51:47 +02:00
print '</td>' ;
2019-11-12 09:46:08 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2018-06-22 14:51:47 +02:00
}
2016-07-23 16:37:21 +02:00
2020-02-10 14:34:00 +01:00
// Finished
if ( ! empty ( $arrayfields [ 'p.finished' ][ 'checked' ]))
{
print '<td class="center">' ;
print $product_static -> getLibFinished ();
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2019-04-04 17:06:26 +02:00
// Weight
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.weight' ][ 'checked' ]))
2019-04-04 17:06:26 +02:00
{
2020-09-07 10:18:17 +02:00
print '<td class="center">' ;
print $obj -> weight ;
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2019-04-04 17:06:26 +02:00
}
2020-01-21 10:33:27 +01:00
// Weight units
if ( ! empty ( $arrayfields [ 'p.weight_units' ][ 'checked' ])) {
print '<td class="center">' ;
2020-01-21 17:29:45 +01:00
if ( $product_static -> weight != '' ) print measuringUnitString ( 0 , 'weight' , $product_static -> weight_units );
2020-01-21 10:33:27 +01:00
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2019-04-04 17:06:26 +02:00
// Length
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.length' ][ 'checked' ]))
2019-04-04 17:06:26 +02:00
{
2020-09-07 10:18:17 +02:00
print '<td class="center">' ;
print $obj -> length ;
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2019-04-04 17:06:26 +02:00
}
2020-01-21 10:33:27 +01:00
// Length units
if ( ! empty ( $arrayfields [ 'p.length_units' ][ 'checked' ])) {
print '<td class="center">' ;
2020-01-21 17:29:45 +01:00
if ( $product_static -> length != '' ) print measuringUnitString ( 0 , 'size' , $product_static -> length_units );
2020-01-21 10:33:27 +01:00
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2020-09-07 10:18:17 +02:00
// Width
if ( ! empty ( $arrayfields [ 'p.width' ][ 'checked' ]))
{
print '<td align="center">' ;
print $obj -> width ;
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2020-01-21 10:33:27 +01:00
// Width units
if ( ! empty ( $arrayfields [ 'p.width_units' ][ 'checked' ])) {
print '<td class="center">' ;
2020-01-21 17:29:45 +01:00
if ( $product_static -> width != '' ) print measuringUnitString ( 0 , 'size' , $product_static -> width_units );
2020-01-21 10:33:27 +01:00
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2020-09-07 10:18:17 +02:00
// Height
if ( ! empty ( $arrayfields [ 'p.height' ][ 'checked' ]))
{
print '<td align="center">' ;
print $obj -> height ;
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2020-01-21 10:33:27 +01:00
// Height units
if ( ! empty ( $arrayfields [ 'p.height_units' ][ 'checked' ])) {
print '<td class="center">' ;
2020-01-21 17:29:45 +01:00
if ( $product_static -> height != '' ) print measuringUnitString ( 0 , 'size' , $product_static -> height_units );
2020-01-21 10:33:27 +01:00
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2019-04-04 17:06:26 +02:00
// Surface
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.surface' ][ 'checked' ]))
2019-04-04 17:06:26 +02:00
{
2020-09-07 10:18:17 +02:00
print '<td class="center">' ;
print $obj -> surface ;
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2019-04-04 17:06:26 +02:00
}
2020-01-21 10:33:27 +01:00
// Surface units
if ( ! empty ( $arrayfields [ 'p.surface_units' ][ 'checked' ])) {
print '<td class="center">' ;
2020-01-21 17:29:45 +01:00
if ( $product_static -> surface != '' ) print measuringUnitString ( 0 , 'surface' , $product_static -> surface_units );
2020-01-21 10:33:27 +01:00
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2019-04-04 17:06:26 +02:00
// Volume
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.volume' ][ 'checked' ]))
2019-04-04 17:06:26 +02:00
{
2020-09-07 10:18:17 +02:00
print '<td class="center">' ;
print $obj -> volume ;
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2019-04-04 17:06:26 +02:00
}
2020-01-21 11:02:14 +01:00
// Volume units
2020-01-21 10:33:27 +01:00
if ( ! empty ( $arrayfields [ 'p.volume_units' ][ 'checked' ])) {
print '<td class="center">' ;
2020-01-21 17:29:45 +01:00
if ( $product_static -> volume != '' ) print measuringUnitString ( 0 , 'volume' , $product_static -> volume_units );
2020-01-21 10:33:27 +01:00
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2020-09-07 10:18:17 +02:00
// Unit
if ( ! empty ( $arrayfields [ 'cu.label' ][ 'checked' ]))
{
print '<td align="center">' ;
if ( ! empty ( $obj -> cu_label )) {
print $langs -> trans ( $obj -> cu_label );
}
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2019-04-04 17:13:52 +02:00
2018-06-22 14:51:47 +02:00
// Sell price
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.sellprice' ][ 'checked' ]))
2018-06-22 14:51:47 +02:00
{
2018-07-12 18:05:33 +02:00
print '<td class="right nowraponall">' ;
2018-06-22 15:43:22 +02:00
if ( $obj -> tosell )
{
if ( $obj -> price_base_type == 'TTC' ) print price ( $obj -> price_ttc ) . ' ' . $langs -> trans ( " TTC " );
else print price ( $obj -> price ) . ' ' . $langs -> trans ( " HT " );
}
2018-06-22 14:51:47 +02:00
print '</td>' ;
2019-11-12 09:46:08 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2018-06-22 14:51:47 +02:00
}
2016-07-23 16:37:21 +02:00
2020-05-08 22:41:49 +02:00
// Multiprices
if ( $conf -> global -> PRODUIT_MULTIPRICES ){
foreach ( $arraypricelevel as $key => $value )
{
if ( ! empty ( $arrayfields [ 'p.sellprice' . $key ][ 'checked' ]))
{
2020-05-14 11:37:26 +02:00
print '<td class="right nowraponall">' ;
if ( $obj -> tosell )
2020-05-08 22:41:49 +02:00
{
2020-05-25 22:50:00 +02:00
// TODO Make 1 request for all price levels (without filter on price_level) and saved result into an cache array
// then reuse the cache array if we need prices for other price levels
2020-05-14 11:37:26 +02:00
$resultp = " SELECT p.rowid, p.fk_product, p.price, p.price_ttc, p.price_level, p.date_price " ;
$resultp .= " FROM " . MAIN_DB_PREFIX . " product_price as p " ;
$resultp .= " WHERE fk_product = " . $obj -> rowid ;
$resultp .= " AND p.price_level = " . $key ;
$resultp .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC " ;
$resultp = $db -> query ( $resultp );
if ( $resultp )
{
$objp = $db -> fetch_object ( $resultp );
if ( $obj -> price_base_type == 'TTC' ) print price ( $objp -> price_ttc ) . ' ' . $langs -> trans ( " TTC " );
2020-05-14 11:38:27 +02:00
else print price ( $objp -> price ) . ' ' . $langs -> trans ( " HT " );
2020-05-14 11:37:26 +02:00
$db -> free ( $resultp );
} else {
dol_print_error ( $db );
2020-05-08 22:46:06 +02:00
}
2020-05-08 22:41:49 +02:00
}
2020-05-14 11:37:26 +02:00
print '</td>' ;
2020-05-08 22:41:49 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
}
}
2018-06-22 15:43:22 +02:00
// Better buy price
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.minbuyprice' ][ 'checked' ]))
2018-06-22 14:51:47 +02:00
{
2018-07-12 18:05:33 +02:00
print '<td class="right nowraponall">' ;
2018-06-22 15:43:22 +02:00
if ( $obj -> tobuy && $obj -> minsellprice != '' )
{
//print price($obj->minsellprice).' '.$langs->trans("HT");
if ( $product_fourn -> find_min_price_product_fournisseur ( $obj -> rowid ) > 0 )
2017-06-30 10:56:05 +02:00
{
2018-06-22 15:43:22 +02:00
if ( $product_fourn -> product_fourn_price_id > 0 )
2017-06-30 10:56:05 +02:00
{
2019-11-12 09:46:08 +01:00
if ( ! empty ( $conf -> fournisseur -> enabled ) && $user -> rights -> fournisseur -> lire )
2017-06-30 10:56:05 +02:00
{
2019-11-12 09:46:08 +01:00
$htmltext = $product_fourn -> display_price_product_fournisseur ( 1 , 1 , 0 , 1 );
print $form -> textwithpicto ( price ( $product_fourn -> fourn_unitprice * ( 1 - $product_fourn -> fourn_remise_percent / 100 ) - $product_fourn -> fourn_remise ) . ' ' . $langs -> trans ( " HT " ), $htmltext );
2020-05-21 15:05:19 +02:00
} else print price ( $product_fourn -> fourn_unitprice ) . ' ' . $langs -> trans ( " HT " );
2017-06-30 10:56:05 +02:00
}
}
2018-06-22 15:43:22 +02:00
}
2018-06-22 14:51:47 +02:00
print '</td>' ;
2019-11-12 09:46:08 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2018-06-22 14:51:47 +02:00
}
2017-06-26 22:44:56 +02:00
2018-06-22 15:43:22 +02:00
// Number of buy prices
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.numbuyprice' ][ 'checked' ]))
2018-06-22 14:51:47 +02:00
{
2019-02-24 11:18:55 +01:00
print '<td class="right">' ;
2018-06-22 15:43:22 +02:00
if ( $obj -> tobuy )
{
if ( count ( $productFournList = $product_fourn -> list_product_fournisseur_price ( $obj -> rowid )) > 0 )
2017-06-30 10:56:05 +02:00
{
2019-11-12 09:46:08 +01:00
$htmltext = $product_fourn -> display_price_product_fournisseur ( 1 , 1 , 0 , 1 , $productFournList );
2019-01-27 11:55:16 +01:00
print $form -> textwithpicto ( count ( $productFournList ), $htmltext );
2017-06-30 10:56:05 +02:00
}
2018-06-22 15:43:22 +02:00
}
2018-06-22 14:51:47 +02:00
print '</td>' ;
}
2017-07-07 19:48:35 +02:00
2020-09-07 10:18:17 +02:00
// VAT or Sell Tax Rate
if ( ! empty ( $arrayfields [ 'p.tva_tx' ][ 'checked' ]))
{
print '<td class="right">' ;
print vatrate ( $obj -> tva_tx , true );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2019-06-19 21:35:35 +02:00
2018-06-22 14:51:47 +02:00
// WAP
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.pmp' ][ 'checked' ]))
2018-06-22 14:51:47 +02:00
{
2019-02-24 11:18:55 +01:00
print '<td class="nowrap right">' ;
2018-06-22 15:43:22 +02:00
print price ( $product_static -> pmp , 1 , $langs );
2018-06-22 14:51:47 +02:00
print '</td>' ;
}
2020-08-07 20:10:31 +02:00
// Cost price
2020-07-24 13:40:06 +02:00
if ( ! empty ( $arrayfields [ 'p.cost_price' ][ 'checked' ]))
{
print '<td class="nowrap right">' ;
//print $obj->cost_price;
print price ( $obj -> cost_price ) . ' ' . $langs -> trans ( " HT " );
print '</td>' ;
}
2018-06-22 15:43:22 +02:00
// Limit alert
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.seuil_stock_alerte' ][ 'checked' ]))
2018-06-22 14:51:47 +02:00
{
2019-02-24 11:18:55 +01:00
print '<td class="right">' ;
2018-06-22 15:43:22 +02:00
if ( $obj -> fk_product_type != 1 )
{
print $obj -> seuil_stock_alerte ;
}
2018-06-22 14:51:47 +02:00
print '</td>' ;
2019-11-12 09:46:08 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2018-06-22 14:51:47 +02:00
}
// Desired stock
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.desiredstock' ][ 'checked' ]))
2018-06-22 14:51:47 +02:00
{
2019-02-24 11:18:55 +01:00
print '<td class="right">' ;
2018-06-22 15:43:22 +02:00
if ( $obj -> fk_product_type != 1 )
{
print $obj -> desiredstock ;
}
2018-06-22 14:51:47 +02:00
print '</td>' ;
2019-11-12 09:46:08 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2018-06-22 15:43:22 +02:00
}
// Stock real
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.stock' ][ 'checked' ]))
2018-06-22 15:43:22 +02:00
{
2019-02-24 11:18:55 +01:00
print '<td class="right">' ;
2018-06-22 15:43:22 +02:00
if ( $obj -> fk_product_type != 1 )
{
if ( $obj -> seuil_stock_alerte != '' && $product_static -> stock_reel < ( float ) $obj -> seuil_stock_alerte ) print img_warning ( $langs -> trans ( " StockLowerThanLimit " , $obj -> seuil_stock_alerte )) . ' ' ;
print $product_static -> stock_reel ;
}
print '</td>' ;
2019-11-12 09:46:08 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2018-06-22 15:43:22 +02:00
}
// Stock virtual
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'stock_virtual' ][ 'checked' ]))
2018-06-22 15:43:22 +02:00
{
2019-02-24 11:18:55 +01:00
print '<td class="right">' ;
2018-06-22 15:43:22 +02:00
if ( $obj -> fk_product_type != 1 )
{
if ( $obj -> seuil_stock_alerte != '' && $product_static -> stock_theorique < ( float ) $obj -> seuil_stock_alerte ) print img_warning ( $langs -> trans ( " StockLowerThanLimit " , $obj -> seuil_stock_alerte )) . ' ' ;
print $product_static -> stock_theorique ;
}
print '</td>' ;
2019-11-12 09:46:08 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2018-06-22 15:43:22 +02:00
}
// Lot/Serial
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.tobatch' ][ 'checked' ]))
2018-06-22 15:43:22 +02:00
{
2019-02-24 11:18:55 +01:00
print '<td class="center">' ;
2018-06-22 15:43:22 +02:00
print yn ( $obj -> tobatch );
print '</td>' ;
2019-11-12 09:46:08 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2018-06-22 14:51:47 +02:00
}
// Accountancy code sell
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.accountancy_code_sell' ][ 'checked' ]))
2018-06-22 15:43:22 +02:00
{
print '<td>' . $obj -> accountancy_code_sell . '</td>' ;
2019-11-12 09:46:08 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2018-06-22 15:43:22 +02:00
}
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.accountancy_code_sell_intra' ][ 'checked' ]))
2019-04-25 01:16:29 +02:00
{
2020-09-07 10:18:17 +02:00
print '<td>' . $obj -> accountancy_code_sell_intra . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2019-04-25 01:16:29 +02:00
}
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.accountancy_code_sell_export' ][ 'checked' ]))
2019-04-25 01:16:29 +02:00
{
2020-09-07 10:18:17 +02:00
print '<td>' . $obj -> accountancy_code_sell_export . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2019-04-25 01:16:29 +02:00
}
// Accountancy code buy
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.accountancy_code_buy' ][ 'checked' ]))
2018-06-22 15:43:22 +02:00
{
print '<td>' . $obj -> accountancy_code_buy . '</td>' ;
2019-11-12 09:46:08 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2018-06-22 15:43:22 +02:00
}
2020-03-01 04:52:12 +01:00
if ( ! empty ( $arrayfields [ 'p.accountancy_code_buy_intra' ][ 'checked' ]))
{
print '<td>' . $obj -> accountancy_code_buy_intra . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
if ( ! empty ( $arrayfields [ 'p.accountancy_code_buy_export' ][ 'checked' ]))
{
print '<td>' . $obj -> accountancy_code_buy_export . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2018-06-22 14:51:47 +02:00
// Extra fields
2018-06-22 15:43:22 +02:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php' ;
2018-06-22 14:51:47 +02:00
// Fields from hook
2020-05-08 01:40:25 +02:00
$parameters = array ( 'arrayfields' => $arrayfields , 'obj' => $obj , 'i' => $i , 'totalarray' =>& $totalarray );
2019-11-12 09:46:08 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListValue' , $parameters ); // Note that $action and $object may have been modified by hook
2018-06-22 14:51:47 +02:00
print $hookmanager -> resPrint ;
// Date creation
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.datec' ][ 'checked' ]))
2018-06-22 14:51:47 +02:00
{
2019-05-04 16:46:09 +02:00
print '<td class="center nowraponall">' ;
2019-04-01 19:27:34 +02:00
print dol_print_date ( $db -> jdate ( $obj -> date_creation ), 'dayhour' , 'tzuser' );
2018-06-22 14:51:47 +02:00
print '</td>' ;
2019-11-12 09:46:08 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2018-06-22 14:51:47 +02:00
}
// Date modification
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.tms' ][ 'checked' ]))
2018-06-22 14:51:47 +02:00
{
2019-05-04 16:46:09 +02:00
print '<td class="center nowraponall">' ;
2019-04-01 19:27:34 +02:00
print dol_print_date ( $db -> jdate ( $obj -> date_update ), 'dayhour' , 'tzuser' );
2018-06-22 14:51:47 +02:00
print '</td>' ;
2019-11-12 09:46:08 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2018-06-22 14:51:47 +02:00
}
2018-06-22 15:43:22 +02:00
// Status (to sell)
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.tosell' ][ 'checked' ]))
2018-06-22 14:51:47 +02:00
{
2019-02-24 11:18:55 +01:00
print '<td class="right nowrap">' ;
2019-11-12 09:46:08 +01:00
if ( ! empty ( $conf -> use_javascript_ajax ) && $user -> rights -> produit -> creer && ! empty ( $conf -> global -> MAIN_DIRECT_STATUS_UPDATE )) {
2018-06-22 15:43:22 +02:00
print ajax_object_onoff ( $product_static , 'status' , 'tosell' , 'ProductStatusOnSell' , 'ProductStatusNotOnSell' );
} else {
2019-01-27 11:55:16 +01:00
print $product_static -> LibStatut ( $obj -> tosell , 5 , 0 );
2017-10-13 13:28:26 +02:00
}
print '</td>' ;
2019-11-12 09:46:08 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2018-06-22 14:51:47 +02:00
}
2018-06-22 15:43:22 +02:00
// Status (to buy)
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.tobuy' ][ 'checked' ]))
2018-06-22 15:43:22 +02:00
{
2019-02-24 11:18:55 +01:00
print '<td class="right nowrap">' ;
2019-11-12 09:46:08 +01:00
if ( ! empty ( $conf -> use_javascript_ajax ) && $user -> rights -> produit -> creer && ! empty ( $conf -> global -> MAIN_DIRECT_STATUS_UPDATE )) {
2018-06-22 15:43:22 +02:00
print ajax_object_onoff ( $product_static , 'status_buy' , 'tobuy' , 'ProductStatusOnBuy' , 'ProductStatusNotOnBuy' );
} else {
2019-01-27 11:55:16 +01:00
print $product_static -> LibStatut ( $obj -> tobuy , 5 , 1 );
2018-06-22 15:43:22 +02:00
}
print '</td>' ;
2019-11-12 09:46:08 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2018-06-22 15:43:22 +02:00
}
2019-11-29 11:32:09 +01:00
2018-06-22 15:43:22 +02:00
// Action
2019-02-24 11:18:55 +01:00
print '<td class="nowrap center">' ;
2018-06-22 15:43:22 +02:00
if ( $massactionbutton || $massaction ) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
2019-11-12 09:46:08 +01:00
$selected = 0 ;
if ( in_array ( $obj -> rowid , $arrayofselected )) $selected = 1 ;
print '<input id="cb' . $obj -> rowid . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj -> rowid . '"' . ( $selected ? ' checked="checked"' : '' ) . '>' ;
2018-06-22 15:43:22 +02:00
}
print '</td>' ;
2019-11-12 09:46:08 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2017-10-13 13:28:26 +02:00
2018-06-22 15:43:22 +02:00
print " </tr> \n " ;
$i ++ ;
2017-10-13 13:28:26 +02:00
}
2018-06-22 15:43:22 +02:00
$db -> free ( $resql );
2003-09-04 11:59:59 +02:00
2018-06-22 15:43:22 +02:00
print " </table> " ;
print " </div> " ;
2018-06-22 14:51:47 +02:00
print '</form>' ;
2020-05-21 15:05:19 +02:00
} else {
2018-06-22 14:51:47 +02:00
dol_print_error ( $db );
2005-11-27 22:41:30 +01:00
}
2003-09-04 11:59:59 +02:00
2018-08-15 12:48:13 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-07-24 17:52:46 +02:00
$db -> close ();