2004-10-20 00:24:10 +02:00
< ? php
2021-03-18 17:08:55 +01:00
/* Copyright ( C ) 2003 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2004 - 2014 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2004 Sebastien Di Cintio < sdicintio @ ressource - toi . org >
* Copyright ( C ) 2004 Benoit Mortier < benoit . mortier @ opensides . be >
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
* Copyright ( C ) 2020 - 2021 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2003-11-17 17:35:49 +01: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-11-17 17:35:49 +01: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-11-17 17:35:49 +01:00
*/
2005-04-12 22:01:42 +02:00
/**
2009-07-30 00:52:08 +02:00
* \defgroup service Module services
2009-06-08 20:14:37 +02:00
* \brief Module pour gerer le suivi de services predefinis
2011-10-24 14:11:49 +02:00
* \file htdocs / core / modules / modService . class . php
2009-06-08 20:14:37 +02:00
* \ingroup service
2021-03-20 13:55:43 +01:00
* \brief Description and activation file for the module Service
2008-10-01 21:10:17 +02:00
*/
2019-11-13 19:35:39 +01:00
include_once DOL_DOCUMENT_ROOT . '/core/modules/DolibarrModules.class.php' ;
2007-10-10 01:15:25 +02:00
2003-11-17 17:35:49 +01:00
2012-03-30 00:54:41 +02:00
/**
2015-09-07 15:55:26 +02:00
* Class to describe and enable module Service
2008-10-01 21:10:17 +02:00
*/
2003-11-17 17:35:49 +01:00
class modService extends DolibarrModules
{
2008-10-01 21:10:17 +02:00
/**
2011-09-26 16:22:35 +02:00
* Constructor . Define names , constants , directories , boxes , permissions
*
2012-01-04 21:23:50 +01:00
* @ param DoliDB $db Database handler
2008-10-01 21:10:17 +02:00
*/
2019-02-25 20:35:59 +01:00
public function __construct ( $db )
2008-10-01 21:10:17 +02:00
{
2018-08-10 15:39:49 +02:00
global $conf , $mysoc ;
2009-06-08 20:44:53 +02:00
2012-01-04 21:23:50 +01:00
$this -> db = $db ;
$this -> numero = 53 ;
2008-10-01 21:10:17 +02:00
$this -> family = " products " ;
2019-06-21 13:25:40 +02:00
$this -> module_position = '29' ;
2008-10-01 21:10:17 +02:00
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
2019-01-27 11:55:16 +01:00
$this -> name = preg_replace ( '/^mod/i' , '' , get_class ( $this ));
2017-05-04 20:16:55 +02:00
$this -> description = " Service management " ;
2008-10-01 21:10:17 +02:00
2008-12-15 23:25:59 +01:00
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this -> version = 'dolibarr' ;
2009-05-04 13:40:00 +02:00
2008-10-06 09:39:52 +02:00
$this -> const_name = 'MAIN_MODULE_' . strtoupper ( $this -> name );
2019-11-13 19:35:39 +01:00
$this -> picto = 'service' ;
2009-05-04 13:40:00 +02:00
2009-04-28 15:04:35 +02:00
// Data directories to create when module is enabled
2014-10-03 02:00:50 +02:00
$this -> dirs = array ( " /product/temp " );
2008-10-01 21:10:17 +02:00
2018-07-10 09:32:55 +02:00
// Dependencies
2019-11-13 19:35:39 +01:00
$this -> hidden = false ; // A condition to hide module
$this -> depends = array (); // List of module class names as string that must be enabled if this module is enabled
$this -> requiredby = array (); // List of module ids to disable if this one is disabled
$this -> conflictwith = array (); // List of module class names as string this module is in conflict with
2021-02-06 13:48:31 +01:00
$this -> phpmin = array ( 5 , 6 ); // Minimum version of PHP required by module
2008-10-01 21:10:17 +02:00
2009-06-08 20:44:53 +02:00
// Config pages
2012-03-03 16:33:38 +01:00
$this -> config_page_url = array ( " product.php@product " );
2019-11-13 19:35:39 +01:00
$this -> langfiles = array ( " products " , " companies " , " stocks " , " bills " );
2009-06-08 20:44:53 +02:00
2009-05-04 13:40:00 +02:00
// Constants
2008-10-01 21:10:17 +02:00
$this -> const = array ();
2009-05-04 13:40:00 +02:00
// Boxes
2013-10-26 16:18:28 +02:00
$this -> boxes = array (
2019-11-13 19:35:39 +01:00
0 => array ( 'file' => 'box_services_contracts.php' , 'enabledbydefaulton' => 'Home' ),
1 => array ( 'file' => 'box_graph_product_distribution.php' , 'enabledbydefaulton' => 'Home' )
2013-10-26 16:18:28 +02:00
);
2008-10-01 21:10:17 +02:00
// Permissions
$this -> rights = array ();
$this -> rights_class = 'service' ;
2019-11-13 19:35:39 +01:00
$r = 0 ;
2009-06-08 20:14:37 +02:00
$this -> rights [ $r ][ 0 ] = 531 ; // id de la permission
2018-05-01 11:09:03 +02:00
$this -> rights [ $r ][ 1 ] = 'Read services' ; // libelle de la permission
2009-06-08 20:14:37 +02:00
$this -> rights [ $r ][ 2 ] = 'r' ; // type de la permission (deprecie a ce jour)
2016-06-04 12:16:30 +02:00
$this -> rights [ $r ][ 3 ] = 0 ; // La permission est-elle une permission par defaut
2009-06-08 20:14:37 +02:00
$this -> rights [ $r ][ 4 ] = 'lire' ;
2020-10-31 14:32:18 +01:00
$r ++ ;
2009-06-08 20:14:37 +02:00
$this -> rights [ $r ][ 0 ] = 532 ; // id de la permission
2018-05-01 11:09:03 +02:00
$this -> rights [ $r ][ 1 ] = 'Create/modify services' ; // libelle de la permission
2009-06-08 20:14:37 +02:00
$this -> rights [ $r ][ 2 ] = 'w' ; // type de la permission (deprecie a ce jour)
$this -> rights [ $r ][ 3 ] = 0 ; // La permission est-elle une permission par defaut
$this -> rights [ $r ][ 4 ] = 'creer' ;
2020-10-31 14:32:18 +01:00
$r ++ ;
2009-06-08 20:14:37 +02:00
$this -> rights [ $r ][ 0 ] = 534 ; // id de la permission
2018-05-01 11:09:03 +02:00
$this -> rights [ $r ][ 1 ] = 'Delete les services' ; // libelle de la permission
2009-06-08 20:14:37 +02:00
$this -> rights [ $r ][ 2 ] = 'd' ; // type de la permission (deprecie a ce jour)
$this -> rights [ $r ][ 3 ] = 0 ; // La permission est-elle une permission par defaut
$this -> rights [ $r ][ 4 ] = 'supprimer' ;
2020-10-31 14:32:18 +01:00
$r ++ ;
2009-06-08 20:14:37 +02:00
2019-11-13 19:35:39 +01:00
$this -> rights [ $r ][ 0 ] = 538 ; // Must be same permission than in product module
2018-05-01 11:09:03 +02:00
$this -> rights [ $r ][ 1 ] = 'Export services' ;
2009-06-08 20:14:37 +02:00
$this -> rights [ $r ][ 2 ] = 'r' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'export' ;
2020-10-31 14:32:18 +01:00
$r ++ ;
2009-06-08 20:44:53 +02:00
2016-09-30 13:02:13 +02:00
// Menus
//-------
2019-11-13 19:35:39 +01:00
$this -> menu = 1 ; // This module add menu entries. They are coded into menu manager.
2019-03-03 13:02:20 +01:00
/* We can ' t enable this here because it must be enabled in both product and service module and this creates duplicate inserts
$r = 0 ;
$this -> menu [ $r ] = array ( 'fk_menu' => 'fk_mainmenu=home,fk_leftmenu=admintools' , // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type' => 'left' , // This is a Left menu entry
'titre' => 'ProductVatMassChange' ,
'url' => '/product/admin/product_tools.php?mainmenu=home&leftmenu=admintools' ,
'langs' => 'products' , // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position' => 300 ,
'enabled' => '$conf->product->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)' , // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms' => '1' , // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'target' => '' ,
'user' => 0 ); // 0=Menu for internal users, 1=external users, 2=both
$r ++ ;
*/
2017-11-06 12:59:58 +01:00
2020-09-17 13:03:34 +02:00
$usenpr = 0 ;
2021-02-23 22:03:23 +01:00
if ( is_object ( $mysoc )) {
$usenpr = $mysoc -> useNPR ();
}
2020-09-17 10:11:06 +02:00
2020-10-31 14:32:18 +01:00
// Exports
2009-06-08 20:44:53 +02:00
//--------
2020-03-12 12:45:44 +01:00
$r = 0 ;
2009-06-08 20:44:53 +02:00
2021-04-14 04:45:17 +02:00
$alias_product_perentity = empty ( $conf -> global -> MAIN_PRODUCT_PERENTITY_SHARED ) ? " p " : " ppe " ;
2021-03-30 22:05:03 +02:00
2009-06-08 20:44:53 +02:00
$r ++ ;
2020-03-12 12:45:44 +01:00
$this -> export_code [ $r ] = $this -> rights_class . '_' . $r ;
$this -> export_label [ $r ] = " Services " ; // Translation key (used only if key ExportDataset_xxx_z not found)
$this -> export_permission [ $r ] = array ( array ( " service " , " export " ));
$this -> export_fields_array [ $r ] = array (
'p.rowid' => " Id " , 'p.ref' => " Ref " , 'p.label' => " Label " ,
'p.fk_product_type' => 'Type' , 'p.tosell' => " OnSell " , 'p.tobuy' => " OnBuy " ,
'p.description' => " Description " , 'p.url' => " PublicUrl " ,
'p.customcode' => 'CustomCode' , 'p.fk_country' => 'IDCountry' ,
2021-03-30 03:27:46 +02:00
$alias_product_perentity . '.accountancy_code_sell' => " ProductAccountancySellCode " , $alias_product_perentity . '.accountancy_code_sell_intra' => " ProductAccountancySellIntraCode " ,
$alias_product_perentity . '.accountancy_code_sell_export' => " ProductAccountancySellExportCode " , $alias_product_perentity . '.accountancy_code_buy' => " ProductAccountancyBuyCode " ,
$alias_product_perentity . '.accountancy_code_buy_intra' => " ProductAccountancyBuyIntraCode " , $alias_product_perentity . '.accountancy_code_buy_export' => " ProductAccountancyBuyExportCode " ,
2020-03-12 12:45:44 +01:00
'p.note' => " NotePrivate " , 'p.note_public' => 'NotePublic' ,
'p.weight' => " Weight " , 'p.length' => " Length " , 'p.width' => " Width " , 'p.height' => " Height " , 'p.surface' => " Surface " , 'p.volume' => " Volume " ,
2019-10-04 10:04:02 +02:00
'p.duration' => " Duration " ,
2019-10-09 02:05:20 +02:00
'p.finished' => 'Nature' ,
2020-03-12 12:45:44 +01:00
'p.price_base_type' => " PriceBase " , 'p.price' => " UnitPriceHT " , 'p.price_ttc' => " UnitPriceTTC " ,
2019-10-09 02:05:20 +02:00
'p.tva_tx' => 'VATRate' ,
2020-03-12 12:45:44 +01:00
'p.datec' => 'DateCreation' , 'p.tms' => 'DateModification'
2019-10-04 10:04:02 +02:00
);
2021-02-23 22:03:23 +01:00
if ( is_object ( $mysoc ) && $usenpr ) {
$this -> export_fields_array [ $r ][ 'p.recuperableonly' ] = 'NPR' ;
}
2021-04-12 06:27:46 +02:00
if (( ! empty ( $conf -> fournisseur -> enabled ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD )) || ! empty ( $conf -> supplier_order -> enabled ) || ! empty ( $conf -> supplier_invoice -> enabled ) || ! empty ( $conf -> margin -> enabled )) {
2021-02-23 22:03:23 +01:00
$this -> export_fields_array [ $r ] = array_merge ( $this -> export_fields_array [ $r ], array ( 'p.cost_price' => 'CostPrice' ));
}
if ( ! empty ( $conf -> stock -> enabled )) {
$this -> export_fields_array [ $r ] = array_merge ( $this -> export_fields_array [ $r ], array ( 'p.stock' => 'Stock' , 'p.seuil_stock_alerte' => 'StockLimit' , 'p.desiredstock' => 'DesiredStock' , 'p.pmp' => 'PMPValue' ));
}
2022-08-19 18:07:21 +02:00
if ( isModEnabled ( 'barcode' )) {
2021-02-23 22:03:23 +01:00
$this -> export_fields_array [ $r ] = array_merge ( $this -> export_fields_array [ $r ], array ( 'p.barcode' => 'BarCode' ));
}
2021-03-01 20:37:16 +01:00
$keyforselect = 'product' ;
$keyforelement = 'product' ;
$keyforaliasextra = 'extra' ;
2019-03-03 13:02:20 +01:00
include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php' ;
2021-04-12 06:27:46 +02:00
if (( ! empty ( $conf -> fournisseur -> enabled ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD )) || ! empty ( $conf -> supplier_order -> enabled ) || ! empty ( $conf -> supplier_invoice -> enabled )) {
2021-02-23 22:03:23 +01:00
$this -> export_fields_array [ $r ] = array_merge ( $this -> export_fields_array [ $r ], array ( 's.nom' => 'Supplier' , 'pf.ref_fourn' => 'SupplierRef' , 'pf.quantity' => 'QtyMin' , 'pf.remise_percent' => 'DiscountQtyMin' , 'pf.unitprice' => 'BuyingPrice' , 'pf.delivery_time_days' => 'NbDaysToDelivery' ));
}
if ( ! empty ( $conf -> global -> EXPORTTOOL_CATEGORIES )) {
$this -> export_fields_array [ $r ] = array_merge ( $this -> export_fields_array [ $r ], array ( 'group_concat(cat.label)' => 'Categories' ));
}
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS )) {
$this -> export_fields_array [ $r ] = array_merge ( $this -> export_fields_array [ $r ], array ( 'l.lang' => 'Language' , 'l.label' => 'TranslatedLabel' , 'l.description' => 'TranslatedDescription' , 'l.note' => 'TranslatedNote' ));
}
if ( ! empty ( $conf -> global -> PRODUCT_USE_UNITS )) {
$this -> export_fields_array [ $r ][ 'p.fk_unit' ] = 'Unit' ;
}
2020-03-12 12:45:44 +01:00
$this -> export_TypeFields_array [ $r ] = array (
'p.ref' => " Text " , 'p.label' => " Text " ,
'p.fk_product_type' => 'Numeric' , 'p.tosell' => " Boolean " , 'p.tobuy' => " Boolean " ,
2021-03-18 17:08:55 +01:00
'p.description' => " Text " , 'p.url' => " Text " ,
2021-03-30 03:27:46 +02:00
$alias_product_perentity . '.accountancy_code_sell' => " Text " , $alias_product_perentity . '.accountancy_code_sell_intra' => " Text " , $alias_product_perentity . '.accountancy_code_sell_export' => " Text " ,
$alias_product_perentity . '.accountancy_code_buy' => " Text " , $alias_product_perentity . '.accountancy_code_buy_intra' => " Text " , $alias_product_perentity . '.accountancy_code_buy_export' => " Text " ,
2020-03-12 12:45:44 +01:00
'p.note' => " Text " , 'p.note_public' => " Text " ,
'p.weight' => " Numeric " , 'p.length' => " Numeric " , 'p.width' => " Numeric " , 'p.height' => " Numeric " , 'p.surface' => " Numeric " , 'p.volume' => " Numeric " ,
2019-10-09 02:05:20 +02:00
'p.customcode' => 'Text' ,
'p.duration' => " Text " ,
'p.finished' => 'Numeric' ,
2020-03-12 12:45:44 +01:00
'p.price_base_type' => " Text " , 'p.price' => " Numeric " , 'p.price_ttc' => " Numeric " , 'p.tva_tx' => 'Numeric' ,
'p.datec' => 'Date' , 'p.tms' => 'Date'
2019-10-04 10:04:02 +02:00
);
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> stock -> enabled )) {
$this -> export_TypeFields_array [ $r ] = array_merge ( $this -> export_TypeFields_array [ $r ], array ( 'p.stock' => 'Numeric' , 'p.seuil_stock_alerte' => 'Numeric' , 'p.desiredstock' => 'Numeric' , 'p.pmp' => 'Numeric' , 'p.cost_price' => 'Numeric' ));
}
2022-08-19 18:07:21 +02:00
if ( isModEnabled ( 'barcode' )) {
2021-02-23 22:03:23 +01:00
$this -> export_TypeFields_array [ $r ] = array_merge ( $this -> export_TypeFields_array [ $r ], array ( 'p.barcode' => 'Text' ));
}
2021-04-12 06:27:46 +02:00
if (( ! empty ( $conf -> fournisseur -> enabled ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD )) || ! empty ( $conf -> supplier_order -> enabled ) || ! empty ( $conf -> supplier_invoice -> enabled )) {
2021-02-23 22:03:23 +01:00
$this -> export_TypeFields_array [ $r ] = array_merge ( $this -> export_TypeFields_array [ $r ], array ( 's.nom' => 'Text' , 'pf.ref_fourn' => 'Text' , 'pf.unitprice' => 'Numeric' , 'pf.quantity' => 'Numeric' , 'pf.remise_percent' => 'Numeric' , 'pf.delivery_time_days' => 'Numeric' ));
}
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS )) {
$this -> export_TypeFields_array [ $r ] = array_merge ( $this -> export_TypeFields_array [ $r ], array ( 'l.lang' => 'Text' , 'l.label' => 'Text' , 'l.description' => 'Text' , 'l.note' => 'Text' ));
}
if ( ! empty ( $conf -> global -> EXPORTTOOL_CATEGORIES )) {
$this -> export_TypeFields_array [ $r ] = array_merge ( $this -> export_TypeFields_array [ $r ], array ( " group_concat(cat.label) " => 'Text' ));
}
2020-03-12 12:45:44 +01:00
$this -> export_entities_array [ $r ] = array (); // We define here only fields that use another icon that the one defined into import_icon
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> global -> EXPORTTOOL_CATEGORIES )) {
$this -> export_entities_array [ $r ] = array_merge ( $this -> export_entities_array [ $r ], array ( " group_concat(cat.label) " => 'category' ));
}
if ( ! empty ( $conf -> stock -> enabled )) {
$this -> export_entities_array [ $r ] = array_merge ( $this -> export_entities_array [ $r ], array ( 'p.stock' => 'product' , 'p.pmp' => 'product' ));
}
2022-08-19 18:07:21 +02:00
if ( isModEnabled ( 'barcode' )) {
2021-02-23 22:03:23 +01:00
$this -> export_entities_array [ $r ] = array_merge ( $this -> export_entities_array [ $r ], array ( 'p.barcode' => 'product' ));
}
2021-04-12 06:27:46 +02:00
if (( ! empty ( $conf -> fournisseur -> enabled ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD )) || ! empty ( $conf -> supplier_order -> enabled ) || ! empty ( $conf -> supplier_invoice -> enabled )) {
2021-02-23 22:03:23 +01:00
$this -> export_entities_array [ $r ] = array_merge ( $this -> export_entities_array [ $r ], array ( 's.nom' => 'product_supplier_ref' , 'pf.ref_fourn' => 'product_supplier_ref' , 'pf.unitprice' => 'product_supplier_ref' , 'pf.quantity' => 'product_supplier_ref' , 'pf.remise_percent' => 'product_supplier_ref' , 'pf.delivery_time_days' => 'product_supplier_ref' ));
}
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS )) {
$this -> export_entities_array [ $r ] = array_merge ( $this -> export_entities_array [ $r ], array ( 'l.lang' => 'translation' , 'l.label' => 'translation' , 'l.description' => 'translation' , 'l.note' => 'translation' ));
}
if ( ! empty ( $conf -> global -> EXPORTTOOL_CATEGORIES )) {
$this -> export_dependencies_array [ $r ] = array ( 'category' => 'p.rowid' );
}
if ( ! empty ( $conf -> stock -> enabled )) {
$this -> export_entities_array [ $r ] = array_merge ( $this -> export_entities_array [ $r ], array ( 'p.stock' => 'product' , 'p.pmp' => 'product' ));
}
2022-08-19 18:07:21 +02:00
if ( isModEnabled ( 'barcode' )) {
2021-02-23 22:03:23 +01:00
$this -> export_entities_array [ $r ] = array_merge ( $this -> export_entities_array [ $r ], array ( 'p.barcode' => 'product' ));
}
2021-04-12 06:27:46 +02:00
if (( ! empty ( $conf -> fournisseur -> enabled ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD )) || ! empty ( $conf -> supplier_order -> enabled ) || ! empty ( $conf -> supplier_invoice -> enabled )) {
2021-02-23 22:03:23 +01:00
$this -> export_entities_array [ $r ] = array_merge ( $this -> export_entities_array [ $r ], array ( 's.nom' => 'product_supplier_ref' , 'pf.ref_fourn' => 'product_supplier_ref' , 'pf.unitprice' => 'product_supplier_ref' , 'pf.quantity' => 'product_supplier_ref' , 'pf.remise_percent' => 'product_supplier_ref' , 'pf.delivery_time_days' => 'product_supplier_ref' ));
}
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS )) {
$this -> export_entities_array [ $r ] = array_merge ( $this -> export_entities_array [ $r ], array ( 'l.lang' => 'translation' , 'l.label' => 'translation' , 'l.description' => 'translation' , 'l.note' => 'translation' ));
}
if ( ! empty ( $conf -> global -> EXPORTTOOL_CATEGORIES )) {
$this -> export_dependencies_array [ $r ] = array ( 'category' => 'p.rowid' );
}
2020-03-12 12:45:44 +01:00
$this -> export_sql_start [ $r ] = 'SELECT DISTINCT ' ;
$this -> export_sql_end [ $r ] = ' FROM ' . MAIN_DB_PREFIX . 'product as p' ;
2021-03-27 05:23:20 +01:00
if ( ! empty ( $conf -> global -> MAIN_PRODUCT_PERENTITY_SHARED )) {
2021-04-14 04:45:17 +02:00
$this -> export_sql_end [ $r ] .= " LEFT JOIN " . MAIN_DB_PREFIX . " product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . (( int ) $conf -> entity );
2021-03-18 17:08:55 +01:00
}
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> global -> EXPORTTOOL_CATEGORIES )) {
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN ' . MAIN_DB_PREFIX . 'categorie as cat ON cp.fk_categorie = cat.rowid' ;
}
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS )) {
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_lang as l ON l.fk_product = p.rowid' ;
}
2020-03-12 12:45:44 +01:00
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_extrafields as extra ON p.rowid = extra.fk_object' ;
2021-04-12 06:27:46 +02:00
if (( ! empty ( $conf -> fournisseur -> enabled ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD )) || ! empty ( $conf -> supplier_order -> enabled ) || ! empty ( $conf -> supplier_invoice -> enabled )) {
2021-02-23 22:03:23 +01:00
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN ' . MAIN_DB_PREFIX . 'societe s ON s.rowid = pf.fk_soc' ;
}
2020-10-31 14:32:18 +01:00
$this -> export_sql_end [ $r ] .= ' WHERE p.fk_product_type = 1 AND p.entity IN (' . getEntity ( 'product' ) . ')' ;
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> global -> EXPORTTOOL_CATEGORIES )) {
$this -> export_sql_order [ $r ] = ' GROUP BY p.rowid' ; // FIXME The group by used a generic value to say "all fields in select except function fields"
}
2012-03-03 16:33:38 +01:00
2021-02-23 22:03:23 +01:00
if ( empty ( $conf -> product -> enabled )) { // We enable next import templates only if module product not already enabled (to avoid duplicate entries)
if ( ! empty ( $conf -> global -> PRODUIT_MULTIPRICES )) {
2014-05-11 17:52:16 +02:00
// Exports product multiprice
$r ++ ;
2020-03-12 12:45:44 +01:00
$this -> export_code [ $r ] = $this -> rights_class . '_' . $r ;
$this -> export_label [ $r ] = " ProductsMultiPrice " ; // Translation key (used only if key ExportDataset_xxx_z not found)
2021-03-29 10:26:17 +02:00
$this -> export_permission [ $r ] = array ( array ( " service " , " export " ));
2020-03-12 12:45:44 +01:00
$this -> export_fields_array [ $r ] = array ( 'p.rowid' => " Id " , 'p.ref' => " Ref " ,
'pr.price_base_type' => " PriceBase " , 'pr.price_level' => " PriceLevel " ,
'pr.price' => " PriceLevelUnitPriceHT " , 'pr.price_ttc' => " PriceLevelUnitPriceTTC " ,
'pr.price_min' => " MinPriceLevelUnitPriceHT " , 'pr.price_min_ttc' => " MinPriceLevelUnitPriceTTC " ,
2014-05-11 17:52:16 +02:00
'pr.tva_tx' => 'PriceLevelVATRate' ,
'pr.date_price' => 'DateCreation' );
2021-02-23 22:03:23 +01:00
if ( is_object ( $mysoc ) && $usenpr ) {
$this -> export_fields_array [ $r ][ 'pr.recuperableonly' ] = 'NPR' ;
}
2018-05-27 15:04:12 +02:00
//$this->export_TypeFields_array[$r]=array(
// 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",
// 'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text',
// 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",
// 'p.datec'=>'Date','p.tms'=>'Date'
//);
2020-03-12 12:45:44 +01:00
$this -> export_entities_array [ $r ] = array ( 'p.rowid' => " product " , 'p.ref' => " product " ,
'pr.price_base_type' => " product " , 'pr.price_level' => " product " , 'pr.price' => " product " ,
2014-05-11 17:52:16 +02:00
'pr.price_ttc' => " product " ,
2020-03-12 12:45:44 +01:00
'pr.price_min' => " product " , 'pr.price_min_ttc' => " product " ,
2014-05-11 17:52:16 +02:00
'pr.tva_tx' => 'product' ,
2020-10-31 14:32:18 +01:00
'pr.recuperableonly' => 'product' ,
'pr.date_price' => " product " );
2020-03-12 12:45:44 +01:00
$this -> export_sql_start [ $r ] = 'SELECT DISTINCT ' ;
$this -> export_sql_end [ $r ] = ' FROM ' . MAIN_DB_PREFIX . 'product as p' ;
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_price as pr ON p.rowid = pr.fk_product AND pr.entity = ' . $conf -> entity ; // export prices only for the current entity
$this -> export_sql_end [ $r ] .= ' WHERE p.entity IN (' . getEntity ( 'product' ) . ')' ; // For product and service profile
2019-04-29 21:23:01 +02:00
}
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> global -> PRODUIT_CUSTOMER_PRICES )) {
2020-10-31 14:32:18 +01:00
// Exports product multiprice
$r ++ ;
$this -> export_code [ $r ] = $this -> rights_class . '_' . $r ;
$this -> export_label [ $r ] = " ProductsPricePerCustomer " ; // Translation key (used only if key ExportDataset_xxx_z not found)
2021-03-29 10:26:17 +02:00
$this -> export_permission [ $r ] = array ( array ( " service " , " export " ));
2020-10-31 14:32:18 +01:00
$this -> export_fields_array [ $r ] = array ( 'p.rowid' => " Id " , 'p.ref' => " Ref " ,
's.nom' => 'ThirdParty' ,
'pr.price_base_type' => " PriceBase " ,
'pr.price' => " PriceUnitPriceHT " , 'pr.price_ttc' => " PriceUnitPriceTTC " ,
'pr.price_min' => " MinPriceUnitPriceHT " , 'pr.price_min_ttc' => " MinPriceUnitPriceTTC " ,
'pr.tva_tx' => 'PriceVATRate' ,
'pr.default_vat_code' => 'PriceVATCode' ,
'pr.datec' => 'DateCreation' );
2021-02-23 22:03:23 +01:00
if ( is_object ( $mysoc ) && $usenpr ) {
$this -> export_fields_array [ $r ][ 'pr.recuperableonly' ] = 'NPR' ;
}
2020-10-31 14:32:18 +01:00
$this -> export_entities_array [ $r ] = array ( 'p.rowid' => " product " , 'p.ref' => " product " ,
's.nom' => 'company' ,
'pr.price_base_type' => " product " , 'pr.price' => " product " ,
'pr.price_ttc' => " product " ,
'pr.price_min' => " product " , 'pr.price_min_ttc' => " product " ,
'pr.tva_tx' => 'product' ,
'pr.default_vat_code' => 'product' ,
'pr.recuperableonly' => 'product' ,
'pr.datec' => " product " );
$this -> export_sql_start [ $r ] = 'SELECT DISTINCT ' ;
$this -> export_sql_end [ $r ] = ' FROM ' . MAIN_DB_PREFIX . 'product as p' ;
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = ' . $conf -> entity ; // export prices only for the current entity
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as s ON pr.fk_soc = s.rowid' ;
$this -> export_sql_end [ $r ] .= ' WHERE p.entity IN (' . getEntity ( 'product' ) . ')' ; // For product and service profile
2014-05-11 17:52:16 +02:00
}
2019-04-29 21:23:01 +02:00
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> global -> PRODUIT_SOUSPRODUITS )) {
2020-10-31 14:32:18 +01:00
// Exports virtual products
$r ++ ;
$this -> export_code [ $r ] = $this -> rights_class . '_' . $r ;
$this -> export_label [ $r ] = " AssociatedProducts " ; // Translation key (used only if key ExportDataset_xxx_z not found)
2021-03-29 10:26:17 +02:00
$this -> export_permission [ $r ] = array ( array ( " service " , " export " ));
2020-10-31 14:32:18 +01:00
$this -> export_fields_array [ $r ] = array (
'p.rowid' => " Id " , 'p.ref' => " Ref " , 'p.label' => " Label " , 'p.description' => " Description " , 'p.url' => " PublicUrl " ,
2021-03-30 03:27:46 +02:00
$alias_product_perentity . '.accountancy_code_sell' => " ProductAccountancySellCode " , $alias_product_perentity . '.accountancy_code_sell_intra' => " ProductAccountancySellIntraCode " ,
$alias_product_perentity . '.accountancy_code_sell_export' => " ProductAccountancySellExportCode " , $alias_product_perentity . '.accountancy_code_buy' => " ProductAccountancyBuyCode " ,
$alias_product_perentity . '.accountancy_code_buy_intra' => " ProductAccountancyBuyIntraCode " , $alias_product_perentity . '.accountancy_code_buy_export' => " ProductAccountancyBuyExportCode " ,
2020-10-31 14:32:18 +01:00
'p.note' => " NotePrivate " , 'p.note_public' => 'NotePublic' ,
'p.weight' => " Weight " , 'p.length' => " Length " , 'p.surface' => " Surface " , 'p.volume' => " Volume " , 'p.customcode' => 'CustomCode' ,
'p.price_base_type' => " PriceBase " , 'p.price' => " UnitPriceHT " , 'p.price_ttc' => " UnitPriceTTC " , 'p.tva_tx' => 'VATRate' , 'p.tosell' => " OnSell " ,
'p.tobuy' => " OnBuy " , 'p.datec' => 'DateCreation' , 'p.tms' => 'DateModification'
);
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> stock -> enabled )) {
$this -> export_fields_array [ $r ] = array_merge ( $this -> export_fields_array [ $r ], array ( 'p.stock' => 'Stock' , 'p.seuil_stock_alerte' => 'StockLimit' , 'p.desiredstock' => 'DesiredStock' , 'p.pmp' => 'PMPValue' ));
}
2022-08-19 18:07:21 +02:00
if ( isModEnabled ( 'barcode' )) {
2021-02-23 22:03:23 +01:00
$this -> export_fields_array [ $r ] = array_merge ( $this -> export_fields_array [ $r ], array ( 'p.barcode' => 'BarCode' ));
}
2020-10-31 14:32:18 +01:00
$this -> export_fields_array [ $r ] = array_merge ( $this -> export_fields_array [ $r ], array ( 'pa.qty' => 'Qty' , 'pa.incdec' => 'ComposedProductIncDecStock' ));
$this -> export_TypeFields_array [ $r ] = array (
'p.ref' => " Text " , 'p.label' => " Text " , 'p.description' => " Text " , 'p.url' => " Text " ,
2021-03-30 03:27:46 +02:00
$alias_product_perentity . 'p.accountancy_code_sell' => " Text " , $alias_product_perentity . '.accountancy_code_sell_intra' => " Text " , $alias_product_perentity . '.accountancy_code_sell_export' => " Text " ,
$alias_product_perentity . 'p.accountancy_code_buy' => " Text " , $alias_product_perentity . '.accountancy_code_buy_intra' => " Text " , $alias_product_perentity . '.accountancy_code_buy_export' => " Text " ,
2020-10-31 14:32:18 +01:00
'p.note' => " Text " , 'p.note_public' => " Text " ,
'p.weight' => " Numeric " , 'p.length' => " Numeric " , 'p.surface' => " Numeric " , 'p.volume' => " Numeric " , 'p.customcode' => 'Text' ,
'p.price_base_type' => " Text " , 'p.price' => " Numeric " , 'p.price_ttc' => " Numeric " , 'p.tva_tx' => 'Numeric' , 'p.tosell' => " Boolean " , 'p.tobuy' => " Boolean " ,
'p.datec' => 'Date' , 'p.tms' => 'Date'
);
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> stock -> enabled )) {
$this -> export_TypeFields_array [ $r ] = array_merge ( $this -> export_TypeFields_array [ $r ], array ( 'p.stock' => 'Numeric' , 'p.seuil_stock_alerte' => 'Numeric' , 'p.desiredstock' => 'Numeric' , 'p.pmp' => 'Numeric' , 'p.cost_price' => 'Numeric' ));
}
2022-08-19 18:07:21 +02:00
if ( isModEnabled ( 'barcode' )) {
2021-02-23 22:03:23 +01:00
$this -> export_TypeFields_array [ $r ] = array_merge ( $this -> export_TypeFields_array [ $r ], array ( 'p.barcode' => 'Text' ));
}
2020-10-31 14:32:18 +01:00
$this -> export_TypeFields_array [ $r ] = array_merge ( $this -> export_TypeFields_array [ $r ], array ( 'pa.qty' => 'Numeric' ));
$this -> export_entities_array [ $r ] = array (
'p.rowid' => " virtualproduct " , 'p.ref' => " virtualproduct " , 'p.label' => " virtualproduct " , 'p.description' => " virtualproduct " , 'p.url' => " virtualproduct " ,
2021-03-30 03:27:46 +02:00
$alias_product_perentity . '.accountancy_code_sell' => 'virtualproduct' , $alias_product_perentity . '.accountancy_code_sell_intra' => 'virtualproduct' , $alias_product_perentity . '.accountancy_code_sell_export' => 'virtualproduct' ,
$alias_product_perentity . '.accountancy_code_buy' => 'virtualproduct' , $alias_product_perentity . '.accountancy_code_buy_intra' => 'virtualproduct' , $alias_product_perentity . '.accountancy_code_buy_export' => 'virtualproduct' ,
2020-03-12 12:45:44 +01:00
'p.note' => " virtualproduct " , 'p.length' => " virtualproduct " ,
2020-10-31 14:32:18 +01:00
'p.surface' => " virtualproduct " , 'p.volume' => " virtualproduct " , 'p.weight' => " virtualproduct " , 'p.customcode' => 'virtualproduct' ,
'p.price_base_type' => " virtualproduct " , 'p.price' => " virtualproduct " , 'p.price_ttc' => " virtualproduct " , 'p.tva_tx' => " virtualproduct " ,
'p.tosell' => " virtualproduct " , 'p.tobuy' => " virtualproduct " , 'p.datec' => " virtualproduct " , 'p.tms' => " virtualproduct "
);
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> stock -> enabled )) {
$this -> export_entities_array [ $r ] = array_merge ( $this -> export_entities_array [ $r ], array ( 'p.stock' => 'virtualproduct' , 'p.seuil_stock_alerte' => 'virtualproduct' , 'p.desiredstock' => 'virtualproduct' , 'p.pmp' => 'virtualproduct' ));
}
2022-08-19 18:07:21 +02:00
if ( isModEnabled ( 'barcode' )) {
2021-02-23 22:03:23 +01:00
$this -> export_entities_array [ $r ] = array_merge ( $this -> export_entities_array [ $r ], array ( 'p.barcode' => 'virtualproduct' ));
}
2020-10-31 14:32:18 +01:00
$this -> export_entities_array [ $r ] = array_merge ( $this -> export_entities_array [ $r ], array ( 'pa.qty' => " subproduct " , 'pa.incdec' => 'subproduct' ));
2021-03-01 20:37:16 +01:00
$keyforselect = 'product' ;
$keyforelement = 'product' ;
$keyforaliasextra = 'extra' ;
2020-10-31 14:32:18 +01:00
include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php' ;
$this -> export_fields_array [ $r ] = array_merge ( $this -> export_fields_array [ $r ], array ( 'p2.rowid' => " Id " , 'p2.ref' => " Ref " , 'p2.label' => " Label " , 'p2.description' => " Description " ));
$this -> export_entities_array [ $r ] = array_merge ( $this -> export_entities_array [ $r ], array ( 'p2.rowid' => " subproduct " , 'p2.ref' => " subproduct " , 'p2.label' => " subproduct " , 'p2.description' => " subproduct " ));
$this -> export_sql_start [ $r ] = 'SELECT DISTINCT ' ;
$this -> export_sql_end [ $r ] = ' FROM ' . MAIN_DB_PREFIX . 'product as p' ;
2021-03-30 17:28:58 +02:00
if ( ! empty ( $conf -> global -> MAIN_PRODUCT_PERENTITY_SHARED )) {
2021-03-30 22:12:57 +02:00
$this -> export_sql_end [ $r ] .= " LEFT JOIN " . MAIN_DB_PREFIX . " product_perentity as pac ON pac.fk_product = p.rowid AND pac.entity = " . (( int ) $conf -> entity );
2021-03-18 17:08:55 +01:00
}
2020-10-31 14:32:18 +01:00
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_extrafields as extra ON p.rowid = extra.fk_object,' ;
$this -> export_sql_end [ $r ] .= ' ' . MAIN_DB_PREFIX . 'product_association as pa, ' . MAIN_DB_PREFIX . 'product as p2' ;
$this -> export_sql_end [ $r ] .= ' WHERE p.entity IN (' . getEntity ( 'product' ) . ')' ; // For product and service profile
$this -> export_sql_end [ $r ] .= ' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils' ;
2019-03-03 13:02:20 +01:00
}
2014-05-11 17:52:16 +02:00
}
2012-03-03 16:33:38 +01:00
// Imports
//--------
2020-03-12 12:45:44 +01:00
$r = 0 ;
2012-03-03 16:33:38 +01:00
2019-03-03 13:02:20 +01:00
// Import list of services
2019-04-30 03:30:40 +02:00
2012-03-03 16:33:38 +01:00
$r ++ ;
2020-03-12 12:45:44 +01:00
$this -> import_code [ $r ] = $this -> rights_class . '_' . $r ;
$this -> import_label [ $r ] = " Products " ; // Translation key
$this -> import_icon [ $r ] = $this -> picto ;
$this -> import_entities_array [ $r ] = array (); // We define here only fields that use a different icon from the one defined in import_icon
$this -> import_tables_array [ $r ] = array ( 'p' => MAIN_DB_PREFIX . 'product' , 'extra' => MAIN_DB_PREFIX . 'product_extrafields' );
$this -> import_tables_creator_array [ $r ] = array ( 'p' => 'fk_user_author' ); // Fields to store import user id
2020-10-31 14:32:18 +01:00
$this -> import_fields_array [ $r ] = array (
'p.ref' => " Ref* " ,
'p.label' => " Label* " ,
'p.fk_product_type' => " Type* " ,
'p.tosell' => " OnSell* " ,
'p.tobuy' => " OnBuy* " ,
'p.description' => " Description " ,
'p.url' => " PublicUrl " ,
'p.customcode' => 'CustomCode' ,
'p.fk_country' => 'CountryCode' ,
'p.accountancy_code_sell' => " ProductAccountancySellCode " ,
'p.accountancy_code_sell_intra' => " ProductAccountancySellIntraCode " ,
'p.accountancy_code_sell_export' => " ProductAccountancySellExportCode " ,
'p.accountancy_code_buy' => " ProductAccountancyBuyCode " ,
'p.accountancy_code_buy_intra' => " ProductAccountancyBuyIntraCode " ,
'p.accountancy_code_buy_export' => " ProductAccountancyBuyExportCode " ,
'p.note_public' => " NotePublic " ,
'p.note' => " NotePrivate " ,
'p.weight' => " Weight " ,
'p.weight_units' => " WeightUnits " ,
'p.length' => " Length " ,
2021-03-30 17:28:58 +02:00
'p.length_units' => " LengthUnits " ,
2020-10-31 14:32:18 +01:00
'p.width' => " Width " ,
'p.width_units' => " WidthUnits " ,
'p.height' => " Height " ,
2021-03-30 17:28:58 +02:00
'p.height_units' => " HeightUnits " ,
2020-10-31 14:32:18 +01:00
'p.surface' => " Surface " ,
2021-03-30 17:28:58 +02:00
'p.surface_units' => " SurfaceUnits " ,
2020-10-31 14:32:18 +01:00
'p.volume' => " Volume " ,
'p.volume_units' => " VolumeUnits " ,
'p.duration' => " Duration " , //duration of service
'p.finished' => 'Nature' ,
'p.price' => " SellingPriceHT " , //without
'p.price_min' => " MinPrice " ,
'p.price_ttc' => " SellingPriceTTC " , //with tax
'p.price_min_ttc' => " SellingMinPriceTTC " ,
'p.price_base_type' => " PriceBaseType " , //price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card
'p.tva_tx' => 'VATRate' ,
'p.datec' => 'DateCreation' ,
'p.cost_price' => " CostPrice " ,
);
$this -> import_convertvalue_array [ $r ] = array (
'p.weight_units' => array (
'rule' => 'fetchscalefromcodeunits' , // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table
'classfile' => '/core/class/cunits.class.php' ,
'class' => 'CUnits' ,
'method' => 'fetch' ,
'units' => 'weight' ,
'dict' => 'DictionaryMeasuringUnits'
),
'p.length_units' => array (
'rule' => 'fetchscalefromcodeunits' , // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table
'classfile' => '/core/class/cunits.class.php' ,
'class' => 'CUnits' ,
'method' => 'fetch' ,
'units' => 'size' ,
'dict' => 'DictionaryMeasuringUnits'
),
'p.width_units' => array (
'rule' => 'fetchscalefromcodeunits' , // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table
'classfile' => '/core/class/cunits.class.php' ,
'class' => 'CUnits' ,
'method' => 'fetch' ,
'units' => 'size' ,
'dict' => 'DictionaryMeasuringUnits'
),
'p.height_units' => array (
'rule' => 'fetchscalefromcodeunits' , // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table
'classfile' => '/core/class/cunits.class.php' ,
'class' => 'CUnits' ,
'method' => 'fetch' ,
'units' => 'size' ,
'dict' => 'DictionaryMeasuringUnits'
),
'p.surface_units' => array (
'rule' => 'fetchscalefromcodeunits' , // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table
'classfile' => '/core/class/cunits.class.php' ,
'class' => 'CUnits' ,
'method' => 'fetch' ,
'units' => 'surface' ,
'dict' => 'DictionaryMeasuringUnits'
),
'p.volume_units' => array (
'rule' => 'fetchscalefromcodeunits' , // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table
'classfile' => '/core/class/cunits.class.php' ,
'class' => 'CUnits' ,
'method' => 'fetch' ,
'units' => 'volume' ,
'dict' => 'DictionaryMeasuringUnits'
),
'p.fk_country' => array (
'rule' => 'fetchidfromcodeid' ,
'classfile' => '/core/class/ccountry.class.php' ,
'class' => 'Ccountry' ,
'method' => 'fetch' ,
'dict' => 'DictionaryCountry'
)
2018-05-27 15:04:12 +02:00
);
2021-03-30 17:28:58 +02:00
$this -> import_regex_array [ $r ] = array (
'p.ref' => '[^ ]' ,
'p.price_base_type' => '\AHT\z|\ATTC\z' ,
'p.tosell' => '^[0|1]$' ,
'p.tobuy' => '^[0|1]$' ,
'p.fk_product_type' => '^[0|1]$' ,
'p.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$' ,
'p.recuperableonly' => '^[0|1]$' ,
);
if ( ! empty ( $conf -> stock -> enabled )) { //if Stock module enabled
$this -> import_fields_array [ $r ] = array_merge ( $this -> import_fields_array [ $r ], array (
'p.fk_default_warehouse' => 'DefaultWarehouse' ,
'p.tobatch' => 'ManageLotSerial' ,
'p.seuil_stock_alerte' => 'StockLimit' , //lower limit for warning
'p.pmp' => 'PMPValue' , //weighted average price
'p.desiredstock' => 'DesiredStock' //desired stock for replenishment feature
));
$this -> import_regex_array [ $r ] = array_merge ( $this -> import_regex_array [ $r ], array (
'p.tobatch' => '^[0|1|2]$'
));
$this -> import_convertvalue_array [ $r ] = array_merge ( $this -> import_convertvalue_array [ $r ], array (
'p.fk_default_warehouse' => array (
'rule' => 'fetchidfromref' ,
'classfile' => '/product/stock/class/entrepot.class.php' ,
'class' => 'Entrepot' ,
'method' => 'fetch' ,
'element' => 'Warehouse'
)
));
}
2021-04-12 06:27:46 +02:00
if (( ! empty ( $conf -> fournisseur -> enabled ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD )) || ! empty ( $conf -> supplier_order -> enabled ) || ! empty ( $conf -> supplier_invoice -> enabled ) || ! empty ( $conf -> margin -> enabled )) {
2021-02-23 22:03:23 +01:00
$this -> import_fields_array [ $r ] = array_merge ( $this -> import_fields_array [ $r ], array ( 'p.cost_price' => 'CostPrice' ));
}
if ( is_object ( $mysoc ) && $usenpr ) {
$this -> import_fields_array [ $r ] = array_merge ( $this -> import_fields_array [ $r ], array ( 'p.recuperableonly' => 'NPR' ));
}
if ( is_object ( $mysoc ) && $mysoc -> useLocalTax ( 1 )) {
$this -> import_fields_array [ $r ] = array_merge ( $this -> import_fields_array [ $r ], array ( 'p.localtax1_tx' => 'LT1' , 'p.localtax1_type' => 'LT1Type' ));
}
if ( is_object ( $mysoc ) && $mysoc -> useLocalTax ( 2 )) {
$this -> import_fields_array [ $r ] = array_merge ( $this -> import_fields_array [ $r ], array ( 'p.localtax2_tx' => 'LT2' , 'p.localtax2_type' => 'LT2Type' ));
}
2022-08-19 18:07:21 +02:00
if ( isModEnabled ( 'barcode' )) {
2021-02-23 22:03:23 +01:00
$this -> import_fields_array [ $r ] = array_merge ( $this -> import_fields_array [ $r ], array ( 'p.barcode' => 'BarCode' ));
}
if ( ! empty ( $conf -> global -> PRODUCT_USE_UNITS )) {
$this -> import_fields_array [ $r ][ 'p.fk_unit' ] = 'Unit' ;
}
2020-10-31 14:32:18 +01:00
// Add extra fields
2019-11-13 19:35:39 +01:00
$import_extrafield_sample = array ();
2021-10-31 14:33:44 +01:00
$sql = " SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . " extrafields WHERE type <> 'separate' AND elementtype = 'product' AND entity IN (0, " . $conf -> entity . " ) " ;
2019-11-13 19:35:39 +01:00
$resql = $this -> db -> query ( $sql );
2021-02-23 22:03:23 +01:00
if ( $resql ) { // This can fail when class is used on old database (during migration for example)
while ( $obj = $this -> db -> fetch_object ( $resql )) {
2020-10-31 14:32:18 +01:00
$fieldname = 'extra.' . $obj -> name ;
$fieldlabel = ucfirst ( $obj -> label );
$this -> import_fields_array [ $r ][ $fieldname ] = $fieldlabel . ( $obj -> fieldrequired ? '*' : '' );
$import_extrafield_sample [ $fieldname ] = $fieldlabel ;
}
2012-03-03 16:33:38 +01:00
}
// End add extra fields
2019-11-13 19:35:39 +01:00
$this -> import_fieldshidden_array [ $r ] = array ( 'extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'product' ); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this -> import_regex_array [ $r ] = array (
2020-10-31 14:32:18 +01:00
'p.ref' => '[^ ]' ,
2021-03-30 17:28:58 +02:00
'p.price_base_type' => 'HT|TTC' ,
2019-10-04 10:04:02 +02:00
'p.tosell' => '^[0|1]$' ,
2020-10-31 14:32:18 +01:00
'p.tobuy' => '^[0|1]$' ,
'p.fk_product_type' => '^[0|1]$' ,
'p.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$' ,
2019-10-04 10:04:02 +02:00
'p.recuperableonly' => '^[0|1]$' ,
'p.finished' => '^[0|1]$'
);
// field order as per structure of table llx_product
$import_sample = array (
2021-03-30 17:28:58 +02:00
'p.ref' => " ref:PREF123456 " ,
2019-10-04 10:04:02 +02:00
'p.datec' => dol_print_date ( dol_now (), '%Y-%m-%d' ),
'p.label' => " Product name in default language " ,
'p.description' => " Product description in default language " ,
'p.note_public' => " a public note (free text) " ,
'p.note' => " a private note (free text) " ,
'p.customcode' => 'customs code' ,
'p.fk_country' => 'FR' ,
2019-10-07 12:37:01 +02:00
'p.price' => " 100 " ,
'p.price_min' => " 100 " ,
'p.price_ttc' => " 110 " ,
'p.price_min_ttc' => " 110 " ,
2019-10-04 10:04:02 +02:00
'p.price_base_type' => " HT (show/use price excl. tax) / TTC (show/use price incl. tax) " ,
2019-11-13 19:35:39 +01:00
'p.tva_tx' => '10' , // tax rate eg: 10. Must match numerically one of the tax rates defined for your country'
2019-10-04 10:04:02 +02:00
'p.tosell' => " 0 (not for sale to customer, eg. raw material) / 1 (for sale) " ,
'p.tobuy' => " 0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase) " ,
'p.fk_product_type' => " 0 (product) / 1 (service) " ,
'p.duration' => " eg. 365d/12m/1y " ,
'p.url' => 'link to product (no https)' ,
'p.accountancy_code_sell' => " " ,
'p.accountancy_code_sell_intra' => " " ,
'p.accountancy_code_sell_export' => " " ,
'p.accountancy_code_buy' => " " ,
2020-03-01 04:52:12 +01:00
'p.accountancy_code_buy_intra' => " " ,
'p.accountancy_code_buy_export' => " " ,
2019-10-04 10:04:02 +02:00
'p.weight' => " " ,
2019-11-13 19:35:39 +01:00
'p.weight_units' => 'kg' , // Use a unit of measure from the dictionary. g/Kg/T etc....matches field "Short label" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_units',
2019-10-04 10:04:02 +02:00
'p.length' => " " ,
2019-11-13 19:35:39 +01:00
'p.length_units' => 'm' , // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units',
2019-10-04 10:04:02 +02:00
'p.width' => " " ,
2019-11-13 19:35:39 +01:00
'p.width_units' => 'm' , // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units',
2019-10-04 10:04:02 +02:00
'p.height' => " " ,
2019-11-13 19:35:39 +01:00
'p.height_units' => 'm' , // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units',
2019-10-04 10:04:02 +02:00
'p.surface' => " " ,
2019-11-13 19:35:39 +01:00
'p.surface_units' => 'm2' , // Use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units',
2019-10-04 10:04:02 +02:00
'p.volume' => " " ,
2019-11-13 19:35:39 +01:00
'p.volume_units' => 'm3' , //Use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units',
2021-03-30 17:28:58 +02:00
'p.finished' => '0 (raw material) / 1 (finished goods), matches field "code" in dictionary table "' . MAIN_DB_PREFIX . 'c_product_nature"'
2019-10-04 10:04:02 +02:00
);
//clauses copied from import_fields_array
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> stock -> enabled )) {
$import_sample = array_merge ( $import_sample , array (
2019-10-07 12:37:01 +02:00
'p.seuil_stock_alerte' => '' ,
'p.pmp' => '0' ,
'p.desiredstock' => ''
2021-02-23 22:03:23 +01:00
));
}
2021-04-12 06:27:46 +02:00
if (( ! empty ( $conf -> fournisseur -> enabled ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD )) || ! empty ( $conf -> supplier_order -> enabled ) || ! empty ( $conf -> supplier_invoice -> enabled ) || ! empty ( $conf -> margin -> enabled )) {
2021-02-23 22:03:23 +01:00
$import_sample = array_merge ( $import_sample , array ( 'p.cost_price' => '90' ));
}
if ( is_object ( $mysoc ) && $usenpr ) {
$import_sample = array_merge ( $import_sample , array ( 'p.recuperableonly' => '0' ));
}
if ( is_object ( $mysoc ) && $mysoc -> useLocalTax ( 1 )) {
$import_sample = array_merge ( $import_sample , array ( 'p.localtax1_tx' => '' , 'p.localtax1_type' => '' ));
}
if ( is_object ( $mysoc ) && $mysoc -> useLocalTax ( 2 )) {
$import_sample = array_merge ( $import_sample , array ( 'p.localtax2_tx' => '' , 'p.localtax2_type' => '' ));
}
2022-08-19 18:07:21 +02:00
if ( isModEnabled ( 'barcode' )) {
2021-02-23 22:03:23 +01:00
$import_sample = array_merge ( $import_sample , array ( 'p.barcode' => '' ));
}
2019-11-13 19:35:39 +01:00
if ( ! empty ( $conf -> global -> PRODUCT_USE_UNITS )) {
2019-10-04 10:04:02 +02:00
$import_sample = array_merge (
$import_sample ,
array (
2019-11-13 19:35:39 +01:00
'p.fk_unit' => 'use a unit of measure from the dictionary. G/KG/M2/M3 etc....matches field "code" in table "' . MAIN_DB_PREFIX . 'c_units"'
2019-10-04 10:04:02 +02:00
)
2021-02-23 22:03:23 +01:00
);
2019-10-04 10:04:02 +02:00
2021-02-23 22:03:23 +01:00
if ( ! is_array ( $this -> import_convertvalue_array [ $r ])) {
$this -> import_convertvalue_array [ $r ] = array ();
}
2019-10-04 10:04:02 +02:00
$this -> import_convertvalue_array [ $r ] = array_merge ( $this -> import_convertvalue_array [ $r ], array (
'p.fk_unit' => array (
'rule' => 'fetchidfromcodeorlabel' ,
'classfile' => '/core/class/cunits.class.php' ,
'class' => 'CUnits' ,
'method' => 'fetch' ,
'dict' => 'DictionaryUnits'
)
));
}
2019-11-13 19:35:39 +01:00
$this -> import_examplevalues_array [ $r ] = array_merge ( $import_sample , $import_extrafield_sample );
2019-03-03 13:02:20 +01:00
$this -> import_updatekeys_array [ $r ] = array ( 'p.ref' => 'Ref' );
2022-08-19 18:07:21 +02:00
if ( isModEnabled ( 'barcode' )) {
2021-02-23 22:03:23 +01:00
$this -> import_updatekeys_array [ $r ] = array_merge ( $this -> import_updatekeys_array [ $r ], array ( 'p.barcode' => 'BarCode' )); //only show/allow barcode as update key if Barcode module enabled
}
2014-05-11 17:52:16 +02:00
2021-02-23 22:03:23 +01:00
if ( empty ( $conf -> product -> enabled )) { // We enable next import templates only if module product not already enabled (to avoid duplicate entries)
2021-04-12 06:27:46 +02:00
if (( ! empty ( $conf -> fournisseur -> enabled ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD )) || ! empty ( $conf -> supplier_order -> enabled ) || ! empty ( $conf -> supplier_invoice -> enabled )) {
2020-10-31 14:32:18 +01:00
// Import suppliers prices (note: this code is duplicated in module Service)
2014-05-11 17:52:16 +02:00
$r ++ ;
2019-11-13 19:35:39 +01:00
$this -> import_code [ $r ] = $this -> rights_class . '_supplierprices' ;
$this -> import_label [ $r ] = " SuppliersPricesOfProductsOrServices " ; // Translation key
$this -> import_icon [ $r ] = $this -> picto ;
$this -> import_entities_array [ $r ] = array (); // We define here only fields that use another icon that the one defined into import_icon
$this -> import_tables_array [ $r ] = array ( 'sp' => MAIN_DB_PREFIX . 'product_fournisseur_price' );
$this -> import_tables_creator_array [ $r ] = array ( 'sp' => 'fk_user' );
$this -> import_fields_array [ $r ] = array ( //field order as per structure of table llx_product_fournisseur_price, without optional fields
2020-10-31 14:32:18 +01:00
'sp.fk_product' => " ProductOrService* " ,
'sp.fk_soc' => " Supplier* " ,
'sp.ref_fourn' => 'SupplierRef*' ,
'sp.quantity' => " QtyMin* " ,
'sp.tva_tx' => 'VATRate' ,
'sp.default_vat_code' => 'VATCode' ,
'sp.delivery_time_days' => 'DeliveryDelay' ,
'sp.supplier_reputation' => 'SupplierReputation'
2014-05-11 17:52:16 +02:00
);
2021-02-23 22:03:23 +01:00
if ( is_object ( $mysoc ) && $usenpr ) {
$this -> import_fields_array [ $r ] = array_merge ( $this -> import_fields_array [ $r ], array ( 'sp.recuperableonly' => 'VATNPR' ));
}
if ( is_object ( $mysoc ) && $mysoc -> useLocalTax ( 1 )) {
$this -> import_fields_array [ $r ] = array_merge ( $this -> import_fields_array [ $r ], array ( 'sp.localtax1_tx' => 'LT1' , 'sp.localtax1_type' => 'LT1Type' ));
}
if ( is_object ( $mysoc ) && $mysoc -> useLocalTax ( 2 )) {
$this -> import_fields_array [ $r ] = array_merge ( $this -> import_fields_array [ $r ], array ( 'sp.localtax2_tx' => 'LT2' , 'sp.localtax2_type' => 'LT2Type' ));
}
2019-11-13 19:35:39 +01:00
$this -> import_fields_array [ $r ] = array_merge ( $this -> import_fields_array [ $r ], array (
2018-02-06 10:03:06 +01:00
'sp.price' => " PriceQtyMinHT* " ,
2019-11-13 19:35:39 +01:00
'sp.unitprice' => 'UnitPriceHT*' , // TODO Make this field not required and calculate it from price and qty
2018-02-06 10:03:06 +01:00
'sp.remise_percent' => 'DiscountQtyMin'
));
2014-05-11 17:52:16 +02:00
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> multicurrency -> enabled )) {
2020-10-31 14:32:18 +01:00
$this -> import_fields_array [ $r ] = array_merge ( $this -> import_fields_array [ $r ], array (
2021-02-23 22:03:23 +01:00
'sp.fk_multicurrency' => 'CurrencyCodeId' , //ideally this should be automatically obtained from the CurrencyCode on the next line
'sp.multicurrency_code' => 'CurrencyCode' ,
'sp.multicurrency_tx' => 'CurrencyRate' ,
'sp.multicurrency_unitprice' => 'CurrencyUnitPrice' ,
'sp.multicurrency_price' => 'CurrencyPrice' ,
2020-10-31 14:32:18 +01:00
));
2019-03-03 13:02:20 +01:00
}
2019-04-30 03:30:40 +02:00
2021-02-23 22:03:23 +01:00
$this -> import_convertvalue_array [ $r ] = array (
2019-11-13 19:35:39 +01:00
'sp.fk_soc' => array ( 'rule' => 'fetchidfromref' , 'classfile' => '/societe/class/societe.class.php' , 'class' => 'Societe' , 'method' => 'fetch' , 'element' => 'ThirdParty' ),
'sp.fk_product' => array ( 'rule' => 'fetchidfromref' , 'classfile' => '/product/class/product.class.php' , 'class' => 'Product' , 'method' => 'fetch' , 'element' => 'Product' )
2021-02-23 22:03:23 +01:00
);
$this -> import_examplevalues_array [ $r ] = array (
2021-03-30 17:28:58 +02:00
'sp.fk_product' => " ref:PRODUCT_REF or id:123456 " ,
2019-10-04 10:04:02 +02:00
'sp.fk_soc' => " My Supplier " ,
2019-10-07 12:37:01 +02:00
'sp.ref_fourn' => " XYZ-F123456 " ,
2019-10-04 10:04:02 +02:00
'sp.quantity' => " 5 " ,
2019-10-07 12:37:01 +02:00
'sp.tva_tx' => '10' ,
2019-10-04 10:04:02 +02:00
'sp.price' => " 50 " ,
'sp.unitprice' => '50' ,
'sp.remise_percent' => '0' ,
'sp.default_vat_code' => '' ,
2019-10-07 12:37:01 +02:00
'sp.delivery_time_days' => '5' ,
2019-10-04 10:04:02 +02:00
'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER'
2021-02-23 22:03:23 +01:00
);
if ( is_object ( $mysoc ) && $usenpr ) {
$this -> import_examplevalues_array [ $r ] = array_merge ( $this -> import_examplevalues_array [ $r ], array ( 'sp.recuperableonly' => '' ));
}
if ( is_object ( $mysoc ) && $mysoc -> useLocalTax ( 1 )) {
$this -> import_examplevalues_array [ $r ] = array_merge ( $this -> import_examplevalues_array [ $r ], array ( 'sp.localtax1_tx' => 'LT1' , 'sp.localtax1_type' => 'LT1Type' ));
}
if ( is_object ( $mysoc ) && $mysoc -> useLocalTax ( 2 )) {
$this -> import_examplevalues_array [ $r ] = array_merge ( $this -> import_examplevalues_array [ $r ], array ( 'sp.localtax2_tx' => 'LT2' , 'sp.localtax2_type' => 'LT2Type' ));
}
$this -> import_examplevalues_array [ $r ] = array_merge ( $this -> import_examplevalues_array [ $r ], array (
2019-10-07 12:37:01 +02:00
'sp.price' => " 50.00 " ,
'sp.unitprice' => '10' ,
2019-10-04 10:04:02 +02:00
// TODO Make this field not required and calculate it from price and qty
2019-10-07 12:37:01 +02:00
'sp.remise_percent' => '20'
2021-02-23 22:03:23 +01:00
));
if ( ! empty ( $conf -> multicurrency -> enabled )) {
2019-11-13 19:35:39 +01:00
$this -> import_examplevalues_array [ $r ] = array_merge ( $this -> import_examplevalues_array [ $r ], array (
2021-02-23 22:03:23 +01:00
'sp.fk_multicurrency' => 'eg: 2, rowid for code of multicurrency currency' ,
'sp.multicurrency_code' => 'GBP' ,
'sp.multicurrency_tx' => '1.12345' ,
'sp.multicurrency_unitprice' => '' ,
// TODO Make this field not required and calculate it from price and qty
'sp.multicurrency_price' => ''
2019-10-04 10:04:02 +02:00
));
}
2021-03-30 17:28:58 +02:00
if ( ! empty ( $conf -> global -> PRODUCT_USE_SUPPLIER_PACKAGING )) {
$this -> import_examplevalues_array [ $r ] = array_merge ( $this -> import_examplevalues_array [ $r ], array (
2022-03-17 18:53:50 +01:00
'sp.packagning' => '10' ,
2021-03-30 17:28:58 +02:00
));
}
2019-10-04 10:04:02 +02:00
2021-03-30 17:28:58 +02:00
$this -> import_updatekeys_array [ $r ] = array ( 'sp.fk_product' => 'ProductOrService' , 'sp.ref_fourn' => 'SupplierRef' , 'sp.fk_soc' => 'Supplier' );
2014-05-11 17:52:16 +02:00
}
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> global -> PRODUIT_MULTIPRICES )) {
2020-10-31 14:32:18 +01:00
// Import products multiprices
2014-05-11 17:52:16 +02:00
$r ++ ;
2019-11-13 19:35:39 +01:00
$this -> import_code [ $r ] = $this -> rights_class . '_multiprice' ;
$this -> import_label [ $r ] = " ProductsOrServiceMultiPrice " ; // Translation key
$this -> import_icon [ $r ] = $this -> picto ;
$this -> import_entities_array [ $r ] = array (); // We define here only fields that use another icon that the one defined into import_icon
$this -> import_tables_array [ $r ] = array ( 'pr' => MAIN_DB_PREFIX . 'product_price' );
$this -> import_tables_creator_array [ $r ] = array ( 'pr' => 'fk_user_author' ); // Fields to store import user id
$this -> import_fields_array [ $r ] = array ( 'pr.fk_product' => " ProductOrService* " ,
'pr.price_base_type' => " PriceBase " , 'pr.price_level' => " PriceLevel " ,
'pr.price' => " PriceLevelUnitPriceHT " , 'pr.price_ttc' => " PriceLevelUnitPriceTTC " ,
'pr.price_min' => " MinPriceLevelUnitPriceHT " , 'pr.price_min_ttc' => " MinPriceLevelUnitPriceTTC " ,
2014-05-11 17:52:16 +02:00
'pr.date_price' => 'DateCreation*' );
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> global -> PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL )) {
$this -> import_fields_array [ $r ][ 'pr.tva_tx' ] = 'VATRate' ;
}
if ( is_object ( $mysoc ) && $usenpr ) {
$this -> import_fields_array [ $r ] = array_merge ( $this -> import_fields_array [ $r ], array ( 'pr.recuperableonly' => 'NPR' ));
}
2019-11-13 19:35:39 +01:00
$this -> import_regex_array [ $r ] = array ( 'pr.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$' , 'pr.recuperableonly' => '^[0|1]$' );
$this -> import_convertvalue_array [ $r ] = array (
2020-10-31 14:32:18 +01:00
'pr.fk_product' => array ( 'rule' => 'fetchidfromref' , 'classfile' => '/product/class/product.class.php' , 'class' => 'Product' , 'method' => 'fetch' , 'element' => 'Product' )
2019-04-29 20:41:36 +02:00
);
2021-03-30 17:28:58 +02:00
$this -> import_examplevalues_array [ $r ] = array ( 'pr.fk_product' => " ref:SERVICE_REF or id:123456 " ,
2019-11-13 19:35:39 +01:00
'pr.price_base_type' => " HT (for excl tax) or TTC (for inc tax) " , 'pr.price_level' => " 1 " ,
'pr.price' => " 100 " , 'pr.price_ttc' => " 110 " ,
'pr.price_min' => " 100 " , 'pr.price_min_ttc' => " 110 " ,
2019-04-29 20:41:36 +02:00
'pr.tva_tx' => '20' ,
2020-10-31 14:32:18 +01:00
'pr.recuperableonly' => '0' ,
2014-05-11 17:52:16 +02:00
'pr.date_price' => '2013-04-10' );
}
2017-11-06 12:59:58 +01:00
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS )) {
2020-10-31 14:32:18 +01:00
// Import translations of product names and descriptions
2017-11-06 12:59:58 +01:00
$r ++ ;
2019-11-13 19:35:39 +01:00
$this -> import_code [ $r ] = $this -> rights_class . '_languages' ;
$this -> import_label [ $r ] = " ProductsOrServicesTranslations " ;
$this -> import_icon [ $r ] = $this -> picto ;
$this -> import_entities_array [ $r ] = array (); // We define here only fields that use another icon that the one defined into import_icon
$this -> import_tables_array [ $r ] = array ( 'l' => MAIN_DB_PREFIX . 'product_lang' );
2017-11-06 12:59:58 +01:00
// multiline translation, one line per translation
2019-11-13 19:35:39 +01:00
$this -> import_fields_array [ $r ] = array ( 'l.fk_product' => 'ProductOrService*' , 'l.lang' => 'Language*' , 'l.label' => 'TranslatedLabel' , 'l.description' => 'TranslatedDescription' );
2017-11-06 12:59:58 +01:00
//$this->import_fields_array[$r]['l.note']='TranslatedNote';
2019-11-13 19:35:39 +01:00
$this -> import_convertvalue_array [ $r ] = array (
'l.fk_product' => array ( 'rule' => 'fetchidfromref' , 'classfile' => '/product/class/product.class.php' , 'class' => 'Product' , 'method' => 'fetch' , 'element' => 'Product' )
2017-11-06 12:59:58 +01:00
);
2021-03-30 17:28:58 +02:00
$this -> import_examplevalues_array [ $r ] = array ( 'l.fk_product' => 'ref:SERVICE_REF or id:123456' , 'l.lang' => 'en_US' , 'l.label' => 'Label in en_US' , 'l.description' => 'Desc in en_US' );
2019-11-13 19:35:39 +01:00
$this -> import_updatekeys_array [ $r ] = array ( 'l.fk_product' => 'ProductOrService' , 'l.lang' => 'Language' );
2017-11-06 12:59:58 +01:00
}
2014-05-11 17:52:16 +02:00
}
2008-10-01 21:10:17 +02:00
}
/**
2012-01-04 21:23:50 +01:00
* Function called when module is enabled .
* The init function add constants , boxes , permissions and menus ( defined in constructor ) into Dolibarr database .
* It also creates data directories
*
2020-10-31 14:32:18 +01:00
* @ param string $options Options when enabling module ( '' , 'newboxdefonly' , 'noboxes' )
2012-01-04 21:23:50 +01:00
* @ return int 1 if OK , 0 if KO
2008-10-01 21:10:17 +02:00
*/
2019-02-26 21:13:07 +01:00
public function init ( $options = '' )
2008-10-01 21:10:17 +02:00
{
2012-03-03 17:37:45 +01:00
$this -> remove ( $options );
2008-10-01 21:10:17 +02:00
$sql = array ();
2019-01-27 11:55:16 +01:00
return $this -> _init ( $sql , $options );
2008-10-01 21:10:17 +02:00
}
2003-11-17 17:35:49 +01:00
}