You are here:Home » vTiger » How to Create Vtiger Module?

How to Create Vtiger Module?

Create Vtiger Module Overview

We will be creating a new module called ‘Projects’ and all the examples referred will be based on this module name.

New Module: Projects

Let us say the new ‘Projects’ module basically contains two blocks of information. The blocks in Project module are:
  • Project Information
  • Description
The Project Information block contain the following fields:</p>
  • Project Name (Text)
  • Project Type (Text)
  • Project Lead (Text)
  • Assigned To (Combo Values)
  • Start Date (Date)
  • End Date (Date)
Assumptions
  • Similarly the Description Block will contain Description field of type Textarea.
  • If the module has some related information we will be specifying the same in Related Lists.
For the Projects module, we assume the related information as ‘Contacts’ and ‘Activities’.

After creating the basic block of the new module, integrate it into vtiger CRM by updating the following files.

Part 1: Vtiger Back-end Modifications

Files to be updated while creating a new module (Projects) are:
  • schema/DatabaseSchema.xml
  • modules/Users/DefaultDataPopulator.php
  • modules/CustomView/PopulateCustomView.php
  • modules/CustomView/CustomView.php
  • include/utils/ListViewUtils.php
  • data/CRMEntity.php
  • include/utils/UserInfoUtil.php
  • index.php
  • Popup.php
  • modules/Settings/CustomFieldList.php
  • modules/Settings/AddCustomFieldToDB.php
  • data/Tracker.php
  • include/utils/CommonUtils.php
  • include/utils/utils.php
  • modules/Home/UnifiedSearch.php
  • include/ComboStrings.php

Step 1: Update DatabaseSchema.xml File

Design new tables that are to be created for the new module in the DatabaseSchema.xml file present under <vtiger Home>/schema folder along with its attributes. The new tables created in schema should also take care of the relations that will exist among the tables.

Example:
For Projects module, create four tables in the DatabaseSchema.xml file present under <vtiger Home>/schema/ folder, say – ‘vtiger_projects’, ‘vtiger_projectcontrel’, ‘vtiger_projectscf’ & ‘vtiger_projectgrouprelation’

Step 2: Update modules/Users/DefaultDataPopulator.php File

(Note: according to the Creating New Fields in Existing Modules page adding the lines to the file is only necessary if the module is going to be included w/ a new release. other wise you can just create the SQL script.”)

Insert values for the new module Projects in 3 tables namely, ‘vtiger_tab’, ‘vtiger_blocks’ and ‘vtiger_fields’

A) Insert values into vtiger_tab table

IMPORTANT NOTE:
For inserting values into vtiger_tab table use value for tabid greater than 29 as values from 1 to 29 are already occupied by other modules of vtiger CRM.

NOTE: For compatibility with other extensions you should obtain your tabid values using the SQL max() function this way if others have already used any numbers you can get unused ones: select max(tabid) from vtiger_tab

Syntax:
$this->db->query("INSERT INTO vtiger_tab VALUES (<tabid>, '<name>', <presence>, <tabsequence>, '<tablabel>', <modifiedby>, <modifiedtime>, <customized>)");

Example:

$this->db->query("INSERT INTO vtiger_tab VALUES (30,'Projects',0,4,'Projects',null,null,0,1)");

B) Insert values into vtiger_blocks table

IMPORTANT NOTE: For blockid use values greater than 83 as values from 1 to 83 are already occupied by other modules blocks.

NOTE: For compatibility with other extensions you should obtain your blockid values using the SQL max() function this way if others have already used any numbers you can get unused ones: select max(blockid) from vtiger_blocks

Syntax:
$this->db->query("INSERT INTO vtiger_blocks VALUES (<blockid>, <tabid>, '<blocklabel>', <sequence>, <show_title >, <visible>, <create_view>, <edit_view>, <detail_view>)");

Example:

$this->db->query("insert into vtiger_blocks values (84,30,'LBL_PROJECT_INFORMATION',1,0,0,0,0,0)");
$this->db->query("insert into vtiger_blocks values (85,30,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)");
$this->db->query("insert into vtiger_blocks values (86,30,'LBL_DESCRIPTION_INFORMATION',3,0,0,0,0,0)");

C)Insert values into vtiger_field table

The ‘fieldid’ column values in vtiger_field table will be generated dynamically using ‘getUniqueID’ method of PearDataBase class.

Syntax:
$this->db->query("insert into vtiger_field values (<tabid>, <fieldid>, <columnname>, <tablename>, <generatedtype>, <uitype>, <fieldname>, <fieldlabel>, <readonly>, <presence>, <selected>, <maximumlength>, <sequence>, <block>, <displaytype>, <typeofdata >, <quickcreate>, <quickcreatesequence>, <info_type>)");

For ui types see: Ui types
For data type see: INV…~ON

Example:
$this->db->query("insert into vtiger_field values (30,".$this->db->getUniqueID("vtiger_field").",'projectname','vtiger_projects',1,'2','projectname','Project Name',1,0,0,100,1,84,1,'V~M',0,1,'BAS')");
$this->db->query("insert into vtiger_field values (30,".$this->db->getUniqueID("vtiger_field").",'projecttype','vtiger_projects',1,'1','projecttype','Project Type',1,0,0,100,2,84,1,'V~O',0,1,'BAS')");
$this->db->query("insert into vtiger_field values (30,".$this->db->getUniqueID("vtiger_field").",'projectlead','vtiger_projects',1,'1','projectlead','Project Lead',1,0,0,100,3,84,1,'V~O',0,1,'BAS')");
$this->db->query("insert into vtiger_field values (30,".$this->db->getUniqueID("vtiger_field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,4,84,1,'V~M',1,null,'BAS')");
$this->db->query("insert into vtiger_field values (30,".$this->db->getUniqueID("vtiger_field").",'start_date','vtiger_projects',1,'5','start_date','Start Date',1,0,0,100,5,84,1,'D~O',1,null,'BAS')");
$this->db->query("insert into vtiger_field values (30,".$this->db->getUniqueID("vtiger_field").",'due_date','vtiger_projects',1,'5','due_date','End Date',1,0,0,100,6,84,1,'D~O~OTH~GE~start_date~Start Date',1,null,'BAS')");
$this->db->query("insert into vtiger_field values (30,".$this->db->getUniqueID("vtiger_field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,7,84,2,'T~O',1,null,'BAS')");
$this->db->query("insert into vtiger_field values (30,".$this->db->getUniqueID("vtiger_field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,8,84,2,'T~O',1,null,'BAS')");

$this->db->query("insert into vtiger_field values (30,".$this->db->getUniqueID("vtiger_field").",'description','vtiger_crmentity',1,'19','description','Description',1,0,0,100,1,86,1,'V~O',1,null,'BAS')");

For more information see: Creating New Fields in Existing Modules





Step 3: Update modules/CustomView/PopulateCustomView.php File

To get the Custom View by default for new Projects Module we need to have entry in ‘populateCustomView.php’ file

Example:

A) Insert the following array values in$customview array

Array('viewname'=>'All',
'setdefault'=>'1',
'setmetrics'=>'0',
'cvmodule'=>'Projects',
'stdfilterid'=>'',
'advfilterid'=>''),

B) Insert the following array values in$cvcolumns array

Array('vtiger_projects:projectname:projectname:Projects_Project_Name:V',
'vtiger_projects:projecttype:projecttype:Projects_Project_Type:V',
'vtiger_projects:projectlead:projectlead:Projects_Project_Lead:V',
'vtiger_projects:date_start:date_start:Projects_Start_Date:D',
'vtiger_projects:due_date:due_date:Projects_End_Date:D',
'vtiger_crmentity:smownerid:assigned_user_id:Projects_Assigned_To:V'),

Step 4: Update modules/CustomView/CustomView.php File

In CustomView.php file, put an entry for new module in $module_list array in the following format.

Format:
"<MODULE_NAME>"=>Array("<BLOCK_NAME>"=><BLOCK_ID>)

Example:

"Projects"=>Array("Information"=>84,"Description"=>86,"Custom Information"=>85);

Step 4 Notes

Didn’t find the $module_list array in the specified file (vTiger 5.0.3), after a search I found it in \modules\Reports\reports.php and upadted the array there.
I found it here in 5.0.4 as well, on line 109. Please confirm if it is the place to add the entry.
You may need to change vtiger_field, It seems like it might be stored there also. I’m not sure tho. Jonb 09:34, 11 June 2007 (PDT)

Step 5: Update include/utils/ListViewUtils.php File

Seems we need an entry in getListViewHeader() To get records in module ListView, put the listview query for new module in getListQuery() method of include/utils/ListViewUtils.php file.

Example: 
For Projects module, put the following query in getListQuery() method of include/utils/ListViewUtils.php file.

if($module == "Projects")
 {
//Query modified to sort by assigned to
     $query = "SELECT vtiger_crmentity.*,
     vtiger_projects.*
     FROM vtiger_projects
     INNER JOIN vtiger_crmentity
     ON vtiger_crmentity.crmid = vtiger_projects.projectid
     LEFT JOIN vtiger_projectsgrouprelation
     ON vtiger_projects.projectid = vtiger_projectsgrouprelation.projectid
     LEFT JOIN vtiger_groups
     ON vtiger_groups.groupname = vtiger_projectsgrouprelation.groupname
     LEFT JOIN vtiger_users
     ON vtiger_users.id = vtiger_crmentity.smownerid
     WHERE vtiger_crmentity.deleted = 0 ".$where;
if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
      {
   $sec_parameter=getListViewSecurityParameter($module);
     $query .= $sec_parameter;
      }
}

what if statement? there are lots, i am in vtiger 5.0.3 ** Search for a Case statement in vTiger 5.0.3, It worked for me. In vtiger 5.0.4, I added this data after the switch started on line 1819 you could search for “switch($module)” and add a case with the above data in it. I added the above block on line 2560.

Ver 504rc Seems we need an entry in getListViewHeader() as well

 //Added for Action - edit and delete link header in listview getListViewHeader()
 //Different solutions - A

if ($module =="Projects" AND $viewnamedesc['viewname']=="All" AND (isProjectLeader() OR isProjectAdmin() ))
  {
    $list_header[] = $mod_strings["LBL_ADD_WORKERS"];
  }

 if(isPermitted($module,"EditView","") == 'yes' || isPermitted($module,"Delete","") == 'yes')
 {
    if ($module =="Projects" AND isProjectLeader() AND !isProjectAdmin() )
    {

    } else {
    $list_header[] = $app_strings["LBL_ACTION"];
    }
  }
  //Different solutions - E

This snippit should be inserted just before:

$log->debug("Exiting getListViewHeader method ...");
 return $list_header;

Step 6: Update data/CRMEntity.php File

This file needs to updated for two reasons. one is to insert the module-group relation and another one is to update the module-group relation

Example:

In insertIntoEntityTable() method, insert the following lines of code.

Inside the if loop - if($_REQUEST['ajxaction'] != ‘DETAILVIEW’ || ($_REQUEST['ajxaction'] == ‘DETAILVIEW’ && $_REQUEST['fldName'] == ‘assigned_user_id’)) – put the following entry.

   elseif($module == 'Projects' && $table_name == 'vtiger_projects')
   {
   updateProjectGroupRelation($this->id,$groupname);
   }
   //and in the else part put the following lines
   elseif($module == 'Projects' && $table_name == 'vtiger_projects')
   {
   updateProjectGroupRelation($this->id,); 
  }

In else part,

if($insertion_mode == ‘edit’) // loop put the following lines

   elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'vtiger_projects')
   {
   insert2ProjectGroupRelation($this->id,$groupname);
   }

