Asterisk + Vtiger CRM 5.1 电击拨号 实现来电弹屏
http://www.ztmaker.com/read.php?tid-325.html
一、Asterisk 端配置
修改配置文件"/etc/asterisk/manager_custom.conf",在其中添加一个管理帐号"vtigercrm":
[vtigercrm]
secret = vtigercrm
deny=0.0.0.0/0.0.0.0
permit=192.168.1.3/255.255.255.0
read = system,call,log,verbose,command,agent,user
write = system,call,log,verbose,command,agent,user
然后重启 Asterisk:
二、CRM 端配置
1、设置模块
使用管理员登录"VtigerCRM",在菜单中选择"Settings->Module Manager"进入模块列表页面。
在此页面中找到"PBX Manager"模块,将其启用后,点击配置图标对此模块进行配置。各配置项内容如下:
Asterisk server IP: 填写 Asterisk 服务器地址
Asterisk server port: 填写 Asterisk 管理端口,默认为 5038
Asterisk username: 填写 Asterisk 帐号名称,按之前的配置就填写为"vtigercrm"
Asterisk password: 填写 Asterisk 帐号密码,按之前的配置就填写为"vtigercrm"
Asterisk Version: 选择 Asterisk 的版本
2、设置用户分机
使用用户帐号登录后,点击右上方的"My Preferences",在打开的页面中找到"Asterisk Configuration"栏,并作如下配置:
Asterisk Extension: 填写用户的分机号
Receive Incoming Calls: 选中此选项
3、启动客户端程序
使用 SSH 登录 CRM 服务器,进入 CRM 系统安装路径下的"cron/modules/PBXManager"目录,然后运行以下命令:
# ./AsteriskClient.php
如果一切正常就会出现如下信息:
Date: 05-03-2010
Connecting to asterisk server.....
Connected successfully
Trying to login to asterisk
Logged in successfully to asterisk server
至此,就可以使用电话拨打刚才设置的用户分机号了,如果一切正常,就可以看到CRM页面的右下角就会出现一个来电提示框。另外在菜单中打开"Tools->PBX Manager",在页面中也可以看到来电记录。
注:如果 Asterisk 是 1.4 版的,请到以下位置下载修改过的"AsteriskClient.php"来替换原系统中的文件:
http://danielaliaman.com/blog///index.php/2009/07/23/vtiger_pbx_manager_issues_only_first_cal?blog=2
http://hi.baidu.com/ahhui/blog/item/e275b419ca6b415343a9ad83.html
环境:Elastix1.6
[vtigecrm]
复制代码
secret = vtigecrm deny=0.0.0.0/0.0.0.0 permit=0.0.0.0/0.0.0.0 read = system,call,log,verbose,command,agent,user write = system,call,log,verbose,command,agent,user 以上代码中vtigercrm不是特定的,但要在vtigercrm中的pbx设置要一致。
Asterisk server IP :192.168.0.15 (这是astersik
服务器的IP)
复制代码·
Asterisk server port :5038 (默认5038) Asterisk username :vtigercrm Asterisk password :vtigercrm Asterisk Version:1.4
4、设置vtigercrm中的个人分机号:
switch($typeCalled){
复制代码
case "SIP": $context = "local-extensions"; break; case "PSTN": $context = "from-inside";//"outbound-dialing"; break; default: $context = "default"; } 更改为:
switch($typeCalled){
复制代码
case "SIP": $context = "local-extensions"; break; case "PSTN": $context = "from-internal";//"outbound-dialing"; break; default: $context = "from-internal"; } 如果顺利,到这里就能用vtigercrm点击拨号了,点击号码后,你的分机会响铃,响铃分机提机后,系统就自动将号码拨出。
php AsteriskClient.php
复制代码
运行后,不能终止,如果服务器重启过,还需要再次运行。 |
弹屏补丁
vtigercrm/include/js/asterisk.js
function _defAsteriskTimer(){
var asteriskTimer = null;
var ASTERISK_POLLTIME = 5000; //vtigercrm polls the asterisk server for incoming calls after every 3 seconds for now
var ASTERISK_INCOMING_DIV_TIMEOUT = 60;
notificationPopup.js
function ResetPopup(){
popupDiv.innerHTML = "";
popupDiv.style.height = "0px";
popupDiv.style.display = "none";
parentDiv.removeChild(popupDiv);
if(parentDiv.children.length ==0){
parentDiv.style.display = "none";
}
}
vtigercrm/cron/modules/PBXManager/AsteriskClient.php
function asterisk_handleResponse2($mainresponse, $adb, $asterisk, $state) {
$appdata = $mainresponse['AppData'];
$uniqueid = $channel = $callerType = $extension = null;
$parseSuccess = false;
if(
$mainresponse['Event'] == 'Newexten' && (strstr($appdata, "__DIALED_NUMBER") || strstr($appdata, "EXTTOCALL"))
) {
$uniqueid = $mainresponse['Uniqueid'];
$channel = $mainresponse['Channel'];
$splits = explode('/', $channel);
$callerType = $splits[0];
$splits = explode('=', $appdata);
$extension = $splits[1];
$parseSuccess = true;
} else if($mainresponse['Event'] == 'OriginateResponse'){
//if the event is OriginateResponse then its an outgoing call and set the flag to 1, so that AsteriskClient does not pick up as incoming call
$uniqueid = $mainresponse['Uniqueid'];
$adb->pquery("UPDATE vtiger_asteriskincomingevents set flag = 1 WHERE uid = ?", array($uniqueid));
}else if($mainresponse['Event']=='NewCallerid'){
$channel = $mainresponse['Channel'];
if(strncmp($channel,"DAHDI",5)==0){
$uniqueid = $mainresponse['Uniqueid'];
if(!empty($mainresponse['CallerID'])) {
$callerNumber = $mainresponse['CallerID'];
}elseif(!empty($mainresponse['CallerIDNum'])) {
$callerNumber = $mainresponse['CallerIDNum'];
}
$sql = "UPDATE vtiger_asteriskincomingevents set from_number=? WHERE uid=?";
$adb->pquery($sql, array($callerNumber, $uniqueid));
}
}