Unique function to show input or output of extrafields datas
This commit is contained in:
parent
6e66922a6b
commit
ec52f54a52
@ -2190,59 +2190,75 @@ abstract class CommonObject
|
|||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to show lines of extrafields with output datas
|
* Function to show lines of extrafields with output datas
|
||||||
*
|
*
|
||||||
* @param object $extrafields extrafield Object
|
* @param object $extrafields extrafield Object
|
||||||
|
* @param string $mode Show output (view) or input (edit) for extrafield
|
||||||
*
|
*
|
||||||
* return string
|
* return string
|
||||||
*/
|
*/
|
||||||
function showOptionals($extrafields)
|
function showOptionals($extrafields,$mode='view')
|
||||||
{
|
{
|
||||||
global $_POST;
|
global $_POST;
|
||||||
|
|
||||||
$out = '';
|
$out = '';
|
||||||
|
|
||||||
if (! empty($this->array_options))
|
if(count($extrafields->attribute_label) > 0)
|
||||||
{
|
{
|
||||||
$e = 0;
|
$out .= "\n";
|
||||||
foreach($extrafields->attribute_label as $key=>$label)
|
$out .= '<!-- showOptionalsInput --> ';
|
||||||
{
|
$out .= "\n";
|
||||||
$colspan='3';
|
|
||||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$this->array_options["options_".$key]);
|
$e = 0;
|
||||||
if ($extrafields->attribute_type[$key] == 'separate')
|
foreach($extrafields->attribute_label as $key=>$label)
|
||||||
{
|
{
|
||||||
$out = $extrafields->showSeparator($key);
|
$colspan='3';
|
||||||
}
|
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$this->array_options["options_".$key]);
|
||||||
else
|
if ($extrafields->attribute_type[$key] == 'separate')
|
||||||
{
|
{
|
||||||
if ( !empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0)
|
$out .= $extrafields->showSeparator($key);
|
||||||
{
|
}
|
||||||
$out .= '<tr>';
|
else
|
||||||
$colspan='0';
|
{
|
||||||
}
|
if ( !empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0)
|
||||||
else
|
{
|
||||||
{
|
$out .= '<tr>';
|
||||||
$out .= '<tr>';
|
$colspan='0';
|
||||||
}
|
}
|
||||||
// Convert date into timestamp format
|
else
|
||||||
if (in_array($extrafields->attribute_type[$key],array('date','datetime')))
|
{
|
||||||
{
|
$out .= '<tr>';
|
||||||
$value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$this->array_options['options_'.$key];
|
}
|
||||||
}
|
// Convert date into timestamp format
|
||||||
$out .= '<td>'.$label.'</td>';
|
if (in_array($extrafields->attribute_type[$key],array('date','datetime')))
|
||||||
$out .='<td colspan="'.$colspan.'">';
|
{
|
||||||
$out .= $extrafields->showOutputField($key,$value);
|
$value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$this->array_options['options_'.$key];
|
||||||
$out .= '</td>'."\n";
|
}
|
||||||
|
$out .= '<td>'.$label.'</td>';
|
||||||
if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= '</tr>';
|
$out .='<td colspan="'.$colspan.'">';
|
||||||
else $out .= '</tr>';
|
|
||||||
$e++;
|
switch($mode) {
|
||||||
}
|
case "view":
|
||||||
}
|
$out .= $extrafields->showOutputField($key,$value);
|
||||||
}
|
break;
|
||||||
return $out;
|
case "edit":
|
||||||
}
|
$out .= $extrafields->showInputField($key,$value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$out .= '</td>'."\n";
|
||||||
|
|
||||||
|
if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= '</tr>';
|
||||||
|
else $out .= '</tr>';
|
||||||
|
$e++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$out .= "\n";
|
||||||
|
$out .= '<!-- /showOptionalsInput --> ';
|
||||||
|
}
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user