Creating a custom VtigerCRM Module

Step 1.
Download the module creation script from the VtigerCRM or copy it from below

name = 'Phpqa';

// Initialize all the tables required
// Initialize Webservice

// Add the module to the Menu (entry point from UI). Will display under Tools menu
$menu = Vtiger_Menu::getInstance('Tools');

// Add the basic module block
$block1 = new Vtiger_Block();
$block1->label = 'LBL_PHPQA_INFORMATION';

// Add custom block (required to support Custom Fields)
$block2 = new Vtiger_Block();
$block2->label = 'LBL_CUSTOM_INFORMATION';

/** Create required fields and add to the block */
$field1 = new Vtiger_Field();
$field1->name = 'Sales';
$field1->label = 'Sales';
$field1->table = $module->basetable;
$field1->typeofdata = 'V~O';
$block1->addField($field1); /** Creates the field and adds to block */

// Set at-least one field to identifier of module record

$field2 = new Vtiger_Field();
$field2->name = 'Name';
$field2->label = 'Name';
$field2->typeofdata = 'V~O';// Varchar~Optional
$block1->addField($field2); /** table and column are automatically set */

$field3 = new Vtiger_Field();
$field3->name = 'InvoiceType';
$field3->label= 'Invoice Type';
$field3->typeofdata = 'V~O'; // Date~Mandatory
$block1->addField($field3);  /** table, column, label, set to default values */

$field4 = new Vtiger_Field();
$field4->name = 'InvoiceID';
$field4->label= 'Invoice ID';
$field4->typeofdata = 'V~O';

/** END */

// Create default custom filter (mandatory)
$filter1 = new Vtiger_Filter();
$filter1->name = 'All';
$filter1->isdefault = true;

// Add fields to the filter created
$filter1->addField($field1)->addField($field2, 1)->addField($field5, 2);

// Create one more filter
$filter2 = new Vtiger_Filter();
$filter2->name = 'All2';

// Add fields to the filter
$filter2->addField($field2, 1);

// Add rule to the filter field
$filter2->addRule($field1, 'CONTAINS', 'Test');

/** Associate other modules to this module */
//$module->setRelatedList(Vtiger_Module::getInstance('Accounts'), 'Accounts', Array('ADD','SELECT'));

/** Set sharing access of this module */

/** Enable and Disable available tools */
$module->enableTools(Array('Import', 'Export'));


Step 2
Save it in your vigercrm root folder. and run the script .
Step 3
Copy the desired version of sample vtigercrm module from the vtlib/ModuleDir and paste it into the /modules directory
Step 4
Rename the folder name into the desired name you have given in the module creation script. (Phpqa)
Step 5
Rename the ModuleFile.php, ModuleFileAjax.php, ModuleFile.js to your module name. Here the ModuleFile indicates your module name. So names are like Phpqa.php, PhpqaAjax.php and PhpqaFile.js
Step 6
Open the Phpqa.php and rename the class name into Phpqa. Change the all modulename occurance into your custom module name
Change the following
var $table_name = 'vtiger_phpqa';
var $table_index= 'phpqaid';

var $customFieldTable = Array('vtiger_phpqacf', 'phpqaid');

var $tab_name = Array('vtiger_crmentity', 'vtiger_phpqa', 'vtiger_phpqacf');

var $tab_name_index = Array(
 'vtiger_crmentity' => 'crmid',
 'vtiger_phpqa'   => 'phpqaid',
 'vtiger_phpqacf' => 'phpqaid');

Also the change the other listed variables in the page as per our need.
Step 7
Change the Language file variable based on the module name. Its located in /language folder of the module .

'Phpqa' => 'Phpqa',
'LBL_CUSTOM_INFORMATION' => 'Custom Information',
'LBL_PHPQABLOCK_INFORMATION' => 'Phpqa Block Information'


Step 8
You can see your module is listed in the vtigercrm admin console. Settings > Module Manager page under the custom module. Here we can disable/enable and export your module for future use. if you click on the export buttom, a Zip file will be downloaded as an installtion file. and we are reuse it in other vtiger applications.