Compare commits

..

No commits in common. "a8a25063ace4f2b08ba11a0bf0dde13e301ff4de" and "3ebca7bb4a04430aecf781bee6ba7b1a1ec56a41" have entirely different histories.

45 changed files with 1418 additions and 1270 deletions

View File

@ -23,6 +23,4 @@ class CondominioController extends Controller
{ {
abort(403); abort(403);
} }
} }

View File

@ -81,7 +81,7 @@ class MovimentiController extends Controller
foreach ($movimenti as $movimento) foreach ($movimenti as $movimento)
{ {
$lista[]=[ $lista[]=[
'Data'=> date_format(date_create($movimento->Data),'d/m/Y'), 'Data'=>$movimento->Data,
'Categoria'=>$movimento->Categoria, 'Categoria'=>$movimento->Categoria,
'Tag'=>$movimento->Tag, 'Tag'=>$movimento->Tag,
'Descrizione'=>$movimento->Descrizione, 'Descrizione'=>$movimento->Descrizione,

View File

@ -4,59 +4,58 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
// use Junges\ACL\Models\Group; use Junges\ACL\Models\Group;
// use Junges\ACL\Models\Permission; use Junges\ACL\Models\Permission;
use Spatie\Permission\Models\Role;
use Spatie\Permission\Models\Permission;
use App\Models\User;
class Utenti extends Controller class Utenti extends Controller
{ {
//
public function createRole($ruolo) public function nuovoGruppo()
{ {
$role=Role::create(['name'=>$ruolo]); return view('vendor.junges.form_addGroup',['gruppi'=>Utenti::getGruppi()]);
return json_encode(Role::all()->pluck('name'));
} }
function createPermission($permesso){ public function saveNuovoGruppo(Request $request)
$permission=Permission::create(['name'=>$permesso]); {
return json_encode(Permission::all()->pluck('name')); $group=Group::create(['name' => $request['gruppo'],'description'=>$request['descrizione']]);
return view('vendor.junges.form_addGroup',['gruppi'=>Utenti::getGruppi()]);
} }
function userClass() { public function nuovoPermesso()
$user=new User(); {
return get_class_methods($user); return view('vendor.junges.form_addPermission',['permessi'=>Utenti::getPermessi()]);
}
public function saveNuovoPermesso(Request $request)
{
$group=Permission::create(['name' => $request['permesso'],'description'=>$request['descrizione']]);
return view('vendor.junges.form_addPermission',['permessi'=>Utenti::getPermessi()]);
} }
// post del create user public function getPermessi()
function createUser(Request $params){ {
User::addUser($params); return DB::table('permissions')->orderBy('name')->get();
return redirect('/admin/users/new');
} }
// mostra il form della creazione dell'utente public function getGruppi()
function addUser(){ {
$roles = Role::all(); return DB::table('groups')->orderBy('name')->get();
$users = User::all();
return view('users.create',['ruoli'=>$roles,'users'=>$users]);
} }
function listUser(){ public function vw_assignToGroup()
$users = User::all(); {
return view('users.list',['users'=>$users]); return view('vendor.junges.assignPermissionToGroup',[
'permessi'=>Utenti::getPermessi(),
'gruppi'=>Utenti::getGruppi(),
]);
} }
function listRoles(){ public function assignPermissionToGroup(Request $request)
$roles = Role::all(); {
return $roles; $group=Group::findByName($request['gruppo']);
$group->assignPermission($request['permesso']);
return view('vendor.junges.assignPermissionToGroup',[
'permessi'=>Utenti::getPermessi(),
'gruppi'=>Utenti::getGruppi(),
]);
} }
function deleteUser($id) {
User::destroy($id);
return redirect('/admin/users/new');
}
} }

View File

@ -63,8 +63,6 @@ class Kernel extends HttpKernel
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
'role_or_permission' => \Spatie\Permission\Middlewares\RoleOrPermissionMiddleware::class,
]; ];
} }

View File

