|
dolibarr 25.0.0-alpha
|
Class to manage standard extra fields. More...

Public Member Functions | |
| __construct ($db) | |
| Constructor. | |
| addExtraField ($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list='-1', $help='', $computed='', $entity='', $langfile='', $enabled='1', $totalizable=0, $printable=0, $moreparams=array(), $aiprompt="", $emptyonclone=0, $showintooltip=0, $personal_data=0) | |
| Add a new extra field parameter. | |
| updateExtraField ($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list='-1', $help='', $computed='', $entity='', $langfile='', $enabled='1', $totalizable=0, $printable=0, $moreparams=array(), $emptyonclone=0, $showintooltip=0, $personal_data=0) | |
| Update an existing extra field parameter. | |
| delete ($attrname, $elementtype='') | |
| Delete an optional attribute. | |
| update ($attrname, $label, $type, $length, $elementtype, $unique=0, $required=0, $pos=0, $param=array(), $alwayseditable=0, $perms='', $list='', $help='', $default='', $computed='', $entity='', $langfile='', $enabled='1', $totalizable=0, $printable=0, $moreparams=array(), $aiprompt="", $emptyonclone=0, $showintooltip=0, $personal_data=0) | |
| Modify type of a personalized attribute. | |
| fetch_name_optionals_label ($elementtype, $forceload=false, $attrname='') | |
| Load the array of extrafields definition $this->attributes. | |
| showInputField ($key, $value, $moreparam='', $keysuffix='', $keyprefix='', $morecss='', $object=0, $extrafieldsobjectkey='', $mode=0, $filteronparentvalue=0) | |
| Return HTML string to put an input field into a page Code very similar with showInputField of common object. | |
| showOutputField ($key, $value, $moreparam='', $extrafieldsobjectkey='', $outputlangs=null, $object=null, $mode='') | |
| Return HTML string to put an output field into a page. | |
| getAlignFlag ($key, $extrafieldsobjectkey='') | |
| Return the CSS to use for this extrafield into list. | |
| getCSSClass ($key, $extrafieldsobjectkey='', $mode='csslist') | |
| Return the CSS to use for this extrafield into list. | |
| showSeparator ($key, $object, $colspan=2, $display_type='card', $mode='') | |
| Return HTML string to print separator extrafield. | |
| setOptionalsFromPost ($extralabels, $object, $onlykey='', $todefaultifmissing=0) | |
| Fill array_options property of object by extrafields value (using for data sent by forms) | |
| getOptionalsFromPost ($extrafieldsobjectkey, $keysuffix='', $keyprefix='') | |
| return array_options array of data of extrafields value of object sent by a search form | |
Static Public Member Functions | |
| static | getListOfTypesLabels () |
| Return array with all possible types and labels of extrafields. | |
| static | isEmptyValue ($v, string $type) |
| Return if a value is "empty" for a mandatory vision. | |
Private Member Functions | |
| create ($attrname, $type='varchar', $length='255', $elementtype='', $unique=0, $required=0, $default_value='', $param=array(), $perms='', $list='0', $computed='', $help='', $moreparams=array()) | |
| Add a new optional attribute. | |
| create_label ($attrname, $label='', $type='', $pos=0, $size='', $elementtype='', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list='-1', $help='', $default='', $computed='', $entity='', $langfile='', $enabled='1', $totalizable=0, $printable=0, $moreparams=array(), $aiprompt="", $emptyonclone=0, $showintooltip=0, $personal_data=0) | |
| Add description of a new optional attribute. | |
| delete_label ($attrname, $elementtype='') | |
| Delete description of an optional attribute. | |
| update_label ($attrname, $label, $type, $size, $elementtype, $unique=0, $required=0, $pos=0, $param=array(), $alwayseditable=0, $perms='', $list='0', $help='', $default='', $computed='', $entity='', $langfile='', $enabled='1', $totalizable=0, $printable=0, $moreparams=array(), $aiprompt="", $emptyonclone=0, $showintooltip=0, $personal_data=0) | |
| Modify description of personalized attribute This is a private method. | |
Class to manage standard extra fields.
Definition at line 42 of file extrafields.class.php.
| ExtraFields::__construct | ( | $db | ) |
Constructor.
Definition at line 135 of file extrafields.class.php.
| ExtraFields::addExtraField | ( | $attrname, | |
| $label, | |||
| $type, | |||
| $pos, | |||
| $size, | |||
| $elementtype, | |||
| $unique = 0, | |||
| $required = 0, | |||
| $default_value = '', | |||
| $param = '', | |||
| $alwayseditable = 0, | |||
| $perms = '', | |||
| $list = '-1', | |||
| $help = '', | |||
| $computed = '', | |||
| $entity = '', | |||
| $langfile = '', | |||
| $enabled = '1', | |||
| $totalizable = 0, | |||
| $printable = 0, | |||
| $moreparams = array(), | |||
| $aiprompt = "", | |||
| $emptyonclone = 0, | |||
| $showintooltip = 0, | |||
| $personal_data = 0 ) |
Add a new extra field parameter.
| string | $attrname | Code of attribute |
| string | $label | label of attribute |
| string | $type | Type of attribute ('boolean', 'int', 'varchar', 'text', 'html', 'date', 'datetime', 'duration', 'price', 'pricecy', 'phone', 'email', 'password', 'url', 'select', 'checkbox', 'separate',...) |
| int | $pos | Position of attribute |
| string | $size | Size/length definition of attribute ('5', '24,8', ...). For float, it contains 2 numeric separated with a comma. |
| string | $elementtype | Element type. Same value than object->table_element (Example 'member', 'product', 'thirdparty', ...) |
| int<0,1> | $unique Is field unique or not | |
| int<0,1> | $required Is field required or not | |
| string | $default_value | Defaulted value (In database. use the default_value feature for default value on screen. Example: '', '0', 'null', 'avalue') |
| array<string,mixed|mixed[]>|string | $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) | |
| int<0,1> | $alwayseditable Is attribute always editable regardless of the document status | |
| string | $perms | Permission to check |
| string | $list | Visibility ('0'=never visible, '1'=visible on list+forms, '2'=list only, '3'=form only or 'eval string') |
| string | $help | Text with help tooltip |
| string | $computed | Computed value |
| string | $entity | Entity of extrafields (for multicompany modules) |
| string | $langfile | Language file |
| string | $enabled | Condition to have the field enabled or not |
| int<0,1> | $totalizable Is a measure. Must show a total on lists | |
| int<0,1> | $printable Is extrafield displayed on PDF | |
| array<string,mixed> | $moreparams More parameters. Example: array('css'=>, 'csslist'=>Css on list, 'cssview'=>...) | |
| string | $aiprompt | Ai prompt value |
| int<0,1> | $emptyonclone Is attribute to be emptied after object clone | |
| int<0,1> | $showintooltip Is attribute to be show on tooltip | |
| int<0,1> | $personal_data Is attribute a personal data (RGPD,nLPD/LGPD) |
Definition at line 171 of file extrafields.class.php.
References create(), and create_label().
|
private |
Add a new optional attribute.
This is a private method. For public method, use addExtraField.
| string | $attrname | code of attribute |
| string | $type | Type of attribute ('boolean', 'int', 'varchar', 'text', 'html', 'date', 'datetime', 'duration', 'price', 'pricecy', 'phone', 'email', 'password', 'url', 'select', 'checkbox', ...) |
| string | $length | Size/length of attribute ('5', '24,8', ...) |
| string | $elementtype | Element type ('member', 'product', 'thirdparty', 'contact', ...) |
| int<0,1> | $unique Is field unique or not | |
| int<0,1> | $required Is field required or not | |
| string | $default_value | Default value for field (in database) |
| array<string,mixed|mixed[]> | $param Params for field (ex for select list : array('options'=>array('value'=>'label of option')) | |
| string | $perms | Permission |
| string | $list | Into list view by default |
| string | $computed | Computed value |
| string | $help | Help on tooltip |
| array<string,mixed> | $moreparams More parameters. Example: array('css'=>, 'csslist'=>, 'cssview'=>...) |
Definition at line 317 of file extrafields.class.php.
Referenced by addExtraField().
|
private |
Add description of a new optional attribute.
| string | $attrname | code of attribute |
| string | $label | label of attribute |
| string | $type | Type of attribute ('int', 'varchar', 'text', 'html', 'date', 'datehour', 'float') |
| int | $pos | Position of attribute |
| string | $size | Size/length of attribute ('5', '24,8', ...) |
| string | $elementtype | Element type ('member', 'product', 'thirdparty', ...) |
| int<0,1> | $unique Is field unique or not | |
| int<0,1> | $required Is field required or not | |
| array<string,mixed|mixed[]>|string | $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) | |
| int<0,1> | $alwayseditable Is attribute always editable regardless of the document status | |
| string | $perms | Permission to check |
| string | $list | Visibility |
| string | $help | Help on tooltip |
| string | $default | Default value (in database. use the default_value feature for default value on screen). |
| string | $computed | Computed value |
| string | $entity | Entity of extrafields |
| string | $langfile | Language file |
| string | $enabled | Condition to have the field enabled or not |
| int<0,1> | $totalizable Is a measure. Must show a total on lists | |
| int<0,1> | $printable Is extrafield displayed on PDF | |
| array<string,mixed> | $moreparams More parameters. Example: array('css'=>, 'csslist'=>, 'cssview'=>...) | |
| string | $aiprompt | Ai prompt value |
| int<0,1> | $emptyonclone Is attribute to be emptied after object clone | |
| int<0,1> | $showintooltip Is attribute to be show on tooltip | |
| int<0,1> | $personal_data Is attribute a personal data (RGPD,nLPD/LGPD) |
| Exception |
Definition at line 444 of file extrafields.class.php.
References $conf, dol_now(), and dol_syslog().
Referenced by addExtraField().
| ExtraFields::delete | ( | $attrname, | |
| $elementtype = '' ) |
Delete an optional attribute.
| string | $attrname | Code of attribute to delete |
| string | $elementtype | Element type ('member', 'product', 'thirdparty', 'contact', ...) |
Definition at line 593 of file extrafields.class.php.
References delete_label().
|
private |
Delete description of an optional attribute.
| string | $attrname | Code of attribute to delete |
| string | $elementtype | Element type ('member', 'product', 'thirdparty', ...) |
Definition at line 658 of file extrafields.class.php.
References $conf, dol_print_error(), and dol_syslog().
Referenced by delete().
| ExtraFields::fetch_name_optionals_label | ( | $elementtype, | |
| $forceload = false, | |||
| $attrname = '' ) |
Load the array of extrafields definition $this->attributes.
| string | $elementtype | Type of element ('all' = all or $object->table_element like 'adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...). |
| boolean | $forceload | Force load of extra fields whatever is status of cache. |
| string | $attrname | The name of the attribute. |
Definition at line 1061 of file extrafields.class.php.
References $conf, dol_syslog(), and jsonOrUnserialize().
| ExtraFields::getAlignFlag | ( | $key, | |
| $extrafieldsobjectkey = '' ) |
Return the CSS to use for this extrafield into list.
| string | $key | Key of attribute |
| string | $extrafieldsobjectkey | If defined, use the new method to get extrafields data |
Definition at line 2780 of file extrafields.class.php.
| ExtraFields::getCSSClass | ( | $key, | |
| $extrafieldsobjectkey = '', | |||
| $mode = 'csslist' ) |
Return the CSS to use for this extrafield into list.
| string | $key | Key of attribute |
| string | $extrafieldsobjectkey | If defined, use the new method to get extrafields data |
| string | $mode | 'csslist' (used on td into table list), 'css' (used on create/update), 'cssview' (used on view) |
Definition at line 2793 of file extrafields.class.php.
|
static |
Return array with all possible types and labels of extrafields.
Definition at line 3269 of file extrafields.class.php.
References getDolGlobalString().
Referenced by FormAdmin\selectTypeOfFields().
| ExtraFields::getOptionalsFromPost | ( | $extrafieldsobjectkey, | |
| $keysuffix = '', | |||
| $keyprefix = '' ) |
return array_options array of data of extrafields value of object sent by a search form
| array<string,mixed>|string | $extrafieldsobjectkey array of extrafields (old usage) or value of object->table_element (new usage) | |
| string | $keysuffix | Suffix string to add into name and id of field (can be used to avoid duplicate names) |
| string | $keyprefix | Prefix string to add into name and id of field (can be used to avoid duplicate names) |
Definition at line 3118 of file extrafields.class.php.
References dol_htmlcleanlastbr(), dol_mktime(), GETPOST(), GETPOSTINT(), GETPOSTISARRAY(), and price2num().
|
static |
Return if a value is "empty" for a mandatory vision.
| null|int|float|string|array<int|string,mixed> | $v Value to test | |
| string | $type | Type of extrafield 'sellist', 'link', 'select', ... |
Definition at line 3300 of file extrafields.class.php.
Referenced by CommonObject\insertExtraFields().
| ExtraFields::setOptionalsFromPost | ( | $extralabels, | |
| $object, | |||
| $onlykey = '', | |||
| $todefaultifmissing = 0 ) |
Fill array_options property of object by extrafields value (using for data sent by forms)
| null | $extralabels | Deprecated (old $array of extrafields, now set this to null) |
| CommonObject | $object | Object |
| string | $onlykey | Only some keys are filled: 'string' => When we make update of only one extrafield ($action = 'update_extras'), calling page can set this to avoid to have other extrafields being reset. '@GETPOSTISSET' => When we make update of several extrafields ($action = 'update'), calling page can set this to avoid to have fields not into POST being reset. |
| int | $todefaultifmissing | 1=Set value to the default value in database if value is mandatory and missing |
Definition at line 2941 of file extrafields.class.php.
| ExtraFields::showInputField | ( | $key, | |
| $value, | |||
| $moreparam = '', | |||
| $keysuffix = '', | |||
| $keyprefix = '', | |||
| $morecss = '', | |||
| $object = 0, | |||
| $extrafieldsobjectkey = '', | |||
| $mode = 0, | |||
| $filteronparentvalue = 0 ) |
Return HTML string to put an input field into a page Code very similar with showInputField of common object.
| string | $key | Key of attribute |
| string|array{start:int,end:int} | $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value); for dates in filter mode, a range array('start'=><timestamp>, 'end'=><timestamp>) should be provided | |
| string | $moreparam | To add more parameters on html input tag |
| string | $keysuffix | Suffix string to add after name and id of field (can be used to avoid duplicate names) |
| string | $keyprefix | Prefix string to add before name and id of field (can be used to avoid duplicate names) |
| string | $morecss | More css (to defined size of field. Old behaviour: may also be a numeric) |
| int | CommonObject | $object | Current object or object ID. Preferably, pass the object itself. |
| string | $extrafieldsobjectkey | The key to use to store retrieved data (commonly $object->table_element) |
| int | $mode | 1=Used for search filters |
| int | $filteronparentvalue | 1=Filter the values of a dependent list on the value currently saved for its parent list. Used when the field is edited alone (the parent list is not on the form, so the javascript that filters the list can't work). |
Definition at line 1197 of file extrafields.class.php.
References $conf, $object, ajax_combobox(), dol_escape_htmltag(), dol_eval(), dol_syslog(), forgeSQLFromUniversalSearchCriteria(), getDolGlobalInt(), getDolGlobalString(), isModEnabled(), price(), showOutputField(), and string.
| ExtraFields::showOutputField | ( | $key, | |
| $value, | |||
| $moreparam = '', | |||
| $extrafieldsobjectkey = '', | |||
| $outputlangs = null, | |||
| $object = null, | |||
| $mode = '' ) |
Return HTML string to put an output field into a page.
| string | $key | Key of attribute |
| string | $value | Value to show |
| string | $moreparam | To add more parameters on html input tag (only checkbox use html input for output rendering) |
| string | $extrafieldsobjectkey | Required (for example $object->table_element). |
| Translate | null | $outputlangs | Output |
| CommonObject | null | $object | The parent object of field to show |
| string | $mode | '' or 'list' |
Definition at line 2256 of file extrafields.class.php.
References $c, $conf, $object, colorIsLight(), convertSecondToTime(), dol_escape_htmltag(), dol_escape_js(), dol_eval(), dol_htmlentitiesbr(), dol_include_once(), dol_print_date(), dol_print_email(), dol_print_ip(), dol_print_phone(), dol_print_url(), dol_syslog(), dol_trunc(), getDolGlobalInt(), img_object(), img_picto(), price(), status, string, and yn().
Referenced by showInputField().
| ExtraFields::showSeparator | ( | $key, | |
| $object, | |||
| $colspan = 2, | |||
| $display_type = 'card', | |||
| $mode = '' ) |
Return HTML string to print separator extrafield.
| string | $key | Key of attribute |
| object | $object | Object |
| int | $colspan | Value of colspan to use (it must includes the first column with title) |
| string | $display_type | "card" for form display, "line" for document line display (extrafields on propal line, order line, etc...) |
| string | $mode | Show output ('view') or input ('create' or 'edit') for extrafield |
Definition at line 2839 of file extrafields.class.php.
| ExtraFields::update | ( | $attrname, | |
| $label, | |||
| $type, | |||
| $length, | |||
| $elementtype, | |||
| $unique = 0, | |||
| $required = 0, | |||
| $pos = 0, | |||
| $param = array(), | |||
| $alwayseditable = 0, | |||
| $perms = '', | |||
| $list = '', | |||
| $help = '', | |||
| $default = '', | |||
| $computed = '', | |||
| $entity = '', | |||
| $langfile = '', | |||
| $enabled = '1', | |||
| $totalizable = 0, | |||
| $printable = 0, | |||
| $moreparams = array(), | |||
| $aiprompt = "", | |||
| $emptyonclone = 0, | |||
| $showintooltip = 0, | |||
| $personal_data = 0 ) |
Modify type of a personalized attribute.
| string | $attrname | Name of attribute |
| string | $label | Label of attribute |
| string | $type | Type of attribute ('boolean', 'int', 'varchar', 'text', 'html', 'date', 'datetime', 'duration', 'price', 'phone', 'email', 'password', 'url', 'select', 'checkbox', ...) |
| string | $length | Size/length of attribute ('5', '24,8', ...) |
| string | $elementtype | Element type ('member', 'product', 'thirdparty', 'contact', ...) |
| int<0,1> | $unique Is field unique or not | |
| int<0,1> | $required Is field required or not | |
| int<0,1> | $pos Position of attribute | |
| array<string,mixed|mixed[]> | $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) | |
| int<0,1> | $alwayseditable Is attribute always editable regardless of the document status | |
| string | $perms | Permission to check |
| string | $list | Visibility |
| string | $help | Help on tooltip |
| string | $default | Default value (in database. use the default_value feature for default value on screen). |
| string | $computed | Computed value |
| string | $entity | Entity of extrafields |
| string | $langfile | Language file |
| string | $enabled | Condition to have the field enabled or not |
| int<0,1> | $totalizable Is extrafield totalizable on list | |
| int<0,1> | $printable Is extrafield displayed on PDF | |
| array<string,mixed> | $moreparams More parameters. Example: array('css'=>, 'csslist'=>, 'cssview'=>...) | |
| string | $aiprompt | Ai prompt value |
| int<0,1> | $emptyonclone Is attribute to be emptied after object clone | |
| int<0,1> | $showintooltip Is attribute to be show on tooltip | |
| int<0,1> | $personal_data Is attribute a personal data (RGPD,nLPD/LGPD) |
| Exception |
Definition at line 722 of file extrafields.class.php.
References dol_syslog(), and update_label().
Referenced by updateExtraField().
|
private |
Modify description of personalized attribute This is a private method.
For public method, use updateExtraField.
| string | $attrname | Name of attribute |
| string | $label | Label of attribute |
| string | $type | Type of attribute |
| string | $size | Size/length of attribute ('5', '24,8', ...) |
| string | $elementtype | Element type ('member', 'product', 'thirdparty', ...) |
| int<0,1> | $unique Is field unique or not | |
| int<0,1> | $required Is field required or not | |
| int | $pos | Position of attribute |
| array<string,mixed|array<string,mixed>> | $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) | |
| int<0,1> | $alwayseditable Is attribute always editable regardless of the document status | |
| string | $perms | Permission to check |
| string | $list | Visibility |
| string | $help | Help on tooltip. |
| string | $default | Default value (in database. use the default_value feature for default value on screen). |
| string | $computed | Computed value |
| string | $entity | Entity of extrafields |
| string | $langfile | Language file |
| string | $enabled | Condition to have the field enabled or not |
| int<0,1> | $totalizable Is extrafield totalizable on list | |
| int<0,1> | $printable Is extrafield displayed on PDF | |
| array<string,mixed> | $moreparams More parameters. Example: array('css'=>, 'csslist'=>, 'cssview'=>...) | |
| string | $aiprompt | Ai prompt value |
| int<0,1> | $emptyonclone Is attribute to be emptied after object clone | |
| int<0,1> | $showintooltip Is attribute to be show on tooltip | |
| int<0,1> | $personal_data Is attribute a personal data (RGPD,nLPD/LGPD) |
| Exception |
Definition at line 890 of file extrafields.class.php.
References $conf, dol_now(), dol_print_error(), and dol_syslog().
Referenced by update(), and updateExtraField().
| ExtraFields::updateExtraField | ( | $attrname, | |
| $label, | |||
| $type, | |||
| $pos, | |||
| $size, | |||
| $elementtype, | |||
| $unique = 0, | |||
| $required = 0, | |||
| $default_value = '', | |||
| $param = '', | |||
| $alwayseditable = 0, | |||
| $perms = '', | |||
| $list = '-1', | |||
| $help = '', | |||
| $computed = '', | |||
| $entity = '', | |||
| $langfile = '', | |||
| $enabled = '1', | |||
| $totalizable = 0, | |||
| $printable = 0, | |||
| $moreparams = array(), | |||
| $emptyonclone = 0, | |||
| $showintooltip = 0, | |||
| $personal_data = 0 ) |
Update an existing extra field parameter.
| string | $attrname | Code of attribute |
| string | $label | label of attribute |
| string | $type | Type of attribute ('boolean', 'int', 'varchar', 'text', 'html', 'date', 'datetime', 'duration', 'price', 'pricecy', 'phone', 'email', 'password', 'url', 'select', 'checkbox', 'separate',...) |
| int | $pos | Position of attribute |
| string | $size | Size/length definition of attribute ('5', '24,8', ...). For float, it contains 2 numeric separated with a comma. |
| string | $elementtype | Element type. Same value than object->table_element (Example 'member', 'product', 'thirdparty', ...) |
| int<0,1> | $unique Is field unique or not | |
| int<0,1> | $required Is field required or not | |
| string | $default_value | Defaulted value (In database. use the default_value feature for default value on screen. Example: '', '0', 'null', 'avalue') |
| array<string,mixed|mixed[]>|string | $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) | |
| int<0,1> | $alwayseditable Is attribute always editable regardless of the document status | |
| string | $perms | Permission to check |
| string | $list | Visibility ('0'=never visible, '1'=visible on list+forms, '2'=list only, '3'=form only or 'eval string') |
| string | $help | Text with help tooltip |
| string | $computed | Computed value |
| string | $entity | Entity of extrafields (for multicompany modules) |
| string | $langfile | Language file |
| string | $enabled | Condition to have the field enabled or not |
| int<0,1> | $totalizable Is a measure. Must show a total on lists | |
| int<0,1> | $printable Is extrafield displayed on PDF | |
| array<string,mixed> | $moreparams More parameters. Example: array('css'=>, 'csslist'=>Css on list, 'cssview'=>...) | |
| int<0,1> | $emptyonclone Is attribute to be emptied after object clone | |
| int<0,1> | $showintooltip Show in tooltip | |
| int<0,1> | $personal_data Is attribute a personal data (RGPD,nLPD/LGPD) |
Definition at line 252 of file extrafields.class.php.
References dol_syslog(), update(), and update_label().