Skip to content
Snippets Groups Projects
Commit 0aa23606 authored by Charles Benke's avatar Charles Benke
Browse files

Update extrafields.class.php

add new extrafields type 'link'
parent df9f822a
Branches
Tags
No related merge requests found
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
* Copyright (C) 2009-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2009-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <forian.henry@open-concept.pro> * Copyright (C) 2013 Florian Henry <forian.henry@open-concept.pro>
* Copyright (C) 2015 Charles-Fr BENKE <charles.fr@benke.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -77,6 +78,7 @@ class ExtraFields ...@@ -77,6 +78,7 @@ class ExtraFields
'checkbox' => 'ExtrafieldCheckBox', 'checkbox' => 'ExtrafieldCheckBox',
'radio' => 'ExtrafieldRadio', 'radio' => 'ExtrafieldRadio',
'chkbxlst' => 'ExtrafieldCheckBoxFromList', 'chkbxlst' => 'ExtrafieldCheckBoxFromList',
'link' => 'ExtrafieldLink',
); );
/** /**
...@@ -187,6 +189,9 @@ class ExtraFields ...@@ -187,6 +189,9 @@ class ExtraFields
} elseif (($type=='select') || ($type=='sellist') || ($type=='radio') ||($type=='checkbox') ||($type=='chkbxlst')){ } elseif (($type=='select') || ($type=='sellist') || ($type=='radio') ||($type=='checkbox') ||($type=='chkbxlst')){
$typedb='text'; $typedb='text';
$lengthdb=''; $lengthdb='';
} elseif ($type=='link') {
$typedb='int';
$lengthdb='11';
} else { } else {
$typedb=$type; $typedb=$type;
$lengthdb=$length; $lengthdb=$length;
...@@ -404,6 +409,9 @@ class ExtraFields ...@@ -404,6 +409,9 @@ class ExtraFields
} elseif (($type=='select') || ($type=='sellist') || ($type=='radio') || ($type=='checkbox') || ($type=='chkbxlst')) { } elseif (($type=='select') || ($type=='sellist') || ($type=='radio') || ($type=='checkbox') || ($type=='chkbxlst')) {
$typedb='text'; $typedb='text';
$lengthdb=''; $lengthdb='';
} elseif ($type=='link') {
$typedb='int';
$lengthdb='11';
} else { } else {
$typedb=$type; $typedb=$type;
$lengthdb=$length; $lengthdb=$length;
...@@ -1043,6 +1051,19 @@ class ExtraFields ...@@ -1043,6 +1051,19 @@ class ExtraFields
} }
$out .= '</select>'; $out .= '</select>';
} }
elseif ($type == 'link')
{
$out='';
$param_list=array_keys($param['options']);
// 0 : ObjectName
// 1 : classPath
$InfoFieldList = explode(":", $param_list[0]);
dol_include_once($InfoFieldList[1]);
$object = new $InfoFieldList[0]($this->db);
$object->fetch($value);
$out='<input type="text" class="flat" name="options_'.$key.$keyprefix.'" size="20" value="'.$object->ref.'" >';
}
/* Add comments /* Add comments
if ($type == 'date') $out.=' (YYYY-MM-DD)'; if ($type == 'date') $out.=' (YYYY-MM-DD)';
elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)'; elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)';
...@@ -1268,6 +1289,21 @@ class ExtraFields ...@@ -1268,6 +1289,21 @@ class ExtraFields
} else } else
dol_syslog(get_class($this) . '::showOutputField error ' . $this->db->lasterror(), LOG_WARNING); dol_syslog(get_class($this) . '::showOutputField error ' . $this->db->lasterror(), LOG_WARNING);
} }
elseif ($type == 'link')
{
$out='';
$param_list=array_keys($params['options']);
// 0 : ObjectName
// 1 : classPath
$InfoFieldList = explode(":", $param_list[0]);
dol_include_once($InfoFieldList[1]);
$object = new $InfoFieldList[0]($this->db);
if ($value)
{
$object->fetch($value);
$value=$object->getNomUrl(3);
}
}
else else
{ {
$showsize=round($size); $showsize=round($size);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment