2017-08-04 16:28:16 +02:00
< ? php
2020-09-07 15:04:06 +02:00
/*
* OpenSTAManager : il software gestionale open source per l ' assistenza tecnica e la fatturazione
2021-01-20 15:08:51 +01:00
* Copyright ( C ) DevCode s . r . l .
2020-09-07 15:04:06 +02:00
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < https :// www . gnu . org / licenses />.
*/
2017-08-04 16:28:16 +02:00
include_once __DIR__ . '/../../core.php' ;
2023-12-06 16:48:54 +01:00
if ( ! function_exists ( 'menuSelection' )) {
function menuSelection ( $element , $group_id , $depth , $permessi_disponibili )
{
$dbo = database ();
++ $depth ;
2017-08-04 16:28:16 +02:00
2023-12-06 16:48:54 +01:00
// Permessi impostati per il gruppo
$permesso_salvato = $dbo -> fetchOne ( 'SELECT permessi FROM zz_permissions WHERE idgruppo = ' . prepare ( $group_id ) . ' AND idmodule = ' . prepare ( $element [ 'id' ]));
2022-11-24 18:55:19 +01:00
2023-12-06 16:48:54 +01:00
$permessi = $permesso_salvato ? $permesso_salvato [ 'permessi' ] : '-' ;
2023-08-04 14:54:28 +02:00
2023-12-06 16:48:54 +01:00
$result = '
< tr >
< td > '.str_repeat(' & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; ', $depth).' < span > '.$element[' title '].' </ span ></ td >
< td >
< select name = " permesso_'. $element['id'] .' " id = " permesso_'. $element['id'] .' " class = " form-control superselect openstamanager-input select-input " onchange = " update_permissions('. $element['id'] .', $ (this).find( \ 'option:selected \ ').val(), $ (this).find( \ 'option:selected \ ').data( \ 'color \ ')) " > ' ;
2017-08-04 16:28:16 +02:00
2023-12-06 16:48:54 +01:00
foreach ( $permessi_disponibili as $id => $nome ) {
switch ( $id ) {
case 'rw' :
$bgcolor = 'green' ;
2024-01-15 15:30:45 +01:00
break ;
2023-12-06 16:48:54 +01:00
case 'r' :
$bgcolor = 'orange' ;
2024-01-15 15:30:45 +01:00
break ;
2023-12-06 16:48:54 +01:00
case '-' :
$bgcolor = 'red' ;
2024-01-15 15:30:45 +01:00
break ;
2023-12-06 16:48:54 +01:00
default :
2024-01-15 15:30:45 +01:00
break ;
2023-12-06 16:48:54 +01:00
}
$attr = ( $id == $permessi ) ? ' selected="selected"' : '' ;
$result .= '
< option data - color = " text-'. $bgcolor .' " _bgcolor_ = " '. $bgcolor .' " value = " '. $id .' " '.$attr.' > '.$nome.' </ option > ' ;
2022-11-24 18:55:19 +01:00
}
2017-08-04 16:28:16 +02:00
$result .= '
2023-12-06 16:48:54 +01:00
</ select >
</ td >
</ tr > ' ;
2020-10-30 17:24:13 +01:00
2023-12-06 16:48:54 +01:00
$submenus = $element [ 'all_children' ];
if ( ! empty ( $submenus )) {
foreach ( $submenus as $submenu ) {
$result .= menuSelection ( $submenu , $group_id , $depth , $permessi_disponibili , $perms_names );
}
2020-10-30 17:24:13 +01:00
}
2017-08-04 16:28:16 +02:00
2023-12-06 16:48:54 +01:00
return $result ;
}
2023-12-06 17:24:23 +01:00
}