439
edits
(→Architecture: added Runtime outline) |
|||
| Line 90: | Line 90: | ||
Here is an outline of how CustomFields works: what functions will be called and why: | Here is an outline of how CustomFields works: what functions will be called and why: | ||
'''- At admin page:''' | '''- 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). | * 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:''' | '''- At printing:''' | ||
| Line 102: | Line 104: | ||
* 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 | * 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; | * 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:''' | '''- At edition:''' | ||
| Line 108: | Line 111: | ||
* 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. | * 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); | * CUSTOMFIELDS_MODIFY trigger calls $customfields->update($newrecord); | ||
'''- At creation (saving):''' | '''- At creation (saving):''' | ||
| Line 115: | Line 119: | ||
* 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. | * 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). | * The appropriate action is then done (creation in this case) by calling $customfields->create($record). | ||
'''- At edition or creation of product lines:''' | '''- At edition or creation of product lines:''' | ||
* Similar to '''At edition''' but with hooks: formCreateProductOptions and formEditProductOptions. | * Similar to '''At edition''' but with hooks: formCreateProductOptions and formEditProductOptions. | ||
'''- At ODT document generation and substitution:''' | '''- At ODT document generation and substitution:''' | ||
| Line 124: | Line 130: | ||
* 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() | * 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. | * 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:''' | '''- At ODT document generation and substitution for product lines:''' | ||
edits