Jump to content

Developing ATK modules - Part 1 (Basic)

From NusaATK
Revision as of 23:06, 11 January 2007 by bahtiar (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Introduction

If you’ve been using Achievo for a while, and you want to develop your own extensions to the application, this is the guide for you!

After reading this guide (and working through the examples), you will have an understanding of how Achievo works and how you can extend it to meet the needs of your organisation. You will find how incredibly easy it is to develop extra features for Achievo.

From the start of the project, Achievo has been developed with extension in mind. A project management suite is typically an application that never completely fits to an organisation. Each organisation has its own way of doing things. Each organisation has its own workflow. With this in mind, we created a powerful backend that allows you to completely adapt Achievo to your needs.

In this guide, we will teach you the basics of Achievo’s architecture. Later, in Part II we will dive deeper into the internals of Achievo, and teach you how you can make your extensions even more powerful and feature-rich. Finally in Part III, you will learn how to change existing Achievo functionality, without hacking the original Achievo code, and the most powerful features of the backend.

If you encounter any problems with the examples in this guide, or if you have any questions or comments, just drop me a mail (ivo@achievo.org). This is the first version of the guide, so some things may not be clear enough yet. I welcome any suggestions for improvements.

Prerequisites

In order to develop extensions for Achievo, you should have some knowledge about programming in PHP, since that is the language Achievo was written in. You don’t need to be a guru, but knowledge of the basic concepts will help you understand this guide. If you have never used PHP before, find a tutorial on the web. The official PHP site, www.php.net, is a good starting point if you want to learn more about PHP.

Experience with databases is recommended. It’s certainly not necessary to be an expert in SQL. (You will find out how little SQL you will actually have to write when developing Achievo extensions!) You should have some basic knowledge about databases however. We need to create some tables, so you need to know at least a bit of SQL. In this guide we concentrate on MySQL as a database server, but the instructions are quite similar for other databases.

We assume you have a working Achievo installation that you are able to develop on (Achievo 0.8 or newer). Don’t use your company’s production installation, or production database! Your fellow Achievo users will be very unhappy if you do that. Just create a copy of the database and a copy of the Achievo installation. (Don’t forget to update Achievo’s config.inc.php file so Achievo will use the database copy instead of the original, and don’t forget to grant correct privileges to the databaseuser.) If you installed a new database, make sure you have some initial data in it: at least one security profile and a user.

Finally, all you need is a text editor. I can recommend SciTE (www.scintilla.org/SciTE.html), which is a free source code editor which features syntax highlighting. But of course you can use the text editor you are most comfortable with.

So. If any of the above did not scare you away, we are now ready to start.

Pizza

Pizza? Yes. Pizza.

The example we are going to use in this guide is a Pizza Database. This example is chosen for a few reasons. First, it’s going to show you that you can add virtually anything to Achievo. This illustrates that Achievo is not branch-specific, and extensions for all kinds of businesses can be added. Second, it is a feature that is unlikely to ever exist in Achievo for real, so it can be used perfectly as an example application. And finally, I was hungry when I wrote this guide. If you like the guide, buy me a pizza sometime. :-)

Let me explain to you first what we’re going to develop. Suppose we own a Pizza Restaurant, and for some obscure reason, we use Achievo to track time we spent on baking pizzas.

An ideal Achievo extension for our little restaurant would be to have a database where we can store what Pizzas we serve (to be used later to generate menu cards, keep track of orders etc.)

So what do we need? A feature in Achievo where we can manage Pizzas. Management of Pizzas includes saving new pizzas, editing existing ones and deleting pizzas we no longer serve.

Data model

Once you know what you want to develop, you will need to design a data model. This means, we’re going to think about the database tables that we will need for our feature.

Let’s think of what we want to store about a pizza. A pizza of course has a name. It also should have a description, and a price. Maybe we also want to know the date that we entered the Pizza in the database. As you probably already know: in a database, a record should also have a unique id. While the name of a pizza might be unique, it’s a good idea to use a separate numeric id as primary key. (Read some database tutorials if you want to know why.)

Let’s leave it at that for now, to keep the example simple. (In Part 2, I will teach you how you can keep track of orders, how you can manage ingredients and some more advanced features, but to understand the basics, the fields I just mentioned are sufficient.)

So we should create a table in the Achievo database called ‘pizza’ with the fields we just described. This is what the table should look like:

Pizza

Fieldname Type
id integer
name string
description text
price float
entrydate date


When we create the table in the database, using reasonable values for field lengths etc., the SQL script might look like:

 CREATE TABLE pizza(
   id int(10) NOT NULL,
   name varchar(50),
   description text,
   price decimal(5,2),
   entrydate date,
   PRIMARY KEY (id)
 );

This script is for MySQL databases. If you use a different database, you might need to modify the script a bit to accommodate for some database dependent SQL statements.

After we run this script on the database, we are ready to start development.

Achievo modules

(note: still have to copy/paste/fix this from the pdfs; start with page 6)