I added this onto coomondocgenerator.class.php
// Incoterms
$array_key.’_code_incoterms’=>$object->code_incoterms,
$array_key.’_libelle_incoterms’=>$object->libelle_incoterms,
$array_key.’_location_incoterms’=>$object->location_incoterms,
$array_key.’_fk_incoterms’=>$object->fk_incoterms,
{object_libelle_incoterms} : Replaced properly
{object_location_incoterms}: Replaced properly
{object_fk_incoterms}: Replaced properly (It’s row id)
{object_code_incoterms}: Replaced with empty
I think the SQL query isn’t taking anything
If I use $array_key.’_code_incoterms’=>$object->getIncotermsForPDF(), I got
« Incoterm : CIF - location »
f I use $array_key.’_code_incoterms’=>$object->display_incoterms(), I got
« CIF - location »
I recycled display_incoterms function on coomonobject.class.php file to make exactly what I want, but for me this solution feels dirty.
function display_incotermsODT()
{
$out = '';
$this->libelle_incoterms = '';
if (!empty($this->fk_incoterms))
{
$sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms;
$result = $this->db->query($sql);
if ($result)
{
$res = $this->db->fetch_object($result);
$out .= $res->code;
}
}
return $out;
}
Maybe this code can give as a clue. coomonobject.class.php file
[code]
/**
* Return incoterms informations
*
* @return string incoterms info
*/
function display_incoterms()
{
$out = ‹ ›;
$this->libelle_incoterms = ‹ ›;
if (!empty($this->fk_incoterms))
{
$sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms;
$result = $this->db->query($sql);
if ($result)
{
$res = $this->db->fetch_object($result);
$out .= $res->code;
}
}
$out .= ' - '.$this->location_incoterms;
return $out;
}
/**
* Return incoterms informations for pdf display
*
* @return string incoterms info
*/
function getIncotermsForPDF()
{
$sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms;
$resql = $this->db->query($sql);
if ($resql)
{
$res = $this->db->fetch_object($resql);
return 'Incoterm : '.$res->code.' - '.$this->location_incoterms;
}
else
{
return false;
}
}
/**
* Define incoterms values of current object
*
* @param int $id_incoterm Id of incoterm to set or '' to remove
* @param string $location location of incoterm
* @return int <0 if KO, >0 if OK
*/
function setIncoterms($id_incoterm, $location)
{
if ($this->id && $this->table_element)
{
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET fk_incoterms = ".($id_incoterm > 0 ? $id_incoterm : "null");
$sql.= ", location_incoterms = '".($id_incoterm > 0 ? $this->db->escape($location) : "null")."'";
$sql.= " WHERE rowid = " . $this->id;
dol_syslog(get_class($this).'::setIncoterms', LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$this->fk_incoterms = $id_incoterm;
$this->location_incoterms = $location;
$sql = 'SELECT libelle FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms;
$res = $this->db->query($sql);
if ($res)
{
$obj = $this->db->fetch_object($res);
$this->libelle_incoterms = $obj->libelle;
}
return 1;
}
else
{
return -1;
}
}
else return -1;
}[/code]