class CardPage extends FormPage (View source)

CardPage class

Properties

protected string $head from Page
protected string $title from Page
protected string $access_permission from Page
protected array $tabs from Page
protected array $main_subtitle from Page
protected string $tabs_picture from Page
protected string $tabs_title from Page
protected string $active_tab from Page
protected boolean $close_form from Page
protected boolean $close_table from Page
protected boolean $add_fiche_end from Page
protected string $rights_class from Page
protected string $modulepart from Page
protected array $assets from Page
object $form from FormPage
protected string $body from FormPage
protected array $fields from FormPage
protected string $edit_permission
protected string $delete_permission
protected boolean $close_buttons_div
protected boolean $show_documents
protected string $const_name_prefix
protected string $sub_permission
protected string $mail_subject
protected string $mail_template
protected array $mail_substitutions
protected boolean $enable_mail_delivery_receipt
protected object $extrafields

Methods

__construct($page_title, $access_perm = '', $edit_perm = '', $delete_perm = '', $show_documents = false, $enable_save_as = false, $const_name_prefix = '', $sub_permission = '')

Constructor

$this
setTitle($page_title)

Set page title.

from Page
$this
setMainSubtitle($title, $picture = 'title_generic.png')

Set page main subtitle.

from Page
$this
loadLang($lang_file, $is_module_file = true)

Load a language file

from Page
$this
loadLangs($lang_files_array, $from_module = false)

Load an array of language files

from Page
$this
appendToHead($content)

Append content to page head.

from Page
$this
addJsFile($js_file)

Add JS file to page head.

from Page
$this
addJsFiles($js_files_array)

Add an array of JS files.

from Page
$this
addCssFile($css_file)

Add CSS file to page head.

from Page
$this
addCssFiles($css_files_array)

Add an array of CSS files.

from Page
$this
addTab($title, $url, $is_active = false, $position = -1)

Add a tab to the page.

from Page
$this
setTabsPicture($picture)

Set tabs picture.

from Page
$this
setTabsTitle($title)

Set tabs title.

from Page
generateTabs($noheader)

Generate tabs

from Page
$this
addSubTitle($title, $picture = 'title_generic.png', $morehtmlright = '')

Add a subtitle

from Page
$this
openForm($action = 'create', $enctype = '')

Open a form only if not already opened

from Page
$this
closeForm()

Close an opened form

from Page
$this
openTable($header_columns = array(), $attr = 'class="noborder allwidth"', $print_fiche_head = false, $summary = '')

Opens a new html table

from Page
$this
closeTable($print_fiche_end = false)

Close an opened html table

from Page
$this
openRow($odd = true, $more_attr = '')

Open a table row

from Page
$this
closeRow()

Close a table row

from Page
$this
addColumn($content, $attr = '')

Add a table column

from Page
$this
addLineBreak($repeat)

Add a line break (or many)

from Page
string
getTemplatePath($template)

Return template absolute path

from Page
$this
showTemplate($template_path, $path_is_absolute = false, $use_require_once = false, $template_params = array())

Include a template into the page.

from Page
$this
underConstruction()

Show page_under_construction template (only once)

from Page
$this
notFound()

Show page_not_found template (only once)

from Page
loadDefaultActions()

Load default actions

from Page
$this
begin()

Generate page beginning

generate()

Generate page body

from FormPage
redirect($url)

Redirect to a url (alias for dolibase_redirect function).

from Page
end($object = null)

Generate page end

$this
setFields($fields)

Set page fields

from FormPage
boolean
checkFields()

Check page fields

from FormPage
boolean|int
checkField($field_name, $field_trans = '', $field_validation_rules = '', $return_err_number = false)

Check specified field

from FormPage
Field|empty
getField($field_name)

Return specified field if found

from FormPage
$this
askForConfirmation($url, $title, $question, $action, $question_param = '', $dialog_id_suffix = '')

Show a confirmation message

from FormPage
$this
appendToBody($content)

Append a content to page body

from FormPage
boolean
canEdit()

Return if the current user can edit the page or not

boolean
canDelete()

Return if the current user can delete the object or not

$this
setMailSubject($mail_subject)

Set mail subject

$this
setMailTemplate($mail_template)

Set mail template

$this
enableMailDeliveryReceipt()

Enables mail delivery receipt

$this
setMailSubstitutions($mail_substitutions_array)

Set mail substitutions

openButtonsDiv()

Open buttons div (if not already opened)

closeButtonsDiv()

Close buttons div (if opened)

$this
addButton($name, $href = '#', $target = '_self', $class = 'butAction', $close_parent_div = false)

Add a button to the page

$this
addConfirmButton($name, $id, $href = '#', $target = '_self', $class = 'butAction', $close_parent_div = false)

Add a confirmation button to the page

