From 976f6d42b8b3dfe1c87e1b28901df33e968b5235 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Wed, 1 Jun 2022 09:15:21 +0200 Subject: [PATCH 1/4] php V8 warning --- htdocs/core/lib/usergroups.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 3883ae11fb4..dac412f92a6 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -485,7 +485,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''; if ($edit) { //print ajax_constantonoff('THEME_TOPMENU_DISABLE_IMAGE', array(), null, 0, 0, 1); - print $form->selectarray('THEME_TOPMENU_DISABLE_IMAGE', $listoftopmenumodes, $conf->global->THEME_TOPMENU_DISABLE_IMAGE); + print $form->selectarray('THEME_TOPMENU_DISABLE_IMAGE', $listoftopmenumodes, isset($conf->global->THEME_TOPMENU_DISABLE_IMAGE)?$conf->global->THEME_TOPMENU_DISABLE_IMAGE:0); } else { $listoftopmenumodes[$conf->global->THEME_TOPMENU_DISABLE_IMAGE]; //print yn($conf->global->THEME_TOPMENU_DISABLE_IMAGE); From 06def03a1fcc28beaef2e2e6d54f757c52fb2eb7 Mon Sep 17 00:00:00 2001 From: Manu Date: Wed, 1 Jun 2022 09:36:57 +0200 Subject: [PATCH 2/4] Fix a few CSS errors in md theme --- htdocs/theme/md/style.css.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 73337ba0284..8e71dfcd06f 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -488,7 +488,7 @@ section.setupsection { border-radius: 5px; } -.field-error-icon { color: #ea1212; !important; } +.field-error-icon { color: #ea1212 !important; } textarea { border-radius: 0; @@ -3570,7 +3570,7 @@ td.border, div.tagtable div div.border { left: 0; top: 0; max-width: 150px !important; - //background-color: inherit; + /*background-color: inherit;*/ background-color: gainsboro; z-index: 2; } @@ -3583,7 +3583,7 @@ td.border, div.tagtable div div.border { right: 0; top: 0; max-width: 150px !important; - //background-color: inherit; + /*background-color: inherit;*/ background-color: gainsboro; z-index: 2; } @@ -4164,7 +4164,7 @@ tr.liste_sub_total, tr.liste_sub_total td { } .paymenttable tr td:first-child, .margintable tr td:first-child { - //padding-left: 2px; + /*padding-left: 2px;*/ } .paymenttable, .margintable tr td { height: 22px; From d345957b84eec122f1bee13fe850975ca45df14e Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 1 Jun 2022 11:36:47 +0200 Subject: [PATCH 3/4] Fix: import update on xlsx --- htdocs/core/modules/import/import_xlsx.modules.php | 2 +- htdocs/imports/import.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index c3339a0a138..a7fcf6f0d0f 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -920,7 +920,7 @@ class ImportXlsx extends ModeleImports if (empty($keyfield)) { $keyfield = 'rowid'; } - $sqlSelect .= "WHERE ".$keyfield." = ".((int) $lastinsertid); + $sqlSelect .= " WHERE ".$keyfield." = ".((int) $lastinsertid); $resql = $this->db->query($sqlSelect); if ($resql) { diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index c4eb34ce1e5..05d1dd89a88 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1120,7 +1120,7 @@ if ($step == 4 && $datatoimport) { $j = 0; foreach ($optionsall as $tmpcode => $tmpval) { // Loop on each entry to add into each combo list. $label = ''; - if ($tmpval['picto']) { + if (!empty($tmpval['picto'])) { $label .= img_picto('', $tmpval['picto'], 'class="pictofixedwidth"'); } $label .= $tmpval['required'] ? '' : ''; From 69e8c1abe472910083cfb1a53fbaa583618d8d1e Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 1 Jun 2022 11:44:07 +0200 Subject: [PATCH 4/4] New : update in import for socialnetworks --- .../modules/import/import_csv.modules.php | 35 ++++++++++++++----- .../modules/import/import_xlsx.modules.php | 35 ++++++++++++++----- htdocs/core/modules/modSociete.class.php | 9 +++++ 3 files changed, 61 insertions(+), 18 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 08eb9a6f42d..8c3e5bfeab9 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -750,13 +750,6 @@ class ImportCsv extends ModeleImports $i++; } - // We db escape social network field because he isn't in field creation - if (in_array("socialnetworks", $listfields)) { - $socialkey = array_search("socialnetworks", $listfields); - $tmpsql = $listvalues[$socialkey]; - $listvalues[$socialkey] = "'".$this->db->escape($tmpsql)."'"; - } - // We add hidden fields (but only if there is at least one field to add into table) // We process here all the fields that were declared into the array $this->import_fieldshidden_array of the descriptor file. // Previously we processed the ->import_fields_array. @@ -838,8 +831,18 @@ class ImportCsv extends ModeleImports foreach ($updatekeys as $key) { $col = $objimport->array_import_updatekeys[0][$key]; $key = preg_replace('/^.*\./i', '', $key); - $where[] = $key.' = '.$data[$key]; - $filters[] = $col.' = '.$data[$key]; + if ($conf->socialnetworks->enabled && strpos($key, "socialnetworks") !== false) { + $tmp = explode("_", $key); + $key = $tmp[0]; + $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)."\"%'"; + } else { + $where[] = $key.' = '.$data[$key]; + $filters[] = $col.' = '.$data[$key]; + } } $sqlSelect .= " WHERE ".implode(' AND ', $where); @@ -896,6 +899,13 @@ class ImportCsv extends ModeleImports } if (!empty($lastinsertid)) { + // We db escape social network field because he isn't in field creation + if (in_array("socialnetworks", $listfields)) { + $socialkey = array_search("socialnetworks", $listfields); + $tmpsql = $listvalues[$socialkey]; + $listvalues[$socialkey] = "'".$this->db->escape($tmpsql)."'"; + } + // Build SQL UPDATE request $sqlstart = "UPDATE ".$tablename; @@ -933,6 +943,13 @@ class ImportCsv extends ModeleImports // Update not done, we do insert if (!$error && !$updatedone) { + // We db escape social network field because he isn't in field creation + if (in_array("socialnetworks", $listfields)) { + $socialkey = array_search("socialnetworks", $listfields); + $tmpsql = $listvalues[$socialkey]; + $listvalues[$socialkey] = "'".$this->db->escape($tmpsql)."'"; + } + // Build SQL INSERT request $sqlstart = "INSERT INTO ".$tablename."(".implode(", ", $listfields).", import_key"; $sqlend = ") VALUES(".implode(', ', $listvalues).", '".$this->db->escape($importid)."'"; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index c3339a0a138..3887caccb8e 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -795,13 +795,6 @@ class ImportXlsx extends ModeleImports $i++; } - // We db escape social network field because he isn't in field creation - if (in_array("socialnetworks", $listfields)) { - $socialkey = array_search("socialnetworks", $listfields); - $tmpsql = $listvalues[$socialkey]; - $listvalues[$socialkey] = "'".$this->db->escape($tmpsql)."'"; - } - // We add hidden fields (but only if there is at least one field to add into table) // We process here all the fields that were declared into the array $this->import_fieldshidden_array of the descriptor file. // Previously we processed the ->import_fields_array. @@ -883,8 +876,18 @@ class ImportXlsx extends ModeleImports foreach ($updatekeys as $key) { $col = $objimport->array_import_updatekeys[0][$key]; $key = preg_replace('/^.*\./i', '', $key); - $where[] = $key . ' = ' . $data[$key]; - $filters[] = $col . ' = ' . $data[$key]; + if ($conf->socialnetworks->enabled && strpos($key, "socialnetworks") !== false) { + $tmp = explode("_", $key); + $key = $tmp[0]; + $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)."\"%'"; + } else { + $where[] = $key.' = '.$data[$key]; + $filters[] = $col.' = '.$data[$key]; + } } $sqlSelect .= " WHERE " . implode(' AND ', $where); @@ -941,6 +944,13 @@ class ImportXlsx extends ModeleImports } if (!empty($lastinsertid)) { + // We db escape social network field because he isn't in field creation + if (in_array("socialnetworks", $listfields)) { + $socialkey = array_search("socialnetworks", $listfields); + $tmpsql = $listvalues[$socialkey]; + $listvalues[$socialkey] = "'".$this->db->escape($tmpsql)."'"; + } + // Build SQL UPDATE request $sqlstart = "UPDATE " . $tablename; @@ -978,6 +988,13 @@ class ImportXlsx extends ModeleImports // Update not done, we do insert if (!$error && !$updatedone) { + // We db escape social network field because he isn't in field creation + if (in_array("socialnetworks", $listfields)) { + $socialkey = array_search("socialnetworks", $listfields); + $tmpsql = $listvalues[$socialkey]; + $listvalues[$socialkey] = "'".$this->db->escape($tmpsql)."'"; + } + // Build SQL INSERT request $sqlstart = "INSERT INTO " . $tablename . "(" . implode(", ", $listfields) . ", import_key"; $sqlend = ") VALUES(" . implode(', ', $listvalues) . ", '" . $this->db->escape($importid) . "'"; diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index a6d9b95d19c..322988e7a7b 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -693,6 +693,15 @@ class modSociete extends DolibarrModules 's.code_compta' => 'CustomerAccountancyCode', 's.code_compta_fournisseur' => 'SupplierAccountancyCode' ); + if (!empty($conf->socialnetworks->enabled)) { + $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_socialnetworks WHERE active = 1"; + $resql = $this->db->query($sql); + while ($obj = $this->db->fetch_object($resql)) { + $fieldname = 's.socialnetworks_'.$obj->code; + $fieldlabel = ucfirst($obj->label); + $this->import_updatekeys_array[$r][$fieldname] = $fieldlabel; + } + } // Add profids as criteria to search duplicates $langs->load("companies"); $i=1;