Skip to content

Commit

Permalink
Merge pull request #5595 from atm-florian/FIX_5594
Browse files Browse the repository at this point in the history
FIX #5594
  • Loading branch information
eldy committed Aug 9, 2016
2 parents 112b945 + 90cb71f commit 4a1fbff
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions htdocs/core/class/extrafields.class.php
Expand Up @@ -675,7 +675,7 @@ function showInputField($key,$value,$moreparam='',$keyprefix='',$keysuffix='',$s
if ($showsize > 48) $showsize=48;
}
}

if (in_array($type,array('date','datetime')))
{
$tmp=explode(',',$size);
Expand Down Expand Up @@ -812,7 +812,7 @@ function showInputField($key,$value,$moreparam='',$keyprefix='',$keysuffix='',$s
if (strpos($InfoFieldList[4], '$SEL$')!==false) {
$InfoFieldList[4]=str_replace('$SEL$','SELECT',$InfoFieldList[4]);
}

// current object id can be use into filter
if (strpos($InfoFieldList[4], '$ID$')!==false && !empty($objectid)) {
$InfoFieldList[4]=str_replace('$ID$',$objectid,$InfoFieldList[4]);
Expand All @@ -830,14 +830,14 @@ function showInputField($key,$value,$moreparam='',$keyprefix='',$keysuffix='',$s
$sqlwhere.= ' WHERE '.$InfoFieldList[4];
}
}
else
else
{
$sqlwhere.= ' WHERE 1=1';
}
// Some tables may have field, some other not. For the moment we disable it.
if (in_array($InfoFieldList[0],array('tablewithentity')))
if (in_array($InfoFieldList[0],array('tablewithentity')))
{
$sqlwhere.= ' AND entity = '.$conf->entity;
$sqlwhere.= ' AND entity = '.$conf->entity;
}
$sql.=$sqlwhere;
//print $sql;
Expand Down Expand Up @@ -996,19 +996,19 @@ function showInputField($key,$value,$moreparam='',$keyprefix='',$keysuffix='',$s
$sql = 'SELECT ' . $keyList;
$sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0];
if (! empty($InfoFieldList[4])) {

// can use SELECT request
if (strpos($InfoFieldList[4], '$SEL$')!==false) {
$InfoFieldList[4]=str_replace('$SEL$','SELECT',$InfoFieldList[4]);
}

// current object id can be use into filter
if (strpos($InfoFieldList[4], '$ID$')!==false && !empty($objectid)) {
$InfoFieldList[4]=str_replace('$ID$',$objectid,$InfoFieldList[4]);
} else {
$InfoFieldList[4]=str_replace('$ID$','0',$InfoFieldList[4]);
}

// We have to join on extrafield table
if (strpos($InfoFieldList[4], 'extra') !== false) {
$sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList[0] . '_extrafields as extra';
Expand All @@ -1020,13 +1020,13 @@ function showInputField($key,$value,$moreparam='',$keyprefix='',$keysuffix='',$s
$sqlwhere .= ' WHERE 1=1';
}
// Some tables may have field, some other not. For the moment we disable it.
if (in_array($InfoFieldList[0], array ('tablewithentity')))
if (in_array($InfoFieldList[0], array ('tablewithentity')))
{
$sqlwhere .= ' AND entity = ' . $conf->entity;
}
// $sql.=preg_replace('/^ AND /','',$sqlwhere);
// print $sql;

$sql .= $sqlwhere;
dol_syslog(get_class($this) . '::showInputField type=chkbxlst',LOG_DEBUG);
$resql = $this->db->query($sql);
Expand Down Expand Up @@ -1232,7 +1232,12 @@ function showOutputField($key,$value,$moreparam='')
{
$sql.= ' as main';
}
$sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'";
if ($selectkey=='rowid') {
$sql.= " WHERE ".$selectkey."=".$this->db->escape($value);
} else {
$sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'";
}

//$sql.= ' AND entity = '.$conf->entity;

dol_syslog(get_class($this).':showOutputField:$type=sellist', LOG_DEBUG);
Expand Down Expand Up @@ -1391,10 +1396,10 @@ function showOutputField($key,$value,$moreparam='')
$showsize=round($size);
if ($showsize > 48) $showsize=48;
}

//print $type.'-'.$size;
$out=$value;

return $out;
}

Expand All @@ -1411,7 +1416,7 @@ function getAlignFlag($key)
$type=$this->attribute_type[$key];

$align='';

if ($type == 'date')
{
$align="center";
Expand Down Expand Up @@ -1440,10 +1445,10 @@ function getAlignFlag($key)
{
$align="center";
}

return $align;
}

/**
* Return HTML string to print separator extrafield
*
Expand Down Expand Up @@ -1523,7 +1528,7 @@ function setOptionalsFromPost($extralabels,&$object,$onlykey='')
return 0;
}
}

/**
* return array_options array for object by extrafields value (using for data send by forms)
*
Expand Down

0 comments on commit 4a1fbff

Please sign in to comment.