} $smarty->assign('extensions', $extensions); $smarty->display('extensions-realtime.tpl'); /*?><pre>extensions:<?print_r($extensions);?></pre><? */ } if ($_REQUEST['action'] == 'originatecall') { //$extennum - номер экстена, на который позвонить $databaseUser = $ami->database_show('AMPUSER'); $databaseCall = $ami->database_show('CURRCALL'); //найдем нашего агента и вернем данные только по нему //все взаимодействие через переменную сессий $AgentAccount if (isset($LogExtenNum)) { $LogExtenName = $databaseUser["/AMPUSER/{$LogExtenNum}/cidname"]; $CurrCallNum = $databaseCall["/CURRCALL/{$LogExtenNum}/NUM"]; $CurrCallName = $databaseCall["/CURRCALL/{$LogExtenNum}/NAME"]; $data[$LogExtenNum] = $ami->Originate("LOCAL/" . $LogExtenNum . "@" . $dialplan_context, $extennum, $dialplan_context, '1', '30000', '"' . $LogExtenNum . '" <' . $LogExtenName . '>', '', '', '', ''); // $smarty->assign('data', $data); // $smarty->display('operator-json2d.tpl'); echo json_encode($data); } } if ($_REQUEST['action'] == 'transfer') { //$extennum - номер экстена, на который передресовывать //$redirchan - канал, который передресовывать //найдем нашего агента и вернем данные только по нему //все взаимодействие через переменную сессий $AgentAccount if (isset($LogExtenNum)) { $LogExtenName = $databaseUser["/AMPUSER/{$LogExtenNum}/cidname"]; $CurrCallNum = $databaseCall["/CURRCALL/{$LogExtenNum}/NUM"]; $CurrCallName = $databaseCall["/CURRCALL/{$LogExtenNum}/NAME"]; $data[$LogExtenNum] = $ami->Redirect($redirchan, '', $extennum, $dialplan_context, '1');
$manager->Originate( 'SIP/'.$a, '', '', '1', 'ChanSpy', $b.',qx', '', '', '', '', 'Async', '' ); */ $r = $manager->Originate('SIP/' . $a, $a, 'from-internal', '1', 'ChanSpy', $b . ',' . $type, '', $b, '', '', 'Async', ''); echo $r['Response'] . ' mode=' . $type; $manager->disconnect(); //echo 'ok'; /* 'Канал для вызова, например SIP/1001', 'Экстеншн для диалплана', 'Контекст диалплана', 'Приоритет контекста диалплана', 'Или приложение астериска для запуска, например playback', 'параметры приложения, например путь к аудиофайлу', 'таймаут', 'Номер абонента от которого идет вызов или имя', 'переменные для диалплана', 'account - незнаю зачем, не использовал еще', 'Синхронный или асинхронный запрос (ждет или не ждет ответа о состоянии запроса)',
$accounts[$i] =$res -> fetchRow(); } foreach ($accounts as $calling_account) { $current_did = $calling_account[4]; if (!$DID_to_reach or $current_did==$DID_to_reach) { $channel = "SIP/".$calling_account[0]; $exten = '1234'; $context = '1234@a2billing_echotest'; $priority = 1; $timeout = 30000; $async = True; $callerid = "1234"; echo "--> Trying to Originate call to $channel \n\n"; $res_orig = $as->Originate($channel, $exten, $context, $priority, $application=NULL, $data=NULL, $timeout, $callerid, $variable=NULL, $account=NULL, $async, $actionid=NULL); print_r ($res_orig); } } } else { echo "No account found"; } // && DISCONNECTING echo "\nDisconnect\n"; $as->disconnect(); } else { echo "Cannot connect to the asterisk manager!<br>Please check your manager configuration.\n\n";
if (strlen($called) > 2) { $A2B->cardnumber = $_SESSION["pr_login"]; $dialstr = $called; $as = new AGI_AsteriskManager(); // && CONNECTING connect($server=NULL, $username=NULL, $secret=NULL) $res = $as->connect(MANAGER_HOST, MANAGER_USERNAME, MANAGER_SECRET); if ($res) { $channel = $dialstr; $exten = $calling; $context = $A2B->config["callback"]['context_preditctivedialer']; $priority = 1; $timeout = $A2B->config["callback"]['timeout'] * 1000; $application = ''; $callerid = $A2B->config["callback"]['callerid']; $account = $_SESSION["pr_login"]; $res = $as->Originate($channel, $exten, $context, $priority, $application, $data, $timeout, $callerid, $variable, $account, $async, $actionid); if ($res["Response"] == 'Error') { $error_msg = "<font face='Arial, Helvetica, sans-serif' size='2' color='red'><b>" . gettext("Error : The system cannot call you back, please inform the administrator") . " !!!</b></font><br>"; } // && DISCONNECTING $as->disconnect(); } else { $error_msg = gettext("Cannot connect to the asterisk manager!") . "<br>" . gettext("Please check the manager configuration..."); } } else { $error_msg = "<font face='Arial, Helvetica, sans-serif' size='2' color='red'><b>" . gettext("Error : You have to specify your phonenumber and the number you wish to call") . " !!!</b></font><br>"; } } $customer = $_SESSION["pr_login"]; $DBHandle = DbConnect(); if ($FG_DEBUG == 3) {
function preview_form($pDB, $smarty, $module_name, $local_templates_dir, $formCampos, $oForm, $arrConf, $arrValoresGestionAnterior) { require_once "/var/lib/asterisk/agi-bin/phpagi-asmanager.php"; $oForm->setViewMode(); // Esto es para activar el modo "preview" $pInterfazdeAgente = new paloSantoInterfazdeAgente($pDB); $iNumForm = $pInterfazdeAgente->getForm($_SESSION['id_campania']); $pDBsqlite = new paloDB("sqlite3:////var/www/db/acl.db"); $pInterfazdeAgenteSqlite = new paloSantoInterfazdeAgente($pDBsqlite); $extensionAgente = $pInterfazdeAgenteSqlite->getExtensionAgente($_SESSION['elastix_user']); if (isset($_GET['telefono'])) { // si el telefono viene en la barra de direccion $destinatario = $_GET['telefono']; } if (!isset($iNumForm) || !is_numeric($iNumForm)) { return false; } $oDataForm = new paloSantoDataForm($pDB); $arrDataForm = $oDataForm->getFormularios($iNumForm); if (is_array($arrValoresGestionAnterior)) { $arrFieldForm = $oDataForm->obtener_campos_formulario($iNumForm, NULL, $_SESSION['telefono'], $_SESSION, $arrValoresGestionAnterior); // envío arreglo $_GET } else { $arrFieldForm = $oDataForm->obtener_campos_formulario($iNumForm, NULL, $_SESSION['telefono'], $_SESSION); } $smarty->assign("id_formulario_actual", $iNumForm); $smarty->assign("style_field", "style='display:none;'"); $smarty->assign("formulario", $arrFieldForm); if (isset($destinatario) && $destinatario != "") { // si hay telefono seteado llamar al numero $astman = new AGI_AsteriskManager(); if (!$astman->connect($arrConf['asterisk_host'], $arrConf['asterisk_user'], $arrConf['asterisk_pass'])) { $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("No es posible conectarse a la PBX.")); } else { $result = $astman->Originate("Local/{$extensionAgente}@from-internal", $extensionAgente, "hispana-callcenter", 1, null, null, null, null, "DEST={$destinatario}", null); } } $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/preview.tpl", _tr('Gestión de clientes')); // hay que pasar el arreglo return $contenidoModulo; }
} $smarty->assign('extensions', $extensions); $smarty->display('extensions-realtime.tpl'); /*?><pre>extensions:<?print_r($extensions);?></pre><? */ } if ($_REQUEST['action'] == 'originatecall') { //$extennum - номер экстена, на который позвонить $databaseUser = $ami->database_show('AMPUSER'); $databaseCall = $ami->database_show('CURRCALL'); //найдем нашего агента и вернем данные только по нему //все взаимодействие через переменную сессий $AgentAccount if (isset($LogExtenNum)) { $LogExtenName = $databaseUser["/AMPUSER/{$LogExtenNum}/cidname"]; $CurrCallNum = $databaseCall["/CURRCALL/{$LogExtenNum}/NUM"]; $CurrCallName = $databaseCall["/CURRCALL/{$LogExtenNum}/NAME"]; $data[$LogExtenNum] = $ami->Originate("LOCAL/" . $LogExtenNum . "@from-internal", $extennum, 'from-internal', '1', '30000', '"' . $LogExtenNum . '" <' . $LogExtenName . '>', '', '', '', ''); // $smarty->assign('data', $data); // $smarty->display('operator-json2d.tpl'); echo json_encode($data); } } if ($_REQUEST['action'] == 'transfer') { //$extennum - номер экстена, на который передресовывать //$redirchan - канал, который передресовывать //найдем нашего агента и вернем данные только по нему //все взаимодействие через переменную сессий $AgentAccount if (isset($LogExtenNum)) { $LogExtenName = $databaseUser["/AMPUSER/{$LogExtenNum}/cidname"]; $CurrCallNum = $databaseCall["/CURRCALL/{$LogExtenNum}/NUM"]; $CurrCallName = $databaseCall["/CURRCALL/{$LogExtenNum}/NAME"]; $data[$LogExtenNum] = $ami->Redirect($redirchan, '', $extennum, 'from-internal', '1');