diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 5ccdb661ec2c2f58df7867f260c78c2bf7c5b369..ba24d5c53bf49cc5c7b1e0c36be7c0a612fee906 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -938,7 +938,7 @@ class DoliDBMysqli * * @param string $table Name of table * @param string $field Optionnel : Name of field if we want description of field - * @return resource Resource + * @return resultset Resultset x (x->Field, x->Type, ...) */ function DDLDescTable($table,$field="") { diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 695ab573fc4682f626878ff24f81dfc885de36dc..a94d9dd96ba8fec692b8f5d834646c16848a7145 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -1169,7 +1169,7 @@ class DoliDBPgsql * * @param string $table Name of table * @param string $field Optionnel : Name of field if we want description of field - * @return resource Resource + * @return resultset Resultset x (x->attname) */ function DDLDescTable($table,$field="") { diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 1b6f255a4f03d6cb2495b613db9aea8016285e2a..b1eaa2a725f1d254fc660cc4700d2084eeff6832 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -66,8 +66,7 @@ class ImportCsv extends ModeleImports global $conf,$langs; $this->db = $db; - $this->separator=','; // Change also function cleansep - if (! empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE)) $this->separator=$conf->global->IMPORT_CSV_SEPARATOR_TO_USE; + $this->separator=(GETPOST('separator')?GETPOST('separator'):(empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE)?',':$conf->global->IMPORT_CSV_SEPARATOR_TO_USE)); $this->enclosure='"'; $this->escape='"'; @@ -579,7 +578,7 @@ class ImportCsv extends ModeleImports //var_dump($objimport->array_import_convertvalue); exit; // Build SQL request - if (! tablewithentity($tablename)) + if (! tablewithentity($tablename)) { $sql ='INSERT INTO '.$tablename.'('.$listfields.', import_key'; if (! empty($objimport->array_import_tables_creator[0][$alias])) $sql.=', '.$objimport->array_import_tables_creator[0][$alias]; @@ -651,25 +650,16 @@ function cleansep($value) function tablewithentity($table) { global $db; - $sql = "SHOW COLUMNS FROM ".$table." LIKE 'entity'"; - - $resql=$db->query($sql); - if ($resql) - { - $numrows=$db->num_rows($resql); - if ($numrows) - { - return 1; - } - else - { - return 0; - } - } - else - { - return -1; + + $resql=$db->DDLDescTable($table,'entity'); + if ($resql) + { + $i=0; + $obj=$db->fetch_object($resql); + if ($obj) return 1; + else return 0; } + else return -1; } ?> \ No newline at end of file diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index d532b20d5a04852e0ed44062e8f3da027b2d5d0a..d6ee18c9b6c5c187ea959bcb6081ea32d1f0d456 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -355,7 +355,7 @@ class modSociete extends DolibarrModules $this->import_label[$r]='ImportDataset_company_2'; $this->import_icon[$r]='contact'; $this->import_entities_array[$r]=array('s.fk_soc'=>'company'); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('s'=>MAIN_DB_PREFIX.'socpeople'); // List of tables to insert into (insert done in same order) + $this->import_tables_array[$r]=array('s'=>MAIN_DB_PREFIX.'socpeople','extra'=>MAIN_DB_PREFIX.'socpeople_extrafields'); // List of tables to insert into (insert done in same order) $this->import_fields_array[$r]=array('s.fk_soc'=>'ThirdPartyName*','s.civilite'=>'UserTitle','s.name'=>"Name*",'s.firstname'=>"Firstname",'s.address'=>"Address",'s.cp'=>"Zip",'s.ville'=>"Town",'s.fk_pays'=>"CountryCode",'s.birthday'=>"BirthdayDate",'s.poste'=>"Role",'s.phone'=>"Phone",'s.phone_perso'=>"PhonePerso",'s.phone_mobile'=>"PhoneMobile",'s.fax'=>"Fax",'s.email'=>"Email",'s.note'=>"Note",'s.datec'=>"DateCreation"); // Add extra fields $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'contact'"; @@ -370,7 +370,7 @@ class modSociete extends DolibarrModules } } // End add extra fields - $this->import_fieldshidden_array[$r]=array('s.fk_user_creat'=>'user->id'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) + $this->import_fieldshidden_array[$r]=array('s.fk_user_creat'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'socpeople'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_convertvalue_array[$r]=array( 's.fk_soc'=>array('rule'=>'fetchidfromref','file'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'), 's.fk_pays'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/cpays.class.php','class'=>'Cpays','method'=>'fetch','dict'=>'DictionnaryCountry'), diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index eba68cc646c3585eae1099688959a21de9b2ed06..90662ebb70b39b36f946ddf05cb2aa753b670015 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -33,7 +33,7 @@ else if (type == 'varchar') { size.val('255').removeAttr('disabled'); unique.removeAttr('disabled','disabled'); } else size.val('').attr('disabled','disabled'); } - init_typeoffields(''); + init_typeoffields('<?php echo GETPOST('type'); ?>'); jQuery("#type").change(function() { init_typeoffields($(this).val()); }); diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 85c8410da7e8bb42272aafca00af0e030f4e73de..01f85c32df43bb55df9ea7d39b9e1dd024f04e2f 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1017,7 +1017,7 @@ if ($step == 4 && $datatoimport) } else { - print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryFieldHaveNoSource")).'">'.$langs->trans("NextStep").'</a>'; + print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("SomeMandatoryFieldHaveNoSource")).'">'.$langs->trans("NextStep").'</a>'; } } @@ -1281,7 +1281,7 @@ if ($step == 5 && $datatoimport) } else { - print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("RunSimulateImportFile").'</a>'; + print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("RunSimulateImportFile").'</a>'; } print '</center>'; }