class CreatePage extends FormPage (View source)

CreatePage 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 object $extrafields

Methods

__construct($page_title, $access_perm = '')

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

from Page
generate()

Generate page body

from FormPage
redirect($url)

Redirect to a url (alias for dolibase_redirect function).

from Page
end()

Generate page end.

from Page
$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
checkExtraFields($object)

Check page extrafields

$this
addField($field_name, $field_content, $is_required = false, $field_summary = '', $more_attr = '')

Add a table field

$this
addTextField($field_name, $input_name, $input_value = '', $is_required = false, $field_summary = '', $input_size = 20)

Add a table field with a text input

$this
addTextAreaField($field_name, $text_area_name, $text_area_value = '', $is_required = false, $field_summary = '', $toolbarname = 'dolibarr_details', $height = 100, $valign = 'top')

Add a table field with a text area

$this
addNumberField($field_name, $input_name, $input_value = '', $is_required = false, $field_summary = '', $min, $max = 100)

Add a table field with a number input

$this
addDateField($field_name, $input_name, $input_value = '', $is_required = false, $field_summary = '')

Add a table field with a date picker

$this
addListField($field_name, $list_name, $list_choices, $selected_choice = '', $is_required = false, $field_summary = '', $show_empty)

Add a table field with a list

$this
addRadioListField($field_name, $radio_name, $radio_list, $selected = '', $is_required = false, $field_summary = '', $valign = 'middle')

Add a table field with a radio input(s)

$this
addCheckListField($field_name, $check_name, $check_list, $selected = '', $is_required = false, $field_summary = '', $valign = 'middle')

Add a table field with a checkbox input(s)

$this
addColorField($field_name, $input_name, $input_value = '', $is_required = false, $field_summary = '')

Add a table field with a color picker

$this
addExtraFields($object)

Add extra fields

$this
generateFormButtons()

Generate form buttons

Details

__construct($page_title, $access_perm = '')

Constructor

Parameters

$page_title HTML page title
$access_perm Access 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()

Generate page end.

Note: this function should be called after $page->begin() call.

$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 checkExtraFields($object)

Check page extrafields

Parameters

$object Object

Return Value

boolean true or false

$this addField($field_name, $field_content, $is_required = false, $field_summary = '', $more_attr = '')

Add a table field

Parameters

$field_name field name
$field_content field content
$is_required is field required or not
$field_summary field summary
$more_attr more attributes to add

Return Value

$this

$this addTextField($field_name, $input_name, $input_value = '', $is_required = false, $field_summary = '', $input_size = 20)

Add a table field with a text input

Parameters

$field_name field name
$input_name input name
$input_value input value
$is_required is field required or not
$field_summary field summary
$input_size input size

Return Value

$this

$this addTextAreaField($field_name, $text_area_name, $text_area_value = '', $is_required = false, $field_summary = '', $toolbarname = 'dolibarr_details', $height = 100, $valign = 'top')

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
$is_required is field required or not
$field_summary field summary
$toolbarname Editor toolbar name, values: 'Full', dolibarr_details', 'dolibarr_notes', 'dolibarr_mailings', 'dolibarr_readonly'
$height text area height
$valign field vertical align

Return Value

$this

$this addNumberField($field_name, $input_name, $input_value = '', $is_required = false, $field_summary = '', $min, $max = 100)

Add a table field with a number input

Parameters

$field_name field name
$input_name input name
$input_value input value
$is_required is field required or not
$field_summary field summary
$min input minimum number
$max input maximum number

Return Value

$this

$this addDateField($field_name, $input_name, $input_value = '', $is_required = false, $field_summary = '')

Add a table field with a date picker

Parameters

$field_name field name
$input_name input name
$input_value input value
$is_required is field required or not
$field_summary field summary

Return Value

$this

$this addListField($field_name, $list_name, $list_choices, $selected_choice = '', $is_required = false, $field_summary = '', $show_empty)

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
$is_required is field required or not
$field_summary field summary
$show_empty show empty value

Return Value

$this

$this addRadioListField($field_name, $radio_name, $radio_list, $selected = '', $is_required = false, $field_summary = '', $valign = 'middle')

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
$is_required is field required or not
$field_summary field summary
$valign field vertical align

Return Value

$this

$this addCheckListField($field_name, $check_name, $check_list, $selected = '', $is_required = false, $field_summary = '', $valign = 'middle')

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' => 'Checkbox 1', 'check_2' => 'Checkbox 2')
$selected selected checkbox input
$is_required is field required or not
$field_summary field summary
$valign field vertical align

Return Value

$this

$this addColorField($field_name, $input_name, $input_value = '', $is_required = false, $field_summary = '')

Add a table field with a color picker

Parameters

$field_name field name
$input_name input name
$input_value input value
$is_required is field required or not
$field_summary field summary

Return Value

$this

$this addExtraFields($object)

Add extra fields

Parameters

$object Object

Return Value

$this

$this generateFormButtons()

Generate form buttons

Return Value

$this