Skip to content
Snippets Groups Projects
Commit d4534f4a authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: [ bug #1384 ] Wrong name for import products and product prices

parent 3776f7b1
No related branches found
No related tags found
No related merge requests found
......@@ -206,6 +206,32 @@ class modProduct extends DolibarrModules
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 = 0 AND p.entity IN ('.getEntity("product", 1).')';
if (! empty($conf->global->PRODUIT_MULTIPRICES))
{
// Exports product multiprice
$r++;
$this->export_code[$r]=$this->rights_class.'_'.$key;
$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'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC",
'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC",
'pr.tva_tx'=>'PriceLevelVATRate',
'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",
'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC",
'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).')';
}
// Imports
//--------
......@@ -239,15 +265,15 @@ class modProduct extends DolibarrModules
if (! empty($conf->fournisseur->enabled))
{
// Import product suppliers
// Import suppliers prices (note: this code is duplicated into module service)
$r++;
$this->import_code[$r]=$this->rights_class.'_'.$r;
$this->import_label[$r]="SuppliersPrices"; // Translation key
$this->import_icon[$r]='product';
$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('sp.fk_product'=>"Product*",
$this->import_fields_array[$r]=array('sp.fk_product'=>"ProductOrService*",
'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
......@@ -266,55 +292,29 @@ class modProduct extends DolibarrModules
);
}
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",
'pr.price_base_type'=>"PriceLevelPriceBase",'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');
$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",
'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC",
'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).')';
// Import product multiprice
//--------
$r=0;
$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
$this->import_fields_array[$r]=array('pr.fk_product'=>"ProductRowid*",
'pr.price_base_type'=>"PriceLevelPriceBase",'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*');
$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');
if (! empty($conf->global->PRODUIT_MULTIPRICES))
{
// Import product multiprice
$r++;
$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'=>"ProductRowid*",
'pr.price_base_type'=>"PriceLevelPriceBase",'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*');
$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');
}
}
......
......@@ -168,6 +168,35 @@ class modService extends DolibarrModules
$this->export_sql_end[$r] .=' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity("product", 1).')';
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;
$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'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC",
'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC",
'pr.tva_tx'=>'PriceLevelVATRate',
'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",
'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC",
'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).')';
}
}
// Imports
//--------
$r=0;
......@@ -196,6 +225,64 @@ class modService extends DolibarrModules
$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.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]$');
$this->import_examplevalues_array[$r]=array('p.ref'=>"PR123456",'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');
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 into module product)
$r++;
$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('sp.fk_product'=>"ProductOrService*",
'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
'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",
'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'
);
}
if (! empty($conf->global->PRODUIT_MULTIPRICES))
{
// Import product multiprice
$r++;
$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'=>"ProductRowid*",
'pr.price_base_type'=>"PriceLevelPriceBase",'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*');
$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');
}
}
}
......
......@@ -352,10 +352,13 @@ if ($step == 1 || ! $datatoimport)
{
foreach ($objimport->array_import_code as $key => $value)
{
//var_dump($objimport->array_import_code[$key]);
$val=!$val;
print '<tr '.$bc[$val].'><td nospan="nospan">';
//print img_object($objimport->array_import_module[$key]->getName(),$import->array_import_module[$key]->picto).' ';
print $objimport->array_import_module[$key]->getName();
$titleofmodule=$objimport->array_import_module[$key]->getName();
// Special cas for import common to module/services
if (in_array($objimport->array_import_code[$key], array('produit_supplierprices','produit_multiprice'))) $titleofmodule=$langs->trans("ProductOrService");
print $titleofmodule;
print '</td><td>';
//print $value;
print img_object($objimport->array_import_module[$key]->getName(),$objimport->array_import_icon[$key]).' ';
......@@ -407,8 +410,10 @@ if ($step == 2 && $datatoimport)
// Module
print '<tr><td width="25%">'.$langs->trans("Module").'</td>';
print '<td>';
//print img_object($objimport->array_import_module[0]->getName(),$objimport->array_import_module[0]->picto).' ';
print $objimport->array_import_module[0]->getName();
$titleofmodule=$objimport->array_import_module[0]->getName();
// Special cas for import common to module/services
if (in_array($objimport->array_import_code[0], array('produit_supplierprices','produit_multiprice'))) $titleofmodule=$langs->trans("ProductOrService");
print $titleofmodule;
print '</td></tr>';
// Lot de donnees a importer
......@@ -490,8 +495,10 @@ if ($step == 3 && $datatoimport)
// Module
print '<tr><td width="25%">'.$langs->trans("Module").'</td>';
print '<td>';
//print img_object($objimport->array_import_module[0]->getName(),$objimport->array_import_module[0]->picto).' ';
print $objimport->array_import_module[0]->getName();
$titleofmodule=$objimport->array_import_module[0]->getName();
// Special cas for import common to module/services
if (in_array($objimport->array_import_code[0], array('produit_supplierprices','produit_multiprice'))) $titleofmodule=$langs->trans("ProductOrService");
print $titleofmodule;
print '</td></tr>';
// Lot de donnees a importer
......@@ -695,8 +702,10 @@ if ($step == 4 && $datatoimport)
// Module
print '<tr><td width="25%">'.$langs->trans("Module").'</td>';
print '<td>';
//print img_object($objimport->array_import_module[0]->getName(),$objimport->array_import_module[0]->picto).' ';
print $objimport->array_import_module[0]->getName();
$titleofmodule=$objimport->array_import_module[0]->getName();
// Special cas for import common to module/services
if (in_array($objimport->array_import_code[0], array('produit_supplierprices','produit_multiprice'))) $titleofmodule=$langs->trans("ProductOrService");
print $titleofmodule;
print '</td></tr>';
// Lot de donnees a importer
......@@ -1144,8 +1153,10 @@ if ($step == 5 && $datatoimport)
// Module
print '<tr><td width="25%">'.$langs->trans("Module").'</td>';
print '<td>';
//print img_object($objimport->array_import_module[0]->getName(),$objimport->array_import_module[0]->picto).' ';
print $objimport->array_import_module[0]->getName();
$titleofmodule=$objimport->array_import_module[0]->getName();
// Special cas for import common to module/services
if (in_array($objimport->array_import_code[0], array('produit_supplierprices','produit_multiprice'))) $titleofmodule=$langs->trans("ProductOrService");
print $titleofmodule;
print '</td></tr>';
// Lot de donnees a importer
......@@ -1487,8 +1498,10 @@ if ($step == 6 && $datatoimport)
// Module
print '<tr><td width="25%">'.$langs->trans("Module").'</td>';
print '<td>';
//print img_object($objimport->array_import_module[0]->getName(),$objimport->array_import_module[0]->picto).' ';
print $objimport->array_import_module[0]->getName();
$titleofmodule=$objimport->array_import_module[0]->getName();
// Special cas for import common to module/services
if (in_array($objimport->array_import_code[0], array('produit_supplierprices','produit_multiprice'))) $titleofmodule=$langs->trans("ProductOrService");
print $titleofmodule;
print '</td></tr>';
// Lot de donnees a importer
......
......@@ -179,6 +179,7 @@ ProductIsUsed=This product is used
NewRefForClone=Ref. of new product/service
CustomerPrices=Customers prices
SuppliersPrices=Suppliers prices
SuppliersPricesOfProductsOrServices=Suppliers prices (of products or services)
CustomCode=Customs code
CountryOrigin=Origin country
HiddenIntoCombo=Hidden into select lists
......@@ -208,6 +209,7 @@ CostPmpHT=Net total VWAP
ProductUsedForBuild=Auto consumed by production
ProductBuilded=Production completed
ProductsMultiPrice=Product multi-price
ProductsOrServiceMultiPrice=Customers prices (of products or services, multi-prices)
ProductSellByQuarterHT=Products turnover quarterly VWAP
ServiceSellByQuarterHT=Services turnover quarterly VWAP
Quarter1=1st. Quarter
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment