diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index 86adb3df28cf6d493e4e373375b5c769fa5ce8bd..4a0edaa5f4bb343967f1192bafe75fd205428636 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\Models\PAD; use App\Queries\UnidadeQuery; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -20,7 +21,7 @@ class DashboardController extends Controller if($user->isTypeTeacher()) { - return view('dashboard'); + return view('dashboard', ['PADs' => PAD::all(), 'menu_index'=> 0]); } } diff --git a/app/Http/Controllers/PADController.php b/app/Http/Controllers/PADController.php new file mode 100644 index 0000000000000000000000000000000000000000..a3cf726e6783c4492e57aabff919c9d5bcfad1d8 --- /dev/null +++ b/app/Http/Controllers/PADController.php @@ -0,0 +1,116 @@ +id); + return view('pad.index', ["PADs" => $PADs, 'index_menu' => 1 ]); + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + return view('pad.create', ['index_menu' => 1 ]); + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + $rules = [ + 'first_name' => 'required|string|min:3|max:255', + 'city_name' => 'required|string|min:3|max:255', + 'email' => 'required|string|email|max:255' + ]; + $validator = Validator::make($request->all(),$rules); + if ($validator->fails()) { + return redirect('insert') + ->withInput() + ->withErrors($validator); + } + else{ + $data = $request->input(); + try{ + $student = new StudInsert; + $student->first_name = $data['first_name']; + $student->last_name = $data['last_name']; + $student->city_name = $data['city_name']; + $student->email = $data['email']; + $student->save(); + return redirect('insert')->with('status',"Insert successfully"); + } + catch(Exception $e){ + return redirect('insert')->with('failed',"operation failed"); + } + } + + return redirect('/dashboard'); + } + + /** + * Show the form for editing the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function edit($id) + { + $model = PAD::find($id); + return view('pad.update', ['pad' => $model]); + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, $id) + { + $model = PAD::find($id); + $model->name = $request->name; + $model->save(); + + return redirect('/pad/index'); + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy($id) + { + $model = PAD::find($id); + $model->delete(); + + return redirect('/pad/index'); + } +} \ No newline at end of file diff --git a/app/Models/Curso.php b/app/Models/Curso.php index 7731d51c2e8a772ef4b45e170e8f4e37be91bc28..8c9aab2a0d2a9a5a0fa1f4011e3c1e787679187f 100644 --- a/app/Models/Curso.php +++ b/app/Models/Curso.php @@ -14,7 +14,7 @@ class Curso extends Model * * @var string */ - protected $table = 'curso'; + protected $table = 'cursos'; /** * The attributes that are mass assignable. diff --git a/app/Models/PAD.php b/app/Models/PAD.php index ab6daca2d96de0a22704c44b719787d3ae3a4176..3f3920e774e2de63936814aec6f6c087870dedc1 100644 --- a/app/Models/PAD.php +++ b/app/Models/PAD.php @@ -8,4 +8,38 @@ use Illuminate\Database\Eloquent\Model; class PAD extends Model { use HasFactory; + + /** + * References table PADs + * + * @var string + */ + protected $table = 'PADs'; + + /** + * The attributes that are mass assignable. + * + * @var array + */ + protected $fillable = ['ano', 'semestre', 'carga_horaria', 'categoria', 'afastamento_total', 'afastamento_parcial', 'exerce_funcao_admin', 'exerce_funcao_sindical', 'licenca_de_acor_legais', 'outras_observacoes', 'professor_id', 'curso_id']; + + /** + * Get User with user.id = user.campus_id + * + * @return User + */ + public function professor() + { + return $this->belongsTo(User::class); + } + + /** + * Get Curso with curso.id = curso.curso_id + * + * @return Curso + */ + public function curso() + { + return $this->belongsTo(Curso::class); + } } diff --git a/app/Queries/PADQuery.php b/app/Queries/PADQuery.php new file mode 100644 index 0000000000000000000000000000000000000000..402e0b7174c875d5131009f467f2e4b6b0bce031 --- /dev/null +++ b/app/Queries/PADQuery.php @@ -0,0 +1,19 @@ +id(); $table->string('name'); $table->foreignId('campus_id'); diff --git a/database/migrations/2022_03_20_233337_create_p_a_d_s_table.php b/database/migrations/2022_03_20_233337_create_p_a_d_s_table.php index 2d8b96e8c58a9fcdf5415227aeae2c498d8b5b14..d2bc1d74f7ae1686b0ad4f9dac356a0d89ad6ace 100644 --- a/database/migrations/2022_03_20_233337_create_p_a_d_s_table.php +++ b/database/migrations/2022_03_20_233337_create_p_a_d_s_table.php @@ -13,7 +13,7 @@ class CreatePADSTable extends Migration */ public function up() { - Schema::create('p_a_d_s', function (Blueprint $table) { + Schema::create('PADs', function (Blueprint $table) { $table->id(); $table->timestamps(); $table->integer('ano'); @@ -26,6 +26,12 @@ class CreatePADSTable extends Migration $table->boolean('exerce_funcao_sindical')->default(false); $table->string('licenca_de_acor_legais', 50)->default(null); $table->string('outras_observacoes', 200)->nullable(true); + + $table->unsignedBigInteger('professor_id'); + $table->foreign('professor_id')->references('id')->on('users'); + + $table->unsignedBigInteger('curso_id'); + $table->foreign('curso_id')->references('id')->on('cursos'); }); } @@ -36,6 +42,6 @@ class CreatePADSTable extends Migration */ public function down() { - Schema::dropIfExists('p_a_d_s'); + Schema::dropIfExists('PADs'); } } diff --git a/database/migrations/2022_03_20_233345_create_ref_planejamento_ches_table.php b/database/migrations/2022_03_20_233345_create_ref_planejamento_ches_table.php index 8d1ddbe71a4e3d4a495e7e24edea171685b74b76..b5759421ed7be070046b6b4e47f2b0bf5b89dcca 100644 --- a/database/migrations/2022_03_20_233345_create_ref_planejamento_ches_table.php +++ b/database/migrations/2022_03_20_233345_create_ref_planejamento_ches_table.php @@ -19,7 +19,7 @@ class CreateRefPlanejamentoChesTable extends Migration $table->string("descricao_atividade", 50); $table->float("ch_semanal", 5, 2); $table->float("ch_maxima", 5, 2); - $table->foreignId('p_a_d_s_id') + $table->foreignId('PAD_id') ->constrained() ->onUpdate('cascade') ->onDelete('cascade'); diff --git a/database/seeders/CursoSeeder.php b/database/seeders/CursoSeeder.php index f9d09cdf3ca6b38c372086f21c6dab093067f79b..8f3b5171366d6451d378f825adbd83997a7e8b16 100644 --- a/database/seeders/CursoSeeder.php +++ b/database/seeders/CursoSeeder.php @@ -5,7 +5,7 @@ namespace Database\Seeders; use App\Models\Campus; use App\Models\Curso; use Illuminate\Database\Seeder; -use Illuminate\Support\Facades\DB; + class CursoSeeder extends Seeder { @@ -29,6 +29,5 @@ class CursoSeeder extends Seeder ]); } } - } } diff --git a/public/css/forms.css b/public/css/forms.css new file mode 100644 index 0000000000000000000000000000000000000000..670797c4e7c238d3d68b4da99327425aee531c5d --- /dev/null +++ b/public/css/forms.css @@ -0,0 +1,52 @@ +/* content que contem o corpo da pagina */ +.content { + position: relative; + top: 0px; + width: 100%; +} + +.titulo { + font-size: 32px; + color: #000000; + font-family: Arial, sans-serif; + font-weight: bold; + text-align: center; +} + +#bordcab { + + margin: 0 0 0 0; + background: #e6e7e8; + + width: 100%; + height: 100%; + border-radius: 0px 0px 20px 20px; +} + +hr { + margin-top: 0px; + background-color: rgb(105, 105, 105); + border-top: 1px solid; +} + +#bord { + border-width: 1px; + border-style: solid; + border-color: rgb(105, 105, 105); + background-color: #e6e7e8; + width: 100%; + height: 100%; + border-radius: 20px; + padding: 1em; + margin: 20px; +} + +#compbord { + padding: 20px; + margin: 0px; +} + +#addrow { + padding: 20px; + margin: 0px; +} diff --git a/public/js/forms.js b/public/js/forms.js new file mode 100644 index 0000000000000000000000000000000000000000..c349e1f7f67708ec6b9960d3b6e4832b544e5fd7 --- /dev/null +++ b/public/js/forms.js @@ -0,0 +1,85 @@ +$(document).ready(function() { + $("#add_row").on("click", function() { + // Dynamic Rows Code + + // Get max row id and set new id + var newid = 0; + $.each($("#tab_logic tr"), function() { + if (parseInt($(this).data("id")) > newid) { + newid = parseInt($(this).data("id")); + } + }); + newid++; + + var tr = $("