diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 53211070923..e4cd29813db 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2010-2011 Juanjo Menent * Copyright (C) 2010-2012 Philippe Grand + * Copyright (C) 2012 Marcos García * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1840,6 +1841,43 @@ class CommandeFournisseur extends CommonOrder return -1; } } + + /** + * Returns the translated input method + * + * @return string + */ + function getInputMethod() + { + global $db, $langs; + + if ($this->methode_commande_id > 0) + { + $sql = "SELECT rowid, code, libelle"; + $sql.= " FROM ".MAIN_DB_PREFIX.'c_input_method'; + $sql.= " WHERE active=1 AND rowid = ".$db->escape($this->methode_commande_id); + + $query = $db->query($sql); + + if ($query && $db->num_rows($query)) + { + $result = $db->fetch_object($query); + + $string = $langs->trans($result->code); + + if ($string == $result->code) + { + $string = $obj->libelle != '-' ? $obj->libelle : ''; + } + + return $string; + } + + dol_print_error($db); + } + + return ''; + } } diff --git a/htdocs/fourn/commande/document.php b/htdocs/fourn/commande/document.php index da69298763e..80530156201 100644 --- a/htdocs/fourn/commande/document.php +++ b/htdocs/fourn/commande/document.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2012 Marcos García * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -160,7 +161,7 @@ if ($object->id > 0) if ($object->methode_commande) { - print ''.$langs->trans("Method").''.$object->methode_commande.''; + print ''.$langs->trans("Method").''.$object->getInputMethod().''; } } diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 18de50e8c2c..7837a4c347a 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -1118,25 +1118,7 @@ if ($id > 0 || ! empty($ref)) if ($object->methode_commande) { - $sql = "SELECT rowid, code, libelle"; - $sql.= " FROM ".MAIN_DB_PREFIX.'c_input_method'; - $sql.= " WHERE active=1 AND rowid = ".$db->escape($object->methode_commande_id); - - $resql = $db->query($sql); - - if ($resql && $db->num_rows($resql)) - { - $obj = $db->fetch_object($resql); - - // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut - $methode_commande = ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->libelle!='-'?$obj->libelle:'')); - } - else - { - dol_print_error($db); - } - - print ''.$langs->trans("Method").''.$methode_commande.''; + print ''.$langs->trans("Method").''.$object->getInputMethod().''; } } diff --git a/htdocs/fourn/commande/history.php b/htdocs/fourn/commande/history.php index 2ba34ecc885..4dd2e12fd0e 100644 --- a/htdocs/fourn/commande/history.php +++ b/htdocs/fourn/commande/history.php @@ -109,7 +109,7 @@ if ($id > 0 || ! empty($ref)) if ($commande->methode_commande) { - print ''.$langs->trans("Method").''.$commande->methode_commande.''; + print ''.$langs->trans("Method").''.$commande->getInputMethod().''; } } diff --git a/htdocs/fourn/commande/note.php b/htdocs/fourn/commande/note.php index d3e61d40999..3fd9a18a8f5 100644 --- a/htdocs/fourn/commande/note.php +++ b/htdocs/fourn/commande/note.php @@ -1,7 +1,8 @@ * Copyright (C) 2004-2009 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2012 Marcos García * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -130,7 +131,7 @@ if ($id > 0 || ! empty($ref)) if ($object->methode_commande) { - print ''.$langs->trans("Method").''.$object->methode_commande.''; + print ''.$langs->trans("Method").''.$object->getInputMethod().''; } }