$this
addListButton($name, $buttons = array(), $class = 'butAction', $close_parent_div = false)

Add a list button to the page

$this
addSaveAsButton($close_parent_div = false)

Add save as button to the page

$this
showField($field_name, $field_content, $is_editable = false, $edit_link = '', $attr = '')

Show a table field

$this
showRefField($field_name, $object, $list_link = '')

Show reference/Ref. field

$this
showExtraFields($object)

Show extra fields

int
updateExtraFields($object)

Update extra fields

$this
showBanner($object, $list_link = '', $morehtmlleft = '')

Show banner

$this
editField($field_name, $field_content, $action_name)

Edit a field

$this
editTextField($field_name, $input_name, $input_value = '', $input_size = 20, $action_prefix = 'set_')

Add a table field with a text input

$this
editTextAreaField($field_name, $text_area_name, $text_area_value = '', $toolbarname = 'dolibarr_details', $height = 100, $action_prefix = 'set_')

Add a table field with a text area

$this
editNumberField($field_name, $input_name, $input_value = '', $min, $max = 100, $action_prefix = 'set_')

Add a table field with a number input

$this
editDateField($field_name, $input_name, $input_value = '', $action_prefix = 'set_date_')

Add a table field with a date picker

$this
editListField($field_name, $list_name, $list_choices, $selected_choice = '', $show_empty, $action_prefix = 'set_')

Add a table field with a list

$this
editRadioListField($field_name, $radio_name, $radio_list, $selected = '', $action_prefix = 'set_')

Add a table field with a radio input(s)

$this
editCheckListField($field_name, $check_name, $check_list, $selected = '', $action_prefix = 'set_')

Add a table field with a checkbox input(s)

$this
editColorField($field_name, $input_name, $input_value = '', $action_prefix = 'set_')

Add a table field with a color picker

printRelatedObjects($object)

Print related objects block.

printDocuments($object)

Print documents block

printMailForm($object)

Print mail form

Details

__construct($page_title, $access_perm = '', $edit_perm = '', $delete_perm = '', $show_documents = false, $enable_save_as = false, $const_name_prefix = '', $sub_permission = '')

Constructor

Parameters

$page_title HTML page title
$access_perm Access permission
$edit_perm Edit permission
$delete_perm Delete permission
$show_documents Show documents/linked files block
$enable_save_as Enable save as feature
$const_name_prefix Constant name prefix
$sub_permission Module sub permission

$this setTitle($page_title)

Set page title.

Note: this function should be called before $page->begin() function, otherwise it will not work as expected.

Parameters

$page_title Page title

Return Value

$this

$this setMainSubtitle($title, $picture = 'title_generic.png')

Set page main subtitle.

Note: this function should be called before $page->begin() function, otherwise it will not work as expected.

Parameters

$title title
$picture subtitle picture

Return Value

$this

$this loadLang($lang_file, $is_module_file = true)

Load a language file

Parameters

$lang_file Language file
$is_module_file File is in module 'langs' directory or not

Return Value

$this

$this loadLangs($lang_files_array, $from_module = false)

Load an array of language files

Parameters

$lang_files_array Language files array
$from_module Files should be loaded from module 'langs' directory or not

Return Value

$this

$this appendToHead($content)

Append content to page head.

Note: this function should be called before $page->begin() function, otherwise it will not work as expected.

Parameters

$content content to add

Return Value

$this

$this addJsFile($js_file)

Add JS file to page head.

Note: this function should be called before $page->begin() function, otherwise it will not work as expected.

Parameters

$js_file Javascript file

Return Value

$this

$this addJsFiles($js_files_array)

Add an array of JS files.

Note: this function should be called before $page->begin() function, otherwise it will not work as expected.

Parameters

$js_files_array Javascript files array

Return Value

$this

$this addCssFile($css_file)

Add CSS file to page head.

Note: this function should be called before $page->begin() function, otherwise it will not work as expected.

Parameters

$css_file CSS file

Return Value

$this

$this addCssFiles($css_files_array)

Add an array of CSS files.

Note: this function should be called before $page->begin() function, otherwise it will not work as expected.

Parameters

$css_files_array CSS files array

Return Value

$this

$this addTab($title, $url, $is_active = false, $position = -1)

Add a tab to the page.

Note: this function should be called before $page->begin() function, otherwise it will not work as expected.

Parameters

$title tab title
$url tab url
$is_active should this tab be the activated one (true or false)
$position tab position (-1 means add to the end)

Return Value

$this

$this setTabsPicture($picture)

Set tabs picture.

Note: this function should be called before $page->begin() function, otherwise it will not work as expected.

Parameters

$picture tabs picture

Return Value

$this

$this setTabsTitle($title)

Set tabs title.

Note: this function should be called before $page->begin() function, otherwise it will not work as expected.

