Friday, October 21, 2011

Php Plugins for BlueBox2.0

Not many developers are aware that writing a plugin for BlueBox2.0 is as easy as it actually is.

By plugin, we are referring to an 'intercept function' that dove-tails into the current system process model built into BlueBox2.0.

Each time a standard class->method is called within the BB2 framework, a plugin can be inserted to handle the data passing through at that point.

Here is how...
  • Firstly, create a php file in portal/{database_name}/custom_modules called bb_plugins.php
  • The file should have the following format:

    <?php
    class bb_plugins extends baseclass{
       ...
    }
    ?>

  • Then add as many plugn functions as you require, naming them as class_name_plugin_name, ie

    function bb_sales_orders_post_add(){
    ...
    }

  • The format of the plugin is also important and should have at minimum, the following:

    function bb_sales_orders_post_add($conf=NULL){
           global $global,$class,$method;
           .....
           return($conf)
    }

  •  Standard intercept-nodes are:
    • pre_view
    • post_view
    • pre_viewlist
    • post_viewlist
    • pre_get
    • post_get
    • pre_add_form
    • post_add_form
    • pre_add
    • post_add
    • pre_edit_form
    • post_edit_form
    • pre_edit
    • post_edit
    • pre_delete
    • post_delete
    • pre_truedelete
    • post_truedelete

    And some special instances are:

    • bb_secure->pre_login
    • bb_secure->post_login
    • bb_datamerge->extra_data

  • And that's it... from there it is up to you. You can intercept data, call other functions, do whatever you require with the data that is passed into the function via $conf, just as long as you pass it back out with return $conf at the end...
  • As an extra feature, bb_plugins.php can also be used to set bbsettings dynamically.
    This is done by declaring a function as class_name_bbsetting_full_name, eg:

    function bb_sales_orders_bbsetting_display_name_template($conf=NULL){
          
    global $global,$class,$method;
           $value=$conf[name]." ".$conf[_id];
           return($value)
    }

Friday, October 14, 2011

New Module : BlueBox Financial Document Templates

This week we released a new module for BlueBox2.0 which allows you to template the header and lines for financial documents.

Similar to the Module Defaults module, this new module adds the functionality of being able to attach a number of pre-set lines to the template. Using this new module you will be able to set up 'standard' documents which are captured regularly, and specify which items, quantities and prices to apply automatically.

The templates are accessed via the DataFunctions menu, and if you have permission to add new templates a quick-link can be seen there as well.

Here is the process:

The new module can be accessed, added to and edited via it's direct link under the admin menu:

As easy way to access the Findoc Templates for a specific module is to click on DatabaseFunctions in the top menu for that module (ie SalesOrders). Click on New Findoc Template...

A new Findoc Template requires a name and a module_name. Optionally you can set header-defaults in the 'other variables' area... these are to be separated into new lines, with an = between the variable name and it's raw value.

Once added you can then add multiple lines to the template, at minimum you must add the item, with qty, price and description optional.

Finally, back in the SalesOrders module, if you click on the DatabaseFuntions menu you will now see the new template available for selection...clicking on it will apply the defaults to a new sales order.