|
|
|
|
<?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<EFBFBD>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<EFBFBD>o foi poss<EFBFBD>vel coletar as informa<EFBFBD><EFBFBD>es, por favor verifique a conex<EFBFBD>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;
|
|
|
|
|
}
|
|
|
|
|
|