diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 934eb672c7c..0c7d8baec0d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4105,7 +4105,7 @@ abstract class CommonObject $out .= $extrafields->showOutputField($key,$value); break; case "edit": - $out .= $extrafields->showInputField($key,$value,'',$keyprefix); + $out .= $extrafields->showInputField($key,$value,'',$keyprefix,'',0,$this->id); break; } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 645b50cb8bc..82754a309b9 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -636,10 +636,11 @@ class ExtraFields * @param string $moreparam To add more parametes on html input tag * @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names) * @param string $keysuffix Suffix string to add into name and id of field (can be used to avoid duplicate names) - * @param int $showsize Value for size attribute + * @param int $showsize Value for size attributed + * @param int $objectid Current object id * @return string */ - function showInputField($key,$value,$moreparam='',$keyprefix='',$keysuffix='',$showsize=0) + function showInputField($key,$value,$moreparam='',$keyprefix='',$keysuffix='',$showsize=0, $objectid=0) { global $conf,$langs; @@ -805,6 +806,17 @@ class ExtraFields $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) { @@ -820,7 +832,11 @@ class ExtraFields { $sqlwhere.= ' WHERE 1'; } - if (in_array($InfoFieldList[0],array('tablewithentity'))) $sqlwhere.= ' AND entity = '.$conf->entity; // Some tables may have field, some other not. For the moment we disable it. + // Some tables may have field, some other not. For the moment we disable it. + if (in_array($InfoFieldList[0],array('tablewithentity'))) + { + $sqlwhere.= ' AND entity = '.$conf->entity; + } $sql.=$sqlwhere; //print $sql; @@ -978,6 +994,19 @@ class ExtraFields $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'; @@ -988,12 +1017,14 @@ class ExtraFields } else { $sqlwhere .= ' WHERE 1'; } - if (in_array($InfoFieldList[0], array ( - 'tablewithentity' - ))) - $sqlwhere .= ' AND entity = ' . $conf->entity; // Some tables may have field, some other not. For the moment we disable it. - // $sql.=preg_replace('/^ AND /','',$sqlwhere); - // print $sql; + // Some tables may have field, some other not. For the moment we disable it. + 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); diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index ca8785acdfb..b29016ac28b 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -81,7 +81,7 @@ if (empty($reshook) && ! empty($extrafields->attribute_label)) print ''; print ''; - print $extrafields->showInputField($key, $value); + print $extrafields->showInputField($key, $value,'','','',0,$object->id); print ''; diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index c472878a21c..99a042c8c31 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -79,7 +79,8 @@ ALTER TABLE llx_paiement ADD COLUMN ref varchar(30) NOT NULL DEFAULT '' AFTER ro ALTER TABLE llx_socpeople ADD COLUMN photo varchar(255) AFTER skype; -ALTER TABLE llx_user_param MODIFY COLUMN param varchar(255) NOT NULL DEFAULT ''; +UPDATE llx_user_param SET param='ToDelete' WHERE param IS NULL; +ALTER TABLE llx_user_param MODIFY COLUMN param varchar(255) NOT NULL; ALTER TABLE llx_user_param MODIFY COLUMN value text NOT NULL; ALTER TABLE llx_expedition ADD COLUMN import_key varchar(14); @@ -323,7 +324,8 @@ ALTER TABLE llx_categorie_project ADD CONSTRAINT fk_categorie_project_fk_project ALTER TABLE llx_c_tva ADD COLUMN code varchar(10) DEFAULT '' after fk_pays; -DROP INDEX uk_c_tva_id ON llx_c_tva; +-- VMYSQL4.0 DROP INDEX uk_c_tva_id ON llx_c_tva; +-- VPGSQL8.0 DROP INDEX uk_c_tva_id; ALTER TABLE llx_c_tva ADD UNIQUE INDEX uk_c_tva_id (fk_pays, code, taux, recuperableonly); -- Regions Bolivia (id country=52) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index f4d311c8f27..eacf9b6e5ce 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -397,8 +397,8 @@ ExtrafieldLink=Link to an object ExtrafieldParamHelpselect=Parameters list have to be like key,value

for example :
1,value1
2,value2
3,value3
...

In order to have the list depending on another :
1,value1|parent_list_code:parent_key
2,value2|parent_list_code:parent_key ExtrafieldParamHelpcheckbox=Parameters list have to be like key,value

for example :
1,value1
2,value2
3,value3
... ExtrafieldParamHelpradio=Parameters list have to be like key,value

for example :
1,value1
2,value2
3,value3
... -ExtrafieldParamHelpsellist=Parameters list comes from a table
Syntax : table_name:label_field:id_field::filter
Example : c_typent:libelle:id::filter

filter can be a simple test (eg active=1) to display only active value
if you want to filter on extrafields use syntaxt extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another :
c_typent:libelle:id:parent_list_code|parent_column:filter -ExtrafieldParamHelpchkbxlst=Parameters list comes from a table
Syntax : table_name:label_field:id_field::filter
Example : c_typent:libelle:id::filter

filter can be a simple test (eg active=1) to display only active value
if you want to filter on extrafields use syntaxt extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another :
c_typent:libelle:id:parent_list_code|parent_column:filter +ExtrafieldParamHelpsellist=Parameters list comes from a table
Syntax : table_name:label_field:id_field::filter
Example : c_typent:libelle:id::filter

filter can be a simple test (eg active=1) to display only active value
You can also use $ID$ in filter witch is the current id of current object
To do a SELECT in filter use $SEL$
if you want to filter on extrafields use syntaxt extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another :
c_typent:libelle:id:parent_list_code|parent_column:filter +ExtrafieldParamHelpchkbxlst=Parameters list comes from a table
Syntax : table_name:label_field:id_field::filter
Example : c_typent:libelle:id::filter

filter can be a simple test (eg active=1) to display only active value
You can also use $ID$ in filter witch is the current id of current object
To do a SELECT in filter use $SEL$
if you want to filter on extrafields use syntaxt extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another :
c_typent:libelle:id:parent_list_code|parent_column:filter ExtrafieldParamHelplink=Parameters must be ObjectName:Classpath
Syntax : ObjectName:Classpath
Example : Societe:societe/class/societe.class.php LibraryToBuildPDF=Library used to build PDF WarningUsingFPDF=Warning: Your conf.php contains directive dolibarr_pdf_force_fpdf=1. This means you use the FPDF library to generate PDF files. This library is old and does not support a lot of features (Unicode, image transparency, cyrillic, arab and asiatic languages, ...), so you may experience errors during PDF generation.
To solve this and have a full support of PDF generation, please download TCPDF library, then comment or remove the line $dolibarr_pdf_force_fpdf=1, and add instead $dolibarr_lib_TCPDF_PATH='path_to_TCPDF_dir'