lavori sulla parte dei progetti.
This commit is contained in:
parent
5fed6fdf16
commit
10d5766975
@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
||||
use App\Models\Progetti;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\RigaProgetto;
|
||||
|
||||
class ProgettiController extends Controller
|
||||
{
|
||||
@ -34,15 +35,19 @@ class ProgettiController extends Controller
|
||||
return redirect(Route('progetti'));
|
||||
}
|
||||
|
||||
public function inserisciTask(Request $id)
|
||||
public function inserisciTask(Request $args)
|
||||
{
|
||||
|
||||
RigaProgetto::saveRiga($args);
|
||||
return redirect(Route('detail',['id'=>$args['fk_id_progetto']]));
|
||||
}
|
||||
|
||||
public function dettaglioProgetto(Request $id)
|
||||
{
|
||||
$progetto = Progetti::getProgettoById($id['id']);
|
||||
return view('progetti.dettaglio',['dettaglio'=>$progetto]);
|
||||
$progetto_id=$id['id'];
|
||||
$progetto = Progetti::getProgettoById($progetto_id);
|
||||
$righe = RigaProgetto::getRigheProgetto($progetto_id);
|
||||
return view('progetti.dettaglio',['dettaglio'=>$progetto, 'righe'=>$righe,]);
|
||||
//dd($righe);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,7 +27,11 @@ class Progetti extends Model
|
||||
}
|
||||
|
||||
public static function getProgettoById($id){
|
||||
return DB::table('progettis')->join('users','progettis.fk_user','=','users.id')->where('progettis.id','=',$id)->get();
|
||||
return DB::table('progettis')->
|
||||
join('users','progettis.fk_user','=','users.id')->
|
||||
select('users.id as userid', 'users.name as name', 'progettis.*')->
|
||||
where('progettis.id','=',$id)->
|
||||
get();
|
||||
}
|
||||
|
||||
public static function saveProgetto($progetto){
|
||||
|
@ -4,8 +4,25 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class RigaProgetto extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public static function getRigheProgetto($progetto_id)
|
||||
{
|
||||
return DB::table('riga_progettos')->where('fk_id_progetto','=',$progetto_id)->get();
|
||||
}
|
||||
|
||||
public static function saveRiga($args)
|
||||
{
|
||||
DB::table('riga_progettos')->insert([
|
||||
'fk_id_progetto'=>$args['fk_id_progetto'],
|
||||
'data'=>$args['data'],
|
||||
'descrizione'=>$args['descrizione'],
|
||||
'prezzo'=>$args['prezzo'],
|
||||
'ore'=>$args['ore'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,12 @@ class CreateRigaProgettosTable extends Migration
|
||||
Schema::create('riga_progettos', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
$table->date('data');
|
||||
$table->longText('descrizione');
|
||||
$table->decimal('prezzo',10,2)->nullable();
|
||||
$table->decimal('ore',10,2)->nullable();
|
||||
$table->unsignedBigInteger('fk_id_progetto');
|
||||
$table->foreign('fk_id_progetto')->references('id')->on('progettis');
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -81,14 +81,14 @@
|
||||
<div class="panel-heading" id="form">Inserisci riga (click
|
||||
show/hide)</div>
|
||||
<div class="panel-body">
|
||||
<form method="POST">
|
||||
<form method="POST" action="">
|
||||
<div class="row">
|
||||
@csrf
|
||||
<div class="col-xs-2">
|
||||
|
||||
<!-- Form per task con jquery e aggiunta righe automatica -->
|
||||
<label for="tdata" class="form-label">data:</label> <input
|
||||
type="date" name="tdata" class="form-control" id="tdata"
|
||||
type="date" name="data" class="form-control" id="data"
|
||||
value="{{ date('Y-m-d') }}">
|
||||
|
||||
</div>
|
||||
@ -96,7 +96,7 @@
|
||||
|
||||
<!-- Form per task con jquery e aggiunta righe automatica -->
|
||||
<label for="desc" class="form-label">descrizione:</label> <input
|
||||
type="text" name="desc" class="form-control" id="desc">
|
||||
type="text" name="descrizione" class="form-control" id="desc">
|
||||
|
||||
</div>
|
||||
<div class="col-xs-2">
|
||||
@ -108,10 +108,11 @@
|
||||
<div class="col-xs-2">
|
||||
<label for="ore" class="form-label">prezzo:</label>
|
||||
<!-- Form per task con jquery e aggiunta righe automatica -->
|
||||
<input type="text" name="ore" class="form-control" id="ore">
|
||||
<input type="text" name="prezzo" class="form-control" id="ore">
|
||||
|
||||
</div>
|
||||
<div class="col-xs-1">
|
||||
<input type="hidden" name="fk_id_progetto" value="{{ $progetto->id }}">
|
||||
<input type="submit" name="Submit" class="form-control">
|
||||
|
||||
</div>
|
||||
@ -128,8 +129,9 @@
|
||||
<div class="panel-heading" id="form">Elementi e costi del progetto</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<table class="table table-striped table-bordered table-hover"
|
||||
id="tab_progetti">
|
||||
|
||||
<div class="row">
|
||||
<table class="table table-striped table-bordered table-hover" id="tab_progetti">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Data</th>
|
||||
@ -140,19 +142,29 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($righe as $riga)
|
||||
@if(isset($riga->data))
|
||||
<tr>
|
||||
<td>{{ date('d/m/Y',strtotime($riga->data)) }}</td>
|
||||
<td>{{ date('d/m/Y',strtotime($riga->data)) }}</td>
|
||||
<td>{{ $riga->descrizione }}</td>
|
||||
<td>{{ $riga->ore }}</td>
|
||||
<td>{{ $riga->prezzo }}</td>
|
||||
</tr>
|
||||
@else
|
||||
<tr>
|
||||
<td>non c'è</td>
|
||||
<td>non c'è</td>
|
||||
<td>non c'è</td>
|
||||
<td>non c'è</td>
|
||||
</tr>
|
||||
@endif
|
||||
@endforeach
|
||||
</tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.col-lg-12 -->
|
||||
|
||||
@endsection @section('script')
|
||||
@ -163,11 +175,11 @@
|
||||
});
|
||||
|
||||
$('#form').click(function(){
|
||||
$('form').slideToggle(500);
|
||||
$('form').toggle();
|
||||
});
|
||||
|
||||
$("#dettaglio").click(function(){
|
||||
$("[hidable]").slideToggle(500);
|
||||
$('[hidable]').toggle();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
@ -110,7 +110,7 @@ Route::get('/', [MovimentiController::class,'dashboard']);
|
||||
Route::post('progetti/new', [ProgettiController::class, 'salvaProgetto']);
|
||||
Route::get('progetti/new', [ProgettiController::class, 'nuovoProgetto'])->name('nuovoProgetto');
|
||||
Route::get('progetti/delete',[ProgettiController::class, 'deleteProgetto']);
|
||||
Route::get('progetti/detail', [ProgettiController::class, 'dettaglioProgetto']);
|
||||
Route::get('progetti/detail', [ProgettiController::class, 'dettaglioProgetto'])->name('detail');
|
||||
Route::post('progetti/detail', [ProgettiController::class, 'inserisciTask']);
|
||||
|
||||
/// TEST routes
|
||||
|
Loading…
Reference in New Issue
Block a user