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.
299 lines
11 KiB
299 lines
11 KiB
<?php |
|
include "funcoes.php"; |
|
|
|
$interval = isset($_POST['interval']) ? $_POST['interval'] : ''; |
|
|
|
$intInicio = isset($_POST['intInicio']) ? $_POST['intInicio'] : ''; |
|
$intFim = isset($_POST['intFim']) ? $_POST['intFim'] : ''; |
|
|
|
$mInicio = isset($_POST['m_inicio']) ? $_POST['m_inicio'] : ''; |
|
$mFim = isset($_POST['m_fim']) ? $_POST['m_fim'] : ''; |
|
$vInicio = isset($_POST['v_inicio']) ? $_POST['v_inicio'] : ''; |
|
$vFim = isset($_POST['v_fim']) ? $_POST['v_fim'] : ''; |
|
$sInicio = isset($_POST['s_inicio']) ? $_POST['s_inicio'] : ''; |
|
$sFim = isset($_POST['s_fim']) ? $_POST['s_fim'] : ''; |
|
|
|
$ajax = isset($_GET['ajax']) ? $_GET['ajax'] : ''; |
|
$myIP = $_SERVER[HTTP_HOST]; |
|
|
|
if ($ajax) { |
|
$_SESSION['SSinterval'] = $interval; |
|
|
|
if ($_SESSION['SSinterval']) { |
|
$_SESSION['SSintInicio'] = '0'; |
|
$_SESSION['SSintFim'] = '0'; |
|
} else { |
|
$_SESSION['SSintInicio'] = $intInicio; |
|
$_SESSION['SSintFim'] = $intFim; |
|
} |
|
|
|
$_SESSION['SSmInicio'] = $mInicio; |
|
$_SESSION['SSmFim'] = $mFim; |
|
|
|
$_SESSION['SSvInicio'] = $vInicio; |
|
$_SESSION['SSvFim'] = $vFim; |
|
|
|
$_SESSION['SSsInicio'] = $sInicio; |
|
$_SESSION['SSsFim'] = $sFim; |
|
|
|
echo $_SESSION['SSinterval']; |
|
exit(); |
|
} |
|
|
|
___GetHorarioItem(); |
|
|
|
function DiasSemana($dia) { |
|
$semana = array("Domingo" => "sun", "Segunda" => "mon", "Terça" => "tue", "Quarta" => "wed", "Quinta" => "thu", "Sexta" => "fri", "Sabado" => "sat"); |
|
|
|
$opt = ""; |
|
$sel = ""; |
|
foreach ($semana as $key => $value) { |
|
if ($value == $dia) |
|
$sel = "selected"; |
|
else |
|
$sel = ""; |
|
$opt .= "<option value=\"$value\" $sel>$key</option>"; |
|
} |
|
|
|
return $opt; |
|
} |
|
|
|
function ___GetHorarioLG() { |
|
$query = "SELECT * FROM pbx_horarios WHERE nome = 'LIGUE_GRATIS_VERIFICA'"; |
|
$resp = @pg_query($query); |
|
$resp = pg_fetch_assoc($resp); |
|
|
|
if ($resp['nome']) { |
|
return true; |
|
} else { |
|
return false; |
|
} |
|
} |
|
|
|
function ___GetHorarioItem() { |
|
$SSvars = array('SSmInicio', 'SSmFim', 'SSvInicio', 'SSvFim'); |
|
$res = false; |
|
|
|
$query = "SELECT b.id, todos_dias_semana, horario_inicio, horario_fim, semana, semana_fim FROM pbx_horarios a |
|
INNER JOIN pbx_horarios_itens b ON a.id = b.id_horario |
|
WHERE a.nome = 'LIGUE_GRATIS_VERIFICA' ORDER BY 1"; |
|
$resp = @pg_query($query); |
|
$resp = pg_fetch_all($resp); |
|
|
|
foreach ($SSvars as $session) { |
|
if (!$_SESSION[$session]) { |
|
$res = true; |
|
} |
|
} |
|
|
|
if ($res) { |
|
$_SESSION['SSinterval'] = $resp[0]['todos_dias_semana']; |
|
|
|
$_SESSION['SSintInicio'] = $resp[0]['semana']; |
|
$_SESSION['SSintFim'] = $resp[0]['semana_fim']; |
|
|
|
$_SESSION['SSmInicio'] = $resp[0]['horario_inicio']; |
|
$_SESSION['SSmFim'] = $resp[0]['horario_fim']; |
|
|
|
$_SESSION['SSvInicio'] = $resp[1]['horario_inicio']; |
|
$_SESSION['SSvFim'] = $resp[1]['horario_fim']; |
|
|
|
$_SESSION['SSsInicio'] = $resp[2]['horario_inicio'] ? $resp[2]['horario_inicio'] : ''; |
|
$_SESSION['SSsFim'] = $resp[2]['horario_fim'] ? $resp[2]['horario_fim'] : ''; |
|
} |
|
} |
|
?> |
|
<!DOCTYPE html> |
|
<html> |
|
<head> |
|
<link rel="stylesheet" href="admin/css/formliguemegratis.css" type="text/css" media="screen" title="no title" charset="ISO-8859-1" > |
|
<script src="admin/js/jquery_3.3.1.js"></script> |
|
<script> |
|
$(function () { |
|
if ($("input[name='interval']:checked").val() == '1') { |
|
$('#dia_semana').hide(); |
|
} |
|
|
|
$(".inter").change(function () { |
|
GetSSAjax("http://<?php echo $myIP; ?>" + "/index.php?idProg=312&ajax=1", 'formHorario'); |
|
}); |
|
|
|
$("input[name='interval']").change(function () { |
|
if ($(this).val() == '1') { |
|
$('#dia_semana').fadeOut('slow', function () { |
|
$('#dia_semana').hide(); |
|
$('#final_semana').hide(); |
|
}); |
|
} else { |
|
$('#dia_semana').fadeIn('slow', function () { |
|
$('#dia_semana').show(); |
|
$('#final_semana').show(); |
|
}); |
|
} |
|
GetSSAjax("http://<?php echo $myIP; ?>" + "/index.php?idProg=312&ajax=1", 'formHorario'); |
|
}); |
|
|
|
$('#mhorasIni').on('keyup', function () { |
|
if ($(this).val().length === 2) { |
|
var texto = $(this).val(); |
|
$(this).val(texto + ':'); |
|
} |
|
GetSSAjax("http://<?php echo $myIP; ?>" + "/index.php?idProg=312&ajax=1", 'formHorario'); |
|
}); |
|
|
|
$('#mhorasFim').on('keyup', function () { |
|
if ($(this).val().length === 2) { |
|
var texto = $(this).val(); |
|
$(this).val(texto + ':'); |
|
} |
|
GetSSAjax("http://<?php echo $myIP; ?>" + "/index.php?idProg=312&ajax=1", 'formHorario'); |
|
}); |
|
|
|
$('#vhorasIni').on('keyup', function () { |
|
if ($(this).val().length === 2) { |
|
var texto = $(this).val(); |
|
$(this).val(texto + ':'); |
|
} |
|
GetSSAjax("http://<?php echo $myIP; ?>" + "/index.php?idProg=312&ajax=1", 'formHorario'); |
|
}); |
|
|
|
$('#vhorasFim').on('keyup', function () { |
|
if ($(this).val().length === 2) { |
|
var texto = $(this).val(); |
|
$(this).val(texto + ':'); |
|
} |
|
GetSSAjax("http://<?php echo $myIP; ?>" + "/index.php?idProg=312&ajax=1", 'formHorario'); |
|
}); |
|
|
|
$('#shorasIni').on('keyup', function () { |
|
if ($(this).val().length === 2) { |
|
var texto = $(this).val(); |
|
$(this).val(texto + ':'); |
|
} |
|
GetSSAjax("http://<?php echo $myIP; ?>" + "/index.php?idProg=312&ajax=1", 'formHorario'); |
|
}); |
|
|
|
$('#shorasFim').on('keyup', function () { |
|
if ($(this).val().length === 2) { |
|
var texto = $(this).val(); |
|
$(this).val(texto + ':'); |
|
} |
|
GetSSAjax("http://<?php echo $myIP; ?>" + "/index.php?idProg=312&ajax=1", 'formHorario'); |
|
}); |
|
|
|
GetSSAjax("http://<?php echo $myIP; ?>" + "/index.php?idProg=312&ajax=1", 'formHorario'); |
|
}); |
|
|
|
function GetSSAjax(url, form) { |
|
$.ajax({ |
|
url: url, |
|
type: 'POST', |
|
data: $('#' + form).serialize(), |
|
}); |
|
|
|
alert(data); |
|
} |
|
</script> |
|
<style> |
|
.alert-error { |
|
padding: 17px; |
|
background-color: #f44336; |
|
color: white; |
|
} |
|
|
|
.alert-success{ |
|
padding: 17px; |
|
background-color: #33cc33; |
|
color: white; |
|
} |
|
|
|
.closebtn { |
|
margin-left: 15px; |
|
color: white; |
|
font-weight: bold; |
|
float: right; |
|
font-size: 22px; |
|
line-height: 20px; |
|
cursor: pointer; |
|
transition: 0.3s; |
|
} |
|
|
|
.closebtn:hover { |
|
color: black; |
|
} |
|
</style> |
|
</head> |
|
<body> |
|
<div class = "container"> |
|
<h3>CONFIGURAÇÃO DE HORÁRIO</h3> |
|
<hr/> |
|
<form method="POST" autocomplete="off" id="formHorario" action="index.php?idProg=312"> |
|
<div class="row"> |
|
<h3>Dia da Semanda</h3> |
|
<div class="col-25"> |
|
<input type="radio" name="interval" value="1" <?php echo $_SESSION['SSinterval'] == 1 ? 'checked' : ''; ?>>Todos |
|
<input type="radio" name="interval" value="0" <?php echo $_SESSION['SSinterval'] == 0 ? 'checked' : ''; ?>>Intervalo |
|
</div> |
|
</div> |
|
|
|
<div class="row" id="dia_semana"> |
|
<div class="col-25" style="margin-right: 10px;"> |
|
<select class="inter" name="intInicio"> |
|
<?php echo DiasSemana($_SESSION['SSintInicio']) ?> |
|
</select> |
|
</div> |
|
<div class="col-25"> |
|
<select class="inter" name="intFim"> |
|
<?php echo DiasSemana($_SESSION['SSintFim']) ?> |
|
</select> |
|
</div> |
|
</div> |
|
|
|
<div class="row"> |
|
<h3>Período Matutino</h3> |
|
<div class="col-75"> |
|
<div class="col-25" style="margin-right: 10px;"> |
|
<label>Inicio</label> |
|
<input type="text" id="mhorasIni" maxlength="5" name="m_inicio" value="<?php echo $_SESSION['SSmInicio']; ?>" placeholder="Ex: 07:30"/> |
|
</div> |
|
<div class="col-25"> |
|
<label>Fim</label> |
|
<input type="text" id="mhorasFim" maxlength="5" name="m_fim" value="<?php echo $_SESSION['SSmFim']; ?>" placeholder="Ex: 11:29"/> |
|
</div> |
|
</div> |
|
</div> |
|
|
|
<div class="row"> |
|
<h3>Período Vespertino</h3> |
|
<div class="col-75"> |
|
<div class="col-25" style="margin-right: 10px;"> |
|
<label>Inicio</label> |
|
<input type="text" id="vhorasIni" maxlength="5" name="v_inicio" value="<?php echo $_SESSION['SSvInicio']; ?>" placeholder="Ex: 13:30"/> |
|
</div> |
|
<div class="col-25"> |
|
<label>Fim</label> |
|
<input type="text" id="vhorasFim" maxlength="5" name="v_fim" value="<?php echo $_SESSION['SSvFim']; ?>" placeholder="Ex: 17:29"/> |
|
</div> |
|
</div> |
|
</div> |
|
|
|
<div class="row" id="final_semana"> |
|
<h3>Final de Semana (Sábado)</h3> |
|
<div class="col-75"> |
|
<div class="col-25" style="margin-right: 10px;"> |
|
<label>Inicio</label> |
|
<input type="text" id="shorasIni" maxlength="5" name="s_inicio" value="<?php echo $_SESSION['SSsInicio']; ?>" placeholder="Ex: 08:00"/> |
|
</div> |
|
<div class="col-25"> |
|
<label>Fim</label> |
|
<input type="text" id="shorasFim" maxlength="5" name="s_fim" value="<?php echo $_SESSION['SSsFim']; ?>" placeholder="Ex: 12:00"/> |
|
</div> |
|
</div> |
|
</div> |
|
</form> |
|
</div> |
|
</body> |
|
</html> |
|
|
|
|
|
|
|
|