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
e8ed04d2
Commit
e8ed04d2
authored
Jun 24, 2020
by
alinetenorio
Browse files
finalizando validação de planilha
parent
46fef0e3
Changes
4
Show whitespace changes
Inline
Side-by-side
app/Http/Controllers/TrabalhoController.php
View file @
e8ed04d2
...
...
@@ -31,6 +31,7 @@ use Illuminate\Support\Facades\Log;
use
Illuminate\Support\Str
;
use
App\Mail\SubmissaoTrabalho
;
use
App\Mail\EventoCriado
;
use
Illuminate\Support\Facades\Validator
;
class
TrabalhoController
extends
Controller
{
...
...
@@ -125,23 +126,13 @@ class TrabalhoController extends Controller
'anexoComiteEtica'
=>
[(
$request
->
anexoComitePreenchido
!==
'sim'
&&
$request
->
anexoJustificativaPreenchido
!==
'sim'
?
'required_without:justificativaAutorizacaoEtica'
:
''
),
'file'
,
'mimes:pdf'
,
'max:2000000'
],
'justificativaAutorizacaoEtica'
=>
[(
$request
->
anexoJustificativaPreenchido
!==
'sim'
&&
$request
->
anexoComitePreenchido
!==
'sim'
?
'required_without:anexoComiteEtica'
:
''
),
'file'
,
'mimes:pdf'
,
'max:2000000'
],
'anexoLattesCoordenador'
=>
[(
$request
->
anexoLattesPreenchido
!==
'sim'
?
'required'
:
''
),
'file'
,
'mimes:pdf'
,
'max:2000000'
],
'anexoPlanilha'
=>
[(
$request
->
anexoPlanilhaPreenchido
!==
'sim'
?
'required'
:
''
),
'file'
,
'mimes:pdf,xls'
,
'max:2000000'
],
'anexoPlanilha'
=>
[(
$request
->
anexoPlanilhaPreenchido
!==
'sim'
?
'required'
:
''
),
'file'
,
'mimes:pdf,xls
,xlsx
'
,
'max:2000000'
],
'anexoPlanoTrabalho.*'
=>
[
'nullable'
,
'file'
,
'mimes:pdf'
,
'max:2000000'
],
]);
//dd($request->all());
// $extensions = array("xls","xlsx");
// if(isset($request->anexoPlanilha )){
// $result = array($request->file('anexoPlanilha')->getClientOriginalExtension());
// if(in_array($result[0], $extensions)){
// }else{
// $validatedData = $request->validate([
// 'anexoPlanilha' => [($request->anexoPlanilhaPreenchido!=='sim'?'required':''), 'file', 'mimes:pdf,xls,xlsx', 'max:2000000']
// ]);
// }
// }
if
(
gettype
(
$this
->
validarAnexosRascunho
(
$request
,
$trabalho
))
!=
'integer'
){
return
$this
->
validarAnexosRascunho
(
$request
,
$trabalho
);
}
//$trabalho = Trabalho::create([
$trabalho
[
'titulo'
]
=
$request
->
nomeProjeto
;
...
...
@@ -182,10 +173,13 @@ class TrabalhoController extends Controller
'nomePlanoTrabalho.*'
=>
[
'nullable'
,
'string'
],
'anexoProjeto'
=>
[(
$request
->
anexoProjetoPreenchido
!==
'sim'
?
'required'
:
''
),
'file'
,
'mimes:pdf'
,
'max:2000000'
],
'anexoLattesCoordenador'
=>
[(
$request
->
anexoLattesPreenchido
!==
'sim'
?
'required'
:
''
),
'file'
,
'mimes:pdf'
,
'max:2000000'
],
'anexoPlanilha'
=>
[(
$request
->
anexoPlanilhaPreenchido
!==
'sim'
?
'required'
:
''
),
'file'
,
'mimes:pdf,xls'
,
'max:2000000'
],
'anexoPlanilha'
=>
[(
$request
->
anexoPlanilhaPreenchido
!==
'sim'
?
'required'
:
''
),
'file'
,
'mimes:pdf,xls
,xlsx
'
,
'max:2000000'
],
'anexoPlanoTrabalho.*'
=>
[
'nullable'
,
'file'
,
'mimes:pdf'
,
'max:2000000'
],
]);
if
(
gettype
(
$this
->
validarAnexosRascunho
(
$request
,
$trabalho
))
!=
'integer'
){
return
$this
->
validarAnexosRascunho
(
$request
,
$trabalho
);
}
//$trabalho = Trabalho::create([
$trabalho
[
'titulo'
]
=
$request
->
nomeProjeto
;
$trabalho
[
'coordenador_id'
]
=
$coordenador
->
id
;
...
...
@@ -316,7 +310,7 @@ class TrabalhoController extends Controller
//---Dados do Projeto
$trabalho
=
Trabalho
::
where
(
'proponente_id'
,
$proponente
->
id
)
->
where
(
'evento_id'
,
$request
->
editalId
)
->
where
(
'status'
,
'Rascunho'
)
->
orderByDesc
(
'updated_at'
)
->
first
();
//
dd($trabalho);
//dd($trabalho);
if
(
$trabalho
==
null
){
$trabalho
=
new
Trabalho
();
$trabalho
->
proponente_id
=
$proponente
->
id
;
...
...
@@ -330,7 +324,7 @@ class TrabalhoController extends Controller
$trabalho
->
fill
(
array_fill_keys
(
$stringKeys
,
""
)
+
array_fill_keys
(
$intKeys
,
1
)
)
->
save
();
//
dd($trabalho);
//dd($trabalho);
}
if
(
!
(
is_null
(
$request
->
nomeProjeto
))
)
{
...
...
@@ -379,11 +373,24 @@ class TrabalhoController extends Controller
//---Anexos planos de trabalho
//dd($trabalho);
return
$trabalho
;
}
public
function
validarAnexosRascunho
(
Request
$request
,
$trabalho
){
//dd($trabalho->getAttributes());
$validator
=
Validator
::
make
(
$trabalho
->
getAttributes
(),[
'anexoPlanilhaPontuacao'
=>
$request
->
anexoPlanilha
==
null
?
[
'planilha'
]
:
[],
]);
if
(
$validator
->
fails
())
{
dd
(
'asdf'
);
return
back
()
->
withErrors
(
$validator
)
->
withInput
();
}
return
1
;
}
public
function
armazenarAnexosFinais
(
$request
,
$pasta
,
$trabalho
,
$evento
){
// Anexo Projeto
...
...
app/Providers/AppServiceProvider.php
View file @
e8ed04d2
...
...
@@ -27,5 +27,6 @@ class AppServiceProvider extends ServiceProvider
Validator
::
extend
(
'cpf'
,
'\App\Utils\CpfValidation@validate'
);
Validator
::
extend
(
'link_lattes'
,
'\App\Utils\LattesValidation@validate'
,
'Link inválido'
);
Validator
::
extend
(
'link_grupo'
,
'\App\Utils\GrupoPesquisaValidation@validate'
,
'Link inválido'
);
Validator
::
extend
(
'planilha'
,
'\App\Utils\ExtensaoValidation@validate'
,
'Extensão do arquivo é inválida'
);
}
}
app/Utils/ExtensaoValidation.php
0 → 100644
View file @
e8ed04d2
<?php
namespace
App\Utils
;
class
ExtensaoValidation
{
public
function
validate
(
$attribute
,
$value
,
$parameters
,
$validator
)
{
$extensions
=
array
(
"xls"
,
"xlsx"
,
"pdf"
);
$result
=
pathinfo
(
$value
)[
'extension'
];
if
(
!
in_array
(
$result
,
$extensions
)){
return
false
;
}
return
true
;
}
}
\ No newline at end of file
resources/views/evento/submeterTrabalho.blade.php
View file @
e8ed04d2
...
...
@@ -8,7 +8,7 @@
<
div
class
=
"card-body"
>
<
h5
class
=
"card-title"
>
Enviar
Projeto
</
h5
>
<
p
class
=
"card-text"
>
<
form
method
=
"POST"
action
=
"
{
{route('trabalho.store')}
}
"
enctype
=
"multipart/form-data"
>
<
form
method
=
"POST"
name
=
"formTrabalho"
action
=
"
{
{route('trabalho.store')}
}
"
enctype
=
"multipart/form-data"
>
@
csrf
<
input
type
=
"hidden"
name
=
"editalId"
value
=
"
{
{$edital->id}
}
"
>
...
...
@@ -143,7 +143,7 @@
'nomeAnexo'
=>
'anexoProjeto'
])}}
">Arquivo atual</a>
@endif
<input type="
hidden
" id="
anexoProjetoPreenchido
" name="
anexoProjetoPreenchido
"
@if( isset(
$rascunho
) &&
$rascunho->anexoProjeto
!= "") value="
sim
" @else value="
old
(
'anexoProjetoPreenchido'
)
" @endif >
@if( isset(
$rascunho
) &&
$rascunho->anexoProjeto
!= "") value="
sim
" @else value="
{{
old
(
'anexoProjetoPreenchido'
)
}}
" @endif >
<div class="
input
-
group
">
<div class="
custom
-
file
">
...
...
@@ -165,7 +165,7 @@
'nomeAnexo'
=>
'anexoLattesCoordenador'
])}}
">Arquivo atual</a>
@endif
<input type="
hidden
" id="
anexoLattesPreenchido
" name="
anexoLattesPreenchido
"
@if( isset(
$rascunho
) &&
$rascunho->anexoLattesCoordenador
!= "") value="
sim
" @else value="
old
(
'anexoLattesPreenchido'
)
" @endif >
@if( isset(
$rascunho
) &&
$rascunho->anexoLattesCoordenador
!= "") value="
sim
" @else value="
{{
old
(
'anexoLattesPreenchido'
)
}}
" @endif >
<div class="
input
-
group
">
...
...
@@ -198,7 +198,7 @@
'nomeAnexo'
=>
'anexoAutorizacaoComiteEtica'
])}}
">Arquivo atual</a>
@endif
<input type="
hidden
" id="
anexoComitePreenchido
" name="
anexoComitePreenchido
"
@if( isset(
$rascunho
) &&
$rascunho->anexoAutorizacaoComiteEtica
!= "") value="
sim
" @else value="
old
(
'anexoComitePreenchido'
)
" @endif >
@if( isset(
$rascunho
) &&
$rascunho->anexoAutorizacaoComiteEtica
!= "") value="
sim
" @else value="
{{
old
(
'anexoComitePreenchido'
)
}}
" @endif >
<div class="
input
-
group
">
...
...
@@ -221,7 +221,7 @@
'nomeAnexo'
=>
'anexoPlanilhaPontuacao'
])}}
">Arquivo atual</a>
@endif
<input type="
hidden
" id="
anexoPlanilhaPreenchido
" name="
anexoPlanilhaPreenchido
"
@if( isset(
$rascunho
) &&
$rascunho->anexoPlanilhaPontuacao
!= "") value="
sim
" @else value="
old
(
'anexoPlanilhaPreenchido'
)
" @endif >
@if( isset(
$rascunho
) &&
$rascunho->anexoPlanilhaPontuacao
!= "") value="
sim
" @else value="
{{
old
(
'anexoPlanilhaPreenchido'
)
}}
" @endif >
<div class="
input
-
group
">
<div class="
custom
-
file
">
...
...
@@ -234,6 +234,11 @@
<strong>{{
$message
}}</strong>
</span>
@enderror
@error('anexoPlanilhaPontuacao')
<span class="
invalid
-
feedback
" role="
alert
" style="
overflow
:
visible
;
display
:
block
">
<strong>{{
$message
}}</strong>
</span>
@enderror
</div>
<div class="
col
-
sm
-
6
">
...
...
@@ -243,7 +248,7 @@
'nomeAnexo'
=>
'justificativaAutorizacaoEtica'
])}}
">Arquivo atual</a>
@endif
<input type="
hidden
" id="
anexoJustificativaPreenchido
" name="
anexoJustificativaPreenchido
"
@if( isset(
$rascunho
) &&
$rascunho->justificativaAutorizacaoEtica
!= "") value="
sim
" @else value="
old
(
'anexoJustificativaPreenchido'
)
" @endif >
@if( isset(
$rascunho
) &&
$rascunho->justificativaAutorizacaoEtica
!= "") value="
sim
" @else value="
{{
old
(
'anexoJustificativaPreenchido'
)
}}
" @endif >
<div class="
input
-
group
">
...
...
@@ -268,7 +273,7 @@
'nomeAnexo'
=>
'anexoDecisaoCONSU'
])}}
">Arquivo atual</a>
@endif
<input type="
hidden
" id="
anexoConsuPreenchido
" name="
anexoConsuPreenchido
"
@if( isset(
$rascunho
) &&
$rascunho->anexoDecisaoCONSU
!= "") value="
sim
" @else value="
old
(
'anexoConsuPreenchido'
)
" @endif >
@if( isset(
$rascunho
) &&
$rascunho->anexoDecisaoCONSU
!= "") value="
sim
" @else value="
{{
old
(
'anexoConsuPreenchido'
)
}}
" @endif >
<div class="
input
-
group
">
<div class="
custom
-
file
">
...
...
@@ -770,6 +775,11 @@
anexoPlanilhaPreenchido
.
value
=
"sim"
;
}
}
function
removerPlanilha
(){
console
.
log
(
'a'
);
$
(
'#anexoPlanilhaPreenchido'
)
.
val
(
""
);
}
window
.
onload
=
areas
();
window
.
onload
=
habilitarBotao
();
</
script
>
...
...
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