vTigerCRM 6.5创建自定义模块

  1. 新建安装需要的配置文件和语言包
    新建install_modules/Mymodule/languages/en_us/Mymodule.php
<?php
$languageStrings = array(
);

$jsLanguageStrings = array(
);

新建install_modules/Mymodule/languages/zh_cn/Mymodule.php

<?php
 *************************************************************************************/
$languageStrings = array(   
    'Mymodule' => 'xxxx',
         //.....
);
$jsLanguageStrings = array(
);

新建install_modules/Mymodule/modules/Mymodule/Mymodule.php

<?php
/*+**********************************************************************************
 * The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 ************************************************************************************/

include_once 'modules/Vtiger/CRMEntity.php';

class Payments extends Vtiger_CRMEntity {
    var $table_name = 'vtiger_mymodule';
    var $table_index= 'mymoduleid';

    /**
     * Mandatory table for supporting custom fields.
     */
    var $customFieldTable = Array('vtiger_mymodule', 'mymoduleid');

    /**
     * Mandatory for Saving, Include tables related to this module.
     */
    var $tab_name = Array('vtiger_crmentity', 'vtiger_mymodule, 'vtiger_mymodulecf');

    /**
     * Mandatory for Saving, Include tablename and tablekey columnname here.
     */
    var $tab_name_index = Array(
        'vtiger_crmentity' => 'crmid',
        'vtiger_mymodule => 'mymoduleid',
        'vtiger_mymodulecf'=>'mymoduleid');

    /**
     * Mandatory for Listing (Related listview)
     */
    var $list_fields = Array (
        /* Format: Field Label => Array(tablename, columnname) */
        // tablename should not have prefix 'vtiger_'
        'Account Name' => Array('vtiger_mymodule', 'accountname'),
        'Assigned To' => Array('crmentity','smownerid')
    );
    var $list_fields_name = Array (
        /* Format: Field Label => fieldname */
        'Account Name' => 'accountname',
        'Assigned To' => 'assigned_user_id',
    );

    // Make the field link to detail view
    var $list_link_field = 'accountname';

    // For Popup listview and UI type support
    var $search_fields = Array(
        /* Format: Field Label => Array(tablename, columnname) */
        // tablename should not have prefix 'vtiger_'
        'Account Name' => Array('mymodule', 'accountname'),
        'Assigned To' => Array('vtiger_crmentity','assigned_user_id'),
    );
    var $search_fields_name = Array (
        /* Format: Field Label => fieldname */
        'Account Name' => 'accountname',
        'Assigned To' => 'assigned_user_id',
    );

    // For Popup window record selection
    var $popup_fields = Array ('accountname');

    // For Alphabetical search
    var $def_basicsearch_col = 'accountname';

    // Column value to use on detail view record text display
    var $def_detailview_recname = 'accountname';

    // Used when enabling/disabling the mandatory fields for the module.
    // Refers to vtiger_field.fieldname values.
    var $mandatory_fields = Array('accountname','assigned_user_id');

    var $default_order_by = 'accountname';
    var $default_sort_order='ASC';

    /**
    * Invoked when special actions are performed on the module.
    * @param String Module name
    * @param String Event Type
    */
    function vtlib_handler($moduleName, $eventType) {
        global $adb;
        if($eventType == 'module.postinstall') {
            // TODO Handle actions after this module is installed.
        } else if($eventType == 'module.disabled') {
            // TODO Handle actions before this module is being uninstalled.
        } else if($eventType == 'module.preuninstall') {
            // TODO Handle actions when this module is about to be deleted.
        } else if($eventType == 'module.preupdate') {
            // TODO Handle actions before this module is updated.
        } else if($eventType == 'module.postupdate') {
            // TODO Handle actions after this module is updated.
        }
    }
}

新建install_modules/Mymodule/manifest.xml

<?xml version='1.0'?>
<module>
    <exporttime>2017-11-27 11:07:36</exporttime>
    <name>Mymodule</name>
    <label>Mymodule</label>
    <parent>Support</parent>
    <version>2.0</version>
    <dependencies>
        <vtiger_version>6.0.0rc</vtiger_version>
        <vtiger_max_version>6.*</vtiger_max_version>
    </dependencies>
    <tables>
        <table>
            <name>vtiger_mymodule</name>
            <sql><![CDATA[CREATE TABLE `vtiger_mymodule` (
  `mymoduleid` int(11) NOT NULL,
  `mymodule_no` varchar(30) NOT NULL,
  `servicecontractsid` int(10) NOT NULL,
  PRIMARY KEY  (`mymoduleid`),
  CONSTRAINT `fk_1_vtiger_mymodule` FOREIGN KEY (`mymoduleid`) REFERENCES `vtiger_crmentity` (`crmid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8]]>
            </sql>
        </table>
        <table>
            <name>vtiger_mymodulecf</name>
            <sql><![CDATA[CREATE TABLE `vtiger_mymodulecf` (
  `mymoduleid` int(19) NOT NULL,
  PRIMARY KEY  (`mymoduleid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8]]>
            </sql>
        </table>
    </tables>
    <blocks>
        <block>
            <label>LBL_PAYMENTS_INFORMATION</label>
            <fields>
                <field>
                    <fieldname>mymodule_no</fieldname>
                    <uitype>4</uitype>
                    <columnname>mymodule_no</columnname>
                    <tablename>vtiger_mymodule</tablename>
                    <generatedtype>1</generatedtype>
                    <fieldlabel>Payments No</fieldlabel>
                    <readonly>1</readonly>
                    <presence>0</presence>
                    <defaultvalue></defaultvalue>
                    <sequence>2</sequence>
                    <maximumlength>100</maximumlength>
                    <typeofdata>V~O</typeofdata>
                    <quickcreate>3</quickcreate>
                    <quickcreatesequence>0</quickcreatesequence>
                    <displaytype>1</displaytype>
                    <info_type>BAS</info_type>
                    <helpinfo><![CDATA[]]>
                    </helpinfo>
                    <masseditable>0</masseditable>
                </field>
                
                <field>
                    <fieldname>servicecontractsid</fieldname>
                    <uitype>51</uitype>
                    <columnname>servicecontractsid</columnname>
                    <tablename>vtiger_mymodule</tablename>
                    <generatedtype>1</generatedtype>
                    <fieldlabel>ServiceContract Name</fieldlabel>
                    <readonly>1</readonly>
                    <presence>2</presence>
                    <defaultvalue></defaultvalue>
                    <sequence>9</sequence>
                    <maximumlength>100</maximumlength>
                    <typeofdata>V~O</typeofdata>
                    <quickcreate>1</quickcreate>
                    <quickcreatesequence></quickcreatesequence>
                    <displaytype>1</displaytype>
                    <info_type>BAS</info_type>
                    <helpinfo><![CDATA[]]>
                    </helpinfo>
                    <masseditable>1</masseditable>
                </field>
                <field>
                    <fieldname>assigned_user_id</fieldname>
                    <uitype>53</uitype>
                    <columnname>smownerid</columnname>
                    <tablename>vtiger_crmentity</tablename>
                    <generatedtype>1</generatedtype>
                    <fieldlabel>Assigned To</fieldlabel>
                    <readonly>1</readonly>
                    <presence>2</presence>
                    <defaultvalue></defaultvalue>
                    <sequence>4</sequence>
                    <maximumlength>100</maximumlength>
                    <typeofdata>V~M</typeofdata>
                    <quickcreate>0</quickcreate>
                    <quickcreatesequence>2</quickcreatesequence>
                    <displaytype>1</displaytype>
                    <info_type>BAS</info_type>
                    <helpinfo><![CDATA[]]>
                    </helpinfo>
                    <masseditable>1</masseditable>
                </field>
                <field>
                    <fieldname>createdtime</fieldname>
                    <uitype>70</uitype>
                    <columnname>createdtime</columnname>
                    <tablename>vtiger_crmentity</tablename>
                    <generatedtype>1</generatedtype>
                    <fieldlabel>Created Time</fieldlabel>
                    <readonly>1</readonly>
                    <presence>0</presence>
                    <defaultvalue></defaultvalue>
                    <sequence>14</sequence>
                    <maximumlength>100</maximumlength>
                    <typeofdata>DT~O</typeofdata>
                    <quickcreate>3</quickcreate>
                    <quickcreatesequence></quickcreatesequence>
                    <displaytype>2</displaytype>
                    <info_type>BAS</info_type>
                    <helpinfo><![CDATA[]]>
                    </helpinfo>
                    <masseditable>0</masseditable>
                </field>
                <field>
                    <fieldname>modifiedtime</fieldname>
                    <uitype>70</uitype>
                    <columnname>modifiedtime</columnname>
                    <tablename>vtiger_crmentity</tablename>
                    <generatedtype>1</generatedtype>
                    <fieldlabel>Modified Time</fieldlabel>
                    <readonly>1</readonly>
                    <presence>0</presence>
                    <defaultvalue></defaultvalue>
                    <sequence>15</sequence>
                    <maximumlength>100</maximumlength>
                    <typeofdata>DT~O</typeofdata>
                    <quickcreate>3</quickcreate>
                    <quickcreatesequence></quickcreatesequence>
                    <displaytype>2</displaytype>
                    <info_type>BAS</info_type>
                    <helpinfo><![CDATA[]]>
                    </helpinfo>
                    <masseditable>0</masseditable>
                </field>
                <field>
                    <fieldname>modifiedby</fieldname>
                    <uitype>52</uitype>
                    <columnname>modifiedby</columnname>
                    <tablename>vtiger_crmentity</tablename>
                    <generatedtype>1</generatedtype>
                    <fieldlabel>Last Modified By</fieldlabel>
                    <readonly>1</readonly>
                    <presence>0</presence>
                    <defaultvalue></defaultvalue>
                    <sequence>16</sequence>
                    <maximumlength>100</maximumlength>
                    <typeofdata>V~O</typeofdata>
                    <quickcreate>3</quickcreate>
                    <quickcreatesequence></quickcreatesequence>
                    <displaytype>3</displaytype>
                    <info_type>BAS</info_type>
                    <helpinfo><![CDATA[]]>
                    </helpinfo>
                    <masseditable>0</masseditable>
                </field>
            </fields>
        </block>
        <block>
            <label>LBL_CUSTOM_INFORMATION</label>
        </block>
        <block>
            <label>LBL_DESCRIPTION_INFORMATION</label>
            <fields>
                <field>
                    <fieldname>description</fieldname>
                    <uitype>19</uitype>
                    <columnname>description</columnname>
                    <tablename>vtiger_crmentity</tablename>
                    <generatedtype>1</generatedtype>
                    <fieldlabel>Notes</fieldlabel>
                    <readonly>1</readonly>
                    <presence>2</presence>
                    <defaultvalue></defaultvalue>
                    <sequence>1</sequence>
                    <maximumlength>100</maximumlength>
                    <typeofdata>V~O</typeofdata>
                    <quickcreate>1</quickcreate>
                    <quickcreatesequence></quickcreatesequence>
                    <displaytype>1</displaytype>
                    <info_type>BAS</info_type>
                    <helpinfo><![CDATA[]]>
                    </helpinfo>
                    <masseditable>1</masseditable>
                </field>
            </fields>
        </block>
    </blocks>
    <customviews>
        <customview>
            <viewname>All</viewname>
            <setdefault>true</setdefault>
            <setmetrics>false</setmetrics>
            <fields>
                <field>
                    <fieldname>mymoduleid</fieldname>
                    <columnindex>1</columnindex>
                </field>
                <field>
                    <fieldname>mymodule_no</fieldname>
                    <columnindex>0</columnindex>
                </field>
            </fields>
        </customview>
    </customviews>
    <sharingaccess>
        <default>public_readwritedelete</default>
    </sharingaccess>
    <actions>
        <action>
            <name><![CDATA[Export]]>
            </name>
            <status>enabled</status>
        </action>
    </actions>
    <relatedlists>
        <relatedlist>
            <function>get_related_list</function>
            <label>Account</label>
            <sequence>1</sequence>
            <presence>0</presence>
            <actions>
                <action>ADD</action>
                <action>SELECT</action>
            </actions>
            <relatedmodule>Account</relatedmodule>
        </relatedlist>
    </relatedlists>
</module>

将install_modules/Mymodule/打包为zip文件。

cd install_modules/Mymodule
zip -q -r mymodule.zip ./

2、安装
访问
http://你的项目域名/index.php?module=ModuleManager&parent=Settings&view=List&block=2&fieldid=8

按步骤进行安装

3、如有报错,则追踪代码。
比如常见的vtiger_ws_entity表中没有插入刚才安装的模块的数据。
vtiger_entityname表中也需要新增一条刚才新加模块的记录
具体的报错要跟踪代码打断点。
vitger个大坑货。文档不全,代码冗杂,无力吐槽

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 214,588评论 6 496
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,456评论 3 389
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 160,146评论 0 350
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,387评论 1 288
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,481评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,510评论 1 293
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,522评论 3 414
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,296评论 0 270
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,745评论 1 307
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,039评论 2 330
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,202评论 1 343
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,901评论 5 338
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,538评论 3 322
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,165评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,415评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,081评论 2 365
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,085评论 2 352

推荐阅读更多精彩内容

  • 1.LAMP介绍  LAM(M)P:L: linuxA: apache (httpd)M: mysql, mar...
    尛尛大尹阅读 1,047评论 0 1
  • php+mysql+apache+centos 编译安装 领导要求先保证php环境稳定,然后再去考虑其他,例如性能...
    dnaEMx阅读 2,191评论 1 16
  • 今天下沙广场格外热闹,巨大的屏幕上放映这电影,看到了猴子和尚,原来是三打白骨精,广场上的哥哥姐姐,叔叔阿姨,都聚精...
    yangwubolwg阅读 353评论 0 0
  • 在当地一家工厂打工多年,平日里摸爬滚打,混沌又潇洒,简单的苦涩。 厂子大点了,裙带关系就很重要...
    风流墨客阅读 184评论 0 0
  • 姐夫是一个厨师,最开始的时候也是一个餐厅打下手的,姐夫在那家餐厅到现在待了差不多10年,也看着公司由最初的...
    小惠_f2b8阅读 237评论 0 1