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.
 
 
 
 
 
 

95 lines
3.5 KiB

<?php
$tpLayout = 1;
$idCont = $_GET["idContato"];
$identificador = $_GET["identificador"];
$idCamp = $_GET["idCamp"];
$idLista = $_GET["idLista"];
$nomeTpl = "supervisao/EncerraContatoCampanha.tpl";
$ListaStatus = GetStatusDiscador(0);
$query = "select status, nome from pbx_supervisor_agentes where matricula = (select matricula from pbx_campanha_operacao where cmp_id = $idCamp and list_id = $idLista and cont_id = $idCont)";
//echo $query;
$result = pg_query($dbcon, $query);
$dados = pg_fetch_array($result);
$agenteStatus = $dados["status"];
$agenteNome = $dados["nome"];
if ($agenteStatus) {
$msg = $agenteNome; //"Este contato encontra-se pendente de encerramento para o Agente: $agenteNome! ";
$msg2 = $agenteStatus; //"O status deste agente neste momento é: $agenteStatus! ";
}
if ($_POST["btEncerra"]) {
$idCont = $_POST["idContato"];
$identificador = $_GET["identificador"];
$idCamp = $_POST["idCamp"];
$idLista = $_POST["idLista"];
$status = $_POST["ListaStatus"];
$mensagem = $_POST["msg_discador"];
$matricula = GetMatricula();
//$teste = "idContato: ".$idCont."/ IdCamp: ".$idCamp."/ idLista: ".$idLista."/ status: ".$status."/ matricula: ".$matricula."/ mensagem: ".$mensagem;
//echo $teste;
if (!$status) {
$msgErro = "É necessário selecionar um status!";
} else if (!$mensagem) {
$msgErro = "Por favor digite uma mensagem para encerramento!";
} else {
$query = "update pbx_campanha_operacao set cmpo_status = 1, matricula = '$matricula' where cmp_id = $idCamp and list_id = $idLista and cont_id = $idCont";
$result = pg_query($dbcon, $query);
//echo $query;
$query1 = "update pbx_campanha_contato set cont_discado = 1, cont_status = $status, cont_msg = '$mensagem' ,matricula = '$matricula' where cmp_id = $idCamp and list_id = $idLista and cont_id = $idCont;";
$result = pg_query($dbcon, $query1);
//echo $query1;
}
if ($result) {
$GLOBALS['jsStartup'][] = "window.close()";
$GLOBALS['jsStartup'][] = "window.opener.ResetForm();";
} else {
if (empty($msgErro))
$msgErro = "Não foi possível realizar a operação!";
$GLOBALS['jsStartup'][] = "alert('$msgErro');";
}
}
$sZw = '100%';
$sZh = '50px';
$styleAdd = '';
// $sZmsg_discador = sprintf("width: %s;height: %s;padding:0;margin:0;%s", $sZw, $sZh, $styleAdd);
// $sZListaStatus = sprintf("width: %s;height: %s;padding:0;margin:0;%s", '80%', '26px', $styleAdd);
//print $linhas;
$smarty->assign('ListaStatus', $ListaStatus);
$smarty->assign('idCont', $idCont);
$smarty->assign('identificador', $identificador);
$smarty->assign('idCamp', $idCamp);
$smarty->assign('idLista', $idLista);
$smarty->assign('msg', $msg);
$smarty->assign('msg2', $msg2);
GetTemplate($smarty, $nomeTpl);
function GetStatusDiscador() {
$lista = '';
/*
* Pega a lista de status da operação.
*/
$query = "select ctst_id, ctst_nome from pbx_campanha_contato_status where ctst_status = 1 order by ctst_nome";
$result = pg_query($query);
$sel = $value ? " selected" : "";
$lista = "<option value=\"0\"$sel>---------------</option>";
while ($dados = @pg_fetch_row($result)) {
$sel = ($value == $dados[0]) ? " selected" : "";
$id = $dados[0];
$desc = $dados[1];
$lista .= "<option value=\"$id\"$sel>$desc</option>";
}
$lista .= "</select>";
return $lista;
}
?>