forked from SimplesIP/pabx-app
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.8 KiB
77 lines
2.8 KiB
2 years ago
|
<?php
|
||
|
|
||
|
/*
|
||
|
* To change this template, choose Tools | Templates
|
||
|
* and open the template in the editor.
|
||
|
*/
|
||
|
|
||
|
$tpLayout = 1;
|
||
|
$nomeTpl = 'callcenter/agente/pausa.tpl';
|
||
|
$valueBt = "Pausar";
|
||
|
|
||
|
if (IsPostBack()) {
|
||
|
$paramPausa = array();
|
||
|
$_SESSION["SetListaMotivo"] = $_POST["listaMotivo"];
|
||
|
$paramPausa = $_SESSION["paramPausa"];
|
||
|
|
||
|
if ($paramPausa[3] == 'agt') {
|
||
|
$cmd = sprintf("window.opener.PausaAgente('%s', '%s', '%s', '2');", $paramPausa[0], $paramPausa[1], $paramPausa[2]);
|
||
|
} else if ($paramPausa[3] == 'media') {
|
||
|
$urlAPI = $_SESSION['prm_chat_api'] . '/integracao/media/api/agente/';
|
||
|
|
||
|
if($paramPausa[4] == 'LIVRE'){
|
||
|
$res = request($urlAPI.'entrarPausa',['matricula' => $paramPausa[0],'id_pausa' => $_SESSION["SetListaMotivo"]]);
|
||
|
if($res['status'] == 'success'){
|
||
|
$jsStartup[] = "alert('Sucesso! Agente foi adicionado em Pausa!')";
|
||
|
} else {
|
||
|
$jsStartup[] = sprintf("alert('Erro! %s')", utf8_decode($res['message']));
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
$cmd = sprintf("window.opener.PausaDac('%s', 0);", $paramPausa[2]);
|
||
|
}
|
||
|
|
||
|
//if(IsAdmin ()) echo $cmd . " mot " . $_SESSION["SetListaMotivo"];
|
||
|
$jsStartup[] = $cmd;
|
||
|
$jsStartup[] = "window.close()";
|
||
|
} else {
|
||
|
$paramPausa = array();
|
||
|
$paramPausa[0] = isset($_GET['pausaAgente']) ? $_GET['pausaAgente'] : '0000';
|
||
|
$paramPausa[1] = isset($_GET['ramal']) ? $_GET['ramal'] : '0000';
|
||
|
$paramPausa[2] = $_GET['dac'];
|
||
|
$paramPausa[3] = isset($_GET['tipoPausa']) ? $_GET['tipoPausa'] : 'agt';
|
||
|
$paramPausa[4] = $_GET['status'];
|
||
|
$_SESSION["paramPausa"] = $paramPausa;
|
||
|
}
|
||
|
|
||
|
$msgSis = "";
|
||
|
$_SESSION[AGT_PAUSA_MOTIVO] = GetMotivoDef($dbcon);
|
||
|
|
||
|
$smarty->assign('menuAgente', "");
|
||
|
$smarty->assign('value', $valueBt);
|
||
|
$smarty->assign('motivoPausa', GetMotivo($dbcon, $_SESSION[AGT_PAUSA_MOTIVO]));
|
||
|
$smarty->assign('msgSis', $msgSis);
|
||
|
GetTemplate($smarty, $nomeTpl);
|
||
|
|
||
|
function request($url, $post = []) {
|
||
|
$ch = curl_init();
|
||
|
$isPost = $post ? 1 : 0;
|
||
|
|
||
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||
|
curl_setopt($ch, CURLOPT_POST, $isPost);
|
||
|
|
||
|
if ($isPost) {
|
||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post));
|
||
|
}
|
||
|
|
||
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
||
|
|
||
|
$head = curl_exec($ch);
|
||
|
curl_close($ch);
|
||
|
return json_decode($head, true);
|
||
|
}
|
||
|
|
||
|
?>
|