dolibarr 20.0.0
|
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()) | |
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()) | |
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()) | |
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='', $objectid=0, $extrafieldsobjectkey='', $mode=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) | |
Return HTML string to put an output field into a page. | |
getAlignFlag ($key, $extrafieldsobjectkey='') | |
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()) | |
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()) | |
Modify description of personalized attribute This is a private method. | |
Class to manage standard extra fields.
Definition at line 40 of file extrafields.class.php.
ExtraFields::__construct | ( | $db | ) |
Constructor.
Definition at line 111 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() ) |
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','price', 'pricecy', 'phone','mail','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 | $unique | Is field unique or not |
int | $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 | $param | Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) |
int | $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 | $totalizable | Is a measure. Must show a total on lists |
int | $printable | Is extrafield displayed on PDF |
array | $moreparams | More parameters. Example: array('css'=>, 'csslist'=>Css on list, 'cssview'=>...) |
Definition at line 142 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', 'price', 'pricecy', 'phone', 'mail', 'password', 'url', 'select', 'checkbox', ...) |
string | $length | Size/length of attribute ('5', '24,8', ...) |
string | $elementtype | Element type ('member', 'product', 'thirdparty', 'contact', ...) |
int | $unique | Is field unique or not |
int | $required | Is field required or not |
string | $default_value | Default value for field (in database) |
array | $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 | $moreparams | More parameters. Example: array('css'=>, 'csslist'=>, 'cssview'=>...) |
Definition at line 283 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 | $unique | Is field unique or not |
int | $required | Is field required or not |
array | string | $param | Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) |
int | $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 | $totalizable | Is a measure. Must show a total on lists |
int | $printable | Is extrafield displayed on PDF |
array | $moreparams | More parameters. Example: array('css'=>, 'csslist'=>, 'cssview'=>...) |
Exception |
Definition at line 399 of file extrafields.class.php.
References 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 532 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 590 of file extrafields.class.php.
References 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 954 of file extrafields.class.php.
References 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 2271 of file extrafields.class.php.
|
static |
Return array with all possible types and labels of extrafields.
Definition at line 2708 of file extrafields.class.php.
References getDolGlobalString().
ExtraFields::getOptionalsFromPost | ( | $extrafieldsobjectkey, | |
$keysuffix = '', | |||
$keyprefix = '' ) |
return array_options array of data of extrafields value of object sent by a search form
array | 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 2571 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.
mixed | $v | Value to test |
string | $type | Type of extrafield 'sellist', 'link', 'select', ... |
Definition at line 2739 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)
array | null | $extralabels | Deprecated (old $array of extrafields, now set this to null) |
object | $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 2408 of file extrafields.class.php.
References $object, dol_eval(), dol_mktime(), getDolGlobalString(), GETPOST(), GETPOSTINT(), price2num(), and setEventMessages().
ExtraFields::showInputField | ( | $key, | |
$value, | |||
$moreparam = '', | |||
$keysuffix = '', | |||
$keyprefix = '', | |||
$morecss = '', | |||
$objectid = 0, | |||
$extrafieldsobjectkey = '', | |||
$mode = 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 | $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 | $objectid | Current object id |
string | $extrafieldsobjectkey | The key to use to store retrieved data (commonly $object->table_element) |
int | $mode | 1=Used for search filters |
Definition at line 1065 of file extrafields.class.php.
References ajax_combobox(), dol_escape_htmltag(), dol_eval(), dol_syslog(), forgeSQLFromUniversalSearchCriteria(), getDolGlobalInt(), getDolGlobalString(), and price().
ExtraFields::showOutputField | ( | $key, | |
$value, | |||
$moreparam = '', | |||
$extrafieldsobjectkey = '', | |||
$outputlangs = null ) |
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 | $outputlangs | Output language |
Definition at line 1892 of file extrafields.class.php.
References dol_eval(), dol_print_date(), dol_print_email(), dol_print_ip(), dol_print_phone(), dol_print_url(), dol_syslog(), dol_trunc(), getDolGlobalInt(), img_object(), price(), and yn().
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 2309 of file extrafields.class.php.
References $object, and GETPOSTINT().
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() ) |
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','price','phone','mail','password','url','select','checkbox', ...) |
int | $length | Length of attribute |
string | $elementtype | Element type ('member', 'product', 'thirdparty', 'contact', ...) |
int | $unique | Is field unique or not |
int | $required | Is field required or not |
int | $pos | Position of attribute |
array | $param | Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) |
int | $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 | $totalizable | Is extrafield totalizable on list |
int | $printable | Is extrafield displayed on PDF |
array | $moreparams | More parameters. Example: array('css'=>, 'csslist'=>, 'cssview'=>...) |
Exception |
Definition at line 648 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 |
int | $size | Length of attribute |
string | $elementtype | Element type ('member', 'product', 'thirdparty', ...) |
int | $unique | Is field unique or not |
int | $required | Is field required or not |
int | $pos | Position of attribute |
array | $param | Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) |
int | $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 | $totalizable | Is extrafield totalizable on list |
int | $printable | Is extrafield displayed on PDF |
array | $moreparams | More parameters. Example: array('css'=>, 'csslist'=>, 'cssview'=>...) |
Exception |
Definition at line 800 of file extrafields.class.php.
References 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() ) |
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','price', 'pricecy', 'phone','mail','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 | $unique | Is field unique or not |
int | $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 | $param | Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) |
int | $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 | $totalizable | Is a measure. Must show a total on lists |
int | $printable | Is extrafield displayed on PDF |
array | $moreparams | More parameters. Example: array('css'=>, 'csslist'=>Css on list, 'cssview'=>...) |
Definition at line 218 of file extrafields.class.php.
References dol_syslog(), update(), and update_label().