Generalizzato i documenti issue

This commit is contained in:
Amministratore 2023-10-13 14:33:00 +02:00
parent 7443d52215
commit e0c8491e45
9 changed files with 170 additions and 17 deletions

View File

@ -10,10 +10,19 @@ class GenDocController extends Controller
//
public function fileForm(Request $request){
$documenti = GenDoc::listDocument($request->input('entity'),$request->input('entity_id'));
return view('conti.documenti.insert', [
return view('conti.documenti.gendoc', [
'id'=>$request->input('entity_id'),
'entity'=>$request->input('entity'),
'documenti'=>$documenti,
]);
}
public function storeFile(Request $request){
GenDoc::saveDocument($request);
return redirect()->back();
}
}

View File

@ -58,7 +58,7 @@ class Documenti extends Model
}
// Proposta modifica issue {#5 gitea} (generalizzazione del documento)
/*
/*
public static function getList($id,$entity)
{
self::where('entita','=',$entity)->where('entita_id','=',$id)->get();

View File

@ -14,7 +14,7 @@ class GenDoc extends Model
public static function saveDocument($data){
$filename=$data->file('filename')->store('Documenti');
$filename=$data->file('filename')->store(self::getEntityFolder($data['entity']));
DB::table('gen_docs')
->insert([
'entity'=>$data['entity'],
@ -27,8 +27,8 @@ class GenDoc extends Model
public static function listDocument($entity,$entity_id)
{
// Ritorna la lista dei documenti in base all'entità e al rispettivo id
// return DB::table('gen_docs')->where('entity','=',$entity)->where('entity_id','=',$entity_id)->get(); //nuova funzione
return DB::table('documentis')->where('movimenti_id','=', $entity_id)->get();
return DB::table('gen_docs')->where('entity','=',$entity)->where('entity_id','=',$entity_id)->get(); //nuova funzione
// return DB::table('documentis')->where('movimenti_id','=', $entity_id)->get();
}
public static function countDocument($entity,$entity_id){
@ -40,5 +40,14 @@ class GenDoc extends Model
return $quanti;
}
private static function getEntityFolder($entity)
{
$entity_resolve=[
0=>'Movimenti',
1=>'Contratti',
2=>'Automobili',
3=>'Progetti',
];
return $entity_resolve[$entity];
}
}

View File

@ -14,16 +14,39 @@ class Movimenti extends Model
protected $casts = [ 'mov_data'=>'datetime'];
public static function getList() {
return DB::table('movimentis')
$query='SELECT
a.id,
a.mov_data,
a.mov_importo,
a.mov_descrizione,
c.cat_name,
t.tag_name,
(SELECT Count(entity_id) as quanti FROM gen_docs WHERE entity=0 AND entity_id = a.id) as quanti
FROM movimentis as a
JOIN tags as t ON a.mov_fk_tags=t.id
JOIN categories as c ON a.mov_fk_categoria=c.id';
/* return DB::table('movimentis')
->join('categories','movimentis.mov_fk_categoria','=','categories.id')
->join('tags','movimentis.mov_fk_tags','=','tags.id')
//->leftJoin('gen_docs', 'entity_id','=','movimentis.id')
->leftJoin('documentis', 'movimenti_id','=','movimentis.id') // #issue 5
// ->where('gen_docs.entity','=',1)
->select('movimentis.id','mov_data','mov_descrizione','mov_importo','cat_name','tag_name', DB::raw('Count(movimenti_id) as quanti'))
//->select('movimentis.id','mov_data','mov_descrizione','mov_importo','cat_name','tag_name', DB::raw('Count(entity_id) as quanti'))
->groupBy('movimentis.id','mov_data','mov_descrizione','mov_importo','cat_name','tag_name')
->get();
->leftJoin('gen_docs', 'entity_id','=','movimentis.id')
// ->leftJoin('documentis', 'movimenti_id','=','movimentis.id') // #issue 5
// ->where('gen_docs.entity','=',0)
// ->select('movimentis.id','mov_data','mov_descrizione','mov_importo','cat_name','tag_name', DB::raw('Count(movimenti_id) as quanti'))
->select('movimentis.id','mov_data','mov_descrizione','mov_importo','cat_name','tag_name', DB::raw('Count(entity_id) as quanti'))
->groupBy('movimentis.id','mov_data','mov_descrizione','mov_importo','cat_name','tag_name')*/
return DB::select(DB::raw(
'SELECT
a.id,
a.mov_data,
a.mov_importo,
a.mov_descrizione,
c.cat_name,
t.tag_name,
(SELECT Count(entity_id) as quanti FROM gen_docs WHERE entity=0 AND entity_id = a.id) as quanti
FROM movimentis as a
JOIN tags as t ON a.mov_fk_tags=t.id
JOIN categories as c ON a.mov_fk_categoria=c.id'
));
}
public static function getSaldo($date) {

View File

@ -21,6 +21,7 @@
"laravel/tinker": "^2.5",
"laravel/ui": "^3.4",
"laraveldaily/laravel-charts": "^0.1.29",
"pcloud/pcloud-php-sdk": "^3.0",
"rap2hpoutre/fast-excel": "^3.2",
"secondtruth/startmin": "^1.1",
"sfneal/view-export": "^2.10",

40
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "b97b1d1172c798a3b3b8a87527b31518",
"content-hash": "6ea1c68b72b752163572b68dfb52147e",
"packages": [
{
"name": "almasaeed2010/adminlte",
@ -3870,6 +3870,44 @@
},
"time": "2020-10-15T08:29:30+00:00"
},
{
"name": "pcloud/pcloud-php-sdk",
"version": "3.0.0",
"source": {
"type": "git",
"url": "https://github.com/pCloud/pcloud-sdk-php.git",
"reference": "61fb9b98ca2db11ead4423ef16ce0ac5ea16225b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pCloud/pcloud-sdk-php/zipball/61fb9b98ca2db11ead4423ef16ce0ac5ea16225b",
"reference": "61fb9b98ca2db11ead4423ef16ce0ac5ea16225b",
"shasum": ""
},
"require": {
"ext-curl": "*",
"php": ">=7.1"
},
"require-dev": {
"phpunit/phpunit": "9.5.11"
},
"type": "library",
"autoload": {
"psr-4": {
"pCloud\\Sdk\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "pCloud SDK for PHP",
"support": {
"issues": "https://github.com/pCloud/pcloud-sdk-php/issues",
"source": "https://github.com/pCloud/pcloud-sdk-php/tree/v3"
},
"time": "2022-10-06T13:02:11+00:00"
},
{
"name": "phenx/php-font-lib",
"version": "0.5.4",

View File

@ -20,7 +20,7 @@ class CreateGenDocsTable extends Migration
$table->integer('entity')->unsigned();
$table->bigInteger('entity_id');
$table->string('filename', 255);
$table->longText('descrizone');
$table->longText('descrizione');
});
}

View File

@ -0,0 +1,73 @@
@extends('adminlte::page')
@section('content_header')
<h1>Lista Documenti</h1>
@endsection
@section('content')
<div class="container">
<!-- Content here -->
<div class="row">
<div class="col-lg-12">
<form action="" method="POST" enctype='multipart/form-data'>
@csrf
<div class="mb-3">
<label for="descrizione" class="form-label">Descrizione</label>
<input type="text" class="form-control" id="descrizione" name="descrizione">
</div>
<div class="mb-3">
<label for="file" class="form-label">File</label>
<input type="file" class="form-control" id="file" name="filename">
</div>
<div class="mb-3">
<!-- {issue #5} -->
<input type="hidden" name="entity" value="{{$entity}}">
<input type="hidden" name="entity_id" value="{{$id}}">
<!-- {issue #5} END -->
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
Lista dei documenti
</div>
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover" id="categorie">
<thead>
<tr>
<th>Descrizione</th>
<th>Azione</th>
</tr>
</thead>
<tbody>
@foreach($documenti as $documento)
<tr>
<td><a href="/storage/{{ $documento->filename; }}">{{ $documento->descrizione; }}</a></td>
<td>
<a class="btn btn-primary" href="/admin/doc_update?id={{ $documento->id; }}"><i class="fa fa-pencil-square-o fw"></i></a>&nbsp;
<a class="btn btn-danger" href="/admin/doc_delete?id={{ $documento->id; }}"><i class="fa fa-trash-o fa-fw"></i></a>&nbsp;
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!-- /.col-lg-12 -->
@endsection
@section('script')
<script src="/js/app/conti_categorie.js"></script>
@endsection

View File

@ -44,7 +44,7 @@
<td>
<button class="btn btn-warning btn-detail open_modal_modifica" value="{{ $movimento->id; }}">Edit</button>&nbsp;
<a class="btn btn-danger" href="/admin/movimenti/delete?id={{ $movimento->id; }}">Canc.</a>&nbsp;
<a class="btn btn-warning" href="/admin/movimenti/docs?entity=1&entity_id={{ $movimento->id; }}">Doc.</a>&nbsp;
<a class="btn btn-warning" href="/admin/movimenti/docs?entity=0&entity_id={{ $movimento->id; }}">Doc.</a>&nbsp;
<!-- Definisce quanti documenti sono presenti per il record -->
( {{ $movimento->quanti ?? ''; }} )
</td>