$(function () { const url = new URL(window.location.href); const matricula = url.searchParams.get("matricula"); if (matricula) { atendimentoAgente(matricula) atualizaStatusAgente(matricula) } localStorage.setItem('monitorRamaisStatus', $("input[name='conframal']:checked").val()) $('input[name=conframal]').on('change', () => { localStorage.removeItem('monitorRamaisStatus') localStorage.setItem('monitorRamaisStatus', $("input[name='conframal']:checked").val()) }) resizegrid() }) const desconectMesa = async () => { function req() { return $.ajax({ url: 'index.php?idProg=307&pbxRequest=1&ajax=desconnect', type: "GET" }); } await req().then(() => { window.location.href = "index.php?idProg=307&pbxRequest=1"; }) } const criarGrid = (data) => { let cont = 0 let line = '' let rline = '' let cdata = 0 data.forEach((e) => { cont++ line += e.row if (cont > 4 || cdata >= data.length) { rline += `${line}` line = '' cont = 0 } cdata++ }) if(cont <= 4){ rline += `${line}` } $('#dadosContato').append(rline); } const HangupCall = (id) => { $.ajax({ url: "index.php?idProg=307&pbxRequest=1&ajax=hangup&f=" + id, type: "GET", success: function (res) { if (res) { console.log(res) } } }); } const AtualizaChamdas = () => { if(!localStorage.getItem('monitorRamaisStatus')){ return } $.ajax({ url: "index.php?idProg=307&pbxRequest=1&ajax=ramais", type: "GET", success: function (res) { if (res) { let lrow = [] let crow = 0 Object.keys(res).forEach((el) => { if (res[el].Status == localStorage.getItem('monitorRamaisStatus') || res[el].Status.indexOf(localStorage.getItem('monitorRamaisStatus')) >= 0) { let direct = '' if (res[el].StatusCall == 'E') { direct = res[el].CallInput + ` ` } else if (res[el].StatusCall == 'S') { direct = res[el].CallOutput + ` ` } let status = ` LIVRE` if (direct) { status = ` OCUPADO` } else if (res[el].Status == "UNKNOWN") { status = ` INATIVO` } // let tbl = `` // if (res[el].CallChannel) { // /** ATIVACAO DO HUNGUP NA TELA DA MESA **/ // tbl += `` // } // tbl += `
` lrow.push({ ramal: res[el].ObjectName, row: `

${res[el].ObjectName}

${res[el].Duration} - ${direct}

${status}

${res[el].Status}

`}) crow++ } }) $("#dadosContato").html('') criarGrid(lrow) } } }); setTimeout(function () { AtualizaChamdas(); var alturaTable = $('#dadosContato').height(); if (alturaTable + 300 > 1360) { $('#rodapeSite').css({"top": alturaTable + 300}); $('#tabLayout').css({"height": alturaTable + 325}); } }, 1200); } function timeDiffCalc(dateFuture, dateNow) { let diffInMilliSeconds = Math.abs(dateFuture - dateNow) / 1000; const days = Math.floor(diffInMilliSeconds / 86400); diffInMilliSeconds -= days * 86400; const hours = Math.floor(diffInMilliSeconds / 3600) % 24; diffInMilliSeconds -= hours * 3600; const minutes = Math.floor(diffInMilliSeconds / 60) % 60; diffInMilliSeconds -= minutes * 60; const seconds = Math.floor(diffInMilliSeconds); const adicionaZero = (numero) => { if (numero <= 9) { return "0" + numero; } else { return numero; } } let difference = ''; if (days > 0) { difference += (days === 1) ? `${days}` : `${days}`; } difference += adicionaZero(hours); difference += ":" + adicionaZero(minutes); difference += ":" + adicionaZero(seconds); return difference; } const resizegrid = () => { let heightgrid = $('#content').height() if(heightgrid > 600){ $('#rodapeSite').css({"top": $('#content').height() + 200}); } setTimeout(() => { resizegrid() }, 1000); }