PageSourceSearch

https://incentivoesporte.com.br/src/Evento/Controller/Evento.controller.js?v=1.20.047

js incentivoesporte.com.br collected 2026-10-04 02:35:18 UTC 40,954 bytes, 986 lines download raw bytes

1var app = angular.module("RecebeDigitalSiteApp");
2app.controller(
3    "Evento.Controller",
4    function (
5        $scope,
6        $rootScope,
7        $location,
8        config,
9        $anchorScroll,
10        $sce,
11        $routeParams,
12        EventosAPIService,
13        CidadesAPIService,
14        ModalidadesAPIService,
15        growl,
16        OrganizadoresAPIService,
17    ) {
18        $scope.nEvento = {};
19        $scope.aEvento = {};
20        $scope.aInscritos = [];
21        $scope.aInscricoesSorteio = [];
22        $scope.faleOrganizador = {};
23        $scope.eve_tab = "sobre";
24
25        $scope.isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
26
27        $scope.curPageInsc = 0;
28        $scope.cPgInsc = 0;
29        $scope.numPerPageInsc = 50;
30        $scope.nPgTotalInsc = 0;
31
32        $scope.curPageSorteio = 0;
33        $scope.cPgSorteio = 0;
34        $scope.numPerPageSorteio = 50;
35        $scope.nPgTotalSorteio = 0;
36
37        $scope.markerUrlValue =
38            $scope.publicBasePatch + "/Images/map-marker-ie.png";
39        $scope.markers = [];
40
41        $scope.$on("$viewContentLoaded", function () {
42            console.log("event viewContentLoaded");
43            $scope.url = $location.path();
44            if ($routeParams.eventotoken) {
45                $scope.getEventoDetalhe($routeParams.eventotoken);
46            }
47        });
48
49        $scope.getEventoDetalhe = function (eventoToken) {
50            $("#div-loading").removeClass("d-none");
51            $("#no-results").addClass("d-none");
52
53            $scope.aEvento = {};
54
55            EventosAPIService.getEventosPorToken(eventoToken)
56                .then(function (response) {
57                    $scope.aEvento = response.data;
58                    if ($scope.aEvento == "false") {
59                        $scope.aEvento = null;
60                        $("#no-results").removeClass("d-none");
61                        $("#no-results-text").html(
62                            "😓 Evento não encontrado.",
63                        );
64                    } else {
65                        setDadosEvento(eventoToken);
66                    }
67
68                    $("#div-loading").addClass("d-none");
69                })
70                .catch(function (response) {
71                    $("#no-results").removeClass("d-none");
72                    $("#no-results-text").html(
73                        "😱 Desculpe, mas tivemos uma falha ao buscar os Eventos: " +
74                            (response.status ? response.status + " - " : "") +
75                            (response.statusText
76                                ? response.statusText
77                                : response.TypeError),
78                    );
79                    $("#div-loading").addClass("d-none");
80                });
81        };
82
83        const setDadosEvento = (eventoToken) => {
84            if (!$scope.aEvento.eve_id) {
85                return false;
86            }
87
88            if ($scope.aEvento.eve_corfonte) {
89                let cCorFundo =
90                    $scope.aEvento.eve_corfonte.toUpperCase() == "#FFFFFF"
91                        ? $scope.aEvento.eve_corfonte
92                        : $scope.aEvento.eve_corfundo;
93                $scope.aEvento.eve_corfonte =
94                    $scope.aEvento.eve_corfonte.toUpperCase() == "#FFFFFF"
95                        ? $scope.aEvento.eve_corfundo
96                        : $scope.aEvento.eve_corfonte;
97                $scope.aEvento.eve_corfundo = cCorFundo;
98            }
99
100            if ($scope.aEvento.eve_tag_google_head) {
101                $scope.setupGoogleAnalytics(
102                    $scope.aEvento.eve_tag_google_head,
103                    "HEAD",
104                );
105            }
106
107            if ($scope.aEvento.eve_tag_google_body) {
108                $scope.setupGoogleAnalytics(
109                    $scope.aEvento.eve_tag_google_body,
110                    "BODY",
111                );
112            }
113
114            if ($scope.aEvento.eve_visita_contador) {
115                $scope.aEvento.contadorVisitas = JSON.parse(
116                    $scope.aEvento.eve_visita_contador,
117                );
118            }
119
120            document.title = $scope.aEvento.eve_nome;
121
122            $scope.nLoteEvento = $scope.getLoteEvento();
123        };
124
125        $scope.setvideoSource = function (cVideoURL) {
126            if (cVideoURL) {
127                let cURLYT = "https://www.youtube.com/embed/";
128                let aVideoURL = cVideoURL.split("v=");
129                return $sce.trustAsResourceUrl(cURLYT + aVideoURL[1]);
130            }
131        };
132
133        $scope.setMapaLocalEvento = function () {
134            if (
135                $scope.aEvento.eve_end_latitude &&
136                $scope.aEvento.eve_end_longitude
137            ) {
138                const cNomeLocal =
139                    "<strong>" +
140                    $scope.aEvento.eve_end_nome_local +
141                    "</strong><br/>" +
142                    $scope.aEvento.eve_end_endereco +
143                    ", " +
144                    $scope.aEvento.eve_end_num +
145                    "<br/>" +
146                    $scope.aEvento.cid_descricao +
147                    "/" +
148                    $scope.aEvento.eve_end_uf;
149
150                $scope.lat = $scope.aEvento.eve_end_latitude;
151                $scope.lng = $scope.aEvento.eve_end_longitude;
152
153                setTimeout(() => {
154                    var map = L.map("map").setView(
155                        [$scope.lat, $scope.lng],
156                        15,
157                    );
158
159                    L.tileLayer(
160                        "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
161                        {
162                            attribution: "&copy; OpenStreetMap contributors",
163                        },
164                    ).addTo(map);
165
166                    L.marker([$scope.lat, $scope.lng])
167                        .addTo(map)
168                        .bindPopup(cNomeLocal)
169                        .openPopup();
170                }, 1500);
171            }
172        };
173
174        $scope.changeAba = function (nomeAba) {
175            $scope.eve_tab = nomeAba;
176            if (nomeAba == "inscritos") {
177                $scope.getEventoInscritos($scope.aEvento.eve_token);
178            }
179            if (nomeAba == "sorteio") {
180                if ($scope.aEvento.eve_sorteio == "F") {
181                    $scope.getSorteioTodasEvento($scope.aEvento.eve_token);
182                    return true;
183                }
184                let sorteioInscricoes =
185                    window.localStorage.getItem("sorteioInscricao");
186                if (sorteioInscricoes) {
187                    sorteioInscricoes = jQuery.parseJSON(sorteioInscricoes);
188                    const dAgora = new Date();
189                    const dExpires = new Date(sorteioInscricoes.expires);
190                    if (dAgora < dExpires) {
191                        $scope.aInscricoesSorteio = sorteioInscricoes.meta;
192                    } else {
193                        window.localStorage.removeItem("sorteioInscricao");
194                    }
195                }
196            }
197            if (nomeAba == "local") {
198                $scope.setMapaLocalEvento();
199            }
200        };
201
202        $scope.getUltimoSorteioEvento = function (eventoToken) {
203            $("#div-loading-sorteio").removeClass("d-none");
204            $("#no-results-sorteio").addClass("d-none");
205
206            const ultimoSorteio = $scope.aInscricoesSorteio.length
207                ? $scope.aInscricoesSorteio.length
208                : 0;
209
210            EventosAPIService.getUltimoSorteioEvento(eventoToken, ultimoSorteio)
211                .then(function (response) {
212                    if (response.data.insc_num) {
213                        $scope.aInscricoesSorteio.push(response.data);
214
215                        $scope.cInscNumSorteada = {
216                            numero: response.data.insc_num,
217                            atleta: response.data.att_nome,
218                            data_hora: response.data.insc_data_sorteio_comp,
219                        };
220                        window.localStorage.setItem(
221                            "sorteioInscricao",
222                            JSON.stringify({
223                                meta: $scope.aInscricoesSorteio,
224                                expires: new Date().setHours(
225                                    new Date().getHours() + 3,
226                                ),
227                            }),
228                        );
229                    } else {
230                        $scope.aEvento.eve_sorteio = "F";
231                        $("#div-loading-sorteio").addClass("d-none");
232                    }
233                })
234                .catch(function (response) {
235                    $("#no-results-sorteio").removeClass("d-none");
236                    $("#no-results-sorteio-text").html(
237                        "&#128561; Desculpe, mas tivemos uma falha ao buscar os Eventos: " +
238                            (response.status ? response.status + " - " : "") +
239                            (response.statusText
240                                ? response.statusText
241                                : response.TypeError),
242                    );
243                    $("#div-loading-sorteio").addClass("d-none");
244                });
245        };
246
247        $scope.getSorteioTodasEvento = function (eventoToken) {
248            $("#div-loading-sorteio").removeClass("d-none");
249            $("#no-results-sorteio").addClass("d-none");
250
251            EventosAPIService.getSorteioTodasEvento(eventoToken)
252                .then(function (response) {
253                    if (response.data.length) {
254                        $scope.aInscricoesSorteio = response.data;
255                        $scope.cInscNumSorteada = {};
256
257                        $scope.cPgSorteio = 1;
258                        $scope.currentPageSorteio = 0;
259                        $scope.nPgTotalSorteio =
260                            $scope.aInscricoesSorteio.length >
261                            $scope.numPerPageSorteio
262                                ? Math.ceil(
263                                      $scope.aInscricoesSorteio.length /
264                                          $scope.numPerPageSorteio,
265                                  ).toFixed(0)
266                                : 1;
267                    } else {
268                        $("#div-loading-sorteio").addClass("d-none");
269                    }
270                })
271                .catch(function (response) {
272                    $("#no-results-sorteio").removeClass("d-none");
273                    $("#no-results-sorteio-text").html(
274                        "&#128561; Desculpe, mas tivemos uma falha ao buscar os Eventos: " +
275                            (response.status ? response.status + " - " : "") +
276                            (response.statusText
277                                ? response.statusText
278                                : response.TypeError),
279                    );
280                    $("#div-loading-sorteio").addClass("d-none");
281                });
282        };
283
284        $scope.rePageSorteio = function () {
285            $scope.cPgSorteio = 1;
286            $scope.currentPageSorteio = 0;
287        };
288
289        $scope.changePageSorteio = function (nIdx) {
290            $scope.cPgSorteio = nIdx;
291            $scope.currentPageSorteio = nIdx - 1;
292        };
293
294        $scope.getEventoInscritos = function (eventoToken) {
295            $("#div-loading-insc").removeClass("d-none");
296            $("#no-results-insc").addClass("d-none");
297
298            $scope.aEvento.inscritos = [];
299            EventosAPIService.getInscritosEvento(eventoToken)
300                .then(function (response) {
301                    $scope.aEvento.inscritos = response.data;
302                    if (!$scope.aEvento.inscritos) {
303                        $("#no-results-insc").removeClass("d-none");
304                    } else if ($scope.aEvento.inscritos) {
305                        if ($scope.aEvento.inscritos.length > 1) {
306                            $scope.aInscritos = $scope.aEvento.inscritos.reduce(
307                                (acc, item) => {
308                                    const athleteId = `${item.insc_id}`;
309                                    if (acc[athleteId]) {
310                                        acc[athleteId].push(item);
311                                        return acc;
312                                    }
313                                    acc[athleteId] = [];
314                                    acc[athleteId].push(item);
315                                    return acc;
316                                },
317                                {},
318                            );
319                        } else {
320                            $scope.aInscritos[
321                                $scope.aEvento.inscritos[0].insc_id
322                            ] = [$scope.aEvento.inscritos[0]];
323                        }
324                        $scope.aEvento.inscritos =
325                            $scope.aEvento.inscritos.filter(
326                                (eve, index, array) =>
327                                    array.findIndex(
328                                        (t) =>
328 t.insc_id == eve.insc_id,
329                                    ) == index,
330                            );
331
332                        $scope.cPgInsc = 1;
333                        $scope.currentPageInsc = 0;
334                        $scope.nPgTotalInsc =
335                            $scope.aEvento.inscritos.length >
336                            $scope.numPerPageInsc
337                                ? Math.ceil(
338                                      $scope.aEvento.inscritos.length /
339                                          $scope.numPerPageInsc,
340                                  ).toFixed(0)
341                                : 1;
342                    }
343
344                    $("#div-loading-insc").addClass("d-none");
345                })
346                .catch(function (response) {
347                    $("#no-results-insc").removeClass("d-none");
348                    $("#no-results-insc-text").html(
349                        "&#128561; Desculpe, mas tivemos uma falha ao buscar os Eventos: " +
350                            (response.status ? response.status + " - " : "") +
351                            (response.statusText
352                                ? response.statusText
353                                : response.TypeError),
354                    );
355                    $("#div-loading-insc").addClass("d-none");
356                });
357        };
358
359        $scope.rePage = function () {
360            $scope.cPgInsc = 1;
361            $scope.currentPageInsc = 0;
362        };
363
364        $scope.changePage = function (nIdx) {
365            $scope.cPgInsc = nIdx;
366            $scope.currentPageInsc = nIdx - 1;
367        };
368
369        $scope.ordenarInscricao = function (sCampo) {
370            $scope.criterioOrdenacao = sCampo;
371            $scope.direcaoOrdenacao = !$scope.direcaoOrdenacao;
372        };
373
374        $scope.getLoteEvento = function () {
375            if ($scope.aEvento) {
376                let cDataInsc = new Date();
377                let nLote = 0;
378                //Verifica primeiro lote
379                let cDataLoteDe = new Date(
380                    $scope.aEvento.eve_lote1_de + " 00:00:00",
381                );
382                let cDataLoteAte = new Date(
383                    $scope.aEvento.eve_lote1_ate + " 23:59:59",
384                );
385                if (cDataInsc >= cDataLoteDe && cDataInsc <= cDataLoteAte) {
386                    nLote = 1;
387                } else {
388                    cDataLoteDe = new Date(
389                        $scope.aEvento.eve_lote2_de + " 00:00:00",
390                    );
391                    cDataLoteAte = new Date(
392                        $scope.aEvento.eve_lote2_ate + " 23:59:59",
393                    );
394                    if (cDataInsc >= cDataLoteDe && cDataInsc <= cDataLoteAte) {
395                        nLote = 2;
396                    } else {
397                        cDataLoteDe = new Date(
398                            $scope.aEvento.eve_lote3_de + " 00:00:00",
399                        );
400                        cDataLoteAte = new Date(
401                            $scope.aEvento.eve_lote3_ate + " 23:59:59",
402                        );
403                        if (
404                            cDataInsc >= cDataLoteDe &&
405                            cDataInsc <= cDataLoteAte
406                        ) {
407                            nLote = 3;
408                        } else {
409                            cDataLoteDe = new Date(
410                                $scope.aEvento.eve_lote4_de + " 00:00:00",
411                            );
412                            cDataLoteAte = new Date(
413                                $scope.aEvento.eve_lote4_ate + " 23:59:59",
414                            );
415                            if (
416                                cDataInsc >= cDataLoteDe &&
417                                cDataInsc <= cDataLoteAte
418                            ) {
419                                nLote = 4;
420                            } else {
421                                cDataLoteDe = new Date(
422                                    $scope.aEvento.eve_lote5_de + " 00:00:00",
423                                );
424                                cDataLoteAte = new Date(
425                                    $scope.aEvento.eve_lote5_ate + " 23:59:59",
426                                );
427                                if (
428                                    cDataInsc >= cDataLoteDe &&
429                                    cDataInsc <= cDataLoteAte
430                                ) {
431                                    nLote = 5;
432                                }
433                            }
434                        }
435                    }
436                }
437                return nLote;
438            }
439        };
440
441        $scope.enviaFaleConoscoOrganizador = function (faleOrganiz) {
442            $("#div-loading-email").removeClass("d-none");
443            faleOrganiz.evento = $scope.aEvento.eve_id;
444            EventosAPIService.enviaFaleConoscoOrganizador(faleOrganiz)
445                .then(function (response) {
446                    if (response.data.return) {
447                        $scope.alerta("success", response.data.msg);
448                        $scope.faleOrganizador = {};
449                        if ($scope.frmFaleOrganizador) {
450                            $scope.frmFaleOrganizador.$setPristine();
451                            $scope.frmFaleOrganizador.$setUntouched(); // Recomendo adicionar este também
452                        }
453                    } else {
454                        $scope.alerta("error", response.data.msg);
455                    }
456                    $("#div-loading-email").addClass("d-none");
457                })
458                .catch(function (response) {
459                    $("#div-loading-email").addClass("d-none");
460                    $scope.alerta(
461                        "error",
462                        "Falha ao tentar enviar seu e-mail para o organizador desse evento. Erro: " +
463                            (response.status ? response.status + " - " : "") +
464                            (response.statusText
465                                ? response.statusText
466                                : response.TypeError),
467                    );
468                });
469        };
470
471        const cadastroOrganizador = async function (organizador) {
472            organizador.AcaoDoControlador = "novo";
473            organizador.org_benef_pessoa = organizador.org_pessoa;
474            organizador.integracao = "orcamento_evento";
475
476            return OrganizadoresAPIService.salvaOrganizadores(organizador)
477                .then(function (response) {
478                    if (!response.data.return) {
479                        $scope.alerta("error", response.data.msg);
480                    }
481                    return response;
482                })
483                .catch(function (response) {
484                    $scope.alerta(
485                        "error",
486                        "Falha ao salvar os dados do organizador: " +
487                            (response.status ? response.status + " - " : "") +
488                            (response.statusText
489                                ? response.statusText
490                                : response),
491                    );
492                    return false;
493                });
494        };
495
496        $scope.novoEvento = async function (evento, nOrganizador) {
497            if (
498                !evento.eve_cadastro &&
499                !evento.eve_cronometragem &&
500                !evento.eve_inscricoes
501            ) {
502                $scope.alerta(
503                    "error",
504                    "Por favor, selecione pelo menos um Serviço Contratado!",
505                );
506                $anchorScroll(0, 0);
507
508                return false;
509            }
510
511            $("#submit-form-novo-evento-button").addClass("d-none");
512            $("#div-loading").removeClass("d-none");
513            evento.AcaoDoControlador = "novo";
514
515            if (!evento.eve_org_id && $scope.isOrgCNPJObrigatorio()) {
516                const organizadorResponse =
517                    await cadastroOrganizador(nOrganizador);
518                if (!organizadorResponse || !organizadorResponse.data.return) {
519                    $("#div-loading").addClass("d-none");
520                    $("#submit-form-novo-evento-button").removeClass("d-none");
521                    return;
522                }
523                evento.eve_org_id = organizadorResponse.data.id;
524            }
525
526            EventosAPIService.salvaEventos(evento)
527                .then(function (response) {
528                    $("#div-loading").addClass("d-none");
529                    $("#submit-form-novo-evento-button").removeClass("d-none");
530
531                    if (response.data.return) {
532                        $scope.alerta("success", response.data.msg);
533                        $scope.nEvento = {};
534                        $scope.nOrganizador = {};
535                        $scope.formNovoCad.$setPristine();
536                    } else {
537                        $scope.alerta("error", response.data.msg);
538                    }
539                })
540                .catch(function (response) {
541                    $scope.alerta(
542                        "error",
543                        "Falha ao salvar os dados do evento: " +
544                            (response.status ? response.status + " - " : "") +
545                            (response.statusText
546                                ? response.statusText
547                                : response),
548                    );
549                    $("#div-loading").addClass("d-none");
550                    $("#submit-form-novo-evento-button").removeClass("d-none");
551                });
552        };
553
554        $scope.isOrgCNPJObrigatorio = function () {
555            if (
556                $scope.nEvento.eve_cadastro ||
557                $scope.nEvento.eve_inscricoes ||
558                $scope.nEvento.eve_cronometragem
559            ) {
560                return true;
561            }
562            return false;
563        };
564
565        //Controle dos lotes para cadastro do evento
566        $scope.ajustarDatasLotes = () => {
567            if (
568                $scope.nEvento.eve_data_insc_ini &&
569                $scope.nEvento.eve_data_insc_fim
570            ) {
571                const inicioInscricao = moment(
572                    $scope.nEvento.eve_data_insc_ini,
573                    "DD/MM/YYYY",
574                );
575                const fimInscricoes = moment(
576                    $scope.nEvento.eve_data_insc_fim,
577                    "DD/MM/YYYY",
578                );
579
580                // Reset all batches
581                $scope.nEvento.eve_lote1_de =
582                    inicioInscricao.format("DD/MM/YYYY");
583                $scope.nEvento.eve_lote1_ate = $scope.nEvento.eve_lote2_de
584                    ? moment($scope.nEvento.eve_lote2_de, "DD/MM/YYYY")
585                          .subtract(1, "days")
586                          .format("DD/MM/YYYY")
587                    : fimInscricoes.format("DD/MM/YYYY");
588                $("#nov_eve_lote1_de").datepicker(
589                    "setDate",
590                    $scope.nEvento.eve_lote1_de,
591                );
592                $("#nov_eve_lote1_ate").datepicker(
593                    "setDate",
594                    $scope.nEvento.eve_lote1_ate,
595                );
596
597                $scope.nEvento.eve_lote2_ate =
598                    $scope.nEvento.eve_lote1_ate && $scope.nEvento.eve_lote3_de
599                        ? moment($scope.nEvento.eve_lote3_de, "DD/MM/YYYY")
600                              .subtract(1, "days")
601                              .format("DD/MM/YYYY")
602                        : $scope.nEvento.eve_lote2_de
603                          ? fimInscricoes.format("DD/MM/YYYY")
604                          : null;
605                if ($scope.nEvento.eve_lote2_ate) {
606                    $("#nov_eve_lote2_ate").datepicker(
607                        "setDate",
608                        $scope.nEvento.eve_lote2_ate,
609                    );
610                }
611
612                $scope.nEvento.eve_lote3_ate =
613                    $scope.nEvento.eve_lote2_ate && $scope.nEvento.eve_lote4_de
614                        ? moment($scope.nEvento.eve_lote4_de, "DD/MM/YYYY")
615                              .subtract(1, "days")
616                              .format("DD/MM/YYYY")
617                        : $scope.nEvento.eve_lote3_de
618                          ? fimInscricoes.format("DD/MM/YYYY")
619                          : null;
620                if ($scope.nEvento.eve_lote3_ate) {
621                    $("#nov_eve_lote3_ate").datepicker(
622                        "setDate",
623                        $scope.nEvento.eve_lote3_ate,
624                    );
625                }
626
627                $scope.nEvento.eve_lote4_ate =
628                    $scope.nEvento.eve_lote3_ate && $scope.nEvento.eve_lote5_de
629                        ? moment($scope.nEvento.eve_lote5_de, "DD/MM/YYYY")
630                              .subtract(1, "days")
631                              .format("DD/MM/YYYY")
632                        : $scope.nEvento.eve_lote4_de
633                          ? fimInscricoes.format("DD/MM/YYYY")
634                          : null;
635                if ($scope.nEvento.eve_lote4_ate) {
636                    $("#nov_eve_lote4_ate").datepicker(
637                        "setDate",
638                        $scope.nEvento.eve_lote4_ate,
639                    );
640                }
641
642                $scope.nEvento.eve_lote5_ate =
643                    $scope.nEvento.eve_lote4_ate && $scope.nEvento.eve_lote5_de
644                        ? fimInscricoes.format("DD/MM/YYYY")
645                        : null;
646                if ($scope.nEvento.eve_lote5_ate) {
647                    $("#nov_eve_lote4_ate").datepicker(
648                        "setDate",
649                        $scope.nEvento.eve_lote4_ate,
650                    );
651                }
652            }
653            $scope.validarDatasLotes();
654        };
655
656        $scope.validarDatasLotes = () => {
657            const lotesValidado = {
658                valid: true,
659                message: "Todas as datas dos lotes estão válidas.",
660            };
661            const lotes = [
662                {
663                    inicio: $scope.nEvento.eve_lote1_de,
664                    fim: $scope.nEvento.eve_lote1_ate,
665                },
666                {
667                    inicio: $scope.nEvento.eve_lote2_de,
668                    fim: $scope.nEvento.eve_lote2_ate,
669                },
670                {
671                    inicio: $scope.nEvento.eve_lote3_de,
672                    fim: $scope.nEvento.eve_lote3_ate,
673                },
674                {
675                    inicio: $scope.nEvento.eve_lote4_de,
676                    fim: $scope.nEvento.eve_lote4_ate,
677                },
678                {
679                    inicio: $scope.nEvento.eve_lote5_de,
680                    fim: $scope.nEvento.eve_lote5_ate,
681                },
682            ];
683            const inicioInscricoes = moment(
684                $scope.nEvento.eve_data_insc_ini,
685                "DD/MM/YYYY",
686            );
687            const fimInscricoes = moment(
688                $scope.nEvento.eve_data_insc_fim,
689                "DD/MM/YYYY",
690            );
691
692            for (let i = 0; i < lotes.length; i++) {
693                const loteAtual = lotes[i];
694                if (loteAtual.inicio && loteAtual.fim) {
695                    const dataInicio = moment(loteAtual.inicio, "DD/MM/YYYY");
696                    const dataFim = moment(loteAtual.fim, "DD/MM/YYYY");
697
698                    if (
699                        dataInicio.isBefore(inicioInscricoes) ||
700                        dataFim.isBefore(inicioInscricoes)
701                    ) {
702                        lotesValidado.valid = false;
703                        lotesValidado.message = `Erro no lote ${
704                            i + 1
705                        }: A data de término/início não pode ser anterior à data de início das inscrições.`;
706                        $scope.validacaoLotes = lotesValidado;
707                        return false;
708                    }
709
710                    if (
711                        dataInicio.isAfter(fimInscricoes) ||
712                        dataFim.isAfter(fimInscricoes)
713                    ) {
714                        lotesValidado.valid = false;
715                        lotesValidado.message = `Erro no lote ${
716                            i + 1
717                        }: A data de término/início não pode ser posterior à data de término das inscrições.`;
718                        $scope.validacaoLotes = lotesValidado;
719                        return false;
720                    }
721
722                    if (dataInicio.isAfter(dataFim)) {
723                        lotesValidado.valid = false;
724                        lotesValidado.message = `Erro no lote ${
725                            i + 1
726                        }: A data de início não pode ser posterior à data de término.`;
727                        $scope.validacaoLotes = lotesValidado;
728                        return false;
729                    }
730
731                    if (dataInicio.isSame(dataFim)) {
732                        lotesValidado.valid = false;
733                        lotesValidado.message = `Erro no lote ${
734                            i + 1
735                        }: A data de início não pode ser igual à data de término.`;
736                        $scope.validacaoLotes = lotesValidado;
737                        return false;
738                    }
739
740                    if (i > 0) {
741                        const fimLoteAnterior = moment(
742                            lotes[i - 1].fim,
743                            "DD/MM/YYYY",
744                        );
745                        if (dataInicio.isBefore(fimLoteAnterior)) {
746                            lotesValidado.valid = false;
747                            lotesValidado.message = `Erro no lote ${
748                                i + 1
749                            }: A data de início não pode ser anterior à data de término do lote ${i}.`;
750                            $scope.validacaoLotes = lotesValidado;
751                            return false;
752                        }
753                    }
754                }
755            }
756            $scope.validacaoLotes = lotesValidado;
757        };
758
759        $scope.addLote = (lote) => {
760            const loteAnterior = lote - 1;
761            if (
762                $scope.nEvento["eve_lote" + loteAnterior + "_de"] &&
763                $scope.nEvento["eve_lote" + loteAnterior + "_ate"]
764            ) {
765                const loteInicio = moment(
766                    $scope.nEvento["eve_lote" + loteAnterior + "_de"],
767                    "DD/MM/YYYY",
768                );
769                const loteFim = moment(
770                    $scope.nEvento["eve_lote" + loteAnterior + "_ate"],
771                    "DD/MM/YYYY",
772                );
773
774                const fimInscricoes = moment(
775                    $scope.nEvento.eve_data_insc_fim,
776                    "DD/MM/YYYY",
777                );
778
779                $scope.nEvento["eve_lote" + lote + "_de"] = loteFim
780                    .add(1, "days")
781                    .format("DD/MM/YYYY");
782                $scope.nEvento["eve_lote" + lote + "_ate"] =
783                    fimInscricoes.format("DD/MM/YYYY");
784                $("#nov_eve_lote" + lote + "_de").datepicker(
785                    "setDate",
786                    $scope.nEvento["eve_lote" + lote + "_de"],
787                );
788                $("#nov_eve_lote" + lote + "_ate").datepicker(
789                    "setDate",
790                    $scope.nEvento["eve_lote" + lote + "_ate"],
791                );
792            }
793        };
794
795        $scope.deleteLote = (lote) => {
796            delete $scope.nEvento["eve_lote" + lote + "_de"];
797            delete $scope.nEvento["eve_lote" + lote + "_ate"];
798            const loteAnterior = lote - 1;
799            if (
800                $scope.nEvento["eve_lote" + loteAnterior + "_de"] &&
801                $scope.nEvento["eve_lote" + loteAnterior + "_ate"] &&
802                lote > 1
803            ) {
804                const fimInscricoes = moment(
805                    $scope.nEvento.eve_data_insc_fim,
806                    "DD/MM/YYYY",
807                );
808
809                $scope.nEvento["eve_lote" + loteAnterior + "_ate"] =
810                    fimInscricoes.format("DD/MM/YYYY");
811                $("#nov_eve_lote" + loteAnterior + "_ate").datepicker(
812                    "setDate",
813                    $scope.nEvento["eve_lote" + loteAnterior + "_ate"],
814                );
815            }
816        };
817
818        $scope.loadCidades = function () {
819            delete $scope.aCidades;
820            CidadesAPIService.loadCidades("")
821                .then(function (response) {
822                    $scope.aCidades = response.data;
823                })
824                .catch(function (response) {
825                    $scope.alerta(
826                        "error",
827                        "Falha ao carregar os Cidadess: " +
828                            (response.status ? response.status + " - " : "") +
829                            (response.statusText
830                                ? response.statusText
831                                : response.TypeError),
832                    );
833                });
834        };
835
836        $scope.cfgCidades = {
837            create: false,
838            valueField: "cid_id",
839            searchField: ["cid_id", "cid_descricao", "cid_uf"],
840            delimiter: config.SelDelimiter,
841            placeholder: "Selecione uma Cidade",
842            maxItems: 1,
843            onInitialize: function (selectize) {
844                $scope.loadCidades();
845            },
846            onChange: function (selectize) {
847                var aCidadeFK = $scope.aCidades.filter((cidade) => {
848                    if (cidade.cid_id == selectize) return cidade;
849                });
850                if (aCidadeFK[0]) {
851                    $scope.nEvento.eve_end_uf = aCidadeFK[0].cid_uf;
852                    $scope.$apply();
853                }
854            },
855            render: {
856                option: function (item, escape) {
857                    return (
858                        '<table class="table" style="margin-bottom: 0px !important;">' +
859                        "<tr>" +
860                        '<td class="text-nowrap left-justify" width="80%">' +
861                        (item.cid_descricao ? escape(item.cid_descricao) : "") +
862                        "</td> " +
863                        '<td class="text-nowrap left-justify" width="10%"><strong>' +
864                        escape(item.cid_uf) +
865                        "</strong></td>" +
866                        "</tr>" +
867                        "</table>"
868                    );
869                },
870                item: function (item, escape) {
871                    return (
872                        "<div>" +
873                        (item.cid_descricao
874                            ? escape(item.cid_descricao)
875                            : "  ") +
876                        " | " +
877                        "<strong>" +
878                        escape(item.cid_uf) +
879                        "</strong>" +
880                        "</div>"
881                    );
882                },
883            },
884        };
885
886        $scope.loadModalidades = function () {
887            delete $scope.aModalidades;
888            ModalidadesAPIService.loadModalidades("")
889                .then(function (response) {
890                    $scope.aModalidades = response.data;
891                })
892                .catch(function (response) {
893                    $scope.alerta(
894                        "error",
895                        "Falha ao carregar os Modalidadess: " +
896                            (response.status ? response.status + " - " : "") +
897                            (response.statusText
898                                ? response.statusText
899                                : response.TypeError),
900                    );
901                });
902        };
903
904        $scope.cfgModalidades = {
905            create: false,
906            valueField: "mod_id",
907            searchField: ["mod_id", "mod_descricao"],
908            delimiter: config.SelDelimiter,
909            placeholder: "Selecione um Modalidades",
910            maxItems: 1,
911            onInitialize: function (selectize) {
912                $scope.loadModalidades();
913            },
914            render: {
915                option: function (item, escape) {
916                    return (
917                        '<table class="table" style="margin-bottom: 0px !important;">' +
918                        "<tr>" +
919                        '<td class="text-nowrap left-justify">' +
920                        (item.mod_descricao ? escape(item.mod_descricao) : "") +
921                        "</td> " +
922                        "</tr>" +
923                        "</table>"
924                    );
925                },
926                item: function (item, escape) {
927                    return (
928                        "<div>" +
929                        (item.mod_descricao
930                            ? escape(item.mod_descricao)
931                            : "  ") +
932                        "</div>"
933                    );
934                },
935            },
936        };
937
938        $scope.aPessoas = [
939            { pessoa_id: "F", pessoa_descr: "Física" },
940            { pessoa_id: "J", pessoa_descr: "Jurídica" },
941        ];
942
943        $scope.cfgPessoa = {
944            create: false,
945            valueField: "pessoa_id",
946            searchField: ["pessoa_id", "pessoa_descr"],
947            delimiter: config.SelDelimiter,
948            placeholder: "Selecione tipo de Pessoa",
949            maxItems: 1,
950            render: {
951                option: function (item, escape) {
952                    return (
953                        '<table class="table" style="margin-bottom: 0px !important;">' +
954                        "<tr>" +
955                        '<td class="text-nowrap left-justify" width="10%"><strong>' +
956                        escape(item.pessoa_id) +
957                        "</strong></td>" +
958                        '<td class="text-nowrap left-justify" width="90%">' +
959                        (item.pessoa_descr ? escape(item.pessoa_descr) : "") +
960                        "</td> " +
961                        "</tr>" +
962                        "</table>"
963                    );
964                },
965                item: function (item, escape) {
966                    return (
967                        "<div>" +
968                        "<strong>" +
969                        escape(item.pessoa_id) +
970                        " | " +
971                        "</strong>" +
972                        (item.pessoa_descr ? escape(item.pessoa_descr) : "  ") +
973                        "</div>"
974                    );
975                },
976            },
977        };
978    },
979);
980
981app.filter("startFrom", function () {
982    return function (input, start) {
983        start = +start; //parse to int
984        return input ? input.slice(start) : 0;
985    };
986});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.