Parameters

$title tabs title

Return Value

$this

protected generateTabs($noheader)

Generate tabs

Parameters

$noheader -1 or 0=Add tab header, 1=no tab header.

$this addSubTitle($title, $picture = 'title_generic.png', $morehtmlright = '')

Add a subtitle

Parameters

$title subtitle title
$picture subtitle picture
$morehtmlright more HTML to show on the right

Return Value

$this

$this openForm($action = 'create', $enctype = '')

Open a form only if not already opened

Parameters

$action form action
$enctype form enctype attribute

Return Value

$this

$this closeForm()

Close an opened form

Return Value

$this

$this openTable($header_columns = array(), $attr = 'class="noborder allwidth"', $print_fiche_head = false, $summary = '')

Opens a new html table

Parameters

$header_columns table header columns, e.: array( array('name' => 'Column1', 'attr' => 'align="center"'), array('name' => 'Column2', 'attr' => 'align="center" width="20"') )
$attr table attributes
$print_fiche_head print Dolibarr fiche head
$summary table summary

Return Value

$this

$this closeTable($print_fiche_end = false)

Close an opened html table

Parameters

$print_fiche_end print Dolibarr fiche end

Return Value

$this

$this openRow($odd = true, $more_attr = '')

Open a table row

Parameters

$odd row is odd or peer
$more_attr more attributes to add

Return Value

$this

$this closeRow()

Close a table row

Return Value

$this

$this addColumn($content, $attr = '')

Add a table column

Parameters

$content column content
$attr column attributes

Return Value

$this

$this addLineBreak($repeat)

Add a line break (or many)

Parameters

$repeat repeat line breaks

Return Value

$this

protected string getTemplatePath($template)

Return template absolute path

Parameters

$template template relative path or name

Return Value

string template absolute path

$this showTemplate($template_path, $path_is_absolute = false, $use_require_once = false, $template_params = array())

Include a template into the page.

Note: the template should be inside module tpl folder when $path_is_absolute parameter equal false.

Parameters

$template_path template path
$path_is_absolute define whether the template path is absolute or not
$use_require_once permit to avoid including the template many times on the same page
$template_params template parameters

Return Value

$this

$this underConstruction()

Show page_under_construction template (only once)

Return Value

$this

$this notFound()

Show page_not_found template (only once)

Return Value

$this

protected loadDefaultActions()

Load default actions

$this begin()

Generate page beginning

Return Value

$this

protected generate()

Generate page body

redirect($url)

Redirect to a url (alias for dolibase_redirect function).

Note: this function should be called before any output, so before $page->begin() function.

Parameters

$url

end($object = null)

Generate page end

Parameters

$object Object

$this setFields($fields)

Set page fields

Parameters

$fields array of fields

Return Value

$this

boolean checkFields()

Check page fields

Return Value

boolean true or false

boolean|int checkField($field_name, $field_trans = '', $field_validation_rules = '', $return_err_number = false)

Check specified field

Parameters

$field_name Field name
$field_trans Field translation
$field_validation_rules Field validatin rules
$return_err_number return errors number or boolean value

Return Value

boolean|int true/false | errors number

protected Field|empty getField($field_name)

Return specified field if found

Parameters

$field_name

Return Value

Field|empty field object or empty value

$this askForConfirmation($url, $title, $question, $action, $question_param = '', $dialog_id_suffix = '')

Show a confirmation message

Parameters

$url Page url
$title Message title
$question Message question / content
$action Action to do after confirmation
$question_param Question parameter
$dialog_id_suffix Dialog id suffix (used to show the dialog without reloading the page)

Return Value

$this

$this appendToBody($content)

Append a content to page body

Parameters

$content content to add

Return Value

$this

boolean canEdit()

Return if the current user can edit the page or not

Return Value

boolean true or false

boolean canDelete()

Return if the current user can delete the object or not

Return Value

boolean true or false

$this setMailSubject($mail_subject)

Set mail subject

Parameters

$mail_subject Mail subject string

Return Value

$this

$this setMailTemplate($mail_template)

Set mail template

Parameters

$mail_template Mail template string

Return Value

$this

$this enableMailDeliveryReceipt()

Enables mail delivery receipt

Return Value

$this

$this setMailSubstitutions($mail_substitutions_array)

Set mail substitutions

Parameters

$mail_substitutions_array Mail substitutions array

Return Value

$this

protected openButtonsDiv()

Open buttons div (if not already opened)

protected closeButtonsDiv()

Close buttons div (if opened)

$this addButton($name, $href = '#', $target = '_self', $class = 'butAction', $close_parent_div = false)

Add a button to the page

Parameters

$name button name
$href button href
$target button target
$class button class
$close_parent_div should close parent div or not

Return Value

$this

