participantes.blade.php 41 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472
<!-- Participantes -->
@php $cont= 0; @endphp
<div class="col-md-12" style="margin-top: 20px">
    <div class="card" style="border-radius: 5px">
        <div class="card-body" style="padding-top: 0.2rem;">
            <div class="container">
                <div class="form-row mt-3">
                    <div class="col-md-11"><h5 style="color: #234B8B; font-weight: bold">Dados do(s) Discente(s)</h5></div>
                    <div class="col-md-1 text-sm-right">
                        <a type="button" value="{{ $edital->id }}" id="atribuir1" data-toggle="modal" data-target="#exampleModal0">
                            <img class="" src="{{asset('img/icons/add.ico')}}" style="width:30px" alt="">
                        </a>
                    </div>
                </div>
                <hr style="border-top: 1px solid#1492E6">
                <div class="row-cols-sm-12 justify-content-start">
                    <ol style="counter-reset: item;list-style-type: none; margin-left:-20px; margin-right:20px; margin-top:10px">
                        <li id="item">
                            <div style="margin-bottom:15px">
                                <div id="participante" class="row">
                                    @for($i = 0; $i < $edital->numParticipantes; $i++)

                                        <div @if(!isset(old('marcado')[$i])) hidden @endif class="form-row mb-1 col-md-3" style="margin-top: 10px" id="part{{$i}}">
                                            <div class="col-sm-4" style="display: flex; align-items: center;">
                                                <img src="{{asset('img/icons/usuario.svg')}}" style="width:60px" alt="">
                                            </div>
                                            <div class="col-sm-8" style="display: flex; align-items: center;">
                                                <a href="" style="" class="justify-content-center" data-toggle="modal" data-target="#exampleModal{{$i}}" id="nomePart{{$i+1}}">
                                                    @if(isset(old('marcado')[$i]))
                                                        @if(isset(old('name')[$i]))Nome: {{old('name')[$i]}} @else Discente {{$i+1}} @endif
                                                            @if(isset(old('nomePlanoTrabalho')[$i]))<br> Plano: {{old('nomePlanoTrabalho')[$i]}} @endif
                                                    @endif
                                                </a>
                                            </div>
                                        </div>

                                        <div class="modal fade" id="exampleModal{{$i}}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                                            <div class="modal-dialog modal-dialog-centered modal-xl">
                                                <div class="modal-content">
                                                    <div class="modal-header">
                                                        <h5 class="modal-title" id="exampleModalLabel">Dados do Discente {{$i+1}}</h5>
                                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                            <span aria-hidden="true">&times;</span>
                                                        </button>
                                                    </div>

                                                    <div class="modal-body">
                                                        <div class="col-1" style="margin-top:9.3px" hidden>
                                                            {{-- <button type="button" class="btn btn-danger shadow-sm" id="buttonRemover" onclick="removerPart(this)" >X</button> --}}
                                                            <input type="checkbox" id="checkB{{$i}}" aria-label="Checkbox for following text input"  @if(isset(old('marcado')[$i])) checked @endif name="marcado[]" value="{{ $i }}">
                                                        </div>


                                                        <div class="col-md-12">
                                                            <div class="container">
                                                                <div class="row">
                                                                    <input type="hidden"  name="funcaoParticipante[]" value="4">
                                                                    <div class="col-md-12 mt-3"><h5>Dados do discente</h5></div>
                                                                    <div class="col-6">
                                                                        @component('componentes.input', ['label' => 'Nome completo'])
                                                                            <input type="text" class="form-control " value="{{old('name')[$i] ?? "" }}"  name="name[{{$i}}]" placeholder="Nome Completo" maxlength="150" id="nome{{$i}}"/>
                                                                            <span style="color: red; font-size: 12px" id="caracsRestantesnome{{$i}}">
                              </span>
                                                                            @error("name.".$i)
                                                                            <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
                                  <strong>{{ $message }}</strong>
                                </span>
                                                                            @enderror
                                                                        @endcomponent
                                                                    </div>
                                                                    <div class="col-6">
                                                                        @component('componentes.input', ['label' => 'E-mail'])
                                                                            <input type="email" class="form-control" value="{{old('email')[$i] ?? "" }}" name="email[{{$i}}]" placeholder="E-mail" maxlength="150" id="email{{$i}}" />
                                                                            <span style="color: red; font-size: 12px" id="caracsRestantesemail{{$i}}">
                                  </span>
                                                                            @error('email.'.$i)
                                                                            <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
                                      <strong>{{ $message }}</strong>
                                    </span>
                                                                            @enderror
                                                                        @endcomponent
                                                                    </div>
                                                                    <div class="col-6">
                                                                        @component('componentes.input', ['label' => 'Data de nascimento'])
                                                                            <input type="date" class="form-control"  value="{{old('data_de_nascimento')[$i] ?? "" }}" name="data_de_nascimento[{{$i}}]" placeholder="Data de nascimento" />
                                                                            @error('data_de_nascimento.'.$i)
                                                                            <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
                                      <strong>{{ $message }}</strong>
                                    </span>
                                                                            @enderror
                                                                        @endcomponent
                                                                    </div>
                                                                    <div class="col-6">
                                                                        @component('componentes.input', ['label' => 'CPF'])
                                                                            <input type="text" class="form-control cpf" value="{{old('cpf')[$i] ?? "" }}" name="cpf[{{$i}}]" placeholder="CPF"  />

                                                                            @error('cpf.'.$i)
                                                                            <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
                                      <strong>{{ $message }}</strong>
                                    </span>
                                                                            @enderror
                                                                        @endcomponent
                                                                    </div>
                                                                    <div class="col-6">
                                                                        @component('componentes.input', ['label' => 'RG'])
                                                                            <input type="text" class="form-control rg"  min="9" maxlength="9" value="{{old('rg')[$i] ?? "" }}" name="rg[{{$i}}]"  placeholder="RG" />
                                                                            @error('rg.'.$i)
                                                                            <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
                                      <strong>{{ $message }}</strong>
                                    </span>
                                                                            @enderror
                                                                        @endcomponent
                                                                    </div>
                                                                    <div class="col-6">
                                                                        @component('componentes.input', ['label' => 'Celular'])
                                                                            <input type="tel" class="form-control celular"  value="{{old('celular')[$i] ?? "" }}" name="celular[{{$i}}]"  placeholder="Celular" />
                                                                            @error('celular.'.$i)
                                                                            <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
                                      <strong>{{ $message }}</strong>
                                    </span>
                                                                            @enderror
                                                                        @endcomponent
                                                                    </div>
                                                                    <div class="col-md-12"><h5>Endereço</h5></div>
                                                                    <div class="col-6">
                                                                        @component('componentes.input', ['label' => 'CEP'])
                                                                            <input name="cep[{{$i}}]" type="text" id="cep{{$i}}" 
                                                                            value="{{ old('cep')[$i] ?? ''}}" class="form-control cep"
                                                                            onblur="pesquisacep(this.value, {{$i}})" />
                                                                            @error('cep.'.$i)
                                                                                <span class="invalid-feedback" role="alert" style="overflow: visible; display:block"><strong>{{ $message }}</strong></span>
                                                                            @enderror
                                                                        @endcomponent
                                                                    </div>

                                                                    <div class="col-6">
                                                                        @component('componentes.input', ['label' => 'Estado'])
                                                                            <input name="uf[{{$i}}]" type="text" class="form-control"
                                                                            value="{{ old('uf')[$i] ?? '' }}" id="uf{{$i}}" />
                                                                            @error('uf.'.$i)
                                                                                <span class="invalid-feedback" role="alert" style="overflow: visible; display:block"><strong>{{ $message }}</strong></span>
                                                                            @enderror
                                                                        @endcomponent
                                                                    </div>

                                                                    <div class="col-6">
                                                                        @component('componentes.input', ['label' => 'Cidade'])
                                                                            <input name="cidade[{{$i}}]" type="text" id="cidade{{$i}}" class="form-control"
                                                                            value="{{ old('cidade')[$i] ?? '' }}" />
                                                                            @error('cidade.'.$i)
                                                                                <span class="invalid-feedback" role="alert" style="overflow: visible; display:block"><strong>{{ $message }}</strong></span>
                                                                            @enderror
                                                                        @endcomponent
                                                                    </div>

                                                                    <div class="col-6">
                                                                        @component('componentes.input', ['label' => 'Bairro'])
                                                                            <input name="bairro[{{$i}}]" type="text" id="bairro{{$i}}" class="form-control" 
                                                                            value="{{ old('bairro')[$i] ?? '' }}" />
                                                                            @error('bairro.'.$i)
                                                                                <span class="invalid-feedback" role="alert" style="overflow: visible; display:block"><strong>{{ $message }}</strong></span>
                                                                            @enderror
                                                                        @endcomponent
                                                                    </div>

                                                                    <div class="col-6">
                                                                        @component('componentes.input', ['label' => 'Rua'])
                                                                            <input name="rua[{{$i}}]" type="text" id="rua{{$i}}" class="form-control"
                                                                            value="{{ old('rua')[$i] ?? '' }}" />
                                                                            @error('rua.'.$i)
                                                                                <span class="invalid-feedback" role="alert" style="overflow: visible; display:block"><strong>{{ $message }}</strong></span>
                                                                            @enderror
                                                                        @endcomponent
                                                                    </div>

                                                                    <div class="col-6">
                                                                        @component('componentes.input', ['label' => 'Número'])
                                                                            <input name="numero[{{$i}}]" type="text" class="form-control"
                                                                            value="{{ old('numero')[$i] ?? '' }}" />
                                                                            @error('numero.'.$i)
                                                                                <span class="invalid-feedback" role="alert" style="overflow: visible; display:block"><strong>{{ $message }}</strong></span>
                                                                            @enderror
                                                                        @endcomponent
                                                                    </div>
                                                                    
                                                                    
                                                                    
                                                                    
                                                                    
                                                                    <div class="col-12">
                                                                        <div class="form-group">
                                                                            <label class=" control-label" for="firstname">Complemento</label>
                                                                            <input type="text" class="form-control" value="{{old('complemento')[$i] ?? "" }}" name="complemento[{{$i}}]"    placeholder="Complemento" maxlength="75" id="complemento{{$i}}"/>
                                                                            <span style="color: red; font-size: 12px" id="caracsRestantescomplemento{{$i}}">
                              </span>
                                                                            @error('complemento.'.$i)
                                                                            <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
                                    <strong>{{ $message }}</strong>
                                  </span>
                                                                            @enderror
                                                                        </div>
                                                                    </div>
                                                                    <div class="col-md-12"><h5>Dados do curso</h5></div>
                                                                    <div class="col-6">
                                                                        @component('componentes.input', ['label' => 'Instituição de Ensino'])
                                                                            <select style="display: inline" onchange="showInstituicao(this)" class="form-control" name="instituicao[{{$i}}]">
                                                                                <option value="" disabled selected hidden>-- Instituição --</option>
                                                                                <option @if(old('instituicao')[$i] ?? "" == 'UFAPE' ) selected @endif value="UFAPE">Universidade Federal do Agreste de Pernambuco - UFAPE</option>
                                                                                <option @if(old('instituicao')[$i] ?? "" == 'Outra' ) selected @endif value="Outra" >Outra</option>
                                                                            </select>
                                                                            @error('instituicao.'.$i)
                                                                            <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
                                      <strong>{{ $message }}</strong>
                                    </span>
                                                                            @enderror
                                                                        @endcomponent
                                                                    </div>
                                                                    <div class="col-6" id="displayinstituicao[{{$i}}]" style='display:none'>
                                                                        @component('componentes.input', ['label' => 'Digite a Instituição'])
                                                                            <input id="outrainstituicao[{{$i}}]" type="text" class="form-control @error('instituicao') is-invalid @enderror" name="outrainstituicao[{{$i}}]" value="{{ old('outrainstituicao')[$i] ?? "" }}" placeholder="Digite o nome da Instituição" autocomplete="instituicao" autofocus>
                                                                            @error('outrainstituicao.'.$i)
                                                                            <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                                                            @enderror
                                                                        @endcomponent
                                                                    </div>
                                                                    <div class="col-6">
                                                                        @component('componentes.input', ['label' => 'Curso'])
                                                                            <select style="display: inline" class="form-control" name="curso[{{$i}}]" onchange="showCurso(this)">
                                                                                <option value="" disabled selected hidden>-- Selecione uma opção--</option>
                                                                                <option @if(old('curso')[$i] ?? "" == 'Bacharelado em Agronomia' ) selected @endif value="Bacharelado em Agronomia">Bacharelado em Agronomia</option>
                                                                                <option @if(old('curso')[$i] ?? "" == 'Bacharelado em Ciência da Computação' ) selected @endif value="Bacharelado em Ciência da Computação">Bacharelado em Ciência da Computação</option>
                                                                                <option @if(old('curso')[$i] ?? "" == 'Bacharelado em Engenharia de Alimentos' ) selected @endif value="Bacharelado em Engenharia de Alimentos">Bacharelado em Engenharia de Alimentos</option>
                                                                                <option @if(old('curso')[$i] ?? "" == 'Bacharelado em Medicina Veterinária' ) selected @endif value="Bacharelado em Medicina Veterinária">Bacharelado em Medicina Veterinária</option>
                                                                                <option @if(old('curso')[$i] ?? "" == 'Bacharelado em Zootecnia' ) selected @endif value="Bacharelado em Zootecnia">Bacharelado em Zootecnia</option>
                                                                                <option @if(old('curso')[$i] ?? "" == 'Licenciatura em Letras' ) selected @endif value="Licenciatura em Letras">Licenciatura em Letras</option>
                                                                                <option @if(old('curso')[$i] ?? "" == 'Licenciatura em Pedagogia' ) selected @endif value="Licenciatura em Pedagogia">Licenciatura em Pedagogia</option>
                                                                                <option @if(old('curso')[$i] ?? "" == 'Outro' ) selected @endif value="Outro" >Outro</option>
                                                                            </select>
                                                                            @error('curso.'.$i)
                                                                            <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
                                      <strong>{{ $message }}</strong>
                                    </span>
                                                                            @enderror
                                                                        @endcomponent
                                                                    </div>
                                                                    <div class="col-6" id="displaycurso[{{$i}}]" style='display:none'>
                                                                        @component('componentes.input', ['label' => 'Digite o nome do curso'])
                                                                            <input id="outrocurso[{{$i}}]" type="text" class="form-control" name="outrocurso[{{$i}}]" value="{{ old('outrocurso')[$i] ?? "" }}" placeholder="Digite o nome do curso" autocomplete="curso" autofocus>
                                                                            @error('outrocurso.'.$i)
                                                                            <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                                                            @enderror
                                                                        @endcomponent
                                                                    </div>
                                                                    <div class="col-6">
                                                                        @component('componentes.select', ['label' => 'Turno'])
                                                                            <select  name="turno[{{$i}}]"  class="form-control" >
                                                                                <option value=""  selected>-- Selecione uma opção --</option>
                                                                                @foreach ($enum_turno as $key => $value)
                                                                                    <option @if(old('turno')[$i] ?? "" == $value ) selected @endif value="{{ $value }}">{{ $value }}</option>
                                                                                @endforeach
                                                                            </select>
                                                                            @error('turno.'.$i)
                                                                            <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
                                  <strong>{{ $message }}</strong>
                                </span>
                                                                            @enderror
                                                                        @endcomponent
                                                                    </div>
                                                                    @php
                                                                        $options = array('3' => 3, '4' => 4, '5' => 5, '6' => 6, '7' => 7,'8' => 8,'9' => 9,'10' => 10,'11' => 11,'12' => 12);
                                                                    @endphp
                                                                    <div class="col-6">
                                                                        @component('componentes.select', ['label' => 'Total de períodos/anos do curso'])
                                                                            <select  name="total_periodos[{{$i}}]"   class="form-control" onchange="gerarPeriodo(this)" >
                                                                                <option value=""  selected>-- Selecione uma opção --</option>
                                                                                @foreach ($options as $key => $value)
                                                                                    <option @if(old('total_periodos')[$i]  ?? "" == $key ) selected @endif value="{{ $key }}">{{ $value }}</option>
                                                                                @endforeach
                                                                            </select>
                                                                            @error('total_periodos.'.$i)
                                                                            <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
                                  <strong>{{ $message }}</strong>
                                </span>
                                                                            @enderror
                                                                        @endcomponent
                                                                    </div>
                                                                    <div class="col-6">
                                                                        @component('componentes.select', ['label' => 'Período/Ano atual'])
                                                                            <select name="periodo_atual[]"  class="form-control"  >
                                                                                <option value=""  selected>-- Selecione uma opção --</option>

                                                                            </select>
                                                                            @error('periodo_atual.'.$i)
                                                                            <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
                                  <strong>{{ $message }}</strong>
                                </span>
                                                                            @enderror
                                                                        @endcomponent
                                                                    </div>
                                                                    <div class="col-6">
                                                                        @component('componentes.select', ['label' => 'Ordem de prioridade'])
                                                                            <select name="ordem_prioridade[]"  class="form-control" >
                                                                                <option value=""  selected>-- ORDEM --</option>
                                                                                @for($j = 1; $j <= $edital->numParticipantes; $j++)
                                                                                    <option @if(old('total_periodos')[$i]  ?? "" == $j ) selected @endif value="{{ $j }}">{{ $j }}</option>
                                                                                @endfor

                                                                            </select>
                                                                            @error('ordem_prioridade.'.$i)
                                                                            <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
                                  <strong>{{ $message }}</strong>
                                </span>
                                                                            @enderror
                                                                        @endcomponent
                                                                    </div>
                                                                    @if($edital->tipo != "PIBEX")

                                                                        <div class="col-6">
                                                                            @component('componentes.input', ['label' => 'Coeficiente de rendimento (média geral)'])
                                                                                <input type="number" class="form-control media" value="{{old('media_do_curso')[$i] ?? "" }}" name="media_do_curso[{{$i}}]"  min="0" max="10" step="0.01"  >
                                                                                @error('media_do_curso.'.$i)
                                                                                <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
                                        <strong>{{ $message }}</strong>
                                      </span>
                                                                                @enderror
                                                                            @endcomponent
                                                                        </div>
                                                                    @endif
                                                                    <div class="col-md-12"><h5>Plano de trabalho</h5></div>
                                                                    <div class="col-12">
                                                                        @component('componentes.input', ['label' => 'Título'])
                                                                            <input type="text" class="form-control" value="{{old('nomePlanoTrabalho')[$i] ?? "" }}" name="nomePlanoTrabalho[{{$i}}]"  placeholder="Digite o título do plano de trabalho" maxlength="255" id="nomePlanoTrabalho{{$i}}">
                                                                            <span style="color: red; font-size: 12px" id="caracsRestantesnomePlanoTrabalho{{$i}}">
                                  </span>
                                                                            @error('nomePlanoTrabalho.'.$i)
                                                                            <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
                                      <strong>{{ $message }}</strong>
                                    </span>
                                                                            @enderror
                                                                        @endcomponent
                                                                    </div>
                                                                    <div class="col-12">
                                                                        @component('componentes.input', ['label' => 'Anexo (.pdf)'])
                                                                            <input type="file" class="input-group-text" value="{{old('anexoPlanoTrabalho')[$i] ?? "" }}" name="anexoPlanoTrabalho[{{$i}}]"  accept=".pdf" placeholder="Anexo do Plano de Trabalho" />
                                                                            @error('anexoPlanoTrabalho.'.$i)
                                                                            <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
                                      <strong>{{ $message }}</strong>
                                    </span>
                                                                            @enderror
                                                                            @error('anexoPlanoTrabalho')
                                                                            <span class="invalid-feedback" role="alert" style="overflow: visible; display:block">
                                      <strong>{{ $message }}</strong>
                                    </span>
                                                                            @enderror
                                                                        @endcomponent
                                                                    </div>

                                                                    <div class="col-6">
                                                                        <button data-dismiss="modal" type="button" id="cancelar{{$i}}" class=" btn btn-danger" style="font-size: 16px" onclick="desmarcar({{$i}})" @if(isset(old('marcado')[$i+1])) disabled @endif>Cancelar</button>
                                                                    </div>
                                                                    <div class="col-6">
                                                                        <button data-dismiss="modal" type="button" id="guardar{{$i}}" class="btn btn-success float-right" style="font-size: 16px" onclick="marcar({{$i}})">Salvar</button>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>



                                                    </div>
                                                </div>
                                            </div>
                                        </div>


                                    @endfor

                                </div>
                            </div>

                        </li>

                    </ol>

                </div>
            </div>
        </div>
    </div>
