diff --git a/code/app/Console/Commands/FixDatabase.php b/code/app/Console/Commands/FixDatabase.php
index 2a894d7d..6cf47e8c 100644
--- a/code/app/Console/Commands/FixDatabase.php
+++ b/code/app/Console/Commands/FixDatabase.php
@@ -100,5 +100,15 @@ public function handle()
$d->save();
}
}
+
+ /*
+ Per abilitare la funzione multi-gas laddove effettivamente
+ utilizzata
+ */
+
+ $all_gas = Gas::all();
+ foreach($all_gas as $gas) {
+ $gas->setConfig('multigas', $all_gas->count() > 1 ? '1' : '0');
+ }
}
}
diff --git a/code/app/Helpers/Permissions.php b/code/app/Helpers/Permissions.php
index a53407e5..7c4939bf 100644
--- a/code/app/Helpers/Permissions.php
+++ b/code/app/Helpers/Permissions.php
@@ -2,7 +2,7 @@
function allPermissions()
{
- return [
+ $ret = [
'App\Gas' => [
'gas.access' => _i('Accesso consentito anche in manutenzione'),
'gas.permissions' => _i('Modificare tutti i permessi'),
@@ -23,7 +23,6 @@ function allPermissions()
'measures.admin' => _i('Amministrare le unità di misura'),
'gas.statistics' => _i('Visualizzare le statistiche'),
'notifications.admin' => _i('Amministrare le notifiche'),
- 'gas.multi' => _i('Amministrare la modalità Multi-GAS su questa istanza'),
],
'App\Supplier' => [
'supplier.modify' => _i('Modificare i fornitori assegnati'),
@@ -33,6 +32,13 @@ function allPermissions()
'supplier.movements' => _i('Amministrare i movimenti contabili del fornitore'),
],
];
+
+ $gas = currentAbsoluteGas();
+ if ($gas->multigas) {
+ $ret['App\Gas']['gas.multi'] = _i('Amministrare la modalità Multi-GAS su questa istanza');
+ }
+
+ return $ret;
}
function allRoles()
@@ -85,10 +91,8 @@ function classByRule($rule_id)
$all_permissions = allPermissions();
foreach ($all_permissions as $class => $rules) {
- foreach (array_keys($rules) as $identifier) {
- if ($rule_id == $identifier) {
- return $class;
- }
+ if (isset($rules[$rule_id])) {
+ return $class;
}
}
diff --git a/code/app/Http/Controllers/GasController.php b/code/app/Http/Controllers/GasController.php
index 08e19ebd..a5455f0e 100644
--- a/code/app/Http/Controllers/GasController.php
+++ b/code/app/Http/Controllers/GasController.php
@@ -69,6 +69,7 @@ private function configGeneral($gas, $request)
$gas->setManyConfigs($request, [
'restricted',
+ 'multigas',
'language'
]);
}
diff --git a/code/app/Parameters/Config/HasMultiGAS.php b/code/app/Parameters/Config/HasMultiGAS.php
new file mode 100644
index 00000000..f4fefee3
--- /dev/null
+++ b/code/app/Parameters/Config/HasMultiGAS.php
@@ -0,0 +1,21 @@
+multigas;
}
}
diff --git a/code/resources/views/gas/general.blade.php b/code/resources/views/gas/general.blade.php
index 1ca8cf4d..5801f667 100644
--- a/code/resources/views/gas/general.blade.php
+++ b/code/resources/views/gas/general.blade.php
@@ -15,6 +15,8 @@
@if(someoneCan('gas.access', $gas))
@endif
+
+
diff --git a/code/resources/views/permissions/gas-management.blade.php b/code/resources/views/permissions/gas-management.blade.php
index 6853ead3..1e53040b 100644
--- a/code/resources/views/permissions/gas-management.blade.php
+++ b/code/resources/views/permissions/gas-management.blade.php
@@ -15,7 +15,7 @@
@endif
- @if(someoneCan('gas.multi'))
+ @if($currentgas->multigas)
@endif