<?php
include 'topo.php';

$msg = "";
$msgClass = "msgErro";
$titulo = "Configurações > Geral";
$msg_ok = "Alterado com sucesso";
$msg_erro = "Erro ao alterar";

##########################
# alterar
##########################
if(isPost($_POST['ok'])){
	$obj = new Config();
	$obj->id = $_POST['config']['id'];
	$obj->carregar();
	$obj->carga($_POST['config']);
	if($obj->alterar()){
		$msg = $msg_ok;
		$msgClass = "msgSucesso";
	}
	else{
		$msg = $msg_erro;
	}
}
?>

<h1><?=$titulo?></h1>

<?php include PATHADMIN.'msg.php'; ?>

<?php
$lista = UtilObjeto::listar("config","ORDER BY config");
if(is_array($lista)){
	foreach($lista as $id => $dados) { 
	?>
	<div class="boxForm">
		<div class="boxTitulo"><?=$dados['descricao']?></div>
		<form name="form<?=$id?>" id="form<?=$id?>" action="" method="post">
			<div class="campo3">
				<label for="valor<?=$id?>">Valor:</label>
				<input type="text" id="valor<?=$id?>" name="config[valor]" value="<?=$dados['valor']?>" />
			</div>
			<div class="campo3 align-right">
				<input type="submit" class="botao" name="ok" value="Salvar" title="Salvar" />
			</div>
			<input type="hidden" name="config[id]" value="<?=$id?>" />
		</form>
	</div>
	<?php
	}
}
?>

<?php
include 'rodape.php';
?>