Plugin Development

iBilling Plugin / App Development

Welcome to Training for iBilling developers. Here you’ll find sets of lessons that describe how to accomplish a specific task with code samples you can re-use in your app. This is the perfect starting point for creating apps that run on iBilling. View these guidelines as a gentle introduction to build your first app—including the tools you need and the major concepts and best practices that will ease your path.

The first three modules end with a tutorial, where you’ll implement what you’ve learned. At the end of the last tutorial, you’ll have created a simple note taking app.

Get the Tools

Before you start developing great apps for iBilling, set up a development environment to work in and make sure you have the right tools.

To develop iBilling apps, you need:

– A Code Editor – Use your favorite code editor. Generally I use PHPStorm. You may use any code editor, for example Sublime Text, Notepad ++ etc.

– A Local Server installed in your computer. For Example – XAMPP, WAMP for Windows and MAMP for Mac

– Latest Version of iBilling

Building Your First App

In this tutorial, I will show you how to build your first iBilling app. You’ll also learn some fundamentals of app design, including how to build a simple user interface and handle user input.

Set Up Your Environment:
Before you start this tutorial, be sure you have your development environment set up.

Download Local Server-
For Windows – XAMPP
For MAC MAMP

Ignore this, if you already have local server installed

2) Install iBilling –
Download Latest Version of iBilling & install it in http://localhost/ibilling

I recommend to install with the same name so that it can be accessible with above url & you can easily follow my instructions to learn.

This tutorial format to create a iBilling app that teaches you some fundamental concepts about iBilling development, so it’s important that you follow each step.

Getting Started

1) Create App Directory: Create a folder named “notes” inside plugins directory-
Plugins directory is located here – <ibilling_root>/application/plugins

plugin-directory

2) Create Compulsory files inside App Directory: In iBilling every app needs one compulsory file –manifest.php
Create a file inside notes folder named – manifest.php
Now add the following codes here-

3) You just Created a Plugin/ App: Now login to your iBilling & Go to Plugins Menu. You will see your plugin that you just created in the list-

4) In the list you will see two buttons – Install & Delete. So what will happen if you click install button. Well, let’s write it programmatically, we will say through our codes, what will happen.

Please do not click Install Button Now, it’s too early :)

Create a file named “install.php” inside notes directory. This file will be called when user click the install button & we will write our installer with this file. Now open the “install.php” file and write following codes-

If you are familiar with phpMyAdmin, look into this picture-

creating_plugin_table

 

I am describing the codes here-

In Line 1 we wrote- $t = new Schema(‘app_notes’);
With this code we told the iBilling that we want to create a table named app_notes

In Line 2- $t->add(‘title’);
We want to add a column named title where we will store the Title of the Note

In Line 3- $t->add(‘contents’); To add column note where we will store note contents

In Line 4- $t->save();

With this method save(), the system will build the table inside your database.

Create another compulsory file named *.plugin.php

Create a file ibml.plugin.php inside notes directory. And add the following codes-

add_menu_admin($name,$link=’#’,$c=”,$icon=’leaf’,$position=’5′,$submenu=array()) is a function. I am describing the parameters –
$name = Name of the Menu (e.g. Notes)
$link = The link for this menu item
$c = Enter the plugin directory name here, in that case it will be – notes
$icon = The icon name [You can use font-awesome icon name here]
Ignore other parameters for now.

Check this Picture below, to know How this function works-

 

creating_plugin_menu

Now, Login to your iBilling and Navigate to Settings -> Plugins. Click the “Install” Button for the Notes Plugin.
The system will install the notes plugin & you will find a Newly created menu Notes –

notes-app-menu

Click on the newly Created Menu – “Notes”
It does nothing, a blank page, right ?
Okay, let’s write some codes-
Create a file inside notes directory named – init.php and add the following codes-

 

Create View Interface:

Create a folder named ‘views’ inside notes directory.

Create a file ‘list.tpl‘ Inside views directory.

So, The Folder Structure will look like this-

 

plugin_folder_structure

Add following Contents in list.tpl

Now Create Another file named add.tpl inside views directory & add the following contents-

Now Create Another file named edit.tpl inside views directory & add the following contents-

Your Note Plugin is Ready !

You can write the uninstaller, so that if Uninstall Button Click, it will roll back the database (e.g. notes table will be dropped)

Create a file inside notes directory named uninstall.php with following codes-

Need help ? Post in the Forums- http://www.softhash.com/community/

Download this Plugin