Browse Source

Correções nos horários, nas funções da URA e inserção da função para apagar dados do sqlite ao apagar uma fila

1.9
Matheo Bonucia 2 months ago
parent
commit
f141683c0f
  1. 77
      admin/cadHorarios.php
  2. 2
      admin/funcoes.php
  3. 3
      admin/queues.php

77
admin/cadHorarios.php

@ -64,9 +64,16 @@ if (IsPostBack()) {
values( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)";
$query = sprintf($query, QuotedStr($id), QuotedStr($horario_inicio), QuotedStr($horario_fim), QuotedStr($todos_dias_semana), QuotedStr($semana ? $semana : '0'), QuotedStr($semana_fim ? $semana_fim : '0'), QuotedStr($todos_dias_mes), QuotedStr($dias_mes ? $dias_mes : '0'), QuotedStr($dias_mes_fim ? $dias_mes_fim : '0'), QuotedStr($todos_mes), QuotedStr($mes ? $mes : '0'), QuotedStr($mes_fim ? $mes_fim : '0'), QuotedStr($opcaoH), QuotedStr($acaoH), QuotedStr($feriado), $org_id, QuotedStr(Acoes_asterisk($dbcon, $opcaoH, $acaoH)));
$result = pg_query($dbcon, $query);
if(!$result){
throw new Exception('Erro ao registrar item no horário: '. pg_last_error($dbcon));
}
$query = sprintf("update pbx_horarios set status = 0 where id = %s and org_id = %d", $id, $org_id);
$result = pg_query($dbcon, $query);
if(!$result){
throw new Exception("Erro ao atualizar horário: ". pg_last_error($dbcon));
}
} else if (isset($_POST["btEditar"])) {
$query = "UPDATE pbx_horarios_itens SET "
. "horario_inicio = %s, "
@ -148,7 +155,7 @@ function SetInicio($data = null)
function DiasSemana($dia)
{
$semana = array("Domingo" => "sun", "Segunda" => "mon", "Terça" => "tue", "Quarta" => "wed", "Quinta" => "thu", "Sexta" => "fri", "Sabado" => "sat");
$semana = array("Domingo" => "sun", "Segunda" => "mon", "Terça" => "tue", "Quarta" => "wed", "Quinta" => "thu", "Sexta" => "fri", "Sábado" => "sat");
$opt = "";
$sel = "";
@ -216,28 +223,21 @@ function GetHorarios($dbcon, $id, $acaoH)
$mesesDisp = array("jan" => "Jan", "feb" => "Fev", "mar" => "Mar", "apr" => "Abr", "may" => "Mai", "jun" => "Jun", "jul" => "Jul", "aug" => "Ago", "sep" => "Set", "oct" => "Out", "nov" => "Nov", "dec" => "Dez");
$semanaDisp = array("sun" => "Dom", "mon" => "Seg", "tue" => "Ter", "wed" => "Qua", "thu" => "Qui", "fri" => "Sex", "sat" => "Sab");
$query = "select id, nome, discar, opcao_nao, acao_nao from pbx_horarios where id = $id and org_id = $org_id";
$query = "select id, nome, discar, opcao_nao, acao_nao from pbx_horarios where id = $id and org_id = $org_id";
$result = pg_query($dbcon, $query);
$row = pg_fetch_array($result);
$nome = $row["nome"];
$discar = $row["discar"];
$opcao_nao = $row["opcao_nao"] ? $row["opcao_nao"] : '-';
//$acao_nao = $row["acao_nao"] ? $row["acao_nao"] : '-';
if($opcao_nao == "ramal"){
$acao_nao = $row["acao_nao"] ? $row["acao_nao"] : '-';
$acao_nao = strval($org_id) . $acao_nao;
}else {
$acao_nao = $row["acao_nao"] ? $row["acao_nao"] : '-';
}
$acao_nao = $row["acao_nao"] ? $row["acao_nao"] : '-';
$query = "select * from ( select a.id, a.id_horario, a.horario_inicio, a.horario_fim, a.todos_dias_semana, a.semana,
a.semana_fim, a.todos_dias_mes, a.dias_mes, a.dias_mes_fim, a.todos_mes, a.mes,
a.mes_fim, b.name as opcao, a.acao as acao, case when(feriado = 'A')then 0 else 1 end as feriado
from pbx_horarios_itens a
left outer join pbx_opcoes b on b.value = a.opcao
left outer join pbx_opcao_acao c on c.opcao = a.opcao and c.id = a.acao
left outer join pbx_opcoes b on b.value = a.opcao and b.org_id = a.org_id
left outer join pbx_opcao_acao c on c.opcao = a.opcao and c.id = a.acao and c.org_id = a.org_id
where id_horario = $id and a.org_id = $org_id) as itens order by feriado asc, id";
$result = pg_query($dbcon, $query);
@ -256,17 +256,8 @@ function GetHorarios($dbcon, $id, $acaoH)
$todos_mes = $row["todos_mes"] ? 'sim' : 'nao';
$mes = $row["mes"] ? $mesesDisp[$row["mes"]] : '-';
$mes_fim = $row["mes_fim"] ? $mesesDisp[$row["mes_fim"]] : '-';
$opcaoH = $row["opcao"] ? $row["opcao"] : '-';
//$acaoH = $row["acao"] ? $row["acao"] : '-';
if($opcaoH == "Ramal"){
$acaoH = $row["acao"] ? $row["acao"] : '-';
$acaoH = $org_id . $acaoH;
}else {
$acaoH = $row["acao"] ? $row["acao"] : '-';
}
$acaoH = $row["acao"] ? $row["acao"] : '-';
$feriado = $row['feriado'] == '0';
$feriado = sprintf('<img src="images/%s" width="12" height="12" border="0" title="%s">', ($feriado ? "button_ok16.png" : "fecha16.png"), ($feriado ? "Feriado!" : "Dia Normal!"));
$link = sprintf('<a href="index.php?idProg=11033&pbxRequest=1&acaoH=%s&id=%s&deletar=%s">Apagar</a>', $acaoH, $row["id_horario"], $row["id"]);
@ -436,15 +427,15 @@ function GetHorarios($dbcon, $id, $acaoH)
}
} else {
if (!document.getElementById('opcaoH').value) {
alert('Informe uma "Opção" para o Horário!');
alert('Informe uma "opção" para o horário!');
return false;
} else if (!document.getElementById('acaoH').value) {
alert('Informe a "Ação" para o Horário"!');
alert('Informe a "ação" para o horário"!');
return false;
}
if (!document.getElementById('feriado_sim').checked && !document.getElementById('feriado_nao').checked) {
alert('Marque a Opção Feriado"!');
alert('Marque a opção Feriado"!');
return false;
}
}
@ -471,7 +462,7 @@ function GetHorarios($dbcon, $id, $acaoH)
<table width="98%" border="1" align="center" cellpadding="0" cellspacing="0" class="tabela">
<tr bordercolor="#EAEAEA" class="cabecalho" background="img/button03.gif">
<td width="99%" class="cabecalho">
<div align="center">CADASTRO DE HORÁRIOS
<div align="center">CADASTRO DE HORÁRIOS
<input name="id" type="hidden" id="id2" value="<?= $id; ?>" />
<input name="acao" type="hidden" id="id2" value="<?= $acao; ?>" />
<input name="numItens" type="hidden" id="id" value="<?= $numItens; ?>" />
@ -515,7 +506,7 @@ function GetHorarios($dbcon, $id, $acaoH)
<tr>
<td>
<fieldset>
<legend class="labels">Opções fora de Horário:</legend>
<legend class="labels">Opções fora de horário:</legend>
<select style="width: 160px" name="opcao_nao" class="validate[optional] caixas" id="opcao_nao" onchange="ajaxComboBox('admin/popula.php?id=<?= $acao_nao; ?>', 'acao_nao', 'opcao_nao', '<?= $acao2; ?>');">
<?= _GetOpcoes($dbcon, $opcao_nao, 0, 1); ?>
</select>
@ -530,7 +521,7 @@ function GetHorarios($dbcon, $id, $acaoH)
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA">
<td class="labels">
<fieldset>
<legend class="labels">Horários</legend>
<legend class="labels">Horários:</legend>
In&iacute;cio
<input name="horario_inicio" type="text" class="caixas" id="horario_inicio" size="5" maxlength="5" value="<?= $horario_inicio; ?>" onkeydown="formataHora('horario_inicio', event);" />
Fim
@ -562,7 +553,7 @@ function GetHorarios($dbcon, $id, $acaoH)
<tr>
<td valign="top">
<fieldset>
<legend class="labels">Início</legend>
<legend class="labels">Início</legend>
<select name="semana" size="1" id="semana" disabled="disabled">
<?= DiasSemana($semana); ?>
</select>
@ -585,7 +576,7 @@ function GetHorarios($dbcon, $id, $acaoH)
</td>
<td width="33%" valign="top">
<fieldset>
<legend class="labels">Dia do Mês</legend>
<legend class="labels">Dia do Mês</legend>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" class="labels">
@ -597,7 +588,7 @@ function GetHorarios($dbcon, $id, $acaoH)
<tr>
<td>
<fieldset>
<legend class="labels">Início</legend>
<legend class="labels">Início</legend>
<select name="dias_mes" size="1" id="dias_mes" disabled="disabled">
<?= DiasMes($dias_mes); ?>
</select>
@ -629,7 +620,7 @@ function GetHorarios($dbcon, $id, $acaoH)
<tr>
<td width="50%" valign="top">
<fieldset>
<legend class="labels">In&iacute;cio</legend>
<legend class="labels">Início</legend>
<select name="mes" size="1" id="mes" disabled="disabled">
<?= Meses($mes); ?>
</select>
@ -673,13 +664,13 @@ function GetHorarios($dbcon, $id, $acaoH)
<legend class="labels">Feriado</legend>
<span class="style1">
Sim<input name="feriado" type="radio" class="labels" id="feriado_sim" value="A" <?= (!$feriado && !is_null($feriado) ? 'checked="checked"' : ''); ?> />
Não<input name="feriado" type="radio" class="labels" id="feriado_nao" value="I" <?= ($feriado || is_null($feriado) ? 'checked="checked"' : ''); ?> />
Não<input name="feriado" type="radio" class="labels" id="feriado_nao" value="I" <?= ($feriado || is_null($feriado) ? 'checked="checked"' : ''); ?> />
</span>
</fieldset>
</td>
<td>
<fieldset>
<legend class="labels">Ação</legend>
<legend class="labels">Ação</legend>
<span class="style1">
<?php if ($_GET['action'] == 'edit') { ?>
<input name="btEditar" type="submit" class="labels" onclick="SetAcao('incluir');" id="btNovoHorario" value="Editar" />
@ -694,7 +685,7 @@ function GetHorarios($dbcon, $id, $acaoH)
</td>
</tr>
<tr>
<td class="labels">Horários Disponíveis </td>
<td class="labels">Horários Disponíveis </td>
</tr>
<tr>
<td height="130" valign="top" class="labels">
@ -702,27 +693,27 @@ function GetHorarios($dbcon, $id, $acaoH)
<table width="98%" align="center" border="1" cellspacing="1" cellpadding="0" class="grid">
<tr>
<th rowspan="2" align="center" bgcolor="#999999"><span title="Feriado">Feriado</span></th>
<th colspan="2" align="center" bgcolor="#999999">Horário</th>
<th colspan="2" align="center" bgcolor="#999999">Horário</th>
<th colspan="3" align="center" bgcolor="#999999">Dia da semana</th>
<th colspan="3" align="center" bgcolor="#999999">Dia do Mês </th>
<th colspan="3" align="center" bgcolor="#999999">Dia do Mês </th>
<th colspan="3" align="center" bgcolor="#999999">Meses</th>
<th colspan="2" align="center" bgcolor="#999999">Caso Combine</th>
<th rowspan="2" align="center" bgcolor="#999999" colspan="2">Ações</th>
<th rowspan="2" align="center" bgcolor="#999999" colspan="2">Ações</th>
</tr>
<tr class="labels">
<th bgcolor="#999999">Início</th>
<th bgcolor="#999999">Início</th>
<th bgcolor="#999999">Fim</th>
<th bgcolor="#999999">Todos</th>
<th bgcolor="#999999">Inicio</th>
<th bgcolor="#999999">Fim</th>
<th bgcolor="#999999">Todos</th>
<th bgcolor="#999999">Início</th>
<th bgcolor="#999999">Início</th>
<th bgcolor="#999999">Fim</th>
<th bgcolor="#999999">Todos</th>
<th bgcolor="#999999">Início</th>
<th bgcolor="#999999">Início</th>
<th bgcolor="#999999">Fim</th>
<th bgcolor="#999999">Opção</th>
<th bgcolor="#999999">Ação</th>
<th bgcolor="#999999">Opção</th>
<th bgcolor="#999999">Ação</th>
</tr>
<?= $linhas; ?>
</table>

2
admin/funcoes.php

@ -472,7 +472,7 @@ function gera_arquivos($dbcon, $tipo, $reload = 1, $reloadUra = 1) {
* Esta opcao desvia a chamada para uma ura interativa personalizada.
*/
if ($uraAtiva) {
fwrite($escreve, sprintf("[ura-%s]\n", trim($dados['id_asterisk'])));
fwrite($escreve, sprintf("[ura-%s]\n", trim($dados['id'])));
fwrite($escreve, "include => padrao\n");
fwrite($escreve, "exten => s,1,Answer()\n");
fwrite($escreve, 'exten => s,n,ExecIf($["${ISNULL(${CDR(direcao)})}" = "1"]?Set(CDR(direcao)=I))' . "\n");

3
admin/queues.php

@ -37,6 +37,9 @@ if ($acao == "deleta") {
// //gera arquivos e executa o reload dos dados no asterisk
// gera_arquivos($dbcon, 'QUEUES_GRUPOS');
Ajusta_tabelas('filas', $numero, $dbcon);
$apagar = ['ORG_ID', 'ORG_FILA', 'TIPO', 'NOME_APP', 'NUMERO', 'ID_APP'];
removeItemSqlite($dbcon, $apagar, $numero, $org_id);
}
?>

Loading…
Cancel
Save