dolibarr  7.0.0-beta
Public Member Functions | Private Member Functions | List of all members
ExtraFields Class Reference

Class to manage standard extra fields. More...

+ Collaboration diagram for ExtraFields:

Public Member Functions

 __construct ($db)
 Constructor. More...
 
 addExtraField ($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list=-1, $ishidden=0, $computed='', $entity='', $langfile='', $enabled='1')
 Add a new extra field parameter. More...
 
 delete ($attrname, $elementtype='member')
 Delete an optional attribute. More...
 
 update ($attrname, $label, $type, $length, $elementtype, $unique=0, $required=0, $pos=0, $param='', $alwayseditable=0, $perms='', $list='', $ishidden=0, $default='', $computed='', $entity='', $langfile='', $enabled='1')
 Modify type of a personalized attribute. More...
 
 fetch_name_optionals_label ($elementtype, $forceload=false)
 Load array this->attributes, or old this->attribute_xxx like attribute_label, attribute_type, ... More...
 
 showInputField ($key, $value, $moreparam='', $keysuffix='', $keyprefix='', $showsize=0, $objectid=0)
 Return HTML string to put an input field into a page Code very similar with showInputField of common object. More...
 
 showOutputField ($key, $value, $moreparam='')
 Return HTML string to put an output field into a page. More...
 
 getAlignFlag ($key)
 Return tag to describe alignement to use for this extrafield. More...
 
 showSeparator ($key)
 Return HTML string to print separator extrafield. More...
 
 setOptionalsFromPost ($extralabels, &$object, $onlykey='')
 Fill array_options property of object by extrafields value (using for data sent by forms) More...
 
 getOptionalsFromPost ($extralabels, $keyprefix='', $keysuffix='')
 return array_options array of data of extrafields value of object sent by a search form More...
 

Private Member Functions

 create ($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0, $default_value='', $param='', $perms='', $list=0, $computed='')
 Add a new optional attribute. More...
 
 create_label ($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list=-1, $ishidden=0, $default='', $computed='', $entity='', $langfile='', $enabled='1')
 Add description of a new optional attribute. More...
 
 delete_label ($attrname, $elementtype='member')
 Delete description of an optional attribute. More...
 
 update_label ($attrname, $label, $type, $size, $elementtype, $unique=0, $required=0, $pos=0, $param='', $alwayseditable=0, $perms='', $list=0, $ishidden=0, $default='', $computed='', $entity='', $langfile='', $enabled='1')
 Modify description of personalized attribute. More...
 

Detailed Description

Class to manage standard extra fields.

Definition at line 37 of file extrafields.class.php.

Constructor & Destructor Documentation

ExtraFields::__construct (   $db)

Constructor.

Parameters
DoliDB$dbDatabase handler

Definition at line 110 of file extrafields.class.php.

Member Function Documentation

ExtraFields::addExtraField (   $attrname,
  $label,
  $type,
  $pos,
  $size,
  $elementtype,
  $unique = 0,
  $required = 0,
  $default_value = '',
  $param = '',
  $alwayseditable = 0,
  $perms = '',
  $list = -1,
  $ishidden = 0,
  $computed = '',
  $entity = '',
  $langfile = '',
  $enabled = '1' 
)

Add a new extra field parameter.

