forked from Wavyzz/dolibarr
code syntax core directory
This commit is contained in:
@@ -135,7 +135,9 @@ class modService extends DolibarrModules
|
||||
*/
|
||||
|
||||
$usenpr = 0;
|
||||
if (is_object($mysoc)) $usenpr = $mysoc->useNPR();
|
||||
if (is_object($mysoc)) {
|
||||
$usenpr = $mysoc->useNPR();
|
||||
}
|
||||
|
||||
// Exports
|
||||
//--------
|
||||
@@ -161,16 +163,32 @@ class modService extends DolibarrModules
|
||||
'p.tva_tx'=>'VATRate',
|
||||
'p.datec'=>'DateCreation', 'p.tms'=>'DateModification'
|
||||
);
|
||||
if (is_object($mysoc) && $usenpr) $this->export_fields_array[$r]['p.recuperableonly'] = 'NPR';
|
||||
if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $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'));
|
||||
if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode'));
|
||||
if (is_object($mysoc) && $usenpr) {
|
||||
$this->export_fields_array[$r]['p.recuperableonly'] = 'NPR';
|
||||
}
|
||||
if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) {
|
||||
$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'));
|
||||
}
|
||||
if (!empty($conf->barcode->enabled)) {
|
||||
$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode'));
|
||||
}
|
||||
$keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra';
|
||||
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
|
||||
if (!empty($conf->fournisseur->enabled)) $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';
|
||||
if (!empty($conf->fournisseur->enabled)) {
|
||||
$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';
|
||||
}
|
||||
$this->export_TypeFields_array[$r] = array(
|
||||
'p.ref'=>"Text", 'p.label'=>"Text",
|
||||
'p.fk_product_type'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean",
|
||||
@@ -185,36 +203,74 @@ class modService extends DolibarrModules
|
||||
'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric',
|
||||
'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.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric'));
|
||||
if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));
|
||||
if (!empty($conf->fournisseur->enabled)) $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'));
|
||||
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'));
|
||||
}
|
||||
if (!empty($conf->barcode->enabled)) {
|
||||
$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));
|
||||
}
|
||||
if (!empty($conf->fournisseur->enabled)) {
|
||||
$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'));
|
||||
}
|
||||
$this->export_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
|
||||
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'));
|
||||
if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product'));
|
||||
if (!empty($conf->fournisseur->enabled)) $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'));
|
||||
if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product'));
|
||||
if (!empty($conf->fournisseur->enabled)) $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->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'));
|
||||
}
|
||||
if (!empty($conf->barcode->enabled)) {
|
||||
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product'));
|
||||
}
|
||||
if (!empty($conf->fournisseur->enabled)) {
|
||||
$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'));
|
||||
}
|
||||
if (!empty($conf->barcode->enabled)) {
|
||||
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product'));
|
||||
}
|
||||
if (!empty($conf->fournisseur->enabled)) {
|
||||
$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');
|
||||
}
|
||||
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
|
||||
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p';
|
||||
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';
|
||||
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';
|
||||
}
|
||||
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object';
|
||||
if (!empty($conf->fournisseur->enabled)) $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';
|
||||
if (!empty($conf->fournisseur->enabled)) {
|
||||
$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';
|
||||
}
|
||||
$this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity('product').')';
|
||||
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"
|
||||
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"
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
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)) {
|
||||
// Exports product multiprice
|
||||
$r++;
|
||||
$this->export_code[$r] = $this->rights_class.'_'.$r;
|
||||
@@ -226,7 +282,9 @@ class modService extends DolibarrModules
|
||||
'pr.price_min'=>"MinPriceLevelUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC",
|
||||
'pr.tva_tx'=>'PriceLevelVATRate',
|
||||
'pr.date_price'=>'DateCreation');
|
||||
if (is_object($mysoc) && $usenpr) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR';
|
||||
if (is_object($mysoc) && $usenpr) {
|
||||
$this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR';
|
||||
}
|
||||
//$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',
|
||||
@@ -246,8 +304,7 @@ class modService extends DolibarrModules
|
||||
$this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile
|
||||
}
|
||||
|
||||
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES))
|
||||
{
|
||||
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
|
||||
// Exports product multiprice
|
||||
$r++;
|
||||
$this->export_code[$r] = $this->rights_class.'_'.$r;
|
||||
@@ -261,7 +318,9 @@ class modService extends DolibarrModules
|
||||
'pr.tva_tx'=>'PriceVATRate',
|
||||
'pr.default_vat_code'=>'PriceVATCode',
|
||||
'pr.datec'=>'DateCreation');
|
||||
if (is_object($mysoc) && $usenpr) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR';
|
||||
if (is_object($mysoc) && $usenpr) {
|
||||
$this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR';
|
||||
}
|
||||
$this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product",
|
||||
's.nom'=>'company',
|
||||
'pr.price_base_type'=>"product", 'pr.price'=>"product",
|
||||
@@ -278,8 +337,7 @@ class modService extends DolibarrModules
|
||||
$this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile
|
||||
}
|
||||
|
||||
if (!empty($conf->global->PRODUIT_SOUSPRODUITS))
|
||||
{
|
||||
if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) {
|
||||
// Exports virtual products
|
||||
$r++;
|
||||
$this->export_code[$r] = $this->rights_class.'_'.$r;
|
||||
@@ -295,8 +353,12 @@ class modService extends DolibarrModules
|
||||
'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'
|
||||
);
|
||||
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'));
|
||||
if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode'));
|
||||
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'));
|
||||
}
|
||||
if (!empty($conf->barcode->enabled)) {
|
||||
$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode'));
|
||||
}
|
||||
$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",
|
||||
@@ -307,8 +369,12 @@ class modService extends DolibarrModules
|
||||
'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'
|
||||
);
|
||||
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'));
|
||||
if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));
|
||||
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'));
|
||||
}
|
||||
if (!empty($conf->barcode->enabled)) {
|
||||
$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));
|
||||
}
|
||||
$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",
|
||||
@@ -319,8 +385,12 @@ class modService extends DolibarrModules
|
||||
'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"
|
||||
);
|
||||
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'));
|
||||
if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct'));
|
||||
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'));
|
||||
}
|
||||
if (!empty($conf->barcode->enabled)) {
|
||||
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct'));
|
||||
}
|
||||
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct", 'pa.incdec'=>'subproduct'));
|
||||
$keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra';
|
||||
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
|
||||
@@ -454,20 +524,30 @@ class modService extends DolibarrModules
|
||||
'dict' => 'DictionaryCountry'
|
||||
)
|
||||
);
|
||||
if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $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'));
|
||||
if (!empty($conf->barcode->enabled)) $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';
|
||||
if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) {
|
||||
$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'));
|
||||
}
|
||||
if (!empty($conf->barcode->enabled)) {
|
||||
$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';
|
||||
}
|
||||
// Add extra fields
|
||||
$import_extrafield_sample = array();
|
||||
$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0,".$conf->entity.")";
|
||||
$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))
|
||||
{
|
||||
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);
|
||||
$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
|
||||
@@ -528,25 +608,39 @@ class modService extends DolibarrModules
|
||||
'p.finished' => '0 (raw material) / 1 (finished goods)'
|
||||
);
|
||||
//clauses copied from import_fields_array
|
||||
if (!empty($conf->stock->enabled)) $import_sample = array_merge($import_sample, array(
|
||||
if (!empty($conf->stock->enabled)) {
|
||||
$import_sample = array_merge($import_sample, array(
|
||||
'p.seuil_stock_alerte' => '',
|
||||
'p.pmp' => '0',
|
||||
'p.desiredstock' => ''
|
||||
));
|
||||
if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $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'=>''));
|
||||
if (!empty($conf->barcode->enabled)) $import_sample = array_merge($import_sample, array('p.barcode'=>''));
|
||||
));
|
||||
}
|
||||
if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) {
|
||||
$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'=>''));
|
||||
}
|
||||
if (!empty($conf->barcode->enabled)) {
|
||||
$import_sample = array_merge($import_sample, array('p.barcode'=>''));
|
||||
}
|
||||
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
|
||||
$import_sample = array_merge(
|
||||
$import_sample,
|
||||
array(
|
||||
'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"'
|
||||
)
|
||||
);
|
||||
);
|
||||
|
||||
if (!is_array($this->import_convertvalue_array[$r])) $this->import_convertvalue_array[$r] = array();
|
||||
if (!is_array($this->import_convertvalue_array[$r])) {
|
||||
$this->import_convertvalue_array[$r] = array();
|
||||
}
|
||||
$this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array(
|
||||
'p.fk_unit' => array(
|
||||
'rule' => 'fetchidfromcodeorlabel',
|
||||
@@ -559,12 +653,12 @@ class modService extends DolibarrModules
|
||||
}
|
||||
$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
|
||||
$this->import_updatekeys_array[$r] = array('p.ref'=>'Ref');
|
||||
if (!empty($conf->barcode->enabled)) $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
|
||||
if (!empty($conf->barcode->enabled)) {
|
||||
$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
|
||||
}
|
||||
|
||||
if (empty($conf->product->enabled)) // We enable next import templates only if module product not already enabled (to avoid duplicate entries)
|
||||
{
|
||||
if (!empty($conf->fournisseur->enabled))
|
||||
{
|
||||
if (empty($conf->product->enabled)) { // We enable next import templates only if module product not already enabled (to avoid duplicate entries)
|
||||
if (!empty($conf->fournisseur->enabled)) {
|
||||
// Import suppliers prices (note: this code is duplicated in module Service)
|
||||
$r++;
|
||||
$this->import_code[$r] = $this->rights_class.'_supplierprices';
|
||||
@@ -583,31 +677,36 @@ class modService extends DolibarrModules
|
||||
'sp.delivery_time_days' => 'DeliveryDelay',
|
||||
'sp.supplier_reputation' => 'SupplierReputation'
|
||||
);
|
||||
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'));
|
||||
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'));
|
||||
}
|
||||
$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
|
||||
'sp.price'=>"PriceQtyMinHT*",
|
||||
'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty
|
||||
'sp.remise_percent'=>'DiscountQtyMin'
|
||||
));
|
||||
|
||||
if (!empty($conf->multicurrency->enabled))
|
||||
{
|
||||
if (!empty($conf->multicurrency->enabled)) {
|
||||
$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
|
||||
'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',
|
||||
'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',
|
||||
));
|
||||
}
|
||||
|
||||
$this->import_convertvalue_array[$r] = array(
|
||||
$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(
|
||||
);
|
||||
$this->import_examplevalues_array[$r] = array(
|
||||
'sp.fk_product' => "PRODUCT_REF or id:123456",
|
||||
'sp.fk_soc' => "My Supplier",
|
||||
'sp.ref_fourn' => "XYZ-F123456",
|
||||
@@ -619,33 +718,37 @@ class modService extends DolibarrModules
|
||||
'sp.default_vat_code' => '',
|
||||
'sp.delivery_time_days' => '5',
|
||||
'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER'
|
||||
);
|
||||
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(
|
||||
);
|
||||
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(
|
||||
'sp.price' => "50.00",
|
||||
'sp.unitprice' => '10',
|
||||
// TODO Make this field not required and calculate it from price and qty
|
||||
'sp.remise_percent' => '20'
|
||||
));
|
||||
if (!empty($conf->multicurrency->enabled))
|
||||
{
|
||||
));
|
||||
if (!empty($conf->multicurrency->enabled)) {
|
||||
$this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
|
||||
'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'=>''
|
||||
'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'=>''
|
||||
));
|
||||
}
|
||||
|
||||
$this->import_updatekeys_array[$r] = array('sp.fk_product'=>'ProductOrService', 'sp.ref_fourn'=>'SupplierRef', 'sp.fk_soc'=>'Supplier');
|
||||
$this->import_updatekeys_array[$r] = array('sp.fk_product'=>'ProductOrService', 'sp.ref_fourn'=>'SupplierRef', 'sp.fk_soc'=>'Supplier');
|
||||
}
|
||||
|
||||
if (!empty($conf->global->PRODUIT_MULTIPRICES))
|
||||
{
|
||||
if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
|
||||
// Import products multiprices
|
||||
$r++;
|
||||
$this->import_code[$r] = $this->rights_class.'_multiprice';
|
||||
@@ -659,8 +762,12 @@ class modService extends DolibarrModules
|
||||
'pr.price'=>"PriceLevelUnitPriceHT", 'pr.price_ttc'=>"PriceLevelUnitPriceTTC",
|
||||
'pr.price_min'=>"MinPriceLevelUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC",
|
||||
'pr.date_price'=>'DateCreation*');
|
||||
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'));
|
||||
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'));
|
||||
}
|
||||
$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(
|
||||
'pr.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product')
|
||||
@@ -674,8 +781,7 @@ class modService extends DolibarrModules
|
||||
'pr.date_price'=>'2013-04-10');
|
||||
}
|
||||
|
||||
if (!empty($conf->global->MAIN_MULTILANGS))
|
||||
{
|
||||
if (!empty($conf->global->MAIN_MULTILANGS)) {
|
||||
// Import translations of product names and descriptions
|
||||
$r++;
|
||||
$this->import_code[$r] = $this->rights_class.'_languages';
|
||||
|
||||
Reference in New Issue
Block a user