Fix: Try another fix on getTrad bug.
This commit is contained in:
parent
4b27a9215b
commit
bdb7becbc6
@ -510,7 +510,6 @@ if ($id > 0 || ! empty($ref))
|
|||||||
// Payment type
|
// Payment type
|
||||||
print "<td nowrap>";
|
print "<td nowrap>";
|
||||||
$label=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$objp->fk_type;
|
$label=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$objp->fk_type;
|
||||||
// $label=$langs->getTradFromKey("PaymentTypeShort".$objp->fk_type);
|
|
||||||
|
|
||||||
if ($objp->fk_type == 'SOLD') $label=' ';
|
if ($objp->fk_type == 'SOLD') $label=' ';
|
||||||
print $label;
|
print $label;
|
||||||
|
|||||||
@ -327,6 +327,7 @@ class Translate
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return translated value of key. Search in lang file, then into database.
|
* Return translated value of key. Search in lang file, then into database.
|
||||||
|
* Key must be any complete entry into lang file: CurrencyEUR, ...
|
||||||
* If not found, return key.
|
* If not found, return key.
|
||||||
* WARNING: To avoid infinite loop (getLabelFromKey->transnoentities->getTradFromKey), getLabelFromKey must
|
* WARNING: To avoid infinite loop (getLabelFromKey->transnoentities->getTradFromKey), getLabelFromKey must
|
||||||
* not be called with same value than input.
|
* not be called with same value than input.
|
||||||
@ -334,7 +335,7 @@ class Translate
|
|||||||
* @param string $key Key to translate
|
* @param string $key Key to translate
|
||||||
* @return string Translated string
|
* @return string Translated string
|
||||||
*/
|
*/
|
||||||
function getTradFromKey($key)
|
private function getTradFromKey($key)
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
@ -342,19 +343,19 @@ class Translate
|
|||||||
$newstr=$key;
|
$newstr=$key;
|
||||||
if (preg_match('/^Currency([A-Z][A-Z][A-Z])$/i',$key,$reg))
|
if (preg_match('/^Currency([A-Z][A-Z][A-Z])$/i',$key,$reg))
|
||||||
{
|
{
|
||||||
$newstr=$this->getLabelFromKey($db,$key,'c_currencies','code_iso','label',$reg[1]);
|
$newstr=$this->getLabelFromKey($db,$reg[1],'c_currencies','code_iso','label');
|
||||||
}
|
}
|
||||||
else if (preg_match('/^SendingMethod([0-9A-Z]+)$/i',$key,$reg))
|
else if (preg_match('/^SendingMethod([0-9A-Z]+)$/i',$key,$reg))
|
||||||
{
|
{
|
||||||
$newstr=$this->getLabelFromKey($db,$key,'c_shipment_mode','code','libelle',$reg[1]);
|
$newstr=$this->getLabelFromKey($db,$reg[1],'c_shipment_mode','code','libelle');
|
||||||
}
|
}
|
||||||
else if (preg_match('/^PaymentTypeShort([0-9A-Z]+)$/i',$key,$reg))
|
else if (preg_match('/^PaymentTypeShort([0-9A-Z]+)$/i',$key,$reg))
|
||||||
{
|
{
|
||||||
$newstr=$this->getLabelFromKey($db,$key,'c_paiement','code','libelle',$reg[1]);
|
$newstr=$this->getLabelFromKey($db,$reg[1],'c_paiement','code','libelle');
|
||||||
}
|
}
|
||||||
else if (preg_match('/^Civility([0-9A-Z]+)$/i',$key,$reg))
|
else if (preg_match('/^Civility([0-9A-Z]+)$/i',$key,$reg))
|
||||||
{
|
{
|
||||||
$newstr=$this->getLabelFromKey($db,$key,'c_civilite','code','civilite',$reg[1]);
|
$newstr=$this->getLabelFromKey($db,$reg[1],'c_civilite','code','civilite');
|
||||||
}
|
}
|
||||||
else if (preg_match('/^OrderSource([0-9A-Z]+)$/i',$key,$reg))
|
else if (preg_match('/^OrderSource([0-9A-Z]+)$/i',$key,$reg))
|
||||||
{
|
{
|
||||||
@ -616,29 +617,28 @@ class Translate
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a label for a key. Store key-label into cache variable $this->cache_labels to save SQL requests to get labels.
|
* Return a label for a key.
|
||||||
* This function can be used to get label in database but more often to get code from key id.
|
* Search into translation array, then into cache, then if still not found, search into database.
|
||||||
|
* Store key-label found into cache variable $this->cache_labels to save SQL requests to get labels.
|
||||||
*
|
*
|
||||||
* @param DoliBD $db Database handler
|
* @param DoliBD $db Database handler
|
||||||
* @param string $key Key to get label (key in language file)
|
* @param string $key Key to get label (key in language file)
|
||||||
* @param string $tablename Table name without prefix
|
* @param string $tablename Table name without prefix
|
||||||
* @param string $fieldkey Field for key
|
* @param string $fieldkey Field for key
|
||||||
* @param string $fieldlabel Field for label
|
* @param string $fieldlabel Field for label
|
||||||
* @param string $keyindatabase Key to get label (key in database table)
|
|
||||||
* @return string Label in UTF8 (but without entities)
|
* @return string Label in UTF8 (but without entities)
|
||||||
*/
|
*/
|
||||||
function getLabelFromKey($db,$key,$tablename,$fieldkey,$fieldlabel,$keydatabase='')
|
function getLabelFromKey($db,$key,$tablename,$fieldkey,$fieldlabel)
|
||||||
{
|
{
|
||||||
// If key empty
|
// If key empty
|
||||||
if ($key == '') return '';
|
if ($key == '') return '';
|
||||||
if (empty($keydatabase)) $keydatabase=$key;
|
|
||||||
|
|
||||||
//print 'param: '.$key.'-'.$keydatabase.'-'.$this->trans($key); exit;
|
//print 'param: '.$key.'-'.$keydatabase.'-'.$this->trans($key); exit;
|
||||||
|
|
||||||
// Check in language array
|
// Check if in language array (this can call getTradFromKey)
|
||||||
if ($this->transnoentities($key) != $key)
|
if ($this->transnoentitiesnoconv($key) != $key)
|
||||||
{
|
{
|
||||||
return $this->transnoentities($key); // Found in language array
|
return $this->transnoentitiesnoconv($key); // Found in language array
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check in cache
|
// Check in cache
|
||||||
@ -649,7 +649,7 @@ class Translate
|
|||||||
|
|
||||||
$sql = "SELECT ".$fieldlabel." as label";
|
$sql = "SELECT ".$fieldlabel." as label";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX.$tablename;
|
$sql.= " FROM ".MAIN_DB_PREFIX.$tablename;
|
||||||
$sql.= " WHERE ".$fieldkey." = '".$keydatabase."'";
|
$sql.= " WHERE ".$fieldkey." = '".$key."'";
|
||||||
dol_syslog(get_class($this).'::getLabelFromKey sql='.$sql,LOG_DEBUG);
|
dol_syslog(get_class($this).'::getLabelFromKey sql='.$sql,LOG_DEBUG);
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
|
|||||||
@ -546,7 +546,7 @@ class pdf_crabe extends ModelePDFFactures
|
|||||||
$pdf->SetXY($tab3_posx+21, $tab3_top+$y);
|
$pdf->SetXY($tab3_posx+21, $tab3_top+$y);
|
||||||
$pdf->MultiCell(20, 3, price($row->amount), 0, 'L', 0);
|
$pdf->MultiCell(20, 3, price($row->amount), 0, 'L', 0);
|
||||||
$pdf->SetXY($tab3_posx+40, $tab3_top+$y);
|
$pdf->SetXY($tab3_posx+40, $tab3_top+$y);
|
||||||
$oper = $outputlangs->getTradFromKey("PaymentTypeShort" . $row->code);
|
$oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code);
|
||||||
|
|
||||||
$pdf->MultiCell(20, 3, $oper, 0, 'L', 0);
|
$pdf->MultiCell(20, 3, $oper, 0, 'L', 0);
|
||||||
$pdf->SetXY($tab3_posx+58, $tab3_top+$y);
|
$pdf->SetXY($tab3_posx+58, $tab3_top+$y);
|
||||||
|
|||||||
@ -765,7 +765,7 @@ if ($pageposafter > $pageposbefore) {
|
|||||||
$pdf->SetXY($tab3_posx+21, $tab3_top+$y);
|
$pdf->SetXY($tab3_posx+21, $tab3_top+$y);
|
||||||
$pdf->MultiCell(20, 3, price($row->amount), 0, 'L', 0);
|
$pdf->MultiCell(20, 3, price($row->amount), 0, 'L', 0);
|
||||||
$pdf->SetXY($tab3_posx+40, $tab3_top+$y);
|
$pdf->SetXY($tab3_posx+40, $tab3_top+$y);
|
||||||
$oper = $outputlangs->getTradFromKey("PaymentTypeShort" . $row->code);
|
$oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code);
|
||||||
|
|
||||||
$pdf->MultiCell(20, 3, $oper, 0, 'L', 0);
|
$pdf->MultiCell(20, 3, $oper, 0, 'L', 0);
|
||||||
$pdf->SetXY($tab3_posx+58, $tab3_top+$y);
|
$pdf->SetXY($tab3_posx+58, $tab3_top+$y);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user