From f6d2033a242feb7c30be12bdb3fe03087901e540 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 10 Sep 2022 15:00:34 +0200 Subject: [PATCH 01/11] Fix php / token error --- htdocs/recruitment/recruitmentcandidature_card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/recruitment/recruitmentcandidature_card.php b/htdocs/recruitment/recruitmentcandidature_card.php index 0d2cc848aaa..f06fc476883 100644 --- a/htdocs/recruitment/recruitmentcandidature_card.php +++ b/htdocs/recruitment/recruitmentcandidature_card.php @@ -574,7 +574,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Contract refused / accepted if ($object->status == $object::STATUS_CONTRACT_PROPOSED) { if ($permissiontoadd) { - print ''.$langs->trans("Accept").' / '.$langs->trans("Decline").''; + print ''.$langs->trans("Accept").' / '.$langs->trans("Decline").''; } } From 4c74687c1032946fe88f68b2197b1365438a9ae6 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 10 Sep 2022 15:01:36 +0200 Subject: [PATCH 02/11] Update recruitmentjobposition_card.php --- htdocs/recruitment/recruitmentjobposition_card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/recruitment/recruitmentjobposition_card.php b/htdocs/recruitment/recruitmentjobposition_card.php index b2172aca80d..44a65e90271 100644 --- a/htdocs/recruitment/recruitmentjobposition_card.php +++ b/htdocs/recruitment/recruitmentjobposition_card.php @@ -446,7 +446,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Close as recruited/canceled if ($object->status == $object::STATUS_VALIDATED) { if ($usercanclose) { - print 'global->MAIN_JUMP_TAG) ? '' : '#close').'"'; + print 'global->MAIN_JUMP_TAG) ? '' : '#close').'"'; print '>'.$langs->trans('Close').''; } else { print ''.$langs->trans('Close').''; From 4f45c89ecb53252e3e29f51461546193769c2028 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 10 Sep 2022 13:02:21 +0000 Subject: [PATCH 03/11] Fixing style errors. --- htdocs/recruitment/recruitmentjobposition_card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/recruitment/recruitmentjobposition_card.php b/htdocs/recruitment/recruitmentjobposition_card.php index 44a65e90271..a20d631e3f2 100644 --- a/htdocs/recruitment/recruitmentjobposition_card.php +++ b/htdocs/recruitment/recruitmentjobposition_card.php @@ -446,7 +446,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Close as recruited/canceled if ($object->status == $object::STATUS_VALIDATED) { if ($usercanclose) { - print 'global->MAIN_JUMP_TAG) ? '' : '#close').'"'; + print 'global->MAIN_JUMP_TAG) ? '' : '// close').'"'; print '>'.$langs->trans('Close').''; } else { print ''.$langs->trans('Close').''; From 4ec58d76544989c6f3cc77e7139cc4ec529a70dc Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 10 Sep 2022 15:20:31 +0200 Subject: [PATCH 04/11] Update recruitmentjobposition_card.php --- htdocs/recruitment/recruitmentjobposition_card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/recruitment/recruitmentjobposition_card.php b/htdocs/recruitment/recruitmentjobposition_card.php index a20d631e3f2..85100f992bd 100644 --- a/htdocs/recruitment/recruitmentjobposition_card.php +++ b/htdocs/recruitment/recruitmentjobposition_card.php @@ -446,7 +446,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Close as recruited/canceled if ($object->status == $object::STATUS_VALIDATED) { if ($usercanclose) { - print 'global->MAIN_JUMP_TAG) ? '' : '// close').'"'; + print 'global->MAIN_JUMP_TAG) ? '' : '// close').'"'; print '>'.$langs->trans('Close').''; } else { print ''.$langs->trans('Close').''; From 0b944e62ee86b77b292abc78667bb1bccd093ebf Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 10 Sep 2022 17:01:21 +0200 Subject: [PATCH 05/11] Update recruitmentjobposition_card.php --- htdocs/recruitment/recruitmentjobposition_card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/recruitment/recruitmentjobposition_card.php b/htdocs/recruitment/recruitmentjobposition_card.php index 85100f992bd..d7d115b04b0 100644 --- a/htdocs/recruitment/recruitmentjobposition_card.php +++ b/htdocs/recruitment/recruitmentjobposition_card.php @@ -446,7 +446,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Close as recruited/canceled if ($object->status == $object::STATUS_VALIDATED) { if ($usercanclose) { - print 'global->MAIN_JUMP_TAG) ? '' : '// close').'"'; + print 'global->MAIN_JUMP_TAG) ? '' : '#close').'"'; print '>'.$langs->trans('Close').''; } else { print ''.$langs->trans('Close').''; From dde3b71cadee16baa42c98656b29dde6b147b92f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Sep 2022 11:33:43 +0200 Subject: [PATCH 06/11] FIX tooltip of technical tables added of a module --- htdocs/admin/modulehelp.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index 0c53bebfc52..63a1ff214c1 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -382,15 +382,16 @@ if ($mode == 'feature') { $text .= '

'; $text .= '
'.$langs->trans("AddDataTables").': '; - $sqlfiles = dol_dir_list(dol_buildpath($moduledir.'/sql/'), 'files', 0, 'llx.*\.sql', array('\.key\.sql', '\.sql\.back')); + $sqlfiles1 = dol_dir_list(DOL_DOCUMENT_ROOT.'/install/mysql/tables/', 'files', 0, 'llx.*-'.$moduledir.'\.sql', array('\.key\.sql', '\.sql\.back')); + $sqlfiles2 = dol_dir_list(dol_buildpath($moduledir.'/sql/'), 'files', 0, 'llx.*\.sql', array('\.key\.sql', '\.sql\.back')); + $sqlfiles = array_merge($sqlfiles1, $sqlfiles2); + if (count($sqlfiles) > 0) { - $text .= $langs->trans("Yes").' ('; $i = 0; foreach ($sqlfiles as $val) { - $text .= ($i ? ', ' : '').preg_replace('/\.sql$/', '', preg_replace('/llx_/', '', $val['name'])); + $text .= ($i ? ', ' : '').preg_replace('/\-'.$moduledir.'$/', '', preg_replace('/\.sql$/', '', preg_replace('/llx_/', '', $val['name']))); $i++; } - $text .= ')'; } else { $text .= $langs->trans("No"); } @@ -413,7 +414,7 @@ if ($mode == 'feature') { $text .= '
'.$langs->trans("AddData").': '; $filedata = dol_buildpath($moduledir.'/sql/data.sql'); if (dol_is_file($filedata)) { - $text .= $langs->trans("Yes").' ('.$moduledir.'/sql/data.sql)'; + $text .= $langs->trans("Yes").' ('.$moduledir.'/sql/data.sql)'; } else { $text .= $langs->trans("No"); } From cad8b1ee7e84f704b3f66f3bda54940ee31e6cec Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Sep 2022 12:25:15 +0200 Subject: [PATCH 07/11] Fix autoadd in basket after a search (only if search on barcode) --- htdocs/takepos/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 004ce45c459..b567ff5fee9 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -684,8 +684,8 @@ function Search2(keyCodeForEnter, moreorless) { console.log("There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0]['rowid']); ChangeThirdparty(data[0]['rowid']); } - else if ('product' == data[0]['object']) { - console.log("There is only 1 answer matching the search, so we add the product in basket, qty="+data[0]['qty']); + else if ($('#search').val() == data[0]['barcode'] && 'product' == data[0]['object']) { + console.log("There is only 1 answer and we found search on a barcode, so we add the product in basket, qty="+data[0]['qty']); ClickProduct(0, data[0]['qty']); } } From 3a8e66bfad76cc532a23b3d2f5e60318daabaada Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 13 Sep 2022 02:30:15 +0200 Subject: [PATCH 08/11] Fix phpunit --- htdocs/admin/modulehelp.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index 63a1ff214c1..01c29b48a26 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -382,9 +382,9 @@ if ($mode == 'feature') { $text .= '

'; $text .= '
'.$langs->trans("AddDataTables").': '; - $sqlfiles1 = dol_dir_list(DOL_DOCUMENT_ROOT.'/install/mysql/tables/', 'files', 0, 'llx.*-'.$moduledir.'\.sql', array('\.key\.sql', '\.sql\.back')); - $sqlfiles2 = dol_dir_list(dol_buildpath($moduledir.'/sql/'), 'files', 0, 'llx.*\.sql', array('\.key\.sql', '\.sql\.back')); - $sqlfiles = array_merge($sqlfiles1, $sqlfiles2); + $listofsqlfiles1 = dol_dir_list(DOL_DOCUMENT_ROOT.'/install/mysql/tables/', 'files', 0, 'llx.*-'.$moduledir.'\.sql', array('\.key\.sql', '\.sql\.back')); + $listofsqlfiles2 = dol_dir_list(dol_buildpath($moduledir.'/sql/'), 'files', 0, 'llx.*\.sql', array('\.key\.sql', '\.sql\.back')); + $sqlfiles = array_merge($listofsqlfiles1, $listofsqlfiles2); if (count($sqlfiles) > 0) { $i = 0; From 0fe65591e80bfcc498a7be55bf9f73275e901ff6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Sep 2022 14:01:41 +0200 Subject: [PATCH 09/11] Fix message avec import simulation Fix suggested name of import profile avec a save. Fix trans --- htdocs/core/modules/modSociete.class.php | 2 +- htdocs/imports/import.php | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 327262ce39f..7f7624b167f 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -747,7 +747,7 @@ class modSociete extends DolibarrModules 's.fk_departement' => "StateCode", 's.fk_pays' => "CountryCode", 's.birthday' => "DateOfBirth", - 's.poste' => "Role", + 's.poste' => "PostOrFunction", 's.phone' => "Phone", 's.phone_perso' => "PhonePerso", 's.phone_mobile' => "PhoneMobile", diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index a66814ce1b1..8916041520d 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -235,6 +235,7 @@ if ($action == 'add_import_model') { $result = $objimport->create($user); if ($result >= 0) { setEventMessages($langs->trans("ImportModelSaved", $objimport->model_name), null, 'mesgs'); + $import_name = ''; } else { $langs->load("errors"); if ($objimport->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS') { @@ -1286,7 +1287,7 @@ if ($step == 4 && $datatoimport) { print ''; // Lines for remark - print ''.$langs->trans("Remark").''; + print ''.$langs->trans("Note").''; print '
'; print ''; @@ -1470,8 +1471,8 @@ if ($step == 4 && $datatoimport) { print ''; $nameofimportprofile = str_replace(' ', '-', $langs->trans("ImportProfile").' '.$titleofmodule.' '.dol_print_date(dol_now('gmt'), 'dayxcard')); - if (is_object($objimport) && !empty($objimport->model_name)) { - $nameofimportprofile = $objimport->model_name; + if (GETPOST('import_name')) { // If we have submited a form, we take value used fot the update try + $nameofimportprofile = $import_name; } print ''; @@ -1966,9 +1967,9 @@ if ($step == 5 && $datatoimport) { print '
'; print ''.$langs->trans("NowClickToRunTheImport", $langs->transnoentitiesnoconv("RunImportFile")).'
'; - if (empty($nboferrors)) { + /*if (empty($nboferrors)) { print $langs->trans("DataLoadedWithId", $importid).'
'; - } + }*/ print '
'; print '
'; From 34da698537c5360164ca14acc0a0e4640ee5441b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Sep 2022 16:01:45 +0200 Subject: [PATCH 10/11] FIX Import in upgrade when using a socialnetwork field. --- htdocs/core/db/Database.interface.php | 9 +++++++++ htdocs/core/db/mysqli.class.php | 12 ++++++++++++ htdocs/core/db/pgsql.class.php | 14 +++++++++++++- htdocs/core/db/sqlite3.class.php | 14 +++++++++++++- htdocs/core/lib/website.lib.php | 6 +++--- htdocs/core/modules/import/import_csv.modules.php | 12 ++++++++---- htdocs/core/modules/import/import_xlsx.modules.php | 8 ++++++-- htdocs/debugbar/class/TraceableDB.php | 12 ++++++++++++ 8 files changed, 76 insertions(+), 11 deletions(-) diff --git a/htdocs/core/db/Database.interface.php b/htdocs/core/db/Database.interface.php index 1d24b058614..faff7ff5172 100644 --- a/htdocs/core/db/Database.interface.php +++ b/htdocs/core/db/Database.interface.php @@ -182,9 +182,18 @@ interface Database * * @param string $stringtoencode String to escape * @return string String escaped + * @deprecated */ public function escapeunderscore($stringtoencode); + /** + * Escape a string to insert data into a like + * + * @param string $stringtoencode String to escape + * @return string String escaped + */ + public function escapeforlike($stringtoencode); + /** * Sanitize a string for SQL forging * diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 29c2d30df2f..f2c5f9f3a03 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -479,12 +479,24 @@ class DoliDBMysqli extends DoliDB * * @param string $stringtoencode String to escape * @return string String escaped + * @deprecated */ public function escapeunderscore($stringtoencode) { return str_replace('_', '\_', (string) $stringtoencode); } + /** + * Escape a string to insert data into a like + * + * @param string $stringtoencode String to escape + * @return string String escaped + */ + public function escapeforlike($stringtoencode) + { + return str_replace(array('_', '\\', '%'), array('\_', '\\\\', '\%'), (string) $stringtoencode); + } + /** * Return generic error code of last operation. * diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index fe3269867a9..e259933cd07 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -726,10 +726,22 @@ class DoliDBPgsql extends DoliDB * * @param string $stringtoencode String to escape * @return string String escaped + * @deprecated */ public function escapeunderscore($stringtoencode) { - return str_replace('_', '\_', $stringtoencode); + return str_replace('_', '\_', (string) $stringtoencode); + } + + /** + * Escape a string to insert data into a like + * + * @param string $stringtoencode String to escape + * @return string String escaped + */ + public function escapeforlike($stringtoencode) + { + return str_replace(array('_', '\\', '%'), array('\_', '\\\\', '\%'), (string) $stringtoencode); } /** diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index 8d0141e8ca6..e31eeffe457 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -654,10 +654,22 @@ class DoliDBSqlite3 extends DoliDB * * @param string $stringtoencode String to escape * @return string String escaped + * @deprecated */ public function escapeunderscore($stringtoencode) { - return str_replace('_', '\_', $stringtoencode); + return str_replace('_', '\_', (string) $stringtoencode); + } + + /** + * Escape a string to insert data into a like + * + * @param string $stringtoencode String to escape + * @return string String escaped + */ + public function escapeforlike($stringtoencode) + { + return str_replace(array('_', '\\', '%'), array('\_', '\\\\', '\%'), (string) $stringtoencode); } /** diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index e9de957e4a8..e9ea4dbcf09 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -947,11 +947,11 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so $sql .= " AND ("; $searchalgo = ''; if (preg_match('/meta/', $algo)) { - $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.title LIKE '%".$db->escapeunderscore($db->escape($searchstring))."%' OR wp.description LIKE '%".$db->escapeunderscore($db->escape($searchstring))."%'"; - $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.keywords LIKE '".$db->escapeunderscore($db->escape($searchstring)).",%' OR wp.keywords LIKE '% ".$db->escapeunderscore($db->escape($searchstring))."%'"; // TODO Use a better way to scan keywords + $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.title LIKE '%".$db->escapeforlike($db->escape($searchstring))."%' OR wp.description LIKE '%".$db->escapeforlike($db->escape($searchstring))."%'"; + $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.keywords LIKE '".$db->escapeforlike($db->escape($searchstring)).",%' OR wp.keywords LIKE '% ".$db->escapeforlike($db->escape($searchstring))."%'"; // TODO Use a better way to scan keywords } if (preg_match('/content/', $algo)) { - $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.content LIKE '%".$db->escapeunderscore($db->escape($searchstring))."%'"; + $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.content LIKE '%".$db->escapeforlike($db->escape($searchstring))."%'"; } $sql .= $searchalgo; if (is_array($otherfilters) && !empty($otherfilters['category'])) { diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 32284a2cbd1..0bea7d1d739 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -835,8 +835,8 @@ class ImportCsv extends ModeleImports $sqlSelect = "SELECT ".$fname." FROM ".$tablename; $data = array_combine($listfields, $listvalues); - $where = array(); - $filters = array(); + $where = array(); // filters to forge SQL request + $filters = array(); // filters to forge output error message foreach ($updatekeys as $key) { $col = $objimport->array_import_updatekeys[0][$key]; $key = preg_replace('/^.*\./i', '', $key); @@ -846,8 +846,12 @@ class ImportCsv extends ModeleImports $socialnetwork = $tmp[1]; $jsondata = $data[$key]; $json = json_decode($jsondata); - $where[] = $key." LIKE '%\"".$socialnetwork."\":\"".$this->db->escape($json->$socialnetwork)."\"%'"; - $filters[] = $col." LIKE '%\"".$socialnetwork."\":\"".$this->db->escape($json->$socialnetwork)."\"%'"; + $stringtosearch = json_encode($socialnetwork).':'.json_encode($json->$socialnetwork); + //var_dump($stringtosearch); + //var_dump($this->db->escape($stringtosearch)); // This provide a value for sql string (but not for a like) + $where[] = $key." LIKE '%".$this->db->escapeforlike($this->db->escape($stringtosearch))."%'"; + $filters[] = $col." LIKE '%".$this->db->escapeforlike($this->db->escape($stringtosearch))."%'"; + //var_dump($where[1]); // This provide a value for sql string inside a like } else { $where[] = $key.' = '.$data[$key]; $filters[] = $col.' = '.$data[$key]; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index d8a9d77a98e..8652f106ca2 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -891,8 +891,12 @@ class ImportXlsx extends ModeleImports $socialnetwork = $tmp[1]; $jsondata = $data[$key]; $json = json_decode($jsondata); - $where[] = $key." LIKE '%\"".$socialnetwork."\":\"".$this->db->escape($json->$socialnetwork)."\"%'"; - $filters[] = $col." LIKE '%\"".$socialnetwork."\":\"".$this->db->escape($json->$socialnetwork)."\"%'"; + $stringtosearch = json_encode($socialnetwork).':'.json_encode($json->$socialnetwork); + //var_dump($stringtosearch); + //var_dump($this->db->escape($stringtosearch)); // This provide a value for sql string (but not for a like) + $where[] = $key." LIKE '%".$this->db->escapeforlike($this->db->escape($stringtosearch))."%'"; + $filters[] = $col." LIKE '%".$this->db->escapeforlike($this->db->escape($stringtosearch))."%'"; + //var_dump($where[1]); // This provide a value for sql string inside a like } else { $where[] = $key.' = '.$data[$key]; $filters[] = $col.' = '.$data[$key]; diff --git a/htdocs/debugbar/class/TraceableDB.php b/htdocs/debugbar/class/TraceableDB.php index 082e45e4f43..785af37fc94 100644 --- a/htdocs/debugbar/class/TraceableDB.php +++ b/htdocs/debugbar/class/TraceableDB.php @@ -255,12 +255,24 @@ class TraceableDB extends DoliDB * * @param string $stringtoencode String to escape * @return string String escaped + * @deprecated */ public function escapeunderscore($stringtoencode) { return $this->db->escapeunderscore($stringtoencode); } + /** + * Escape a string to insert data into a like + * + * @param string $stringtoencode String to escape + * @return string String escaped + */ + public function escapeforlike($stringtoencode) + { + return str_replace(array('_', '\\', '%'), array('\_', '\\\\', '\%'), (string) $stringtoencode); + } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get last ID after an insert INSERT From 5f27435ffcf7f61c14d9982c6eb3ab44b17bac42 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Sep 2022 16:06:42 +0200 Subject: [PATCH 11/11] Fix position of import --- htdocs/core/modules/modAccounting.class.php | 36 ++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 5e30978693e..737d2831db6 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -272,6 +272,24 @@ class modAccounting extends DolibarrModules //-------- $r = 0; + // Chart of accounts + $r++; + $this->import_code[$r] = $this->rights_class.'_'.$r; + $this->import_label[$r] = "Chartofaccounts"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('aa'=>MAIN_DB_PREFIX.'accounting_account'); + $this->import_tables_creator_array[$r] = array('aa'=>'fk_user_author'); // Fields to store import user id + $this->import_fields_array[$r] = array('aa.fk_pcg_version'=>"Chartofaccounts*", 'aa.account_number'=>"AccountAccounting*", 'aa.label'=>"Label*", 'aa.account_parent'=>"Accountparent", "aa.fk_accounting_category"=>"AccountingCategory", "aa.pcg_type"=>"Pcgtype*", 'aa.active'=>'Status*', 'aa.datec'=>"DateCreation"); + $this->import_regex_array[$r] = array('aa.fk_pcg_version'=>'pcg_version@'.MAIN_DB_PREFIX.'accounting_system', 'aa.account_number'=>'^.{1,32}$', 'aa.label'=>'^.{1,255}$', 'aa.account_parent'=>'^.{0,32}$', 'aa.fk_accounting_category'=>'rowid@'.MAIN_DB_PREFIX.'c_accounting_category', 'aa.pcg_type'=>'^.{1,20}$', 'aa.active'=>'^0|1$', 'aa.datec'=>'^\d{4}-\d{2}-\d{2}$'); + $this->import_convertvalue_array[$r] = array( + 'aa.account_number'=>array('rule'=>'accountingaccount'), + 'aa.account_parent'=>array('rule'=>'fetchidfromref', 'classfile'=>'/accountancy/class/accountingaccount.class.php', 'class'=>'AccountingAccount', 'method'=>'fetch', 'element'=>'AccountingAccount'), + 'aa.fk_accounting_category'=>array('rule'=>'fetchidfromcodeorlabel', 'classfile'=>'/accountancy/class/accountancycategory.class.php', 'class'=>'AccountancyCategory', 'method'=>'fetch', 'dict'=>'DictionaryAccountancyCategory'), + ); + $this->import_examplevalues_array[$r] = array('aa.fk_pcg_version'=>"PCG99-ABREGE", 'aa.account_number'=>"707", 'aa.label'=>"Product sales", 'aa.account_parent'=>"ref:7 or id:1407", "aa.fk_accounting_category"=>"", "aa.pcg_type"=>"PROD", 'aa.active'=>'1', 'aa.datec'=>"2017-04-28"); + $this->import_updatekeys_array[$r] = array('aa.fk_pcg_version'=>'Chartofaccounts', 'aa.account_number'=>'AccountAccounting'); + // General ledger $r++; $this->import_code[$r] = $this->rights_class.'_'.$r; @@ -393,23 +411,5 @@ class modAccounting extends DolibarrModules 'b.multicurrency_amount'=>"90 (Necessary if devise is different than EUR)", 'b.multicurrency_code'=>"US (Necessary if devise is different than EUR)", ); - - // Chart of accounts - $r++; - $this->import_code[$r] = $this->rights_class.'_'.$r; - $this->import_label[$r] = "Chartofaccounts"; // Translation key - $this->import_icon[$r] = $this->picto; - $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r] = array('aa'=>MAIN_DB_PREFIX.'accounting_account'); - $this->import_tables_creator_array[$r] = array('aa'=>'fk_user_author'); // Fields to store import user id - $this->import_fields_array[$r] = array('aa.fk_pcg_version'=>"Chartofaccounts*", 'aa.account_number'=>"AccountAccounting*", 'aa.label'=>"Label*", 'aa.account_parent'=>"Accountparent", "aa.fk_accounting_category"=>"AccountingCategory", "aa.pcg_type"=>"Pcgtype*", 'aa.active'=>'Status*', 'aa.datec'=>"DateCreation"); - $this->import_regex_array[$r] = array('aa.fk_pcg_version'=>'pcg_version@'.MAIN_DB_PREFIX.'accounting_system', 'aa.account_number'=>'^.{1,32}$', 'aa.label'=>'^.{1,255}$', 'aa.account_parent'=>'^.{0,32}$', 'aa.fk_accounting_category'=>'rowid@'.MAIN_DB_PREFIX.'c_accounting_category', 'aa.pcg_type'=>'^.{1,20}$', 'aa.active'=>'^0|1$', 'aa.datec'=>'^\d{4}-\d{2}-\d{2}$'); - $this->import_convertvalue_array[$r] = array( - 'aa.account_number'=>array('rule'=>'accountingaccount'), - 'aa.account_parent'=>array('rule'=>'fetchidfromref', 'classfile'=>'/accountancy/class/accountingaccount.class.php', 'class'=>'AccountingAccount', 'method'=>'fetch', 'element'=>'AccountingAccount'), - 'aa.fk_accounting_category'=>array('rule'=>'fetchidfromcodeorlabel', 'classfile'=>'/accountancy/class/accountancycategory.class.php', 'class'=>'AccountancyCategory', 'method'=>'fetch', 'dict'=>'DictionaryAccountancyCategory'), - ); - $this->import_examplevalues_array[$r] = array('aa.fk_pcg_version'=>"PCG99-ABREGE", 'aa.account_number'=>"707", 'aa.label'=>"Product sales", 'aa.account_parent'=>"ref:7 or id:1407", "aa.fk_accounting_category"=>"", "aa.pcg_type"=>"PROD", 'aa.active'=>'1', 'aa.datec'=>"2017-04-28"); - $this->import_updatekeys_array[$r] = array('aa.fk_pcg_version'=>'Chartofaccounts', 'aa.account_number'=>'AccountAccounting'); } }