|
|
|
|
@ -141,30 +141,34 @@ class modService extends DolibarrModules
|
|
|
|
|
$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.description'=>"Description",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.duration'=>"Duration",'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'));
|
|
|
|
|
if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit';
|
|
|
|
|
$this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification');
|
|
|
|
|
if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly']='NPR';
|
|
|
|
|
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->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.cost_price'=>'CostPrice'));
|
|
|
|
|
$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->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.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date'
|
|
|
|
|
);
|
|
|
|
|
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_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('p.rowid'=>"service",'p.ref'=>"service",'p.label'=>"service",'p.description'=>"service",'p.accountancy_code_sell'=>'service','p.note'=>"service",'p.price_base_type'=>"service",'p.price'=>"service",'p.price_ttc'=>"service",'p.tva_tx'=>"service",'p.tosell'=>"service",'p.tobuy'=>"service",'p.duration'=>"service",'p.datec'=>"service",'p.tms'=>"service");
|
|
|
|
|
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'=>'service'));
|
|
|
|
|
if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.barcode'=>'service'));
|
|
|
|
|
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'));
|
|
|
|
|
$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.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'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'));
|
|
|
|
|
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');
|
|
|
|
|
$this->export_sql_start[$r]='SELECT DISTINCT ';
|
|
|
|
|
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p';
|
|
|
|
|
@ -185,7 +189,7 @@ class modService extends DolibarrModules
|
|
|
|
|
$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",
|
|
|
|
|
'pr.price_base_type'=>"PriceLevelPriceBase",'pr.price_level'=>"PriceLevel",
|
|
|
|
|
'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",
|
|
|
|
|
'pr.tva_tx'=>'PriceLevelVATRate',
|
|
|
|
|
@ -207,9 +211,89 @@ class modService extends DolibarrModules
|
|
|
|
|
$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.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')';
|
|
|
|
|
$this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
|
|
|
|
|
{
|
|
|
|
|
// 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)
|
|
|
|
|
$this->export_permission[$r]=array(array("produit","export"));
|
|
|
|
|
$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');
|
|
|
|
|
if (is_object($mysoc) && $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",
|
|
|
|
|
'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').')';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! empty($conf->global->PRODUIT_SOUSPRODUITS))
|
|
|
|
|
{
|
|
|
|
|
// 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)
|
|
|
|
|
$this->export_permission[$r]=array(array("produit","export"));
|
|
|
|
|
$this->export_fields_array[$r]=array(
|
|
|
|
|
'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl",
|
|
|
|
|
'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'
|
|
|
|
|
);
|
|
|
|
|
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",'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'
|
|
|
|
|
);
|
|
|
|
|
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",
|
|
|
|
|
'p.accountancy_code_sell'=>'virtualproduct','p.accountancy_code_buy'=>'virtualproduct','p.note'=>"virtualproduct",'p.length'=>"virtualproduct",
|
|
|
|
|
'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"
|
|
|
|
|
);
|
|
|
|
|
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';
|
|
|
|
|
$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';
|
|
|
|
|
$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').')';
|
|
|
|
|
$this->export_sql_end[$r] .=' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! empty($conf->global->PRODUIT_SOUSPRODUITS))
|
|
|
|
|
{
|
|
|
|
|
// Exports virtual products
|
|
|
|
|
@ -259,13 +343,12 @@ class modService extends DolibarrModules
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Imports
|
|
|
|
|
//--------
|
|
|
|
|
$r=0;
|
|
|
|
|
|
|
|
|
|
// Import list of services
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$r++;
|
|
|
|
|
$this->import_code[$r]=$this->rights_class.'_'.$r;
|
|
|
|
|
$this->import_label[$r]="Products"; // Translation key
|
|
|
|
|
@ -277,13 +360,14 @@ class modService extends DolibarrModules
|
|
|
|
|
'p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.url'=>"PublicUrl",'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'
|
|
|
|
|
'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation'
|
|
|
|
|
);
|
|
|
|
|
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) && $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->stock->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue'));
|
|
|
|
|
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) && $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();
|
|
|
|
|
@ -296,24 +380,24 @@ class modService extends DolibarrModules
|
|
|
|
|
$fieldname='extra.'.$obj->name;
|
|
|
|
|
$fieldlabel=ucfirst($obj->label);
|
|
|
|
|
$this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
|
|
|
|
|
$import_extrafield_sample[$fieldname]=$fieldlabel;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 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)
|
|
|
|
|
$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]$',
|
|
|
|
|
'p.finished' => '^[0|1]$'
|
|
|
|
|
);
|
|
|
|
|
$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');
|
|
|
|
|
'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]$',
|
|
|
|
|
'p.recuperableonly'=>'^[0|1]$'
|
|
|
|
|
);
|
|
|
|
|
$import_sample=array('p.ref'=>"SERVICE_REF or id:123456",'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','p.recuperableonly'=>'0 or 1');
|
|
|
|
|
$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->product->enabled)) // We enable next import templates only if module product not already enabled (to avoid duplicate entries)
|
|
|
|
|
{
|
|
|
|
|
if (! empty($conf->fournisseur->enabled))
|
|
|
|
|
@ -355,18 +439,19 @@ class modService extends DolibarrModules
|
|
|
|
|
'sp.multicurrency_price'=>'CurrencyPrice',
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$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",
|
|
|
|
|
'sp.fk_product'=>"SERVICE_REF or id:123456",
|
|
|
|
|
'sp.fk_soc'=>"My Supplier",'sp.ref_fourn'=>"SupplierRef", 'sp.quantity'=>"1", 'sp.tva_tx'=>'21',
|
|
|
|
|
'sp.price'=>"50",
|
|
|
|
|
'sp.unitprice'=>'50',
|
|
|
|
|
'sp.remise_percent'=>'0'
|
|
|
|
|
);
|
|
|
|
|
$this->import_updatekeys_array[$r]=array('sp.fk_product'=>'ProductOrService','sp.ref_fourn'=>'SupplierRef','sp.fk_soc'=>'Supplier');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! empty($conf->global->PRODUIT_MULTIPRICES))
|
|
|
|
|
@ -379,21 +464,24 @@ class modService extends DolibarrModules
|
|
|
|
|
$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'=>"ProductRowid*",
|
|
|
|
|
'pr.price_base_type'=>"PriceLevelPriceBase",'pr.price_level'=>"PriceLevel",
|
|
|
|
|
$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",
|
|
|
|
|
'pr.tva_tx'=>'PriceLevelVATRate',
|
|
|
|
|
'pr.date_price'=>'DateCreation*');
|
|
|
|
|
if (is_object($mysoc) && $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]$');
|
|
|
|
|
$this->import_examplevalues_array[$r]=array('pr.fk_product'=>"1",
|
|
|
|
|
'pr.price_base_type'=>"HT",'pr.price_level'=>"1",
|
|
|
|
|
if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) $this->import_fields_array[$r]['pr.tva_tx']='VATRate';
|
|
|
|
|
if (is_object($mysoc) && $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')
|
|
|
|
|
);
|
|
|
|
|
$this->import_examplevalues_array[$r]=array('pr.fk_product'=>"SERVICE_REF or id:123456",
|
|
|
|
|
'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",
|
|
|
|
|
'pr.tva_tx'=>'20',
|
|
|
|
|
'pr.tva_tx'=>'20',
|
|
|
|
|
'pr.recuperableonly'=>'0',
|
|
|
|
|
'pr.date_price'=>'2013-04-10');
|
|
|
|
|
'pr.date_price'=>'2013-04-10');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! empty($conf->global->MAIN_MULTILANGS))
|
|
|
|
|
@ -406,13 +494,13 @@ class modService extends DolibarrModules
|
|
|
|
|
$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');
|
|
|
|
|
// multiline translation, one line per translation
|
|
|
|
|
$this->import_fields_array[$r]=array('l.fk_product'=>'Ref', 'l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription');
|
|
|
|
|
$this->import_fields_array[$r]=array('l.fk_product'=>'ProductOrService*', 'l.lang'=>'Language*', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription');
|
|
|
|
|
//$this->import_fields_array[$r]['l.note']='TranslatedNote';
|
|
|
|
|
$this->import_convertvalue_array[$r]=array(
|
|
|
|
|
'l.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product')
|
|
|
|
|
);
|
|
|
|
|
$this->import_examplevalues_array[$r]=array('l.fk_product'=>'MyProductRef','l.lang'=>'en_US','l.label'=>'Label in en_US','l.description'=>'Desc in en_US');
|
|
|
|
|
$this->import_updatekeys_array[$r]=array('l.fk_product'=>'Ref','l.lang'=>'Language');
|
|
|
|
|
$this->import_examplevalues_array[$r]=array('l.fk_product'=>'SERVICE_REF or id:123456','l.lang'=>'en_US','l.label'=>'Label in en_US','l.description'=>'Desc in en_US');
|
|
|
|
|
$this->import_updatekeys_array[$r]=array('l.fk_product'=>'ProductOrService','l.lang'=>'Language');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|