NOTE : For vtiger5.0.3 the file name in the step title is incorrect, there’s no method with this name. I found two files (/data/CRMEntity.php and /module/Users/Users.php) with this method with similar lines. Please some other detailed information to identify the correct file. Media:Example.ogg SAME PROBLEM in 5.0.4





Step 8: Update index.php File

For Detail View action we need to put an entry in index.php.

Example: Add the following entry:
case 'Projects':
  require_once("modules/$currentModule/Projects.php");
  $focus = new Projects();
  break;

Step 9: Update Popup.php File

Put an entry in Popup.php to get Module popup.

Example:
case 'Projects' :
      require_once("modules/$currentModule/Project.php");
      $focus = new Project();
      $smarty->assign("SINGLE_MOD",'Projects');
      if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] !='')
      $smarty->assign("RETURN_MODULE",$_REQUEST['return_module']);
      $alphabetical = AlphabeticalSearch($currentModule,'Popup','projectname','true','basic',$popuptype,"","","");
      if (isset($_REQUEST['select'])) $smarty->assign("SELECT",'enable');
break;

Step 10: Update modules/Settings/CustomFieldList.php File

To get custom field for new module, put an entry in $module_array of CustomFieldList.php

Example:
'Projects'=>'Projects',

NOTE: It feels like this part is not needed anymore (vTiger 5.0.3), please confirm. The block was not even in 5.0.4.

