中小旅行社CRM开发与部署 下载本文

$field8->typeofdata = 'V~O'; $block1->addField($field8);

在已存在的模块(旧模块)中添加数据库表字段可采用以下代码: include_once('vtlib/Vtiger/Module.php'); $fieldInstance = new Vtiger_Field(); $fieldInstance->name = 'PayslipName'; $fieldInstance->table = 'vtiger_payslip'; $fieldInstance->column = 'payslipname'; $fieldInstance->columntype = 'VARCHAR(100)'; $fieldInstance->uitype = 2; $fieldInstance->typeofdata = 'V~M'; $blockInstance->addField($fieldInstance);

四、创建过滤机制

主要源码:

$filter1 = new Vtiger_Filter(); $filter1->name = 'All'; $filter1->isdefault = true; $module->addFilter($filter1);

$filter1->addField($field1)->addField($field2,1)->addField($field5,2);

$filter2 = new Vtiger_Filter(); $filter2->name = 'All2'; $module->addFilter($filter2); $filter2->addField($field1); $filter2->addField($field2, 1);

$filter2->addRule($field1, 'CONTAINS', 'Test');

五、创建关联列表

主要源码:

$module->setRelatedList(Vtiger_Module::getInstance('Accounts'), 'Accounts', Array('ADD','SELECT'));

源码说明,为新模块添加一个关联列表——Accounts。去除关联列表使用方法:unsetRelateList.

六、设置共享机制

主要源码:

$module->setDefaultSharing('Private');

中国最大的论文知识平台www.lwxiezuo.com

共享模式可取值:Public_ReadOnly、Public_ReadWrite、

Public_ReadWriteDelete、Private。分别代表公共只读、公共读写、公共读写可删除、私有。

七、建立完整的安装文件

结合之前六步操作,建立脚本文件Create.Module.php,并运行之,即可完成新模块的开发及安装。其完整源码如下:

// Just a bit of HTML formatting

echo '

echo 'vtlib Module Script'; echo '';

echo '

echo '

$Vtiger_Utils_Log = true;

include_once('vtlib/Vtiger/Menu.php'); include_once('vtlib/Vtiger/Module.php'); $module = new Vtiger_Module(); $module->name = 'Acare'; $module->save(); $module->initTables();

$menu = Vtiger_Menu::getInstance('kh'); $menu->addModule($module); $block1 = new Vtiger_Block();

$block1->label = 'LBL_ACARE_INFORMATION'; $module->addBlock($block1); $block2 = new Vtiger_Block();

$block2->label = 'LBL_CUSTOM_INFORMATION'; $module->addBlock($block2); $field1 = new Vtiger_Field(); $field1->name = 'acarename';

中国最大的论文知识平台www.lwxiezuo.com

$field1->label = 'AcareName'; $field1->table = $module->basetable; $field1->column = 'acarename'; $field1->columntype = 'VARCHAR(255)'; $field1->uitype = 2;

$field1->typeofdata = 'V~M'; $block1->addField($field1); $module->setEntityIdentifier($field1); $field2 = new Vtiger_Field(); $field2->name = 'AcareType'; $field2->label = 'Acare Type'; $field2->columntype = 'VARCHAR(100)'; $field2->uitype = 15; $field2->typeofdata = 'V~O'; $block1->addField($field2);

$field2->setPicklistValues( Array ('法定假日', '客户生日','纪念日','其他') );

$field3 = new Vtiger_Field(); $field3->name = 'Month'; $field3->uitype = 23;

$field3->typeofdata = 'D~M'; $block1->addField($field3); $field4 = new Vtiger_Field(); $field4->name = 'LinkTo'; $field4->label= 'Link To'; $field4->table = 'vtiger_acare'; $field4->column = 'linkto';

$field4->columntype = 'VARCHAR(100)'; $field4->uitype = 10; $field4->typeofdata = 'V~O';

$field4->helpinfo = '关联到现有客户'; $block1->addField($field4);

$field4->setRelatedModules(Array('Accounts')); $field5 = new Vtiger_Field(); $field5->name = 'assigned_user_id'; $field5->label = 'Assigned To';

中国最大的论文知识平台www.lwxiezuo.com

$field5->table = 'vtiger_crmentity'; $field5->column = 'smownerid'; $field5->uitype = 53; $field5->typeofdata = 'V~M'; $block1->addField($field5); $field6 = new Vtiger_Field(); $field6->name = 'CreatedTime'; $field6->label= 'Created Time'; $field6->table = 'vtiger_crmentity'; $field6->column = 'createdtime'; $field6->uitype = 70; $field6->typeofdata = 'T~O'; $field6->displaytype= 2; $block1->addField($field6); $field7 = new Vtiger_Field(); $field7->name = 'ModifiedTime'; $field7->label= 'Modified Time'; $field7->table = 'vtiger_crmentity'; $field7->column = 'modifiedtime'; $field7->uitype = 70; $field7->typeofdata = 'T~O'; $field7->displaytype= 2; $block1->addField($field7); $field8 = new Vtiger_Field(); $field8->name = 'acaredes'; $field8->label = 'AcareDes'; $field8->table = $module->basetable; $field8->column = 'acaredes'; $field8->columntype = 'VARCHAR(255)'; $field8->uitype = 19; $field8->typeofdata = 'V~O'; $block1->addField($field8); $filter1 = new Vtiger_Filter(); $filter1->name = 'All'; $filter1->isdefault = true; $module->addFilter($filter1);

中国最大的论文知识平台www.lwxiezuo.com

$filter1->addField($field1)->addField($field2, 1)->addField($field5, 2);

$filter2 = new Vtiger_Filter(); $filter2->name = 'All2'; $module->addFilter($filter2); $filter2->addField($field1); $filter2->addField($field2, 1);

$filter2->addRule($field1, 'CONTAINS', 'Test');

$module->setRelatedList(Vtiger_Module::getInstance('Accounts'), 'Accounts', Array('ADD','SELECT'));

$module->setDefaultSharing('Private');

$module->enableTools(Array('Import', 'Export')); $module->disableTools('Merge'); echo ''; ?>

客户关怀界面如图5-9所示。

图5-9客户关怀界面

因此可以同样的方法开发其他系统模块。本次CRM开发共新开发了三个系统模块。其他两个分别为应收款模块:通过关联销售发票实现应收款功能和应付款模块通过关联采购订单实现应付款功能。分别如图5-10和5-11所示。同时本次系统开发还对其他个系统功能模块进行功能及界面优化

图5-10应付款界面

图5-11应收款界面

中国最大的论文知识平台www.lwxiezuo.com