</div>
<script>


</script>
  <!-- Adicionando Javascript -->
  <script>
    
    function limpa_formulário_cep(id) {
            //Limpa valores do formulário de cep.
            document.getElementById(`rua${id}`).value=("");
            document.getElementById(`bairro${id}`).value=("");
            document.getElementById(`cidade${id}`).value=("");
            document.getElementById(`uf${id}`).value=("");
            //document.getElementById('ibge').value=("");
    }
    
    let cont = 0; //Esse cont representa a adição de cada aluno
    function meu_callback(conteudo) {
        if (!("erro" in conteudo)) {
            //Atualiza os campos com os valores.
            document.getElementById(`rua${cont}`).value=(conteudo.logradouro);
            document.getElementById(`bairro${cont}`).value=(conteudo.bairro);
            document.getElementById(`cidade${cont}`).value=(conteudo.localidade);
            document.getElementById(`uf${cont}`).value=(conteudo.uf);
            
            
            //document.getElementById('ibge').value=(conteudo.ibge);
        } //end if.
        else {
            //CEP não Encontrado.
            limpa_formulário_cep(cont);
            alert("CEP não encontrado.");
        }
    }

    function pesquisacep(valor, id) {
        //Nova variável "cep" somente com dígitos.
        var cep = valor.replace(/\D/g, '');
        
        //Verifica se campo cep possui valor informado.
        if (cep != "") {

            //Expressão regular para validar o CEP.
            var validacep = /^[0-9]{8}$/;

            //Valida o formato do CEP.
            if(validacep.test(cep)) {

                //Preenche os campos com "..." enquanto consulta webservice.
                document.getElementById(`rua${id}`).value="...";
                document.getElementById(`bairro${id}`).value="...";
                document.getElementById(`cidade${id}`).value="...";
                document.getElementById(`uf${id}`).value="...";
                //document.getElementById('ibge').value="...";

                //Cria um elemento javascript.
                var script = document.createElement('script');

                //Sincroniza com o callback.
                cont = id
                script.src = 'https://viacep.com.br/ws/'+ cep + '/json/?callback=meu_callback';

                //Insere script no documento e carrega o conteúdo.
                document.body.appendChild(script);

            } //end if.
            else {
                //cep é inválido.
                limpa_formulário_cep(id);
                alert("Formato de CEP inválido.");
            }
        } //end if.
        else {
            //cep sem valor, limpa formulário.
            limpa_formulário_cep(id);
        }
    };

</script>