diff --git a/app/Http/Controllers/AnagraficaController.php b/app/Http/Controllers/AnagraficaController.php
index cb24b08..08ab94a 100644
--- a/app/Http/Controllers/AnagraficaController.php
+++ b/app/Http/Controllers/AnagraficaController.php
@@ -2,9 +2,46 @@
namespace App\Http\Controllers;
+use App\Models\anagrafica;
+use App\Models\contatto;
use Illuminate\Http\Request;
class AnagraficaController extends Controller
{
//
+ public function newContact()
+ {
+ return view('anagrafica.form');
+ }
+
+ public function insContact(Request $request)
+ {
+ anagrafica::inserisci($request);
+ return view('anagrafica.list',['anagrafiche'=>anagrafica::getList()]);
+ }
+
+ public function schedaContact(Request $request)
+ {
+ $dati = anagrafica::getById($request['id']);
+ return view('anagrafica.scheda',['anagrafiche'=>$dati]);
+ }
+
+ public function listContact()
+ {
+ return view('anagrafica.list',['anagrafiche'=>anagrafica::getList()]);
+ }
+
+ public function modifica(Request $request)
+ {
+ return view('anagrafica.form',['anagrafiche'=>anagrafica::getById($request['id'])]);
+ }
+
+ public function getScheda(Request $request)
+ {
+ $id=$request['id'];
+ $anagrafica = anagrafica::getById($id);
+ $contatto=contatto::listContactsById($id);
+ return view('anagrafica.dettagli',['anagrafiche'=>$anagrafica,'contatti'=>$contatto['contatti'],'tipo'=>$contatto['tipo']]);
+
+ }
}
diff --git a/app/Models/anagrafica.php b/app/Models/anagrafica.php
index 67c3735..66a5627 100644
--- a/app/Models/anagrafica.php
+++ b/app/Models/anagrafica.php
@@ -4,20 +4,35 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\DB;
class anagrafica extends Model
{
use HasFactory;
public static function inserisci($param) {
- ;
+ DB::table('anagraficas')->insert([
+ 'ang_cognome'=>$param['ang_cognome'],
+ 'ang_nome'=>$param['ang_nome'],
+ 'ang_ragioneSociale'=>$param['ang_ragioneSociale'],
+ 'ang_codiceFiscale'=>$param['ang_codiceFiscale'],
+ 'ang_partitaIva'=>$param['ang_partitaIva'],
+ 'ang_indirizzo'=>$param['ang_indirizzo'],
+ 'ang_CAP'=>$param['ang_CAP'],
+ 'ang_Citta'=>$param['ang_Citta'],
+ 'ang_Provincia'=>$param['ang_Provincia'],
+ 'ang_telefono'=>$param['ang_telefono'],
+ 'ang_note'=>$param['ang_note'],
+ ]);
}
- public static function getList($param) {
- ;
+ public static function getList() {
+ $lista = DB::table('anagraficas')->OrderBy('ang_cognome')->get();
+ return $lista;
}
public static function getById($param) {
- ;
+
+ return DB::table('anagraficas')->where('id','=',$param)->get();
}
}
diff --git a/app/Models/contatto.php b/app/Models/contatto.php
index f14032b..7a7505a 100644
--- a/app/Models/contatto.php
+++ b/app/Models/contatto.php
@@ -4,8 +4,20 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\DB;
class contatto extends Model
{
use HasFactory;
+
+
+
+ public static function listContactsById($id)
+ {
+ $type=[1=>'Telefono',2=>'Cellulare',3=>'Fax',4=>'Email','Website'];
+ $lista=DB::table('contattos')->where('cnt_fk_anagraficaId','=',$id)->get();
+ return ['tipo'=>$type,'contatti'=>$lista];
+ }
+
+
}
diff --git a/database/migrations/2022_02_08_093657_create_anagraficas_table.php b/database/migrations/2022_02_08_093657_create_anagraficas_table.php
index 5fabac0..f89b088 100644
--- a/database/migrations/2022_02_08_093657_create_anagraficas_table.php
+++ b/database/migrations/2022_02_08_093657_create_anagraficas_table.php
@@ -19,10 +19,19 @@ class CreateAnagraficasTable extends Migration
$table->string('ang_cognome');
$table->string('ang_nome');
- $table->string('ang_ragioneSociale')->nullable();
- $table->string('ang_codiceFiscale')->nullable();
- $table->string('ang_partitaIva')->nullable();
+ $table->string('ang_ragioneSociale',255)->nullable();
+ $table->string('ang_codiceFiscale',255)->nullable();
+ $table->string('ang_partitaIva',255)->nullable();
+ $table->longText('ang_indirizzo')->nullable();
+ $table->string('ang_CAP',10)->nullable();
+ $table->string('ang_Citta',255)->nullable();
+ $table->string('ang_Provincia',255)->nullable();
+
+ //ALTER TABLE `bubofamily_db`.`anagraficas`
+ //ADD COLUMN `ang_telefono` VARCHAR(45) NOT NULL AFTER `ang_note`;
+
+ $table->string('ang_telefono',45);
$table->longText('ang_note')->nullable();
});
}
diff --git a/database/migrations/2022_02_08_122700_create_contattos_table.php b/database/migrations/2022_02_08_122700_create_contattos_table.php
index f5d29a3..167f6bf 100644
--- a/database/migrations/2022_02_08_122700_create_contattos_table.php
+++ b/database/migrations/2022_02_08_122700_create_contattos_table.php
@@ -17,7 +17,7 @@ class CreateContattosTable extends Migration
$table->id();
$table->timestamps();
$table->unsignedBigInteger('cnt_fk_anagraficaId');
- $table->foreign('cnt_fk_anagraficaId')->references('id')->on('anagraficas');
+ $table->foreign('cnt_fk_anagraficaId')->references('id')->on('anagraficas')->onDelete('cascade');
$table->integer('cnt_tipo');
$table->longText('cnt_valore');
$table->longText('cnt_note');
diff --git a/resources/views/anagrafica/dettagli.blade.php b/resources/views/anagrafica/dettagli.blade.php
new file mode 100644
index 0000000..17d507f
--- /dev/null
+++ b/resources/views/anagrafica/dettagli.blade.php
@@ -0,0 +1,103 @@
+@extends('admin')
+@section('content')
+
+
+
+
+
+
+
+ Contatto
+
+
+
+
+
+ Cognome: |
+ Nome: |
+ Ragione Sociale: |
+
+
+ {{ $anagrafiche[0]->ang_cognome }} |
+ {{ $anagrafiche[0]->ang_nome }} |
+ {{ $anagrafiche[0]->ang_ragioneSociale }}
+ |
+
+ Partita Iva: |
+ Codice Fiscale: |
+
+
+ {{ $anagrafiche[0]->ang_partitaIva }} |
+ {{ $anagrafiche[0]->ang_codiceFiscale }} |
+
+
+
+ Indirizzo: |
+
+
+ {{ $anagrafiche[0]->ang_indirizzo }} |
+
+
+ CAP |
+ Città |
+ Provincia |
+
+
+ {{ $anagrafiche[0]->ang_CAP }} |
+ {{ $anagrafiche[0]->ang_Citta }} |
+ {{ $anagrafiche[0]->ang_Provincia }} |
+
+
+ Telefono principale: |
+
+
+ {{ $anagrafiche[0]->ang_telefono }} |
+
+
+ Note: |
+
+
+ {{ $anagrafiche[0]->ang_note }} |
+
+
+
+
+
+ Tipo |
+ Valore |
+ Annotazioni |
+
+
+
+ @foreach($contatti as $contatto)
+
+ {{ $tipo[$contatto->cnt_tipo] }} |
+ {{ $contatto->cnt_valore }} |
+ {{ $contatto->cnt_note }} |
+
+ @endforeach
+
+
+
+
+
+
+
+
+
+
+@endsection
+
+@section('script')
+
+@endsection
diff --git a/resources/views/anagrafica/form.blade.php b/resources/views/anagrafica/form.blade.php
new file mode 100644
index 0000000..cb27fa1
--- /dev/null
+++ b/resources/views/anagrafica/form.blade.php
@@ -0,0 +1,105 @@
+@extends('admin')
+@section('content')
+
+
+
+
+
+
+ Nuova anagrafica
+
+
+
+
+
+
+
+
+
+@endsection
+
+@section('script')
+
+@endsection
diff --git a/resources/views/anagrafica/list.blade.php b/resources/views/anagrafica/list.blade.php
new file mode 100644
index 0000000..f23fe82
--- /dev/null
+++ b/resources/views/anagrafica/list.blade.php
@@ -0,0 +1,67 @@
+@extends('admin')
+@section('content')
+
+
+
+
+
+
+
+
+
+ Lista dei contatti
+
+
+
+
+
+
+ Cognome |
+ Nome |
+ Città |
+ Telefono |
+ Azioni |
+
+
+
+ @foreach($anagrafiche ?? '' as $anagrafica)
+
+ {{ $anagrafica->ang_cognome; }} |
+ {{ $anagrafica->ang_nome; }} |
+ {{ $anagrafica->ang_Citta; }} |
+ {{ $anagrafica->ang_telefono; }} |
+
+ Modifica
+ Cancella
+ |
+
+ @endforeach
+
+
+
+
+
+
+
+
+
+
+@endsection
+
+@section('script')
+
+@endsection
diff --git a/resources/views/components/menu.blade.php b/resources/views/components/menu.blade.php
index db5fb3f..359cc30 100644
--- a/resources/views/components/menu.blade.php
+++ b/resources/views/components/menu.blade.php
@@ -64,6 +64,20 @@
+
+ Contatti
+
+
+