Next contact

This commit is contained in:
fbsanchez 2019-06-03 13:04:49 +02:00
parent b4dcf4a6f1
commit 13086b596c
2 changed files with 60 additions and 0 deletions

View File

@ -739,6 +739,41 @@ if (!empty($network_interfaces)) {
?>
<script type="text/javascript">
$(document).ready (function () {
setInterval(() => {
last = $('.progress_text').text().split(' ')[0]*1;
width = $(".progress").width() / $('.progress').parent().width() * 100;
width_interval = <?php echo (100 / $agent['intervalo']); ?>;
if (last % 10 == 0) {
$.post({
url: "ajax.php",
data: {
page: 'operation/agentes/ver_agente',
id_agente: <?php echo $id_agente; ?>,
refresh_contact: 1
},
success: function(data) {
try {
val = JSON.parse(data);
$('.progress_text').text(val['last_contact']+' s');
$('.progress').width(val['progress']+"%");
} catch (e) {
console.error(e);
$('.progress_text').text((last -1) + " s");
if (width < 100) {
$('.progress').width((width+width_interval) + "%");
}
}
}
});
} else {
$('.progress_text').text((last -1) + " s");
if (width < 100) {
$('.progress').width((width+width_interval) + "%");
}
}
}, 1000);
$("#agent_data_main").find("thead").click (function () {
close_table('#agent_data_main');
})

View File

@ -62,6 +62,31 @@ if (is_ajax()) {
$agent_alias = get_parameter('alias', '');
$agents_inserted = get_parameter('agents_inserted', []);
$id_group = (int) get_parameter('id_group');
$refresh_contact = get_parameter('refresh_contact', 0);
if ($refresh_contact) {
$id_agente = get_parameter('id_agente', 0);
if ($id_agente > 0) {
$d = db_get_row(
'tagente',
'id_agente',
$id_agente
);
$progress = agents_get_next_contact($id_agente);
echo json_encode(
[
'progress' => $progress,
'last_contact' => ($d['intervalo'] * (100 - $progress) / 100),
]
);
}
return;
}
if ($get_agents_group_json) {
$id_group = (int) get_parameter('id_group');
$recursion = (bool) get_parameter('recursion');