Commit 34f2a26d authored by carlos's avatar carlos
Browse files

atualizando

parent 7b97025b
......@@ -79,7 +79,7 @@ class TrabalhoController extends Controller
//Relaciona o projeto criado com o proponente que criou o projeto
$proponente = Proponente::where('user_id', Auth::user()->id)->first();
//$trabalho->proponentes()->save($proponente);
//dd($coordenador);
//dd($coordenador->id);
$trabalho = "trabalho";
if($evento->inicioSubmissao > $mytime){
if($mytime >= $evento->fimSubmissao){
......@@ -287,6 +287,8 @@ class TrabalhoController extends Controller
$subareas = Subarea::all();
$funcaoParticipantes = FuncaoParticipantes::all();
$participantes = Participante::where('trabalho_id', $id)->get();
$participantesUsersIds = Participante::where('trabalho_id', $id)->select('user_id')->get();
$users = User::whereIn('id', $participantesUsersIds)->get();
$arquivos = Arquivo::where('trabalhoId', $id)->get();
return view('projeto.editar')->with(['projeto' => $projeto,
......@@ -294,6 +296,7 @@ class TrabalhoController extends Controller
'areas' => $areas,
'subAreas' => $subareas,
'edital' => $edital,
'users' => $users,
'funcaoParticipantes' => $funcaoParticipantes,
'participantes' => $participantes,
'arquivos' => $arquivos,]);
......@@ -401,10 +404,11 @@ class TrabalhoController extends Controller
$trabalho->update();
// criando novos participantes que podem ter sido adicionados
$participantes = Participante::where('trabalho_id', $trabalho->id)->get();
$participantesUsersIds = Participante::where('trabalho_id', '=', $trabalho->id)->select('user_id')->get();
$users = User::whereIn('id', $participantesUsersIds)->get();
$emailParticipantes = [];
foreach ($participantes as $participante) {
array_push($emailParticipantes, $participante->user->email);
foreach ($users as $user) {
array_push($emailParticipantes, $user->email);
}
foreach ($request->emailParticipante as $key => $value) {
......@@ -443,7 +447,7 @@ class TrabalhoController extends Controller
//atualizando os participantes que já estão no projeto e planos de trabalho se enviados
if (in_array($request->emailParticipante[$key], $emailParticipantes, false)) {
$user = User::where('email', $request->emailParticipante[$key])->first();
$participante::where([['user_id', '=', $user->id], ['trabalho_id', '=', $trabalho->id]]);
$participante = Participante::where([['user_id', '=', $user->id], ['trabalho_id', '=', $trabalho->id]])->first();
$user->name = $request->nomeParticipante[$key];
$user->update();
......@@ -451,34 +455,37 @@ class TrabalhoController extends Controller
$participante->funcao_participante_id = $request->funcaoParticipante[$key];
$participante->update();
// //atualizando planos de trabalho incompleto
// dd($request);
// if (!(is_null($request->anexoPlanoTrabalho[1]))) {
// $arquivo = Arquivo::where('participanteId', $participante->id)->first();
// Storage::delete($arquivo->nome);
// $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->nome = $path . $nome;
// $arquivo->trabalhoId = $trabalho->id;
// $arquivo->data = $mytime;
// $arquivo->participanteId = $participante->id;
// $arquivo->versaoFinal = true;
// $arquivo->save();
// }
//atualizando planos de trabalho
if (array_key_exists($key, $request->anexoPlanoTrabalho)) {
if (!(is_null($request->anexoPlanoTrabalho[$key]))) {
$arquivo = Arquivo::where('participanteId', $participante->id)->first();
Storage::delete($arquivo->nome);
$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->nome = $path . $nome;
$arquivo->trabalhoId = $trabalho->id;
$arquivo->data = $mytime;
$arquivo->participanteId = $participante->id;
$arquivo->versaoFinal = true;
$arquivo->save();
}
}
}
}
// Atualizando possiveis usuários removidos
$participantes = Participante::where('trabalho_id', $trabalho->id)->get();
$participantesUsersIds = Participante::where('trabalho_id', '=', $trabalho->id)->select('user_id')->get();
$users = User::whereIn('id', $participantesUsersIds)->get();
foreach ($participantes as $participante) {
if (!(in_array($participante->user->email, $request->emailParticipante, false))) {
foreach ($users as $user) {
if (!(in_array($user->email, $request->emailParticipante, false))) {
$participante = Participante::where([['user_id', '=', $user->id], ['trabalho_id', '=', $trabalho->id]])->first();
$arquivo = Arquivo::where('participanteId', $participante->id);
Storage::delete($arquivo->nome);
$arquivo->delete();
......
......@@ -1215,16 +1215,16 @@
},
{
"name": "opis/closure",
"version": "3.5.3",
"version": "3.5.4",
"source": {
"type": "git",
"url": "https://github.com/opis/closure.git",
"reference": "cac47092144043d5d676e2e7cf8d0d2f83fc89ca"
"reference": "1d0deef692f66dae5d70663caee2867d0971306b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/opis/closure/zipball/cac47092144043d5d676e2e7cf8d0d2f83fc89ca",
"reference": "cac47092144043d5d676e2e7cf8d0d2f83fc89ca",
"url": "https://api.github.com/repos/opis/closure/zipball/1d0deef692f66dae5d70663caee2867d0971306b",
"reference": "1d0deef692f66dae5d70663caee2867d0971306b",
"shasum": ""
},
"require": {
......@@ -1272,7 +1272,7 @@
"serialization",
"serialize"
],
"time": "2020-05-25T09:32:45+00:00"
"time": "2020-06-07T11:41:29+00:00"
},
{
"name": "paragonie/random_compat",
......@@ -1321,16 +1321,16 @@
},
{
"name": "phpoption/phpoption",
"version": "1.7.3",
"version": "1.7.4",
"source": {
"type": "git",
"url": "https://github.com/schmittjoh/php-option.git",
"reference": "4acfd6a4b33a509d8c88f50e5222f734b6aeebae"
"reference": "b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/schmittjoh/php-option/zipball/4acfd6a4b33a509d8c88f50e5222f734b6aeebae",
"reference": "4acfd6a4b33a509d8c88f50e5222f734b6aeebae",
"url": "https://api.github.com/repos/schmittjoh/php-option/zipball/b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3",
"reference": "b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3",
"shasum": ""
},
"require": {
......@@ -1372,7 +1372,7 @@
"php",
"type"
],
"time": "2020-03-21T18:07:53+00:00"
"time": "2020-06-07T10:40:07+00:00"
},
{
"name": "psr/container",
......@@ -3316,27 +3316,27 @@
},
{
"name": "vlucas/phpdotenv",
"version": "v3.6.5",
"version": "v3.6.6",
"source": {
"type": "git",
"url": "https://github.com/vlucas/phpdotenv.git",
"reference": "8b64814b356b96a90d2bc942b152c80d8888b8d4"
"reference": "4669484ccbc38fe7c4e0c50456778f2010566aad"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/8b64814b356b96a90d2bc942b152c80d8888b8d4",
"reference": "8b64814b356b96a90d2bc942b152c80d8888b8d4",
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/4669484ccbc38fe7c4e0c50456778f2010566aad",
"reference": "4669484ccbc38fe7c4e0c50456778f2010566aad",
"shasum": ""
},
"require": {
"php": "^5.4 || ^7.0 || ^8.0",
"phpoption/phpoption": "^1.5",
"symfony/polyfill-ctype": "^1.9"
"phpoption/phpoption": "^1.5.2",
"symfony/polyfill-ctype": "^1.16"
},
"require-dev": {
"ext-filter": "*",
"ext-pcre": "*",
"phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0 || ^7.0"
"phpunit/phpunit": "^4.8.35 || ^5.7.27 || ^6.5.6 || ^7.0"
},
"suggest": {
"ext-filter": "Required to use the boolean validator.",
......@@ -3375,7 +3375,7 @@
"env",
"environment"
],
"time": "2020-05-23T09:42:03+00:00"
"time": "2020-06-02T14:08:54+00:00"
}
],
"packages-dev": [
......
......@@ -26,7 +26,18 @@
</div>
</div>
</a>
</div>
</div>
<div class="col-sm-3 d-flex justify-content-center">
<a href="{{ route('grandearea.index') }}" style="text-decoration:none; color: inherit;">
<div class="card text-center " style="border-radius: 30px; width: 13rem;height: 15rem;">
<div class="card-body d-flex justify-content-center">
<h2 style="padding-top:15px">Áreas</h2>
</div>
</div>
</a>
</div>
<div class="col-sm-3 d-flex justify-content-center">
<a href="{{ route('admin.usuarios') }}" style="text-decoration:none; color: inherit;">
<div class="card text-center " style="border-radius: 30px; width: 13rem;height: 15rem;">
......
......@@ -273,96 +273,100 @@
<div class="col-sm-12">
<div id="participantes">
@foreach($participantes as $participante)
<div id="novoParticipante">
<br>
<h5>Dados do participante</h5>
<div class="row">
<div class="col-sm-5">
<label>Nome Completo</label>
<input value="{{ $participante->user->name }}" type="text" style="margin-bottom:10px" class="form-control @error('nomeParticipante') is-invalid @enderror" name="nomeParticipante[]" placeholder="Nome" required>
@error('nomeParticipante')
<span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
<div class="col-sm-4">
<label>E-mail</label>
<input value="{{ $participante->user->email }}" type="email" style="margin-bottom:10px" class="form-control @error('emailParticipante') is-invalid @enderror" name="emailParticipante[]" placeholder="email" required>
@error('emailParticipante')
<span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
<div class="col-sm-3">
<label>Função:</label>
<select class="form-control @error('funcaoParticipante') is-invalid @enderror" name="funcaoParticipante[]" id="funcaoParticipante">
<option value="" disabled selected hidden>-- Função --</option>
@foreach($funcaoParticipantes as $funcaoParticipante)
@if($funcaoParticipante->id === $participante->funcao_participante_id)
<option value="{{$funcaoParticipante->id}}" selected>{{$funcaoParticipante->nome}}</option>
@else
<option value="{{$funcaoParticipante->id}}">{{$funcaoParticipante->nome}}</option>
@endif
@endforeach
@error('funcaoParticipante')
<span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
<strong>{{ $message }}</strong>
</span>
@enderror
</select>
</div>
</div>
<h5>Dados do plano de trabalho</h5>
@foreach ($arquivos as $arquivo)
@if($arquivo->participanteId === $participante->id)
<a href="{{ route('baixar.plano', ['id' => $arquivo->id]) }}">Plano de trabalho atual</a>
@endif
@endforeach
<div class="row">
<div class="col-sm-12">
<div id="planoTrabalho">
<div class="row">
<div class="col-sm-4">
<label>Titulo </label>
<input type="text" style="margin-bottom:10px" class="form-control @error('nomePlanoTrabalho') is-invalid @enderror" name="nomePlanoTrabalho[]" placeholder="Nome">
@error('nomePlanoTrabalho')
@foreach($users as $user)
@if($participante->user_id === $user->id)
<div id="novoParticipante">
<br>
<h5>Dados do participante</h5>
<div class="row">
<div class="col-sm-5">
<label>Nome Completo</label>
<input value="{{ $user->name }}" type="text" style="margin-bottom:10px" class="form-control @error('nomeParticipante') is-invalid @enderror" name="nomeParticipante[]" placeholder="Nome" required>
@error('nomeParticipante')
<span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
<div class="col-sm-4">
<label>E-mail</label>
<input value="{{ $user->email }}" type="email" style="margin-bottom:10px" class="form-control @error('emailParticipante') is-invalid @enderror" name="emailParticipante[]" placeholder="email" required>
@error('emailParticipante')
<span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
<div class="col-sm-3">
<label>Função:</label>
<select class="form-control @error('funcaoParticipante') is-invalid @enderror" name="funcaoParticipante[]" id="funcaoParticipante">
<option value="" disabled selected hidden>-- Função --</option>
@foreach($funcaoParticipantes as $funcaoParticipante)
@if($funcaoParticipante->id === $participante->funcao_participante_id)
<option value="{{$funcaoParticipante->id}}" selected>{{$funcaoParticipante->nome}}</option>
@else
<option value="{{$funcaoParticipante->id}}">{{$funcaoParticipante->nome}}</option>
@endif
@endforeach
@error('funcaoParticipante')
<span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
{{-- Arquivo --}}
<div class="col-sm-7">
<label for="nomeTrabalho">Anexo</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text" id="anexoPlanoTrabalho">Selecione um arquivo:</span>
</select>
</div>
</div>
<h5>Dados do plano de trabalho</h5>
@foreach ($arquivos as $arquivo)
@if($arquivo->participanteId === $participante->id)
<a href="{{ route('baixar.plano', ['id' => $arquivo->id]) }}">Plano de trabalho atual</a>
@endif
@endforeach
<div class="row">
<div class="col-sm-12">
<div id="planoTrabalho">
<div class="row">
<div class="col-sm-4">
<label>Titulo </label>
<input type="text" style="margin-bottom:10px" class="form-control @error('nomePlanoTrabalho') is-invalid @enderror" name="nomePlanoTrabalho[]" placeholder="Nome">
@error('nomePlanoTrabalho')
<span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
{{-- Arquivo --}}
<div class="col-sm-7">
<label for="nomeTrabalho">Anexo</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text" id="anexoPlanoTrabalho">Selecione um arquivo:</span>
</div>
<div class="custom-file">
<input type="file" class="custom-file-input @error('anexoPlanoTrabalho') is-invalid @enderror" id="anexoPlanoTrabalho" aria-describedby="anexoPlanoTrabalho" name="anexoPlanoTrabalho[]">
<label class="custom-file-label" id="custom-file-label" for="inputGroupFile01">O arquivo deve ser no formato PDF de até 2mb.</label>
</div>
</div>
@error('anexoPlanoTrabalho')
<span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
<div class="custom-file">
<input type="file" class="custom-file-input @error('anexoPlanoTrabalho') is-invalid @enderror" id="anexoPlanoTrabalho" aria-describedby="anexoPlanoTrabalho" name="anexoPlanoTrabalho[]">
<label class="custom-file-label" id="custom-file-label" for="inputGroupFile01">O arquivo deve ser no formato PDF de até 2mb.</label>
<div class="col-sm-1">
<a class="delete">
<img src="/img/icons/user-times-solid.svg" style="width:25px;margin-top:35px">
</a>
</div>
</div>
@error('anexoPlanoTrabalho')
<span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
<div class="col-sm-1">
<a class="delete">
<img src="/img/icons/user-times-solid.svg" style="width:25px;margin-top:35px">
</a>
</div>
</div>
</div>
</div>
</div>
</div>
@endif
@endforeach
@endforeach
</div>
<a href="#" class="btn btn-primary" id="addCoautor" style="width:100%;margin-top:10px">Participantes +</a>
......@@ -419,7 +423,7 @@
addModalidade($(this).val());
});
$(document).on('click', '.delete', function() {
if (qtdParticipantes > 2) {
if (qtdParticipantes > 1) {
qtdParticipantes--;
$(this).closest('#novoParticipante').remove();
return false;
......
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