Parameters
string$attrnameCode of attribute
string$labellabel of attribute
int$typeType of attribute ('boolean', 'int', 'text', 'varchar', 'date', 'datehour','price','phone','mail','password','url','select','checkbox', ...)
int$posPosition of attribute
string$sizeSize/length of attribute
string$elementtypeElement type ('member', 'product', 'thirdparty', ...)
int$uniqueIs field unique or not
int$requiredIs field required or not
string$default_valueDefaulted value (In database. use the default_value feature for default value on screen. Example: '', '0', 'null', 'avalue')
array | string$paramParams for field (ex for select list : array('options' => array(value'=>'label of option')) )
int$alwayseditableIs attribute always editable regardless of the document status
string$permsPermission to check
int$listVisibilty
int$ishiddenDeprecated. Use visibility instead.
string$computedComputed value
string$entityEntity of extrafields (for multicompany modules)
string$langfileLanguage file
string$enabledCondition to have the field enabled or not
Returns
int <=0 if KO, >0 if OK

Definition at line 151 of file extrafields.class.php.

References create(), and create_label().

ExtraFields::create (   $attrname,
  $type = 'varchar',
  $length = 255,
  $elementtype = 'member',
  $unique = 0,
  $required = 0,
  $default_value = '',
  $param = '',
  $perms = '',
  $list = 0,
  $computed = '' 
)
private

Add a new optional attribute.

This is a private method. For public method, use addExtraField.

Parameters
string$attrnamecode of attribute
int$typeType of attribute ('boolean', 'int', 'text', 'varchar', 'date', 'datehour','price','phone','mail','password','url','select','checkbox', ...)
string$lengthSize/length of attribute ('5', '24,8', ...)
string$elementtypeElement type ('member', 'product', 'thirdparty', 'contact', ...)
int$uniqueIs field unique or not
int$requiredIs field required or not
string$default_valueDefault value for field (in database)
array$paramParams for field (ex for select list : array('options'=>array('value'=>'label of option'))
string$permsPermission
int$listInto list view by default
string$computedComputed value
Returns
int <=0 if KO, >0 if OK

Definition at line 201 of file extrafields.class.php.

References $resql.

Referenced by addExtraField().

ExtraFields::create_label (   $attrname,
  $label = '',
  $type = '',
  $pos = 0,
  $size = 0,
  $elementtype = 'member',
  $unique = 0,
  $required = 0,
  $param = '',
  $alwayseditable = 0,
  $perms = '',
  $list = -1,
  $ishidden = 0,
  $default = '',
  $computed = '',
  $entity = '',
  $langfile = '',
  $enabled = '1' 
)
private

Add description of a new optional attribute.

Parameters
string$attrnamecode of attribute
string$labellabel of attribute
int$typeType of attribute ('int', 'text', 'varchar', 'date', 'datehour', 'float')
int$posPosition of attribute
string$sizeSize/length of attribute ('5', '24,8', ...)
string$elementtypeElement type ('member', 'product', 'thirdparty', ...)
int$uniqueIs field unique or not
int$requiredIs field required or not
array | string$paramParams for field (ex for select list : array('options' => array(value'=>'label of option')) )
int$alwayseditableIs attribute always editable regardless of the document status
string$permsPermission to check
int$listVisibily
int$ishiddenDeprecated. Use visibility instead.
string$defaultDefault value (in database. use the default_value feature for default value on screen).
string$computedComputed value
string$entityEntity of extrafields
string$langfileLanguage file
string$enabledCondition to have the field enabled or not
Returns
int <=0 if KO, >0 if OK

Definition at line 293 of file extrafields.class.php.

References dol_now(), and dol_syslog().

Referenced by addExtraField().

ExtraFields::delete (   $attrname,
  $elementtype = 'member' 
)

Delete an optional attribute.

Parameters
string$attrnameCode of attribute to delete
string$elementtypeElement type ('member', 'product', 'thirdparty', 'contact', ...)
Returns
int < 0 if KO, 0 if nothing is done, 1 if OK

Definition at line 387 of file extrafields.class.php.

References $resql, and delete_label().

ExtraFields::delete_label (   $attrname,
  $elementtype = 'member' 
)
private

Delete description of an optional attribute.

Parameters
string$attrnameCode of attribute to delete
string$elementtypeElement type ('member', 'product', 'thirdparty', ...)
Returns
int < 0 if KO, 0 if nothing is done, 1 if OK

Definition at line 445 of file extrafields.class.php.

References $resql, dol_print_error(), dol_syslog(), and print.

Referenced by delete().

ExtraFields::fetch_name_optionals_label (   $elementtype,
  $forceload = false 
)

Load array this->attributes, or old this->attribute_xxx like attribute_label, attribute_type, ...

Parameters
string$elementtypeType of element ('adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...).
boolean$forceloadForce load of extra fields whatever is option MAIN_EXTRAFIELDS_DISABLED. Deprecated. Should not be required.
Returns
array Array of attributes keys+label for all extra fields.

Definition at line 712 of file extrafields.class.php.

References $resql, and dol_syslog().

ExtraFields::getAlignFlag (   $key)

Return tag to describe alignement to use for this extrafield.

Parameters
string$keyKey of attribute
Returns
string Formated value

Definition at line 1644 of file extrafields.class.php.

ExtraFields::getOptionalsFromPost (   $extralabels,
  $keyprefix = '',
  $keysuffix = '' 
)

return array_options array of data of extrafields value of object sent by a search form

Parameters
array$extralabels$array of extrafields
string$keyprefixPrefix string to add into name and id of field (can be used to avoid duplicate names)
string$keysuffixSuffix string to add into name and id of field (can be used to avoid duplicate names)
Returns
array|int array_options set or 0 if no value

Definition at line 1779 of file extrafields.class.php.

References dol_mktime(), GETPOST(), and price2num().

ExtraFields::setOptionalsFromPost (   $extralabels,
$object,
  $onlykey = '' 
)

Fill array_options property of object by extrafields value (using for data sent by forms)

Parameters
array$extralabels$array of extrafields
object$objectObject
string$onlykeyOnly following key is filled. When we make update of only one extrafield ($action = 'update_extras'), calling page must must set this to avoid to have other extrafields being reset.
Returns
int 1 if array_options set, 0 if no value, -1 if error (field required missing for example)

Definition at line 1704 of file extrafields.class.php.

References dol_mktime(), GETPOST(), price2num(), and setEventMessages().

ExtraFields::showInputField (   $key,
  $value,
  $moreparam = '',
  $keysuffix = '',
  $keyprefix = '',
  $showsize = 0,
  $objectid = 0 
)

Return HTML string to put an input field into a page Code very similar with showInputField of common object.

Parameters
string$keyKey of attribute
string$valuePreselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value)
string$moreparamTo add more parametes on html input tag
string$keysuffixPrefix string to add after name and id of field (can be used to avoid duplicate names)
string$keyprefixSuffix string to add before name and id of field (can be used to avoid duplicate names)
mixed$showsizeValue for css to define size. May also be a numeric.
int$objectidCurrent object id
Returns
string

Definition at line 826 of file extrafields.class.php.

References $form, $resql, ajax_combobox(), dol_escape_htmltag(), dol_syslog(), dol_trunc(), and price().

ExtraFields::showOutputField (   $key,
  $value,
  $moreparam = '' 
)

Return HTML string to put an output field into a page.

Parameters
string$keyKey of attribute
string$valueValue to show
string$moreparamTo add more parameters on html input tag (only checkbox use html input for output rendering)
Returns
string Formated value

Definition at line 1349 of file extrafields.class.php.

References $resql, dol_eval(), dol_print_date(), dol_print_email(), dol_print_phone(), dol_print_url(), dol_syslog(), dol_trunc(), and price().

ExtraFields::showSeparator (   $key)

Return HTML string to print separator extrafield.

Parameters
string$keyKey of attribute
Returns
string

Definition at line 1690 of file extrafields.class.php.

ExtraFields::update (   $attrname,
  $label,
  $type,
  $length,
  $elementtype,
  $unique = 0,
  $required = 0,
  $pos = 0,
  $param = '',
  $alwayseditable = 0,
  $perms = '',
  $list = '',
  $ishidden = 0,
  $default = '',
  $computed = '',
  $entity = '',
  $langfile = '',
  $enabled = '1' 
)

Modify type of a personalized attribute.

Parameters
string$attrnameName of attribute
string$labelLabel of attribute
string$typeType of attribute ('boolean', 'int', 'text', 'varchar', 'date', 'datehour','price','phone','mail','password','url','select','checkbox', ...)
int$lengthLength of attribute
string$elementtypeElement type ('member', 'product', 'thirdparty', 'contact', ...)
int$uniqueIs field unique or not
int$requiredIs field required or not
int$posPosition of attribute
array$paramParams for field (ex for select list : array('options' => array(value'=>'label of option')) )
int$alwayseditableIs attribute always editable regardless of the document status
string$permsPermission to check
int$listVisibility
int$ishiddenDeprecated. Use visiblity instead.
string$defaultDefault value (in database. use the default_value feature for default value on screen).
string$computedComputed value
string$entityEntity of extrafields
string$langfileLanguage file
string$enabledCondition to have the field enabled or not
Returns
int >0 if OK, <=0 if KO

Definition at line 501 of file extrafields.class.php.

References $resql, dol_syslog(), and update_label().

ExtraFields::update_label (   $attrname,
  $label,
  $type,
  $size,
  $elementtype,
  $unique = 0,
  $required = 0,
  $pos = 0,
  $param = '',
  $alwayseditable = 0,
  $perms = '',
  $list = 0,
  $ishidden = 0,
  $default = '',
  $computed = '',
  $entity = '',
  $langfile = '',
  $enabled = '1' 
)
private

Modify description of personalized attribute.

Parameters
string$attrnameName of attribute
string$labelLabel of attribute
string$typeType of attribute
int$sizeLength of attribute
string$elementtypeElement type ('member', 'product', 'thirdparty', ...)
int$uniqueIs field unique or not
int$requiredIs field required or not
int$posPosition of attribute
array$paramParams for field (ex for select list : array('options' => array(value'=>'label of option')) )
int$alwayseditableIs attribute always editable regardless of the document status
string$permsPermission to check
int$listVisiblity
int$ishiddenDeprecated. Use visility instead.
string$defaultDefault value (in database. use the default_value feature for default value on screen).
string$computedComputed value
string$entityEntity of extrafields
string$langfileLanguage file
string$enabledCondition to have the field enabled or not
Returns
int <=0 if KO, >0 if OK

Definition at line 608 of file extrafields.class.php.

References dol_now(), dol_print_error(), dol_syslog(), and print.

Referenced by update().


The documentation for this class was generated from the following file: