Module CustomFields Dev: Difference between revisions

Jump to navigation Jump to search
→‎Architecture: added Runtime outline
(→‎Preliminary test: Adding another case)
(→‎Architecture: added Runtime outline)
Line 86: Line 86:
* /customfieldspdftest/class/actions_customfieldspdftest.class.php --- Main functions library and hooks class, to hook onto pdf generation. Contains the PDFTest functions.
* /customfieldspdftest/class/actions_customfieldspdftest.class.php --- Main functions library and hooks class, to hook onto pdf generation. Contains the PDFTest functions.
* /customfieldspdftest/core/modules/modCustomFieldsPDFTest.class.php --- Module descriptor for Dolibarr
* /customfieldspdftest/core/modules/modCustomFieldsPDFTest.class.php --- Module descriptor for Dolibarr
== Runtime outline ==
Here is an outline of how CustomFields works: what functions will be called and why:
'''- At admin page:'''
* No external function call (apart for some icons or needed admin functions like for tabs), everything that is done are sql queries via CustomFields class (to fetch and modify the sql columns in the customfields tables).
'''- At printing:'''
* Module's hook formObjectOptions calls Dolibarr's hookmanager
* Hookmanager calls CustomFields /class/actions_customfields.class.php, function formObjectOptions() of CustomFields
* Preprocess a few parameters (mainly the $action) and calls customfields_print_forms()
* customfields_print_forms() preprocess all the hook's parameters and assimilate them with the CustomFields's configuration parameters (there's no connection to the database at this stage, only parameters preprocessing), then calls /lib/customfields_printforms.lib.php, functions customfields_print_creation_form() or customfields_print_datasheet_form
* both customfields_print_creation_form() lookup the database using CustomFields class and prints empty custom fields; customfields_print_datasheet_form() lookup the database using CustomFields class, fetch the values of the custom fields and prints them;
'''- At edition:'''
* Same steps as '''At printing'''
* then customfields_print_datasheet_form() process the custom field being edited differently than the others: if editing, it prints the html input field (to enter a new value), or if saving it just saves the data into the database by calling the CUSTOMFIELDS_MODIFY trigger and then continue to print the other fields normally.
* CUSTOMFIELDS_MODIFY trigger calls $customfields->update($newrecord);
'''- At creation (saving):'''
* Module's creation trigger MYMODULE_CREATE calls Dolibarr's run_trigger()
* Dolibarr run_trigger() calls CustomFields trigger file /core/trigger/interface_50_modCustomFields_SaveFields.class.php, function run_trigger()
* CustomFields's run_trigger() assimilate the given parameters with the CustomFields's config parameters, and if the trigger is found in $triggersarray, then the appropriate action is taken (by default: _CREATE or another standard action if recognized), if not in $triggersarray, the function will still try to automatically detect the appropriate action by detecting MYMODULE_ALISTOFACTIONS with a regular expression.
* The appropriate action is then done (creation in this case) by calling $customfields->create($record).
'''- At edition or creation of product lines:'''
* Similar to '''At edition''' but with hooks: formCreateProductOptions and formEditProductOptions.
'''- At ODT document generation and substitution:'''
* Module's ODT generator calls for Dolibarr's function complete_substitution_array(), which then calls for CustomFields substitution file /core/substitution/functions_customfields.lib.php, function customfields_completesubstitutionarray()
* CustomFields's function customfields_completesubstitutionarray() calls the simplifier library customfields_aux.lib.php, function customfields_fill_object() and make the substitution inside the $substitutionarray.
'''- At ODT document generation and substitution for product lines:'''
* Same as the previous point but this function is called for every product lines, and thus the data is cached. Also the simplifier function is here called customfields_fill_object_lines(), and the CustomFields's substitution function called customfields_completesubstitutionarray_lines().


= How to add the support of a new module =
= How to add the support of a new module =
439

edits

Navigation menu