Ver. 504rc Not needed as it has been taken care of with function getCustomFieldSupportedModules()

In this function a query is executed (might be useful for checking your tables) which dynamically builds the array.
                select distinct vtiger_field.tabid, name
  from vtiger_field
  inner join vtiger_tab on vtiger_field.tabid=vtiger_tab.tabid
  where vtiger_field.tabid not in(9,10,16,15,8,29)

Step 11: Update modules/Settings/AddCustomFieldToDB.php File

Specify the table name to store custom field value of new module

Example:
elseif($fldmodule == 'Projects')
  {
    $tableName='vtiger_projectscf';
  }

Ver. 504rc Not sure if this is needed. If you stick to the normal ‘cf’ convention then (module name + ‘cf’) the the final elseif will take care of it. i.e. If there is a module name and its not empty then concatenate the module name to cf to build the table name


elseif($fldmodule != '')
 {
  $tableName= 'vtiger_'.strtolower($fldmodule).'cf';
 }

Needs verifying





Step 12: Update data/Tracker.php File

For tracking the modules’ record in LastViewed list we need to put an entry in Tracker.php

Example:
elseif($current_module =='Projects')
     {
     $query = 'select projectname from vtiger_projects where projectid=' .$item_id;
     $result = $this->db->query($query);
     $pb = $adb->query_result($result,0,'projectname');
     $item_summary = $pb;
      }

It feels like this part is not needed anymore (vTiger 5.0.3), please confirm. Did not see it in 5.0.4 either.

Ver. 504rc This entry is not needed as it is taken care of, dynamically in function track_view() The query looks like this, replace the question mark with the module name for testing.

       select fieldname,tablename,entityidfield
       from vtiger_entityname
       where modulename = ?";

Step 13: Update include/utils/CommonUtils.php File

For the new module you need to put an entry in the following methods
getQuickCreateModules()
getEntityName()
getGroupName()

Example:
a) Include the following in $new_label array in getQuickCreateModules()’Projects’=>’LNK_NEW_PROJECT’,

It feels like this part is not needed anymore (vTiger 5.0.3), please confirm

b) Include the following case as one of the cases in getEntityName() method
 It feels like this part is not needed anymore (vTiger 5.0.3), please confirm

case "Projects":$query = "select projectname from vtiger_projects where projectid in (".$list.")";
     $result = $adb->query($query);
     $numrows = $adb->num_rows($result);
     $project_name = array();
     for($i=0; $i < $numrows; $i++)
     {
        $project_id = $ids_list[$i];
        $project_name[$project_id] = $adb->query_result($result,$i,'projectname');
     }
     return $project_name;
break;

c)Include the following elseif part in getGroupName() method:

elseif($module == 'Projects')
     {
     $sql = "select vtiger_projectgrouprelation.groupname,vtiger_groups.groupid from vtiger_projectgrouprelation inner join vtiger_groups on                        vtiger_groups.groupname=vtiger_projectgrouprelation.groupname where vtiger_projectgrouprelation.projectid=".$id;
     }

