|
|
|
|
const enviarMensagem = (dataSend) => {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: `${server_api}/integracao/media/api/agente/enviarMensagem`,
|
|
|
|
|
type: "POST",
|
|
|
|
|
data: JSON.stringify(dataSend),
|
|
|
|
|
success: function (res) {
|
|
|
|
|
//console.log(res)
|
|
|
|
|
},
|
|
|
|
|
error: function (res) {
|
|
|
|
|
$('.chat-window').append(`<div class="sender"><span class="sender-message">MENSAGEM N<EFBFBD>O FOI ENVIADA!</span></div>`)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const listaMensagem = (uniqueid) => new Promise((resolve) => {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: `${server_api}/integracao/media/api/agente/listarMensagem`,
|
|
|
|
|
type: "POST",
|
|
|
|
|
data: JSON.stringify({
|
|
|
|
|
uniqueid
|
|
|
|
|
}),
|
|
|
|
|
success: function (res) {
|
|
|
|
|
localStorage.removeItem('obj_contact')
|
|
|
|
|
localStorage.setItem('obj_contact', JSON.stringify(res))
|
|
|
|
|
resolve(res)
|
|
|
|
|
},
|
|
|
|
|
error: function (res) {
|
|
|
|
|
alert('Nao foi possivel carregar as listas de mensagens.')
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const listarAgentesDisponivel = () => new Promise((resolve) => {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: `${server_api}/integracao/media/api/agente/listarAgentesDisponivel`,
|
|
|
|
|
type: "GET",
|
|
|
|
|
success: function (res) {
|
|
|
|
|
resolve(res)
|
|
|
|
|
},
|
|
|
|
|
error: function (res) {
|
|
|
|
|
alert('Nao foi possivel carregar as listas de agentes.')
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const listarAtendimentoAgente = (matricula) => new Promise((resolve) => {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: `${server_api}/integracao/media/api/agente/listarAtendimentoAgente`,
|
|
|
|
|
type: "POST",
|
|
|
|
|
data: JSON.stringify({
|
|
|
|
|
matricula
|
|
|
|
|
}),
|
|
|
|
|
success: function (res) {
|
|
|
|
|
localStorage.removeItem('obj_notification')
|
|
|
|
|
localStorage.setItem('obj_notification', JSON.stringify(res))
|
|
|
|
|
resolve(res)
|
|
|
|
|
},
|
|
|
|
|
error: function (res) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const listarPausasAgente = (matricula) => new Promise((resolve) => {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: `${server_api}/integracao/media/api/agente/listarPausasAgente`,
|
|
|
|
|
type: "POST",
|
|
|
|
|
data: JSON.stringify({
|
|
|
|
|
matricula
|
|
|
|
|
}),
|
|
|
|
|
success: function (res) {
|
|
|
|
|
resolve(res)
|
|
|
|
|
},
|
|
|
|
|
error: function (res) {
|
|
|
|
|
alert('Nao foi possivel carregar as listas de pausa.')
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const entrarPausa = (id_pausa, matricula) => new Promise((resolve) => {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: `${server_api}/integracao/media/api/agente/entrarPausa`,
|
|
|
|
|
type: "POST",
|
|
|
|
|
data: JSON.stringify({
|
|
|
|
|
id_pausa,
|
|
|
|
|
matricula
|
|
|
|
|
}),
|
|
|
|
|
success: function (res) {
|
|
|
|
|
if (res.status == 'success') {
|
|
|
|
|
alert('Agente em Pausa!')
|
|
|
|
|
resolve(res)
|
|
|
|
|
} else {
|
|
|
|
|
alert(res.message)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
error: function (res) {
|
|
|
|
|
alert('N<EFBFBD>o foi poss<EFBFBD>vel atribuir a pausa no momento!')
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const sairPausa = (matricula) => new Promise((resolve) => {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: `${server_api}/integracao/media/api/agente/sairPausa`,
|
|
|
|
|
type: "POST",
|
|
|
|
|
data: JSON.stringify({
|
|
|
|
|
matricula
|
|
|
|
|
}),
|
|
|
|
|
success: function (res) {
|
|
|
|
|
alert('Pausa removida do Agente!')
|
|
|
|
|
resolve(res)
|
|
|
|
|
},
|
|
|
|
|
error: function (res) {
|
|
|
|
|
alert('Nao foi possivel carregar as listas de pausa.')
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const entrar = (matricula, queue) => new Promise((resolve) => {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: `${server_api}/integracao/media/api/agente/entrar`,
|
|
|
|
|
type: "POST",
|
|
|
|
|
data: JSON.stringify({
|
|
|
|
|
id_fila: queue,
|
|
|
|
|
matricula
|
|
|
|
|
}),
|
|
|
|
|
success: function (res) {
|
|
|
|
|
resolve(res)
|
|
|
|
|
},
|
|
|
|
|
error: function (res) {
|
|
|
|
|
resolve(res)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const sair = (matricula) => {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: `${server_api}/integracao/media/api/agente/sair`,
|
|
|
|
|
type: "POST",
|
|
|
|
|
data: JSON.stringify({
|
|
|
|
|
matricula
|
|
|
|
|
}),
|
|
|
|
|
success: function (res) {
|
|
|
|
|
if (res.status == 'success') {
|
|
|
|
|
alert('Desconectado do sistema!')
|
|
|
|
|
window.close()
|
|
|
|
|
} else {
|
|
|
|
|
alert(res.message)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
error: function (res) {
|
|
|
|
|
alert('Nao foi possivel desconectar do sistema.')
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const finalizarAtendimento = (matricula, uniqueid) => new Promise((resolve) => {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: `${server_api}/integracao/media/api/agente/finalizarAtendimento`,
|
|
|
|
|
type: "POST",
|
|
|
|
|
data: JSON.stringify({
|
|
|
|
|
matricula,
|
|
|
|
|
uniqueid
|
|
|
|
|
}),
|
|
|
|
|
success: function (res) {
|
|
|
|
|
if (res.status == "success") {
|
|
|
|
|
alert('Atendimento foi finalizado!')
|
|
|
|
|
notifications({
|
|
|
|
|
matricula,
|
|
|
|
|
uniqueid,
|
|
|
|
|
action: 'finish'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
resolve(res)
|
|
|
|
|
},
|
|
|
|
|
error: function (res) {
|
|
|
|
|
alertModal(
|
|
|
|
|
`<h4>OPS... HOUVE UM PROBLEMA  </h4><img id="imgReconnect" width="25px" src="integracao/simpleschat/images/alert.png">
|
|
|
|
|
<p>N<EFBFBD>o foi poss<EFBFBD>vel finalizar atendimento!</p>
|
|
|
|
|
<p>Error: ${res}</p>`,
|
|
|
|
|
'OPS!!!'
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const statusAgente = (matricula) => new Promise((resolve) => {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: `${server_api}/integracao/media/api/agente/statusAgente`,
|
|
|
|
|
type: "POST",
|
|
|
|
|
data: JSON.stringify({
|
|
|
|
|
matricula
|
|
|
|
|
}),
|
|
|
|
|
success: function(res) {
|
|
|
|
|
localStorage.removeItem('obj_status')
|
|
|
|
|
localStorage.setItem('obj_status', JSON.stringify(res))
|
|
|
|
|
resolve(res)
|
|
|
|
|
},
|
|
|
|
|
error: function(res) {
|
|
|
|
|
console.log(res)
|
|
|
|
|
alertModal(
|
|
|
|
|
`<h4>RECONECTANDO, AGUARDE  </h4><img id="imgReconnect" width="25px" src="integracao/simpleschat/images/loading.gif">`,
|
|
|
|
|
'Estamos restabelecendo a conex o com nosso sistema!'
|
|
|
|
|
)
|
|
|
|
|
console.log('statusAgente: ' + res.responseText)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const atualizaAgente = () => new Promise((resolve) => {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: window.location.origin + '/index.php?idProg=14&idSubProg=3&ajax=1&acao=atualiza',
|
|
|
|
|
type: "GET",
|
|
|
|
|
success: function(res){
|
|
|
|
|
resolve(res)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const transferirAtendimento = (origem, destino, uniqueid) => new Promise((resolve) => {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: `${server_api}/integracao/media/api/agente/transferirAtendimento`,
|
|
|
|
|
type: "POST",
|
|
|
|
|
data: JSON.stringify({
|
|
|
|
|
matricula_origem: origem,
|
|
|
|
|
matricula_destino: destino,
|
|
|
|
|
uniqueid
|
|
|
|
|
}),
|
|
|
|
|
success: function (res) {
|
|
|
|
|
if (res.status == 'success') {
|
|
|
|
|
alert('Atendimento foi transferido!')
|
|
|
|
|
resolve(res)
|
|
|
|
|
} else {
|
|
|
|
|
alert(res.message)
|
|
|
|
|
}
|
|
|
|
|
resolve(res)
|
|
|
|
|
},
|
|
|
|
|
error: function (res) {
|
|
|
|
|
alertModal(
|
|
|
|
|
`<h4>OPS... HOUVE UM PROBLEMA  </h4><img id="imgReconnect" width="25px" src="integracao/simpleschat/images/alert.png">
|
|
|
|
|
<p>N<EFBFBD>o foi poss<EFBFBD>vel carregar as infoemacoes do agente!</p>
|
|
|
|
|
<p>Error: ${res}</p>`,
|
|
|
|
|
'OPS!!!'
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const marcarMensagemVista = (uniqueid) => {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: `${server_api}/integracao/media/api/agente/marcarMensagemVista`,
|
|
|
|
|
type: "POST",
|
|
|
|
|
data: JSON.stringify({
|
|
|
|
|
uniqueid
|
|
|
|
|
}),
|
|
|
|
|
success: function (res) {
|
|
|
|
|
//console.log('success')
|
|
|
|
|
},
|
|
|
|
|
error: function (res) {
|
|
|
|
|
alert('Nao foi possivel carregar as informacoes do agente.')
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|