客製~VtigerCRM 在新增 New Lead 時可自動分派給 User

    版本為 03:20, 27 Dec 2024

    到這個版本。

    返回到 版本存檔.

    查閱目前版本

    客戶需求:客戶系統有一個自動新增 New Lead 的程序,不過每次新增 New Lead 後都先分派給 Admin 管理者,然後再由人工方式修改 Lead 的分派給其他 User,為了加強自動化作業,希望系統在每次自動新增 New Lead 時,可以用 Round-Robin 方式,將 Lead 平均分派給給每個 User。

    解決方案:

    1. 修改客戶現有的自動新增 New Lead 程式 lmb.php,開發一個函數取得應該要分派的 User Name。
      • lmb.php
    2. 在 VtigerCRM 的操作介面上方,新增一個按鈕用來使登入的 User 可以切換 Turn ON/OFF Lead。
      • 編輯:/vtigercrm/Smarty/templates/Buttons_List.tpl
      • 編輯:/vtigercrm/Smarty/templates/Header.tpl
      • 編輯:/vtigercrm/themes/softed/style.css
      • 新增:/vtigercrm/modules/Leads/TurnOnLeads.php
    3. 新增一個 Table: vtiger_users_auto_assign,這用來紀錄 User 自動分派 Lead 程式的一些資訊。
       

    程式內容

    lmb.php:
    require_once('functions.autoassign.php');
    ...
    ...
    $UNAME = get_assigned_username();
    if (empty($UNAME)) {
       // in case of null, set username as bill, basically that won't happen.
       $UNAME = "bill";
    }
    // The below are what you want to do
    echo "$UNAME\n";
    ...
    ... 
    
    Buttons_List.tpl:
                                   <!-- All Menu -->
                                   <table border=0 cellspacing=0 cellpadding=5>
                                   <tr>
                                           <td style="padding-left:10px;"><a href="javascript:;" onmouseout="fninvsh('allMenu');" onClick="fnvshobj(this,'allMenu')"><img src="{$IMAGE_PATH}btnL3AllMenu.gif" alt="{$APP.LBL_ALL_MENU_ALT}" title="{$APP.LBL_ALL_MENU_TITLE}" border="0"></a></td>
                                           {if $CHECK.moduleSettings eq 'yes'}
                                           <td style="padding-left:10px;"><a href='index.php?module=Settings&action=ModuleManager&module_settings=true&formodule={$MODULE}&parenttab=Settings'><img src="{'settingsBox.png'|@vtiger_imageurl:$THEME}" alt="{$MODULE|getTranslatedString:$MODULE} {$APP.LBL_SETTINGS}" title="{$MODULE|getTranslatedString:$MODULE} {$APP.LBL_SETTINGS}" border="0"></a></td>
                                           {/if}
                                           <!-- written by alang: for Leads auto-assign -->
                                           <td style="padding-right:10px"><a href="javascript:void(0);" onClick="turnon_leads(this);"><img src="{$IMAGE_PATH}btnL3Tracker.gif" alt="Turn ON/OFF Leads" title="Turn ON/OFF Leads" border=0">
                                           </td>
                                           <!-- End: written by alang: for Leads auto-assign -->
                                   </tr>
                                   </table>
    
    Header.tpl:
    </script>
    <div class="lvtCol fixedLay1" id="vtigerNewsPopupLay" style="display: none; height: 250px; bottom: 2px; padding: 2px; z-index: 12; font-weight: normal;" align="left">
    </div>
    
    <!-- Turn On Leads, written by alang -->
    <script type="text/javascript">
    {literal}
    function turnon_leads(obj) {
           $('status').style.display = 'inline';
           new Ajax.Request(
                   'index.php',
                   {queue: {position: 'end', scope: 'command'},
                           method: 'post',
                           postBody: 'module=Leads&action=LeadsAjax&file=TurnOnLeads&mode=ajax&ajax=true',
                           onComplete: function(response) {
                                   $("turnonLeadsPopupLay").innerHTML=response.responseText;
                                   fnvshobj(obj, 'turnonLeadsPopupLay');
                                   $('status').style.display = 'none';
                           }
                   }
           );
    
    }
    {/literal}
    </script>
    <div class="lvtCol fixedLay1" id="turnonLeadsPopupLay" onmouseout="fninvsh('turnonLeadsPopupLay');" onMouseOver="fnvshNrm('turnonLeadsPopupLay');" style="z-index: 10000001;display:none;position:absolute;">
    </div>
    <!-- End: Turn On Leads, written by alang -->
    
    <!-- END -->
    
    style.css:
    reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown. (click for details)
    TurnOnLeads.php:
    reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown. (click for details)
    Table: vtiger_users_auto_assign
    reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown. (click for details)
    畫面預覽

    vtigercrm-turnonleads-all.png

    Powered by MindTouch Core