2004-10-19 22:24:10 +00:00
< ? php
2005-05-14 14:22:08 +00:00
/* Copyright ( C ) 2003 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2012-01-20 09:09:19 +00:00
* Copyright ( C ) 2004 - 2012 Laurent Destailleur < eldy @ users . sourceforge . net >
2005-05-14 14:22:08 +00:00
* Copyright ( C ) 2004 Sebastien Di Cintio < sdicintio @ ressource - toi . org >
* Copyright ( C ) 2004 Benoit Mortier < benoit . mortier @ opensides . be >
2012-12-30 14:13:49 +00:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ capnetworks . com >
2013-05-29 16:17:39 +00:00
* Copyright ( C ) 2012 - 2013 Juanjo Menent < jmenent @ 2 byte . es >
2003-08-11 18:44:32 +00: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 14:36:08 +00:00
* the Free Software Foundation ; either version 3 of the License , or
2003-08-11 18:44:32 +00: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
2011-07-31 23:24:38 +00:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2003-08-11 18:44:32 +00:00
*/
2005-04-12 20:01:42 +00:00
/**
2009-07-29 22:52:08 +00:00
* \defgroup produit Module products
2012-01-20 09:09:19 +00:00
* \brief Module to manage catalog of predefined products
2011-10-24 12:11:49 +00:00
* \file htdocs / core / modules / modProduct . class . php
2009-02-06 21:56:55 +00:00
* \ingroup produit
2012-01-20 09:09:19 +00:00
* \brief File to describe module to manage catalog of predefined products
2008-10-01 19:10:17 +00:00
*/
2012-08-23 00:04:35 +00:00
include_once DOL_DOCUMENT_ROOT . '/core/modules/DolibarrModules.class.php' ;
2007-10-09 23:15:25 +00:00
2003-11-13 15:09:12 +00:00
2005-04-12 20:01:42 +00:00
/**
2012-04-02 16:37:37 +00:00
* Class descriptor of Product module
2008-10-01 19:10:17 +00:00
*/
2010-04-29 14:18:42 +00:00
class modProduct extends DolibarrModules
2003-08-11 18:44:32 +00:00
{
2008-10-01 19:10:17 +00:00
/**
2011-09-26 14:22:35 +00:00
* Constructor . Define names , constants , directories , boxes , permissions
*
2012-01-04 20:23:50 +00:00
* @ param DoliDB $db Database handler
2008-10-01 19:10:17 +00:00
*/
2012-07-30 15:17:33 +00:00
function __construct ( $db )
2008-10-01 19:10:17 +00:00
{
global $conf ;
2012-01-04 20:23:50 +00:00
$this -> db = $db ;
2010-03-12 23:40:39 +00:00
$this -> numero = 50 ;
2008-10-01 19:10:17 +00:00
$this -> family = " products " ;
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
2009-10-21 13:09:42 +00:00
$this -> name = preg_replace ( '/^mod/i' , '' , get_class ( $this ));
2008-10-01 19:10:17 +00:00
$this -> description = " Gestion des produits " ;
2008-12-15 22:25:59 +00:00
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this -> version = 'dolibarr' ;
2009-01-21 13:20:26 +00:00
2008-10-06 07:39:52 +00:00
$this -> const_name = 'MAIN_MODULE_' . strtoupper ( $this -> name );
2008-10-01 19:10:17 +00:00
$this -> special = 0 ;
$this -> picto = 'product' ;
2009-04-28 13:04:35 +00:00
// Data directories to create when module is enabled
2010-04-29 14:18:42 +00:00
$this -> dirs = array ( " /product/temp " );
2008-10-01 19:10:17 +00:00
2008-12-04 23:06:45 +00:00
// Dependencies
2008-10-01 19:10:17 +00:00
$this -> depends = array ();
2009-06-08 18:14:37 +00:00
$this -> requiredby = array ( " modStock " , " modBarcode " );
2008-10-01 19:10:17 +00:00
// Config pages
2012-03-03 15:33:38 +00:00
$this -> config_page_url = array ( " product.php@product " );
2010-05-02 17:05:07 +00:00
$this -> langfiles = array ( " products " , " companies " , " stocks " , " bills " );
2008-10-01 19:10:17 +00:00
2009-06-08 18:44:53 +00:00
// Constants
2008-10-01 19:10:17 +00:00
$this -> const = array ();
$r = 0 ;
2012-08-17 13:13:10 +00:00
$this -> const [ $r ][ 0 ] = " PRODUCT_CODEPRODUCT_ADDON " ;
$this -> const [ $r ][ 1 ] = " chaine " ;
$this -> const [ $r ][ 2 ] = " mod_codeproduct_leopard " ;
$this -> const [ $r ][ 3 ] = 'Module to control product codes' ;
$this -> const [ $r ][ 4 ] = 0 ;
2012-08-15 07:06:36 +00:00
$r ++ ;
2008-10-01 19:10:17 +00:00
$this -> const [ $r ][ 0 ] = " MAIN_SEARCHFORM_PRODUITSERVICE " ;
$this -> const [ $r ][ 1 ] = " yesno " ;
$this -> const [ $r ][ 2 ] = " 1 " ;
2011-01-30 10:00:10 +00:00
$this -> const [ $r ][ 3 ] = " Show form for quick product search " ;
2008-10-01 19:10:17 +00:00
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
// Boxes
2013-10-26 14:18:28 +00:00
$this -> boxes = array (
0 => array ( 'file' => 'box_produits.php' , 'enabledbydefaulton' => 'Home' ),
1 => array ( 'file' => 'box_produits_alerte_stock.php' , 'enabledbydefaulton' => '' ),
2 => array ( 'file' => 'box_graph_product_distribution.php' , 'enabledbydefaulton' => 'Home' )
);
2008-10-01 19:10:17 +00:00
// Permissions
$this -> rights = array ();
$this -> rights_class = 'produit' ;
$r = 0 ;
$this -> rights [ $r ][ 0 ] = 31 ; // id de la permission
2009-06-08 18:14:37 +00:00
$this -> rights [ $r ][ 1 ] = 'Lire les produits' ; // libelle de la permission
2009-04-28 09:41:30 +00:00
$this -> rights [ $r ][ 2 ] = 'r' ; // type de la permission (deprecie a ce jour)
$this -> rights [ $r ][ 3 ] = 1 ; // La permission est-elle une permission par defaut
2008-10-01 19:10:17 +00:00
$this -> rights [ $r ][ 4 ] = 'lire' ;
$r ++ ;
2010-08-17 08:18:46 +00:00
2008-10-01 19:10:17 +00:00
$this -> rights [ $r ][ 0 ] = 32 ; // id de la permission
2009-06-08 18:14:37 +00:00
$this -> rights [ $r ][ 1 ] = 'Creer/modifier les produits' ; // libelle de la permission
2009-04-28 09:41:30 +00: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
2008-10-01 19:10:17 +00:00
$this -> rights [ $r ][ 4 ] = 'creer' ;
$r ++ ;
2010-08-17 08:18:46 +00:00
2008-10-01 19:10:17 +00:00
$this -> rights [ $r ][ 0 ] = 34 ; // id de la permission
2009-06-08 18:14:37 +00:00
$this -> rights [ $r ][ 1 ] = 'Supprimer les produits' ; // libelle de la permission
2009-04-28 09:41:30 +00: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
2008-10-01 19:10:17 +00:00
$this -> rights [ $r ][ 4 ] = 'supprimer' ;
2010-08-17 08:18:46 +00:00
$r ++ ;
2008-10-01 19:10:17 +00:00
2009-06-08 18:14:37 +00:00
$this -> rights [ $r ][ 0 ] = 38 ; // Must be same permission than in service module
2008-10-01 19:10:17 +00:00
$this -> rights [ $r ][ 1 ] = 'Exporter les produits' ;
$this -> rights [ $r ][ 2 ] = 'r' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'export' ;
2010-08-17 08:18:46 +00:00
$r ++ ;
2008-10-01 19:10:17 +00:00
// Exports
//--------
$r = 0 ;
$r ++ ;
$this -> export_code [ $r ] = $this -> rights_class . '_' . $r ;
2009-06-08 18:44:53 +00:00
$this -> export_label [ $r ] = " Products " ; // Translation key (used only if key ExportDataset_xxx_z not found)
2008-10-01 19:10:17 +00:00
$this -> export_permission [ $r ] = array ( array ( " produit " , " export " ));
2010-11-02 11:42:54 +00:00
$this -> export_fields_array [ $r ] = array ( 'p.rowid' => " Id " , 'p.ref' => " Ref " , 'p.label' => " Label " , 'p.description' => " Description " , 'p.accountancy_code_sell' => " ProductAccountancySellCode " , 'p.accountancy_code_buy' => " ProductAccountancyBuyCode " , 'p.note' => " Note " , 'p.length' => " Length " , 'p.surface' => " Surface " , 'p.volume' => " Volume " , 'p.weight' => " Weight " , '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' );
2012-10-17 18:32:57 +00:00
if ( ! empty ( $conf -> stock -> enabled )) $this -> export_fields_array [ $r ] = array_merge ( $this -> export_fields_array [ $r ], array ( 'p.stock' => 'Stock' , 'p.pmp' => 'PMPValue' ));
2012-09-12 17:11:03 +00:00
if ( ! empty ( $conf -> barcode -> enabled )) $this -> export_fields_array [ $r ] = array_merge ( $this -> export_fields_array [ $r ], array ( 'p.barcode' => 'BarCode' ));
2012-10-25 20:30:17 +00:00
$this -> export_TypeFields_array [ $r ] = array ( 'p.ref' => " Text " , 'p.label' => " Text " , 'p.description' => " Text " , 'p.accountancy_code_sell' => " Text " , 'p.accountancy_code_buy' => " Text " , 'p.note' => " Text " , 'p.length' => " Number " , 'p.surface' => " Number " , 'p.volume' => " Number " , 'p.weight' => " Number " , 'p.customcode' => 'Text' , 'p.price_base_type' => " Text " , 'p.price' => " Number " , 'p.price_ttc' => " Number " , 'p.tva_tx' => 'Number' , 'p.tosell' => " Boolean " , 'p.tobuy' => " Boolean " , 'p.datec' => 'Date' , 'p.tms' => 'Date' );
if ( ! empty ( $conf -> stock -> enabled )) $this -> export_TypeFields_array [ $r ] = array_merge ( $this -> export_TypeFields_array [ $r ], array ( 'p.pmp' => 'Number' ));
if ( ! empty ( $conf -> barcode -> enabled )) $this -> export_TypeFields_array [ $r ] = array_merge ( $this -> export_TypeFields_array [ $r ], array ( 'p.barcode' => 'Text' ));
2013-09-05 15:00:18 +00:00
$this -> export_entities_array [ $r ] = array ( 'p.rowid' => " product " , 'p.ref' => " product " , 'p.label' => " product " , 'p.description' => " product " , 'p.accountancy_code_sell' => 'product' , 'p.note' => " product " , 'p.length' => " product " , 'p.surface' => " product " , 'p.volume' => " product " , 'p.weight' => " product " , 'p.customcode' => 'product' , 'p.price_base_type' => " product " , 'p.price' => " product " , 'p.price_ttc' => " product " , 'p.tva_tx' => " product " , 'p.tosell' => " product " , 'p.tobuy' => " product " , 'p.datec' => " product " , 'p.tms' => " product " );
2012-10-17 18:32:57 +00:00
if ( ! empty ( $conf -> stock -> enabled )) $this -> export_entities_array [ $r ] = array_merge ( $this -> export_entities_array [ $r ], array ( 'p.stock' => 'product' , 'p.pmp' => 'product' ));
2012-03-13 08:38:00 +00:00
if ( ! empty ( $conf -> barcode -> enabled )) $this -> export_entities_array [ $r ] = array_merge ( $this -> export_entities_array [ $r ], array ( 'p.barcode' => 'product' ));
2012-03-03 15:33:38 +00:00
// Add extra fields
2013-05-29 16:17:39 +00:00
$sql = " SELECT name, label, type FROM " . MAIN_DB_PREFIX . " extrafields WHERE elementtype = 'product' " ;
2012-03-03 15:33:38 +00:00
$resql = $this -> db -> query ( $sql );
if ( $resql ) // This can fail when class is used on old database (during migration for example)
{
while ( $obj = $this -> db -> fetch_object ( $resql ))
{
$fieldname = 'extra.' . $obj -> name ;
$fieldlabel = ucfirst ( $obj -> label );
2013-05-29 16:17:39 +00:00
$typeFilter = " Text " ;
switch ( $obj -> type )
{
case 'int' :
case 'double' :
case 'price' :
$typeFilter = " Numeric " ;
break ;
case 'date' :
case 'datetime' :
$typeFilter = " Date " ;
break ;
case 'boolean' :
$typeFilter = " Boolean " ;
break ;
case 'sellist' :
$typeFilter = " List: " . $obj -> param ;
break ;
}
2012-03-03 15:33:38 +00:00
$this -> export_fields_array [ $r ][ $fieldname ] = $fieldlabel ;
2013-05-29 16:17:39 +00:00
$this -> export_TypeFields_array [ $r ][ $fieldname ] = $typeFilter ;
2012-03-03 15:33:38 +00:00
$this -> export_entities_array [ $r ][ $fieldname ] = 'product' ;
}
}
// End add axtra fields
2009-05-04 11:40:00 +00:00
2008-10-01 19:10:17 +00:00
$this -> export_sql_start [ $r ] = 'SELECT DISTINCT ' ;
$this -> export_sql_end [ $r ] = ' FROM ' . MAIN_DB_PREFIX . 'product as p' ;
2013-04-30 10:12:54 +00:00
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_extrafields as extra ON p.rowid = extra.fk_object' ;
2012-02-11 09:18:09 +00:00
$this -> export_sql_end [ $r ] .= ' WHERE p.fk_product_type = 0 AND p.entity IN (' . getEntity ( " product " , 1 ) . ')' ;
2008-10-01 19:10:17 +00:00
// Imports
//--------
$r = 0 ;
$r ++ ;
2009-01-21 13:20:26 +00:00
$this -> import_code [ $r ] = $this -> rights_class . '_' . $r ;
2009-06-08 18:44:53 +00:00
$this -> import_label [ $r ] = " Products " ; // Translation key
2010-09-30 19:25:58 +00:00
$this -> import_icon [ $r ] = $this -> picto ;
2012-01-22 01:28:49 +00:00
$this -> import_entities_array [ $r ] = array (); // We define here only fields that use another icon that the one defined into import_icon
2012-03-03 15:33:38 +00:00
$this -> import_tables_array [ $r ] = array ( 'p' => MAIN_DB_PREFIX . 'product' , 'extra' => MAIN_DB_PREFIX . 'product_extrafields' );
2009-10-17 13:12:55 +00:00
$this -> import_tables_creator_array [ $r ] = array ( 'p' => 'fk_user_author' ); // Fields to store import user id
2012-03-29 22:54:41 +00:00
$this -> import_fields_array [ $r ] = array ( 'p.ref' => " Ref* " , 'p.label' => " Label* " , 'p.description' => " Description " , 'p.accountancy_code_sell' => " ProductAccountancySellCode " , 'p.accountancy_code_buy' => " ProductAccountancyBuyCode " , 'p.note' => " Note " , 'p.length' => " Length " , 'p.surface' => " Surface " , 'p.volume' => " Volume " , 'p.weight' => " Weight " , 'p.duration' => " Duration " , 'p.customcode' => 'CustomCode' , 'p.price' => " SellingPriceHT " , 'p.price_ttc' => " SellingPriceTTC " , 'p.tva_tx' => 'VAT' , 'p.tosell' => " OnSell* " , 'p.tobuy' => " OnBuy* " , 'p.fk_product_type' => " Type* " , 'p.finished' => 'Nature' , 'p.datec' => 'DateCreation*' );
2012-03-03 15:33:38 +00:00
// Add extra fields
2013-05-29 16:17:39 +00:00
$sql = " SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . " extrafields WHERE elementtype = 'product' AND entity = " . $conf -> entity ;
2012-03-03 15:33:38 +00:00
$resql = $this -> db -> query ( $sql );
if ( $resql ) // This can fail when class is used on old database (during migration for example)
{
while ( $obj = $this -> db -> fetch_object ( $resql ))
{
$fieldname = 'extra.' . $obj -> name ;
$fieldlabel = ucfirst ( $obj -> label );
2012-10-25 11:11:55 +00:00
$this -> import_fields_array [ $r ][ $fieldname ] = $fieldlabel . ( $obj -> fieldrequired ? '*' : '' );
2012-03-03 15:33:38 +00:00
}
}
// End add extra fields
$this -> import_fieldshidden_array [ $r ] = array ( 'extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'product' ); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
2012-01-20 09:09:19 +00:00
$this -> import_regex_array [ $r ] = array ( 'p.ref' => '[^ ]' , '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]$' );
2012-10-18 11:25:32 +00:00
$this -> import_examplevalues_array [ $r ] = array ( 'p.ref' => " PREF123456 " , 'p.label' => " My product " , 'p.description' => " This is a description example for record " , 'p.note' => " Some note " , 'p.price' => " 100 " , 'p.price_ttc' => " 110 " , 'p.tva_tx' => '10' , 'p.tosell' => " 0 or 1 " , 'p.tobuy' => " 0 or 1 " , 'p.fk_product_type' => " 0 for product/1 for service " , 'p.finished' => '' , 'p.duration' => " 1y " , 'p.datec' => '2008-12-31' );
2012-10-25 20:30:17 +00:00
2012-10-28 12:57:21 +00:00
if ( ! empty ( $conf -> fournisseur -> enabled ))
{
// Import product suppliers
$r ++ ;
$this -> import_code [ $r ] = $this -> rights_class . '_' . $r ;
$this -> import_label [ $r ] = " SuppliersPrices " ; // Translation key
$this -> import_icon [ $r ] = 'product' ;
$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 ( 'sp.fk_product' => " Product* " ,
2012-10-18 11:25:32 +00:00
'sp.fk_soc' => " Supplier* " , 'sp.ref_fourn' => 'SupplierRef' , 'sp.quantity' => " QtyMin* " , 'sp.tva_tx' => 'VATRate' ,
'sp.price' => " PriceQtyMinHT* " ,
'sp.unitprice' => 'UnitPriceHT*' , // TODO Make this file not required and calculate it from price and qty
2012-10-28 12:57:21 +00:00
'sp.remise_percent' => 'DiscountQtyMin'
);
$this -> import_convertvalue_array [ $r ] = array (
'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' )
);
$this -> import_examplevalues_array [ $r ] = array ( 'sp.fk_product' => " PREF123456 " ,
2012-10-18 11:25:32 +00:00
'sp.fk_soc' => " My Supplier " , 'sp.ref_fourn' => " SupplierRef " , 'sp.quantity' => " 1 " , 'sp.tva_tx' => '21' ,
2012-10-28 12:57:21 +00:00
'sp.price' => " 50 " ,
2012-10-18 11:25:32 +00:00
'sp.unitprice' => '50' ,
2012-10-28 12:57:21 +00:00
'sp.remise_percent' => '0'
);
2012-10-17 17:02:12 +00:00
}
2013-10-26 14:18:28 +00:00
2013-07-18 08:47:08 +00:00
if ( ! empty ( $conf -> global -> PRODUIT_MULTIPRICES )) {
// Exports product multiprice
//--------
$r ++ ;
$this -> export_code [ $r ] = $this -> rights_class . '_' . $r ;
$this -> export_label [ $r ] = " ProductsMultiPrice " ; // Translation key (used only if key ExportDataset_xxx_z not found)
$this -> export_permission [ $r ] = array ( array ( " produit " , " export " ));
$this -> export_fields_array [ $r ] = array ( 'p.rowid' => " Id " , 'p.ref' => " Ref " ,
2014-05-11 11:14:45 +00:00
'pr.price_base_type' => " PriceBase " , 'pr.price_level' => " PriceLevel " ,
'pr.price' => " HT " , 'pr.price_ttc' => " TTC " ,
'pr.price_min' => " MinPriceHT " , 'pr.price_min_ttc' => " MinPriceTTC " ,
'pr.tva_tx' => 'VAT' ,
2013-07-18 08:47:08 +00:00
'pr.date_price' => 'DateCreation' );
$this -> export_entities_array [ $r ] = array ( 'p.rowid' => " product " , 'p.ref' => " product " ,
'pr.price_base_type' => " product " , 'pr.price_level' => " product " , 'pr.price' => " product " ,
'pr.price_ttc' => " product " ,
2014-05-11 11:14:45 +00:00
'pr.price_min' => " product " , 'pr.price_min_ttc' => " product " ,
2013-07-18 08:47:08 +00:00
'pr.tva_tx' => 'product' ,
'pr.date_price' => " 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_price as pr ON p.rowid = pr.fk_product' ;
$this -> export_sql_end [ $r ] .= ' WHERE p.fk_product_type = 0 AND p.entity IN (' . getEntity ( " product " , 1 ) . ')' ;
2013-10-26 14:18:28 +00:00
2013-07-18 08:47:08 +00:00
// Import product multiprice
//--------
$r = 0 ;
2013-10-26 14:18:28 +00:00
2013-07-18 08:47:08 +00:00
$r ++ ;
$this -> import_code [ $r ] = $this -> rights_class . '_' . $r ;
$this -> import_label [ $r ] = " ProductsMultiPrice " ; // 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
2014-05-11 11:14:45 +00:00
$this -> import_fields_array [ $r ] = array ( 'pr.fk_product' => " Id* " ,
'pr.price_base_type' => " PriceBase " , 'pr.price_level' => " PriceLevel " ,
'pr.price' => " HT " , 'pr.price_ttc' => " TTC " ,
'pr.price_min' => " MinPriceHT " , 'pr.price_min_ttc' => " MinPriceTTC " ,
'pr.tva_tx' => 'VAT' ,
2013-07-18 08:47:08 +00:00
'pr.date_price' => 'DateCreation*' );
$this -> import_regex_array [ $r ] = array ( 'pr.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$' );
$this -> import_examplevalues_array [ $r ] = array ( 'pr.fk_product' => " 1 " ,
'pr.price_base_type' => " HT " , 'pr.price_level' => " 1 " ,
'pr.price' => " 100 " , 'pr.price_ttc' => " 110 " ,
'pr.price_min' => " 100 " , 'pr.price_min_ttc' => " 110 " ,
'pr.tva_tx' => '19.6' ,
'pr.date_price' => '2013-04-10' );
}
2012-10-27 18:27:07 +00:00
2006-05-10 22:18:51 +00:00
}
2005-05-14 14:22:08 +00:00
2008-10-01 19:10:17 +00:00
/**
2012-01-04 20:23:50 +00: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
*
2013-10-26 14:18:28 +00:00
* @ param string $options Options when enabling module ( '' , 'newboxdefonly' , 'noboxes' )
2012-01-04 20:23:50 +00:00
* @ return int 1 if OK , 0 if KO
2008-10-01 19:10:17 +00:00
*/
2012-01-04 20:23:50 +00:00
function init ( $options = '' )
2008-10-01 19:10:17 +00:00
{
// Permissions
2012-03-03 16:37:45 +00:00
$this -> remove ( $options );
2005-05-14 14:22:08 +00:00
2008-10-01 19:10:17 +00:00
$sql = array ();
2003-11-13 15:09:12 +00:00
2012-01-04 20:23:50 +00:00
return $this -> _init ( $sql , $options );
2008-10-01 19:10:17 +00:00
}
2004-11-23 20:04:19 +00:00
2012-03-03 16:37:45 +00:00
/**
* Function called when module is disabled .
* Remove from database constants , boxes and permissions from Dolibarr database .
* Data directories are not deleted
*
2013-10-26 14:18:28 +00:00
* @ param string $options Options when enabling module ( '' , 'newboxdefonly' , 'noboxes' )
2012-03-03 16:37:45 +00:00
* @ return int 1 if OK , 0 if KO
*/
function remove ( $options = '' )
{
2008-10-01 19:10:17 +00:00
$sql = array ();
2003-08-30 12:30:46 +00:00
2012-03-03 16:37:45 +00:00
return $this -> _remove ( $sql , $options );
}
2003-08-11 18:44:32 +00:00
}
?>