我創造的好vtiger一個定製模塊vtigerCRM的自定義模塊,這是Vehicles.php
文件中的Modules/Vehicles
:不節能
<?php
include_once 'modules/Vtiger/CRMEntity.php';
class Vehicles extends Vtiger_CRMEntity {
var $table_name = 'vtiger_vehicles';
var $table_index= 'vehiclesid';
var $customFieldTable = Array('vtiger_vehiclescf', 'vehiclesid');
var $tab_name = Array('vtiger_crmentity', 'vtiger_vehicles', 'vtiger_vehiclescf');
var $tab_name_index = Array(
'vtiger_crmentity' => 'crmid',
'vtiger_vehicles' => 'vehiclesid',
'vtiger_vehiclescf'=>'vehiclesid');
var $list_fields = Array (
/* Format: Field Label => Array(tablename, columnname) */
// tablename should not have prefix 'vtiger_'
'Reg No' => Array('vehicles', 'reg_no'),
'Assigned To' => Array('crmentity','smownerid')
);
var $list_fields_name = Array (
/* Format: Field Label => fieldname */
'Reg No' => 'reg_no',
'Assigned To' => 'assigned_user_id',
);
// Make the field link to detail view
var $list_link_field = 'reg_no';
// For Popup listview and UI type support
var $search_fields = Array(
/* Format: Field Label => Array(tablename, columnname) */
// tablename should not have prefix 'vtiger_'
'Reg No' => Array('vehicles', 'reg_no'),
'Assigned To' => Array('vtiger_crmentity','assigned_user_id'),
);
var $search_fields_name = Array (
/* Format: Field Label => fieldname */
'Reg No' => 'reg_no',
'Assigned To' => 'assigned_user_id',
);
// For Popup window record selection
var $popup_fields = Array ('reg_no');
// For Alphabetical search
var $def_basicsearch_col = 'reg_no';
// Column value to use on detail view record text display
var $def_detailview_recname = 'reg_no';
// Used when enabling/disabling the mandatory fields for the module.
// Refers to vtiger_field.fieldname values.
var $mandatory_fields = Array('reg_no','assigned_user_id');
var $default_order_by = 'reg_no';
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.
}
}
}
文件創建的模塊是:
<?php
include_once('vtlib/Vtiger/Module.php');
/**
*Init instance
*/
$Vtiger_Utils_Log = true;
$MODULENAME = 'Vehicles';
$moduleInstance = Vtiger_Module::getInstance($MODULENAME);
if ($moduleInstance || file_exists('modules/'.$MODULENAME)) {
$moduleInstance->delete();
} else {
$moduleInstance = new Vtiger_Module();
$moduleInstance->name = $MODULENAME;
$moduleInstance->parent= 'Inventory';
$moduleInstance->save();
// Schema Setup
$moduleInstance->initTables();
//Bring on the blocks
$block = new Vtiger_Block();
$block->label = 'LBL_'. strtoupper($moduleInstance->name) . '_INFORMATION';
$table = "vtiger_".strtolower($moduleInstance->name);
$moduleInstance->addBlock($block);
$blockcf = new Vtiger_Block();
$blockcf->label = 'LBL_CUSTOM_INFORMATION';
$moduleInstance->addBlock($blockcf);
$field1 = new Vtiger_Field();
$field1->name = 'reg_no';
$field1->label= 'Registration Number';
$field1->uitype= 2;
$field1->table = $table;
$field1->column = $field1->name;
$field1->columntype = 'VARCHAR(255)';
$field1->typeofdata = 'V~M';
$block->addField($field1);
$moduleInstance->setEntityIdentifier($field1);
$field2 = new Vtiger_Field();
$field2->name = 'chas_no';
$field2->label= 'Chassis Number';
$field2->uitype= 2;
$field2->column = $field1->name;
$field2->columntype = 'VARCHAR(255)';
$field2->typeofdata = 'V~O';
$field2->table = $table;
$block->addField($field2);
$field3 = new Vtiger_Field();
$field3->name= 'cust_name';
$field3->label = 'Customer';
$field3->uitype = 10;
$field3->column = $field3->name;
$field3->columntype ='VARCHAR(255)';
$field3->typeofdata ='V~M';
$field3->table = $table;
$block->addField($field3);
$field3->setRelatedModules(Array('Contacts'));
// Recommended common fields every Entity module should have (linked to core table)
$mfield1 = new Vtiger_Field();
$mfield1->name = 'assigned_user_id';
$mfield1->label = 'Assigned To';
$mfield1->table = 'vtiger_crmentity';
$mfield1->column = 'smownerid';
$mfield1->uitype = 53;
$mfield1->typeofdata = 'V~M';
$block->addField($mfield1);
$mfield2 = new Vtiger_Field();
$mfield2->name = 'CreatedTime';
$mfield2->label= 'Created Time';
$mfield2->table = 'vtiger_crmentity';
$mfield2->column = 'createdtime';
$mfield2->uitype = 70;
$mfield2->typeofdata = 'T~O';
$mfield2->displaytype= 2;
$block->addField($mfield2);
$mfield3 = new Vtiger_Field();
$mfield3->name = 'ModifiedTime';
$mfield3->label= 'Modified Time';
$mfield3->table = 'vtiger_crmentity';
$mfield3->column = 'modifiedtime';
$mfield3->uitype = 70;
$mfield3->typeofdata = 'T~O';
$mfield3->displaytype= 2;
$block->addField($mfield3);
// Filter Setup
$filter1 = new Vtiger_Filter();
$filter1->name = 'All';
$filter1->isdefault = true;
$moduleInstance->addFilter($filter1);
$filter1->addField($field1)->addField($field2, 1)->addField($field3, 2)->addField($mfield1, 3);
// Sharing Access Setup
$moduleInstance->setDefaultSharing();
// Webservice Setup
$moduleInstance->initWebservice();
}
一切運行井:
創建模塊車輛...開始
個初始化模塊權限... DONE
更新tabdata文件...完成
設置共享訪問選項...完成
添加到菜單清單...完成
更新parent_tabdata文件...開始
更新parent_tabdata文件...完成
創建模塊,車輛... d ONE
創建塊LBL_VEHICLES_INFORMATION ...完成
爲LBL_VEHICLES_INFORMATION模塊語言的入門...檢查
創建塊LBL_CUSTOM_INFORMATION ...完成
爲LBL_CUSTOM_INFORMATION模塊語言的入門...檢查
創建字段reg_no ...完成
模塊語言m apping的註冊號...檢查
設置實體標識符...完成
創建現場chas_no ...完成
模塊語言映射底盤號碼...檢查
創建場cust_name ... DONE
客戶的模塊語言映射...檢查
設置cust_name關係與聯繫人...完成
創建現場assigned_user_id ...完成
模塊語言映射分配給...檢查
創建現場CreatedTime ...完成
模塊語言映射創建時間...檢查
創建字段ModifiedTime ...做了修改時間
模塊語言映射...檢查
創建過濾所有... DONE
設置過濾器全部以狀態[0] ...完成
添加reg_no所有過濾器...完成
添加chas_no所有過濾器...完成
添加CUST_NAME所有過濾器...完成
添加assigned_user_id所有過濾器...完成
重新計算共享規則...完成
初始化web服務支持...完成
模塊運行良好,但不能添加記錄,但顯示這節省後:
我錯過了什麼,如何解決錯誤?