Files
pannello/associazione/utenze_permessi.php
2019-04-29 16:51:42 +02:00

108 lines
2.4 KiB
PHP
Executable File

<?php
include_once ("../core/config.php");
$UTENTE = login();
$DIRITTI = diritti('Admin');
view_top();
$query = " SELECT
wf_palestra.palestra,
wf_utenti.attivo
FROM
wf_palestra
LEFT OUTER JOIN
wf_utenti
ON
wf_utenti.id_palestra = wf_palestra.id
AND
wf_utenti.id_utenti = ".$_GET['id']."
WHERE
wf_palestra.attivo = 1
";
$permessi = mysql_query( $query, $DB_ID );
$query = " SELECT
utente,
admin
FROM
utenti
WHERE
id = ".$_GET['id']."
AND
attivo = 1
";
$res = mysql_query( $query, $DB_ID );
$dato = mysql_fetch_array ($res);
?>
<script type="text/javascript" src="<?php print $CONF['base_url']?>/jquery/jquery-1.8.0.min.js"></script>
<?php
$tabella = new html (0,"90%", array (0)); ?>
<tr>
<td align="center">
<?php $tabella1 = new html (0,"40%", array (20,0)); ?>
<tr>
<?php if ($dato['admin']) { ?>
<td rowspan=2 class="col3btn"><img src="<?php print $CONF['base_url'] ?>/img/admin.png" ALT="Admin" TITLE="Admin"></td>
<?php } else { ?>
<td rowspan=2 class="col3btn"><img src="<?php print $CONF['base_url'] ?>/img/utente.png" ALT="Utente" TITLE="Utente"></td>
<?php } ?>
<td class="col3campo2"><?php print $dato['utente'] ?></td>
</tr>
<?php $tabella1->close(); ?>
</td>
</tr>
<?php $tabella->riga(); ?>
<tr>
<td align="center">
<?php
$tabella2 = new html (0,"60%", array(30,0));
while ($dato = mysql_fetch_array ( $permessi )) { ?>
<tr>
<td class="col3campo2"><?php print $dato['palestra']?></td>
<td>
<select name='<?php print $dato['palestra']?>' class="cambio" >
<option name='<?php print $dato['palestra']?>' value='0' <?php if ($dato['attivo'] == 0 OR $dato['attivo'] == NULL) { print "selected"; } ?>>Negato</option>
<option name='<?php print $dato['palestra']?>' value='1' <?php if ($dato['attivo'] == 1) { print "selected"; } ?>>Permesso</option>
</select>
</td>
</tr>
<?php
$tabella2->riga();
}
$tabella2->close();
?>
</td>
</tr>
<?php $tabella->close(); ?>
<script type="text/javascript">
$(function(){
$('.cambio').on('change', function(){
var usr = <?php print $_GET['id'] ?>;
var acc = $(this).val();
var pal = $(this).attr('name');
$.ajax({
url: "utente_update.php",
dataType: "json",
data: {
user_id: usr,
accesso: acc,
palestra: pal
},
success: function(data) {
// data contiene i ritorni dalla pagina chiamata ma devono essere in json
}
} );
});
})
</script>
<?php view_footer(); ?>