Creating a custom module in Vtiger CRM from scratch using a table

I am new to Vtiger CRM and I searched a lot to learn how to create a custom module in Vtiger CRM with its associated table from scratch. I can not follow the documentation provided by Vtiger.

+6
source share
3 answers

Refer to this URL to create a new module and fields.

https://wiki.vtiger.com/index.php/CreatingEntityModule

Or if you are having problems, follow the instructions.

do it first.

First, create a new folder (module name without space) in the modules and copy the files from the vtlib / ModuleDir / 5.4.0 file to the folder created in the / newmodule modules

Change the name ModuleFile.js, ModuleFile.php, ModuleFileAjax.php with your module name (no space).

Keep in mind that when changing the name of ModuleFileAjax.php, simply replace ModuleFile with the name of the module.

Go to modulename.php to change the class name, $ table_name (change 6values), $ table_index (change 4values).

Create a new file with any name. Paste the code below to add the fields as well as the module.

<?php // Turn on debugging level $Vtiger_Utils_Log = true; include_once('vtlib/Vtiger/Menu.php'); include_once('vtlib/Vtiger/Module.php'); $module = new Vtiger_Module(); $module->name = 'Store';//(No space in module name) $module->save(); $module->initTables(); $module->initWebservice(); $menu = Vtiger_Menu::getInstance('Support'); $menu->addModule($module); $block1 = new Vtiger_Block(); $block1->label = 'Organization Information'; $module->addBlock($block1); //to create a new block $field0 = new Vtiger_Field(); $field0->name = 'organization_name'; $field0->label = 'Organization Name'; $field0->table = $module->basetable; $field0->column = 'organization_name'; $field0->columntype = 'VARCHAR(100)'; $field0->uitype = 2; $field0->typeofdata = 'V~M'; $module->setEntityIdentifier($field0); //to insert values in entity folder $block1->addField($field0); //to add field in block $field1 = new Vtiger_Field(); $field1->name = 'store_id_auto'; $field1->label = 'Store ID'; $field1->table = $module->basetable; $field1->column = 'store_id_auto'; $field1->columntype = 'VARCHAR(100)'; $field1->uitype = 4; $field1->typeofdata = 'V~O'; $block1->addField($field1); //Do not change any value for filed2. $field2 = new Vtiger_Field(); $field2->name = 'assigned_user_id'; $field2->label = 'Assigned To'; $field2->table = 'vtiger_crmentity'; $field2->column = 'smownerid'; $field2->columntype = 'int(19)'; $field2->uitype = 53; $field2->typeofdata = 'V~M'; $block1->addField($field2); $filter1 = new Vtiger_Filter(); $filter1->name = 'All'; $filter1->isdefault = true; $module->addFilter($filter1); // Add fields to the filter created $filter1->addField($field0, 1); $filter1->addField($field1, 2); $filter1->addField($field2, 3); /** Set sharing access of this module */ $module->setDefaultSharing('Private'); /** Enable and Disable available tools */ $module->enableTools(Array('Import', 'Export')); $module->disableTools('Merge'); ?> 
+14
source

I found the answer to the question. Here is an example of creating a Payslip module in Vtiger.

http://www.codeigniter.in/blog/post/creating-payslip-module-in-vtiger-crm-5.4.0

+2
source

We have a module Create Store Create a folder in the modules / Store, and also create a Store.php file in the "Store" folder

