30,997
edits
PolyglotBot (talk | contribs) m (Import interlang links (links to translated versions of this page in other languages) from origin English page "Extrafields".) |
mNo edit summary Tag: 2017 source edit |
||
| Line 54: | Line 54: | ||
== 加载附加字段类 == | == 加载附加字段类 == | ||
使用附加字段需要包括 | 使用附加字段需要包括 | ||
< | <syntaxhighlight lang="PHP"> | ||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; | ||
</ | </syntaxhighlight> | ||
== 加载附加字段数组于对象 == | == 加载附加字段数组于对象 == | ||
< | <syntaxhighlight lang="PHP"> | ||
$extrafields = new ExtraFields($db); | $extrafields = new ExtraFields($db); | ||
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); | $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); | ||
</ | </syntaxhighlight> | ||
$extralabels 将是带代码和附加字段标签的数组。 | $extralabels 将是带代码和附加字段标签的数组。 | ||
| Line 72: | Line 72: | ||
附加字段的加载,使用 $object->array_options 数组。 | 附加字段的加载,使用 $object->array_options 数组。 | ||
< | <syntaxhighlight lang="PHP"> | ||
$object->fetch($rowid); | $object->fetch($rowid); | ||
$object->fetch_optionals($rowid,$extralabels); | $object->fetch_optionals($rowid,$extralabels); | ||
</ | </syntaxhighlight> | ||
这个代码必须放在上面的后面。 | 这个代码必须放在上面的后面。 | ||
| Line 83: | Line 83: | ||
HTML 示例 | HTML 示例 | ||
< | <syntaxhighlight lang="PHP"> | ||
print $object->array_options ['options_XXX']; | print $object->array_options ['options_XXX']; | ||
</ | </syntaxhighlight> | ||
此处 XXX 为附加字段代码 | 此处 XXX 为附加字段代码 | ||
PDF 示例 | PDF 示例 | ||
< | <syntaxhighlight lang="PHP"> | ||
$pdf->MultiCell (0,5, $outputlangs->convToOutputCharset($object->array_options ['options_XXX']),0,'L'); ) | $pdf->MultiCell (0,5, $outputlangs->convToOutputCharset($object->array_options ['options_XXX']),0,'L'); ) | ||
</ | </syntaxhighlight> | ||
此处 XXX 为附加字段代码 | 此处 XXX 为附加字段代码 | ||
| Line 98: | Line 98: | ||
HTML 示例 | HTML 示例 | ||
< | <syntaxhighlight lang="PHP"> | ||
print $object->lines[$i]->array_options['options_XXX']; | print $object->lines[$i]->array_options['options_XXX']; | ||
</ | </syntaxhighlight> | ||
此处 XXX 为附加字段代码 | 此处 XXX 为附加字段代码 | ||
PDF 示例 | PDF 示例 | ||
< | <syntaxhighlight lang="PHP"> | ||
$pdf->MultiCell (0,5, $outputlangs->convToOutputCharset($object->lines[$i]->array_options['options_XXX']),0,'L'); | $pdf->MultiCell (0,5, $outputlangs->convToOutputCharset($object->lines[$i]->array_options['options_XXX']),0,'L'); | ||
</ | </syntaxhighlight> | ||
此处 XXX 为附加字段代码 | 此处 XXX 为附加字段代码 | ||
| Line 113: | Line 113: | ||
表单发送的附加字段的值需要取回。为此,使用此方法: | 表单发送的附加字段的值需要取回。为此,使用此方法: | ||
< | <syntaxhighlight lang="PHP"> | ||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); | $ret = $extrafields->setOptionalsFromPost($extralabels,$object); | ||
</ | </syntaxhighlight> | ||
== 内部编辑页面显示附加字段 == | == 内部编辑页面显示附加字段 == | ||
< | <syntaxhighlight lang="PHP"> | ||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook | $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook | ||
if (empty($reshook) && ! empty($extrafields->attribute_label)) | if (empty($reshook) && ! empty($extrafields->attribute_label)) | ||
| Line 126: | Line 126: | ||
print $object->showOptionals($extrafields,'edit'); | print $object->showOptionals($extrafields,'edit'); | ||
} | } | ||
</ | </syntaxhighlight> | ||
== 内部显示页面显示附加字段 == | == 内部显示页面显示附加字段 == | ||
< | <syntaxhighlight lang="PHP"> | ||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook | $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook | ||
if (empty($reshook) && ! empty($extrafields->attribute_label)) | if (empty($reshook) && ! empty($extrafields->attribute_label)) | ||
| Line 136: | Line 136: | ||
print $object->showOptionals($extrafields); | print $object->showOptionals($extrafields); | ||
} | } | ||
</ | </syntaxhighlight> | ||
== 对象类的 fetch 方法之后 == | == 对象类的 fetch 方法之后 == | ||
< | <syntaxhighlight lang="PHP"> | ||
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); | require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); | ||
$extrafields=new ExtraFields($this->db); | $extrafields=new ExtraFields($this->db); | ||
| Line 146: | Line 146: | ||
$this->fetch_optionals($this->id,$extralabels); | $this->fetch_optionals($this->id,$extralabels); | ||
} | } | ||
</ | </syntaxhighlight> | ||
==对象类的Update方法之后== | ==对象类的Update方法之后== | ||
< | <syntaxhighlight lang="PHP"> | ||
// Actions on extra fields (by external module or standard code) | // Actions on extra fields (by external module or standard code) | ||
// FIXME le hook fait double emploi avec le trigger !! | // FIXME le hook fait double emploi avec le trigger !! | ||
| Line 167: | Line 167: | ||
} | } | ||
else if ($reshook < 0) $error++; | else if ($reshook < 0) $error++; | ||
</ | </syntaxhighlight> | ||
== 对象类的delete方法之后 == | == 对象类的delete方法之后 == | ||
< | <syntaxhighlight lang="PHP"> | ||
// Removed extrafields | // Removed extrafields | ||
if (! $error) | if (! $error) | ||
| Line 184: | Line 184: | ||
} | } | ||
} | } | ||
</ | </syntaxhighlight> | ||
==管理页== | ==管理页== | ||
< | <syntaxhighlight lang="PHP"> | ||
$elementtype='facture'; //Must be the $table_element of the class that manage extrafield | $elementtype='facture'; //Must be the $table_element of the class that manage extrafield | ||
</ | </syntaxhighlight> | ||
==修复数据库 == | ==修复数据库 == | ||
Search and find definition of $listofmodulesextra add the new extrafield declaration | Search and find definition of $listofmodulesextra add the new extrafield declaration | ||
< | <syntaxhighlight lang="PHP"> | ||
$listofmodulesextra=array('societe'=>'societe','adherent'=>'adherent','product'=>'product', | $listofmodulesextra=array('societe'=>'societe','adherent'=>'adherent','product'=>'product', | ||
'socpeople'=>'socpeople', 'commande'=>'commande', 'facture'=>'facture', | 'socpeople'=>'socpeople', 'commande'=>'commande', 'facture'=>'facture', | ||
'commande_fournisseur'=>'commande_fournisseur', 'actioncomm'=>'actioncomm', | 'commande_fournisseur'=>'commande_fournisseur', 'actioncomm'=>'actioncomm', | ||
'adherent_type'=>'adherent_type','user'=>'user','projet'=>'projet', 'projet_task'=>'projet_task'); | 'adherent_type'=>'adherent_type','user'=>'user','projet'=>'projet', 'projet_task'=>'projet_task'); | ||
</ | </syntaxhighlight> | ||
== 如何在使用模型时更改列的标签 (propals, etc.) == | == 如何在使用模型时更改列的标签 (propals, etc.) == | ||
在该模型的PHP代码中,您可以通过"_tableau(...)"的函数来更改附加字段的标签。 | 在该模型的PHP代码中,您可以通过"_tableau(...)"的函数来更改附加字段的标签。 | ||