Prima pagina per gruppo utenti

This commit is contained in:
Beppe 2022-08-29 17:48:19 +02:00
parent 6239311578
commit 4d03890ce9
5 changed files with 72 additions and 7 deletions

View File

@ -243,5 +243,16 @@ switch (filter('op')) {
ob_end_clean();
echo 'ok';
break;
case 'update':
$dbo->update('zz_groups',[
'id_module_start' => filter('id_module_start'),
],['id' => $id_record]);
ob_end_clean();
echo 'ok';
break;
}

View File

@ -110,5 +110,24 @@ switch ($resource) {
];
}
break;
case 'moduli_gruppo':
$query = "SELECT zz_modules.id, zz_modules.title AS descrizione FROM zz_modules LEFT JOIN zz_permissions ON zz_permissions.idmodule=zz_modules.id |where| ORDER BY descrizione";
$where[] = 'zz_modules.enabled=1';
if( isset($superselect['idgruppo']) && $superselect['idgruppo']!=1 ){
$where[] = 'zz_permissions.idgruppo='.prepare($superselect['idgruppo']);
}
foreach ($elements as $element) {
$filter[] = 'zz_modules.id='.prepare($element);
}
if (!empty($search)) {
$search_fields[] = 'descrizione LIKE '.prepare('%'.$search.'%');
}
break;
}

View File

@ -29,7 +29,13 @@ echo '
]).'</h3>
</div>
<div class="panel-body">';
<div class="panel-body">
<div class="row">
<div class="col-md-3 pull-right">
{["type":"select", "label":"", "name":"id_module_start", "ajax-source":"moduli_gruppo", "select-options": '.json_encode(['idgruppo' => $record['id']]).', "placeholder":"'.tr('Modulo iniziale').'", "value":"'.$record['id_module_start'].'" ]}
</div>
</div>
<br>';
if (!empty($utenti)) {
echo '
@ -231,10 +237,31 @@ function update_permissions(id, value){
function(data){
if(data == "ok") {
toastr["success"]("'.tr('Permessi aggiornati!').'");
if( id==$("#id_module_start").val() && value=="-" ){
$("#id_module_start").selectReset();
update_user($("#id_module_start").val());
}
} else {
swal("'.tr('Errore').'", "'.tr("Errore durante l'aggiornamento dei permessi!").'", "error");
}
}
);
}
$("#id_module_start").change(function(){
update_user($(this).val());
});
function update_user(value){
$.get(
globals.rootdir + "/actions.php?id_module='.$id_module.'&id_record='.$id_record.'&op=update&id_module_start=" + value,
function(data){
if(data == "ok") {
toastr["success"]("'.tr('Prima pagina aggiornata!').'");
} else {
swal("'.tr('Errore').'", "'.tr("Errore durante l'aggiornamento delle informazioni!").'", "error");
}
}
);
}
</script>';

View File

@ -129,7 +129,10 @@ class Auth extends \Util\Singleton
if (!empty($user['enabled'])) {
$this->identifyUser($user['id']);
$module = $this->getFirstModule();
$gruppo = $database->fetchOne("SELECT zz_groups.* FROM zz_groups INNER JOIN zz_users ON zz_users.idgruppo=zz_groups.id");
$module = $gruppo['id_module_start'];
$module = $this->getFirstModule($module);
if (
$this->isAuthenticated() &&
@ -247,7 +250,7 @@ class Auth extends \Util\Singleton
*
* @return string|null
*/
public function getFirstModule()
public function getFirstModule($first = null)
{
if (empty($this->first_module)) {
$parameters = [];
@ -265,7 +268,9 @@ class Auth extends \Util\Singleton
if (!empty($results)) {
$module = null;
if( empty($first) ){
$first = setting('Prima pagina');
}
if (!in_array($first, array_column($results, 'id'))) {
$module = $results[0]['id'];
} else {

View File

@ -33,3 +33,6 @@ INSERT INTO `zz_group_module` (`idgruppo`, `idmodule`, `name`, `clause`, `positi
-- Aggiornamento title e icona per Causali (Causali trasporto) e Causali movimenti
UPDATE `zz_modules` SET `title` = 'Causali trasporto', `icon` = 'fa fa-truck' WHERE `zz_modules`.`name` = 'Causali';
UPDATE `zz_modules` SET `icon` = 'fa fa-exchange' WHERE `zz_modules`.`name` = 'Causali movimenti';
-- Prima pagina per gruppo utenti
ALTER TABLE `zz_groups` ADD `id_module_start` INT NULL AFTER `editable`;