コード例 #1
0
ファイル: systemstatus.server.php プロジェクト: ljhcj/IRISCC
/**
*  initialize page elements
*  @return	objResponse		object		xajax response object
*/
function showChannelsInfo()
{
    global $locate, $config, $db;
    $aDyadicArray[] = array($locate->Translate("src"), $locate->Translate("dst"), $locate->Translate("srcchan"), $locate->Translate("dstchan"), $locate->Translate("starttime"), $locate->Translate("answertime"), $locate->Translate("disposition"));
    $objResponse = new xajaxResponse();
    if ($config['system']['eventtype'] == 'curcdr') {
        if ($_SESSION['curuser']['usertype'] == 'admin') {
            $curcdr = astercrm::getAll("curcdr");
        } else {
            //print_r($_SESSION['curuser']['memberExtens']);exit;
            $curcdr = astercrm::getGroupCurcdr();
        }
        while ($curcdr->fetchInto($row)) {
            $systemCDR[] = array($row["src"], $row["dst"], $row["srcchan"], $row["dstchan"], $row["starttime"], $row["answertime"], $row["disposition"]);
        }
        $activeCalls = "  " . count($systemCDR) . " " . $locate->Translate("active calls");
        $objResponse->addAssign("divActiveCalls", "innerHTML", $activeCalls);
        $systemChannels = common::generateTabelHtml(array_merge($aDyadicArray, $systemCDR));
        $objResponse->addAssign("channels", "innerHTML", nl2br(trim($systemChannels)));
        return $objResponse;
    }
    $channels = split(chr(13), asterisk::getCommandData('show channels verbose'));
    /*
    	if ($channels == null){
    			$objResponse->addAssign("channels", "innerHTML", "can not connect to AMI, please check config.php");
    			return $objResponse;
    	}
    */
    $channels = split(chr(10), $channels[1]);
    //trim the first two records and the last three records
    //	array_pop($channels);
    array_pop($channels);
    $activeCalls = array_pop($channels);
    $activeChannels = array_pop($channels);
    array_shift($channels);
    $title = array_shift($channels);
    $title = split("_", implode("_", array_filter(split(" ", $title))));
    $myInfo[] = $title;
    foreach ($channels as $channel) {
        if (strstr($channel, " Dial")) {
            $myItem = split("_", implode("_", array_filter(split(" ", $channel))));
            $myInfo[] = $myItem;
        }
    }
    $myChannels = common::generateTabelHtml($myInfo);
    $objResponse->addAssign("divActiveCalls", "innerHTML", $activeCalls);
    $objResponse->addAssign("channels", "innerHTML", nl2br(trim($myChannels)));
    return $objResponse;
}