modules / store / Store.php

 include_once 'modules/Vtiger/CRMEntity.php'; class Store extends Vtiger_CRMEntity { var $table_name = 'vtiger_store'; var $table_index= 'storeid'; var $customFieldTable = Array('vtiger_storecf', 'storeid'); var $tab_name = Array('vtiger_crmentity', 'vtiger_store', 'vtiger_storecf'); var $tab_name_index = Array( 'vtiger_crmentity' => 'crmid', 'vtiger_store' => 'storeid', 'vtiger_storecf'=>'storeid'); var $list_fields = Array ( /* Format: Field Label => Array(tablename, columnname) */ // tablename should not have prefix 'vtiger_' 'Organization Name' => Array('store', 'organization_name'), 'Assigned To' => Array('crmentity','smownerid') ); var $list_fields_name = Array ( /* Format: Field Label => fieldname */ 'Organization Name' => 'organization_name', 'Assigned To' => 'assigned_user_id', ); // Make the field link to detail view var $list_link_field = 'organization_name'; // For Popup listview and UI type support var $search_fields = Array( /* Format: Field Label => Array(tablename, columnname) */ // tablename should not have prefix 'vtiger_' 'Organization Name' => Array('store', 'organization_name'), 'Assigned To' => Array('vtiger_crmentity','assigned_user_id'), ); var $search_fields_name = Array ( /* Format: Field Label => fieldname */ 'Organization Name' => 'organization_name', 'Assigned To' => 'assigned_user_id', ); // For Popup window record selection var $popup_fields = Array ('organization_name'); // For Alphabetical search var $def_basicsearch_col = 'organization_name'; // Column value to use on detail view record text display var $def_detailview_recname = 'organization_name'; // Used when enabling/disabling the mandatory fields for the module. // Refers to vtiger_field.fieldname values. var $mandatory_fields = Array('organization_name','assigned_user_id'); var $default_order_by = 'organization_name'; var $default_sort_order='ASC'; } 

Creating Languages โ€‹โ€‹/ en _us / Store.php

 <?php $languageStrings = array( 'SINGLE_Store'=>'Store' ); ?> 

Create the file /var/www/html/Projectname/Store.php and run this file

 <?php // Turn on debugging level $Vtiger_Utils_Log = true; include_once('vtlib/Vtiger/Menu.php'); include_once('vtlib/Vtiger/Module.php'); $module = new Vtiger_Module(); $module->name = 'Store';//(No space in module name) $module->save(); $module->initTables(); $module->initWebservice(); $menu = Vtiger_Menu::getInstance('Support'); $menu->addModule($module); $block1 = new Vtiger_Block(); $block1->label = 'Organization Information'; $module->addBlock($block1); //to create a new block $field0 = new Vtiger_Field(); $field0->name = 'organization_name'; $field0->label = 'Organization Name'; $field0->table = $module->basetable; $field0->column = 'organization_name'; $field0->columntype = 'VARCHAR(100)'; $field0->uitype = 2; $field0->typeofdata = 'V~M'; $module->setEntityIdentifier($field0); //to insert values in entity folder $block1->addField($field0); //to add field in block $field1 = new Vtiger_Field(); $field1->name = 'store_id_auto'; $field1->label = 'Store ID'; $field1->table = $module->basetable; $field1->column = 'store_id_auto'; $field1->columntype = 'VARCHAR(100)'; $field1->uitype = 4; $field1->typeofdata = 'V~O'; $block1->addField($field1); //Do not change any value for filed2. $field2 = new Vtiger_Field(); $field2->name = 'assigned_user_id'; $field2->label = 'Assigned To'; $field2->table = 'vtiger_crmentity'; $field2->column = 'smownerid'; $field2->columntype = 'int(19)'; $field2->uitype = 53; $field2->typeofdata = 'V~M'; $block1->addField($field2); $field3 = new Vtiger_Field(); $field3->name = 'CreatedTime'; $field3->label= 'Created Time'; $field3->table = 'vtiger_crmentity'; $field3->column = 'createdtime'; $field3->uitype = 70; $field3->typeofdata = 'T~O'; $field3->displaytype= 2; $block->addField($field3); $field4 = new Vtiger_Field(); $field4->name = 'ModifiedTime'; $field4->label= 'Modified Time'; $field4->table = 'vtiger_crmentity'; $field4->column = 'modifiedtime'; $field4->uitype = 70; $field4->typeofdata = 'T~O'; $field4->displaytype= 2; $block->addField($field4); $filter1 = new Vtiger_Filter(); $filter1->name = 'All'; $filter1->isdefault = true; $module->addFilter($filter1); // Add fields to the filter created $filter1->addField($field0, 1); $filter1->addField($field1, 2); $filter1->addField($field2, 3); /** Set sharing access of this module */ $module->setDefaultSharing('Private'); /** Enable and Disable available tools */ $module->enableTools(Array('Import', 'Export')); $module->disableTools('Merge'); ?> 
+1
source

Source: https://habr.com/ru/post/957970/


All Articles