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.
 
 
 
 
 
 

56 lines
2.1 KiB

<?php
$dominio = isset($_POST['dominio']) ? $_POST['dominio'] : $_GET['ip'];
$id = isset($_POST['id']) ? $_POST['id'] : $_GET['id'];
$central = isset($_GET['central']) ? $_GET['central'] : '';
$dataAtualiza = isset($_REQUEST['atualiza']) ? $_REQUEST['atualiza'] : '';
$status = isset($_REQUEST['sts']) ? $_REQUEST['sts'] : '';
$tpLayout = 1;
try {
if (isset($_POST['btExecutar'])) {
$mensagem = GetQuery($id, $dominio,$status,$dataAtualiza);
}
} catch (Exception $ex) {
$mensagem = $ex->getMessage();
}
$smarty->assign('dataAtualiza', $dataAtualiza);
$smarty->assign('status', GetStatus($status));
$smarty->assign('mensagem', $mensagem);
$smarty->assign('dominio', $dominio);
$smarty->assign('central', $central);
$smarty->assign('id', $id);
GetTemplate($smarty, 'admin/centrais/cadCentrais.tpl');
//echo "<script>opener.location.reload();</script>";
function GetQuery($id, $ip, $status, $dataAtualiza) {
$ctPg = pg_connect(sprintf("host=%s port=%s dbname=%s user=%s password=%s",IP_CENTRAL_ATUALIZACAO,'5432','atualizacoes','contacte','ctepgSQL'));
if($dataAtualiza == "NÃO ATUALIZADA" || !$dataAtualiza) {
$data = 'null';
} else {
$data = QuotedStr(FormatDtMssql($dataAtualiza));
}
$query = "UPDATE central_atualizacao SET ip_central = '$ip', status_central = '$status', data_atualizacao = $data WHERE id_central = $id";
pg_query($ctPg, $query);
if (pg_last_error()) {
throw new Exception('Não foi possível coletar as informações, por favor verifique a conexão com a base de dados! '.pg_last_error());
}
pg_close($ctPg);
return "Central foi atualizada com sucesso!";
}
function GetStatus($status){
$opt = "";
$opt .= sprintf("<option value='DESATUALIZADA' %s>DESATUALIZADA</option>",$status == 'DESATUALIZADA' ? "selected" : '');
$opt .= sprintf("<option value='ATUALIZADA' %s>ATUALIZADA</option>",$status == 'ATUALIZADA' ? "selected" : '');
return $opt;
}