@ -2,20 +2,21 @@
namespace App\Models; namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Laravel\Sanctum\HasApiTokens; use Laravel\Sanctum\HasApiTokens;
use Spatie\Permission\Traits\HasRoles; //use LdapRecord\Laravel\Auth\Authenticatable;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Junges\ACL\Concerns\HasGroups;
class User extends Authenticatable class User extends Authenticatable
{ {
use HasApiTokens, HasFactory, Notifiable, HasRoles,Authorizable; use HasApiTokens, HasFactory, Notifiable, HasGroups, SoftDeletes;
/** /**
* The attributes that are mass assignable. * The attributes that are mass assignable.
@ -26,7 +27,6 @@ class User extends Authenticatable
'name', 'name',
'email', 'email',
'password', 'password',
'user_role',
]; ];
/** /**
@ -48,8 +48,6 @@ class User extends Authenticatable
'email_verified_at' => 'datetime', 'email_verified_at' => 'datetime',
]; ];
protected $guard_name = 'web';
public function getLdapDomainColumn() public function getLdapDomainColumn()
{ {
return 'domain'; return 'domain';
@ -70,24 +68,11 @@ class User extends Authenticatable
{ {
return DB::table('users')->where('id','=',$id)->get(); return DB::table('users')->where('id','=',$id)->get();
} }
public static function getUsers() public static function getUsers()
{ {
return DB::table('users')->orderBy('name')->get(); return DB::table('users')->orderBy('name')->get();
} }
// Aggiunge un utente e assegna un ruolo
public static function addUser($params)
{
self::create([
'name'=>$params['name'],
'email'=>$params['email'],
'password'=>Hash::make($params['password']),
])->assignRole($params['role']);
}
} }

View File

@ -26,10 +26,5 @@ class AuthServiceProvider extends ServiceProvider
$this->registerPolicies(); $this->registerPolicies();
// //
Gate::before(function ($user, $ability) {
if ($user->hasRole('admin')) {
return true;
}
});
} }
} }

View File

@ -10,10 +10,6 @@
"require" : { "require" : {
"php": "^7.3|^8.0", "php": "^7.3|^8.0",
"barryvdh/laravel-dompdf": "^2.0", "barryvdh/laravel-dompdf": "^2.0",
<<<<<<< HEAD
"directorytree/ldaprecord": "^2.9",
=======
>>>>>>> 3ebca7bb4a04430aecf781bee6ba7b1a1ec56a41
"fruitcake/laravel-cors": "^2.0", "fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1", "guzzlehttp/guzzle": "^7.0.1",
"laravel-notification-channels/telegram": "^2.0", "laravel-notification-channels/telegram": "^2.0",
@ -22,12 +18,12 @@
"laravel/tinker": "^2.5", "laravel/tinker": "^2.5",
"laravel/ui": "^3.4", "laravel/ui": "^3.4",
"laraveldaily/laravel-charts": "^0.1.29", "laraveldaily/laravel-charts": "^0.1.29",
"mateusjunges/laravel-acl": "^4.2",
"rap2hpoutre/fast-excel": "^3.2", "rap2hpoutre/fast-excel": "^3.2",
"secondtruth/startmin": "^1.1", "secondtruth/startmin": "^1.1",
"sfneal/view-export": "^2.10", "sfneal/view-export": "^2.10",
"snapappointments/bootstrap-select": "^1.13", "snapappointments/bootstrap-select": "^1.13",
"spatie/laravel-backup": "^7.0", "spatie/laravel-backup": "^7.0",
"spatie/laravel-permission": "^5.10",
"webklex/laravel-imap": "^2.4" "webklex/laravel-imap": "^2.4"
}, },
"require-dev" : { "require-dev" : {

1055
composer.lock generated

File diff suppressed because it is too large Load Diff

106
config/acl.php Normal file
View File

@ -0,0 +1,106 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Models
|--------------------------------------------------------------------------
|
| When using this package, we need to know which Eloquent Model should be used
| to retrieve your groups and permissions. Of course, it is just the basics models
| needed, but you can use whatever you like.
|
*/
'models' => [
/*
| The model you want to use as Permission model must use the MateusJunges\ACL\Traits\PermissionsTrait
*/
'permission' => Junges\ACL\Models\Permission::class,
/*
| The model you want to use as Group model must use the MateusJunges\ACL\Traits\GroupsTrait
*/
'group' => Junges\ACL\Models\Group::class,
],
/*
|--------------------------------------------------------------------------
| Route Model Binding
|--------------------------------------------------------------------------
|
| If you would like model binding to use a database column other than id when
| retrieving a given model class, you may override the getRouteKeyName method
| on the Eloquent model with yours. The default key used for route model binding
| in this package is the `id` database column. You can modify it by changing the
| following configuration:
|
*/
'route_model_binding_keys' => [
'group_model' => 'id',
'permission_model' => 'id',
],
/*
|--------------------------------------------------------------------------
| Tables
|--------------------------------------------------------------------------
| Specify the basics authentication tables that you are using.
| Once you required this package, the following tables are
| created by default when you run the command
|
| php artisan migrate
|
| If you want to change this tables, please keep the basic structure unchanged.
|
*/
'tables' => [
'groups' => 'groups',
'permissions' => 'permissions',
'users' => 'users',
'group_has_permissions' => 'group_has_permissions',
'model_has_permissions' => 'model_has_permissions',
'model_has_groups' => 'model_has_groups',
],
'column_names' => [
'group_pivot_key' => null,
'permission_pivot_key' => null,
'model_morph_key' => 'model_id',
'team_foreign_key' => 'team_id'
],
'teams' => false,
/*
|--------------------------------------------------------------------------
| Ignition Solution Suggestions
|--------------------------------------------------------------------------
|
| To enable the ignition solutions for laravel-acl, set this flag to true.
|
| The solutions will then be automatically registered with ignition if its installed.
|
*/
'offer_solutions' => false,
'register_permission_check_method' => true,
'cache' => [
/*
* All permissions are cached for 24 hours by default. If permissions or groups are updated,
* then the cache is flushed automatically.
*/
'expiration_time' => DateInterval::createFromDateString('24 hours'),
/*
* The cache key used to store permissions.
*/
'key' => 'junges.acl.cache',
/*
* You can optionally specify a cache driver to use for permissions caching using
* store drivers listed in config/cache.php.
*/
'store' => 'default'
]
];

View File

@ -162,7 +162,6 @@ return [
Illuminate\Validation\ValidationServiceProvider::class, Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class, Illuminate\View\ViewServiceProvider::class,
/* /*
* Package Service Providers... * Package Service Providers...
*/ */
@ -175,7 +174,6 @@ return [
// App\Providers\BroadcastServiceProvider::class, // App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class, App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class, App\Providers\RouteServiceProvider::class,
Spatie\Permission\PermissionServiceProvider::class,
], ],

View File

@ -60,14 +60,26 @@ return [
*/ */
'providers' => [ 'providers' => [
'users' => [ 'ldap' => [
'driver' => 'eloquent', 'driver' => 'ldap', //'eloquent',
'model' => App\Models\User::class, 'model' => LdapRecord\Models\ActiveDirectory\User::class, //App\Models\User::class,
'rules' => [
App\Ldap\Rules\OnlyInGroupUsers::class,
], ],
/*'users' => [ 'database' => [
'model' => App\Models\User::class,
'sync_passwords'=> false,
'sync_attributes' => [
'name' => 'displayname',
'email' => 'mail',
],
],
],
'users' => [
'driver' => 'database', 'driver' => 'database',
'table' => 'users', 'table' => 'users',
],*/ ],
], ],
/* /*

View File

@ -1,161 +0,0 @@
<?php
return [
'models' => [
/*
* When using the "HasPermissions" trait from this package, we need to know which
* Eloquent model should be used to retrieve your permissions. Of course, it
* is often just the "Permission" model but you may use whatever you like.
*
* The model you want to use as a Permission model needs to implement the
* `Spatie\Permission\Contracts\Permission` contract.
*/
'permission' => Spatie\Permission\Models\Permission::class,
/*
* When using the "HasRoles" trait from this package, we need to know which
* Eloquent model should be used to retrieve your roles. Of course, it
* is often just the "Role" model but you may use whatever you like.
*
* The model you want to use as a Role model needs to implement the
* `Spatie\Permission\Contracts\Role` contract.
*/
'role' => Spatie\Permission\Models\Role::class,
],
'table_names' => [
/*
* When using the "HasRoles" trait from this package, we need to know which
* table should be used to retrieve your roles. We have chosen a basic
* default value but you may easily change it to any table you like.
*/
'roles' => 'roles',
/*
* When using the "HasPermissions" trait from this package, we need to know which
* table should be used to retrieve your permissions. We have chosen a basic
* default value but you may easily change it to any table you like.
*/
'permissions' => 'permissions',
/*
* When using the "HasPermissions" trait from this package, we need to know which
* table should be used to retrieve your models permissions. We have chosen a
* basic default value but you may easily change it to any table you like.
*/
'model_has_permissions' => 'model_has_permissions',
/*
* When using the "HasRoles" trait from this package, we need to know which
* table should be used to retrieve your models roles. We have chosen a
* basic default value but you may easily change it to any table you like.
*/
'model_has_roles' => 'model_has_roles',
/*
* When using the "HasRoles" trait from this package, we need to know which
* table should be used to retrieve your roles permissions. We have chosen a
* basic default value but you may easily change it to any table you like.
*/
'role_has_permissions' => 'role_has_permissions',
],
'column_names' => [
/*
* Change this if you want to name the related pivots other than defaults
*/
'role_pivot_key' => null, //default 'role_id',
'permission_pivot_key' => null, //default 'permission_id',
/*
* Change this if you want to name the related model primary key other than
* `model_id`.
*
* For example, this would be nice if your primary keys are all UUIDs. In
* that case, name this `model_uuid`.
*/
'model_morph_key' => 'model_id',
/*
* Change this if you want to use the teams feature and your related model's
* foreign key is other than `team_id`.
*/
'team_foreign_key' => 'team_id',
],
/*
* When set to true, the method for checking permissions will be registered on the gate.
* Set this to false, if you want to implement custom logic for checking permissions.
*/
'register_permission_check_method' => true,
/*
* When set to true the package implements teams using the 'team_foreign_key'. If you want
* the migrations to register the 'team_foreign_key', you must set this to true
* before doing the migration. If you already did the migration then you must make a new
* migration to also add 'team_foreign_key' to 'roles', 'model_has_roles', and
* 'model_has_permissions'(view the latest version of package's migration file)
*/
'teams' => false,
/*
* When set to true, the required permission names are added to the exception
* message. This could be considered an information leak in some contexts, so
* the default setting is false here for optimum safety.
*/
'display_permission_in_exception' => false,
/*
* When set to true, the required role names are added to the exception
* message. This could be considered an information leak in some contexts, so
* the default setting is false here for optimum safety.
*/
'display_role_in_exception' => false,
/*
* By default wildcard permission lookups are disabled.
*/
'enable_wildcard_permission' => false,
'cache' => [
/*
* By default all permissions are cached for 24 hours to speed up performance.
* When permissions or roles are updated the cache is flushed automatically.
*/
'expiration_time' => \DateInterval::createFromDateString('24 hours'),
/*
* The cache key used to store all permissions.
*/
'key' => 'spatie.permission.cache',
/*
* You may optionally indicate a specific cache driver to use for permission and
* role caching using any of the `store` drivers listed in the cache.php config
* file. Using 'default' here means to use the `default` set in cache.php.
*/
'store' => 'default',
],
];

View File

@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePermissionsTable extends Migration
{
public function up()
{
$permissionsTable = config('acl.tables.permissions', 'permissions');
Schema::create($permissionsTable, function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('guard_name');
$table->text('description')->nullable();
$table->softDeletes();
$table->timestamps();
$table->unique(['name', 'guard_name']);
});
}
public function down()
{
$tables = config('acl.tables');
Schema::dropIfExists($tables['permissions']);
}
}

View File

