diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 62f0ca6d387..e45630df298 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -709,35 +709,15 @@ class ImportCsv extends ModeleImports } // Define $listfields and $listvalues to build SQL request - if ($conf->socialnetworks->enabled && strpos($fieldname, "socialnetworks") !== false) { - if (!in_array("socialnetworks", $listfields)) { - $listfields[] = "socialnetworks"; - } - if (!empty($newval) && $arrayrecord[($key - 1)]['type'] > 0) { - $socialkey = array_search("socialnetworks", $listfields); - if (empty($listvalues[$socialkey]) || $listvalues[$socialkey] == "null") { - $socialnetwork = explode("_", $fieldname)[1]; - $newvalue = '\'{ "'.$socialnetwork.'" : "'.$this->db->escape($newval).'" }\''; - $listvalues[$socialkey] = $newvalue; - } else { - $socialnetwork = explode("_", $fieldname)[1]; - $jsondata = $listvalues[$socialkey]; - $jsondata = str_replace("'", "", $jsondata); - $json = json_decode($jsondata); - $json->$socialnetwork = $this->db->escape($newval); - $listvalues[$socialkey] = "'".$this->db->escape(json_encode($json))."'"; - } - } + $listfields[] = $fieldname; + + // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert + if (empty($newval) && $arrayrecord[($key - 1)]['type'] < 0) { + $listvalues[] = ($newval == '0' ? $newval : "null"); + } elseif (empty($newval) && $arrayrecord[($key - 1)]['type'] == 0) { + $listvalues[] = "''"; } else { - $listfields[] = $fieldname; - // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert - if (empty($newval) && $arrayrecord[($key - 1)]['type'] < 0) { - $listvalues[] = ($newval == '0' ? $newval : "null"); - } elseif (empty($newval) && $arrayrecord[($key - 1)]['type'] == 0) { - $listvalues[] = "''"; - } else { - $listvalues[] = "'".$this->db->escape($newval)."'"; - } + $listvalues[] = "'".$this->db->escape($newval)."'"; } } $i++; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index a64063fa9af..9fa5cbf2c44 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -363,8 +363,6 @@ class ImportXlsx extends ModeleImports $warning = 0; $this->errors = array(); $this->warnings = array(); - $this->nbinsert = 0; - $this->nbupdate = 0; //dol_syslog("import_csv.modules maxfields=".$maxfields." importid=".$importid); @@ -752,36 +750,15 @@ class ImportXlsx extends ModeleImports } // Define $listfields and $listvalues to build SQL request - if ($conf->socialnetworks->enabled && strpos($fieldname, "socialnetworks") !== false) { - if (!in_array("socialnetworks", $listfields)) { - $listfields[] = "socialnetworks"; - } - if (!empty($newval) && $arrayrecord[($key)]['type'] > 0) { - $socialkey = array_search("socialnetworks", $listfields); - if (empty($listvalues[$socialkey]) || $listvalues[$socialkey] == "null") { - $socialnetwork = explode("_", $fieldname)[1]; - $newvalue = '\'{ "'.$socialnetwork.'" : "'.$this->db->escape($newval).'" }\''; - $listvalues[$socialkey] = $newvalue; - } else { - $socialnetwork = explode("_", $fieldname)[1]; - $jsondata = $listvalues[$socialkey]; - $jsondata = str_replace("'", "", $jsondata); - $json = json_decode($jsondata); - $json->$socialnetwork = $this->db->escape($newval); - $listvalues[$socialkey] = "'".$this->db->escape(json_encode($json))."'"; - } - } - } else { - $listfields[] = $fieldname; + $listfields[] = $fieldname; - // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert - if (empty($newval) && $arrayrecord[($key)]['type'] < 0) { - $listvalues[] = ($newval == '0' ? $newval : "null"); - } elseif (empty($newval) && $arrayrecord[($key)]['type'] == 0) { - $listvalues[] = "''"; - } else { - $listvalues[] = "'" . $this->db->escape($newval) . "'"; - } + // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert + if (empty($newval) && $arrayrecord[($key)]['type'] < 0) { + $listvalues[] = ($newval == '0' ? $newval : "null"); + } elseif (empty($newval) && $arrayrecord[($key)]['type'] == 0) { + $listvalues[] = "''"; + } else { + $listvalues[] = "'" . $this->db->escape($newval) . "'"; } } $i++; diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 84a5e97f1bf..09089d57563 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -519,16 +519,6 @@ class modSociete extends DolibarrModules if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) { $this->import_fields_array[$r] += array('s.accountancy_code_sell'=>'ProductAccountancySellCode', 's.accountancy_code_buy'=>'ProductAccountancyBuyCode'); } - // Add social networks fields - 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_fields_array[$r][$fieldname] = $fieldlabel; - } - } // Add extra fields $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'societe' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); @@ -705,16 +695,6 @@ class modSociete extends DolibarrModules 's.note_private' => "NotePrivate", 's.note_public' => "NotePublic" ); - // Add social networks fields - 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_fields_array[$r][$fieldname] = $fieldlabel; - } - } // Add extra fields $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql);