<?php
include_once ("../core/config.php");
include_once ("funzioni.php");
$UTENTE = login();
$DIRITTI = diritti('Admin');
view_top();

if (isset($_POST['id'])) {
	extract($_POST);

	if ($id) {
		$query = "	UPDATE
					wf_palestra
				SET
					palestra = '$palestra',
					sigla = '$sigla'
				WHERE
					id = $id	
		";
	} else {
		$query = "	INSERT INTO
					wf_palestra
				SET
					attivo = 1,
					palestra = '$palestra',
					sigla = '$sigla'
		";
	}

	$res = mysql_query( $query, $DB_ID );
//	if ($id == "") {
//		$id = mysql_insert_id();
?>
		<script type="text/javascript">
			document.location.href='palestre_lista.php'
		</script>
<?php
		exit;
//	}

} elseif (isset($_GET['id'])) {
	$id = $_GET['id'];
}
?>

<form name="" method="post">
<input type="hidden" name="id" value="<?php print $id ?>">
<?php

$query = "	SELECT 
			id,
			attivo,
			palestra,
			sigla
		FROM
			wf_palestra
		WHERE
			id = $id
";
$res = mysql_query( $query, $DB_ID );
$dato = mysql_fetch_array ( $res );

$tabella = new html (1,"90%",array(5,20,2,10,0));
$tabella->intestazione (array("","Palestra","", "Sigla", ""));
?>
	<tr>
<?php
if ($dato['attivo']) {
?>
		<td class="spazioh"><a href="wf_gest.php?azione=wf_palestra_off&id=<?php print $dato['id']?>"><img src="<?php print $CONF['base_url'] ?>/img/attivo.gif" ALT="Atleta Attivo" TITLE="Atleta Attivo"></a></td>
<?php	} else { ?>
		<td class="spazioh"><a href="wf_gest.php?azione=wf_palestra_on&id=<?php print $dato['id']?>"><img src="<?php print $CONF['base_url'] ?>/img/non_attivo.gif" ALT="Atleta non Attivo" TITLE="Atleta non Attivo"></a></td>
<?php	} ?>
		<td class="colip"><input size="20" type="text" name=palestra value="<?php print $dato['palestra'] ?>"></td>
		<td class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
		<td class="colip"><input size="3" type="text" name=sigla value="<?php print $dato['sigla'] ?>"></td>
		<td class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
	</tr>
<?php
$tabella = new html (0,"90%",array(5,20,0));
$tabella->riga(); ?>
	<tr>
		<td class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
		<td class="spaziov" colspan=10><input type="submit" value="Conferma"></td>
		<td class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
	</tr>


<?php $tabella->close(); ?>
</form>
<?php view_footer(); ?>