@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateGroupsTable extends Migration
{
public function up()
{
$groupsTable = config('acl.tables.groups', 'groups');
$teams = config('acl.teams');
$columnNames = config('acl.column_names');
Schema::create($groupsTable, function (Blueprint $table) use ($teams, $columnNames) {
$table->bigIncrements('id');
if ($teams || config("acl.testing")) {
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
$table->index($columnNames['team_foreign_key'], 'groups_team_foreign_key_index');
}
$table->string('name');
$table->string('guard_name');
$table->text('description')->nullable();
$table->softDeletes();
$table->timestamps();
if ($teams || config('acl.testing')) {
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
} else {
$table->unique(['name', 'guard_name']);
}
});
}
public function down()
{
$groupsTable = config('acl.tables.groups', 'groups');
Schema::dropIfExists($groupsTable);
}
}

View File

@ -0,0 +1,47 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Junges\ACL\AclRegistrar;
class CreateModelHasPermissionsTable extends Migration
{
public function up()
{
$columnNames = config('acl.column_names');
$modelHasPermissions = config('acl.tables.model_has_permissions', 'model_has_permissions');
$permissionsTable = config('acl.tables.permissions', 'permissions');
$teams = config('acl.teams');
Schema::create($modelHasPermissions, function (Blueprint $table) use ($permissionsTable, $columnNames, $teams) {
$table->unsignedBigInteger(AclRegistrar::$pivotPermission);
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_id_model_type_index');
$table->foreign(AclRegistrar::$pivotPermission)
->references('id')
->on($permissionsTable)
->cascadeOnDelete();
if ($teams) {
$table->unsignedBigInteger($columnNames['team_foreign_key']);
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
$table->primary([$columnNames['team_foreign_key'], AclRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary');
} else {
$table->primary([AclRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary');
}
});
}
public function down()
{
$modelHasPermissionTable = config('acl.tables.model_has_permissions', 'model_has_permissions');
Schema::dropIfExists($modelHasPermissionTable);
}
}

View File

@ -0,0 +1,47 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Junges\ACL\AclRegistrar;
class CreateModelHasGroupsTable extends Migration
{
public function up()
{
$columnNames = config('acl.column_names');
$modelHasGroups = config('acl.tables.model_has_groups', 'model_has_groups');
$groupsTable = config('acl.tables.groups', 'groups');
$teams = config('acl.teams');
Schema::create($modelHasGroups, function (Blueprint $table) use ($groupsTable, $columnNames, $teams) {
$table->unsignedBigInteger(AclRegistrar::$pivotGroup);
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_groups_model_id_model_type_index');
$table->foreign(AclRegistrar::$pivotGroup)
->references('id')
->on($groupsTable)
->cascadeOnDelete();
if ($teams) {
$table->unsignedBigInteger($columnNames['team_foreign_key']);
$table->index($columnNames['team_foreign_key'], 'model_has_groups_team_foreign_key_index');
$table->primary([$columnNames['team_foreign_key'], AclRegistrar::$pivotGroup, $columnNames['model_morph_key'], 'model_type'],
'model_has_groups_group_model_type_primary');
} else {
$table->primary([AclRegistrar::$pivotGroup, $columnNames['model_morph_key'], 'model_type'],
'model_has_groups_group_model_type_primary');
}
});
}
public function down()
{
$modelHasGroupsTable = config('acl.tables.model_has_groups', 'model_has_groups');
Schema::dropIfExists($modelHasGroupsTable);
}
}

View File

@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Junges\ACL\AclRegistrar;
class CreateGroupHasPermissionsTable extends Migration
{
public function up()
{
$groupHasPermissionTable = config('acl.tables.group_has_permissions', 'group_has_permissions');
$groupsTable = config('acl.tables.groups', 'groups');
$permissionsTable = config('acl.tables.permissions', 'permissions');
Schema::create($groupHasPermissionTable, function (Blueprint $table) use ($groupsTable, $permissionsTable) {
$table->unsignedBigInteger(AclRegistrar::$pivotPermission);
$table->unsignedBigInteger(AclRegistrar::$pivotGroup);
$table->foreign(AclRegistrar::$pivotPermission)
->references('id')
->on($permissionsTable)
->cascadeOnDelete();
$table->foreign(AclRegistrar::$pivotGroup)
->references('id')
->on($groupsTable)
->cascadeOnDelete();
$table->primary([AclRegistrar::$pivotPermission, AclRegistrar::$pivotGroup], 'group_has_permission_permission_id_group_id_primary');
});
}
public function down()
{
$groupHasPermissionsTable = config('acl.tables.group_has_permissions', 'group_has_permissions');
Schema::dropIfExists($groupHasPermissionsTable);
}
}

View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class ColumnUsersRoles extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
//
$table->softDeletes();
$table->string('user_role',25)->default('user')->nullable(false);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
//
$table->dropColumn('user_role');
$table->dropSoftDeletes();
});
}
}

View File

@ -1,141 +0,0 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Spatie\Permission\PermissionRegistrar;
class CreatePermissionTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$tableNames = config('permission.table_names');
$columnNames = config('permission.column_names');
$teams = config('permission.teams');
if (empty($tableNames)) {
throw new \Exception('Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
}
if ($teams && empty($columnNames['team_foreign_key'] ?? null)) {
throw new \Exception('Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
}
Schema::create($tableNames['permissions'], function (Blueprint $table) {
$table->bigIncrements('id'); // permission id
$table->string('name'); // For MySQL 8.0 use string('name', 125);
$table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
$table->timestamps();
$table->unique(['name', 'guard_name']);
});
Schema::create($tableNames['roles'], function (Blueprint $table) use ($teams, $columnNames) {
$table->bigIncrements('id'); // role id
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
}
$table->string('name'); // For MySQL 8.0 use string('name', 125);
$table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
$table->timestamps();
if ($teams || config('permission.testing')) {
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
} else {
$table->unique(['name', 'guard_name']);
}
});
Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) {
$table->unsignedBigInteger(PermissionRegistrar::$pivotPermission);
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
$table->foreign(PermissionRegistrar::$pivotPermission)
->references('id') // permission id
->on($tableNames['permissions'])
->onDelete('cascade');
if ($teams) {
$table->unsignedBigInteger($columnNames['team_foreign_key']);
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
$table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary');
} else {
$table->primary([PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary');
}
});
Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) {
$table->unsignedBigInteger(PermissionRegistrar::$pivotRole);
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
$table->foreign(PermissionRegistrar::$pivotRole)
->references('id') // role id
->on($tableNames['roles'])
->onDelete('cascade');
if ($teams) {
$table->unsignedBigInteger($columnNames['team_foreign_key']);
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
$table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary');
} else {
$table->primary([PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary');
}
});
Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) {
$table->unsignedBigInteger(PermissionRegistrar::$pivotPermission);
$table->unsignedBigInteger(PermissionRegistrar::$pivotRole);
$table->foreign(PermissionRegistrar::$pivotPermission)
->references('id') // permission id
->on($tableNames['permissions'])
->onDelete('cascade');
$table->foreign(PermissionRegistrar::$pivotRole)
->references('id') // role id
->on($tableNames['roles'])
->onDelete('cascade');
$table->primary([PermissionRegistrar::$pivotPermission, PermissionRegistrar::$pivotRole], 'role_has_permissions_permission_id_role_id_primary');
});
app('cache')
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
->forget(config('permission.cache.key'));
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$tableNames = config('permission.table_names');
if (empty($tableNames)) {
throw new \Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
}
Schema::drop($tableNames['role_has_permissions']);
Schema::drop($tableNames['model_has_roles']);
Schema::drop($tableNames['model_has_permissions']);
Schema::drop($tableNames['roles']);
Schema::drop($tableNames['permissions']);
}
}

View File

@ -18,7 +18,6 @@ class DatabaseSeeder extends Seeder
UserSeeder::class, UserSeeder::class,
TagSeeder::class, TagSeeder::class,
CategorieSeeder::class, CategorieSeeder::class,
RoleSeeder::class,
]); ]);
} }
} }

View File

