From 20471c54e1a24c4cf4de1d387ca6c8df16da2b14 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Jun 2019 22:23:30 +0200 Subject: [PATCH 1/4] Fix import code (regex of data imported + import of constant) Conflicts: htdocs/core/modules/import/import_csv.modules.php htdocs/core/modules/import/import_xlsx.modules.php --- .../core/modules/import/import_csv.modules.php | 16 ++++++++++++++-- .../modules/import/import_xlsx.modules.php | 18 +++++++++++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index feeddb399c2..38568a81903 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -633,18 +633,30 @@ class ImportCsv extends ModeleImports if (! preg_match('/^'.preg_quote($alias).'\./', $key)) continue; // Not a field of current table if ($val == 'user->id') { - $listfields[] = preg_replace('/^'.preg_quote($alias).'\./','',$key); + $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); $listvalues[] = $user->id; } elseif (preg_match('/^lastrowid-/',$val)) { $tmp=explode('-',$val); $lastinsertid=(isset($last_insert_id_array[$tmp[1]]))?$last_insert_id_array[$tmp[1]]:0; - $keyfield = preg_replace('/^'.preg_quote($alias).'\./','',$key); + $keyfield = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); $listfields[] = $keyfield; $listvalues[] = $lastinsertid; //print $key."-".$val."-".$listfields."-".$listvalues."
";exit; } + elseif (preg_match('/^const-/', $val)) + { + $tmp=explode('-', $val, 2); + $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); + $listvalues[] = "'".$tmp[1]."'"; + } + else + { + $this->errors[$error]['lib']='Bad value of profile setup '.$val.' for array_import_fieldshidden'; + $this->errors[$error]['type']='Import profile setup'; + $error++; + } } } //print 'listfields='.$listfields.'
listvalues='.$listvalues.'
'; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 1c5fae77338..486d72f3d0d 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -653,21 +653,33 @@ class ImportXlsx extends ModeleImports // Loop on each hidden fields to add them into listfields/listvalues foreach($objimport->array_import_fieldshidden[0] as $key => $val) { - if (! preg_match('/^'.preg_quote($alias).'\./', $key)) continue; // Not a field of current table + if (! preg_match('/^'.preg_quote($alias, '/').'\./', $key)) continue; // Not a field of current table if ($val == 'user->id') { - $listfields[] = preg_replace('/^'.preg_quote($alias).'\./','',$key); + $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); $listvalues[] = $user->id; } elseif (preg_match('/^lastrowid-/',$val)) { $tmp=explode('-',$val); $lastinsertid=(isset($last_insert_id_array[$tmp[1]]))?$last_insert_id_array[$tmp[1]]:0; - $keyfield = preg_replace('/^'.preg_quote($alias).'\./','',$key); + $keyfield = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); $listfields[] = $keyfield; $listvalues[] = $lastinsertid; //print $key."-".$val."-".$listfields."-".$listvalues."
";exit; } + elseif (preg_match('/^const-/', $val)) + { + $tmp=explode('-', $val, 2); + $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); + $listvalues[] = "'".$tmp[1]."'"; + } + else + { + $this->errors[$error]['lib']='Bad value of profile setup '.$val.' for array_import_fieldshidden'; + $this->errors[$error]['type']='Import profile setup'; + $error++; + } } } //print 'listfields='.$listfields.'
listvalues='.$listvalues.'
'; From ad725b3bb065df9adf5fa6374865d0f303c96aad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Jun 2019 22:27:35 +0200 Subject: [PATCH 2/4] Doc --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 0ec173983e1..d98d1300e07 100644 --- a/ChangeLog +++ b/ChangeLog @@ -50,6 +50,7 @@ FIX: Use of cron with multicompany FIX: var name FIX: we need to fetch fourn invoice with ref in current entity FIX: Wrong stock movement on supplier credit notes +FIX: Import of record in ledger ***** ChangeLog for 9.0.3 compared to 9.0.2 ***** FIX: #11013 From d5479cd9ae41484b4a818ec56e179b0564c88b5d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Jun 2019 22:37:13 +0200 Subject: [PATCH 3/4] Fix import of ledger --- htdocs/core/modules/modAccounting.class.php | 37 +++++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index ec8622f2b95..708b3a147b6 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -262,15 +262,38 @@ class modAccounting extends DolibarrModules $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('b'=>MAIN_DB_PREFIX.'accounting_bookkeeping'); // List of tables to insert into (insert done in same order) - $this->import_fields_array[$r]=array('b.doc_date'=>"Docdate",'b.code_journal'=>'Codejournal','b.numero_compte'=>'AccountAccountingShort','b.label_operation'=>'LabelOperation','b.debit'=>"Debit",'b.credit'=>"Credit",'b.date_creation'=>"DateCreation"); - $this->import_fieldshidden_array[$r]=array('b.fk_user'=>'user->id'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) - $this->import_convertvalue_array[$r]=array( - 't.fk_projet'=>array('rule'=>'fetchidfromref','classfile'=>'/projet/class/project.class.php','class'=>'Project','method'=>'fetch','element'=>'Project'), - 't.ref'=>array('rule'=>'getrefifauto') + $this->import_fields_array[$r]=array( + 'b.piece_num'=>"TransactionNumShort", + 'b.doc_date'=>"Docdate", + //'b.doc_type'=>'Doctype', + 'b.doc_ref'=>'Piece', + 'b.code_journal'=>'Codejournal', + //'b.journal_label'=>'JournalLabel', + 'b.numero_compte'=>'AccountAccounting', + //'b.label_compte'=>'LabelAccount', + 'b.subledger_account'=>'SubledgerAccount', + 'b.subledger_label'=>'SubledgerAccountLabel', + 'b.label_operation'=>'LabelOperation', + 'b.debit'=>"Debit", + 'b.credit'=>"Credit" ); - //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); + $this->import_fieldshidden_array[$r]=array('b.doc_type'=>'const-import_from_external', 'b.fk_doc'=>'const-0', 'b.fk_docdet'=>'const-0', 'b.fk_user_author'=>'user->id', 'b.date_creation'=>'const-'.dol_print_date(dol_now(), 'standard')); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_regex_array[$r]=array('b.doc_date'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); - //$this->import_examplevalues_array[$r]=array('t.fk_projet'=>'MyProjectRef','t.ref'=>"auto or TK2010-1234",'t.label'=>"My task",'t.progress'=>"0 (not started) to 100 (finished)",'t.datec'=>'1972-10-10','t.note_private'=>"My private note",'t.note_public'=>"My public note"); + $this->import_examplevalues_array[$r]=array( + 'b.piece_num'=>'123 (!!! use next value not already used)', + 'b.doc_date'=>dol_print_date(dol_now(), "%Y-%m-%d"), + //'b.doc_type'=>'import', + 'b.doc_ref'=>'My document ABC', + 'b.code_journal'=>"VTE", + //'b.journal_label'=>"Sale journal", + 'b.numero_compte'=>"707", + //'b.label_compte'=>'Product account 707', + 'b.subledger_account'=>'', + 'b.subledger_label'=>'', + 'b.label_operation'=>"Sale of ABC", + 'b.debit'=>"0", + 'b.credit'=>"100" + ); // Chart of accounts $r++; From 67909302834bc9d4f5ce4a5903f5272fa1cae76a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Jun 2019 23:11:49 +0200 Subject: [PATCH 4/4] Add info on signature generator --- build/generate_filelist_xml.php | 1 + 1 file changed, 1 insertion(+) diff --git a/build/generate_filelist_xml.php b/build/generate_filelist_xml.php index ec9ded557ff..2a0b4996f79 100755 --- a/build/generate_filelist_xml.php +++ b/build/generate_filelist_xml.php @@ -121,6 +121,7 @@ else } print "Release : ".$release."\n"; +print "Working on files into : ".DOL_DOCUMENT_ROOT."\n"; print "Include custom in signature : ".$includecustom."\n"; print "Include constants in signature : "; foreach ($includeconstants as $countrycode => $tmp)