$this addConfirmButton($name, $id, $href = '#', $target = '_self', $class = 'butAction', $close_parent_div = false)

Add a confirmation button to the page

Parameters

$name button name
$id button id (used to display the confirmation dialog)
$href button href
$target button target
$class button class
$close_parent_div should close parent div or not

Return Value

$this

$this addListButton($name, $buttons = array(), $class = 'butAction', $close_parent_div = false)

Add a list button to the page

Parameters

$name button name
$buttons buttons list
$class button class
$close_parent_div should close parent div or not

Return Value

$this

$this addSaveAsButton($close_parent_div = false)

Add save as button to the page

Parameters

$close_parent_div should close parent div or not

Return Value

$this

$this showField($field_name, $field_content, $is_editable = false, $edit_link = '', $attr = '')

Show a table field

Parameters

$field_name field name
$field_content field content
$is_editable is field editable or not
$edit_link edition link
$attr HTML attributes

Return Value

$this

$this showRefField($field_name, $object, $list_link = '')

Show reference/Ref. field

Parameters

$field_name field name
$object object
$list_link link to list

Return Value

$this

$this showExtraFields($object)

Show extra fields

Parameters

$object Object

Return Value

$this

int updateExtraFields($object)

Update extra fields

Parameters

$object Object

Return Value

int

0 if KO, 0 if OK

$this showBanner($object, $list_link = '', $morehtmlleft = '')

Show banner

Parameters

$object object
$list_link link to list
$morehtmlleft more html in the left

Return Value

$this

$this editField($field_name, $field_content, $action_name)

Edit a field

Parameters

$field_name field name
$field_content field content
$action_name action name

Return Value

$this

$this editTextField($field_name, $input_name, $input_value = '', $input_size = 20, $action_prefix = 'set_')

Add a table field with a text input

Parameters

$field_name field name
$input_name input name
$input_value input value
$input_size input size
$action_prefix action prefix

Return Value

$this

$this editTextAreaField($field_name, $text_area_name, $text_area_value = '', $toolbarname = 'dolibarr_details', $height = 100, $action_prefix = 'set_')

Add a table field with a text area

Parameters

$field_name field name
$text_area_name text area name
$text_area_value text area value
$toolbarname Editor toolbar name, values: 'Full', dolibarr_details', 'dolibarr_notes', 'dolibarr_mailings', 'dolibarr_readonly'
$height text area height
$action_prefix action prefix

Return Value

$this

$this editNumberField($field_name, $input_name, $input_value = '', $min, $max = 100, $action_prefix = 'set_')

Add a table field with a number input

Parameters

$field_name field name
$input_name input name
$input_value input value
$min input minimum number
$max input maximum number
$action_prefix action prefix

Return Value

$this

$this editDateField($field_name, $input_name, $input_value = '', $action_prefix = 'set_date_')

Add a table field with a date picker

Parameters

$field_name field name
$input_name input name
$input_value input value
$action_prefix action prefix

Return Value

$this

$this editListField($field_name, $list_name, $list_choices, $selected_choice = '', $show_empty, $action_prefix = 'set_')

Add a table field with a list

Parameters

$field_name field name
$list_name list name
$list_choices list choices, e.: array('choice_1' => 'Choice 1', 'choice_2' => 'Choice 2')
$selected_choice selected choice
$show_empty show empty value
$action_prefix action prefix

Return Value

$this

$this editRadioListField($field_name, $radio_name, $radio_list, $selected = '', $action_prefix = 'set_')

Add a table field with a radio input(s)

Parameters

$field_name field name
$radio_name radio inputs name
$radio_list list of radio inputs, e.: array('radio_1' => 'Radio 1', 'radio_2' => 'Radio 2')
$selected selected radio input
$action_prefix action prefix

Return Value

$this

$this editCheckListField($field_name, $check_name, $check_list, $selected = '', $action_prefix = 'set_')

Add a table field with a checkbox input(s)

Parameters

$field_name field name
$check_name checkbox inputs name
$check_list list of checkbox inputs, e.: array('check_1' => 'Check 1', 'check_2' => 'Check 2')
$selected selected checkbox input
$action_prefix action prefix

Return Value

$this

$this editColorField($field_name, $input_name, $input_value = '', $action_prefix = 'set_')

Add a table field with a color picker

Parameters

$field_name field name
$input_name input name
$input_value input value
$action_prefix action prefix

Return Value

$this

protected printRelatedObjects($object)

Print related objects block.

Note: To enable the linking feature, you must define a constant in each module as 'your_module_right_class_in_capital_letters'.'_ENABLE_EXPANDED_LINKS'

Parameters

$object Object

protected printDocuments($object)

Print documents block

Parameters

$object Object

protected printMailForm($object)

Print mail form

Parameters

$object Object