From 470ccba80af9dd97746f8f2416f1e5b1c13ae771 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Sep 2013 15:41:04 +0200 Subject: [PATCH] Qual: Fix two awful code with hardcoded values. This remove also 2 TODO. --- htdocs/core/lib/functions.lib.php | 8 ++++---- htdocs/societe/canvas/actions_card_common.class.php | 2 +- htdocs/societe/soc.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) 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 {