Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Walter Felipe
submeta
Commits
94a59ba9
"git@sites.upe.br:walter.felipe/submeta.git" did not exist on "5f9ce7476224504eb8ec66a4726a4adc17f233f3"
Unverified
Commit
94a59ba9
authored
Jun 03, 2023
by
Antônio Durval
Committed by
GitHub
Jun 03, 2023
Browse files
Merge pull request #902 from antonioDurval/master
correção da semana
parents
7821fa8f
60c463a7
Changes
6
Show whitespace changes
Inline
Side-by-side
app/Http/Controllers/TrabalhoController.php
View file @
94a59ba9
...
...
@@ -39,6 +39,7 @@ use Illuminate\Validation\Rule;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\Log
;
use
App\Http\Requests\StoreTrabalho
;
use
App\Http\Requests\AdicionarIntegranteRequest
;
use
Illuminate\Support\Facades\Mail
;
use
App\Http\Requests\UpdateTrabalho
;
use
Illuminate\Support\Facades\Storage
;
...
...
@@ -57,6 +58,7 @@ use App\Desligamento;
use
App\ObjetivoDeDesenvolvimentoSustentavel
;
use
App\AvaliacaoRelatorio
;
use
App\Curso
;
use
Illuminate\Support\Facades\Date
;
class
TrabalhoController
extends
Controller
{
...
...
@@ -1202,6 +1204,77 @@ class TrabalhoController extends Controller
}
public
function
adicionarParticipante
(
AdicionarIntegranteRequest
$request
,
$id
){
$usuario
=
User
::
where
(
'cpf'
,
$request
->
cpf_consulta
)
->
first
();
if
(
!
$this
->
validarQtdParticipantesEdital
(
$id
)){
return
redirect
(
route
(
'trabalho.show'
,
[
'id'
=>
$id
]))
->
with
([
'mensagem'
=>
"Número máximo de integrantes do Edital alcançado, não é possivel inserir."
]);
}
if
(
!
$this
->
validarParticipanteRepetido
(
$usuario
->
id
,
$id
))
{
return
redirect
(
route
(
'trabalho.show'
,
[
'id'
=>
$id
]))
->
with
([
'mensagem'
=>
"Já existe um Integrante com esse CPF."
]);
}
$atributos
=
[
'user_id'
=>
$usuario
->
id
,
'funcao_participante_id'
=>
$request
->
funcao_participante
,
'trabalho_id'
=>
$id
,
'data_entrada'
=>
Date
::
now
()
->
format
(
'Y-m-d H:i:s'
)
];
$rg
=
Participante
::
where
(
'user_id'
,
$atributos
[
'user_id'
])
->
where
(
'rg'
,
'!='
,
null
)
->
latest
()
->
first
();
$data_de_nascimento
=
Participante
::
where
(
'user_id'
,
$atributos
[
'user_id'
])
->
where
(
'data_de_nascimento'
,
'!='
,
null
)
->
latest
()
->
first
();
$curso
=
Participante
::
where
(
'user_id'
,
$atributos
[
'user_id'
])
->
where
(
'curso'
,
'!='
,
null
)
->
latest
()
->
first
();
$linkLattes
=
Participante
::
where
(
'user_id'
,
$atributos
[
'user_id'
])
->
where
(
'linkLattes'
,
'!='
,
null
)
->
latest
()
->
first
();
$curso_id
=
Participante
::
where
(
'user_id'
,
$atributos
[
'user_id'
])
->
where
(
'curso_id'
,
'!='
,
null
)
->
latest
()
->
first
();
$atributo
[
'rg'
]
=
$rg
?
$rg
->
rg
:
null
;
$atributo
[
'data_de_nascimento'
]
=
$data_de_nascimento
?
$data_de_nascimento
->
data_de_nascimento
:
null
;
$atributo
[
'curso'
]
=
$curso
?
$curso
->
curso
:
null
;
$atributo
[
'linkLattes'
]
=
$linkLattes
?
$linkLattes
->
linkLattes
:
null
;
$atributo
[
'curso_id'
]
=
$curso_id
?
$curso_id
->
curso_id
:
null
;
Participante
::
create
(
$atributos
);
return
redirect
(
route
(
'trabalho.show'
,
[
'id'
=>
$id
]));
}
private
function
validarQtdParticipantesEdital
(
$id
)
{
$num_participantes_edital
=
Trabalho
::
where
(
'id'
,
$id
)
->
first
()
->
evento
->
numParticipantes
;
$num_participantes_projeto
=
count
(
Participante
::
where
(
'trabalho_id'
,
$id
)
->
get
());
if
(
$num_participantes_projeto
>=
$num_participantes_edital
){
return
false
;
}
return
true
;
}
private
function
validarParticipanteRepetido
(
$usuario_id
,
$trabalho_id
){
if
(
Participante
::
where
(
'user_id'
,
$usuario_id
)
->
where
(
'trabalho_id'
,
$trabalho_id
)
->
first
())
{
return
false
;
}
return
true
;
}
public
function
buscarUsuario
(
Request
$request
)
{
$usuario
=
User
::
where
(
'cpf'
,
$request
->
cpf_consulta
)
->
first
();
$funcao
=
FuncaoParticipantes
::
where
(
'id'
,
$request
->
funcao
)
->
first
();
...
...
app/Http/Requests/AdicionarIntegranteRequest.php
0 → 100644
View file @
94a59ba9
<?php
namespace
App\Http\Requests
;
use
Illuminate\Foundation\Http\FormRequest
;
class
AdicionarIntegranteRequest
extends
FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public
function
rules
()
{
return
[
'cpf_consulta'
=>
[
'required'
,
'string'
,
'regex:/^\d{3}.\d{3}.\d{3}-\d{2}$/'
,
'exists:users,cpf'
],
'funcao_participante'
=>
[
'required'
,
'exists:funcao_participantes,id'
]
];
}
public
function
messages
()
{
return
[
'cpf_consulta.required'
=>
'O CPF é obrigatório'
,
'cpf_consulta.regex'
=>
'O CPF é inválido'
,
'cpf_consulta.exists'
=>
'Usuário não encontrado'
,
'funcao_participante.required'
=>
'A função do participantes é obrigatória'
];
}
}
app/Participante.php
View file @
94a59ba9
...
...
@@ -12,7 +12,7 @@ class Participante extends Model
protected
$fillable
=
[
'rg'
,
'data_de_nascimento'
,
'curso'
,
'funcao_participante_id'
,
'turno'
,
'ordem_prioridade'
,
'periodo_atual'
,
'total_periodos'
,
'media_do_curso'
,
'linkLattes'
,
'tipoBolsa'
,
'data_entrada'
,
'data_saida'
];
'tipoBolsa'
,
'data_entrada'
,
'data_saida'
,
'user_id'
,
'trabalho_id'
,
'curso_id'
];
public
function
user
(){
return
$this
->
belongsTo
(
'App\User'
);
...
...
resources/views/projeto/formularioVisualizar/integrantes.blade.php
View file @
94a59ba9
...
...
@@ -4,11 +4,14 @@
<div
class=
"card-body"
style=
"padding-top: 0.2rem;"
>
<div
class=
"container"
>
<div
class=
"form-row mt-3"
>
<div
class=
"col-sm-
8
"
><h5
style=
"color: #234B8B; font-weight: bold"
>
Integrantes
</h5></div>
<div
class=
"col-sm-4 text-sm
-right
"
>
<div
class=
"col-sm-
5
"
><h5
style=
"color: #234B8B; font-weight: bold"
>
Integrantes
</h5></div>
<div
class=
"col-sm-4 text-sm"
>
<a
href=
"{{route('trabalho.trocaParticipante', ['evento_id' => $projeto->evento->id, 'projeto_id' => $projeto->id])}}"
class=
"button"
>
Solicitar Substituições/Desligamentos
</a>
</div>
<div
class=
"col-sm-3 text-sm-right"
>
<a
href=
""
data-toggle=
"modal"
data-target=
"#modalAdicionarParticipante"
class=
"button"
>
Adicionar Participante
</a>
</div>
</div>
<hr
style=
"border-top: 1px solid#1492E6"
>
...
...
resources/views/projeto/visualizar.blade.php
View file @
94a59ba9
...
...
@@ -38,7 +38,7 @@
@
endif
@
if
(
$edital
->
natureza_id
==
3
)
@
component
(
'projeto.formularioVisualizar.integrantes'
,
[
'projeto'
=>
$projeto
,
'edital'
=>
$edital
,
'trabalhos_user'
=>
$trabalhos_user
])
@
component
(
'projeto.formularioVisualizar.integrantes'
,
[
'projeto'
=>
$projeto
,
'edital'
=>
$edital
,
'trabalhos_user'
=>
$trabalhos_user
,
'funcaoParticipantes'
=>
$funcaoParticipantes
])
@
endcomponent
@
endif
...
...
@@ -149,6 +149,64 @@
</
div
>
</
div
>
</
div
>
<
div
class
=
"modal fade"
id
=
"modalAdicionarParticipante"
tabindex
=
"-1"
role
=
"dialog"
aria
-
labelledby
=
"exampleModalLabel"
aria
-
hidden
=
"true"
>
<
div
class
=
"modal-dialog modal-dialog-centered modal-sm"
>
<
div
class
=
"modal-content"
>
<
div
class
=
"modal-header"
>
<
h5
class
=
"modal-title"
id
=
"exampleModalLabel"
>
Adicionar
Integrante
</
h5
>
<
button
type
=
"button"
class
=
"close"
data
-
dismiss
=
"modal"
aria
-
label
=
"Close"
>
<
span
aria
-
hidden
=
"true"
>&
times
;
</
span
>
</
button
>
</
div
>
<
div
class
=
"container"
>
<
div
class
=
"row justify-content-center"
style
=
"padding-left:35px; padding-right:45px"
>
<
div
class
=
"form-controll"
style
=
"margin-left:10px; margin-top:10px; margin-bottom:15px; font-weight:bold;"
>
<
form
action
=
"{{route('trabalho.adicionarParticipante', ['id' =>
$projeto->id
])}}"
method
=
"POST"
>
@
csrf
<
div
class
=
"form-row d-flex"
>
<
label
for
=
"cpf_consulta"
>
CPF
:</
label
>
<
input
type
=
"text"
id
=
"cpf_consulta"
name
=
"cpf_consulta"
class
=
"form-control"
pattern
=
"\d
{
3}.\d{3}.\d{3}-\d{2
}
"
title
=
"Digite um CPF válido no formato XXX.XXX.XXX-XX"
required
>
</
div
>
<
div
class
=
"form-row d-flex"
style
=
"margin-top:10px"
>
<
label
for
=
"funcao_participante"
>
Função
do
Integrante
:</
label
>
<
select
name
=
"funcao_participante"
id
=
"funcao_participante"
class
=
"form-control"
>
@
foreach
(
$funcaoParticipantes
as
$funcao
)
<!--
EXTENSÃO
-->
@
if
(
$edital
->
natureza_id
==
3
&&
$edital
->
tipo
==
"CONTINUO"
)
@
if
(
$funcao
->
nome
==
"Vice-coordenador"
||
$funcao
->
nome
==
"Colaborador"
)
<
option
value
=
"
{
{$funcao->id}
}
"
checked
>
{{
$funcao
->
nome
}}
</
option
>
@
endif
@
elseif
(
$edital
->
natureza_id
==
3
&&
$edital
->
tipo
==
"PIBEX"
)
@
if
(
$funcao
->
nome
==
"Vice-coordenador"
||
$funcao
->
nome
==
"Colaborador"
)
<
option
value
=
"
{
{$funcao->id}
}
"
checked
>
{{
$funcao
->
nome
}}
</
option
>
@
endif
<!--
PESQUISA
-->
@
else
@
if
(
$funcao
->
nome
==
"Bolsista"
||
$funcao
->
nome
==
"Voluntário"
)
<
option
value
=
"
{
{$funcao->id}
}
"
checked
>
{{
$funcao
->
nome
}}
</
option
>
@
endif
@
endif
@
endforeach
</
select
>
</
div
>
<
div
class
=
"form-row justify-content-center"
style
=
"margin-top:20px;"
>
<
button
type
=
"submit"
class
=
"btn btn-primary"
>
Adicionar
</
button
>
</
div
>
</
form
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
@
endsection
@
section
(
'javascript'
)
...
...
@@ -181,6 +239,7 @@
</
style
>
<
script
>
$
(
"#cpf_consulta"
)
.
mask
(
"000.000.000-00"
)
if
(
document
.
getElementById
(
"radioSim"
)
.
checked
){
document
.
getElementById
(
"radioSim"
)
.
checked
=
true
;
...
...
routes/web.php
View file @
94a59ba9
...
...
@@ -165,6 +165,7 @@ Route::group(['middleware' => ['isTemp', 'auth', 'verified']], function () {
Route
::
post
(
'/projeto/buscarUsuario'
,
'TrabalhoController@buscarUsuario'
)
->
name
(
'trabalho.buscarUsuario'
);
Route
::
post
(
'/projeto/{id}/adicionarParticipante'
,
'TrabalhoController@adicionarParticipante'
)
->
name
(
'trabalho.adicionarParticipante'
);
Route
::
post
(
'/projeto/{id}/atualizar'
,
'TrabalhoController@update'
)
->
name
(
'trabalho.update'
);
Route
::
get
(
'/projeto/{id}/excluir'
,
'TrabalhoController@destroy'
)
->
name
(
'trabalho.destroy'
);
Route
::
get
(
'/projeto/{id}/excluirParticipante'
,
'TrabalhoController@excluirParticipante'
)
->
name
(
'trabalho.excluirParticipante'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment