首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >sugarcrm - leads模块的搜索逻辑

sugarcrm - leads模块的搜索逻辑
EN

Stack Overflow用户
提问于 2014-10-14 16:45:31
回答 1查看 229关注 0票数 0

我必须创建一个新角色,名为“主代理”。他下面会有一些用户。这些信息我将保存在一个数据库表中。当这个主代理登录时,我应该只显示那些分配给他下面的用户的销售线索。

当我以管理员身份登录时,我看到的是所有线索。当我以用户身份登录时,我只能看到分配给此特定用户的销售线索。

我想要操作搜索逻辑,这样我就可以看到在master agent下分配给用户的所有线索。

我一直在分析和查看LeadsInListView文件中的函数create_new_list_query(),以及负责搜索功能的data/SugarBean.php中的相同函数。该函数在如何执行搜索逻辑方面非常令人困惑。

请帮助操作搜索逻辑以包含新角色。

提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2014-10-15 15:32:03

您可以通过将以下文件添加到以下位置来自定义销售线索的ListView

代码语言:javascript
复制
<SUGAR_PATH>/custom/modules/Leads/view/view.list.php 

(如果此目录不存在,请创建它,同时创建view.list.php文件)

并添加以下代码

代码语言:javascript
复制
<?php

require_once('include/MVC/View/views/view.list.php');

class LeadsViewList extends ViewList {

    function listViewProcess() {
        global $current_user;
        $uId = $current_user->id;
        $this->processSearchForm();
        // remove this condition, if your Admin should not see all Leads..
        if(!$current_user->is_admin) {
            // Select From Leads and make a inner join on Users Table to get all users, which reports to
            // if you have the Relationship between your master_agent and his worker in another table, join this..
            $this->params['custom_from'] = ' inner join (select id from users u where u.reports_to_id = "'.$uId.'") as p ';
            $this->params['custom_where'] = ' AND p.id = leads.assigned_user_id ';
        }

        if (empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false) {
            $this->lv->setup($this->seed, 'include/ListView/ListViewGeneric.tpl', $this->where, $this->params);
            $savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : (' - ' . $_REQUEST['saved_search_select_name']);
            echo $this->lv->display();
        }
    }

}
?>

现在,您可以使用您的Master_Agent帐户登录并查看所有员工的销售线索。但请注意,现在Leads的ListView已定制,因此将只显示您的Master_Agent的员工记录。如果您还想显示Master_Agents的Lead,可以像这样扩展custom_where子句:

代码语言:javascript
复制
$this->params['custom_where'] = ' AND p.id = leads.assigned_user_id OR assigned_user_id = "'.$uId.'" ';

我希望这能帮助你,解决你的任务..

帕特里克

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26356355

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档