ach ACL api authentication behind the scenes blesta blesta 3 blesta 3.0 blesta v3 cli client area design developer commentary documentation encryption gateways importing invoices licensing minphp payments plugins security sql injection staff support TOTP translator v3 version 3
WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.
Writing Imports by Cody | Developer Corner | 2008
Last week I introduced the Blesta import library, discussed why this is an important feature of Blesta and touched a little bit on how to work with the library. This week we get a little more technical and dive a bit deeper into the import library, but first a little history on the topic.
The import library has been available since version 1.0, but the documentation was only made available as of version 1.3. If you are using a version older than 1.3 some functions may or may not be available, or may have varying parameters or requirements so please be aware of this fact when consulting the import documentation.
To get started, begin by creating a new PHP document in your favorite text editor or IDE. You must save this file in a location accessible to the /inc/ directory of your Blesta installation. I recommend creating a directory called “import” in the root directory of your Blesta installation and placing this file in there. Following the above you should now have a PHP document in the path /your_blesta_install/import/. You can then copy/paste the code below to get started:
The above code snippet assumes you are importing from a MySQL database. If you are importing from another type of database or file you should replace the contents of the constructor with the appropriate code to access that data. Also note the relative path of the two included files. Be sure this is the correct path to both config.php and import.class.php of your Blesta installation. Both of these files are required in order to use the import library.
Next you’ll want to write the appropriate functions to extract the data out of your current database or file so it can be sent over to the appropriate import library function. Let’s look at an example:
The above example was taken from the ModernBill 5.2.0 import script, and demonstrates how data is formated then sent to the appropriate import library function. To call this function we replace the line:
// We’ll fill this part in laterWith:
Take special notice of the line:
This is the syntax with which we call the import library functions. The above line calls the importInvoice library function, which is used to import an invoice and its line items into Blesta.
Importing into Blesta is as easy as creating a basic PHP 5 class document that extends the AbstractImport class found in /inc/import.class.php of your Blesta installation and invoking the appropriate library function. That’s all there is to it! For a complete listing of all available import functions and their parameters/requirements please see the import documentation.
Tags: documentation | import documentation | importing
No Comments