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

atualizando

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