Wednesday, November 9, 2011

More Bespoke Plugins for BB2.0 : Controlling Fields

For PHP developers there are many ways in which you can control and manipulate the outcomes of system processes within BlueBox2.0. One of these is via our plugins architecture.

The newest feature in this regard is the ability to intercept and control fields and the way they display in forms as well as other outputs (ie views and viewlists).

Interception can take place at 3 levels for form-fields and for displaying variable values.
  • Level 1: Global level - whenever the variable is 'called' it will look to your new method to render it to the engine.
  • Level 2: Class/variable level - whenever the variable is called from forms within a specified class it will look to your new method to render it to the engine.  
  • Level 3: Field level - specified using a naming syntax within the variable name, your method will only be called when your specific custom named variable is called.
  • For Form Fields:
    • Within the BB2 Forms Engine we have a function which renders form-fields to the GUI engine. At it's simplest form it can be called with a BB2.0 Tag like this:
      <!--:formfield:variable_name:-->
    • These new plugins essentially hi-jack the process that is invoked by this tag and allow you to determine what form-field element/s get rendered to the GUI when this variable is called
    • To change the form-field globally for a variable name (ie cashbookISbb_finance_cashbooksID) you can use the class->method call within bb_plugins.php. To do this you will need a bb_plugins.php file in your custom_modules folder and then you will need to name/format your function as follows:

      function formfield_cashbookISbb_finance_cashbooksID($conf=NULL){
            //the value of $conf is an array with useful data in it
            //most notably $conf[default] which is the current value, if any, for this variable
            //for the full array simply resp_r($conf) at this point...
            return("
                         <input
                                id=global[fields][cashbookISbb_finance_cashbooksID]
                                name=global[fields][cashbookISbb_finance_cashbooksID]
                                value='$conf[default]'
                          >");
      }


      In the above example you can see that you need to return a string with a form element in it, but this can be any combination of html, javascript, etc instructions. Basically, wherever this variable is called through the forms engine, this will be sent back to the form as the 'field'.
    • For a specific class/variable combination by using a bbsetting, namely bbsetting_field_display_formfield_plugins. This can be set within a PHP file as follows:

      var $bbsetting_field_display_formfield_plugins=array("field_name"=>"method_to_call");

      or it can be set using the Admin>Module Settings functionality by entering the field=>method pairs separated by commas ie:

      field_name=method_name,
      field_name2=method_name2,

      You can set multiple field=>method values within this array. The 'method' can then sit within the bb_plugins class or the parent class where the bbsetting has been set, either place will work. The method can be styled exactly as per the function example above. So, just to drive the point home, in this instance, if the bbsetting was set in the bb_finance_cashbook_entries class, then only when forms within that class are rendering the cashbookISbb_finance_cashbooksID will this form-field override take effect.
    • On an ad-hoc basis within the variable/field name itself, by using the variable naming syntax as follows : variable_nameISPLUGIN_method_name. This behaves exactly as per the second example above, whereby it looks for the method within the bb_plugins class or, if it can detect a current related class to the variable, within the current class. The method can be styled exactly as per the function example above.
     
  • For Field Value Display:
    • Within the BB2 GUI engine we have a function called item_display_value. This takes an input in the form of an array which specifies the variable name to display and any possible value/s for it. The function then determines how to render the variable/value to the GUI engine.
    • These new plugin options essentially hi-jack this process and override the renderer with your bespoke method.
    • To change the form-field globally for a variable name (ie cashbookISbb_finance_cashbooksID) you can use the class->method call within bb_plugins.php. To do this you will need a bb_plugins.php file in your custom_modules folder and then you will need to name/format your function as follows:

      function item_display_value_cashbookISbb_finance_cashbooksID($conf=NULL){
            //the value of $conf is an array with useful data in it
            //most notably $conf[1] which is the current value, if any, for this variable
            //for the full array simply resp_r($conf) at this point...
            return($conf[1]);
      }


      In the above example you can see that you need to return a string with the value as you want it represented in it, but this can be any combination of html, javascript, etcas required. Basically, wherever this variable is called through the GUI engine, this will be sent back as the value/output.

    • For a specific class/variable combination by using a bbsetting, namely bbsetting_field_display_plugins. This can be set within a PHP file as follows:

      var $bbsetting_field_display_plugins=array("field_name"=>"method_to_call");

      or it can be set using the Admin>Module Settings functionality by entering the field=>method pairs separated by commas ie:

      field_name=method_name,
      field_name2=method_name2,

      You can set multiple field=>method values within this array. The 'method' can then sit within the bb_plugins class or the parent class where the bbsetting has been set, either place will work. The method can be styled exactly as per the function example above. So, just to drive the point home, in this instance, if the bbsetting was set in the bb_finance_cashbook_entries class, then only when forms within that class are rendering the cashbookISbb_finance_cashbooksID will this form-field override take effect.

    • On an ad-hoc basis within the variable name itself, by using the variable naming syntax of variable_nameISPLUGIN_method_name. This behaves exactly as per the second example above, whereby it looks for the method within the bb_plugins class or, if it can detect a current related class to the variable, within the current class. The method can be styled exactly as per the function example above.

Sunday, November 6, 2011

Better Visibility of Inventory Overallocation in BlueBox2.0

BlueBox2.0 has wonderful inventory visibility and control features. These include a detailed inventory report which shows inventory in real time, specifying it's location, allocation status etc.

A new addition to this report is the visibility of whether an item allocated to a document in the system is over-allocated or not. The appearance of a red ! will indicate that the system thinks the item is over-allocated and you are then able to click through to the parent document for further info.



Following on from this, our 'Release Stock' function has also had an upgrade in that it now allows filtering for only those items which are over-allocated, and will indicate in a normal listing of items to release, which it thinks are over-allocated.



Both new features will assist Inventory Controllers as they go about their day-to-day tasks, making finding and releasing over-allocated stock as simple a a few clicks of the mouse.

Friday, November 4, 2011

New BB2.0 Currency Converter via Yahoo

For the past 4 years the BlueBox2.0 Currency Engine has been driven by the Google currency service. However in the past week, our method of gathering the conversion figures from Google results stopped working, due to what appears to be Google's new format of mashing various result sets on their search results page from numerous sources, making getting at the info difficult and unpredictable.

To get away from this method, and to continue to provide a reliable, free web-based source of currency values, we have implemented a Yahoo Currency service which returns a far cleaner result.

This service relies on the 3 digit currency code for each currency, and so, in order for older BB2.0 sites to use this feature their currency 'codes' will need to be updated manually. As soon as these are updated the converter will work automatically. Each time the automatic currency updates function is run from BB2.0, any currencies without a currency code will be skipped.

The codes for standard BB2.0 roll-out currencies are:
  • US Dollar = USD
  • British Pound=GBP
  • South African Rand=ZAR
  • Australian Dollar=AUD
  • New Zealand Dollar=NZD
  • Canadian Dollar=CAD
  • Euro=EUR
  • Japanese Yen=JPY