Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions modules/campaign_monitoring/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ function _moduleContent(&$smarty, $module_name)

function manejarMonitoreo_HTML($module_name, $smarty, $sDirLocalPlantillas)
{
//obtenemos la extension actual del usuario activo
global $arrConf;
$pDB = new paloDB($arrConf['issabel_dsn']['acl']);
$pACL = new paloACL($pDB);
$user = $_SESSION['issabel_user'];
$extension = $pACL->getUserExtension($user);

$smarty->assign("MODULE_NAME", $module_name);
$smarty->assign(array(
'title' => _tr('Campaign Monitoring'),
Expand Down Expand Up @@ -106,6 +113,7 @@ function manejarMonitoreo_HTML($module_name, $smarty, $sDirLocalPlantillas)
'ETIQUETA_MAX_DURAC_LLAM' => _tr('Maximum Call Duration'),
'ETIQUETA_PROMEDIO_DURAC_LLAM' => _tr('Average Call Duration'),
'ETIQUETA_OCULTAR_AGENTES' => _tr('Hide Offline Agents'),
'EXTENSION_USUARIO' => _tr($extension)
));

return $smarty->fetch("file:$sDirLocalPlantillas/informacion_campania.tpl");
Expand Down
59 changes: 59 additions & 0 deletions modules/campaign_monitoring/libs/escuchar_agente.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
include("/var/www/html/libs/misc.lib.php");
include("/var/www/html/configs/default.conf.php");
include("/var/www/html/libs/paloSantoACL.class.php");
include_once("/var/www/html/libs/paloSantoDB.class.php");
session_name("issabelSession");
session_start();
$pDB = new paloDB($arrConf["issabel_dsn"]["acl"]);
$pACL = new paloACL($pDB);

if(isset($_SESSION["issabel_user"])){
$issabel_user = $_SESSION["issabel_user"];
} else {
$issabel_user = "";
echo " no eres usuario autorizado";
exit;
}

$extension_verificada = $pACL->getUserExtension($issabel_user);
//usamos solo la primera extensión como la valida para escuchar aunque el usuario tenga varias extensiones segun ampliacion codigo hgmnetwork.com 20-01-2019
$array_extensiones=explode(";",$extension_verificada);
$extension=$array_extensiones[0];//la primera por defecto
//echo " la extension verificada es $extension_escucha y el id de usuario de sesion es $issabel_user<br>";
//a la extension le quitamos el SIP/ o AGENT/ y dejamos solo el numero
$extension=preg_replace("/(SIP\/|AGENT\/i)/","",$extension);//dejamos solo el numero
//echo "<hr> la extension del usuario es $array_extensiones[0] y la del usuario actual es ".$_GET['agente']." <hr>";
//lo mismo con el agente
$agente =trim($_GET['agente']);
$agente=preg_replace("/(SIP\/|AGENT\/)/i","",$agente);//dejamos solo el numero

#permit=127.0.0.1/255.255.255.0,xxx.xxx.xxx.xxx ;(the ip address of the server this page is running on)
$strHost = "127.0.0.1";

#specify the username you want to login with (these users are defined in /etc/asterisk/manager.conf) o en manager_custom.conf
#por defecto usamos el usuario de php que viene
$strUser = "phpconfig";

#specify the password for the above user
$strSecret = "php[onfig";

$oSocket = fsockopen($strHost, 5038, $errnum, $errdesc) or die("Connection to host failed libs/escuchar_agente.php");

$from = $extension;//quien escucha
$to = $agente;//quien es escuchado el agente
fputs($oSocket, "Action: Login\r\n");
fputs($oSocket, "UserName: $strUser\r\n");
fputs($oSocket, "Secret: $strSecret\r\n\r\n");
$wrets=fgets($oSocket,128);
fputs($oSocket, "Action: Originate\r\n" );
fputs($oSocket, "CallerId: Whisper Agente: $agente\r\n");
//fputs($oSocket, "Channel: SIP/".$from."\r\n" );
fputs($oSocket, "Channel: local/".$from."\r\n" );
fputs($oSocket, "Application: ChanSpy\r\n" );
fputs($oSocket, "Data: SIP/".$to."\r\n\r\n" );
$wrets=fgets($oSocket,128);
sleep(3);

fclose($oSocket);
echo "Realizando Whisper al Agente $agente y a la extensión $extension";
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
{literal}{{#view tagName="tbody"}}
{{#each agentes}}
<tr {{bindAttr class="reciente desde"}}>
<td width="20%" nowrap="nowrap">{{canal}}</td>
<td width="20%" nowrap="nowrap"> OnClick="javascript:escuchar(this.innerHTML,'{/literal}{$EXTENSION_USUARIO}{literal}');"><img src="images/record.png" width="22" height="22" id="escucharAgente"/>{{canal}}</td>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aquí hay un error

Debe borrarse el > antes de OnClick

<td width="14%" nowrap="nowrap">{{estado}}</td>
<td width="23%" nowrap="nowrap">{{numero}}</td>
<td width="23%" nowrap="nowrap">{{troncal}}</td>
Expand Down Expand Up @@ -184,4 +184,4 @@ function toggleOffline(){
elem.style.display = 'none';
}
}
</script>
</script>
32 changes: 31 additions & 1 deletion modules/campaign_monitoring/themes/default/js/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,4 +534,34 @@ function mostrar_mensaje_error(s)
$('#issabel-callcenter-error-message').fadeOut();
}, 5000);
});
}
}

function escuchar(agente,extension){
//reemplazamos cualquier etiqueta dejando solo el texto del agente por ejemplo SIP/agente o A/agente Agent/agente SIP/5001 A/5001
const regex = /(<([^>]+)>)/ig;
var agente = agente.replace(regex, '');
//ahora quitamos el espacio inicial o cualquiera
var agente = agente.replace(' ', '');

$.ajax({
url: "/modules/campaign_monitoring/libs/escuchar_agente.php",
type: "get", //send it through get method
data: {
agente: agente,
extension: extension,
},

success: function(response) {
//Do Something
console.log(response);
},
error: function(xhr) {
//Do Something to handle error
console.log('error escuchar_agente.php');
console.log(xhr);
alert("Se ha producido un error al intentar escuchar al adengte.")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no está bien escrita la palabra agente

}
});


};