6

私はVtiger CRMを初めて使用し、Vtiger CRMでカスタムモジュールを作成し、それに関連付けられたテーブルを最初から作成する方法を見つけるために多くのことを検索しました。Vtiger が提供するドキュメントに従うことができません。

4

2 に答える 2

1

私たちはCreate Storeモジュールを持っていますmodules/Storeにフォルダーを作成し、StoreフォルダーにStore.phpファイルを作成します

モジュール/ストア/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';
}

languages/en_us/Store.php を作成する

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

ファイル /var/www/html/Projectname/Store.php を作成し、このファイルを実行します

<?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');

?>
于 2016-07-18T08:03:19.517 に答える