Merge pull request #10261 from torvista/import

Changes for csv import of Third Parties and Products
This commit is contained in:
Laurent Destailleur 2018-12-22 18:40:37 +01:00 committed by GitHub
commit afac151793
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 516 additions and 167 deletions

View File

@ -143,8 +143,8 @@ class modProduct extends DolibarrModules
// Menus
//-------
$this->menu = 1; // This module add menu entries. They are coded into menu manager.
/* We can't enable this here because it must be enabled in both product and service module and this create duplicate insert
$this->menu = 1; // This module adds menu entries. They are coded into menu manager.
/* We can't enable this here because it must be enabled in both product and service module and this creates duplicate inserts
$r=0;
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'left', // This is a Left menu entry
@ -295,20 +295,49 @@ class modProduct extends DolibarrModules
//--------
$r=0;
// Import list of products
$r++;
$this->import_code[$r]=$this->rights_class.'_'.$r;
$this->import_label[$r]="Products"; // Translation key
$this->import_icon[$r]=$this->picto;
$this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon
$this->import_entities_array[$r]=array(); // We define here only fields that use a different icon from the one defined in import_icon
$this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product','extra'=>MAIN_DB_PREFIX.'product_extrafields');
$this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id
$this->import_fields_array[$r]=array(
'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'=>'VATRate', 'p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation'
$this->import_fields_array[$r]=array(//field order as per structure of table llx_product
'p.ref' => "Ref*",
'p.datec' => 'DateCreation',
'p.label' => "Label*",
'p.description' => "Description",
'p.note_public' => "PublicNote",//public note
'p.note' => "PrivateNote",//private note
'p.customcode' => 'CustomCode',
'p.price' => "SellingPriceHT",//without tax
'p.price_ttc' => "SellingPriceTTC",//with tax
'p.price_base_type' => "PriceBaseType",//price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card
'p.tva_tx' => 'VATRate',
'p.tosell' => "OnSell*",
'p.tobuy' => "OnBuy*",
'p.fk_product_type' => "Type*",
'p.duration' => "Duration",///duration of service
'p.url' => "PublicUrl",
'p.accountancy_code_sell' => "ProductAccountancySellCode",
'p.accountancy_code_buy' => "ProductAccountancyBuyCode",
'p.weight' => "Weight",
'p.length' => "Length",
'p.width' => "Width",
'p.height' => "Height",
'p.surface' => "Surface",
'p.volume' => "Volume",
'p.finished' => 'Nature'
);
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->stock->enabled)) {//if Stock module enabled
$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
'p.seuil_stock_alerte' => 'StockLimit',//lower limit for warning
'p.pmp' => 'PMPValue',//weighted average price
'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature
));
}
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'));
@ -331,14 +360,64 @@ class modProduct extends DolibarrModules
}
// 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.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'=>"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.recuperableonly'=>'0 or 1');
$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]$'
);
$import_sample = array(//field order as per structure of table llx_product
'p.ref' => "PREF123456",
'p.datec' => 'formatted as '.dol_print_date(dol_now(),'%Y-%m-%d'),
'p.label' => "Product name in default language",
'p.description' => "Product description in default language",
'p.note_public' => "a public note (free text)",
'p.note' => "a private note (free text)",
'p.customcode' => 'customs code',
'p.price' => "price ex-vat eg. 100",
'p.price_ttc' => "price inc-vat eg. 110",
'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)",
'p.tva_tx' => 'tax rate eg: 10. Must match numerically one of the tax rates defined for your country',
'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)",
'p.tobuy' => "0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)",
'p.fk_product_type' => "0 (product) / 1 (service)",
'p.duration' => "eg. 365d/12m/1y",
'p.url' => 'link to product (no https)',
'p.accountancy_code_sell' => "",
'p.accountancy_code_buy' => "",
'p.weight' => "",
'p.length' => "",
'p.width' => "",
'p.height' => "",
'p.surface' => "",
'p.volume' => "",
'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(
'p.seuil_stock_alerte' => 'quantity for low-stock warning (empty for no warning)',
'p.pmp' => '0 (default)',
'p.desiredstock' => 'target quantity to maintain in stock (for replenishment feature)'
));
if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample=array_merge($import_sample,array('p.cost_price'=>'user-editable, used for margin calculations only'));
if (is_object($mysoc) && $mysoc->useNPR()) $import_sample=array_merge($import_sample,array('p.recuperableonly'=>'0 / 1 (French VAT NPR yes/no'));
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. 1/2/3 etc....matches field "rowid" in table "'.MAIN_DB_PREFIX.'c_units"'));
$this->import_examplevalues_array[$r]=array_merge($import_sample,$import_extrafield_sample);
$this->import_updatekeys_array[$r]=array('p.ref'=>'Ref','p.barcode'=>'BarCode');
$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->fournisseur->enabled))
{
// Import suppliers prices (note: this code is duplicated into module service)
// Import suppliers prices (note: this code is duplicated in module Service)
$r++;
$this->import_code[$r]=$this->rights_class.'_supplierprices';
$this->import_label[$r]="SuppliersPricesOfProductsOrServices"; // Translation key
@ -346,9 +425,15 @@ class modProduct 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('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.default_vat_code'=>'VATCode'
$this->import_fields_array[$r]=array(//field order as per structure of table llx_product_fournisseur_price, without optional fields
'sp.fk_product'=>"ProductOrService*",
'sp.fk_soc' => "Supplier*",
'sp.ref_fourn' => 'SupplierRef',
'sp.quantity' => "QtyMin*",
'sp.tva_tx' => 'VATRate',
'sp.default_vat_code' => 'VATCode',
'sp.delivery_time_days' => 'DeliveryDelay',
'sp.supplier_reputation' => 'SupplierReputation'
);
if (is_object($mysoc) && $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'));
@ -358,22 +443,60 @@ class modProduct extends DolibarrModules
'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty
'sp.remise_percent'=>'DiscountQtyMin'
));
if ($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',
));
}
$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'
$this->import_examplevalues_array[$r]=array(
'sp.fk_product' => "My Ref. eg: PREF123456",
'sp.fk_soc' => "My Supplier",
'sp.ref_fourn' => "eg: XYZ-F123456",
'sp.quantity' => "eg: 5",
'sp.tva_tx' => 'one of the defined rates eg. 21',
'sp.default_vat_code' => '',
'sp.delivery_time_days' => 'eg. 5',
'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER'
);
if (is_object($mysoc) && $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' => "eg. 50.00",
'sp.unitprice' => 'eg. 10',
// TODO Make this field not required and calculate it from price and qty
'sp.remise_percent' => 'eg: 20'
));
if ($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'=>'eg: GBP',
'sp.multicurrency_tx'=>'currency rate eg: 1.12345',
'sp.multicurrency_unitprice'=>'cost per unit in supplier currency',
// TODO Make this field not required and calculate it from price and qty
'sp.multicurrency_price'=>'cost for min quantity in supplier currency'
));
}
$this->import_updatekeys_array[$r]=array('sp.fk_product'=>'ProductOrService','sp.ref_fourn'=>'SupplierRef','sp.fk_soc'=>'Supplier');
}
if (! empty($conf->global->PRODUIT_MULTIPRICES))
{
// Import product multiprice
// Import products multiprices
$r++;
$this->import_code[$r]=$this->rights_class.'_multiprice';
$this->import_label[$r]="ProductsOrServiceMultiPrice"; // Translation key
@ -400,6 +523,7 @@ class modProduct extends DolibarrModules
if (! empty($conf->global->MAIN_MULTILANGS))
{
// Import translations of product names and descriptions
$r++;
$this->import_code[$r]=$this->rights_class.'_languages';
$this->import_label[$r]="ProductsOrServicesTranslations";

View File

@ -261,11 +261,11 @@ class modSociete extends DolibarrModules
$this->export_icon[$r]='company';
$this->export_permission[$r]=array(array("societe","export"));
$this->export_fields_array[$r]=array(
's.rowid'=>"Id",'s.nom'=>"Name",'s.name_alias'=>"AliasNames",'s.status'=>"Status",'s.client'=>"Customer",'s.fournisseur'=>"Supplier",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification",
's.rowid'=>"Id",'s.nom'=>"Name",'s.name_alias'=>"AliasNameShort",'s.status'=>"Status",'s.client'=>"Customer",'s.fournisseur'=>"Supplier",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification",
's.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",'s.code_compta'=>"AccountancyCode",'s.code_compta_fournisseur'=>"SupplierAccountancyCode",
's.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"Town",'d.nom'=>'State','c.label'=>"Country",'c.code'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax",
's.url'=>"Url",'s.email'=>"Email",'s.default_lang'=>"DefaultLang",'s.siren'=>"ProfId1",'s.siret'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",
's.idprof5'=>"ProfId5",'s.idprof6'=>"ProfId6",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note_private'=>"NotePrivate",'s.note_public'=>"NotePublic",'s.canvas'=>"Canvas",
's.idprof5'=>"ProfId5",'s.idprof6'=>"ProfId6",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note_private'=>"NotePrivate",'s.note_public'=>"NotePublic",
't.libelle'=>"ThirdPartyType",'ce.code'=>"Staff","cfj.libelle"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel',
'st.code'=>'ProspectStatus','payterm.libelle'=>'PaymentConditions','paymode.libelle'=>'PaymentMode'
);
@ -280,7 +280,7 @@ class modSociete extends DolibarrModules
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$this->export_fields_array[$r]+=array('u.login'=>'SaleRepresentativeLogin','u.firstname'=>'SaleRepresentativeFirstname', 'u.lastname'=>'SaleRepresentativeLastname');
//$this->export_TypeFields_array[$r]=array(
// 's.rowid'=>"List:societe:nom", 's.nom'=>"Text", 's.name_alias'=>"Text", 's.status'=>"Text",'s.client'=>"Boolean",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date",
// 's.rowid'=>"List:societe:nom",'s.nom'=>"Text",'s.status'=>"Text",'s.client'=>"Boolean",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date",
// 's.code_client'=>"Text",'s.code_fournisseur'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'c.label'=>"List:c_country:label:label",
// 'c.code'=>"Text",'s.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",'s.default_lang'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text",
// 's.ape'=>"Text",'s.idprof4'=>"Text",'s.idprof5'=>"Text",'s.idprof6'=>"Text",'s.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note'=>"Text",
@ -288,11 +288,11 @@ class modSociete extends DolibarrModules
// 's.fk_stcomm'=>'List:c_stcomm:libelle:code','d.nom'=>'List:c_departements:nom:rowid'
//);
$this->export_TypeFields_array[$r]=array(
's.rowid'=>"Numeric", 's.nom'=>"Text", 's.name_alias'=>"Text", 's.status'=>"Numeric",'s.client'=>"Numeric",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date",
's.rowid'=>"Numeric", 's.nom'=>"Text",'s.name_alias'=>"Text",'s.status'=>"Numeric",'s.client'=>"Numeric",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date",
's.code_client'=>"Text",'s.code_fournisseur'=>"Text",'s.code_compta'=>"Text",'s.code_compta_fournisseur'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",
's.town'=>"Text",'c.label'=>"List:c_country:label:label",'c.code'=>"Text",'s.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",
's.default_lang'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text",'s.ape'=>"Text",'s.idprof4'=>"Text",'s.idprof5'=>"Text",'s.idprof6'=>"Text",
's.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note_private'=>"Text",'s.note_public'=>"Text",'s.canvas'=>"Text",'t.libelle'=>"Text",
's.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note_private'=>"Text",'s.note_public'=>"Text",'t.libelle'=>"Text",
'ce.code'=>"List:c_effectif:libelle:code","cfj.libelle"=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code',
'st.code'=>'List:c_stcomm:libelle:code','d.nom'=>'Text','u.login'=>'Text','u.firstname'=>'Text','u.lastname'=>'Text','payterm.libelle'=>'Text',
'paymode.libelle'=>'Text','s.entity'=>'Numeric'
@ -374,122 +374,333 @@ class modSociete extends DolibarrModules
}
// Imports
//--------
$r=0;
// Imports
//--------
$r = 0;
// Import list of third parties and attributes
$r++;
$this->import_code[$r]=$this->rights_class.'_'.$r;
$this->import_label[$r]='ImportDataset_company_1';
$this->import_icon[$r]='company';
$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('s'=>MAIN_DB_PREFIX.'societe','extra'=>MAIN_DB_PREFIX.'societe_extrafields'); // List of tables to insert into (insert done in same order)
$this->import_fields_array[$r]=array(
's.nom'=>"Name*", 's.name_alias'=>"Alias", 's.status'=>"Status",'s.client'=>"Customer*",'s.fournisseur'=>"Supplier*",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",
's.code_compta'=>"CustomerAccountancyCode",'s.code_compta_fournisseur'=>"SupplierAccountancyCode",'s.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"Town",
's.fk_departement'=>"StateId",'s.fk_pays'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",'s.siren'=>"ProfId1",
's.siret'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.idprof5'=>"ProfId5",'s.idprof6'=>"ProfId6",'s.tva_intra'=>"VATIntraShort",
's.capital'=>"Capital",'s.note_private'=>"NotePrivate",'s.note_public'=>"NotePublic",'s.canvas'=>"Canvas",'s.fk_typent'=>"ThirdPartyType",'s.fk_effectif'=>"Staff",
"s.fk_forme_juridique"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel','s.fk_stcomm'=>'ProspectStatus','s.default_lang'=>'DefaultLanguage',
's.barcode'=>'BarCode','s.datec'=>"DateCreation"
);
// Add extra fields
$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' 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))
{
$fieldname='extra.'.$obj->name;
$fieldlabel=ucfirst($obj->label);
$this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
}
}
// End add extra fields
$this->import_fieldshidden_array[$r]=array('s.fk_user_creat'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'societe'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this->import_convertvalue_array[$r]=array(
's.fk_typent'=>array('rule'=>'fetchidfromcodeorlabel','classfile'=>'/core/class/ctypent.class.php','class'=>'Ctypent','method'=>'fetch','dict'=>'DictionaryCompanyType'),
's.fk_departement'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/cstate.class.php','class'=>'Cstate','method'=>'fetch','dict'=>'DictionaryState'),
's.fk_pays'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry'),
's.fk_stcomm'=>array('rule'=>'zeroifnull'),
's.code_client'=>array('rule'=>'getcustomercodeifauto'),
's.code_fournisseur'=>array('rule'=>'getsuppliercodeifauto'),
's.code_compta'=>array('rule'=>'getcustomeraccountancycodeifauto'),
's.code_compta_fournisseur'=>array('rule'=>'getsupplieraccountancycodeifauto'),
's.capital'=>array('rule'=>'numeric')
);
//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
$this->import_regex_array[$r]=array('s.status'=>'^[0|1]','s.client'=>'^[0|1|2|3]','s.fournisseur'=>'^[0|1]','s.fk_typent'=>'id@'.MAIN_DB_PREFIX.'c_typent','s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$');
$this->import_examplevalues_array[$r]=array(
's.nom'=>"MyBigCompany", 's.name_alias'=>"MyBigAlias", 's.status'=>"0 (closed) or 1 (active)",'s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)',
's.fournisseur'=>'0 or 1','s.datec'=>dol_print_date(dol_now(),'%Y-%m-%d'),'s.code_client'=>'CU01-0001 or empty or "auto"','s.code_fournisseur'=>'SU01-0001 or empty or "auto"',
's.address'=>"61 jump street",'s.zip'=>"123456",'s.town'=>"Big town",'s.fk_pays'=>'US, FR, DE...','s.phone'=>"0101010101",'s.fax'=>"0101010102",
's.url'=>"http://mycompany.com",'s.email'=>"test@mycompany.com",'s.siret'=>"",'s.siren'=>"",'s.ape'=>"",'s.idprof4'=>"",'s.idprof5'=>"",'s.idprof6'=>"",
's.tva_intra'=>"FR0123456789",'s.capital'=>"10000",'s.note_private'=>"This is an example of private note for record",'s.note_public'=>"This is an example of public note for record",
's.fk_typent'=>"2",'s.fk_effectif'=>"3","s.fk_forme_juridique"=>"1",'s.fk_prospectlevel'=>'PL_MEDIUM','s.fk_stcomm'=>'0','s.default_lang'=>'en_US','s.barcode'=>'123456789',
's.datec'=>"2015-01-01 or 2015-01-01 12:30:00"
);
$this->import_updatekeys_array[$r]=array('s.nom'=>'Name','s.code_client'=>'CustomerCode','s.code_fournisseur'=>'SupplierCode','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode');
// Import list of third parties and attributes
// Import list of contact and attributes
$r++;
$this->import_code[$r]=$this->rights_class.'_'.$r;
$this->import_label[$r]='ImportDataset_company_2';
$this->import_icon[$r]='contact';
$this->import_entities_array[$r]=array('s.fk_soc'=>'company'); // We define here only fields that use another icon that the one defined into import_icon
$this->import_tables_array[$r]=array('s'=>MAIN_DB_PREFIX.'socpeople','extra'=>MAIN_DB_PREFIX.'socpeople_extrafields'); // List of tables to insert into (insert done in same order)
$this->import_fields_array[$r]=array(
's.fk_soc'=>'ThirdPartyName','s.civility'=>'UserTitle','s.lastname'=>"Lastname*",'s.firstname'=>"Firstname",'s.address'=>"Address",'s.zip'=>"Zip",
's.town'=>"Town",'s.fk_departement'=>"StateId",'s.fk_pays'=>"CountryCode",'s.birthday'=>"BirthdayDate",'s.poste'=>"Role",'s.phone'=>"Phone",'s.phone_perso'=>"PhonePerso",
's.phone_mobile'=>"PhoneMobile",'s.fax'=>"Fax",'s.email'=>"Email",'s.note_private'=>"Note",'s.note_public'=>"Note",'s.datec'=>"DateCreation"
);
// Add extra fields
$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' 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))
{
$fieldname='extra.'.$obj->name;
$fieldlabel=ucfirst($obj->label);
$this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
}
}
// End add extra fields
$this->import_fieldshidden_array[$r]=array('s.fk_user_creat'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'socpeople'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this->import_convertvalue_array[$r]=array(
's.fk_soc'=>array('rule'=>'fetchidfromref','file'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'),
's.fk_departement'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/cstate.class.php','class'=>'Cstate','method'=>'fetch','dict'=>'DictionaryState'),
's.fk_pays'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry'),
);
//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
$this->import_regex_array[$r]=array('s.birthday'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$');
$this->import_examplevalues_array[$r]=array(
's.fk_soc'=>'MyBigCompany','s.civility'=>"MR",'s.lastname'=>"Smith",'s.firstname'=>'John','s.address'=>'61 jump street','s.zip'=>'75000',
's.town'=>'Bigtown','s.fk_pays'=>'US, FR, DE...','s.datec'=>'1972-10-10','s.poste'=>"Director",'s.phone'=>"5551122",'s.phone_perso'=>"5551133",
's.phone_mobile'=>"5551144",'s.fax'=>"5551155",'s.email'=>"johnsmith@email.com",'s.note_private'=>"My private note",'s.note_public'=>"My public note"
);
$r++;
$this->import_code[$r] = $this->rights_class . '_' . $r;
$this->import_label[$r] = 'ImportDataset_company_1';
$this->import_icon[$r] = 'company';
$this->import_entities_array[$r] = array(); // We define here only fields that use a different icon from the one defined in import_icon
$this->import_tables_array[$r] = array(
's' => MAIN_DB_PREFIX . 'societe',
'extra' => MAIN_DB_PREFIX . 'societe_extrafields'
); // List of tables to insert into (insert done in same order)
$this->import_fields_array[$r] = array(//field order as per structure of table llx_societe
's.nom' => "Name*",
's.name_alias' => "AliasNameShort",
's.status' => "Status",
's.code_client' => "CustomerCode",
's.code_fournisseur' => "SupplierCode",
's.code_compta' => "CustomerAccountancyCode",
's.code_compta_fournisseur' => "SupplierAccountancyCode",
's.address' => "Address",
's.zip' => "Zip",
's.town' => "Town",
's.fk_departement' => "StateId",
's.fk_pays' => "CountryCode",
's.phone' => "Phone",
's.fax' => "Fax",
's.url' => "Url",
's.email' => "Email",
's.skype' => "Skype",
's.fk_effectif' => "Staff",
's.fk_typent' => "ThirdPartyType",
"s.fk_forme_juridique" => "JuridicalStatus",
's.siren' => "ProfId1",
's.siret' => "ProfId2",
's.ape' => "ProfId3",
's.idprof4' => "ProfId4",
's.idprof5' => "ProfId5",
's.idprof6' => "ProfId6",
's.tva_intra' => "VATIntraShort",
's.capital' => "Capital",
's.fk_stcomm' => 'ProspectStatus',
's.note_private' => "NotePrivate",
's.note_public' => "NotePublic",
's.client' => "Customer*",
's.fournisseur' => "Supplier*",
's.fk_prospectlevel' => 'ProspectLevel',
's.mode_reglement' => 'PaymentTypeCustomer',
's.cond_reglement' => "PaymentTermsCustomer",
's.mode_reglement_supplier' => 'PaymentTypeSupplier',
's.cond_reglement_supplier' => "PaymentTermsSupplier",
's.tva_assuj' => 'VATIsUsed',
's.barcode' => 'BarCode',
's.default_lang' => 'DefaultLanguage',
's.canvas' => "Canvas",
's.datec' => "DateCreation",
's.fk_multicurrency' => 'MulticurrencyUsed',
's.multicurrency_code' => 'MulticurrencyCurrency'
);
// Add extra fields
$sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE elementtype = 'societe' AND entity = " . $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)) {
$fieldname = 'extra.' . $obj->name;
$fieldlabel = ucfirst($obj->label);
$this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ? '*' : '');
}
}
// End add extra fields
$this->import_fieldshidden_array[$r] = array(
's.fk_user_creat' => 'user->id',
'extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'societe'
); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this->import_convertvalue_array[$r] = array(//field order as per structure of table llx_societe
's.code_client' => array('rule' => 'getcustomercodeifauto'),
's.code_fournisseur' => array('rule' => 'getsuppliercodeifauto'),
's.code_compta' => array('rule' => 'getcustomeraccountancycodeifauto'),
's.code_compta_fournisseur' => array('rule' => 'getsupplieraccountancycodeifauto'),
's.fk_departement' => array(
'rule' => 'fetchidfromcodeid',
'classfile' => '/core/class/cstate.class.php',
'class' => 'Cstate',
'method' => 'fetch',
'dict' => 'DictionaryState'
),
's.fk_pays' => array(
'rule' => 'fetchidfromcodeid',
'classfile' => '/core/class/ccountry.class.php',
'class' => 'Ccountry',
'method' => 'fetch',
'dict' => 'DictionaryCountry'
),
's.fk_typent' => array(
'rule' => 'fetchidfromcodeorlabel',
'classfile' => '/core/class/ctypent.class.php',
'class' => 'Ctypent',
'method' => 'fetch',
'dict' => 'DictionaryCompanyType'
),
's.capital' => array('rule' => 'numeric'),
's.fk_stcomm' => array('rule' => 'zeroifnull'),
);
//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
$this->import_regex_array[$r] = array(//field order as per structure of table llx_societe
's.status' => '^[0|1]',
's.fk_typent' => 'id@' . MAIN_DB_PREFIX . 'c_typent',
's.client' => '^[0|1|2|3]',
's.fournisseur' => '^[0|1]',
's.mode_reglement' => 'id@' . MAIN_DB_PREFIX . 'c_paiement',
's.cond_reglement' => 'rowid@' . MAIN_DB_PREFIX . 'c_payment_term',
's.mode_reglement_supplier' => 'id@' . MAIN_DB_PREFIX . 'c_paiement',
's.cond_reglement_supplier' => 'rowid@' . MAIN_DB_PREFIX . 'c_payment_term',
's.tva_assuj' => '^[0|1]',
's.fk_multicurrency' => '^[0|1]',
's.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$',
's.multicurrency_code' => 'code_iso@' . MAIN_DB_PREFIX . 'c_currencies'
);
// Import Bank Accounts
$r++;
$this->import_code[$r]=$this->rights_class.'_'.$r;
$this->import_label[$r]="ImportDataset_company_3"; // Translation key
$this->import_icon[$r]='company';
$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('sr'=>MAIN_DB_PREFIX.'societe_rib');
$this->import_fields_array[$r]=array('sr.fk_soc'=>"ThirdPartyName*",'sr.bank'=>"Bank",
'sr.code_banque'=>"BankCode",'sr.code_guichet'=>"DeskCode",'sr.number'=>"BankAccountNumber*",
'sr.cle_rib'=>"BankAccountNumberKey",'sr.bic'=>"BIC",'sr.iban_prefix'=>"IBAN", 'sr.domiciliation'=>"BankAccountDomiciliation",'sr.proprio' => "BankAccountOwner", 'sr.owner_address' => "BankAccountOwnerAddress", 'sr.default_rib' => 'Default'
);
$this->import_examplevalues_array[$r] = array(//field order as per structure of table llx_societe
's.nom' => "TPBigCompany",
's.name_alias' => "Alias for TPBigCompany",
's.status' => "0 (closed) / 1 (active)",
's.code_client' => 'eg. CU01-0001 / empty / "auto"',
's.code_fournisseur' => 'eg. SU01-0001 / empty / "auto"',
's.code_compta' => "Code or empty to be auto-created",
's.code_compta_fournisseur' => "Code or empty to be auto-created",
's.address' => "61 Jump Street",
's.zip' => "123456",
's.town' => "Bigtown",
's.fk_departement' => 'matches field "code_departement" in table "' . MAIN_DB_PREFIX . 'c_departements"',
's.fk_pays' => 'US/FR/DE etc. matches field "code" in table "' . MAIN_DB_PREFIX . 'c_country"',
's.phone' => "eg: +34123456789",
's.fax' => "eg. +34987654321",
's.url' => "e.g. https://www.mybigcompany.com",
's.email' => "e.g. test@mybigcompany.com",
's.skype' => "Skype name",
's.fk_effectif' => "1/2/3/5: represents one of the five ranges of employees",
's.fk_typent' => 'matches field "id" (1-9 etc.) OR "code" (TE_SMALL etc.) in table "' . MAIN_DB_PREFIX . 'c_typent"',
's.fk_forme_juridique' => '1/2/3 etc...matches field "code" in table "' . MAIN_DB_PREFIX . 'c_forme_juridique"',
's.siret' => "",
's.siren' => "",
's.ape' => "",
's.idprof4' => "",
's.idprof5' => "",
's.idprof6' => "",
's.tva_intra' => 'VAT number e.g."FR0123456789"',
's.capital' => "10000",
's.fk_stcomm' => '-1/0/1/2 etc... matches field "id" in table "' . MAIN_DB_PREFIX . 'c_stcomm"',
's.note_private' => "Example of a PRIVATE note.",
's.note_public' => "Example of a PUBLIC note.",
's.client' => '0 (no customer no prospect) / 1 (customer) / 2 (prospect)/ 3 (customer and prospect)',
's.fournisseur' => '0 (not supplier) / 1 (supplier)',
's.fk_prospectlevel' => 'eg. "PL_MEDIUM" matches field "code" in table "' . MAIN_DB_PREFIX . 'c_prospectlevel"',
's.mode_reglement' => '1/2/3...matches field "id" in table "' . MAIN_DB_PREFIX . 'c_paiement"',
's.cond_reglement' => '1/2/3...matches field "rowid" in table "' . MAIN_DB_PREFIX . 'c_payment_term"',
's.mode_reglement_supplier' => '1/2/3...matches field "id" in table "' . MAIN_DB_PREFIX . 'c_paiement"',
's.cond_reglement_supplier' => '1/2/3...matches field "rowid" in table "' . MAIN_DB_PREFIX . 'c_payment_term"',
's.tva_assuj' => '0 (VAT not used) / 1 (VAT used)',
's.barcode' => '123456789',
's.default_lang' => 'en_US / es_ES etc...matches a language directory in htdocs/langs/',
's.canvas' => "empty / a custom canvas form layout url e.g. mycanvas@mymodule",
's.datec' => 'formatted as ' . dol_print_date(dol_now(), '%Y-%m-%d'),
's.fk_multicurrency' => '0 (use system default currency) / 1 (use local currency)',
's.multicurrency_code' => 'GBP/USD etc... matches field "code_iso" in table "' . MAIN_DB_PREFIX . 'c_currencies"'
);
$this->import_updatekeys_array[$r] = array(
's.nom' => 'Name',
's.code_client' => 'CustomerCode',
's.code_fournisseur' => 'SupplierCode',
's.code_compta' => 'CustomerAccountancyCode',
's.code_compta_fournisseur' => 'SupplierAccountancyCode'
);
$this->import_convertvalue_array[$r]=array(
'sr.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty')
);
$this->import_examplevalues_array[$r]=array('sr.fk_soc'=>"MyBigCompany",'sr.bank'=>"ING",
'sr.code_banque'=>"0000", 'sr.code_guichet'=>"1111",'sr.number'=>"3333333333",
'sr.cle_rib'=>"22",'sr.bic'=>"USHINGMMXXX",'sr.iban_prefix'=>"US00 0000 1111 22 3333 3333",'sr.domiciliation'=>"PARIS",'sr.proprio' => "Name of owner", 'sr.owner_address' => "15 paris street 75000 Paris", 'sr.default_rib' => '1 or 0'
);
// Import list of contacts/additional addresses and attributes
$r++;
$this->import_code[$r] = $this->rights_class . '_' . $r;
$this->import_label[$r] = 'ImportDataset_company_2';
$this->import_icon[$r] = 'contact';
$this->import_entities_array[$r] = array('s.fk_soc' => 'company'); // We define here only fields that use a different icon than the one defined in import_icon
$this->import_tables_array[$r] = array(
's' => MAIN_DB_PREFIX . 'socpeople',
'extra' => MAIN_DB_PREFIX . 'socpeople_extrafields'
); // List of tables to insert into (insert done in same order)
$this->import_fields_array[$r] = array(//field order as per structure of table llx_socpeople
's.datec' => "DateCreation",
's.fk_soc' => 'ThirdPartyName',
's.civility' => 'UserTitle',
's.lastname' => "Lastname*",
's.firstname' => "Firstname",
's.address' => "Address",
's.zip' => "Zip",
's.town' => "Town",
's.fk_departement' => "StateId",
's.fk_pays' => "CountryCode",
's.birthday' => "BirthdayDate",
's.poste' => "Role",
's.phone' => "Phone",
's.phone_perso' => "PhonePerso",
's.phone_mobile' => "PhoneMobile",
's.fax' => "Fax",
's.email' => "Email",
's.skype' => "Skype",
's.note_private' => "NotePrivate",
's.note_public' => "NotePublic"
);
// Add extra fields
$sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE elementtype = 'socpeople' AND entity = " . $conf->entity;
$resql = $this->db->query($sql);
if ($resql) // This can fail when class is used on an old database (during a 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 ? '*' : '');
}
}
// End add extra fields
$this->import_fieldshidden_array[$r] = array(
's.fk_user_creat' => 'user->id',
'extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'socpeople'
); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this->import_convertvalue_array[$r] = array(
's.fk_soc' => array(
'rule' => 'fetchidfromref',
'file' => '/societe/class/societe.class.php',
'class' => 'Societe',
'method' => 'fetch',
'element' => 'ThirdParty'
),
's.fk_departement' => array(
'rule' => 'fetchidfromcodeid',
'classfile' => '/core/class/cstate.class.php',
'class' => 'Cstate',
'method' => 'fetch',
'dict' => 'DictionaryState'
),
's.fk_pays' => array(
'rule' => 'fetchidfromcodeid',
'classfile' => '/core/class/ccountry.class.php',
'class' => 'Ccountry',
'method' => 'fetch',
'dict' => 'DictionaryCountry'
),
);
//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
$this->import_regex_array[$r] = array(
's.birthday' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
's.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'
);
$this->import_examplevalues_array[$r] = array(//field order as per structure of table llx_socpeople
's.datec' => 'formatted as ' . dol_print_date(dol_now(), '%Y-%m-%d'),
's.fk_soc' => 'Third Party name eg. TPBigCompany',
's.civility' => 'honorific eg: MR...matches field "code" in table "' . MAIN_DB_PREFIX . 'c_civility"',
's.lastname' => "lastname or label",
's.firstname' => 'John',
's.address' => '61 Jump street',
's.zip' => '75000',
's.town' => 'Bigtown',
's.fk_departement' => 'matches field "code_departement" in table "' . MAIN_DB_PREFIX . 'c_departements"',
's.fk_pays' => 'US/FR/DE etc. matches field "code" in table "' . MAIN_DB_PREFIX . 'c_country"',
's.birthday' => 'formatted as ' . dol_print_date(dol_now(), '%Y-%m-%d'),
's.poste' => "Director",
's.phone' => "5551122",
's.phone_perso' => "5551133",
's.phone_mobile' => "5551144",
's.fax' => "5551155",
's.email' => "johnsmith@email.com",
's.skype' => "skype username",
's.note_private' => "My private note",
's.note_public' => "My public note"
);
// Import Bank Accounts
$r++;
$this->import_code[$r] = $this->rights_class . '_' . $r;
$this->import_label[$r] = "ImportDataset_company_3"; // Translation key
$this->import_icon[$r] = 'company';
$this->import_entities_array[$r] = array(); // We define here only fields that use a different icon to the one defined in import_icon
$this->import_tables_array[$r] = array('sr' => MAIN_DB_PREFIX . 'societe_rib');
$this->import_fields_array[$r] = array(//field order as per structure of table llx_societe_rib
'sr.label' => "Label*",
'sr.fk_soc' => "ThirdPartyName*",
'sr.datec' => "DateCreation*",
'sr.bank' => "Bank",
'sr.code_banque' => "BankCode",
'sr.code_guichet' => "DeskCode",
'sr.number' => "BankAccountNumber*",
'sr.cle_rib' => "BankAccountNumberKey",
'sr.bic' => "BIC",
'sr.iban_prefix' => "IBAN",
'sr.domiciliation' => "BankAccountDomiciliation",
'sr.proprio' => "BankAccountOwner",
'sr.owner_address' => "BankAccountOwnerAddress",
'sr.default_rib' => 'Default'
);
$this->import_convertvalue_array[$r] = array(
'sr.fk_soc' => array(
'rule' => 'fetchidfromref',
'classfile' => '/societe/class/societe.class.php',
'class' => 'Societe',
'method' => 'fetch',
'element' => 'ThirdParty'
)
);
$this->import_examplevalues_array[$r] = array(//field order as per structure of table llx_societe_rib
'sr.label' => 'eg. "account1"',
'sr.fk_soc' => 'eg. "TPBigCompany"',
'sr.datec' => 'date used for creating direct debit UMR formatted as ' . dol_print_date(dol_now(),
'%Y-%m-%d'),
'sr.bank' => 'bank name eg: "ING-Direct"',
'sr.code_banque' => 'account sort code (GB)/Routing number (US) eg. "8456"',
'sr.code_guichet' => "bank code for office/branch",
'sr.number' => 'account number eg. "3333333333"',
'sr.cle_rib' => 'account checksum/control digits (if used) eg. "22"',
'sr.bic' => 'bank identifier eg. "USHINGMMXXX"',
'sr.iban_prefix' => 'complete account IBAN eg. "GB78CPBK08925068637123"',
'sr.domiciliation' => 'bank branch address eg. "PARIS"',
'sr.proprio' => 'name on the bank account',
'sr.owner_address' => 'address of account holder',
'sr.default_rib' => '1 (default account) / 0 (not default)'
);
// Import Company Sales representatives
$r++;

View File

@ -358,7 +358,7 @@ if ($step == 1 || ! $datatoimport)
{
//var_dump($objimport->array_import_code[$key]);
$val=!$val;
print '<tr '.$bc[$val].'><td nospan="nospan">';
print '<tr '.$bc[$val].'><td>';
$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','produit_languages'))) $titleofmodule=$langs->trans("ProductOrService");
@ -367,7 +367,7 @@ if ($step == 1 || ! $datatoimport)
//print $value;
print img_object($objimport->array_import_module[$key]->getName(),$objimport->array_import_icon[$key]).' ';
print $objimport->array_import_label[$key];
print '</td><td align="right">';
print '</td><td style="text-align: right">';
if ($objimport->array_import_perms[$key])
{
print '<a href="'.DOL_URL_ROOT.'/imports/import.php?step=2&datatoimport='.$objimport->array_import_code[$key].$param.'">'.img_picto($langs->trans("NewImport"),'filenew').'</a>';
@ -453,9 +453,9 @@ if ($step == 2 && $datatoimport)
print '<td width="16">'.img_picto_common($key,$objmodelimport->getPictoForKey($key)).'</td>';
$text=$objmodelimport->getDriverDescForKey($key);
print '<td>'.$form->textwithpicto($objmodelimport->getDriverLabelForKey($key),$text).'</td>';
print '<td align="center"><a href="'.DOL_URL_ROOT.'/imports/emptyexample.php?format='.$key.$param.'" target="_blank">'.$langs->trans("DownloadEmptyExample").'</a></td>';
print '<td style="text-align:center"><a href="'.DOL_URL_ROOT.'/imports/emptyexample.php?format='.$key.$param.'" target="_blank">'.$langs->trans("DownloadEmptyExample").'</a></td>';
// Action button
print '<td align="right">';
print '<td style="text-align:right">';
print '<a href="'.DOL_URL_ROOT.'/imports/import.php?step=3&format='.$key.$param.'">'.img_picto($langs->trans("SelectFormat"),'filenew').'</a>';
print '</td>';
print '</tr>';
@ -528,7 +528,7 @@ if ($step == 3 && $datatoimport)
print '<td>';
$text=$objmodelimport->getDriverDescForKey($format);
print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format),$text);
print '</td><td align="right" class="nowrap"><a href="'.DOL_URL_ROOT.'/imports/emptyexample.php?format='.$format.$param.'" target="_blank">'.$langs->trans("DownloadEmptyExample").'</a>';
print '</td><td style="text-align:right" class="nowrap"><a href="'.DOL_URL_ROOT.'/imports/emptyexample.php?format='.$format.$param.'" target="_blank">'.$langs->trans("DownloadEmptyExample").'</a>';
print '</td></tr>';
@ -617,14 +617,14 @@ if ($step == 3 && $datatoimport)
print '</a>';
print '</td>';
// Affiche taille fichier
print '<td align="right">'.dol_print_size(dol_filesize($dir.'/'.$file)).'</td>';
print '<td style="text-align:right">'.dol_print_size(dol_filesize($dir.'/'.$file)).'</td>';
// Affiche date fichier
print '<td align="right">'.dol_print_date(dol_filemtime($dir.'/'.$file),'dayhour').'</td>';
print '<td style="text-align:right">'.dol_print_date(dol_filemtime($dir.'/'.$file),'dayhour').'</td>';
// Del button
print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=delete&step=3'.$param.'&urlfile='.urlencode($relativepath);
print '<td style="text-align:right"><a href="'.$_SERVER['PHP_SELF'].'?action=delete&step=3'.$param.'&urlfile='.urlencode($relativepath);
print '">'.img_delete().'</a></td>';
// Action button
print '<td align="right">';
print '<td style="text-align:right">';
print '<a href="'.$_SERVER['PHP_SELF'].'?step=4'.$param.'&filetoimport='.urlencode($relativepath).'">'.img_picto($langs->trans("NewImport"),'filenew').'</a>';
print '</td>';
print '</tr>';
@ -900,15 +900,15 @@ if ($step == 4 && $datatoimport)
print '</td><td width="50%">';
// List of targets fields
$height=24;
// List of target fields
$height='24px';//needs px for css height attribute below
$i = 0;
$mandatoryfieldshavesource=true;
print '<table width="100%" class="nobordernopadding">';
foreach($fieldstarget as $code=>$label)
{
print '<tr class="oddeven" height="'.$height.'">';
print '<tr class="oddeven" style="height:'.$height.'">';
$i++;
$entity=(! empty($objimport->array_import_entities[0][$code])?$objimport->array_import_entities[0][$code]:$objimport->array_import_icon[0]);
@ -934,7 +934,7 @@ if ($step == 4 && $datatoimport)
print $text;
print '</td>';
// Info field
print '<td style="font-weight: normal" align="right">';
print '<td style="font-weight:normal; text-align:right">';
$filecolumn=$array_match_database_to_file[$code];
// Source field info
$htmltext ='<b><u>'.$langs->trans("FieldSource").'</u></b><br>';
@ -1125,7 +1125,7 @@ if ($step == 4 && $datatoimport)
print '</tr>';
print '<tr class="oddeven">';
print '<td><input name="import_name" size="48" value=""></td><td align="right">';
print '<td><input name="import_name" size="48" value=""></td><td style="text-align:right">';
print '<input type="submit" class="button" value="'.$langs->trans("SaveImportProfile").'">';
print '</td></tr>';
@ -1145,7 +1145,7 @@ if ($step == 4 && $datatoimport)
$obj = $db->fetch_object($resql);
print '<tr class="oddeven"><td>';
print $obj->label;
print '</td><td align="right">';
print '</td><td style="text-align:right">';
print '<a href="'.$_SERVER["PHP_SELF"].'?step='.$step.$param.'&action=deleteprof&id='.$obj->rowid.'&filetoimport='.urlencode($filetoimport).'">';
print img_delete();
print '</a>';
@ -1275,14 +1275,14 @@ if ($step == 5 && $datatoimport)
print '</a>';
print '</td></tr>';
// Nb of fields
// Total lines in source file
print '<tr><td>';
print $langs->trans("NbOfSourceLines");
print '</td><td>';
print $nboflines;
print '</td></tr>';
// Lines nb to import
// Range of lines to import
print '<tr><td>';
print $langs->trans("ImportFromToLine");
print '</td><td>';
@ -1310,7 +1310,7 @@ if ($step == 5 && $datatoimport)
if ($action == 'launchsimu') print ' &nbsp; <a href="'.$_SERVER["PHP_SELF"].'?step=5'.$param.'">'.$langs->trans("Modify").'</a>';
print '</td></tr>';
// Keys for update
// Keys for data UPDATE (not INSERT of new data)
print '<tr><td>';
print $langs->trans("KeysToUseForUpdates");
print '</td><td>';
@ -1328,8 +1328,8 @@ if ($step == 5 && $datatoimport)
}
print ' &nbsp; <a href="'.$_SERVER["PHP_SELF"].'?step=5'.$param.'">'.$langs->trans("Modify").'</a>';
} else {
if (count($objimport->array_import_updatekeys[0]))
{
if ($objimport->array_import_updatekeys[0] && count($objimport->array_import_updatekeys[0]))
{//TODO dropdown UL is created inside nested SPANS
print $form->multiselectarray('updatekeys', $objimport->array_import_updatekeys[0], $updatekeys, 0, 0, '', 1, '80%');
print $form->textwithpicto("", $langs->trans("SelectPrimaryColumnsForUpdateAttempt"));
}
@ -1475,7 +1475,7 @@ if ($step == 5 && $datatoimport)
$arrayrecord=$obj->import_read_record();
if ($arrayrecord === false)
{
$arrayofwarnings[$sourcelinenb][0]=array('lib'=>'File has '.$nboflines.' lines. However we reach end of file after record '.$sourcelinenb.'. This may occurs when some records are split onto several lines.','type'=>'EOF_RECORD_ON_SEVERAL_LINES');
$arrayofwarnings[$sourcelinenb][0]=array('lib'=>'File has '.$nboflines.' lines. However we reach end of file after record '.$sourcelinenb.'. This may occurs when some records are split onto several lines. Ensure the complete string is delimited correctly when there is a separator character in the text string.','type'=>'EOF_RECORD_ON_SEVERAL_LINES');
$endoffile++;
continue;
}
@ -1520,11 +1520,11 @@ if ($step == 5 && $datatoimport)
// Show OK
if (! count($arrayoferrors) && ! count($arrayofwarnings)) {
print '<center>'.img_picto($langs->trans("OK"),'tick').' <b>'.$langs->trans("NoError").'</b></center><br><br>';
print '<div class="center">'.img_picto($langs->trans("OK"),'tick').' <b>'.$langs->trans("NoError").'</b></div><br><br>';
print $langs->trans("NbInsert", $obj->nbinsert).'<br>';
print $langs->trans("NbUpdate", $obj->nbupdate).'<br><br>';
}
else print '<b>'.$langs->trans("NbOfLinesOK",$nbok).'</b><br><br>';
else print $langs->trans("NbOfLinesOK",$nbok).'<br><br>';
// Show Errors
//var_dump($arrayoferrors);
@ -1929,15 +1929,22 @@ function show_elem($fieldssource,$pos,$key,$var,$nostyle='')
{
global $langs,$bc;
$height='24';
$height='24px';
if ($key == 'none') {//stop multiple duplicate ids with no number
print "\n\n<!-- Box_no-key start-->\n";
print '<div class="box boximport" style="padding:0;">' . "\n";
print '<table summary="boxtable_no-key" width="100%" class="nobordernopadding">' . "\n";
} else {
print "\n\n<!-- Box ".$pos." start -->\n";
print '<div class="box boximport" style="padding: 0px 0px 0px 0px;" id="boxto_'.$pos.'">'."\n";
print '<div class="box boximport" style="padding: 0;" id="boxto_' . $pos . '">' . "\n";
print '<table summary="boxtable'.$pos.'" width="100%" class="nobordernopadding">'."\n";
}
if ($pos && $pos > count($fieldssource)) // No fields
{
print '<tr '.($nostyle?'':$bc[$var]).' height="'.$height.'">';
print '<tr'.($nostyle?'':' '.$bc[$var]).' style="height:'.$height.'">';
print '<td class="nocellnopadding" width="16" style="font-weight: normal">';
print img_picto(($pos>0?$langs->trans("MoveField",$pos):''),'grip_title','class="boxhandle" style="cursor:move;"');
print '</td>';
@ -1948,7 +1955,7 @@ function show_elem($fieldssource,$pos,$key,$var,$nostyle='')
}
elseif ($key == 'none') // Empty line
{
print '<tr '.($nostyle?'':$bc[$var]).' height="'.$height.'">';
print '<tr'.($nostyle?'':' '.$bc[$var]).' style="height:'.$height.'">';
print '<td class="nocellnopadding" width="16" style="font-weight: normal">';
print '&nbsp;';
print '</td>';
@ -1959,7 +1966,7 @@ function show_elem($fieldssource,$pos,$key,$var,$nostyle='')
}
else // Print field of source file
{
print '<tr '.($nostyle?'':$bc[$var]).' height="'.$height.'">';
print '<tr'.($nostyle?'':' '.$bc[$var]).' style="height:'.$height.'">';
print '<td class="nocellnopadding" width="16" style="font-weight: normal">';
// The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object
print img_picto($langs->trans("MoveField",$pos),'grip_title','class="boxhandle" style="cursor:move;"');

View File

@ -433,3 +433,10 @@ SaleRepresentativeFirstname=First name of sales representative
SaleRepresentativeLastname=Last name of sales representative
ErrorThirdpartiesMerge=There was an error when deleting the third parties. Please check the log. Changes have been reverted.
NewCustomerSupplierCodeProposed=Customer or Vendor code already used, a new code is suggested
#Imports
PaymentTypeCustomer=Payment Type - Customer
PaymentTermsCustomer=Payment Terms - Customer
PaymentTypeSupplier=Payment Type - Vendor
PaymentTermsSupplier=Payment Term - Vendor
MulticurrencyUsed=Use Multicurrency
MulticurrencyCurrency=Currency