Ejemplo n.º 1
0
function agentTransfer($oPaloConsola)
{
    $sTransferExt = getParameter('extension');
    $type = getParameter('atxfer');
    if (strpos($sTransferExt, '|') !== false) {
        $arrExt = explode(" | ", $sTransferExt);
        $sTransferExt = trim($arrExt[1]);
    }
    //var_dump($sTransferExt);
    $message = ($type == true ? 'Thành công: chuyển máy trực tiếp đến số ' : 'Thành công: chuyển máy gián tiếp đến số ') . $sTransferExt;
    $respuesta = array('action' => 'transfer', 'message' => $message);
    if (is_null($sTransferExt) || !ctype_digit($sTransferExt)) {
        $respuesta['action'] = 'error';
        $respuesta['message'] = 'Sai hay thiếu số extension';
    } else {
        // get queue number of this extension if any
        global $arrConf;
        $oCallHistory = new getInfoMainConsole();
        $oCallHistory->callcenter_db_connect($arrConf['cadena_dsn']);
        $sTransferExt = $oCallHistory->getAgentQueue($sTransferExt);
        $oCallHistory->callcenter_db_disconnect();
        $bExito = $oPaloConsola->transferirLlamada($sTransferExt, in_array(getParameter('atxfer'), array('true', 'checked')));
        if (!$bExito) {
            $respuesta['action'] = 'error';
            $respuesta['message'] = 'Lỗi trong khi chuyển hướng cuộc gọi - ' . $oPaloConsola->errMsg;
        }
    }
    $json = new Services_JSON();
    Header('Content-Type: application/json');
    return $json->encode($respuesta);
}