From 1277e3617978241de8196e4789e82f7e76056ae2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Jun 2019 13:30:18 +0200 Subject: [PATCH 01/15] Prepare 9.0.4 --- ChangeLog | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2a4aa492055..0ec173983e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,54 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 9.0.4 compared to 9.0.3 ***** +FIX: #5249 +FIX: #11025 +FIX: #11032 +FIX: #11097 +FIX: #11169 +FIX: #11202 +FIX: #11244 +FIX: #11296 +FIX: #11316 +FIX: #11335 +FIX: Add missing end date of subscription in export +FIX: A user may read holiday and expense report without permissions +FIX: better syntax +FIX: condition +FIX: confirmation of mass email sending + option MAILING_NO_USING_PHPMAIL +FIX: crabe pdf: bad detailed VAT for situation invoices, in situations S2 and above +FIX: default value for duration of validity can be set from generic +FIX: do not include tpl from disabled modules +FIX: Error management when MAILING_NO_USING_PHPMAIL is set +FIX: Even with permission, can't validate leave once validator defined. +FIX: extrafield list search: SQL error when field is multiselect +FIX: if last char of customercode is accent making the truncate of first +FIX: Import of chart of account +FIX: in edit mode, dictionary inputs do not escape the string inside the 'value' attribute, causing errors if there are any double quotes +FIX: invalid link on user.fk_user +FIX: invoice class: bad SQL request if product type not set +FIX: javascript error when ckeditor module not enabled +FIX: mail presend: can overwrite a file previously uploaded (Issue #11056) +FIX: mass send mail +FIX: missing compatibility with multicompany transverse mode +FIX: missing llx_const encrypt +FIX: modulebuilder: hardcoded llx_ +FIX: Not showing Contract and Project columns on ficheinter list +FIX: only profid1 to 4 were editable for pdf option to show. Not 5 and 6. +FIX: productaccount buylist with pages +FIX: remove isolated transaction commit +FIX: security (a user can read leave or holiday of other without perm. +FIX: situation invoices: bad detailed VAT in situations following the first one +FIX: situation invoices: block progress percentage change for discount lines +FIX: syntax error +FIX: the id was not loaded in fetch of accounting system +FIX: try to use WHERE EXISTS instead of DISTINCT +FIX: use dol_sanitizeFileName() function to remove double spaces in filenames, as well as done on document.php when we want to download pdf +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 ***** ChangeLog for 9.0.3 compared to 9.0.2 ***** FIX: #11013 From 27ad0d1f88cea27b132b3a3da01df7c741b1362e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Jun 2019 16:35:25 +0200 Subject: [PATCH 02/15] Trans --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 76631626eeb..d73ff3b4dbc 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1107,7 +1107,7 @@ AreaForAdminOnly=Setup parameters can be set by administrator users only. SystemInfoDesc=System information is miscellaneous technical information you get in read only mode and visible for administrators only. SystemAreaForAdminOnly=This area is available to administrator users only. Dolibarr user permissions cannot change this restriction. CompanyFundationDesc=Edit the information of the company/entity. Click on "%s" or "%s" button at the bottom of the page. -AccountantDesc=Edit the details of your accountant/bookkeeper +AccountantDesc=If you have an external accountant/bookkeeper, you can edit here its information. AccountantFileNumber=Accountant code DisplayDesc=Parameters affecting the look and behaviour of Dolibarr can be modified here. AvailableModules=Available app/modules From a776f3671b7a1e048ff979e81731c7a949e537cd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Jun 2019 16:50:42 +0200 Subject: [PATCH 03/15] Fix demo profiles --- htdocs/public/demo/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index 7228778144f..0f6e21f0984 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -106,13 +106,13 @@ if (empty($reshook)) // Visible $alwayscheckedmodules=array('barcode','bookmark','categorie','externalrss','fckeditor','geoipmaxmind','gravatar','memcached','syslog','user','webservices'); // Technical module we always want - $alwaysuncheckedmodules=array('dynamicprices','incoterm','loan','multicurrency','paybox','paypal','stripe','google','printing','scanner','skype','workflow'); // Module we dont want by default + $alwaysuncheckedmodules=array('dav','dynamicprices','incoterm','loan','multicurrency','paybox','paypal','stripe','google','printing','scanner','skype','takepos','workflow','website'); // Module we dont want by default // Not visible $alwayshiddencheckedmodules=array('accounting','api','barcode','blockedlog','bookmark','clicktodial','comptabilite','cron','document','domain','externalrss','externalsite','fckeditor','geoipmaxmind','gravatar','label','ldap', 'mailmanspip','notification','oauth','syslog','user','webservices', // Extended modules 'memcached','numberwords','zipautofillfr'); - $alwayshiddenuncheckedmodules=array('ftp','hrm','webservicesclient','websites', + $alwayshiddenuncheckedmodules=array('debugbar','emailcollector','ftp','hrm','modulebuilder','webservicesclient','websites', // Extended modules 'awstats','bittorrent','bootstrap','cabinetmed','cmcic','concatpdf','customfield','deplacement','dolicloud','filemanager','lightbox','mantis','monitoring','moretemplates','multicompany','nltechno','numberingpack','openstreetmap', 'ovh','phenix','phpsysinfo','pibarcode','postnuke','selectbank','skincoloreditor','submiteverywhere','survey','thomsonphonebook','topten','tvacerfa','voyage','webcalendar','webmail'); From 441b279fd86c1e8b893fd26b5a2617918ba23cbd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Jun 2019 18:03:12 +0200 Subject: [PATCH 04/15] Add log to help track travis error --- test/phpunit/FactureFournisseurTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/phpunit/FactureFournisseurTest.php b/test/phpunit/FactureFournisseurTest.php index 2d6218471aa..33d503825ac 100644 --- a/test/phpunit/FactureFournisseurTest.php +++ b/test/phpunit/FactureFournisseurTest.php @@ -135,7 +135,7 @@ class FactureFournisseurTest extends PHPUnit_Framework_TestCase $localobject->initAsSpecimen(); $result=$localobject->create($user); - $this->assertLessThan($result, 0); + $this->assertLessThan($result, 0, $localobject->errorsToString()); print __METHOD__." result=".$result."\n"; return $result; } @@ -160,7 +160,7 @@ class FactureFournisseurTest extends PHPUnit_Framework_TestCase $localobject=new FactureFournisseur($this->savdb); $result=$localobject->fetch($id); - $this->assertLessThan($result, 0); + $this->assertLessThan($result, 0, $localobject->errorsToString()); print __METHOD__." id=".$id." result=".$result."\n"; return $localobject; } @@ -186,7 +186,7 @@ class FactureFournisseurTest extends PHPUnit_Framework_TestCase $result=$localobject->update($user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertLessThan($result, 0); + $this->assertLessThan($result, 0, $localobject->errorsToString()); return $localobject; } @@ -210,7 +210,7 @@ class FactureFournisseurTest extends PHPUnit_Framework_TestCase $result=$localobject->validate($user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertLessThan($result, 0); + $this->assertLessThan($result, 0, $localobject->errorsToString()); return $localobject; } @@ -265,7 +265,7 @@ class FactureFournisseurTest extends PHPUnit_Framework_TestCase $result=$localobject->delete($user); print __METHOD__." id=".$id." result=".$result."\n"; - $this->assertLessThan($result, 0); + $this->assertLessThan($result, 0, $localobject->errorsToString()); return $result; } } From a2d50eb95ac3fba436190b422a09595fe0fe3fbe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Jun 2019 18:12:12 +0200 Subject: [PATCH 05/15] Fix sql regression --- htdocs/fourn/class/fournisseur.facture.class.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 23aff1a9991..15169e79f6d 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -343,7 +343,7 @@ class FactureFournisseur extends CommonInvoice $sql.= ", '".$this->db->escape($this->ref_supplier)."'"; $sql.= ", ".$conf->entity; $sql.= ", '".$this->db->escape($this->type)."'"; - $sql.= ", '".$this->db->escape($this->libelle)."'"; + $sql.= ", '".$this->db->escape($this->label?$this->label:$this->libelle)."'"; $sql.= ", ".$this->socid; $sql.= ", '".$this->db->idate($now)."'"; $sql.= ", '".$this->db->idate($this->date)."'"; @@ -484,7 +484,7 @@ class FactureFournisseur extends CommonInvoice { $idligne = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det'); - $this->updateline( + $this->updateline( $idligne, $line->description, $line->pu_ht, @@ -511,8 +511,6 @@ class FactureFournisseur extends CommonInvoice $result=$this->update_price(); if ($result > 0) { - $action='create'; - // Actions on extra fields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { @@ -587,7 +585,7 @@ class FactureFournisseur extends CommonInvoice $sql.= " t.datec,"; $sql.= " t.datef,"; $sql.= " t.tms,"; - $sql.= " t.libelle,"; + $sql.= " t.libelle as label,"; $sql.= " t.paye,"; $sql.= " t.amount,"; $sql.= " t.remise,"; @@ -646,8 +644,8 @@ class FactureFournisseur extends CommonInvoice $this->date = $this->db->jdate($obj->datef); $this->datep = $this->db->jdate($obj->datef); $this->tms = $this->db->jdate($obj->tms); - $this->libelle = $obj->libelle; // deprecated - $this->label = $obj->libelle; + $this->libelle = $obj->label; // deprecated + $this->label = $obj->label; $this->paye = $obj->paye; $this->amount = $obj->amount; $this->remise = $obj->remise; @@ -2859,7 +2857,7 @@ class SupplierInvoiceLine extends CommonObjectLine */ public function fetch($rowid) { - $sql = 'SELECT f.rowid, f.ref as ref_supplier, f.libelle as label, f.description, f.date_start, f.date_end, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.tva_tx'; + $sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.date_start, f.date_end, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.tva_tx'; $sql.= ', f.localtax1_type, f.localtax2_type, f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2 '; $sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_facture_fourn, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line, f.fk_unit'; $sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc'; From 4696d35bcbc5db53a46fd66a03bb4d8ecd08ab7b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Jun 2019 19:02:24 +0200 Subject: [PATCH 06/15] Fix we need to keep temp dir --- htdocs/core/class/utils.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 3d43a319e51..8f2b1ef303e 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -165,6 +165,12 @@ class Utils } else $this->output=$langs->trans("PurgeNothingToDelete").($choice == 'tempfilesold' ? ' (older than 24h)':''); + // Recreate temp dir that are not automatically recreated for performance purpose + if (! empty($conf->api->enabled)) + { + dol_mkdir($conf->api->dir_temp); + } + //return $count; return 0; // This function can be called by cron so must return 0 if OK } From d41850c7cdf0e326815b3e7a9906506f0655d124 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Jun 2019 20:02:14 +0200 Subject: [PATCH 07/15] Fix purge of old files --- htdocs/core/class/utils.class.php | 25 +++++++++++++++---------- htdocs/langs/en_US/admin.lang | 2 +- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 8f2b1ef303e..6b6d2d42c67 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -50,33 +50,36 @@ class Utils * Purge files into directory of data files. * CAN BE A CRON TASK * - * @param string $choice Choice of purge mode ('tempfiles', '' or 'tempfilesold' to purge temp older than 24h, 'allfiles', 'logfile') - * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) + * @param string $choice Choice of purge mode ('tempfiles', '' or 'tempfilesold' to purge temp older than $nbsecondsold seconds, 'allfiles', 'logfile') + * @param int $nbsecondsold Nb of seconds old to accept deletion of a directory if $choice is 'tempfilesold' + * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) */ - function purgeFiles($choice='tempfilesold') + function purgeFiles($choice = 'tempfilesold', $nbsecondsold = 86400) { global $conf, $langs, $dolibarr_main_data_root; $langs->load("admin"); - dol_syslog("Utils::purgeFiles choice=".$choice, LOG_DEBUG); require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $filesarray=array(); if (empty($choice)) $choice='tempfilesold'; + dol_syslog("Utils::purgeFiles choice=".$choice, LOG_DEBUG); + if ($choice=='tempfiles' || $choice=='tempfilesold') { // Delete temporary files if ($dolibarr_main_data_root) { - $filesarray=dol_dir_list($dolibarr_main_data_root, "directories", 1, '^temp$', '', 'name', SORT_ASC, 2, 0, '', 1); // Do not follow symlinks - if ($choice == 'tempfilesold') + $filesarray=dol_dir_list($dolibarr_main_data_root, "directories", 1, '^temp$', '', 'name', SORT_ASC, 2, 0, '', 1); // Do not follow symlinks + + if ($choice == 'tempfilesold') { $now = dol_now(); foreach($filesarray as $key => $val) { - if ($val['date'] > ($now - (24 * 3600))) unset($filesarray[$key]); // Discard files not older than 24h + if ($val['date'] > ($now - ($nbsecondsold))) unset($filesarray[$key]); // Discard temp dir not older than $nbsecondsold } } } @@ -119,13 +122,14 @@ class Utils $counterror=0; if (count($filesarray)) { - foreach($filesarray as $key => $value) + foreach($filesarray as $key => $value) { //print "x ".$filesarray[$key]['fullname']."-".$filesarray[$key]['type']."
\n"; - if ($filesarray[$key]['type'] == 'dir') + if ($filesarray[$key]['type'] == 'dir') { $startcount=0; $tmpcountdeleted=0; + $result=dol_delete_dir_recursive($filesarray[$key]['fullname'], $startcount, 1, 0, $tmpcountdeleted); $count+=$result; $countdeleted+=$tmpcountdeleted; @@ -165,11 +169,12 @@ class Utils } else $this->output=$langs->trans("PurgeNothingToDelete").($choice == 'tempfilesold' ? ' (older than 24h)':''); - // Recreate temp dir that are not automatically recreated for performance purpose + // Recreate temp dir that are not automatically recreated by core code for performance purpose, we need them if (! empty($conf->api->enabled)) { dol_mkdir($conf->api->dir_temp); } + dol_mkdir($conf->user->dir_temp); //return $count; return 0; // This function can be called by cron so must return 0 if OK diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 256cdc46105..a05eb631e13 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -145,7 +145,7 @@ SystemToolsAreaDesc=This area provides administration features. Use the menu to Purge=Purge PurgeAreaDesc=This page allows you to delete all files generated or stored by Dolibarr (temporary files or all files in %s directory). Using this feature is not necessary. It is provided as a workaround for users whose Dolibarr is hosted by a provider that does not offer permissions to delete files generated by the web server. PurgeDeleteLogFile=Delete log files, including %s defined for Syslog module (no risk of losing data) -PurgeDeleteTemporaryFiles=Delete all temporary files (no risk of losing data) +PurgeDeleteTemporaryFiles=Delete all temporary files (no risk of losing data). Note: Deletion is done only if the temp directory was created 24 hours ago. PurgeDeleteTemporaryFilesShort=Delete temporary files PurgeDeleteAllFilesInDocumentsDir=Delete all files in directory %s. Temporary files but also database backup dumps, files attached to elements (third parties, invoices, ...) and uploaded into the ECM module will be deleted. PurgeRunNow=Purge now From 85919d83244127e67db1d7840a8a979f34b90261 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Jun 2019 22:02:19 +0200 Subject: [PATCH 08/15] Code comment --- htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql index 5317254d79d..a169c6cb0bd 100644 --- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql +++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql @@ -22,7 +22,7 @@ CREATE TABLE llx_accounting_bookkeeping rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, entity integer DEFAULT 1 NOT NULL, -- | multi company id doc_date date NOT NULL, -- FEC:PieceDate - doc_type varchar(30) NOT NULL, -- | facture_client/reglement_client/facture_fournisseur/reglement_fournisseur + doc_type varchar(30) NOT NULL, -- | facture_client/reglement_client/facture_fournisseur/reglement_fournisseur/import doc_ref varchar(300) NOT NULL, -- FEC:PieceRef | facture_client/reglement_client/... reference number fk_doc integer NOT NULL, -- | facture_client/reglement_client/... rowid fk_docdet integer NOT NULL, -- | facture_client/reglement_client/... line rowid From 0ae0951d7d4dcb04f1300e1a84149202cba01a59 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Jun 2019 22:23:30 +0200 Subject: [PATCH 09/15] Fix import code (regex of data imported + import of constant) --- .../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 f75e5035670..1311264f7fb 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -669,18 +669,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 ae0290401cc..00db9096bca 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -688,21 +688,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 fc574946b19860f90485ebd5f8852ee1482c177b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Jun 2019 22:23:51 +0200 Subject: [PATCH 10/15] Fix import of ledger --- htdocs/core/modules/modAccounting.class.php | 28 ++++++++++++--------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 65638a1cab2..e4d7faa31ff 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -264,32 +264,36 @@ class modAccounting 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('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.piece_num'=>"TransactionNumShort", + '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.journal_label'=>'JournalLabel', 'b.numero_compte'=>'AccountAccounting', - 'b.label_compte'=>'LabelAccount', + //'b.label_compte'=>'LabelAccount', 'b.subledger_account'=>'SubledgerAccount', 'b.subledger_label'=>'SubledgerAccountLabel', 'b.label_operation'=>'LabelOperation', 'b.debit'=>"Debit", 'b.credit'=>"Credit" ); - $this->import_fieldshidden_array[$r]=array('b.fk_user_author'=>'user->id'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) + $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( - 'b.doc_date'=>'formatted as \'.dol_print_date(dol_now(),\'%Y-%m-%d\')', - 'b.piece_num'=>'1', + 'b.piece_num'=>'1', + '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'=>"Journal des ventes", + //'b.journal_label'=>"Sale journal", 'b.numero_compte'=>"707", - 'b.label_compte'=>'Ventes', + //'b.label_compte'=>'Product account 707', 'b.subledger_account'=>'', 'b.subledger_label'=>'', - 'b.label_operation'=>"Ventes services", - 'b.debit'=>"0,00", - 'b.credit'=>"100,00" + 'b.label_operation'=>"Sale of ABC", + 'b.debit'=>"0", + 'b.credit'=>"100" ); // Chart of accounts From 20471c54e1a24c4cf4de1d387ca6c8df16da2b14 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Jun 2019 22:23:30 +0200 Subject: [PATCH 11/15] 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 12/15] 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 13/15] 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 83f5b23ade299fc08e7c30834782b0fceceb628c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Jun 2019 22:39:04 +0200 Subject: [PATCH 14/15] Doc --- htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql index a169c6cb0bd..88aa6d4e129 100644 --- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql +++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql @@ -21,7 +21,8 @@ CREATE TABLE llx_accounting_bookkeeping ( rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, entity integer DEFAULT 1 NOT NULL, -- | multi company id - doc_date date NOT NULL, -- FEC:PieceDate + piece_num integer NOT NULL, -- FEC:EcritureNum | accounting transaction id + doc_date date NOT NULL, -- FEC:PieceDate | date of source document doc_type varchar(30) NOT NULL, -- | facture_client/reglement_client/facture_fournisseur/reglement_fournisseur/import doc_ref varchar(300) NOT NULL, -- FEC:PieceRef | facture_client/reglement_client/... reference number fk_doc integer NOT NULL, -- | facture_client/reglement_client/... rowid @@ -48,7 +49,6 @@ CREATE TABLE llx_accounting_bookkeeping fk_user integer NULL, -- The id of user that validate the accounting source document code_journal varchar(32) NOT NULL, -- FEC:JournalCode journal_label varchar(255), -- FEC:JournalLib - piece_num integer NOT NULL, -- FEC:EcritureNum | accounting source document date_validated datetime, -- FEC:ValidDate | if empty: movement not validated / if not empty: movement validated (No deleting / No modification) date_export datetime DEFAULT NULL, -- import_key varchar(14), From 67909302834bc9d4f5ce4a5903f5272fa1cae76a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Jun 2019 23:11:49 +0200 Subject: [PATCH 15/15] 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)