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

<form name="" method="post">
<?php $tabella = new html (0,"90%", array (3,5,2,15,2,10,2,5,0)); ?>
	<tr>
		<td class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
		<td class="spazioh"><a href="iscritti_edit.php"><img src="<?php print $CONF['base_url'] ?>/img/addresource.png"></a></td>
		<td colspan=7 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
	</tr>
<?php
$tabella->riga();
$query = "	SELECT
			wf_palestra.id,
			wf_palestra.attivo,
			wf_palestra.palestra,
			wf_palestra.sigla,
			count(wf_iscritto.id_palestra) AS iscritti
		FROM
			wf_palestra
		LEFT OUTER JOIN
			wf_iscritto
			ON
				wf_iscritto.id_palestra = wf_palestra.id 
				AND
				wf_iscritto.attivo = 1
		GROUP BY
			wf_palestra.id,
                        wf_palestra.attivo,
                        wf_palestra.palestra
		ORDER BY
			attivo desc,
			palestra
";

$res = mysql_query( $query, $DB_ID );
$tabella->intestazione (array("", "", "", "Palestra", "", "Sigla", "", "Iscritti", ""));
$tabella->riga();
while ($dato = mysql_fetch_array ( $res )) {
?>
	<tr>
<?php
	if ($dato['attivo']) {
?>
		<td class="col3btn"><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="Utente attivo" TITLE="Palestra attiva"></a></td>
<?php	} else { ?>
		<td class="col3btn"><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="Utente non attivo" TITLE="Palestra non attiva"></a></td>
<?php	} ?>
		<td class="col3btn"><a href="palestre_edit.php?id=<?php print $dato['id'] ?>"><img src="<?php print $CONF['base_url'] ?>/img/modify.gif" ALT="Modifica palestra" TITLE="Modifica palestra"></a></td>
		<td class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
		<td class="colip"><?php print $dato['palestra'] ?></td>
		<td class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
		<td class="colip"><?php print $dato['sigla'] ?></td>
		<td class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
		<td class="colip"><?php print $dato['iscritti'] ?></td>
		<td class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
		</td>
	</tr>
<?php
} 
$tabella->close();
?>
</form>
<?php view_footer(); ?>
