Generalizzato i documenti issue #5
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user