我希望你们都做得很好。我已经创建了一个自定义模块,使用了这个script.we,运行了这个脚本,在根folder.All字段中工作得很好,列表视图也很完美。
include_once 'vtlib/Vtiger/Module.php';
include_once 'vtlib/Vtiger/Package.php';
include_once‘包括/main/WebUI.php’;
include_once 'include/Webservices/Utils.php';
$Vtiger_Utils_Log =真;
$MODULENAME =‘膝上型’;
$moduleInstance = Vtiger_Module::getInstance($MODULENAME);
if ($moduleInstance连体/file_exists(‘模块/’.$MODULENAME)){
回显“模块已经出现-选择不同的名称。”
}否则{
$moduleInstance =新的Vtiger_Module();
$moduleInstance->name = $MODULENAME;
$moduleInstance->parent= 'Tools';
$moduleInstance->save();
//架构设置
$moduleInstance->initTables();
//字段设置
$block =新的Vtiger_Block();
$block->label = 'LBL_'.strtoupper($moduleInstance->name)。“_信息”;
$moduleInstance->addBlock($block);
$blockcf =新的Vtiger_Block();
$blockcf->label =‘LBL_定制_INFORMATION’;
$moduleInstance->addBlock($blockcf);
// Text Area1 Item_Name
$itemName =新的Vtiger_Field();
$itemName->name = 'itemname';$itemName->label= 'Item Name';$itemName->uitype= 1;$itemName->column = $itemName->name;$itemName->columntype = 'VARCHAR(100)';$itemName->typeofdata = 'V~M';$block->addField($itemName); // Text Area2 Item_Deatils$itemdeatils = new Vtiger_Field();$itemdeatils->name = 'itemdeatils';$itemdeatils->label= 'Item Deatils';$itemdeatils->uitype= 1;$itemdeatils->column = $itemdeatils->name;$itemdeatils->columntype = 'VARCHAR(100)';$itemdeatils->typeofdata = 'V~O';$block->addField($itemdeatils);$moduleInstance->setEntityIdentifier($itemdeatils);// Text Area3 Item_Company.
$companyname = new Vtiger_Field();$companyname->name = 'companyname';$companyname->label= 'Company Name.';$companyname->uitype= 15;$companyname->column = $companyname->name;$companyname->columntype = 'VARCHAR(100)';$companyname->typeofdata = 'V~O';$block->addField($companyname); $companyname->setPicklistValues( Array ('Sumsung','HP','Dell', 'Lenovo','Apple') ); $description = new Vtiger_Field();$description->name = 'description';$description->label= 'Description';$description->uitype= 19;$description->column = 'description';$description->table = 'vtiger_crmentity';$blockcf->addField($description);// 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 = 'DT~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 = 'DT~O';$mfield3->displaytype= 2;$block->addField($mfield3);/* NOTE: Vtiger 7.1.0 onwards */$mfield4 = new Vtiger_Field();$mfield4->name = 'source';$mfield4->label = 'Source';$mfield4->table = 'vtiger_crmentity';$mfield4->displaytype = 2; // to disable field in Edit View$mfield4->quickcreate = 3;$mfield4->masseditable = 0;$block->addField($mfield4);$mfield5 = new Vtiger_Field();$mfield5->name = 'starred';$mfield5->label = 'starred';$mfield5->table = 'vtiger_crmentity_user_field';$mfield5->displaytype = 6;$mfield5->uitype = 56;$mfield5->typeofdata = 'C~O';$mfield5->quickcreate = 3;$mfield5->masseditable = 0;$block->addField($mfield5);$mfield6 = new Vtiger_Field();$mfield6->name = 'tags';$mfield6->label = 'tags';$mfield6->displaytype = 6;$mfield6->columntype = 'VARCHAR(1)';$mfield6->quickcreate = 3;$mfield6->masseditable = 0;$block->addField($mfield6);/* End 7.1.0 */// Filter Setup$filter1 = new Vtiger_Filter();$filter1->name = 'All';$filter1->isdefault = true;$moduleInstance->addFilter($filter1);$filter1->addField($itemName);$filter1->addField($itemdeatils, 1);$filter1->addField($companyname, 2);$filter1->addField($mfield1, 3);// Sharing Access Setup$moduleInstance->setDefaultSharing('Private');// Webservice Setup$moduleInstance->initWebservice();$targetpath =‘模块/’。$moduleInstance->name;
if (! is_file($targetpath)) { mkdir($targetpath);$templatepath = 'vtlib/ModuleDir/6.0.0';$moduleFileContents = file_get_contents($templatepath .)'/ModuleName.php');
$replacevars = array('ModuleName' => $moduleInstance->name,'<modulename>' => strtolower($moduleInstance->name),'<entityfieldlabel>' => $field1->label,'<entitycolumn>' => $field1->column,'<entityfieldname>' => $field1->name); foreach ($replacevars as $key => $value) {$moduleFileContents = str_replace($key, $value, $moduleFileContents); } file_put_contents ($targetpath . '/' . $moduleInstance->name . '.php',$moduleFileContents); } if (! file_exists('languages/en_us/ModuleName.php')) { $ModuleLanguageContents = file_get_contents ($templatepath . '/languages/en_us /ModuleName.php'); $replaceparams = array('Module Name' => $moduleInstance->name,'Custom' => $moduleInstance->name,'ModuleBlock' => $moduleInstance->name,'ModuleFieldLabel Text' => $field1->label ); foreach ($replaceparams as $key => $value) { $ModuleLanguageContents = str_replace($key, $value, $ModuleLanguageContents);}
$languagePath = 'languages/en_us';
file_put_contents
($languagePath . '/' . $moduleInstance->name . '.php',$ModuleLanguageContents); } }Settings_MenuEditor_Module_Model::addModuleToApp ($moduleInstance->name, $moduleInstance->parent); ?> ```如何使用PHP脚本(Vtlib函数)从我的CRM vtiger 7导出和导入自定义模块作为包,请帮助我。
发布于 2022-07-04 06:44:27
我被困在如何使用VTlib库在Vtiger中创建自定义模块上。您共享的代码非常适合在vtiger中创建自定义模块。
要在vtiger中导出自定义模块,需要运行以下代码-
require_once('vtlib/Vtiger/Package.php');
require_once('vtlib/Vtiger/Module.php');
$package = new Vtiger_Package();
$package->export(
Vtiger_Module::getInstance('Payslip'),
'test/vtlib',
'Payslip-Export.zip',
true
);不要忘记更改模块名
https://stackoverflow.com/questions/72852629
复制相似问题