示例#1
0
function get_agent_status($queue, $agent)
{
    global $queue_members;
    # Connect to AGI
    $asm = new AGI_AsteriskManager();
    $asm->connect();
    # Add event handlers to retrieve the answer
    $asm->add_event_handler('queuestatuscomplete', 'Aastra_asm_event_queues_Asterisk');
    $asm->add_event_handler('queuemember', 'Aastra_asm_event_agents_Asterisk');
    # Retrieve info
    while (!$queue_members) {
        $asm->QueueStatus();
        $count++;
        if ($count == 10) {
            break;
        }
    }
    # Get info for the given queue
    $status['Logged'] = False;
    $status['Paused'] = False;
    foreach ($queue_members as $agent_a) {
        if ($agent_a['Queue'] == $queue && $agent_a['Location'] == 'Local/' . $agent . '@from-queue/n' or $agent_a['Queue'] == $queue && $agent_a['Location'] == 'Local/' . $agent . '@from-internal/n') {
            $status['Logged'] = True;
            if ($agent_a['Paused'] == '1') {
                $status['Paused'] = True;
            }
            $status['Type'] = $agent_a['Membership'];
            $status['CallsTaken'] = $agent_a['CallsTaken'];
            $status['LastCall'] = $agent_a['LastCall'];
            break;
        }
        # Get Penalty
        $penalty = $asm->database_get('QPENALTY', $queue . '/agents/' . $agent);
        if ($penalty == '') {
            $penalty = '0';
        }
        $status['Penalty'] = $penalty;
    }
    # Disconnect properly
    $asm->disconnect();
    # Return Status
    return $status;
}
function Aastra_get_queue_entries_Asterisk($queue)
{
    global $queue_entries;
    # Connect to AGI
    $asm = new AGI_AsteriskManager();
    $asm->connect();
    # Add event handlers to retrieve the answer
    $asm->add_event_handler('queuestatuscomplete', 'Aastra_asm_event_queues_asterisk');
    $asm->add_event_handler('queueentry', 'Aastra_asm_event_entries_Asterisk');
    # Retrieve info
    $count = 0;
    while (!$queue_entries) {
        $asm->QueueStatus();
        $count++;
        if ($count == 10) {
            break;
        }
    }
    # Process info
    $index = 0;
    if (count($queue_entries) > 0) {
        foreach ($queue_entries as $entry) {
            if ($entry['Queue'] == $queue) {
                $entries[$index] = $entry;
                $index++;
            }
        }
    }
    # Disconnect properly
    $asm->disconnect();
    # Return Status
    if (isset($entries)) {
        return $entries;
    } else {
        return NULL;
    }
}
示例#3
0
function is_agent_logged($agent)
{
    global $queue_members;
    $queue_members = '';
    # Transcode for device and user mode
    $agent = Aastra_get_userdevice_Asterisk($agent);
    # Not logged by default
    $return = False;
    # Connect to AGI
    $asm = new AGI_AsteriskManager();
    $asm->connect();
    # Add event handlers to retrieve the answer
    $asm->add_event_handler('queuestatuscomplete', 'asm_event_queues');
    $asm->add_event_handler('queuemember', 'asm_event_agents');
    # Retrieve info
    while (!$queue_members) {
        $asm->QueueStatus();
        $count++;
        if ($count == 10) {
            break;
        }
    }
    # Get info for all the queues
    foreach ($queue_members as $agent_a) {
        if ($agent_a['Location'] == 'Local/' . $agent . '@from-queue/n' or $agent_a['Location'] == 'Local/' . $agent . '@from-internal/n') {
            $return = True;
            break;
        }
    }
    # Disconnect properly
    $asm->disconnect();
    # Return Status
    return $return;
}