燃尽的一个不便之处修改

    最近在空间上部署了然知,先来普及一下然知是什么东西,知是一款客户关系管理软件,是开源的,用来管理自己的客户,团队等。简单的说就是跟踪客户信息,比如让销售人员来卖一款产品,每次都要和客户沟通,客户就是不想购买,可以采用电话,qq等沟通方式,但是沟通完了之后我要做一下笔记,沟通到什么程度了,下次是否可以约出来见个面了,下次是不是可以和客户签约了,等等这样我下次再打电话的时候就知道这些信息了,采取响应的行动。

但是在客户列表页面我点击沟通可以弹出联系人和沟通历史的界面,这个界面唯独没有客户的手机号信息,这个非常不方便,如下图:

看了一下源代码是这样的

    public function getPairs($customer = 0, $emptyOption = true)
    {
        $customerIdList = $this->loadModel('customer', 'crm')->getCustomersSawByMe();
        if(empty($customerIdList)) return array();

        $contacts = $this->dao->select('t1.*')->from(TABLE_CONTACT)->alias('t1')
            ->leftJoin(TABLE_RESUME)->alias('t2')->on('t1.id = t2.contact')
            ->where('t1.deleted')->eq(0)
            ->beginIF($customer)->andWhere('t2.customer')->eq($customer)->FI()
            ->andWhere('t2.customer')->in($customerIdList)
            ->fetchPairs('id', 'realname');

        if($emptyOption)  $contacts = array(0 => '') + $contacts;

        return $contacts;
    }

fetchPairs方法反返回的是一个数组,用id作键,用realname作值,修改一下,让它返回用户的姓名,座机号,手机号,重新写了一个方法如下:

    //获取联系人姓名和手机号id,t1.realname,t1.phone,t1.mobile
    public function getPairsPhone($customer = 0, $emptyOption = true)
    {
        $customerIdList = $this->loadModel('customer', 'crm')->getCustomersSawByMe();
        if(empty($customerIdList)) return array();

        $contacts = $this->dao->select('t1.id,t1.realname,t1.phone,t1.mobile')->from(TABLE_CONTACT)->alias('t1')
            ->leftJoin(TABLE_RESUME)->alias('t2')->on('t1.id = t2.contact')
            ->where('t1.deleted')->eq(0)
            ->beginIF($customer)->andWhere('t2.customer')->eq($customer)->FI()
            ->andWhere('t2.customer')->in($customerIdList)
            //->fetchPairs('id', 'realname');
            ->fetchAll();
        $contactsWithPhone = array();
        foreach($contacts as $contact)
        { 
           $contactsWithPhone += array($contact->id => ($contact->realname .' '. $contact->phone));
        }
        //var_dump($contactsWithPhone);
        //exit;
        if($emptyOption)  $contactsWithPhone = array(0 => '') + $contactsWithPhone;

        return $contactsWithPhone;
    }

最后的结果如下截图:

这样打电话的时候就方便多了。

 

posted @ 2015-04-23 23:18  nd  阅读(517)  评论(0编辑  收藏  举报