diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7b21c9ca20c..0012a4c5bd8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4092,14 +4092,14 @@ function dol_osencode($str) /** - * Return an id or code from a code or id. Store Code-Id in a cache. + * Return an id or code from a code or id. Store also Code-Id into a cache for next use. * * @param DoliDB $db Database handler * @param string $key Code to get Id * @param string $tablename Table name without prefix * @param string $fieldkey Field for code * @param string $fieldid Field for id - * @return int Id of code + * @return int <0 if KO, Id of code if OK * @see getLabelFromKey */ function dol_getIdFromCode($db,$key,$tablename,$fieldkey='code',$fieldid='id') @@ -4118,7 +4118,7 @@ function dol_getIdFromCode($db,$key,$tablename,$fieldkey='code',$fieldid='id') $sql = "SELECT ".$fieldid." as id"; $sql.= " FROM ".MAIN_DB_PREFIX.$tablename; $sql.= " WHERE ".$fieldkey." = '".$key."'"; - dol_syslog('dol_getIdFromCode sql='.$sql,LOG_DEBUG); + dol_syslog('dol_getIdFromCode sql='.$sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { @@ -4130,7 +4130,7 @@ function dol_getIdFromCode($db,$key,$tablename,$fieldkey='code',$fieldid='id') } else { - dol_syslog("dol_getIdFromCode error=".$db->lasterror(),LOG_ERR); + dol_syslog("dol_getIdFromCode error=".$db->lasterror(), LOG_ERR); return -1; } } diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index f58d2522079..89776835e2a 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -160,7 +160,7 @@ abstract class ActionsCardCommon $this->object->effectif_id = $_POST["effectif_id"]; if (GETPOST("private") == 1) { - $this->object->typent_id = 8; // TODO predict another method if the field "special" change of rowid + $this->object->typent_id = dol_getIdFromCode($db,'TE_PRIVATE','c_typent'); } else { diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 7d7e1d910ee..c3bfb832f61 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -158,7 +158,7 @@ if (empty($reshook)) $object->effectif_id = GETPOST('effectif_id'); if (GETPOST("private") == 1) { - $object->typent_id = 8; // TODO predict another method if the field "special" change of rowid + $object->typent_id = dol_getIdFromCode($db,'TE_PRIVATE','c_typent'); } else {