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
364df050
Commit
364df050
authored
Jun 18, 2020
by
alinetenorio
Browse files
ajustes em editar
parent
3b89ee9a
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/TrabalhoController.php
View file @
364df050
...
@@ -416,7 +416,7 @@ class TrabalhoController extends Controller
...
@@ -416,7 +416,7 @@ class TrabalhoController extends Controller
$participantes
=
Participante
::
where
(
'trabalho_id'
,
$id
)
->
get
();
$participantes
=
Participante
::
where
(
'trabalho_id'
,
$id
)
->
get
();
$participantesUsersIds
=
Participante
::
where
(
'trabalho_id'
,
$id
)
->
select
(
'user_id'
)
->
get
();
$participantesUsersIds
=
Participante
::
where
(
'trabalho_id'
,
$id
)
->
select
(
'user_id'
)
->
get
();
$users
=
User
::
whereIn
(
'id'
,
$participantesUsersIds
)
->
get
();
$users
=
User
::
whereIn
(
'id'
,
$participantesUsersIds
)
->
get
();
$arquivos
=
Arquivo
::
where
(
'trabalhoId'
,
$id
)
->
get
();
$arquivos
=
Arquivo
::
where
(
'trabalhoId'
,
$id
)
->
get
();
return
view
(
'projeto.editar'
)
->
with
([
'projeto'
=>
$projeto
,
return
view
(
'projeto.editar'
)
->
with
([
'projeto'
=>
$projeto
,
'grandeAreas'
=>
$grandeAreas
,
'grandeAreas'
=>
$grandeAreas
,
...
@@ -593,6 +593,7 @@ class TrabalhoController extends Controller
...
@@ -593,6 +593,7 @@ class TrabalhoController extends Controller
if
(
in_array
(
$request
->
emailParticipante
[
$key
],
$emailParticipantes
,
false
))
{
if
(
in_array
(
$request
->
emailParticipante
[
$key
],
$emailParticipantes
,
false
))
{
$userParticipante
=
User
::
where
(
'email'
,
$value
)
->
first
();
$userParticipante
=
User
::
where
(
'email'
,
$value
)
->
first
();
if
(
$userParticipante
!=
null
){
if
(
$userParticipante
!=
null
){
$user
=
User
::
where
(
'email'
,
$request
->
emailParticipante
[
$key
])
->
first
();
$user
=
User
::
where
(
'email'
,
$request
->
emailParticipante
[
$key
])
->
first
();
$participante
=
Participante
::
where
([[
'user_id'
,
'='
,
$user
->
id
],
[
'trabalho_id'
,
'='
,
$trabalho
->
id
]])
->
first
();
$participante
=
Participante
::
where
([[
'user_id'
,
'='
,
$user
->
id
],
[
'trabalho_id'
,
'='
,
$trabalho
->
id
]])
->
first
();
...
@@ -603,28 +604,42 @@ class TrabalhoController extends Controller
...
@@ -603,28 +604,42 @@ class TrabalhoController extends Controller
$participante
->
update
();
$participante
->
update
();
//atualizando planos de trabalho
//atualizando planos de trabalho
if
(
$request
->
anexoPlanoTrabalho
!=
null
&&
array_key_exists
(
$key
,
$request
->
anexoPlanoTrabalho
))
{
if
(
$request
->
anexoPlanoTrabalho
!=
null
&&
array_key_exists
(
$key
,
$request
->
anexoPlanoTrabalho
))
{
if
(
!
(
is_null
(
$request
->
anexoPlanoTrabalho
[
$key
])))
{
if
(
!
(
is_null
(
$request
->
anexoPlanoTrabalho
[
$key
])))
{
$arquivo
=
Arquivo
::
where
(
'participanteId'
,
$participante
->
id
)
->
first
();
$arquivo
=
Arquivo
::
where
(
'participanteId'
,
$participante
->
id
)
->
first
();
//se plano já existir, deletar
//se plano já existir, deletar
if
(
$arquivo
!=
null
){
if
(
$arquivo
!=
null
){
Storage
::
delete
(
$arquivo
->
nome
);
$arquivo
->
delete
();
}
//atualizar plano
if
(
$request
->
semPlano
[
$key
]
==
null
){
$path
=
'trabalhos/'
.
$request
->
editalId
.
'/'
.
$trabalho
->
id
.
'/'
;
$nome
=
$request
->
nomePlanoTrabalho
[
$key
]
.
".pdf"
;
$file
=
$request
->
anexoPlanoTrabalho
[
$key
];
Storage
::
putFileAs
(
$path
,
$file
,
$nome
);
$arquivo
=
new
Arquivo
();
$arquivo
->
titulo
=
$request
->
nomePlanoTrabalho
[
$key
];
$arquivo
->
nome
=
$path
.
$nome
;
$arquivo
->
trabalhoId
=
$trabalho
->
id
;
$arquivo
->
data
=
$mytime
;
$arquivo
->
participanteId
=
$participante
->
id
;
$arquivo
->
versaoFinal
=
true
;
$arquivo
->
save
();
}
}
}
//removendo planos de trabalho
if
(
$request
->
nomePlanoTrabalho
!=
null
&&
array_key_exists
(
$key
,
$request
->
nomePlanoTrabalho
)){
if
(
$request
->
semPlano
[
$key
]
==
'sim'
){
$arquivo
=
Arquivo
::
where
(
'participanteId'
,
$participante
->
id
)
->
first
();
//se plano já existir, deletar
if
(
$arquivo
!=
null
){
Storage
::
delete
(
$arquivo
->
nome
);
Storage
::
delete
(
$arquivo
->
nome
);
$arquivo
->
delete
();
$arquivo
->
delete
();
}
}
$path
=
'trabalhos/'
.
$request
->
editalId
.
'/'
.
$trabalho
->
id
.
'/'
;
$nome
=
$request
->
nomePlanoTrabalho
[
$key
]
.
".pdf"
;
$file
=
$request
->
anexoPlanoTrabalho
[
$key
];
Storage
::
putFileAs
(
$path
,
$file
,
$nome
);
$arquivo
=
new
Arquivo
();
$arquivo
->
titulo
=
$request
->
nomePlanoTrabalho
[
$key
];
$arquivo
->
nome
=
$path
.
$nome
;
$arquivo
->
trabalhoId
=
$trabalho
->
id
;
$arquivo
->
data
=
$mytime
;
$arquivo
->
participanteId
=
$participante
->
id
;
$arquivo
->
versaoFinal
=
true
;
$arquivo
->
save
();
}
}
}
}
}
}
...
@@ -635,13 +650,14 @@ class TrabalhoController extends Controller
...
@@ -635,13 +650,14 @@ class TrabalhoController extends Controller
$participantesUsersIds
=
Participante
::
where
(
'trabalho_id'
,
'='
,
$trabalho
->
id
)
->
select
(
'user_id'
)
->
get
();
$participantesUsersIds
=
Participante
::
where
(
'trabalho_id'
,
'='
,
$trabalho
->
id
)
->
select
(
'user_id'
)
->
get
();
$users
=
User
::
whereIn
(
'id'
,
$participantesUsersIds
)
->
get
();
$users
=
User
::
whereIn
(
'id'
,
$participantesUsersIds
)
->
get
();
foreach
(
$users
as
$user
)
{
foreach
(
$users
as
$user
)
{
//dd($user);
if
(
!
(
in_array
(
$user
->
email
,
$request
->
emailParticipante
,
false
)))
{
if
(
!
(
in_array
(
$user
->
email
,
$request
->
emailParticipante
,
false
)))
{
$participante
=
Participante
::
where
([[
'user_id'
,
'='
,
$user
->
id
],
[
'trabalho_id'
,
'='
,
$trabalho
->
id
]])
->
first
();
$participante
=
Participante
::
where
([[
'user_id'
,
'='
,
$user
->
id
],
[
'trabalho_id'
,
'='
,
$trabalho
->
id
]])
->
first
();
$arquivo
=
Arquivo
::
where
(
'participanteId'
,
$participante
->
id
)
->
first
();
$arquivo
=
Arquivo
::
where
(
'participanteId'
,
$participante
->
id
);
if
(
$arquivo
!=
null
){
Storage
::
delete
(
$arquivo
->
nome
);
Storage
::
delete
(
$arquivo
->
nome
);
$arquivo
->
delete
();
$arquivo
->
delete
();
}
$participante
->
delete
();
$participante
->
delete
();
}
}
}
}
...
...
resources/views/projeto/editar.blade.php
View file @
364df050
...
@@ -267,6 +267,7 @@
...
@@ -267,6 +267,7 @@
<hr>
<hr>
<h3>Participantes</h3>
<h3>Participantes</h3>
<input type="
hidden
" value="
{{
sizeof
(
$participantes
)}}
" id="
qtdParticipantes
">
{{-- Participantes --}}
{{-- Participantes --}}
<div class="
row
" style="
margin
-
top
:
20
px
">
<div class="
row
" style="
margin
-
top
:
20
px
">
...
@@ -321,7 +322,8 @@
...
@@ -321,7 +322,8 @@
<div class='col-sm-11'>
<div class='col-sm-11'>
<h6 class="
mb
-
1
">Possui plano de trabalho?</h6>
<h6 class="
mb
-
1
">Possui plano de trabalho?</h6>
<button class="
btn
btn
-
primary
mt
-
2
mb
-
2
simPlano
" id="
simPlano
">Sim</button>
<button class="
btn
btn
-
primary
mt
-
2
mb
-
2
simPlano
" id="
simPlano
">Sim</button>
<button class="
btn
btn
-
primary
mt
-
2
mb
-
2
naoPlano
">Não</button>
<button class="
btn
btn
-
primary
mt
-
2
mb
-
2
naoPlano
">Não</button>
<input type="
hidden
" name="
semPlano
[]
" value="">
</div>
</div>
<div class="
col
-
sm
-
1
deletarSemPlano
" >
<div class="
col
-
sm
-
1
deletarSemPlano
" >
<a class="
delete
">
<a class="
delete
">
...
@@ -379,6 +381,7 @@
...
@@ -379,6 +381,7 @@
@endif
@endif
@endforeach
@endforeach
</div>
</div>
</div>
@endif
@endif
@endforeach
@endforeach
@endforeach
@endforeach
...
@@ -411,7 +414,7 @@
...
@@ -411,7 +414,7 @@
<
script
type
=
"text/javascript"
>
<
script
type
=
"text/javascript"
>
$
(
function
()
{
$
(
function
()
{
var
qtdLinhas
=
1
;
var
qtdLinhas
=
1
;
var
qtdParticipantes
=
1
;
var
qtdParticipantes
=
$
(
'#qtdParticipantes'
)
.
val
()
;
// Coautores
// Coautores
$
(
'#addCoautor'
)
.
click
(
function
(
e
)
{
$
(
'#addCoautor'
)
.
click
(
function
(
e
)
{
if
(
qtdParticipantes
<
100
)
{
if
(
qtdParticipantes
<
100
)
{
...
@@ -422,20 +425,7 @@
...
@@ -422,20 +425,7 @@
}
}
});
});
$
(
'.simPlano'
)
.
click
(
function
(
e
)
{
var
possuiPlano
=
$
(
this
)
.
parent
()
.
parent
()
.
next
();
if
(
possuiPlano
[
0
]
.
firstElementChild
==
null
){
e
.
preventDefault
();
linha
=
linhaPlanoTrabalho
();
possuiPlano
.
append
(
linha
);
}
else
if
(
possuiPlano
[
0
]
.
firstElementChild
.
className
==
'exibirPlano'
){
possuiPlano
[
0
]
.
style
.
display
=
'block'
;
}
deletar
=
$
(
this
)
.
parent
()
.
next
()[
0
];
deletar
.
style
.
display
=
"none"
;
});
// $('#addPlanoTrabalho').click(function(e) {
// $('#addPlanoTrabalho').click(function(e) {
// e.preventDefault();
// e.preventDefault();
// if (qtdLinhas < 4) {
// if (qtdLinhas < 4) {
...
@@ -471,7 +461,7 @@
...
@@ -471,7 +461,7 @@
//replace the "Choose a file" label
//replace the "Choose a file" label
$
(
this
)
.
next
(
'#custom-file-label'
)
.
html
(
fileName
);
$
(
this
)
.
next
(
'#custom-file-label'
)
.
html
(
fileName
);
})
})
// F
$
(
'#buttonSim'
)
.
on
(
'click'
,
function
(
e
)
{
$
(
'#buttonSim'
)
.
on
(
'click'
,
function
(
e
)
{
e
.
preventDefault
();
e
.
preventDefault
();
$
(
'#inputEtica'
)
.
prop
(
'disabled'
,
false
);
$
(
'#inputEtica'
)
.
prop
(
'disabled'
,
false
);
...
@@ -480,37 +470,51 @@
...
@@ -480,37 +470,51 @@
$
(
'#buttonNao'
)
.
on
(
'click'
,
function
(
e
)
{
$
(
'#buttonNao'
)
.
on
(
'click'
,
function
(
e
)
{
e
.
preventDefault
();
e
.
preventDefault
();
$
(
'#inputEtica'
)
.
prop
(
'disabled'
,
true
);
$
(
'#inputEtica'
)
.
prop
(
'disabled'
,
true
);
$
(
'#inputJustificativa'
)
.
prop
(
'disabled'
,
false
);
$
(
'#inputJustificativa'
)
.
prop
(
'disabled'
,
false
);
console
.
log
(
'button nao'
);
});
});
$
(
document
)
.
on
(
'click'
,
'.simPlano'
,
function
(
e
)
{
e
.
preventDefault
();
// Habilitando / desabilitando plano de trabalho
$
(
this
)
.
next
()[
0
]
.
className
=
'btn btn-primary mt-2 mb-2 naoPlano'
;
$
(
'.simPlano'
)
.
click
(
function
(
e
)
{
console
.
log
(
'button sim'
);
e
.
preventDefault
();
var
possuiPlano
=
$
(
this
)
.
parent
()
.
parent
()
.
next
();
//se o participante não tem plano, adicionar; se ele já tem, apenas exibir
if
(
possuiPlano
[
0
]
.
firstElementChild
==
null
){
linha
=
linhaPlanoTrabalho
();
possuiPlano
.
append
(
linha
);
possuiPlano
[
0
]
.
style
.
display
=
'block'
;
}
else
if
(
possuiPlano
[
0
]
.
firstElementChild
.
className
==
'exibirPlano'
){
possuiPlano
[
0
]
.
style
.
display
=
'block'
;
}
//esconder a imagem de deletar
deletar
=
$
(
this
)
.
parent
()
.
next
()[
0
];
deletar
.
style
.
display
=
"none"
;
});
});
// se não há plano de trabalho, esconder a div planoHabilitado e exibir imagem de deletar
$
(
document
)
.
on
(
'click'
,
'.naoPlano'
,
function
(
e
)
{
$
(
document
)
.
on
(
'click'
,
'.naoPlano'
,
function
(
e
)
{
e
.
preventDefault
();
e
.
preventDefault
();
var
plano
=
$
(
this
)
.
parent
()
.
parent
()
.
next
()[
0
];
var
plano
=
$
(
this
)
.
parent
()
.
parent
()
.
next
()[
0
];
plano
.
style
.
display
=
'none'
;
plano
.
style
.
display
=
'none'
;
$
(
this
)
.
prev
()[
0
]
.
className
=
'btn btn-primary mt-2 mb-2 simPlano'
;
deletar
=
$
(
this
)
.
parent
()
.
next
()[
0
]
deletar
=
$
(
this
)
.
parent
()
.
next
()[
0
]
deletar
.
style
.
display
=
"block"
;
deletar
.
style
.
display
=
"block"
;
console
.
log
(
'button nao'
);
//comunicar ao controller para deletar somente o plano
$
(
this
)
.
next
()
.
val
(
'sim'
);
});
});
//se há plano de trabalho, esconder a imagem de deletar
$
(
function
()
{
$
(
function
()
{
var
simPlano
=
document
.
getElementsByClassName
(
'simPlano'
);
var
simPlano
=
document
.
getElementsByClassName
(
'simPlano'
);
for
(
var
i
=
0
;
i
<
simPlano
.
length
;
i
++
){
for
(
var
i
=
0
;
i
<
simPlano
.
length
;
i
++
){
var
planoHabilitado
=
simPlano
[
i
]
.
parentElement
.
parentElement
.
nextElementSibling
;
var
planoHabilitado
=
simPlano
[
i
]
.
parentElement
.
parentElement
.
nextElementSibling
;
//se há plano de trabalho
if
(
planoHabilitado
.
firstElementChild
!=
null
&&
planoHabilitado
.
firstElementChild
.
className
==
'exibirPlano'
){
if
(
planoHabilitado
.
firstElementChild
!=
null
&&
planoHabilitado
.
firstElementChild
.
className
==
'exibirPlano'
){
simPlano
[
i
]
.
parentElement
.
nextElementSibling
.
style
.
display
=
"none"
;
simPlano
[
i
]
.
parentElement
.
nextElementSibling
.
style
.
display
=
"none"
;
simPlano
[
i
]
.
nextElementSibling
.
className
=
'btn btn-primary mt-2 mb-2 naoPlano'
;
}
simPlano
[
i
]
.
className
=
'btn btn-primary focus mt-2 mb-2 simPlano'
;
}
else
{
simPlano
[
i
]
.
nextElementSibling
.
className
=
'btn btn-primary focus mt-2 mb-2 naoPlano'
;
}
}
}
});
});
});
});
...
@@ -638,7 +642,8 @@
...
@@ -638,7 +642,8 @@
// }
// }
function
linhaPlanoTrabalho
(){
function
linhaPlanoTrabalho
(){
return
"<h5>Dados do plano de trabalho</h5>"
+
return
"<input"
+
" type="
+
"hidden"
+
" class="
+
"exibirPlano"
+
">"
+
"<h5>Dados do plano de trabalho</h5>"
+
"<div class="
+
"row"
+
">"
+
"<div class="
+
"row"
+
">"
+
"<div class="
+
"col-sm-4"
+
">"
+
"<div class="
+
"col-sm-4"
+
">"
+
"<label>Titulo*</label>"
+
"<label>Titulo*</label>"
+
...
@@ -672,19 +677,10 @@
...
@@ -672,19 +677,10 @@
"<a class="
+
"delete"
+
">"
+
"<a class="
+
"delete"
+
">"
+
"<img src="
+
"/img/icons/user-times-solid.svg"
+
" style="
+
"width:25px;margin-top:35px"
+
">"
+
"<img src="
+
"/img/icons/user-times-solid.svg"
+
" style="
+
"width:25px;margin-top:35px"
+
">"
+
"</a>"
+
"</a>"
+
"</div>"
+
"</div>"
+
//"</div>"+
"</div>"
;
"</div>"
;
}
}
function
addDeletar
(){
return
"<div class="
+
"col-sm-1"
+
" style="
+
"display:inline;"
+
">"
+
"<a class="
+
"delete"
+
">"
+
"<img src="
+
"/img/icons/user-times-solid.svg"
+
" style="
+
"width:25px;margin-top:35px"
+
">"
+
"</a>"
+
"</div>"
;
}
function
areas
()
{
function
areas
()
{
var
grandeArea
=
$
(
'#grandeArea'
)
.
val
();
var
grandeArea
=
$
(
'#grandeArea'
)
.
val
();
$
.
getJSON
(
"{{ config('app.url') }}/naturezas/areas/"
+
grandeArea
,
$
.
getJSON
(
"{{ config('app.url') }}/naturezas/areas/"
+
grandeArea
,
...
...
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