note: in 5.0.4 the pattern for the last bit of the $sql line seems to have changed form “projectid=”.$id;” to “projectid=?’;” Please confirm. Correct, all the 504rc >> queries are parameterized and are used not with the ‘query’ method but the pquery method. eg.

$result = $adb->pquery($query, array());

The array carries all the parameters that are passed to the query, one for each question mark.

Ver. 504rc Function getQuickCreateModules() No addition needed as it is being created dynamically with the following query

        select distinct vtiger_tab.tablabel,
        vtiger_tab.name
 from vtiger_field
  inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid
        where quickcreate=0
  order by vtiger_tab.tablabel

Ver. 504rc Function getEntityName() Seems that this function has also been upgraded and believe that no additions are required. Needs confirmation
Ver. 504rc Function getGroupName() This function needs to be amended as described above but with this version you need the question mark paramater ie


     $sql = "SELECT vtiger_projectgrouprelation.groupname,
             vtiger_groups.groupid
             FROM vtiger_projectgrouprelation
                INNER JOIN vtiger_groups
                ON  vtiger_groups.groupname = vtiger_projectgrouprelation.groupname
             WHERE vtiger_projectgrouprelation.projectid=?";

Step 14: Update include/utils/utils.php File

For the new Projects module we need to put an entry in getRecordOwnerId() method Example:
elseif($module == 'Projects')
 {
   $query1="select vtiger_groups.groupid from vtiger_projectgrouprelation inner join vtiger_groups on vtiger_groups.groupname =    vtiger_projectgrouprelation.groupname where projectid=".$record;
 }
note: in 5.0.4 the pattern for the last bit of the $sql line seems to have changed form “projectid=”.$id;” to “projectid=?’;” Please confirm.

Ver 504rc Yes so in this version (504rc) the query will look like this:
      elseif($module == 'Projects')
 {
        $query1="SELECT vtiger_groups.groupid
                FROM vtiger_projectsgrouprelation
  INNER JOIN vtiger_groups ON vtiger_groups.groupname = vtiger_projectsgrouprelation.project_groupname
  WHERE projectid=?";
        }

Ver 504rc On looking at this function getRecordOwnerId() it looks as thought, if you don’t have a specific entry, then the fall through ‘else’ dynamically creates a query asshown below.

So, for 504 >> it seems that we don’t need to modify Hey, all you great vTiger developers, I can see where this is going. Soon we will just have to run a script and the new module will be installed.

Great work, to all involved in this stratagy!

 else
 {
 require_once("modules/$module/$module.php");
 $modObj = new $module();
 $query1="SELECT vtiger_groups.groupid
  FROM vtiger_".$module."grouprelation
  INNER JOIN vtiger_groups
  ON vtiger_groups.groupname = vtiger_".$module."grouprelation.groupname
                where ".$modObj->groupTable[1]."=?";
 }

Step 15: Update modules/Home/UnifiedSearch.php File

We need to put an entry in this file for search functionality

Example:
require_once('modules/Projects/Projects.php');
and
include 'Projects'=>'Projects', in $object_array;

NB Ver 504rc

This entry is not needed as it is dynamically retrieved with the query in function getSearchModules()
              SELECT distinct vtiger_field.tabid,name
              FROM vtiger_field
              inner join vtiger_tab on vtiger_tab.tabid=vtiger_field.tabid
              WHERE vtiger_tab.tabid not in (16,29)
Use this query to see what will actually be returned

Step 16: Update include/ComboStrings.php File

For the Projects Module we have a field called Project Type, which will display list of combo values about the type of project. In order to have default set of values in the field ‘Project Type’ we need to put an entry in the $combo_strings array.

Example: For Project Type field in Projects Module we can have the following initial values
'projecttype_dom' => Array('CRM'=>'CRM',
'Web Application'=>'Web Application',
'Database'=>'Database',
'Mainframe'=>'Mainframe',
'Verticals'=>'Verticals'),

Part 2: Vtiger Front-end Modifications (Creating Module-specific Files)

