Blesta for Windows
We’ve been hard at work on the next installment of Blesta (version 2.1) lately, which is looking to be our most feature rich update to date. One thing we’ve worked hard on is adding support for Windows machines. Finally, Windows users will get to experience what everyone else has come to love about Blesta: Simplicity, Productivity, and Power. Check back soon for more updates!
Related Tags:
New Standards for Developers
In an effort to increase future compatability with both browsers and PHP environments we’ve introduced two new standards in the Blesta 2.0 release.
Out with the old, in with the new. PHP short tags are out – That means all PHP code must be enclosed in <?php … ?> rather than <? … ?> XHTML Strict is in – All templates (.pdt files) must conform to the XHTML Strict standard (see w3c.org for more informationon on XHTML). What does this mean for me? When submitting templates, modules, gateways, or add-ons be sure to follow the above convention to ensure your contributions will be accepted into a future release of Blesta. If you don’t plan to contribute or distribute your work then of course you need not abide by these standards. Another addition to template creation is the introduction of template versioning. Each template directory will now contain a text file containing the version number (of Blesta) that the associated template files are compatible with. This will allow developers to ensure compatibility with specific versions of Blesta. The backend will still allow older templates to be selected in the Admin area, but will mark each outdated template with “(incompatible)”.
Related Tags:
GoDaddy.com and .mobi domains
I recently received an email from GoDaddy.com that I thought was hilarious. Apparently users with mobile devices can only visit .mobi domain names? Here’s the excerpt:
Imagine if customers could access your Web site even when they’re away from their computers… Having your own .MOBI domain can make that dream a reality. With .MOBI, anyone can access your site from their Web-ready cell phone or mobile device. Oh really? That’s funny because I’ve been visiting .com domains on my mobile since 2001.
Related Tags:
Upcoming version 1.4
While we crank away on version 1.4 (scheduled for release next month), I wanted to give a quick update on a couple of the big features we’ve gotten excited about. Probably the most interesting feature of 1.4 will be the dynamic integrated order system. The system we developed will allow admins to create really cool order forms in just a couple of clicks, and you’ll be able to link to these various order forms from any website using a unique URL. You’ll also be able to pass certain additional parameters on to the order form (in much the same way you can with our sample order form in version 1.3 and earlier), such as package ids, terms, coupon codes and things like that. Additionally, the order system supports drop-in form templates (a PHP class that controls certain actions during the order process) — a great feature for developers. Another big change we’ve made in 1.4 is the way in which language is handled. In 1.4 users will be able to select their own language (separate from the default language) as well as receive e-mails from Blesta in that language, a big improvement over 1.3. A couple other resources we’ve developed recently geared more towards custom developers are below. Expect to see updates to these as well in July.
Resources: Language Validator – helps translate files or update custom language among different versions. Template Listing – a complete listing of what template files are associated with which files.
Related Tags:
Writing Imports
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:
<?php
require("../inc/config.php");
require("../inc/import.class.php");
final class myImport extends AbstractImport {
public static $db;
public function __construct($sqlHost, $sqlUser, $sqlPass, $sqlDB) {
myImport::$db = new mysql($sqlHost, $sqlUser, $sqlPass, $sqlDB);
myImport::$db->linkid = mysql_connect($sqlHost, $sqlUser, $sqlPass, true);
myImport::$db->select();
}
}
$import = new myImport("localhost", "yourUser", "yourPass", "YourOldDatabase");
// We’ll fill this part in later
?>
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:
<?php
public static function importInvoices() {
// Grab all invoices and their line items
$sql = "SELECT invoices.invoice_id, invoices.client_id, invoices.invoice_date_entered, ";
$sql .= "invoices.invoice_date_due, invoices.invoice_date_paid, invoices.invoice_status, ";
$sql .= "invoices.invoice_amount_paid, invoice_line_items.line_item_id, invoice_line_items.package_id, ";
$sql .= "invoice_line_items.line_item_description, invoice_line_items.line_item_total_amount FROM invoices ";
$sql .= "LEFT JOIN invoice_line_items ON invoices.invoice_id=invoice_line_items.invoice_id ";
$sql .= "ORDER BY invoices.invoice_id ASC";
myImport::$db->query($sql);
//Build an array of all invoice data and their line items
$invoice = array();
$lineitems = array();
$lastiid = 0;
for ($i=0, $j=0; $j <= myImport::$db->numRows(); $j++) {
$data = myImport::$db->fetchAssoc();
// Is this a new invoice?
if ($lastiid != $data['invoice_id']) {
// Add the last invoice
if (count($lineitems) > 0) {
$invoice['lineitems'] = $lineitems;
// Add the Invoice
myImport::importInvoice($invoice);
$lineitems = array();
$i=0;
}
$invoice['id'] = $data['invoice_id'];
$invoice['uid'] = $data['client_id'] + UIDSTART;
$invoice['dateb'] = date('Y-m-d', $data['invoice_date_entered']);
$invoice['dated'] = date('Y-m-d', $data['invoice_date_due']);
// only mark it as paid if the status is "Paid"
$invoice['dater'] = ($data['invoice_status'] == "1" ? date('Y-m-d', $data['invoice_date_paid']) : "0000-00-00");
$invoice['previous'] = "0.00";
$invoice['applied'] = $data['invoice_amount_paid'];
$invoice['type'] = "email";
$invoice['status'] = "sent";
$invoice['notes'] = "ModernBill Import";
}
// Add this as a line item
$lineitems[$i]['id'] = $data['line_item_id'];
$lineitems[$i]['iid'] = $data['invoice_id'];
$lineitems[$i]['sid'] = $data['package_id'];
$lineitems[$i]['name'] = $data['line_item_description'];
$lineitems[$i]['price'] = $data['line_item_total_amount'];
$i++;
$lastiid = $data['invoice_id'];
}
}
?>
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 later
With:
$import->importInvoices();
Take special notice of the line:
myImport::importInvoice($invoice);
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.