function refreshCallHistory() { $respuesta = array('action' => 'show_call_history', 'message' => '(no message)'); $sAgent = $_SESSION['callcenter']['extension']; global $arrConf; $oCallHistory = new getInfoMainConsole(); $oCallHistory->callcenter_db_connect($arrConf['cadena_dsn']); $bSuccess = $oCallHistory->getCallHistoryArray(50, $sAgent); $oCallHistory->callcenter_db_disconnect(); if (!$bSuccess) { $respuesta['action'] = 'error'; $respuesta['message'] = 'Error when getting history call: ' . $oCallHistory->errMsg; } else { $respuesta['message'] = $bSuccess; } $json = new Services_JSON(); Header('Content-Type: application/json'); return $json->encode($respuesta); }
function agent_monitoring_HTML($module_name, $smarty, $sDirLocalPlantillas, $oPaloConsola) { global $arrLang; $smarty->assign(array('FRAMEWORK_TIENE_TITULO_MODULO' => existeSoporteTituloFramework(), 'icon' => 'modules/' . $module_name . '/images/realtime.png', 'title' => 'Giám Sát & Quản Lý Tổng Đài Viên')); /* check if user login via agent console if (!isset($_SESSION['callcenter']['agente'])) { $smarty->assign(array( 'mb_title' => 'ERROR', 'mb_message' => 'Đăng nhập tại <a href="index.php?menu=agent_console">Agent Console</a> trước khi sử dụng tính năng này', )); return ''; } */ $estadoMonitor = $oPaloConsola->listarEstadoMonitoreoAgentes(); //echo '<pre>' . print_r($estadoMonitor,1) . '</pre>';die; if (!is_array($estadoMonitor)) { $smarty->assign(array('mb_title' => 'ERROR', 'mb_message' => $oPaloConsola->errMsg)); return ''; } ksort($estadoMonitor); //echo '<pre>' . print_r($estadoMonitor,1) . '</pre>';die; $jsonData = contructDataJSON(mergeQueueAgent($estadoMonitor)); // convert to Smarty data $sThemeDir = "modules/{$module_name}/themes/default"; $arrSmartyData = array(); foreach ($jsonData as $jsonKey => $jsonRow) { $arrSmartyData[$jsonKey] = $jsonRow; // show time format hh:mm:ss base on last-status $arrSmartyData[$jsonKey]['status_time'] = timestamp_format($jsonRow['sec_laststatus']); // show time format hh:mm:ss base on last-status $arrSmartyData[$jsonKey]['sec_calls_time'] = timestamp_format($jsonRow['sec_calls']); switch ($jsonRow['agentstatus']) { case 'offline': // image status with title information $arrSmartyData[$jsonKey]['img_status'] = "{$sThemeDir}/images/status_offline-ic.png"; $arrSmartyData[$jsonKey]['img_status_title'] = "{$jsonKey}: Chưa sẵn sàng"; // status time (count from sec_laststatus) $arrSmartyData[$jsonKey]['status_time_label'] = 'Offline:'; break; case 'online': // image status with title information $arrSmartyData[$jsonKey]['img_status'] = "{$sThemeDir}/images/status_free-ic.png"; $arrSmartyData[$jsonKey]['img_status_title'] = "{$jsonKey}: Đang sẵn sàng"; // status time (count from sec_laststatus) $arrSmartyData[$jsonKey]['status_time_label'] = 'Online:'; break; case 'oncall': // image status with title information $arrSmartyData[$jsonKey]['img_status'] = "{$sThemeDir}/images/status_on_call-ic.png"; $arrSmartyData[$jsonKey]['img_status_title'] = "{$jsonKey}: Đang gọi - Tại kênh: " . $jsonRow['linkqueue']; // status time (count from sec_laststatus) $arrSmartyData[$jsonKey]['status_time_label'] = 'Đang gọi: '; // get customer information $agentState = getAgentState($jsonRow['agent_number']); $arrSmartyData[$jsonKey]['callnumber'] = $agentState['callnumber']; $arrSmartyData[$jsonKey]['callid'] = $agentState['callid']; $customer = getCustomer($arrSmartyData[$jsonKey]['callnumber']); $arrSmartyData[$jsonKey]['customer'] = $customer ? $customer : $arrSmartyData[$jsonKey]['callnumber']; break; case 'paused': // image status with title information $arrSmartyData[$jsonKey]['img_status'] = "{$sThemeDir}/images/status_away-ic.png"; $arrSmartyData[$jsonKey]['img_status_title'] = "{$jsonKey}: Đang tạm nghỉ"; // status time (count from sec_laststatus) $arrSmartyData[$jsonKey]['status_time_label'] = 'Tạm nghỉ:'; break; default: } } // history call global $arrConf; $oCallHistory = new getInfoMainConsole(); $oCallHistory->callcenter_db_connect($arrConf['cadena_dsn']); $arrHistory = $oCallHistory->getCallHistoryArray(); $oCallHistory->callcenter_db_disconnect(); //$oQueueStatus = new queue_waiting(); //$arrQueue = $oQueueStatus->showQueue(); //echo '<pre>' . print_r($res,1) . '</pre>';die; //smarty template assign $smarty->assign(array('AGENT_STATUS' => $arrSmartyData, 'SUPERVISOR_NUMBER' => $_SESSION['callcenter']['extension'], 'THEME_PATH' => $sThemeDir, 'CALL_HISTORY' => $arrHistory, 'ITEM_LIMIT' => 6)); //echo '<pre>' . print_r($arrTicket,1) . '</pre>';die; $sContent = $smarty->fetch("{$sDirLocalPlantillas}/realtime_monitor.tpl"); //initilize with jsonData foreach (array_keys($jsonData) as $k) { unset($jsonData[$k]['agentname']); } // Extraer la información que el navegador va a usar para actualizar $estadoCliente = array(); foreach (array_keys($jsonData) as $k) { $estadoCliente[$k] = array('agentstatus' => $jsonData[$k]['agentstatus'], 'oncallupdate' => $jsonData[$k]['oncallupdate'], 'linkqueue' => $jsonData[$k]['linkqueue']); } $estadoHash = generarEstadoHash($module_name, $estadoCliente); $json = new Services_JSON(); $INITIAL_CLIENT_STATE = $json->encode($jsonData); $sJsonInitialize = <<<JSON_INITIALIZE <script type="text/javascript"> \$(function() { initialize_client_state({$INITIAL_CLIENT_STATE}, '{$estadoHash}');\t }); </script> JSON_INITIALIZE; return $sContent . $sJsonInitialize; }
function manejarSesionActiva_showCallHistory() { $respuesta = array('action' => 'show_call_history', 'message' => '(no message)'); $oCallHistory = new getInfoMainConsole(); $bSuccess = $oCallHistory->getCallHistoryArray(); if (!$bSuccess) { $respuesta['action'] = 'error'; $respuesta['message'] = 'Error when getting history call: ' . $oCallHistory->errMsg; } else { $respuesta['message'] = $bSuccess; } $json = new Services_JSON(); Header('Content-Type: application/json'); return $json->encode($respuesta); }