Patches
A patch is a way to extend Microbizz for a single contract number. For each contract number there is a patch file (in obj/Patch/liveXXXX.php
) which is loaded when a user logs in. The patch file should fill in the $this→patchscripts[]
array; the array is stored in the session.
Different parts of Microbizz checks for patches and do something special if the patch exists. F.ex. the Todo→toDB()
function checks if there is a patch named 'onsave' for the task module, and if so it assumes that the patch is a function and calls that function. So if a contract number provides that patch, then a contract specific function is called whenever a task is saved. Other patches may simply be configurations, like the name of a field which should be used for something. It is entirely up to the part of Microbizz that uses a patch to decide how it wants to use the patch information.
The sections on this page refers to modcodes and the subsections to individual patch names.
basic
adjustsecondarytext_function
This patch can be used to modify the content of secondary texts.
$this->patchscripts['basic']['adjustsecondarytext_function'] = array('PatchCustomer', 'adjustsecondarytext'); // $modcode is the module code // $object is the object we are doing secondary text for // $text is the generated text // Return the adjusted text public static function adjustsecondarytext($modcode, $object, $text) { // do something return $adjusted_text }
applinks
app-settings
floorplan_title
hardurlredirect
basictemplate
mobileredirect
onelineaddresses
c5ivj
mailgetfilters
filter_prehandle_func
onfiltersavedata
onmasterprepare
pdftemplate-lineformat
documentlinecolumnheaderrenames
allowusernologin
ventuusers
folderaccess
filesync2
The patch value is an array holding various flags and settings. Default is an empty array.
name | values | default | meaning |
---|---|---|---|
no-move | true or false | false | If true then don't use the RQMOV call |
onattachvalues
This is called every time Form→attachValues()
is called for any form.
$this->patchscripts['basic']['onattachvalues'] = array('PatchCustomer', 'attachvalues'); // $form is the form, use $form->getID() to check which form it is // $values is the array of values that was passed to $form->attachValues() // $object is an object that is being edited by the fomr, typically $values=$object->toArray() public static function attachvalues($form, $values, $object) { // do something }
onnotesave
onnotepostsave
onnoteremove
onanswergrab
$this->patchscripts['basic']['onanswergrab'] = array('example'); function example($answer, $object, $handle) { // Do something with $answer }
This patch grab question answers. $answer
is the QuestionAnswer
-object. $object
is the object on which the answer is given and $handle
is true if this is the first time the answer is saved (while marked completed)
defaultwa
bouncewarning
mailimport
mailimport_findtask
Used when trying to match an imported mail to a task.
directconnect
smsintercept_numbers
When an SMS is received from a phone no. in this list, it is passwed to the smsintercept_handler function.
smsintercept_keywords
This is a list of SMS keywords that should be handled by the smsintercept_handler function. May be * for all keywords.
smsintercept_handler
This may provide a function which is called when an SMS has been received.
invoiceexport
reduceinvoicelines
$this->patchscripts['invoiceexport']['reduceinvoicelines'] = array('example'); function example($invoiceexportlines) { // Do something with $invoiceexportlines return $invoiceexportlines; }
This patch is a function name for a function that takes an array of InvoiceExportLine as a parameter, which is the result passed from the InvoiceExportLine::getAll()
function and returns a new array of InvoiceExportLine which will replace the result from InvoiceExportLine::getAll()
This can be used to modify or reduce the lines that are sent to invoicing.
edi_new_allowances_logic
Set this to 1 to enable the new EDI allowances logic. The new logic reads the proper names of the allowances, and allows them to be included within the invoicelines.
edi
This patch lists the EAN and CVR numbers that should be used to recognise EDIs for this contract.
$this->patchscripts['invoiceexport']['edi'] = array('CVR' => array('12345678','12345679'), 'EAN' => array('5790001234'));
ongenlinesforpdf
onsaveedilines
onexportcsvline
edi_preferstandardnumber
onsaveedilines
alwaysfilltaskcustomer
If a task both have a customer reference and a separate payment customer reference, the invoice information will be loaded from the latter. If this patch is set to true, then invoice information will be taken from the former (but the invoice will still be linked to the latter).
linelimit
Max. number of invoicelines to display in the “old” invoice export.
tabledatafilter
Use this to modify data in a Table object.
$table = new Table('testtable'); $this->patchscripts['tabledatafilter']['testtable'] = array('example'); // @param array $data function example($data) { // Modify $data to be something else. return $data; }
todo
allow-all-users-and-teams-in-subtasks
If set to true then subtasks will allow selection of all users and teams. If set to users
then subtasks will allow selection of all users.
onsave
$this->patchscripts['todo']['onsave'] = array('example'); // @param Todo $todo function example($todo) { // Do something with $todo }
This patch is a function name for a function that takes a Todo object just before it is saved in the toDB
-function. This can be used to modify the Todo-object before saving it.
onpostsave
This is almost the same as onsave above with the only difference being, that this is triggered after the object is written to the database, which can be useful if we need to know which object the ID was assigned.
onxnethandled
Called when someone clicks on a link in a subcontractor mail.
onuisave
This is called when a user has edited a task manaually. It is called after all sorts of other things have been handled (eg. equipment attachment, file handling, ticket attachment, subcontractor mail etc).
onqfsave
$this->patchscripts['todo']['onqfsave'] = array('example'); // @param Todo $todo function example($todo, $qf, $answers) { // Do something }
When a task is saved from a question action, this patch is used to modify the task further.
The task may be modified further by the question action after the patch returns.
istl
$this->patchscripts['todo']['istl'] = array('example'); // @param Todo $todo function example($todo) { return (shoulduserbetl); }
This patch point can be used to influence if the active user, should be considered a team leader in regard to this task.
If this returns true, then Todo→istl()
will also return true. If this returns false, Todo→istl()
will evaluate as usual.
replacepdfcontentfunc
$this->patchscripts['todo']['replacepdfcontentfunc'] = array('example'); // @param Todo $todo function example($todo, $opts, &$content) { // Replace content with a hello world text. $content = array( array('type' => 'html', 'content' => '<b>Hello World</b>') ); // Or add a hello world text as content in addition to existing content. $content[] = array('type' => 'html', 'content' => '<b>Hello World</b>'); }
Use this patch point to replace content in generated PDF-files from tasks. $todo
is the task in question, $opts
are the options passed to the PDF generator, and $content
is the content array, which needs to be modified in place.
tools
onsave
onhistorysave
ontooltake
onattach
onattached
onpostsave
oninvoice
notakencolor
customers
searchrestrictfunction
detailbuttons
detailtabs
onsaveformaspdf
mailpdf-qf-subject
news-templates
disablerouteplanning
quick_search_add_fields
quick_search_provide_data_modifier
onsubscriptioninvoice
getcustomernumber
usesubscriptiontitleastext
usesubscriptiondescriptionastext
onsave
turbomailimport
project2
runactionbefore
$this->patchscripts['project2']['runactionbefore'] = array('example'); // @param Todo $todo function example($unit) { // Do something with $unit }
This patch is a function name for a function that takes a Unit and a phase ID, and is executed just before running other actions on the unit in the current phase.
runactionafter
This is exactly like runactionbefore expect that this is triggered after other actions ran.
startpage
onlocation_todo_actions
onlocation_customer_actions
onlocation_mobile_todo_actions
onlocation_mobile_customer_actions
custominfoboxes
yellow-server-bar-html
This defines a text to display in a yellow bar at the top of all pages.
prodplan
onsave
onaftersave
ondelete
removeadditionals
select-todo-when-plan-new
keepproductiononclose
todoweeklytimefield
copyroutestarttime
planonholidays
xnet
allowedfields
The extranet often limits which fields are allowed in the layout etc. This patch can be used to change the limitations.
The patch functions takes a Record2 object and a field list as arguments, and returns an updated field list.
$allowedfields = call_user_func($patchfn, $todo, $allowedfields);
exporttools
folderaccess
This is used to extend access to files/folders on the extranet.
It is called with a FileFolder object, and optionally also a File object, as arguments, and should return true to allow access, or false to use the normal rights.
The patch is not used by all parts of MB.
frontpage
no-todo-search-autosubmit
If this is set to true, then the todolist page on the extranet will not perform automatic search ie. you type and then it searches if you haven't typed anything for a couple of minutes.
onpagedisplay
pagetypes
sortfiles
tooldisplayfunc
tool-editablefields
registration
oncheckoutreg
dontcloseauto
onsave
onaftersave
onremove
provider_searchforcustomer
tool-search-autosubmit
If set to false
then the equipment search form will not autosubmit.
todo-search-autosubmit
If set to false
then the task search form will not autosubmit.
api
api_patchcommand
allowchangeinvoicedproductuse
expose_xnet_usernames
toapi_Todo
Called when a Todo has been converted to API format, just before it is sent to the app.
tosys_Todo
Called when a Todo has been converted from API format to an array in MB format, just before it is used to update a Todo.
users
showwebappqr
If true, then show the legacy webapp qr code on the user screen.