/** * Originate src and dest extension * @param src string extension * @param dest string extension * @return object xajax response object */ function invite($src, $dest, $campaignid = '', $dialedlistid = 0) { global $config, $locate; #print_r($_SESSION['curuser']['group']);exit; $src = trim($src); $dest = trim($dest); $objResponse = new xajaxResponse(); //$objResponse->addAssign("dialmsg", "innerHTML", "<b>".$locate->Translate("dailing")." ".$src."</b>"); if ($src == $_SESSION['curuser']['extension']) { $callerid = $dest; } else { $callerid = $src; } $variable = null; $myAsterisk = new Asterisk(); $myAsterisk->config['asmanager'] = $config['asterisk']; $res = $myAsterisk->connect(); if (!$res) { $objResponse->addAssign("mobileStatus", "innerText", "Failed"); } if ($campaignid != '') { $row_campaign = astercrm::getRecordByID($campaignid, "campaign"); //print_r($row_campaign);exit; if (trim($row_campaign['nextcontext']) != '') { $incontext = $row_campaign['nextcontext']; } elseif (trim($row_campaign['incontext']) != '') { $incontext = $row_campaign['incontext']; } else { $incontext = $config['system']['incontext']; } if (trim($row_campaign['firstcontext']) != '') { $outcontext = $row_campaign['firstcontext']; } elseif (trim($row_campaign['outcontext']) != '') { $outcontext = $row_campaign['outcontext']; } else { $outcontext = $config['system']['outcontext']; } if ($row_campaign['callerid'] == "") { $variable = '__CUSCID=' . $_SESSION['curuser']['extension'] . $_SESSION['asterisk']['paramdelimiter']; } //if($row_campaign['inexten'] != '') $src = $row_campaign['inexten']; //echo $variable;exit; if ($_SESSION['curuser']['group']['firstring'] == 'caller') { if ($row_campaign['dialtwoparty'] == "yes") { $strChannel = "local/" . $src . "@" . $incontext . ""; } else { $strChannel = "local/" . $src . "@" . $incontext . "/n"; } if ($row_campaign['callerid'] != "") { $callerid = $row_campaign['callerid']; $variable = '__CUSCID=' . $dest . $_SESSION['asterisk']['paramdelimiter']; } $incontext = $outcontext; } else { if ($row_campaign['dialtwoparty'] == "yes") { $strChannel = "local/" . $dest . "@" . $outcontext . ""; } else { $strChannel = "local/" . $dest . "@" . $outcontext . "/n"; } if ($row_campaign['callerid'] != "") { $callerid = $row_campaign['callerid']; $variable = '__CUSCID=' . $dest . $_SESSION['asterisk']['paramdelimiter']; } $dest = $src; } $variable .= '__CAMPAIGNID=' . $row_campaign['id'] . $_SESSION['asterisk']['paramdelimiter']; #传拨号计划id给asterisk $variable .= '__DIALEDLISTID=' . $dialedlistid . $_SESSION['asterisk']['paramdelimiter']; #dialedlist id给asterisk $variable .= '__DIALEDNUM=' . $dest; } else { if ($_SESSION['curuser']['callerid'] == '') { $variable .= '__CUSCID=' . $_SESSION['curuser']['extension']; } else { $variable .= '__CUSCID=' . $_SESSION['curuser']['callerid']; } //$group_info = astercrm::getRecordByID($_SESSION['curuser']['groupid'],"astercrm_accountgroup"); if ($_SESSION['curuser']['group']['incontext'] != '') { $incontext = $_SESSION['curuser']['group']['incontext']; } else { $incontext = $config['system']['incontext']; } if ($_SESSION['curuser']['group']['outcontext'] != '') { $outcontext = $_SESSION['curuser']['group']['outcontext']; } else { $outcontext = $config['system']['outcontext']; } if ($_SESSION['curuser']['group']['firstring'] == 'caller') { $strChannel = "local/" . $dest . "@" . $incontext . "/n"; $dest = $src; $incontext = $outcontext; } else { $strChannel = "local/" . $src . "@" . $outcontext . "/n"; } } if ($config['system']['allow_dropcall'] == true) { $myAsterisk->dropCall($sid, array('Channel' => "{$strChannel}", 'WaitTime' => 30, 'Exten' => $dest, 'Context' => $incontext, 'Account' => $_SESSION['curuser']['accountcode'], 'Variable' => "{$variable}", 'Priority' => 1, 'MaxRetries' => 0, 'CallerID' => $callerid)); } else { $myAsterisk->sendCall($strChannel, $dest, $incontext, 1, NULL, NULL, 30, $callerid, $variable, $_SESSION['curuser']['accountcode']); } //$objResponse->addAssign("divMsg", "style.visibility", "hidden"); return $objResponse->getXML(); }
function dial($phoneNum, $first = '', $myValue, $dtmf = '') { global $config, $locate; $objResponse = new xajaxResponse(); if (trim($myValue['curid']) > 0) { $curid = trim($myValue['curid']) - 1; } else { $curid = trim($myValue['curid']); } if ($dtmf != '') { $app = 'Dial'; $data = 'local/' . $phoneNum . '@' . $config['system']['outcontext'] . '|30' . '|D' . $dtmf; $first = 'caller'; } $myAsterisk = new Asterisk(); if ($first == '') { $first = $config['system']['firstring']; } $myAsterisk->config['asmanager'] = $config['asterisk']; $res = $myAsterisk->connect(); if (!$res) { $objResponse->addAssign("mobileStatus", "innerText", "Failed"); } if ($first == 'caller') { //caller will ring first $strChannel = "local/" . $_SESSION['curuser']['extension'] . "@" . $config['system']['incontext'] . "/n"; if ($config['system']['allow_dropcall'] == true) { $myAsterisk->dropCall($sid, array('Channel' => "{$strChannel}", 'WaitTime' => 30, 'Exten' => $phoneNum, 'Context' => $config['system']['outcontext'], 'Account' => $_SESSION['curuser']['accountcode'], 'Variable' => "{$strVariable}", 'Priority' => 1, 'MaxRetries' => 0, 'CallerID' => $phoneNum)); } else { $myAsterisk->sendCall($strChannel, $phoneNum, $config['system']['outcontext'], 1, $app, $data, 30, $phoneNum, NULL, $_SESSION['curuser']['accountcode']); } } else { $strChannel = "local/" . $phoneNum . "@" . $config['system']['outcontext'] . "/n"; if ($config['system']['allow_dropcall'] == true) { /* coz after we use new method to capture dial event there's no good method to make both leg display correct clid for now so we comment these lines */ $myAsterisk->dropCall($sid, array('Channel' => "{$strChannel}", 'WaitTime' => 30, 'Exten' => $_SESSION['curuser']['extension'], 'Context' => $config['system']['incontext'], 'Account' => $_SESSION['curuser']['accountcode'], 'Variable' => "{$strVariable}", 'Priority' => 1, 'MaxRetries' => 0, 'CallerID' => $_SESSION['curuser']['extension'])); } else { $myAsterisk->sendCall($strChannel, $_SESSION['curuser']['extension'], $config['system']['incontext'], 1, $app, $data, 30, $_SESSION['curuser']['extension'], NULL, NULL); } } //$myAsterisk->disconnect(); $objResponse->addAssign("divMsg", "style.visibility", "hidden"); return $objResponse->getXML(); }
/** * Originate src and dest extension * @param src string extension * @param dest string extension * @return object xajax response object */ function invite($src, $dest, $campaignid = '') { global $config; $src = trim($src); $dest = trim($dest); $objResponse = new xajaxResponse(); //$objResponse->addAssign("dialmsg", "innerHTML", "<b>".$locate->Translate("dailing")." ".$src."</b>"); if ($src == $_SESSION['curuser']['extension']) { $callerid = $dest; } else { //if ($dest == $_SESSION['curuser']['extension']) $callerid = $src; } // else // return $objResponse; $myAsterisk = new Asterisk(); $myAsterisk->config['asmanager'] = $config['asterisk']; $res = $myAsterisk->connect(); if (!$res) { $objResponse->addAssign("mobileStatus", "innerText", "Failed"); } if ($campaignid != '') { $row_campaign = astercrm::getRecordByID($campaignid, "campaign"); if (trim($row_campaign['incontext']) != '') { $incontext = $row_campaign['incontext']; } else { $incontext = $config['system']['incontext']; } if (trim($row_campaign['outcontext']) != '') { $outcontext = $row_campaign['outcontext']; } else { $outcontext = $config['system']['outcontext']; } //if($row_campaign['inexten'] != '') $src = $row_campaign['inexten']; } else { $group_info = astercrm::getRecordByID($_SESSION['curuser']['groupid'], "astercrm_accountgroup"); if ($group_info['incontext'] != '') { $incontext = $group_info['incontext']; } else { $incontext = $config['system']['incontext']; } if ($group_info['outcontext'] != '') { $outcontext = $group_info['outcontext']; } else { $outcontext = $config['system']['outcontext']; } } $strChannel = "local/" . $src . "@" . $incontext . "/n"; if ($config['system']['allow_dropcall'] == true) { $myAsterisk->dropCall($sid, array('Channel' => "{$strChannel}", 'WaitTime' => 30, 'Exten' => $dest, 'Context' => $outcontext, 'Account' => $_SESSION['curuser']['accountcode'], 'Variable' => "{$strVariable}", 'Priority' => 1, 'MaxRetries' => 0, 'CallerID' => $callerid)); } else { $myAsterisk->sendCall($strChannel, $dest, $outcontext, 1, NULL, NULL, 30, $callerid, NULL, $_SESSION['curuser']['accountcode']); } $objResponse->addAssign("divMsg", "style.visibility", "hidden"); return $objResponse->getXML(); }
function invite($src, $dest, $creditLimit) { global $config; $src = trim($src); $dest = trim($dest); $credit = trim($credit); $myAsterisk = new Asterisk(); $objResponse = new xajaxResponse(); $myAsterisk->config['asmanager'] = $config['asterisk']; $res = $myAsterisk->connect(); if (!$res) { $objResponse->addAssign("mobileStatus", "innerText", "Failed"); } $strChannel = "local/" . $src . "@" . $config['system']['outcontext'] . "/n"; $_SESSION['callbacks'][$src . $dest] = array('legA' => $dest, 'legB' => $src, 'start' => 0, 'creditLimit' => $creditLimit); if ($config['system']['allow_dropcall'] == true) { $myAsterisk->dropCall($sid, array('Channel' => "{$strChannel}", 'WaitTime' => 30, 'Exten' => $dest, 'Context' => $config['system']['outcontext'], 'Account' => $_SESSION['curuser']['accountcode'], 'Variable' => "{$strVariable}", 'Priority' => 1, 'MaxRetries' => 0, 'CallerID' => $dest)); } else { $myAsterisk->sendCall($strChannel, $dest, $config['system']['outcontext'], 1, NULL, NULL, 30, $dest, NULL, $_SESSION['curuser']['accountcode']); } // add to callback table $callback['lega'] = $dest; $callback['legb'] = $src; $callback['credit'] = $creditLimit; $callback['groupid'] = $_SESSION['curuser']['groupid']; astercc::insertNewCallback($callback); return $objResponse->getXML(); }
function dial($phoneNum, $first = '') { global $config, $locate; $myAsterisk = new Asterisk(); if ($first == '') { $first = $config['system']['firstring']; } $myAsterisk->config['asmanager'] = $config['asterisk']; $res = $myAsterisk->connect(); if (!$res) { $objResponse->addAssign("mobileStatus", "innerText", "Failed"); } if ($first == 'caller') { //caller will ring first $strChannel = "local/" . $_SESSION['curuser']['extension'] . "@" . $config['system']['incontext'] . "/n"; if ($config['system']['allow_dropcall'] == true) { $myAsterisk->dropCall($sid, array('Channel' => "{$strChannel}", 'WaitTime' => 30, 'Exten' => $phoneNum, 'Context' => $config['system']['outcontext'], 'Account' => $_SESSION['curuser']['accountcode'], 'Variable' => "{$strVariable}", 'Priority' => 1, 'MaxRetries' => 0, 'CallerID' => $phoneNum)); } else { $myAsterisk->sendCall($strChannel, $phoneNum, $config['system']['outcontext'], 1, NULL, NULL, 30, $phoneNum, NULL, $_SESSION['curuser']['accountcode']); } } else { $strChannel = "local/" . $phoneNum . "@" . $config['system']['outcontext'] . "/n"; if ($config['system']['allow_dropcall'] == true) { /* coz after we use new method to capture dial event there's no good method to make both leg display correct clid for now so we comment these lines */ $myAsterisk->dropCall($sid, array('Channel' => "{$strChannel}", 'WaitTime' => 30, 'Exten' => $_SESSION['curuser']['extension'], 'Context' => $config['system']['incontext'], 'Account' => $_SESSION['curuser']['accountcode'], 'Variable' => "{$strVariable}", 'Priority' => 1, 'MaxRetries' => 0, 'CallerID' => $_SESSION['curuser']['extension'])); } else { $myAsterisk->sendCall($strChannel, $_SESSION['curuser']['extension'], $config['system']['incotext'], 1, NULL, NULL, 30, $_SESSION['curuser']['extension'], NULL, NULL); } } return; }
function chanSpy($spy, $exten, $pam, $pdl) { /* Action: originate Channel: Local/300 WaitTime: 30 CallerId: "Web Call" <8881> Application: ChanSpy Data: IAX2/100|q Async: yes */ /* $channel, $exten=NULL, $context=NULL, $priority=NULL, $application=NULL, $data=NULL, $timeout=NULL, $callerid=NULL, $variable=NULL, $account=NULL, $async=NULL, $actionid=NULL */ Asterisk::sendCall("local/{$spy}", null, null, null, "ChanSpy", $exten . $pdl . "q" . $pam, 30); }
function placeCall($campaignid) { global $config; $myAsterisk = new Asterisk(); $row =& astercrm::getDialNumber($campaignid); // 待拨号码为空 if (!$row) { return false; } //print_r($row); $id = $row['id']; $groupid = $row['groupid']; $campaignid = $row['campaignid']; $phoneNum = $row['dialnumber']; $trytime = $row['trytime']; $assign = $row['assign']; $pdcontext = $row['incontext']; $outcontext = $row['outcontext']; if ($row['inexten'] != "") { $pdextension = $row['inexten']; } else { if ($row['assign'] != "") { $pdextension = $row['assign']; } else { $pdextension = $row['dialnumber']; } } $res = astercrm::deleteRecord($id, "diallist"); $f['dialednumber'] = $phoneNum; $f['dialedby'] = $_SESSION['curuser']['username']; $f['groupid'] = $groupid; $f['trytime'] = $trytime + 1; $f['assign'] = $assign; $f['campaignid'] = $campaignid; $res = astercrm::insertNewDialedlist($f); $actionid = md5(uniqid("")); $strChannel = "local/" . $phoneNum . "@" . $outcontext . "/n"; if ($config['system']['allow_dropcall'] == true) { $myAsterisk->dropCall($actionid, array('Channel' => "{$strChannel}", 'WaitTime' => 30, 'Exten' => $pdextension, 'Context' => $pdcontext, 'Variable' => "{$strVariable}", 'Priority' => 1, 'MaxRetries' => 0, 'CallerID' => $phoneNum)); } else { $myAsterisk->config['asmanager'] = $config['asterisk']; $res = $myAsterisk->connect(); $myAsterisk->sendCall($strChannel, $pdextension, $pdcontext, 1, NULL, NULL, 30, $phoneNum, NULL, NULL, NULL, $actionid); } return true; }