Commit d913684e authored by alissonalbuquerque's avatar alissonalbuquerque
Browse files

add correções de buttons

parent 4ab799ca
...@@ -77,7 +77,7 @@ class EnsinoAulaController extends Controller ...@@ -77,7 +77,7 @@ class EnsinoAulaController extends Controller
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function create(Request $request) public function create(Request $request)
{ {
if($request->cod_dimensao) if($request->cod_dimensao)
{ {
$planejamento = Planejamento::initQuery()->whereCodDimensao($request->cod_dimensao)->first(); $planejamento = Planejamento::initQuery()->whereCodDimensao($request->cod_dimensao)->first();
......
...@@ -9,6 +9,7 @@ use App\Models\Tabelas\Constants; ...@@ -9,6 +9,7 @@ use App\Models\Tabelas\Constants;
use App\Models\User; use App\Models\User;
use App\Models\UserPad; use App\Models\UserPad;
use App\Models\UserType; use App\Models\UserType;
use App\Models\UserTypePad;
use App\Models\Util\Menu; use App\Models\Util\Menu;
use App\Models\Util\MenuItemsAdmin; use App\Models\Util\MenuItemsAdmin;
use App\Models\Util\MenuItemsTeacher; use App\Models\Util\MenuItemsTeacher;
...@@ -29,14 +30,16 @@ class PadController extends Controller ...@@ -29,14 +30,16 @@ class PadController extends Controller
*/ */
public function index() public function index()
{ {
if(Auth::user()->isTypeAdmin()) { if(Auth::user()->isTypeAdmin())
{
$users = User::initQuery()->whereType(UserType::TEACHER)->get();
$pads = Pad::all(); $pads = Pad::all();
$menu = Menu::PADS; $menu = Menu::PADS;
return view('pad.admin.index', ['menu' => $menu, 'pads' => $pads]); return view('pad.admin.index', ['menu' => $menu, 'pads' => $pads]);
} }
if(Auth::user()->isTypeTeacher()) if(Auth::user()->isTypeTeacher())
{ {
$menu = Menu::PADS; $menu = Menu::PADS;
$userPads = UserPad::initQuery()->whereUser(Auth::user()->id)->get(); $userPads = UserPad::initQuery()->whereUser(Auth::user()->id)->get();
...@@ -48,7 +51,8 @@ class PadController extends Controller ...@@ -48,7 +51,8 @@ class PadController extends Controller
* @param integer $id * @param integer $id
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function view($id) { public function view($id)
{
$menu = Menu::PADS; $menu = Menu::PADS;
return view('pad.teacher.view', ['user_pad_id' => $id, 'menu' => $menu]); return view('pad.teacher.view', ['user_pad_id' => $id, 'menu' => $menu]);
} }
...@@ -86,18 +90,24 @@ class PadController extends Controller ...@@ -86,18 +90,24 @@ class PadController extends Controller
'data_fim.after_or_equal' => 'A :attribute deve ser uma data posterior ou igual a data de início', 'data_fim.after_or_equal' => 'A :attribute deve ser uma data posterior ou igual a data de início',
]); ]);
if($validated) { if($validated)
{
$model = new Pad($request->all()); $model = new Pad($request->all());
if($model->save()) { if($model->save())
{
$users = User::initQuery()->whereType(UserType::TEACHER)->get(); $users = User::initQuery()->whereType(UserType::TEACHER)->get();
foreach($users as $user) { foreach($users as $user)
$modelUserPad = new UserPad(); {
$modelUserPad->user_id = $user->id; $profile = $user->profile(UserType::TEACHER);
$modelUserPad->pad_id = $model->id;
$modelUserPad->save(); $userPad = new UserPad();
$userPad->pad_id = $model->id;
$userPad->user_type_id = $profile->id;
$userPad->status = Status::ATIVO;
$userPad->save();
} }
return redirect()->route('pad_index')->with('success', 'PAD cadastrado com sucesso!'); return redirect()->route('pad_index')->with('success', 'PAD cadastrado com sucesso!');
...@@ -113,44 +123,6 @@ class PadController extends Controller ...@@ -113,44 +123,6 @@ class PadController extends Controller
return view('pad.anexo', ['index_menu' => 1 ]); return view('pad.anexo', ['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. * Show the form for editing the specified resource.
* *
......
...@@ -83,7 +83,8 @@ class UserController extends Controller ...@@ -83,7 +83,8 @@ class UserController extends Controller
$password = array_shift($email_splited); $password = array_shift($email_splited);
$model->password = Hash::make($password); $model->password = Hash::make($password);
if($model->save()) { if($model->save())
{
return redirect()->route('user_edit', ['id' => $model->id])->with('success', 'Usuário cadastrado com sucesso!'); return redirect()->route('user_edit', ['id' => $model->id])->with('success', 'Usuário cadastrado com sucesso!');
} }
......
...@@ -23,7 +23,7 @@ class EnsinoAula extends Model ...@@ -23,7 +23,7 @@ class EnsinoAula extends Model
* *
* @var array * @var array
*/ */
protected $fillable = ['orientacao_id', 'user_pad_id', 'dimensao', 'cod_atividade', 'componente_curricular', 'curso', 'nivel', 'modalidade', 'ch_semanal', 'ch_total']; protected $fillable = ['orientacao_id', 'user_pad_id', 'cod_dimensao', 'dimensao', 'cod_atividade', 'componente_curricular', 'curso', 'nivel', 'modalidade', 'ch_semanal', 'ch_total'];
public static function rules() public static function rules()
{ {
......
...@@ -131,8 +131,16 @@ class User extends Authenticatable ...@@ -131,8 +131,16 @@ class User extends Authenticatable
return $this->belongsTo(Unidade::class); return $this->belongsTo(Unidade::class);
} }
public function profile($type_profile)
{
return UserType::initQuery()
->whereUser($this->id)
->whereType($type_profile)
->first();
}
public function perfis() /** @return UserType[]|null */
public function profiles()
{ {
return $this->hasMany(UserType::class); return $this->hasMany(UserType::class);
} }
...@@ -140,9 +148,9 @@ class User extends Authenticatable ...@@ -140,9 +148,9 @@ class User extends Authenticatable
/** /**
* @return UserType|Null * @return UserType|Null
*/ */
public function perfilSelected() public function profileSelected()
{ {
return $this->perfis()->where('selected', true)->first(); return $this->profiles()->where('selected', true)->first();
} }
/** /**
...@@ -150,7 +158,7 @@ class User extends Authenticatable ...@@ -150,7 +158,7 @@ class User extends Authenticatable
*/ */
public function isTypeAdmin() public function isTypeAdmin()
{ {
return $this->perfilSelected()->type === UserType::ADMIN; return $this->profileSelected()->type === UserType::ADMIN;
} }
/** /**
...@@ -158,7 +166,7 @@ class User extends Authenticatable ...@@ -158,7 +166,7 @@ class User extends Authenticatable
*/ */
public function isTypeTeacher() public function isTypeTeacher()
{ {
return $this->perfilSelected()->type === UserType::TEACHER; return $this->profileSelected()->type === UserType::TEACHER;
} }
/** /**
...@@ -166,7 +174,7 @@ class User extends Authenticatable ...@@ -166,7 +174,7 @@ class User extends Authenticatable
*/ */
public function isTypeDirector() public function isTypeDirector()
{ {
return $this->perfilSelected()->type === UserType::DIRECTOR; return $this->profileSelected()->type === UserType::DIRECTOR;
} }
/** /**
...@@ -174,7 +182,7 @@ class User extends Authenticatable ...@@ -174,7 +182,7 @@ class User extends Authenticatable
*/ */
public function isTypeCoordinator() public function isTypeCoordinator()
{ {
return $this->perfilSelected()->type === UserType::COORDINATOR; return $this->profileSelected()->type === UserType::COORDINATOR;
} }
/** /**
...@@ -182,7 +190,7 @@ class User extends Authenticatable ...@@ -182,7 +190,7 @@ class User extends Authenticatable
*/ */
public function isTypeEvaluator() public function isTypeEvaluator()
{ {
return $this->perfilSelected()->type === UserType::EVALUATOR; return $this->profileSelected()->type === UserType::EVALUATOR;
} }
public static function initQuery() public static function initQuery()
......
...@@ -3,23 +3,31 @@ ...@@ -3,23 +3,31 @@
namespace App\Models; namespace App\Models;
use App\Queries\UserPadQuery; use App\Queries\UserPadQuery;
use App\Models\Pad;
use App\Models\Util\Status;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
//remover tabela de user_pad
class UserPad extends Model class UserPad extends Model
{ {
use HasFactory; use HasFactory;
protected $table = 'user_pad'; protected $table = 'user_pad';
protected $fillable = ['user_id', 'pad_id']; protected $fillable = ['user_type_id', 'pad_id', 'status'];
public function user() { public function user() {
return $this->belongsTo(User::class); return $this->belongsTo(UserType::class);
} }
public function pad() { public function pad() {
return $this->belongsTo(PAD::class); return $this->belongsTo(Pad::class);
}
public function statusAsText() {
return Status::listStatus($this->status);
} }
public static function initQuery() { public static function initQuery() {
......
...@@ -39,7 +39,7 @@ class UserType extends Model ...@@ -39,7 +39,7 @@ class UserType extends Model
return Status::listStatus($this->status); return Status::listStatus($this->status);
} }
public function initQuery() public static function initQuery()
{ {
return new UserTypeQuery(get_called_class()); return new UserTypeQuery(get_called_class());
} }
......
...@@ -9,6 +9,7 @@ class Status ...@@ -9,6 +9,7 @@ class Status
const INATIVO = 2; const INATIVO = 2;
const PENDENTE = 3; const PENDENTE = 3;
const ARQUIVADO = 4; const ARQUIVADO = 4;
const FINALIZADO = 5;
public static function listStatus($value = null) { public static function listStatus($value = null) {
...@@ -17,6 +18,7 @@ class Status ...@@ -17,6 +18,7 @@ class Status
self::INATIVO => 'Inativo', self::INATIVO => 'Inativo',
self::PENDENTE => 'Pendente', self::PENDENTE => 'Pendente',
self::ARQUIVADO => 'Arquivado', self::ARQUIVADO => 'Arquivado',
self::FINALIZADO => 'Finalizado',
]; ];
return $value !== null? $values[$value] : $values; return $value !== null? $values[$value] : $values;
......
...@@ -24,12 +24,12 @@ class UserPadQuery extends CustomQuery ...@@ -24,12 +24,12 @@ class UserPadQuery extends CustomQuery
} }
/** /**
* @param integer $user_id * @param integer $user_type_id
* @return UserPadQuery|Builder * @return UserPadQuery|Builder
*/ */
public function whereUser($user_id, $operator = '=') public function whereUser($user_type_id, $operator = '=')
{ {
$this->query = $this->query->where('user_id', $operator, $user_id); $this->query = $this->query->where('user_type_id', $operator, $user_type_id);
return self::$instance; return self::$instance;
} }
...@@ -43,6 +43,16 @@ class UserPadQuery extends CustomQuery ...@@ -43,6 +43,16 @@ class UserPadQuery extends CustomQuery
return self::$instance; return self::$instance;
} }
/**
* @param integer $status
* @return UserPadQuery|Builder
*/
public function whereStatus($status, $operator = '=')
{
$this->query = $this->query->where('status', $operator, $status);
return self::$instance;
}
/** /**
* @param integer $status * @param integer $status
* @return UserPadQuery|Builder * @return UserPadQuery|Builder
......
...@@ -13,5 +13,25 @@ class UserTypeQuery extends CustomQuery ...@@ -13,5 +13,25 @@ class UserTypeQuery extends CustomQuery
self::$instance = $this; self::$instance = $this;
} }
public function whereType($type, $expression = "=")
{
$this->query = $this->query->where('type', $expression, $type);
return self::$instance;
}
public function whereUser($user_id, $expression = "=")
{
$this->query = $this->query->where('user_id', $expression, $user_id);
return self::$instance;
}
public function whereStatus($status, $expression = "=")
{
$this->query = $this->query->where('status', $expression, $status);
return self::$instance;
}
} }
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePADSTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('pads', function (Blueprint $table) {
$table->id();
$table->integer('ano')->default(false);
$table->integer('semestre')->default(false);
$table->integer('carga_horaria')->default(false);
$table->string('categoria', 20)->default(false);
$table->boolean('afastamento_total')->default(false);
$table->boolean('afastamento_parcial')->default(false);
$table->boolean('exerce_funcao_admin')->default(false);
$table->boolean('exerce_funcao_sindical')->default(false);
$table->string('licenca_de_acor_legais', 50)->default(null);
$table->string('outras_observacoes', 200)->nullable(true);
$table->foreignId('user_id');
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('pads');
}
}
...@@ -13,10 +13,12 @@ class CreateUserPadTable extends Migration ...@@ -13,10 +13,12 @@ class CreateUserPadTable extends Migration
*/ */
public function up() public function up()
{ {
Schema::create('user_pad', function (Blueprint $table) { Schema::create('user_pad', function (Blueprint $table)
{
$table->id(); $table->id();
$table->foreignId('user_id'); $table->foreignId('user_type_id');
$table->foreignId('pad_id'); $table->foreignId('pad_id');
$table->tinyInteger('status');
$table->timestamps(); $table->timestamps();
}); });
} }
......
...@@ -16,7 +16,6 @@ class CreateUserTypeTable extends Migration ...@@ -16,7 +16,6 @@ class CreateUserTypeTable extends Migration
Schema::create('user_type', function (Blueprint $table) { Schema::create('user_type', function (Blueprint $table) {
$table->id(); $table->id();
$table->foreignId('user_id'); $table->foreignId('user_id');
$table->foreignId('pad_id')->nullable();
$table->tinyInteger('type'); $table->tinyInteger('type');
$table->tinyInteger('status'); $table->tinyInteger('status');
$table->boolean('selected'); $table->boolean('selected');
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
--}} --}}
<div class="btn-edit-tasks"> <div class="btn-edit-tasks">
<button type="button" class="btn btn-primary {{ $btn_class }}" id="{{ $btn_id }}"> <button type="button" class="btn btn-primary btn-sm {{ $btn_class }}" id="{{ $btn_id }}">
<i class="bi bi-pencil-square"></i> <i class="bi bi-pencil-square"></i>
</button> </button>
</div> </div>
\ No newline at end of file
...@@ -121,15 +121,20 @@ ...@@ -121,15 +121,20 @@
<td>{{ $atividade->nivelAsString() }}</td> <td>{{ $atividade->nivelAsString() }}</td>
<td>{{ $atividade->ch_semanal }}</td> <td>{{ $atividade->ch_semanal }}</td>
<td> <td>
@include('components.buttons.btn-edit-task', [ <div class="btn-group" role="group">
'btn_class' => 'btn-edit_ensino_atendimento_discente', <div class="me-1">
'btn_id' => $atividade->id, @include('components.buttons.btn-edit-task', [
]) 'btn_class' => 'btn-edit_ensino_atendimento_discente',
'btn_id' => $atividade->id,
@include('components.buttons.btn-delete', [ ])
'id' => $atividade->id, </div>
'route' => route('ensino_atendimento_discente_delete', ['id' => $atividade->id]) <div class="me-1">
]) @include('components.buttons.btn-delete', [
'id' => $atividade->id,
'route' => route('ensino_atendimento_discente_delete', ['id' => $atividade->id])
])
</div>
</div>
</td> </td>
</tr> </tr>
@endforeach @endforeach
......
...@@ -160,15 +160,20 @@ ...@@ -160,15 +160,20 @@
<td>{{ $ensinoAula->modalidadeAsString() }}</td> <td>{{ $ensinoAula->modalidadeAsString() }}</td>
<td>{{ $ensinoAula->ch_semanal }}</td> <td>{{ $ensinoAula->ch_semanal }}</td>
<td> <td>
@include('components.buttons.btn-edit-task', [ <div class="btn-group" role="group">
'btn_class' => 'btn-edit_ensino_aula', <div class="me-1">
'btn_id' => $ensinoAula->id, @include('components.buttons.btn-edit-task', [
]) 'btn_class' => 'btn-edit_ensino_aula',
'btn_id' => $ensinoAula->id,
@include('components.buttons.btn-delete', [ ])
'id' => $ensinoAula->id, </div>
'route' => route('ensino_aula_delete', ['id' => $ensinoAula->id]) <div class="me-1">
]) @include('components.buttons.btn-delete', [
'id' => $ensinoAula->id,
'route' => route('ensino_aula_delete', ['id' => $ensinoAula->id])
])
</div>
</div>
</td> </td>
</tr> </tr>
@endforeach @endforeach
......
...@@ -122,15 +122,20 @@ ...@@ -122,15 +122,20 @@
<td>{{ $atividade->funcaoAsString() }}</td> <td>{{ $atividade->funcaoAsString() }}</td>
<td>{{ $atividade->ch_semanal }}</td> <td>{{ $atividade->ch_semanal }}</td>
<td> <td>
@include('components.buttons.btn-edit-task', [ <div class="btn-group" role="group">
'btn_class' => 'btn-edit_ensino_membro_docente', <div class="me-1">
'btn_id' => $atividade->id, @include('components.buttons.btn-edit-task', [
]) 'btn_class' => 'btn-edit_ensino_membro_docente',
'btn_id' => $atividade->id,
@include('components.buttons.btn-delete', [ ])
'id' => $atividade->id, </div>
'route' => route('ensino_membro_docente_delete', ['id' => $atividade->id]) <div class="me-1">
]) @include('components.buttons.btn-delete', [
'id' => $atividade->id,
'route' => route('ensino_membro_docente_delete', ['id' => $atividade->id])
])
</div>
</div>
</td> </td>
</tr> </tr>
@endforeach @endforeach
......
...@@ -171,15 +171,20 @@ ...@@ -171,15 +171,20 @@
<td>{{ $ensinoOrientacao->orientacaoAsString() }}</td> <td>{{ $ensinoOrientacao->orientacaoAsString() }}</td>
<td>{{ $ensinoOrientacao->chSemanal() }}</td> <td>{{ $ensinoOrientacao->chSemanal() }}</td>
<td> <td>
@include('components.buttons.btn-edit-task', [ <div class="btn-group" role="group">
'btn_class' => 'btn-edit_ensino_orientacao', <div class="me-1">
'btn_id' => $ensinoOrientacao->id, @include('components.buttons.btn-edit-task', [
]) 'btn_class' => 'btn-edit_ensino_orientacao',
'btn_id' => $ensinoOrientacao->id,
@include('components.buttons.btn-delete', [ ])
'id' => $ensinoOrientacao->id, </div>
'route' => route('ensino_orientacao_delete', ['id' => $ensinoOrientacao->id]) <div class="me-1">
]) @include('components.buttons.btn-delete', [
'id' => $ensinoOrientacao->id,
'route' => route('ensino_orientacao_delete', ['id' => $ensinoOrientacao->id])
])
</div>
</div>
</td> </td>
</tr> </tr>
@endforeach @endforeach
......
...@@ -105,15 +105,20 @@ ...@@ -105,15 +105,20 @@
<td>{{ $atividade->descricao }}</td> <td>{{ $atividade->descricao }}</td>
<td>{{ $atividade->ch_semanal }}</td> <td>{{ $atividade->ch_semanal }}</td>
<td> <td>
@include('components.buttons.btn-edit-task', [ <div class="btn-group" role="group">
'btn_class' => 'btn-edit_ensino_outros', <div class="me-1">
'btn_id' => $atividade->id, @include('components.buttons.btn-edit-task', [
]) 'btn_class' => 'btn-edit_ensino_outros',
'btn_id' => $atividade->id,
@include('components.buttons.btn-delete', [ ])
'id' => $atividade->id, </div>
'route' => route('ensino_outros_delete', ['id' => $atividade->id]) <div class="me-1">
]) @include('components.buttons.btn-delete', [
'id' => $atividade->id,
'route' => route('ensino_outros_delete', ['id' => $atividade->id])
])
</div>
</div>
</td> </td>
</tr> </tr>
@endforeach @endforeach
......
...@@ -111,15 +111,20 @@ ...@@ -111,15 +111,20 @@
<td>{{ $atividade->nivelAsString() }}</td> <td>{{ $atividade->nivelAsString() }}</td>
<td>{{ $atividade->ch_semanal }}</td> <td>{{ $atividade->ch_semanal }}</td>
<td> <td>
@include('components.buttons.btn-edit-task', [ <div class="btn-group" role="group">
'btn_class' => 'btn-edit_ensino_participacao', <div class="me-1">
'btn_id' => $atividade->id, @include('components.buttons.btn-edit-task', [
]) 'btn_class' => 'btn-edit_ensino_participacao',
'btn_id' => $atividade->id,
@include('components.buttons.btn-delete', [ ])
'id' => $atividade->id, </div>
'route' => route('ensino_participacao_delete', ['id' => $atividade->id]) <div class="me-1">
]) @include('components.buttons.btn-delete', [
'id' => $atividade->id,
'route' => route('ensino_participacao_delete', ['id' => $atividade->id])
])
</div>
</div>
</td> </td>
</tr> </tr>
@endforeach @endforeach
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment