Skip to content

Commit

Permalink
fix issue on call online menu - not showed the call details on form
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Apr 12, 2019
1 parent 93967dd commit 5e2166e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
9 changes: 7 additions & 2 deletions protected/commands/CallChartCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ public function run($args)
$modelSip = Sip::model()->find('techprefix = :key AND host != "dynamic" ', array(':key' => $tech));
if (!count($modelSip)) {
$modelSip = Sip::model()->find('name = :key', array(':key' => $originate));
if (!count($modelSip)) {
//check if is via IP from proxy
$callProxy = AsteriskAccess::getCoreShowChannel($channel, null, $call['server']);
$modelSip = Sip::model()->find('host = :key', array(':key' => $callProxy['X-AUTH-IP']));
}
}

if (count($modelSip)) {
Expand Down Expand Up @@ -237,12 +242,12 @@ public function run($args)
$didChannel = AsteriskAccess::getCoreShowChannel($channel);
// is a DID
if (isset($didChannel['DIALEDPEERNUMBER'])) {
$sip_account = $didChannel['DIALEDPEERNUMBER'];
$originate = $didChannel['DIALEDPEERNUMBER'];
}

}

$sql[] = "(NULL, '$uniqueid', '$originate', $id_user, '$sip_account', '$trunk', '$ndiscado', 'NULL', '$status', '$cdr', 'no','no', '" . $call['server'] . "')";
$sql[] = "(NULL, '$uniqueid', '$originate', $id_user, '$channel', '$trunk', '$ndiscado', 'NULL', '$status', '$cdr', 'no','no', '" . $call['server'] . "')";

if ($modelUserCallShop > 0) {
if (in_array($modelSip->id_user, $callShopIds)) {
Expand Down
32 changes: 21 additions & 11 deletions protected/components/AsteriskAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,24 +451,34 @@ public static function getCoreShowChannelsVerbose()
return $channels;
}

public static function getCoreShowChannel($channel, $agi = null)
public static function getCoreShowChannel($channel, $agi = null, $server = null)
{

$sql = "SELECT * FROM pkg_servers WHERE type = 'asterisk' AND status = 1 AND host != 'localhost'";
if (isset($agi->engine)) {
$modelServers = $agi->query($sql)->fetchAll(PDO::FETCH_ASSOC);
if ($server == null) {
$sql = "SELECT * FROM pkg_servers WHERE type = 'asterisk' AND status = 1 AND host != 'localhost'";
if (isset($agi->engine)) {
$modelServers = $agi->query($sql)->fetchAll(PDO::FETCH_ASSOC);
} else {
$modelServers = Yii::app()->db->createCommand($sql)->queryAll();
}

array_push($modelServers, array(
'host' => 'localhost',
'username' => 'magnus',
'password' => 'magnussolution',
));
} else {
$modelServers = Yii::app()->db->createCommand($sql)->queryAll();
$modelServers = array();
array_push($modelServers, array(
'host' => $server,
'username' => 'magnus',
'password' => 'magnussolution',
));

}

array_push($modelServers, array(
'host' => 'localhost',
'username' => 'magnus',
'password' => 'magnussolution',
));
$channels = array();
foreach ($modelServers as $key => $server) {

$data = AsteriskAccess::instance($server['host'], $server['username'], $server['password'])->coreShowChannel($channel);
if (!isset($data['data']) || strlen($data['data']) < 10 || preg_match("/is not a known channe/", $data['data'])) {
continue;
Expand Down
5 changes: 3 additions & 2 deletions protected/controllers/CallOnLineController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ public function actionRead($asJson = true, $condition = null)

public function actionGetChannelDetails()
{
$model = $this->abstractModel->find('uniqueid = :key', array('key' => $_POST['id']));
$channel = AsteriskAccess::getCoreShowChannel($model->canal);
$model = $this->abstractModel->find('uniqueid = :key', array('key' => $_POST['id']));

$channel = AsteriskAccess::getCoreShowChannel($model->canal, null, $model->server);

$sipcallid = explode("\n", $channel['SIPCALLID']['data']);

Expand Down

0 comments on commit 5e2166e

Please sign in to comment.