mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-12 02:42:33 +01:00
Merge pull request #2450 from defrance69/patch-52
New type of extrafields : link to connect dolibarr elements
This commit is contained in:
@@ -80,6 +80,13 @@ if ($action == 'add')
|
||||
$mesg[]=$langs->trans("ErrorNoValueForCheckBoxType");
|
||||
$action = 'create';
|
||||
}
|
||||
if (GETPOST('type')=='link' && !GETPOST('param'))
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
$mesg[]=$langs->trans("ErrorNoValueForLinkType");
|
||||
$action = 'create';
|
||||
}
|
||||
if (GETPOST('type')=='radio' && !GETPOST('param'))
|
||||
{
|
||||
$error++;
|
||||
|
||||
@@ -3624,6 +3624,7 @@ abstract class CommonObject
|
||||
$attributeType = $extrafields->attribute_type[$attributeKey];
|
||||
$attributeSize = $extrafields->attribute_size[$attributeKey];
|
||||
$attributeLabel = $extrafields->attribute_label[$attributeKey];
|
||||
$attributeParam = $extrafields->attribute_param[$attributeKey];
|
||||
switch ($attributeType)
|
||||
{
|
||||
case 'int':
|
||||
@@ -3646,6 +3647,19 @@ abstract class CommonObject
|
||||
case 'datetime':
|
||||
$this->array_options[$key]=$this->db->idate($this->array_options[$key]);
|
||||
break;
|
||||
case 'link':
|
||||
$param_list=array_keys($attributeParam ['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(0,$value);
|
||||
$this->array_options[$key]=$object->id;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->db->begin();
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* Copyright (C) 2009-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -77,6 +78,7 @@ class ExtraFields
|
||||
'checkbox' => 'ExtrafieldCheckBox',
|
||||
'radio' => 'ExtrafieldRadio',
|
||||
'chkbxlst' => 'ExtrafieldCheckBoxFromList',
|
||||
'link' => 'ExtrafieldLink',
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -187,6 +189,9 @@ class ExtraFields
|
||||
} elseif (($type=='select') || ($type=='sellist') || ($type=='radio') ||($type=='checkbox') ||($type=='chkbxlst')){
|
||||
$typedb='text';
|
||||
$lengthdb='';
|
||||
} elseif ($type=='link') {
|
||||
$typedb='int';
|
||||
$lengthdb='11';
|
||||
} else {
|
||||
$typedb=$type;
|
||||
$lengthdb=$length;
|
||||
@@ -404,6 +409,9 @@ class ExtraFields
|
||||
} elseif (($type=='select') || ($type=='sellist') || ($type=='radio') || ($type=='checkbox') || ($type=='chkbxlst')) {
|
||||
$typedb='text';
|
||||
$lengthdb='';
|
||||
} elseif ($type=='link') {
|
||||
$typedb='int';
|
||||
$lengthdb='11';
|
||||
} else {
|
||||
$typedb=$type;
|
||||
$lengthdb=$length;
|
||||
@@ -1043,6 +1051,19 @@ class ExtraFields
|
||||
}
|
||||
$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
|
||||
if ($type == 'date') $out.=' (YYYY-MM-DD)';
|
||||
elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)';
|
||||
@@ -1268,6 +1289,21 @@ class ExtraFields
|
||||
} else
|
||||
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
|
||||
{
|
||||
$showsize=round($size);
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
else if (type == 'boolean') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();}
|
||||
else if (type == 'price') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();}
|
||||
else if (type == 'select') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();}
|
||||
else if (type == 'link') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();}
|
||||
else if (type == 'sellist') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").show();jQuery("#helpchkbxlst").hide();}
|
||||
else if (type == 'checkbox') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();}
|
||||
else if (type == 'radio') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();}
|
||||
|
||||
@@ -68,7 +68,7 @@ if((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_ar
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (($type== 'sellist') || ($type == 'chkbxlst'))
|
||||
elseif (($type== 'sellist') || ($type == 'chkbxlst') || ($type == 'link') )
|
||||
{
|
||||
$paramlist=array_keys($param['options']);
|
||||
$param_chain = $paramlist[0];
|
||||
|
||||
Reference in New Issue
Block a user