Add a new module folder called Projects inside the modules directory. Ensure that the module name is similar to the name specified in the ‘vtiger_tab’ table. For easier understanding we will be referring to the new module as ‘Projects’ The Files required under the new module are:
  • index.php
  • Module.php (here, Project.php)
  • ListView.php
  • EditView.php
  • DetailView.php
  • Save.php
  • CustomView.php
  • CallRelatedList.php
  • Delete.php
  • Popup.php
  • language/en_us.lang.php
  • Module.js (here, Projects.js)
Note: Step 11 mentions creation of language folder, which will have language file for internationalization purposes. Here the language is US English.</p>

Step 1: To create index.php

Create an index.php file under Projects folder and copy the contents of index.php from an existing module and change the module specific statements.

Example: Copy index.php file from Campaigns module to Projects and change the following:
include ('modules/Campaigns/ListView.php');
to
include ('modules/Projects/ListView.php');

Step 2: To create Module.php (Projects.php)

Create Module.php (here Project.php) file under Projects folder and copy the contents of Module.php from the existing module and change the module specific statements.

Example: Copy the contents of Campaign.php from Campaigns module and change the followings:
class Campaign
to
class Project

For modifying the class variables for Projects module refer the following table

TABLE
$this->log =LoggerManager::getLogger('campaign');
to
$this->log =LoggerManager::getLogger('project');
$this->column_fields = getColumnFields('Campaigns');
to
$this->column_fields = getColumnFields('Projects');
CAMPAIGN_SORT_ORDER
to
PROJECT_SORT_ORDER
CAMPAIGN_ORDER_BY
to
PROJECT_ORDER_BY

Remove the functions get_leads, get_contacts, get_opportunities and get_activities and define the related list functions for Projects module as specified in the vtiger_relatedlists table.





Step 3: To create ListView.php

Create a ListView.php file under Projects folder and copy the contents of ListView.php from an existing module and change the module specific statements.

Example: Copy the contents of ListView.php from Campaigns module and change the following:
require_once('modules/Campaigns/Campaign.php');
to
require_once('modules/Projects/Projects.php');
$focus = new Campaign();
to
$focus = new Project();
$_SESSION['CAMPAIGN_ORDER_BY'] = $order_by;
to
$_SESSION['PROJECT_ORDER_BY'] = $order_by;
$_SESSION['CAMPAIGN_SORT_ORDER'] = $sorder;
to
$_SESSION['PROJECT_SORT_ORDER'] = $sorder;

Similarly replace the existing string ‘Campaigns’ with ‘Projects’ for all other lines.





Step 4: To create EditView.php

Create EditView.php file under Projects folder and copy the contents of EditView.php from an existing module and change the module specific statements.

Example: Copy the contents of EditView.php from Campaigns module and change the following:
require_once('modules/Campaigns/Campaign.php');
to
require_once('modules/Projects/Projects.php');
$focus = new Campaign();
to
$focus = new Project();

Similarly replace the existing string ‘Campaigns’ with ‘Projects’ for all other lines.





Step 5: To Create DetailView.php

Create DetailView.php file under Projects folder and copy the contents of DetailView.php from an existing module and change the module specific statements.

Example: Copy the contents of DetailView.php from Campaigns module and change the following:
require_once('modules/Campaigns/Campaign.php');
to
require_once('modules/Projects/Projects.php');
$focus = new Campaign();
to
$focus = new Project();

Similarly replace the existing string ‘Campaigns’ with ‘Projects’ in all other lines.





Step 6: To Create Save.php

Create a ‘Save.php’ file under new ‘Projects’ folder and copy the contents of Save.php from an existing module and change the module specific statements.

Example: Copy the contents of Save.php from Campaigns module and change the following:
require_once('modules/Campaigns/Campaign.php');
to
require_once('modules/Projects/Projects.php');
$focus = new Campaign();
to
$focus = new Project();

Similarly replace the existing string ‘Campaigns’ with ‘Projects’ for all other lines.





Step 7: To create CustomView.php

Create CustomView.php file under new ‘Projects’ folder and copy the contents of CustomView.php from an existing module.You need not change anything in this file.

Example:Copy the contents of CustomView.php from Campaigns folder.

Step 8: How to Create CallRelatedList.php

