dolibarr 19.0.3
|
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. | |
delete ($attrname, $elementtype='member') | |
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) | |
Load the array of extrafields defintion $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, $keyprefix='', $keysuffix='') | |
return array_options array of data of extrafields value of object sent by a search form | |
Static Public Member Functions | |
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='member', $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='member', $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='member') | |
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. | |
Class to manage standard extra fields.
Definition at line 39 of file extrafields.class.php.
ExtraFields::__construct | ( | $db | ) |
Constructor.
Definition at line 106 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 140 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 208 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 | Visibily |
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 312 of file extrafields.class.php.
References dol_now(), and dol_syslog().
Referenced by addExtraField().
ExtraFields::delete | ( | $attrname, | |
$elementtype = 'member' ) |
Delete an optional attribute.
string | $attrname | Code of attribute to delete |
string | $elementtype | Element type ('member', 'product', 'thirdparty', 'contact', ...) |
Definition at line 444 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 502 of file extrafields.class.php.
References dol_print_error(), and dol_syslog().
Referenced by delete().
ExtraFields::fetch_name_optionals_label | ( | $elementtype, | |
$forceload = false ) |
Load the array of extrafields defintion $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. |
Definition at line 847 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 2014 of file extrafields.class.php.
ExtraFields::getOptionalsFromPost | ( | $extrafieldsobjectkey, | |
$keyprefix = '', | |||
$keysuffix = '' ) |
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 | $keyprefix | Prefix string to add into name and id of field (can be used to avoid duplicate names) |
string | $keysuffix | Suffix string to add into name and id of field (can be used to avoid duplicate names) |
Definition at line 2306 of file extrafields.class.php.
References dol_htmlcleanlastbr(), dol_mktime(), GETPOST(), 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 2440 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 2153 of file extrafields.class.php.
References dol_eval(), dol_mktime(), getDolGlobalString(), GETPOST(), 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 | Prefix string to add after name and id of field (can be used to avoid duplicate names) |
string | $keyprefix | Suffix 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 retreived data (commonly $object->table_element) |
int | $mode | 1=Used for search filters |
Definition at line 954 of file extrafields.class.php.
References ajax_combobox(), dol_escape_htmltag(), dol_eval(), dol_syslog(), 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 1657 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(), img_object(), and price().
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 2054 of file extrafields.class.php.
References GETPOST().
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 560 of file extrafields.class.php.
References dol_syslog(), and update_label().
|
private |
Modify description of personalized attribute.
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 | Visiblity |
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 693 of file extrafields.class.php.
References dol_now(), dol_print_error(), and dol_syslog().
Referenced by update().