Compare commits

...

11 Commits

45 changed files with 1270 additions and 1418 deletions

View File

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

View File

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

View File

@ -4,58 +4,59 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Junges\ACL\Models\Group;
use Junges\ACL\Models\Permission;
// use Junges\ACL\Models\Group;
// use Junges\ACL\Models\Permission;
use Spatie\Permission\Models\Role;
use Spatie\Permission\Models\Permission;
use App\Models\User;
class Utenti extends Controller
{
//
public function nuovoGruppo()
public function createRole($ruolo)
{
return view('vendor.junges.form_addGroup',['gruppi'=>Utenti::getGruppi()]);
$role=Role::create(['name'=>$ruolo]);
return json_encode(Role::all()->pluck('name'));
}
function createPermission($permesso){
$permission=Permission::create(['name'=>$permesso]);
return json_encode(Permission::all()->pluck('name'));
}
public function saveNuovoGruppo(Request $request)
{
$group=Group::create(['name' => $request['gruppo'],'description'=>$request['descrizione']]);
return view('vendor.junges.form_addGroup',['gruppi'=>Utenti::getGruppi()]);
function userClass() {
$user=new User();
return get_class_methods($user);
}
public function nuovoPermesso()
{
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
function createUser(Request $params){
User::addUser($params);
return redirect('/admin/users/new');
}
public function getPermessi()
{
return DB::table('permissions')->orderBy('name')->get();
// mostra il form della creazione dell'utente
function addUser(){
$roles = Role::all();
$users = User::all();
return view('users.create',['ruoli'=>$roles,'users'=>$users]);
}
public function getGruppi()
{
return DB::table('groups')->orderBy('name')->get();
function listUser(){
$users = User::all();
return view('users.list',['users'=>$users]);
}
public function vw_assignToGroup()
{
return view('vendor.junges.assignPermissionToGroup',[
'permessi'=>Utenti::getPermessi(),
'gruppi'=>Utenti::getGruppi(),
]);
function listRoles(){
$roles = Role::all();
return $roles;
}
public function assignPermissionToGroup(Request $request)
{
$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,6 +63,8 @@ class Kernel extends HttpKernel
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::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,21 +2,20 @@
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Laravel\Sanctum\HasApiTokens;
//use LdapRecord\Laravel\Auth\Authenticatable;
use Spatie\Permission\Traits\HasRoles;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Junges\ACL\Concerns\HasGroups;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable, HasGroups, SoftDeletes;
use HasApiTokens, HasFactory, Notifiable, HasRoles,Authorizable;
/**
* The attributes that are mass assignable.
@ -27,6 +26,7 @@ class User extends Authenticatable
'name',
'email',
'password',
'user_role',
];
/**
@ -48,6 +48,8 @@ class User extends Authenticatable
'email_verified_at' => 'datetime',
];
protected $guard_name = 'web';
public function getLdapDomainColumn()
{
return 'domain';
@ -68,11 +70,24 @@ class User extends Authenticatable
{
return DB::table('users')->where('id','=',$id)->get();
}
public static function getUsers()
{
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,5 +26,10 @@ class AuthServiceProvider extends ServiceProvider
$this->registerPolicies();
//
Gate::before(function ($user, $ability) {
if ($user->hasRole('admin')) {
return true;
}
});
}
}

View File

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

1059
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,106 +0,0 @@
<?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

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

View File

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

161
config/permission.php Normal file
View File

@ -0,0 +1,161 @@
<?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

@ -1,29 +0,0 @@
<?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

@ -1,42 +0,0 @@
<?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

@ -1,47 +0,0 @@
<?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

@ -1,47 +0,0 @@
<?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

@ -1,40 +0,0 @@
<?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

@ -1,36 +0,0 @@
<?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

@ -0,0 +1,141 @@
<?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,6 +18,7 @@ class DatabaseSeeder extends Seeder
UserSeeder::class,
TagSeeder::class,
CategorieSeeder::class,
RoleSeeder::class,
]);
}
}

View File

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

View File

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

12
public/js/app/auto.js vendored
View File

@ -1,6 +1,12 @@
$(document).ready(function() {
$('#automobili').DataTable({
responsive: true
responsive: true,
fields: [
{
label:"Data",
type: "datetime"
}
]
});
});
@ -26,7 +32,7 @@ $(document).on('click', '.open_modal_modify', function() {
$.getJSON(url + '/' + riga_id, function(data) {
$('.modal-title').text('Modifica Automobile');
// $('#id').val(data.mov_data);
// $('#id').val(data.mov_data);
$('#targa').val(data.targa);
$('#marca').val(data.marca);
$('#modello').val(data.modello);
@ -85,4 +91,4 @@ $(document).on('click', '.open_modal_nuovo', function() {
$('#myModal_nuovo').modal('show');
// $('.modal-title').append(' entrata');
$('#form').attr('action', 'movimentie');
});
});

View File

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

10
public/js/app/enel.js vendored
View File

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

10
public/js/app/gas.js vendored
View File

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

View File

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

View File

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

View File

@ -4,10 +4,10 @@
<div class="col-lg-12">
<h1 class="page-header">{{ $dettagli->marca; }} {{ $dettagli->modello; }} targa: {{ $dettagli->targa; }}</h1>
</div>
</div>
</div>
<div class="container">
<!-- Content here -->
<div class="row">
<div class="col-lg-12">
<a class="btn btn-primary" href="operazioni/pdf?id={{ $dettagli->id; }}">Esporta PDF</a>
@ -19,10 +19,10 @@
<div class="panel-heading">
Dettaglio auto {{ $dettagli->targa }}
</div>
<div class="panel-body">
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover" id="">
<thead>
<tr>
<th>Marca:</th>
@ -39,7 +39,7 @@
</tr>
</thead>
<tbody>
<tr>
<td>{{ $dettagli->marca; }}</td>
<td>{{ $dettagli->modello; }}</td>
@ -53,9 +53,9 @@
<td>{{ $km ?? ''; }}</td>
<td>{{ $dettagli->note; }}</td>
</tr>
</tbody>
</table>
</div>
</div>
@ -69,10 +69,10 @@
<div class="panel-heading">
Revisioni auto {{ $dettagli->targa }}
</div>
<div class="panel-body">
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover" id="revisione">
<thead>
<tr>
<th>Data</th>
@ -88,7 +88,7 @@
@foreach($operazione as $operazioni)
@if ($operazioni->type =='revisione')
<tr>
<td>{{ $operazioni->data; }}</td>
<td>{{ date_format(date_create($operazioni->data),'d/m/Y'); }}</td>
<td>{{ $operazioni->km; }}</td>
@if($revisione[$operazioni->id][0]->superata >0)
<td>Superata</td>
@ -103,7 +103,7 @@
@endif
@endforeach
</tbody>
</table>
</div>
</div>
@ -111,7 +111,7 @@
</div>
</div>
<!-- Fine Revisioni -->
<!-- Manutenzioni -->
<div class="row">
<div class="col-lg-12">
@ -119,10 +119,10 @@
<div class="panel-heading">
Manutenzione auto {{ $dettagli->targa }}
</div>
<div class="panel-body">
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover" id="manutenzione">
<thead>
<tr>
<th>Data</th>
@ -135,7 +135,7 @@
@foreach($operazione as $operazioni)
@if ($operazioni->type =='manutenzione')
<tr>
<td>{{ $operazioni->data; }}</td>
<td>{{ date_format(date_create($operazioni->data),'d/m/Y'); }}</td>
<td>{{ $operazioni->km; }}</td>
<td>{{ $manutenzione[$operazioni->id][0]->descrizione; }}</td>
<td>{{ $operazioni->importo; }}</td>
@ -143,7 +143,7 @@
@endif
@endforeach
</tbody>
</table>
</div>
</div>
@ -151,7 +151,7 @@
</div>
</div>
<!-- Fine Manutenzioni -->
<!-- Accessori -->
<div class="row">
<div class="col-lg-12">
@ -159,10 +159,10 @@
<div class="panel-heading">
Accessori/Ricambi auto {{ $dettagli->targa }}
</div>
<div class="panel-body">
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover" id="accessori">
<thead>
<tr>
<th>Data</th>
@ -175,7 +175,7 @@
@foreach($operazione as $operazioni)
@if ($operazioni->type=='accessori')
<tr>
<td>{{ $operazioni->data; }}</td>
<td>{{ date_format(date_create($operazioni->data),'d/m/Y'); }}</td>
<td>{{ $operazioni->km; }}</td>
<td>{{ $accessori[$operazioni->id][0]->descrizione; }}</td>
<td>{{ $operazioni->importo; }}</td>
@ -183,7 +183,7 @@
@endif
@endforeach
</tbody>
</table>
</div>
</div>
@ -191,7 +191,7 @@
</div>
</div>
<!-- Fine Accessori -->
<!-- Rifornimenti -->
<div class="row">
<div class="col-lg-12">
@ -199,10 +199,10 @@
<div class="panel-heading">
Rifornimenti auto {{ $dettagli->targa }}
</div>
<div class="panel-body">
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover" id="">
<thead>
<tr>
<th>Data</th>
@ -217,7 +217,7 @@
@foreach($operazione as $operazioni)
@if ($operazioni->type =='rifornimento')
<tr>
<td>{{ $operazioni->data; }}</td>
<td>{{ date_format(date_create($operazioni->data),'d/m/Y'); }}</td>
<td>{{ $operazioni->km; }}</td>
<td>{{ $rifornimento[$operazioni->id][0]->distributore; }}</td>
<td>{{ $rifornimento[$operazioni->id][0]->eurolitro; }}</td>
@ -227,7 +227,7 @@
@endif
@endforeach
</tbody>
</table>
</div>
</div>
@ -235,7 +235,7 @@
</div>
</div>
<!-- Fine Rifornimenti -->
<!-- -->
</div>

View File

@ -30,10 +30,10 @@ table{
</style>
</head>
<body>
<body>
<div class="container">
<!-- Content here -->
<span class="titolo"><h1>Scheda {{ $dettagli->marca; }} {{ $dettagli->modello; }} - {{ $dettagli->targa; }}</h1></span>
<div class="row">
<div class="col-lg-12">
@ -41,14 +41,14 @@ table{
<div class="panel-heading">
Dettaglio
</div>
<div class="panel-body">
<div class="panel-body">
<div class="table-responsive">
<table class="intestazione_doc" id="">
<tr>
<th>Marca:</th><td>{{ $dettagli->marca; }}</td>
<th>Modello:</th><td>{{ $dettagli->modello; }}</td>
<th>Targa:</th> <td>{{ $dettagli->targa; }}</td>
</tr>
<tr>
<th>Alimentazione:</th><td>{{ $dettagli->alimentazione; }}</td>
@ -78,10 +78,10 @@ table{
<div class="panel-heading">
Revisioni
</div>
<div class="panel-body">
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover" id="revisione">
<thead>
<tr>
<th>Data</th>
@ -97,7 +97,7 @@ table{
@foreach($operazione as $operazioni)
@if ($operazioni->type =='revisione')
<tr>
<td>{{ $operazioni->data; }}</td>
<td>{{ date_format(date_create($operazioni->data),'d/m/Y'); }}</td>
<td>{{ $operazioni->km; }}</td>
<td>{{ $revisione[$operazioni->id][0]->superata; }}</td>
<td>{{ $revisione[$operazioni->id][0]->centrorevisione; }}</td>
@ -108,7 +108,7 @@ table{
@endif
@endforeach
</tbody>
</table>
</div>
</div>
@ -116,18 +116,18 @@ table{
</div>
</div>
<!-- Fine Revisioni -->
<br><hr>
<br><hr>
<!-- Manutenzioni -->
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
Manutenzione
Manutenzione
</div>
<div class="panel-body">
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover" id="manutenzione">
<thead>
<tr>
<th>Data</th>
@ -140,7 +140,7 @@ table{
@foreach($operazione as $operazioni)
@if ($operazioni->type =='manutenzione')
<tr>
<td>{{ $operazioni->data; }}</td>
<td>{{ date_format(date_create($operazioni->data),'d/m/Y'); }}</td>
<td>{{ $operazioni->km; }}</td>
<td>{{ $manutenzione[$operazioni->id][0]->descrizione; }}</td>
<td>{{ $operazioni->importo; }}</td>
@ -148,7 +148,7 @@ table{
@endif
@endforeach
</tbody>
</table>
</div>
</div>
@ -164,10 +164,10 @@ table{
<div class="panel-heading">
Accessori/Ricambi
</div>
<div class="panel-body">
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover" id="accessori">
<thead>
<tr>
<th>Data</th>
@ -180,7 +180,7 @@ table{
@foreach($operazione as $operazioni)
@if ($operazioni->type=='accessori')
<tr>
<td>{{ $operazioni->data; }}</td>
<td>{{ date_format(date_create($operazioni->data),'d/m/Y'); }}</td>
<td>{{ $operazioni->km; }}</td>
<td>{{ $accessori[$operazioni->id][0]->descrizione; }}</td>
<td>{{ $operazioni->importo; }}</td>
@ -188,7 +188,7 @@ table{
@endif
@endforeach
</tbody>
</table>
</div>
</div>
@ -204,10 +204,10 @@ table{
<div class="panel-heading">
Rifornimenti
</div>
<div class="panel-body">
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover" id="">
<thead>
<tr>
<th>Data</th>
@ -222,7 +222,7 @@ table{
@foreach($operazione as $operazioni)
@if ($operazioni->type =='rifornimento')
<tr>
<td>{{ $operazioni->data; }}</td>
<td>{{ date_format(date_create($operazioni->data),'d/m/Y'); }}</td>
<td>{{ $operazioni->km; }}</td>
<td>{{ $rifornimento[$operazioni->id][0]->distributore; }}</td>
<td>{{ $rifornimento[$operazioni->id][0]->eurolitro; }}</td>
@ -232,7 +232,7 @@ table{
@endif
@endforeach
</tbody>
</table>
</div>
</div>

View File

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

View File

@ -7,10 +7,15 @@
<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-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><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><a href="{{ route('logout'); }}"><i class="fa fa-sign-out fa-fw"></i>
Logout</a></li>
</ul></li>
<!-- https://spatie.be/docs/laravel-permission/v5/basic-usage/new-app -->
<!-- /USERMENU -->

View File

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

View File

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

View File

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

View File

@ -24,7 +24,7 @@
Nuova lettura Gas
</div>
<div class="panel-body">
<form action="" method="POST">
@csrf
<div class="mb-3">
@ -38,7 +38,7 @@
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
<div class="panel-heading">
Letture Gas
@ -57,7 +57,7 @@
</thead>
<tbody>
@php $dateprec=NULL; @endphp
@foreach($lettureGas as $lettura)
@php
if (!is_null($dateprec))
@ -65,13 +65,13 @@
$diffdate=date_diff(
date_create_from_format('Y-m-d',$lettura->gas_date),
date_create_from_format('Y-m-d',$dateprec)
)->format('%a');
)->format('%a');
$differenza=($lettura->gas_lettura)-$lettprec;
$mediagg=($differenza/$diffdate);
}
@endphp
<tr>
<td>{{ $lettura->gas_date; }}</td>
<td>{{ date_format(date_create($lettura->gas_date),'d/m/Y'); }}</td>
<td>{{ $lettura->gas_lettura; }}</td>
@if(!is_null($dateprec))
<td>{{ $diffdate ?? '' }}</td>
@ -83,9 +83,9 @@
<td></td>
@endif
</tr>
@php
$dateprec=$lettura->gas_date;
$dateprec=$lettura->gas_date;
$lettprec=$lettura->gas_lettura;
@endphp
@endforeach
@ -96,9 +96,8 @@
</div>
</div>
</div>
@endsection
@section('script')
<script src="/js/app/gas.js"></script>
@endsection

View File

@ -0,0 +1,70 @@
@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

@ -1,73 +0,0 @@
<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

@ -1,56 +0,0 @@
<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

@ -1,59 +0,0 @@
@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

@ -1,44 +0,0 @@
@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

@ -1,67 +0,0 @@
@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

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