@ -1,83 +0,0 @@
<?php
namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
use Spatie\Permission\Models\Permission;
use Spatie\Permission\Models\Role;
use Spatie\Permission\PermissionRegistrar;
class RoleSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// Role Creation
$role_admin = Role::create([
'name' => 'admin'
]);
$role_user = Role::create([
'name' => 'user'
]);
$role_guest = Role::create([
'name' => 'guest'
]);
// Permission Creation
Permission::create([
'name' => 'conti'
]);
Permission::create([
'name' => 'consumi'
]);
Permission::create([
'name' => 'automobili'
]);
Permission::create([
'name' => 'contatti'
]);
Permission::create([
'name' => 'affitti'
]);
Permission::create([
'name' => 'progetti'
]);
Permission::create([
'name' => 'amministrazione'
]);
// Assegnazione permessi al ruolo user
$role_user->givePermissionTo('affitti');
$role_user->givePermissionTo('automobili');
$role_user->givePermissionTo('contatti');
$role_user->givePermissionTo('consumi');
$role_user->givePermissionTo('conti');
$role_user->givePermissionTo('progetti');
// Assegnazione permessi al ruolo guest
$role_guest->givePermissionTo('affitti');
$admin = User::create([
'name'=>'Amministratore',
'email'=>'admin@localhost.local',
'password'=>Hash::make('password'),
])->assignRole($role_admin);
$user = User::create([
'name'=>'Utente',
'email'=>'user@localhost.local',
'password'=>Hash::make('password'),
])->assignRole($role_user);
$guest = User::create([
'name'=>'Guest',
'email'=>'guest@localhost.local',
'password'=>Hash::make('password'),
])->assignRole($role_guest);
}
}

View File

@ -22,9 +22,14 @@ class UserSeeder extends Seeder
'name'=>'SystemUser', 'name'=>'SystemUser',
'email'=>'system@localhost.local', 'email'=>'system@localhost.local',
'password'=>Hash::make(Str::random(16)), 'password'=>Hash::make(Str::random(16)),
] ]
); );
DB::table('users')->insert(
[
'name'=>'admin',
'email'=>env('SYSADMIN_MAIL'),
'password'=>Hash::make('admin'),
]
);
} }
} }

View File

@ -1,21 +1,10 @@
$(document).ready(function() { $(document).ready(function() {
$('#automobili').DataTable({ $('#automobili').DataTable({
responsive: true responsive: true
fields: [ });
{ });
label:"Data", $(document).ready(function() {
type: "datetime" $('#contatti').DataTable({
} responsive: true
]
});
$('#contatti').DataTable({
responsive: true
fields: [
{
label:"Data",
type: "datetime"
}
]
}); });
}); });

View File

@ -1,12 +1,6 @@
$(document).ready(function() { $(document).ready(function() {
$('#automobili').DataTable({ $('#automobili').DataTable({
responsive: true, responsive: true
fields: [
{
label:"Data",
type: "datetime"
}
]
}); });
}); });

View File

