Friday, January 13, 2012

Draggable and Resizable Objects in BlueBox2.0

This week I want to share a new LGPL library we have used in a few BlueBox2.0 projects, by Angus Turnbull, TwinHelix Designs, http://www.twinhelix.com.

The use of this new function is to allow certain elements in your pages to be draggable and resizeable.

The small javascript library/function is called dragresize() and we have formalised it into BlueBox2.0 as follows:

To load it in your page, simply call the function inline with one of your print/resp statements as follows:

resp("
           " . dragresize("drag_me",0,0,0,0,2000,2000) . "
            <div class=drsElement style=\"position:absolute;top:200;left:200;background:silver;width:400;height:400;\">
                <div style=\"overflow:auto;width:100%;height:100%;\">
                <img src=http://www.blueboxonline.com/portal/img/2011/banners/jpegs/Specific-Product-Focused.jpg>
                </div>
            </div>
            ");

The important bits here are:
  • dragresize("drag_me",0,0,0,0,2000,2000) where the 'drag_me' is a future-placeholder for scalability when this function will work for specified objects on the page, currently no used, but required. The numbers following that are max-width, max-height, left-threshold, top-threshold, right-threshold, and bottom-threshold.
  •  and, all elements which you want resizable must be set with class=drsElement (for now, until we get the function to isolate to certain objects.)
  • and finally, the elements which are resizable must be set with style-position of absolute or relative.

This example prints a floating box to the screen which, when clicked renders eight handles which allow you to resize the box, revealing less or more of the background image.

Currently our implementation of dragresize is for resizing only, and will only allow you to specify one set of parameters for the page. However, you can set an unlimited number of elements as class=drsElement, which will make them all resizeable.


Saturday, January 7, 2012

BlueBox2.0 Surveys

Tucked away in the Publishing->WebTools menu is our original BlueBox Surveys module. This has recently been upgraded as follows:
  • Link a surveys to any data in the BlueBox2.0 System:
    Using a new feature in the survey header data, you can specify whether to link it to another class/module in BB2.0. This allows you to capture surveys or data segments against other data elements in the system, ie: you could capture a customer satisfaction survey against certain sales orders or even against each customer file in the system.
  • Create a survey and publish the direct-link using new encrypted survey id
    Surveys are now referred to via their long-id (a 32 character encrypted ID). This means that you can publish direct links to various surveys on your website or in emails and have members of the public submit data directly into the system securely.
  • Control survey look and feel via CSS
    A new CSS template which determines that look of each element of the survey can be accessed by editing survey_css.template in the database templates module.
  • Survey dashboard
    The survey dashboard allows you quick access to survey results as well as direct links to each survey. You can also add/edit survey data via this dashboard.
  • Survey reporting
    You can report on survey data in detailed or summary view off the new survey dashboard.

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

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.