Create a ‘CallRelatedList.php’ file under new ‘Projects’ folder and copy the contents of CallRelatedList.php from an existing module and change the module specific statements.

Example: Copy the contents of CallRelatedList.php from Campaigns module and change the following:
require_once('modules/Campaigns/Campaign.php');
to
require_once('modules/Projects/Projects.php');
$focus = new Campaign();
to
$focus = new Project();
Similarly do the requisite replacement of other Campaigns Text with Projects.

Step 9: How to Create Delete.php

Create a ‘Delete.php’ file under new ‘Projects’ folder and copy the contents of Delete.php from an existing module and change the module specific statements.

Example:Copy the contents of Delete.php from Campaigns module and change the following:
require_once('modules/ Campaigns/Campaign.php');
to
require_once('modules/Projects/Projects.php');
$focus = new Campaign();
to
$focus = new Project();

Step 10: How to Create Popup.php

Create ‘Popup.php’ file under ‘Projects’ folder and copy the contents of Popup.php from an existing module. not necessary to change anything in this file.

Example: Copy the contents of Popup.php from Campaigns module.

Step 11: How to Create language/en_us.lang.php

This file is required for i18n support. define $mod_strings array. this array should have entry for the following variables

Entry for blocks name as:
'LBL_PROJECT_INFORMATION'=>'Project Information';

Entry for field labels as:
'Project Name'=>'Project Name';

Step 12: How to Create Module.js (here Projects.js)

Create a Module.js (here ‘Projects.js’) file under new ‘Projects’ folder and put all module related javascript functions in this file.

Step 13: Modify Smarty/templates/EditViewHidden.tpl and Smarty/templates/DetailViewHidden.tpl

Add an {elseif} block for your new module or an OR condition to one of the existing blocks

Implementing Access Control

1. Administration – Fields Access Define global field-level access in module - Add fields – table: vtiger_def_org_field Ex.( for field with fieldid = 0 ):
INSERT INTO `vtiger`.`vtiger_def_org_field` (
 `tabid` ,
 `fieldid` ,
 `visible` ,
 `readonly`
 )
 VALUES (
 '14', '0', '0', '1'
 );

2. Define access rights to profiles ( ex. needed for edytion, without this fields are visible only to admin )

Ex.(for profile 1):

INSERT INTO `vtiger`.`vtiger_profile2field` (`profileid`, `tabid`, `fieldid`, `visible`, `readonly`) VALUES ('1', '14', '0', '0', NULL)

3. ?

Vtiger Implementing Field Customization

To be started

Implementing Reports

To be started for Xl in vtiger 4.4.2

Vtiger Adding PrimaryTab

Create module you want to insert into, open /parent_tabdata.php and add entry in array $parent_tab_info_array
9=>'Menu'

Menu must be the same as parenttab_label in database vtiger_parenttab table



And in array $parent_child_tab_rel_array add an other entry

9=>array(<moduleID>),

menu number must fit parent_tab_info_array one
<moduleID> Module ID list set in vtiger_tab
At the end of /modules/Users/DefaultDataPopulator.php add a line

$this->db->query("insert into vtiger_parenttab values (<tabid>,'<tab name>',<position>,0)");

<tabid> is unique identifier
<tab name> is php identifier for tabs
<position> order in wich you want to see it



In /include/language/*.lang.php add entry

'<tab name>'=>'language specific label',

Note: Only need to touch this script if this is going to be a new tab on the main menu. Otherwise the new field adds the new module to the existing tab specified.

Note: For 5.03 there is a file tabdata.php. New module must be added to the $tab_info_array.

Format: ‘ModuleName’=>##.

Vtiger Adding Module to Primary Tab

At the end of /modules/Users/DefaultDataPopulator.php add a line
$this->db->query("insert into vtiger_parenttabrel values(<tabid>,<moduleid>,<position>)");

<tabid> is the tab you want the item appear found in vtiger_parenttab table <moduleid> is your moduleid found in vtiger_tab table <position> define module position in menu.

Thanks to ZenGo! Web Services.

0 comments:

Post a Comment