@ -1,29 +1,20 @@
$(document).ready(function() { $(document).ready(function() {
$('#listrapportoS').DataTable({ $('#listrapportoS').DataTable({
responsive: true, responsive: true
fields: [
{
label:"Data",
type: "datetime"
}
]
}); });
});
$(document).ready(function() {
$('#listrapportoE').DataTable({ $('#listrapportoE').DataTable({
responsive: true, responsive: true
fields: [
{
label:"Data",
type: "datetime"
}
]
}); });
});
$(document).ready(function() {
$('#categorie').DataTable({ $('#categorie').DataTable({
responsive: true responsive: true
}); });
});
$(document).on('click','.open_modal',function(){ $(document).on('click','.open_modal',function(){
var url = "/admin/categorie/modify"; var url = "/admin/categorie/modify";
var riga_id= $(this).val(); var riga_id= $(this).val();
$.getJSON(url + '/' + riga_id, function (data) { $.getJSON(url + '/' + riga_id, function (data) {
@ -34,9 +25,9 @@ $(document).on('click','.open_modal',function(){
$('#H_cat_id').val(data[0].id); $('#H_cat_id').val(data[0].id);
$('#myModal').modal('show'); $('#myModal').modal('show');
}); });
}); });
$(document).on('click','.open_modal_new',function(){ $(document).on('click','.open_modal_new',function(){
$('#myModal_new').modal('show'); $('#myModal_new').modal('show');
}); });
});

View File

@ -1,11 +1,5 @@
$(document).ready(function() { $(document).ready(function() {
$('#listaLettureEnel').DataTable({ $('#listaLettureEnel').DataTable({
responsive: true, responsive: true
fields: [
{
label:"Data lettura",
type: "datetime"
}
]
}); });
}); });

View File

@ -1,11 +1,5 @@
$(document).ready(function() { $(document).ready(function() {
$('#listaLettureGas').DataTable({ $('#listaLettureGas').DataTable({
responsive: true, responsive: true
fields: [
{
label:"Data lettura",
type: "datetime"
}
]
}); });
}); });

View File

@ -1,12 +1,6 @@
$(document).ready(function() { $(document).ready(function() {
$('#listamovimenti').DataTable({ $('#listamovimenti').DataTable({
"responsive": true, "responsive": true,
fields: [
{
label:"Data",
type: "datetime"
}
],
"order": [[0, "desc"]] "order": [[0, "desc"]]
}); });
}); });

View File

@ -1,7 +1,7 @@
$(document).ready(function() { $(document).ready(function() {
$('#tab_progetti').DataTable({ $('#tab_progetti').DataTable({
responsive: true, responsive: true
fields: [ fields: [
{ {
label:"Data", label:"Data",

View File

@ -88,7 +88,7 @@
@foreach($operazione as $operazioni) @foreach($operazione as $operazioni)
@if ($operazioni->type =='revisione') @if ($operazioni->type =='revisione')
<tr> <tr>
<td>{{ date_format(date_create($operazioni->data),'d/m/Y'); }}</td> <td>{{ $operazioni->data; }}</td>
<td>{{ $operazioni->km; }}</td> <td>{{ $operazioni->km; }}</td>
@if($revisione[$operazioni->id][0]->superata >0) @if($revisione[$operazioni->id][0]->superata >0)
<td>Superata</td> <td>Superata</td>
@ -135,7 +135,7 @@
@foreach($operazione as $operazioni) @foreach($operazione as $operazioni)
@if ($operazioni->type =='manutenzione') @if ($operazioni->type =='manutenzione')
<tr> <tr>
<td>{{ date_format(date_create($operazioni->data),'d/m/Y'); }}</td> <td>{{ $operazioni->data; }}</td>
<td>{{ $operazioni->km; }}</td> <td>{{ $operazioni->km; }}</td>
<td>{{ $manutenzione[$operazioni->id][0]->descrizione; }}</td> <td>{{ $manutenzione[$operazioni->id][0]->descrizione; }}</td>
<td>{{ $operazioni->importo; }}</td> <td>{{ $operazioni->importo; }}</td>
@ -175,7 +175,7 @@
@foreach($operazione as $operazioni) @foreach($operazione as $operazioni)
@if ($operazioni->type=='accessori') @if ($operazioni->type=='accessori')
<tr> <tr>
<td>{{ date_format(date_create($operazioni->data),'d/m/Y'); }}</td> <td>{{ $operazioni->data; }}</td>
<td>{{ $operazioni->km; }}</td> <td>{{ $operazioni->km; }}</td>
<td>{{ $accessori[$operazioni->id][0]->descrizione; }}</td> <td>{{ $accessori[$operazioni->id][0]->descrizione; }}</td>
<td>{{ $operazioni->importo; }}</td> <td>{{ $operazioni->importo; }}</td>
@ -217,7 +217,7 @@
@foreach($operazione as $operazioni) @foreach($operazione as $operazioni)
@if ($operazioni->type =='rifornimento') @if ($operazioni->type =='rifornimento')
<tr> <tr>
<td>{{ date_format(date_create($operazioni->data),'d/m/Y'); }}</td> <td>{{ $operazioni->data; }}</td>
<td>{{ $operazioni->km; }}</td> <td>{{ $operazioni->km; }}</td>
<td>{{ $rifornimento[$operazioni->id][0]->distributore; }}</td> <td>{{ $rifornimento[$operazioni->id][0]->distributore; }}</td>
<td>{{ $rifornimento[$operazioni->id][0]->eurolitro; }}</td> <td>{{ $rifornimento[$operazioni->id][0]->eurolitro; }}</td>

View File

@ -97,7 +97,7 @@ table{
@foreach($operazione as $operazioni) @foreach($operazione as $operazioni)
@if ($operazioni->type =='revisione') @if ($operazioni->type =='revisione')
<tr> <tr>
<td>{{ date_format(date_create($operazioni->data),'d/m/Y'); }}</td> <td>{{ $operazioni->data; }}</td>
<td>{{ $operazioni->km; }}</td> <td>{{ $operazioni->km; }}</td>
<td>{{ $revisione[$operazioni->id][0]->superata; }}</td> <td>{{ $revisione[$operazioni->id][0]->superata; }}</td>
<td>{{ $revisione[$operazioni->id][0]->centrorevisione; }}</td> <td>{{ $revisione[$operazioni->id][0]->centrorevisione; }}</td>
@ -140,7 +140,7 @@ table{
@foreach($operazione as $operazioni) @foreach($operazione as $operazioni)
@if ($operazioni->type =='manutenzione') @if ($operazioni->type =='manutenzione')
<tr> <tr>
<td>{{ date_format(date_create($operazioni->data),'d/m/Y'); }}</td> <td>{{ $operazioni->data; }}</td>
<td>{{ $operazioni->km; }}</td> <td>{{ $operazioni->km; }}</td>
<td>{{ $manutenzione[$operazioni->id][0]->descrizione; }}</td> <td>{{ $manutenzione[$operazioni->id][0]->descrizione; }}</td>
<td>{{ $operazioni->importo; }}</td> <td>{{ $operazioni->importo; }}</td>
@ -180,7 +180,7 @@ table{
@foreach($operazione as $operazioni) @foreach($operazione as $operazioni)
@if ($operazioni->type=='accessori') @if ($operazioni->type=='accessori')
<tr> <tr>
<td>{{ date_format(date_create($operazioni->data),'d/m/Y'); }}</td> <td>{{ $operazioni->data; }}</td>
<td>{{ $operazioni->km; }}</td> <td>{{ $operazioni->km; }}</td>
<td>{{ $accessori[$operazioni->id][0]->descrizione; }}</td> <td>{{ $accessori[$operazioni->id][0]->descrizione; }}</td>
<td>{{ $operazioni->importo; }}</td> <td>{{ $operazioni->importo; }}</td>
@ -222,7 +222,7 @@ table{
@foreach($operazione as $operazioni) @foreach($operazione as $operazioni)
@if ($operazioni->type =='rifornimento') @if ($operazioni->type =='rifornimento')
<tr> <tr>
<td>{{ date_format(date_create($operazioni->data),'d/m/Y'); }}</td> <td>{{ $operazioni->data; }}</td>
<td>{{ $operazioni->km; }}</td> <td>{{ $operazioni->km; }}</td>
<td>{{ $rifornimento[$operazioni->id][0]->distributore; }}</td> <td>{{ $rifornimento[$operazioni->id][0]->distributore; }}</td>
<td>{{ $rifornimento[$operazioni->id][0]->eurolitro; }}</td> <td>{{ $rifornimento[$operazioni->id][0]->eurolitro; }}</td>

View File

@ -1,9 +1,7 @@
<li><a href="/admin"><i class="fa fa-dashboard fa-fw"></i>Riepilogo</a> <li><a href="/admin"><i class="fa fa-dashboard fa-fw"></i>Riepilogo</a>
</li> </li>
@can('conti')
<li><a href="#"><i class="fa fa-money fa-fw"></i>Spese/Incassi<span <li><a href="#"><i class="fa fa-money fa-fw"></i>Spese/Incassi<span
class="fa arrow"></span></a> class="fa arrow"></span></a>
<ul class="nav nav-second-level"> <ul class="nav nav-second-level">
<li><a href="{{ route('movimenti'); }}">Lista Movimenti</a></li> <li><a href="{{ route('movimenti'); }}">Lista Movimenti</a></li>
<li><a href="{{ route('categorie'); }}">Categorie</a></li> <li><a href="{{ route('categorie'); }}">Categorie</a></li>
@ -19,9 +17,7 @@
<li><a href="{{ route('importCR'); }}"><i <li><a href="{{ route('importCR'); }}"><i
class="fa fa-upload fa-fw"></i>Importa Estratto CR</a></li> class="fa fa-upload fa-fw"></i>Importa Estratto CR</a></li>
</ul></li> </ul></li>
</ul> <!-- /.nav-second-level --></li> </ul> <!-- /.nav-second-level --></li>
@endcan @can('consumi')
<li><a href="#"><i class="fa fa-industry fa-fw"></i> Consumi <span <li><a href="#"><i class="fa fa-industry fa-fw"></i> Consumi <span
class="fa arrow"></span></a> class="fa arrow"></span></a>
@ -32,10 +28,8 @@
<li><a href="{{ route('enel'); }}"><i class="fa fa-flash fa-fw"></i>Energia <li><a href="{{ route('enel'); }}"><i class="fa fa-flash fa-fw"></i>Energia
Elettrica</a></li> Elettrica</a></li>
</ul></li> </ul></li>
@endcan @can('automobili')
<li><a href="{{ route('auto_list'); }}"><i class="fa fa-car fa-fw"></i> <li><a href="{{ route('auto_list'); }}"><i class="fa fa-car fa-fw"></i>
Automobili <span class="fa arrow"></span></a></li> Automobili <span class="fa arrow"></span></a></li>
@endcan @can('contatti')
<li><a href="#"><i class="fa fa-phone-square fa-fw"></i> Contatti <span <li><a href="#"><i class="fa fa-phone-square fa-fw"></i> Contatti <span
class="fa arrow"></span></a> class="fa arrow"></span></a>
@ -46,21 +40,15 @@
<li><a href="{{ route('newContact'); }}"><i class="fa fa-plus fa-fw"></i>Nuovo <li><a href="{{ route('newContact'); }}"><i class="fa fa-plus fa-fw"></i>Nuovo
contatto</a></li> contatto</a></li>
</ul></li> </ul></li>
@endcan @can('progetti')
<li><a href="{{ route('progetti'); }}"><i class="fa fa-list fa-fw"></i> <li><a href="{{ route('progetti'); }}"><i class="fa fa-list fa-fw"></i>
Progetti <span class="fa arrow"></span></a></li> Progetti <span class="fa arrow"></span></a></li>
@endcan @can('amministrazione')
<li><a href="#"><i class="fa fa-gears fa-fw"></i>Amministrazione<span <li><a href="#"><i class="fa fa-gears fa-fw"></i>Amministrazione<span
class="fa arrow"></span></a> class="fa arrow"></span></a>
<ul class="nav nav-second-level"> <ul class="nav nav-second-level">
<li><a class="active" href="/admin/users/new">Nuovo Utente</a></li> <li><a class="active" href="#">Utenti</a></li>
<!-- <li><a class="active" href="/admin/group/new">Gruppi</a></li>
<li><a class="active" href="/admin/users/newRole">Gruppi</a></li> <li><a class="active" href="/admin/permesso/new">Permessi</a></li>
<li><a class="active" href="/admin/users/newPermission">Permessi</a></li> <li><a class="active" href="/admin/permesso/assign">Assegna Permessi
--> ai gruppi</a></li>
<li><a class="active" href="/admin/users/assignRole">Assegna Ruoli</a></li>
<!--
<li><a href="/login">Login Page</a></li> <li><a href="/login">Login Page</a></li>
-->
</ul> <!-- /.nav-second-level --></li> </ul> <!-- /.nav-second-level --></li>
@endcan

View File

@ -7,15 +7,10 @@
<ul class="dropdown-menu dropdown-user"> <ul class="dropdown-menu dropdown-user">
<li><a href="#"><i class="fa fa-user fa-fw"></i> Profilo utente</a></li> <li><a href="#"><i class="fa fa-user fa-fw"></i> Profilo utente</a></li>
<li><a href="#"><i class="fa fa-gear fa-fw"></i> Impostazioni</a></li> <li><a href="#"><i class="fa fa-gear fa-fw"></i> Impostazioni</a></li>
@role('admin')
<li class="divider"></li>
<li><a href="/admin/users/new"><i class="fa fa-gear fa-fw"></i> Gestisci Utenti</a></li>
@endrole
<li class="divider"></li> <li class="divider"></li>
<li><a href="https://github.com/fbarachino/bubofamily/issues/new/choose" target="new"><i class="fa fa-bug fa-fw"></i> Segnala un bug</a></li> <li><a href="https://github.com/fbarachino/bubofamily/issues/new/choose" target="new"><i class="fa fa-bug fa-fw"></i> Segnala un bug</a></li>
<li class="divider"></li> <li class="divider"></li>
<li><a href="{{ route('logout'); }}"><i class="fa fa-sign-out fa-fw"></i> <li><a href="{{ route('logout'); }}"><i class="fa fa-sign-out fa-fw"></i>
Logout</a></li> Logout</a></li>
</ul></li> </ul></li>
<!-- https://spatie.be/docs/laravel-permission/v5/basic-usage/new-app -->
<!-- /USERMENU --> <!-- /USERMENU -->

View File

@ -31,7 +31,7 @@
<tbody> <tbody>
@foreach( $movimenti as $movimento ) @foreach( $movimenti as $movimento )
<tr> <tr>
<td>{{ date_format(date_create($movimento->mov_data),'d/m/Y'); }}</td> <td>{{ $movimento->mov_data; }}</td>
<td>{{ $movimento->cat_name; }}</td> <td>{{ $movimento->cat_name; }}</td>
<td>{{ $movimento->mov_descrizione; }}</td> <td>{{ $movimento->mov_descrizione; }}</td>
<td>&euro; {{ $movimento->mov_importo; }}</td> <td>&euro; {{ $movimento->mov_importo; }}</td>

View File

@ -25,7 +25,7 @@
<tbody> <tbody>
@foreach( $dataSpesa as $dato ) @foreach( $dataSpesa as $dato )
<tr> <tr>
<td><a href="/admin/movimenti/report/movimenti_categoria?cat={{ $dato->id }}&month={{ $_GET['Month'] ?? date('m')}}">{{ $dato->cat_name; }}</a> </td> <td><a href="movimenti/report/movimenti_categoria?cat={{ $dato->id }}&month={{ $_GET['Month'] ?? date('m')}}">{{ $dato->cat_name; }}</a> </td>
<td>{{ $dato->resoconto; }}</td> <td>{{ $dato->resoconto; }}</td>
</tr> </tr>
@ -55,7 +55,7 @@
<tbody> <tbody>
@foreach( $dataEntrate as $dato ) @foreach( $dataEntrate as $dato )
<tr> <tr>
<td><a href="/admin/movimenti/report/movimenti_categoria?cat={{ $dato->id }}&month={{ $_GET['Month'] ?? date('m')}}">{{ $dato->cat_name; }}</a> </td> <td><a href="movimenti/report/movimenti_categoria?cat={{ $dato->id }}&month={{ $_GET['Month'] ?? date('m')}}">{{ $dato->cat_name; }}</a> </td>
<td>{{ $dato->resoconto; }}</td> <td>{{ $dato->resoconto; }}</td>
</tr> </tr>
@ -72,3 +72,4 @@
@section('script') @section('script')
<script src="/js/app/conti_categorie.js"></script> <script src="/js/app/conti_categorie.js"></script>
@endsection @endsection

View File

@ -6,7 +6,6 @@
</div> </div>
</div> </div>
<div class="row"> <div class="row">
@hasanyrole('user|admin')
<!-- WIDGET Bilancio --> <!-- WIDGET Bilancio -->
<div class="col-lg-4 col-md-8"> <div class="col-lg-4 col-md-8">
<div class="panel panel-primary"> <div class="panel panel-primary">
@ -53,7 +52,6 @@
</a> </a>
</div> </div>
</div> </div>
@endhasanyrole
</div> </div>
@endsection @endsection

View File

@ -71,7 +71,7 @@
} }
@endphp @endphp
<tr> <tr>
<td>{{ date_format(date_create($lettura->gas_date),'d/m/Y'); }}</td> <td>{{ $lettura->gas_date; }}</td>
<td>{{ $lettura->gas_lettura; }}</td> <td>{{ $lettura->gas_lettura; }}</td>
@if(!is_null($dateprec)) @if(!is_null($dateprec))
<td>{{ $diffdate ?? '' }}</td> <td>{{ $diffdate ?? '' }}</td>
@ -101,3 +101,4 @@
@section('script') @section('script')
<script src="/js/app/gas.js"></script> <script src="/js/app/gas.js"></script>
@endsection @endsection

View File

@ -1,70 +0,0 @@
@extends('admin') @section('content')
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Nuovo utente</h1>
</div>
</div>
<div class="container">
<!-- INIZIO CONTENUTO -->
<div class="row">
<form action="" method="post">
@csrf
<div class="row">
<div class="col-xs-6">
<label for="name" class="form-label">Nome</label> <input
type="text" class="form-control" id="name" name="name">
</div>
<div class="col-xs-6">
<label for="email" class="form-label">E-Mail</label> <input
type="text" class="form-control" id="email" name="email">
</div>
</div>
<div class="row">
<div class="col-xs-6">
<label for="password" class="form-label">Password</label> <input
type="password" class="form-control" id="password" name="password">
</div>
<div class="col-xs-6">
<label for="role" class="form-label">Ruolo</label> <select
class="form-control" id="role" name="role"> @foreach($ruoli as
$ruolo)
<option value="{{ $ruolo->id }}">{{$ruolo->name}}</option>
@endforeach
</select>
</div>
</div>
<div class="row">
<input type="submit" name="submit" value="Nuovo">
</div>
</form>
</div>
<div class="row">&nbsp;
</div>
<div class="row">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover"
id="users">
<thead>
<tr>
<th>Nome</th>
<th>Email</th>
<th>Azioni</th>
</tr>
</thead>
<tbody>
@foreach($users as $user)
<tr>
<td>{{ $user->name }}</td>
<td>{{ $user->email }}</td>
<td><a href="/admin/users/delete/{{ $user->id }}" class="button">Cancella</a></td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<!-- FINE CONTENUTO -->
</div>
@endsection

View File

@ -0,0 +1,73 @@
<input type="hidden" value="{{ csrf_token() }}" name="_token" id="_token">
<div class="form-group">
<label for="group-name">Nome:</label>
<input type="text"
id="group-name"
minlength="3"
name="name"
placeholder="Informe o nome do novo grupo"
value="{{ isset($group) ? $group->name : old('name') }}"
class="form-control">
@if($errors->has('name'))
<span class="text-danger">{{ $errors->first('name') }}</span>
@endif
</div>
<div class="form-group">
<label for="group-slug">Slug do grupo:</label>
<input type="text"
id="group-slug"
minlength="3"
name="slug"
placeholder="Informe o nome do novo grupo"
value="{{ isset($group) ? $group->slug : old('slug') }}"
class="form-control">
@if($errors->has('slug'))
<span class="text-danger">{{ $errors->first('slug') }}</span>
@endif
</div>
<label for="group-description">Descrição:</label>
<div class="form-group">
<textarea name="description"
id="group-description"
placeholder="Informe a descrição deste grupo"
minlength="5"
class="form-control"
cols="30" rows="10">{{ isset($group) ? $group->description : old('description') }}</textarea>
@if($errors->has('description'))
<span class="text-danger">{{ $errors->first('description') }}</span>
@endif
</div>
<div class="form-group">
<label for="group-permissions">Permissões:</label>
<select name="permissions[]"
style="width: 100%"
multiple
id="group-permissions"
class="form-control">
@if(isset($group))
@foreach($permissions as $permission)
<option value="{{ $permission->id }}"
{{ ($group->hasPermission($permission->id) ? 'selected' : '') }}
@if(old('$permissions') != null)
{{ (in_array($permission->id, old('permissions')) ? 'selected' : '') }}
@endif
>
{{ $permission->name }}
</option>
@endforeach
@else
@foreach($permissions as $permission)
<option value="{{ $permission->id }}"
@if(old('permissions') != null)
{{ in_array($permission->id, old('permissions')) ? 'selected' : '' }}
@endif
>
{{ $permission->name }}
</option>
@endforeach
@endif
</select>
@if($errors->has('permissions'))
<span class="text-danger">{{ $errors->first('permissions') }}</span>
@endif
</div>

View File

@ -0,0 +1,56 @@
<div class="form-group">
<label for="users">Selecione o usuário</label>
<select name="user"
id="users"
class="form-control">
@if(isset($user))
@foreach($users as $u)
<option value="{{ $u->id }}"
@if(($u->id == $user->id) || ($u->id == old('user')))
selected
@endif
>
{{ $u->name }}
</option>
@endforeach
@else
@foreach($users as $u)
<option value="{{ $u->id }}" {{ $u->id == old('user') ? 'selected' : '' }}>
{{ $u->name }}
</option>
@endforeach
@endif
</select>
@if($errors->has('users'))
<small class="text-danger">{{ $errors->first('users') }}</small>
@endif
</div>
<div class="form-group">
<label for="groups">Selecione os grupos:</label>
<select name="groups[]"
multiple="multiple"
id="groups" class="form-control">
@if(isset($user))
@foreach($groups as $g)
<option value="{{ $g->id }}"
{{ $user->hasGroup($g) ? 'selected' : '' }}
@if(old('groups') != null)
{{ (in_array($g->id, old('groups')) ? 'selected' : '') }}
@endif
>
{{ $g->name }}
</option>
@endforeach
@else
@foreach($groups as $g)
<option value="{{ $g->id }}"
@if(old('groups') != null)
{{ in_array($g->id, old('groups')) ? 'selected' : '' }}
@endif
>
{{ $g->name }}
</option>
@endforeach
@endif
</select>
</div>

View File

@ -0,0 +1,59 @@
@csrf
<div class="form-group">
<label for="user">Selecione o usuário:</label>
<select name="user"
id="user"
class="form-control">
@if(isset($user))
@foreach($users as $u)
<option value="{{ $user->id }}"
@if(($u->id == $user->id) || ($u->id == old('user')))
selected
@endif
>
{{ $u->name }}</option>
@endforeach
@else
@foreach($users as $u)
<option value="{{ $u->id }}" {{ $u->id == old('user') ? 'selected' : '' }}>
{{ $u->name }}</option>
@endforeach
@endif
</select>
@if($errors->has('user'))
<small class="text-danger">{{ $errors->first('user') }}</small>
@endif
</div>
<div class="form-group">
<label for="user-permissions">Permissões:</label>
<select name="permissions[]"
style="width: 100%"
multiple
id="user-permissions"
class="form-control">
@if(isset($user))
@foreach($permissions as $permission)
<option value="{{ $permission->id }}"
{{ ($user->hasDirectPermission($permission->slug) ? 'selected' : '') }}
@if(old('$permissions') != null)
{{ (in_array($permission->id, old('permissions')) ? 'selected' : '') }}
@endif
>
{{ $permission->name }}
</option>
@endforeach
@else
@foreach($permissions as $permission)
<option value="{{ $permission->id }}"
@if(old('permissions') != null)
{{ in_array($permission->id, old('permissions')) ? 'selected' : '' }}
@endif
>
{{ $permission->name }}
</option>
@endforeach
@endif
</select>
@if($errors->has('permissions'))
<span class="text-danger">{{ $errors->first('permissions') }}</span>
@endif

View File

@ -0,0 +1,44 @@
@extends('admin')
@section('content')
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Assegnazione Permessi</h1>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
Assegnazione dei permessi ai gruppi
</div>
<div class="panel-body">
<form action="" method="POST">
@csrf
<div class="mb-3">
<label for="permesso" class="form-label">Permesso:</label>
<select name="permesso" id="permesso">
@foreach($permessi as $permesso)
<option value="{{ $permesso->name; }}">{{ $permesso->name; }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="gruppo" class="form-label">Gruppo:</label>
<select name="gruppo" id="gruppo">
@foreach($gruppi as $gruppo)
<option value="{{ $gruppo->name; }}">{{ $gruppo->name; }}</option>
@endforeach
</select>
</div>
<input type="submit" value="submit">
</form>
</div>
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,67 @@
@extends('admin')
@section('content')
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Gruppi</h1>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
Inserimento dei gruppi
</div>
<div class="panel-body">
<form action="" method="POST">
@csrf
<div class="mb-3">
<label for="gruppo" class="form-label">Gruppo:</label>
<input type="text" class="form-control" name="gruppo" id="gruppo"/>
</div>
<div class="mb-3">
<label for="descrizione" class="form-label">Descrizione:</label>
<textarea name="descrizione" class="form-control" id="descrizione"></textarea>
</div>
<input type="submit" value="submit">
</form>
</div>
</div>
<div class="panel-heading">
Gruppi inseriti
</div>
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover" id="tab_gruppi">
<thead>
<tr>
<th>Gruppo</th>
<th>Descrizione</th>
</tr>
</thead>
<tbody>
@foreach($gruppi as $gruppo)
<tr>
<td>{{ $gruppo->name ?? ''; }}</td>
<td>{{ $gruppo->description ?? ''; }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
@endsection
@section('script')
<script>
$(document).ready(function() {
$('#tab_gruppi').DataTable({
responsive: true
});
});
</script>
@endsection

View File

@ -0,0 +1,67 @@
@extends('admin')
@section('content')
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Permessi</h1>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
Inserimento dei permessi
</div>
<div class="panel-body">
<form action="" method="POST">
@csrf
<div class="mb-3">
<label for="permesso" class="form-label">Permesso:</label>
<input type="text" class="form-control" name="permesso" id="permesso"/>
</div>
<div class="mb-3">
<label for="descrizione" class="form-label">Descrizione:</label>
<textarea name="descrizione" class="form-control" id="descrizione"></textarea>
</div>
<input type="submit" value="submit">
</form>
</div>
</div>
<div class="panel-heading">
Permessi inseriti
</div>
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover" id="tab_permessi">
<thead>
<tr>
<th>Permesso</th>
<th>Descrizione</th>
</tr>
</thead>
<tbody>
@foreach($permessi as $permesso)
<tr>
<td>{{ $permesso->name ?? ''; }}</td>
<td>{{ $permesso->description ?? ''; }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
@endsection
@section('script')
<script>
$(document).ready(function() {
$('#tab_permessi').DataTable({
responsive: true
});
});
</script>
@endsection

View File

@ -32,7 +32,6 @@ Route::get('/', [MovimentiController::class,'dashboard']);
Route::get('logout', function(){ Auth::logout(); return redirect('login'); })->name('logout'); Route::get('logout', function(){ Auth::logout(); return redirect('login'); })->name('logout');
// MOVIMENTI // MOVIMENTI
Route::group(['middleware'=>['permission:conti']], function(){
Route::post('movimenti/spesa',[MovimentiController::class,'insMovimentiSpesa']); Route::post('movimenti/spesa',[MovimentiController::class,'insMovimentiSpesa']);
Route::post('movimenti/entrata',[MovimentiController::class,'insMovimentiEntrata']); Route::post('movimenti/entrata',[MovimentiController::class,'insMovimentiEntrata']);
Route::get('movimenti',[MovimentiController::class,'listMovimenti'])->name('movimenti'); Route::get('movimenti',[MovimentiController::class,'listMovimenti'])->name('movimenti');
@ -65,7 +64,6 @@ Route::group(['middleware'=>['permission:conti']], function(){
// Richiami di servizio da jquery // Richiami di servizio da jquery
Route::get('service/catlist', [CategorieController::class,'apiList']); Route::get('service/catlist', [CategorieController::class,'apiList']);
Route::get('service/taglist', [TagController::class,'apiList']); Route::get('service/taglist', [TagController::class,'apiList']);
Route::get('service/rolesList', [Utenti::class,'listRoles']);
// TAGS // TAGS
Route::get('tags', [TagController::class,'listTags'])->name('tags'); Route::get('tags', [TagController::class,'listTags'])->name('tags');
@ -73,17 +71,15 @@ Route::group(['middleware'=>['permission:conti']], function(){
Route::get('tags/modify/{id}', [TagController::class,'updateTag']); Route::get('tags/modify/{id}', [TagController::class,'updateTag']);
Route::post('tags/modify', [TagController::class,'updatePostTag']); Route::post('tags/modify', [TagController::class,'updatePostTag']);
Route::get('tags/delete/{id}',[TagController::class,'deleteTag']); Route::get('tags/delete/{id}',[TagController::class,'deleteTag']);
});
// CONSUMI // CONSUMI
Route::group(['middleware'=>['permission:consumi']], function(){
Route::get('consumi/gas', [ContatoreGasController::class,'listLettureGas'])->name('gas'); Route::get('consumi/gas', [ContatoreGasController::class,'listLettureGas'])->name('gas');
Route::post('consumi/gas', [ContatoreGasController::class,'insLettureGas']); Route::post('consumi/gas', [ContatoreGasController::class,'insLettureGas']);
Route::get('consumi/enel', [ContatoreEnElController::class,'listLettureEnel'])->name('enel'); Route::get('consumi/enel', [ContatoreEnElController::class,'listLettureEnel'])->name('enel');
Route::post('consumi/enel', [ContatoreEnElController::class,'insLettureEnel']); Route::post('consumi/enel', [ContatoreEnElController::class,'insLettureEnel']);
});
// AUTOMOBILI // AUTOMOBILI
Route::group(['middleware'=>['permission:automobili']], function(){
Route::get('auto', [AutoController::class, 'index'])->name('auto_list'); Route::get('auto', [AutoController::class, 'index'])->name('auto_list');
Route::get('auto/new', [AutoController::class, 'newAuto'])->name('auto_new'); Route::get('auto/new', [AutoController::class, 'newAuto'])->name('auto_new');
Route::post('auto/new', [AutoController::class, 'saveAuto'])->name('auto_save'); Route::post('auto/new', [AutoController::class, 'saveAuto'])->name('auto_save');
@ -101,9 +97,8 @@ Route::group(['middleware'=>['permission:automobili']], function(){
Route::post('auto/accessori', [AutoController::class, 'saveAccessori']); Route::post('auto/accessori', [AutoController::class, 'saveAccessori']);
Route::get('auto/operazioni', [AutoController::class, 'getOperazioni']); Route::get('auto/operazioni', [AutoController::class, 'getOperazioni']);
Route::get('auto/operazioni/pdf', [AutoController::class, 'exportPdfOperazioni']); Route::get('auto/operazioni/pdf', [AutoController::class, 'exportPdfOperazioni']);
});
// CONTATTI // CONTATTI
Route::group(['middleware'=>['permission:contatti']], function(){
Route::get('contatti', [AnagraficaController::class, 'listContact'])->name('contatti'); Route::get('contatti', [AnagraficaController::class, 'listContact'])->name('contatti');
Route::get('contatti/new', [AnagraficaController::class, 'newContact'])->name('newContact'); Route::get('contatti/new', [AnagraficaController::class, 'newContact'])->name('newContact');
Route::post('contatti/new', [AnagraficaController::class, 'insContact']); Route::post('contatti/new', [AnagraficaController::class, 'insContact']);
@ -111,25 +106,16 @@ Route::group(['middleware'=>['permission:contatti']], function(){
Route::get('contatti/scheda', [AnagraficaController::class, 'getScheda']); Route::get('contatti/scheda', [AnagraficaController::class, 'getScheda']);
Route::get('contatti/addOther', [AnagraficaController::class, 'insOtherContact']); Route::get('contatti/addOther', [AnagraficaController::class, 'insOtherContact']);
Route::post('contatti/addOther', [AnagraficaController::class, 'saveOtherContact']); Route::post('contatti/addOther', [AnagraficaController::class, 'saveOtherContact']);
});
// GRUPPI E PERMESSI // GRUPPI E PERMESSI
Route::group(['middleware'=>['permission:amministrazione']], function(){ Route::get('group/new', [Utenti::class, 'nuovoGruppo']);
/*
Route::get('role/new/{ruolo}', [Utenti::class, 'createRole']);
Route::post('group/new', [Utenti::class, 'saveNuovoGruppo']); Route::post('group/new', [Utenti::class, 'saveNuovoGruppo']);
Route::get('permesso/new/{permesso}', [Utenti::class, 'createPermission']); Route::get('permesso/new', [Utenti::class, 'nuovoPermesso']);
Route::post('permesso/new', [Utenti::class, 'saveNuovoPermesso']); Route::post('permesso/new', [Utenti::class, 'saveNuovoPermesso']);
Route::get('permesso/assign', [Utenti::class, 'vw_assignToGroup']); Route::get('permesso/assign', [Utenti::class, 'vw_assignToGroup']);
Route::post('permesso/assign', [Utenti::class, 'assignPermissionToGroup']); Route::post('permesso/assign', [Utenti::class, 'assignPermissionToGroup']);
*/
Route::get('users/new',[Utenti::class,'addUser']);
Route::post('users/new',[Utenti::class,'createUser']);
Route::get('users/roles',[Utenti::class,'listRoles']);
Route::get('users/delete/{id}',[Utenti::class,'deleteUser']);
});
// PROGETTI // PROGETTI
Route::group(['middleware'=>['permission:progetti']], function(){
Route::get('progetti', [ProgettiController::class, 'listaProgetto'])->name('progetti'); Route::get('progetti', [ProgettiController::class, 'listaProgetto'])->name('progetti');
Route::post('progetti/new', [ProgettiController::class, 'salvaProgetto']); Route::post('progetti/new', [ProgettiController::class, 'salvaProgetto']);
Route::get('progetti/new', [ProgettiController::class, 'nuovoProgetto'])->name('nuovoProgetto'); Route::get('progetti/new', [ProgettiController::class, 'nuovoProgetto'])->name('nuovoProgetto');
@ -140,14 +126,11 @@ Route::group(['middleware'=>['permission:progetti']], function(){
Route::get('progetti/detail/edit/{id}', [RigaProgettoController::class, 'editRiga']); Route::get('progetti/detail/edit/{id}', [RigaProgettoController::class, 'editRiga']);
Route::post('progetti/rigaupdate', [RigaProgettoController::class, 'updateRiga']); Route::post('progetti/rigaupdate', [RigaProgettoController::class, 'updateRiga']);
Route::get('progetti/coordinatori', [ProgettiController::class, 'getCoordinatori']); Route::get('progetti/coordinatori', [ProgettiController::class, 'getCoordinatori']);
});
/// TEST ROUTES /// TEST ROUTES
Route::get('test/fullcalendar', [FullCalenderController::class, 'index']); Route::get('test/fullcalendar', [FullCalenderController::class, 'index']);
Route::post('test/fullcalendar', [FullCalenderController::class, 'ajax']); Route::post('test/fullcalendar', [FullCalenderController::class, 'ajax']);
Route::get('test/condominio',[CondominioController::class,'testPdf']); Route::get('test/condominio',[CondominioController::class,'testPdf']);
Route::get('test/err403',[CondominioController::class,'err403']); Route::get('test/err403',[CondominioController::class,'err403']);
Route::get('test/user_role',[CondominioController::class,'user_role']);
Route::get('test/userclass',[Utenti::class,'userClass']);