2017-08-04 16:28:16 +02:00
< ? php
include_once __DIR__ . '/../../core.php' ;
2018-07-03 11:12:32 +02:00
$utenti = $dbo -> fetchArray ( 'SELECT *, (SELECT ragione_sociale FROM an_anagrafiche WHERE an_anagrafiche.idanagrafica=zz_users.idanagrafica ) AS ragione_sociale, (SELECT GROUP_CONCAT(descrizione SEPARATOR ", ") FROM an_tipianagrafiche INNER JOIN an_tipianagrafiche_anagrafiche ON an_tipianagrafiche.idtipoanagrafica=an_tipianagrafiche_anagrafiche.idtipoanagrafica WHERE idanagrafica=zz_users.idanagrafica GROUP BY idanagrafica) AS tipo FROM zz_users WHERE idgruppo=' . prepare ( $record [ 'id' ]));
2017-08-04 16:28:16 +02:00
echo '
< div class = " panel panel-primary " >
< div class = " panel-heading " >
2017-09-10 14:35:41 +02:00
< h3 class = " panel-title " > '.tr(' Utenti _GROUP_ ' , [
2018-07-18 15:20:10 +02:00
'_GROUP_' => $record [ 'nome' ],
2017-09-10 14:35:41 +02:00
]) . ' </ h3 >
2017-08-04 16:28:16 +02:00
</ div >
< div class = " panel-body " > ' ;
2017-09-12 14:53:19 +02:00
if ( ! empty ( $utenti )) {
2017-08-04 16:28:16 +02:00
echo '
2018-11-20 23:38:50 +01:00
< div class = " table-responsive " >
2017-08-04 16:28:16 +02:00
< table class = " table table-hover table-condensed table-striped " >
< tr >
2017-09-04 12:02:29 +02:00
< th > '.tr(' Nome utente ').' </ th >
< th > '.tr(' Ragione sociale ').' </ th >
2019-06-20 16:44:45 +02:00
< th > '.tr(' Tipo di anagrafica ').' </ th >
< th > '.tr(' Sedi ').' </ th >
2018-11-20 23:38:50 +01:00
< th width = " 120 " > '.tr(' Opzioni ').' </ th >
2017-08-04 16:28:16 +02:00
</ tr > ' ;
2017-09-12 14:53:19 +02:00
foreach ( $utenti as $utente ) {
2017-08-04 16:28:16 +02:00
echo '
< tr >
< td ' ;
2017-09-12 14:53:19 +02:00
if ( $utente [ 'enabled' ] == 0 ) {
2017-08-04 16:28:16 +02:00
echo ' style="text-decoration:line-through;"' ;
}
2017-09-12 14:53:19 +02:00
echo '><i class="fa fa-user"></i> ' . $utente [ 'username' ] . '</td>' ;
if ( $utente [ 'idanagrafica' ] != 0 ) {
2017-08-04 16:28:16 +02:00
echo '
2017-09-12 14:53:19 +02:00
< td > '.Modules::link(' Anagrafiche ', $utente[' idanagrafica '], $utente[' ragione_sociale ']).' </ td >
< td > '.$utente[' tipo '].' </ td > ' ;
2017-08-04 16:28:16 +02:00
} else {
echo '
< td >-</ td >
< td >-</ td > ' ;
}
2019-06-20 16:44:45 +02:00
$sedi = $dbo -> fetchOne ( 'SELECT GROUP_CONCAT(nomesede SEPARATOR ", " ) as nomesede FROM zz_user_sedi INNER JOIN ((SELECT "0" AS id, "Sede legale" AS nomesede) UNION (SELECT id, nomesede FROM an_sedi)) sedi ON zz_user_sedi.idsede=sedi.id WHERE id_user=' . prepare ( $utente [ 'id' ]) . ' GROUP BY id_user ' )[ 'nomesede' ];
2019-06-29 11:01:26 +02:00
2019-06-20 16:44:45 +02:00
echo '
< td > '.$sedi.' </ td > ' ;
2019-06-29 11:01:26 +02:00
2017-08-04 16:28:16 +02:00
/*
* Funzioni per gli utenti
*/
echo '
2019-06-29 11:01:26 +02:00
< td > ' ;
2017-09-01 18:13:25 +02:00
// Disabilitazione utente, se diverso da id_utente #1 (admin)
2017-09-12 14:53:19 +02:00
if ( $utente [ 'id' ] != '1' ) {
if ( $utente [ 'enabled' ] == 1 ) {
2017-08-04 16:28:16 +02:00
echo '
2018-08-11 15:49:46 +02:00
< a href = " javascript:; " onclick = " swal( { title: \ ''.tr('Disabilitare questo utente?').' \ ', type: \ 'info \ ', showCancelButton: true, confirmButtonText: \ ''.tr('Sì').' \ ' }).then(function (result) { location.href= \ ''. $rootdir .'/editor.php?id_module='. $id_module .'&id_record='. $id_record .'&op=disable&id_utente='. $utente['id'] .'&idgruppo='. $record['id'] .' \ '; }) " title = " Disabilita utente " class = " text-danger tip " >< i class = " fa fa-2x fa-eye-slash " ></ i ></ a > ' ;
2017-08-04 16:28:16 +02:00
} else {
2018-06-26 14:30:26 +02:00
echo '
2018-08-11 15:49:46 +02:00
< a href = " javascript:; " onclick = " swal( { title: \ ''.tr('Abilitare questo utente?').' \ ', type: \ 'info \ ', showCancelButton: true, confirmButtonText: \ ''.tr('Sì').' \ ' }).then(function (result) { location.href= \ ''. $rootdir .'/editor.php?id_module='. $id_module .'&id_record='. $id_record .'&op=enable&id_utente='. $utente['id'] .'&idgruppo='. $record['id'] .' \ '; }) " title = " Abilita utente " class = " text-success tip " >< i class = " fa fa-2x fa-eye " ></ i ></ a > ' ;
2017-08-04 16:28:16 +02:00
}
} else {
echo '
2017-09-04 12:02:29 +02:00
< a href = " javascript:; " onclick = " alert( \" '.tr( " Non è possibile disabilitare l 'utente admin").' \ " ) " class = " text-muted tip " >< i class = " fa fa-2x fa-eye-slash " ></ i ></<> ' ;
2017-08-04 16:28:16 +02:00
}
2017-09-10 14:35:41 +02:00
// Cambio password e nome utente
2017-08-04 16:28:16 +02:00
echo '
2018-10-25 17:11:02 +02:00
< a href = " " data - href = " '. $rootdir .'/modules/'.Modules::get( $id_module )['directory'].'/user.php?id_utente='. $utente['id'] .'&idgruppo='. $record['id'] .' " class = " text-warning tip " data - toggle = " modal " title = " Aggiorna dati utente " data - title = " Aggiorna dati utente " >< i class = " fa fa-2x fa-unlock-alt " ></ i ></ a > ' ;
2018-07-02 09:55:16 +02:00
// Disabilitazione token API, se diverso da id_utente #1 (admin)
if ( $utente [ 'id' ] != '1' ) {
$token = $dbo -> fetchOne ( 'SELECT `enabled` FROM `zz_tokens` WHERE `id_utente` = ' . prepare ( $utente [ 'id' ]));
if ( ! empty ( $token [ 'enabled' ])) {
echo '
2018-08-28 17:10:23 +02:00
< a href = " javascript:; " onclick = " swal( { title: \ ''.tr( " Disabilitare l\ 'accesso API per questo utente?").' \ ', type: \'info\', showCancelButton: true, confirmButtonText: \'' . tr ( 'Sì' ) . '\' }).then(function (result) { location.href=\'' . $rootdir . '/editor.php?id_module=' . $id_module . '&id_record=' . $id_record . '&op=token_disable&id_utente=' . $utente [ 'id' ] . '&idgruppo=' . $record [ 'id' ] . '\'; }) " title="Disabilita API" class="text-danger tip"><i class="fa fa-2x fa-key"></i></a>' ;
2018-07-02 09:55:16 +02:00
} else {
echo '
2018-08-28 17:10:23 +02:00
< a href = " javascript:; " onclick = " swal( { title: \ ''.tr( " Abilitare l\ 'accesso API per questo utente?").' \ ', type: \'info\', showCancelButton: true, confirmButtonText: \'' . tr ( 'Sì' ) . '\' }).then(function (result) { location.href=\'' . $rootdir . '/editor.php?id_module=' . $id_module . '&id_record=' . $id_record . '&op=token_enable&id_utente=' . $utente [ 'id' ] . '&idgruppo=' . $record [ 'id' ] . '\'; }) " title="Abilitare API" class="text-success tip"><i class="fa fa-2x fa-key"></i></a>' ;
2018-07-02 09:55:16 +02:00
}
} else {
echo '
< span onclick = " alert( \" '.tr( " Non è possibile gestire l 'accesso API per l' utente admin " ).' \" ) " class = " text-muted tip " >< i class = " fa fa-2x fa-key " ></ i ></ span > ' ;
}
2017-08-04 16:28:16 +02:00
2017-09-01 18:13:25 +02:00
// Eliminazione utente, se diverso da id_utente #1 (admin)
2017-09-12 14:53:19 +02:00
if ( $utente [ 'id' ] != '1' ) {
2018-06-26 14:30:26 +02:00
echo '
2018-08-11 15:49:46 +02:00
< a href = " javascript:; " onclick = " swal( { title: \ ''.tr('Eliminare questo utente?').' \ ', type: \ 'info \ ', showCancelButton: true, confirmButtonText: \ ''.tr('Sì').' \ ' }).then(function (result) { location.href= \ ''. $rootdir .'/editor.php?id_module='. $id_module .'&id_record='. $id_record .'&op=delete&id_utente='. $utente['id'] .'&idgruppo='. $record['id'] .' \ '; }) " title = " Elimina utente " class = " text-danger tip " >< i class = " fa fa-2x fa-trash " ></ i ></ a > ' ;
2017-08-04 16:28:16 +02:00
} else {
echo '
2018-07-02 09:55:16 +02:00
< span onclick = " alert( \" '.tr( " Non è possibile eliminare l 'utente admin").' \ " ) " class = " text-muted tip " >< i class = " fa fa-2x fa-trash " ></ i ></ span > ' ;
2017-08-04 16:28:16 +02:00
}
echo '
</ td >
</ tr > ' ;
}
echo '
2018-11-20 23:38:50 +01:00
</ table >
</ div > ' ;
2017-08-04 16:28:16 +02:00
} else {
echo '
2018-08-28 17:10:23 +02:00
< div class = \ 'alert alert-info\' ><i class=\'fa fa-info-circle\'></i> ' . tr ( 'Non ci sono utenti in questo gruppo' ) . '.</div>' ;
2017-08-04 16:28:16 +02:00
}
echo '
2018-10-25 17:11:02 +02:00
< a data - toggle = " modal " data - href = " '. $rootdir .'/modules/utenti/user.php?idgruppo='. $record['id'] .' " data - title = " '.tr('Aggiungi utente').' " class = " pull-right btn btn-primary " >< i class = " fa fa-plus " ></ i > '.tr(' Aggiungi utente ').' </ a >
2017-08-04 16:28:16 +02:00
</ div >
</ div > ' ;
// Aggiunta nuovo utente
echo '
< hr > ' ;
echo '
< div class = " panel panel-primary " >
< div class = " panel-heading " >
2018-05-22 22:51:22 +02:00
< h3 class = " panel-title " > '.tr(' Permessi _GROUP_ ' , [
2018-07-18 15:20:10 +02:00
'_GROUP_' => $record [ 'nome' ],
2018-11-20 23:38:50 +01:00
]) . (( empty ( $record [ 'editable' ])) ? '<a class=\'clickable btn-xs pull-right ask\' data-msg="' . tr ( 'Verranno reimpostati i permessi di default per il gruppo \'' . $record [ 'nome' ] . '\' ' ) . '." data-class="btn btn-lg btn-warning" data-button="' . tr ( 'Reimposta permessi' ) . '" data-op="restore_permission" >' . tr ( 'Reimposta permessi' ) . '</a>' : '' ) . ' </ h3 >
2018-08-29 18:15:12 +02:00
2017-08-04 16:28:16 +02:00
</ div >
< div class = " panel-body " > ' ;
if ( $record [ 'nome' ] != 'Amministratori' ) {
echo '
2018-11-20 23:38:50 +01:00
< div class = " table-responsive " >
< table class = " table table-hover table-condensed table-striped " >
2017-08-04 16:28:16 +02:00
< tr >
2017-09-04 12:02:29 +02:00
< th > '.tr(' Modulo ').' </ th >
< th > '.tr(' Permessi ').' </ th >
2018-07-02 09:55:16 +02:00
</ tr > ' ;
2018-03-02 19:01:30 +01:00
2018-07-02 09:55:16 +02:00
$moduli = Modules :: getHierarchy ();
$permissions = [
'-' => tr ( 'Nessun permesso' ),
'r' => tr ( 'Sola lettura' ),
'rw' => tr ( 'Lettura e scrittura' ),
];
for ( $m = 0 ; $m < count ( $moduli ); ++ $m ) {
echo menuSelection ( $moduli [ $m ], $id_record , - 1 , array_keys ( $permissions ), array_values ( $permissions ));
2017-08-04 16:28:16 +02:00
}
echo '
2018-11-20 23:38:50 +01:00
</ table >
</ div > ' ;
2017-08-04 16:28:16 +02:00
} else {
echo '
2018-08-28 17:10:23 +02:00
< div class = \ 'alert alert-info\' ><i class=\'fa fa-info-circle\'></i> ' . tr ( 'Gli amministratori hanno accesso a qualsiasi modulo' ) . '.</div>' ;
2017-08-04 16:28:16 +02:00
}
echo '
</ div >
</ div > ' ;
// Eliminazione gruppo (se non è tra quelli di default)
if ( $record [ 'editable' ] == 1 ) {
echo '
2017-09-12 16:17:11 +02:00
<!-- PULSANTI -->
< div class = " row " >
< div class = " col-md-12 text-right " >
< a class = " btn btn-danger ask " data - backto = " record-list " data - msg = " '.tr('Eliminando questo gruppo verranno eliminati anche i permessi e gli utenti collegati').' " data - op = " deletegroup " >
< i class = " fa fa-trash " ></ i > '.tr(' Elimina ').'
</ a >
</ div >
2017-08-04 16:28:16 +02:00
</ div > ' ;
}
echo '
< script >
2018-08-10 17:14:09 +02:00
$ ( document ) . ready ( function (){
$ ( " #save " ) . addClass ( " hide " );
});
2018-12-04 15:01:45 +01:00
$ ( " li.active.header button.btn-primary " ) . attr ( " data-href " , $ ( " a.pull-right " ) . attr ( " data-href " ) );
2017-08-04 16:28:16 +02:00
function update_permissions ( id , value ){
$ . get (
globals . rootdir + " /actions.php?id_module='. $id_module .'&id_record='. $id_record .'&op=update_permission&idmodulo= " + id + " &permesso= " + value ,
function ( data ){
if ( data == " ok " ){
2017-09-04 12:02:29 +02:00
swal ( " '.tr('Salvataggio completato').' " , " '.tr('Permessi aggiornati!').' " , " success " );
2017-08-04 16:28:16 +02:00
}
else {
2017-09-04 12:02:29 +02:00
swal ( " '.tr('Errore').' " , " '.tr( " Errore durante l 'aggiornamento dei permessi!").' " , " error " );
2017-08-04 16:28:16 +02:00
}
}
);
}
</ script > ' ;