Upload app.R
Browse files
app.R
CHANGED
@@ -1,19 +1,18 @@
|
|
1 |
-
library(magrittr)
|
2 |
#
|
3 |
# 0. routing
|
4 |
# --------
|
5 |
|
6 |
#
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
#
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
#
|
18 |
|
19 |
#setwd(absolute_path("assets"))
|
@@ -31,8 +30,8 @@ options(shiny.maxRequestSize=30*1024^2)
|
|
31 |
# 1.1 custom-dependencias
|
32 |
# --------
|
33 |
|
34 |
-
|
35 |
-
|
36 |
source("dataframe extention.R")
|
37 |
source("Compute_YEI.R")
|
38 |
|
@@ -42,9 +41,9 @@ source("Compute_YEI.R")
|
|
42 |
|
43 |
#
|
44 |
talk_states=list(
|
45 |
-
|
46 |
-
|
47 |
-
)
|
48 |
#
|
49 |
CURRENT_STATE="unauthenticated"
|
50 |
EXPORT_STATE=FALSE
|
@@ -54,19 +53,19 @@ credentials.authenticate=function(
|
|
54 |
input_pasword,
|
55 |
valid_credentials=data.frame(user="stockpesca", pasword="Temporal1843@!")
|
56 |
){
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
valid_credentials %>% dplyr::filter(user==input_user & pasword==input_pasword)
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
}
|
71 |
|
72 |
#
|
@@ -75,18 +74,18 @@ credentials.authenticate=function(
|
|
75 |
|
76 |
#
|
77 |
empty_table=data.frame(
|
78 |
-
|
79 |
)
|
80 |
#
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
#datasource.raw_inspecciones() %>% View()
|
91 |
inspecciones.cache=NULL
|
92 |
#inspecciones.cache=datasource.raw_inspecciones()
|
@@ -96,14 +95,14 @@ inspecciones.cache=NULL
|
|
96 |
query_data=function(
|
97 |
file_path
|
98 |
){
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
# try({
|
108 |
# #
|
109 |
# setwd(absolute_path("datasource inspecciones"))
|
@@ -124,18 +123,18 @@ query_data=function(
|
|
124 |
# dbFetch(query)
|
125 |
# }) %>% as.data.frame()
|
126 |
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
-
tryCatch({
|
129 |
-
data <- readxl::read_excel(file_path)
|
130 |
-
print("Archivo leído correctamente")
|
131 |
-
data
|
132 |
-
}, error = function(e) {
|
133 |
-
print("Error al leer el archivo:")
|
134 |
-
print(e$message)
|
135 |
-
data.frame(Mensaje = "Error al leer el archivo Excel")
|
136 |
-
})
|
137 |
-
}
|
138 |
-
|
139 |
}
|
140 |
|
141 |
#
|
@@ -147,200 +146,200 @@ query_data=function(
|
|
147 |
inspecciones.activas=function(
|
148 |
inspecciones
|
149 |
){
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
}
|
159 |
#
|
160 |
inspecciones.ensamblar_variables_de_reporte=function(
|
161 |
inspecciones
|
162 |
){
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
}
|
173 |
#
|
174 |
tabla_de_reporte.formatear_ciclo_anual_en_columnas=
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
#
|
190 |
table_logic_per_index=list(
|
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 |
inspecciones=inspecciones.cache
|
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 |
source("Compute_YEI.R")
|
345 |
#
|
346 |
table_logic_per_index[["2.1"]]=
|
@@ -395,7 +394,7 @@ table_logic_per_index[["2.3"]]=
|
|
395 |
|
396 |
"arte",
|
397 |
"sitio"
|
398 |
-
|
399 |
|
400 |
)
|
401 |
) %>%
|
@@ -436,7 +435,7 @@ table_logic_per_index[["2.5"]]=
|
|
436 |
GROUP_BY=c(
|
437 |
"ano",
|
438 |
"mes",
|
439 |
-
|
440 |
|
441 |
"arte",
|
442 |
"SUBGRUPO",
|
@@ -497,41 +496,41 @@ table_logic_per_index[["2.7"]]=
|
|
497 |
#
|
498 |
|
499 |
#
|
500 |
-
|
501 |
source("Compute_YEI.R")
|
502 |
#
|
503 |
inspecciones.ensamblar_captura_diaria=
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
508 |
|
509 |
-
|
510 |
-
|
511 |
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
)
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
)
|
527 |
-
|
528 |
-
|
529 |
-
) %>%
|
530 |
-
dplyr::mutate(
|
531 |
-
captura_diaria=round( (captura_total/num_dias),4),
|
532 |
-
captura_diaria_por_pescador=round( ( (captura_total/num_dias)/num_pescadores ),4),
|
533 |
-
)
|
534 |
-
}
|
535 |
#
|
536 |
table_logic_per_index[["3.1"]]=
|
537 |
function(
|
@@ -606,7 +605,7 @@ table_logic_per_index[["3.3"]]=
|
|
606 |
fetch_table_per_index=function(
|
607 |
index=1.1
|
608 |
){
|
609 |
-
|
610 |
}
|
611 |
#
|
612 |
table.preview=function(
|
@@ -614,10 +613,10 @@ table.preview=function(
|
|
614 |
max_rows=15,
|
615 |
max_cols=8
|
616 |
){
|
617 |
-
|
618 |
table[1:min(max_rows, nrow(table) ), 1:min(max_cols, ncol(nrow(table)))]
|
619 |
-
|
620 |
-
|
621 |
}
|
622 |
|
623 |
# 5. exportar a un reporte ?nico
|
@@ -626,178 +625,180 @@ table.preview=function(
|
|
626 |
# 6. interfaz del usuario exportar a un reporte ?nico
|
627 |
#
|
628 |
|
629 |
-
|
630 |
#
|
631 |
library(shiny)
|
632 |
ui = fluidPage(
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
accept = c(".xlsx")
|
661 |
-
))),
|
662 |
-
|
663 |
-
fluidRow(
|
664 |
-
wellPanel(
|
665 |
-
|
666 |
-
shiny::tags$strong("Reportes"),
|
667 |
-
shiny::tags$br(),
|
668 |
-
shiny::actionButton("exportar_reportes",
|
669 |
-
"Exportar reportes",
|
670 |
-
width='100%'),
|
671 |
-
textOutput("export_result")
|
672 |
-
),
|
673 |
-
plotOutput(
|
674 |
-
"logo",
|
675 |
-
width = "100%",
|
676 |
-
height = "200px")
|
677 |
-
),
|
678 |
-
|
679 |
-
), # column,
|
680 |
-
|
681 |
-
column(12-4,
|
682 |
-
|
683 |
-
offset = 1,
|
684 |
-
|
685 |
-
fluidRow(wellPanel(
|
686 |
-
shiny::tags$strong("Mensajes"),
|
687 |
-
textOutput("messages"))),
|
688 |
-
|
689 |
-
|
690 |
-
shiny::tags$strong("Pre-visualización de reportes"),
|
691 |
-
|
692 |
-
tabsetPanel(
|
693 |
-
|
694 |
-
tabPanel("0. Tabla maestra",
|
695 |
-
|
696 |
-
div(shiny::tableOutput("0_tabla_maestra"),
|
697 |
-
style = "font-size:50%")),
|
698 |
-
|
699 |
-
tabPanel("1. Esfuerzo",
|
700 |
-
|
701 |
-
tabsetPanel(
|
702 |
-
|
703 |
-
tabPanel(
|
704 |
-
"1.1",
|
705 |
-
div(shiny::tableOutput("1.1")),
|
706 |
-
style = "font-size:50%"),
|
707 |
-
|
708 |
-
tabPanel(
|
709 |
-
"1.2",
|
710 |
-
div(shiny::tableOutput("1.2")),
|
711 |
-
style = "font-size:50%"),
|
712 |
-
|
713 |
-
tabPanel(
|
714 |
-
"1.3",
|
715 |
-
div(shiny::tableOutput("1.3")),
|
716 |
-
style = "font-size:50%"
|
717 |
-
),
|
718 |
-
|
719 |
-
tabPanel(
|
720 |
-
"1.4",
|
721 |
-
div(shiny::tableOutput("1.4")),
|
722 |
-
style = "font-size:50%"),
|
723 |
-
|
724 |
-
tabPanel(
|
725 |
-
"1.5",
|
726 |
-
div(shiny::tableOutput("1.5")),
|
727 |
-
style = "font-size:50%"),
|
728 |
-
|
729 |
-
tabPanel(
|
730 |
-
"1.6",
|
731 |
-
div(shiny::tableOutput("1.6")),
|
732 |
-
style = "font-size:50%"),
|
733 |
-
|
734 |
-
tabPanel(
|
735 |
-
"1.7",
|
736 |
-
div(shiny::tableOutput("1.7")),
|
737 |
-
style = "font-size:50%")
|
738 |
-
)),
|
739 |
-
|
740 |
-
tabPanel("2. Captura total",
|
741 |
-
|
742 |
-
tabsetPanel(
|
743 |
-
|
744 |
-
tabPanel(
|
745 |
-
"2.1",
|
746 |
-
div(shiny::tableOutput("2.1")),
|
747 |
-
style = "font-size:50%"),
|
748 |
-
|
749 |
-
tabPanel(
|
750 |
-
"2.2",
|
751 |
-
div(shiny::tableOutput("2.2")),
|
752 |
-
style = "font-size:50%"),
|
753 |
-
|
754 |
-
tabPanel(
|
755 |
-
"2.3",
|
756 |
-
div(shiny::tableOutput("2.3")),
|
757 |
-
style = "font-size:50%"),
|
758 |
-
|
759 |
-
tabPanel(
|
760 |
-
"2.4",
|
761 |
-
div(shiny::tableOutput("2.4")),
|
762 |
-
style = "font-size:50%"),
|
763 |
-
|
764 |
-
tabPanel(
|
765 |
-
"2.5",
|
766 |
-
div(shiny::tableOutput("2.5")),
|
767 |
-
style = "font-size:50%"),
|
768 |
-
|
769 |
-
tabPanel(
|
770 |
-
"2.6",
|
771 |
-
div(shiny::tableOutput("2.6")),
|
772 |
-
style = "font-size:50%"),
|
773 |
-
|
774 |
-
tabPanel(
|
775 |
-
"2.7",
|
776 |
-
div(shiny::tableOutput("2.7")),
|
777 |
-
style = "font-size:50%")
|
778 |
-
)),
|
779 |
-
|
780 |
-
tabPanel("3. CPUE",
|
781 |
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
801 |
|
802 |
|
803 |
#
|
@@ -831,7 +832,7 @@ server = function(input, output) {
|
|
831 |
actualizar_mensaje_exportado=reactive({
|
832 |
exportado
|
833 |
})
|
834 |
-
|
835 |
#
|
836 |
output$"0_tabla_maestra" = renderTable({
|
837 |
|
@@ -889,309 +890,309 @@ server = function(input, output) {
|
|
889 |
width = '100%',
|
890 |
spacing = "s"
|
891 |
)
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
}
|
901 |
-
},
|
902 |
-
striped = TRUE,
|
903 |
-
hover=TRUE,
|
904 |
-
bordered=TRUE,
|
905 |
-
width='100%',
|
906 |
-
spacing="s"
|
907 |
-
)
|
908 |
-
|
909 |
-
output$"1.3" = renderTable({
|
910 |
-
if (authenticated()) {
|
911 |
-
print(paste("User is authenticated, showing results..."))
|
912 |
-
data <- fetch_table_per_index("1.3")
|
913 |
-
data
|
914 |
-
} else {
|
915 |
-
print(paste("User is not authenticated, returning error message..."))
|
916 |
-
"No tiene permisos para ver esta tabla"
|
917 |
-
}
|
918 |
-
},
|
919 |
-
striped = TRUE,
|
920 |
-
hover=TRUE,
|
921 |
-
bordered=TRUE,
|
922 |
-
width='100%',
|
923 |
-
spacing="s"
|
924 |
-
)
|
925 |
-
|
926 |
-
output$"1.4" = renderTable({
|
927 |
-
if (authenticated()) {
|
928 |
-
print(paste("User is authenticated, showing results..."))
|
929 |
-
data <- fetch_table_per_index("1.4")
|
930 |
-
data
|
931 |
-
} else {
|
932 |
-
print(paste("User is not authenticated, returning error message..."))
|
933 |
-
"No tiene permisos para ver esta tabla"
|
934 |
-
}
|
935 |
-
},
|
936 |
-
striped = TRUE,
|
937 |
-
hover=TRUE,
|
938 |
-
bordered=TRUE,
|
939 |
-
width='100%',
|
940 |
-
spacing="s"
|
941 |
-
)
|
942 |
-
output$"1.5" = renderTable({
|
943 |
-
if (authenticated()) {
|
944 |
-
print(paste("User is authenticated, showing results..."))
|
945 |
-
data <- fetch_table_per_index("1.5")
|
946 |
-
data
|
947 |
-
} else {
|
948 |
-
print(paste("User is not authenticated, returning error message..."))
|
949 |
-
"No tiene permisos para ver esta tabla"
|
950 |
-
}
|
951 |
-
},
|
952 |
-
striped = TRUE,
|
953 |
-
hover=TRUE,
|
954 |
-
bordered=TRUE,
|
955 |
-
width='100%',
|
956 |
-
spacing="s"
|
957 |
-
)
|
958 |
-
output$"1.6" = renderTable({
|
959 |
-
if (authenticated()) {
|
960 |
-
print(paste("User is authenticated, showing results..."))
|
961 |
-
data <- fetch_table_per_index("1.6")
|
962 |
-
data
|
963 |
-
} else {
|
964 |
-
print(paste("User is not authenticated, returning error message..."))
|
965 |
-
"No tiene permisos para ver esta tabla"
|
966 |
-
}
|
967 |
-
},
|
968 |
-
striped = TRUE,
|
969 |
-
hover=TRUE,
|
970 |
-
bordered=TRUE,
|
971 |
-
width='100%',
|
972 |
-
spacing="s"
|
973 |
-
)
|
974 |
-
output$"1.7" = renderTable({
|
975 |
-
if (authenticated()) {
|
976 |
-
print(paste("User is authenticated, showing results..."))
|
977 |
-
data <- fetch_table_per_index("1.7")
|
978 |
-
data
|
979 |
-
} else {
|
980 |
-
print(paste("User is not authenticated, returning error message..."))
|
981 |
-
"No tiene permisos para ver esta tabla"
|
982 |
-
}
|
983 |
-
},
|
984 |
-
striped = TRUE,
|
985 |
-
hover=TRUE,
|
986 |
-
bordered=TRUE,
|
987 |
-
width='100%',
|
988 |
-
spacing="s"
|
989 |
-
)
|
990 |
-
output$"2.1" = renderTable({
|
991 |
-
if (authenticated()) {
|
992 |
-
print(paste("User is authenticated, showing results..."))
|
993 |
-
data <- fetch_table_per_index("2.1")
|
994 |
-
data
|
995 |
-
} else {
|
996 |
-
print(paste("User is not authenticated, returning error message..."))
|
997 |
-
"No tiene permisos para ver esta tabla"
|
998 |
-
}
|
999 |
-
},
|
1000 |
-
striped = TRUE,
|
1001 |
-
hover=TRUE,
|
1002 |
-
bordered=TRUE,
|
1003 |
-
width='100%',
|
1004 |
-
spacing="s"
|
1005 |
-
)
|
1006 |
-
output$"2.2" = renderTable({
|
1007 |
-
if (authenticated()) {
|
1008 |
-
print(paste("User is authenticated, showing results..."))
|
1009 |
-
data <- fetch_table_per_index("2.2")
|
1010 |
-
data
|
1011 |
-
} else {
|
1012 |
-
print(paste("User is not authenticated, returning error message..."))
|
1013 |
-
"No tiene permisos para ver esta tabla"
|
1014 |
-
}
|
1015 |
-
},
|
1016 |
-
striped = TRUE,
|
1017 |
-
hover=TRUE,
|
1018 |
-
bordered=TRUE,
|
1019 |
-
width='100%',
|
1020 |
-
spacing="s"
|
1021 |
-
)
|
1022 |
-
output$"2.3" = renderTable({
|
1023 |
-
if (authenticated()) {
|
1024 |
-
print(paste("User is authenticated, showing results..."))
|
1025 |
-
data <- fetch_table_per_index("2.3")
|
1026 |
-
data
|
1027 |
-
} else {
|
1028 |
-
print(paste("User is not authenticated, returning error message..."))
|
1029 |
-
"No tiene permisos para ver esta tabla"
|
1030 |
-
}
|
1031 |
-
},
|
1032 |
-
striped = TRUE,
|
1033 |
-
hover=TRUE,
|
1034 |
-
bordered=TRUE,
|
1035 |
-
width='100%',
|
1036 |
-
spacing="s"
|
1037 |
-
)
|
1038 |
-
output$"2.4" = renderTable({
|
1039 |
-
if (authenticated()) {
|
1040 |
-
print(paste("User is authenticated, showing results..."))
|
1041 |
-
data <- fetch_table_per_index("2.4")
|
1042 |
-
data
|
1043 |
-
} else {
|
1044 |
-
print(paste("User is not authenticated, returning error message..."))
|
1045 |
-
"No tiene permisos para ver esta tabla"
|
1046 |
-
}
|
1047 |
-
},
|
1048 |
-
striped = TRUE,
|
1049 |
-
hover=TRUE,
|
1050 |
-
bordered=TRUE,
|
1051 |
-
width='100%',
|
1052 |
-
spacing="s"
|
1053 |
-
)
|
1054 |
-
output$"2.5" = renderTable({
|
1055 |
-
if (authenticated()) {
|
1056 |
-
print(paste("User is authenticated, showing results..."))
|
1057 |
-
data <- fetch_table_per_index("2.5")
|
1058 |
-
data
|
1059 |
-
} else {
|
1060 |
-
print(paste("User is not authenticated, returning error message..."))
|
1061 |
-
"No tiene permisos para ver esta tabla"
|
1062 |
-
}
|
1063 |
-
},
|
1064 |
-
striped = TRUE,
|
1065 |
-
hover=TRUE,
|
1066 |
-
bordered=TRUE,
|
1067 |
-
width='100%',
|
1068 |
-
spacing="s"
|
1069 |
-
)
|
1070 |
-
output$"2.6" = renderTable({
|
1071 |
-
if (authenticated()) {
|
1072 |
-
print(paste("User is authenticated, showing results..."))
|
1073 |
-
data <- fetch_table_per_index("2.6")
|
1074 |
-
data
|
1075 |
-
} else {
|
1076 |
-
print(paste("User is not authenticated, returning error message..."))
|
1077 |
-
"No tiene permisos para ver esta tabla"
|
1078 |
-
}
|
1079 |
-
},
|
1080 |
-
striped = TRUE,
|
1081 |
-
hover=TRUE,
|
1082 |
-
bordered=TRUE,
|
1083 |
-
width='100%',
|
1084 |
-
spacing="s"
|
1085 |
-
)
|
1086 |
-
output$"2.7" = renderTable({
|
1087 |
-
if (authenticated()) {
|
1088 |
-
print(paste("User is authenticated, showing results..."))
|
1089 |
-
data <- fetch_table_per_index("2.7")
|
1090 |
-
data
|
1091 |
-
} else {
|
1092 |
-
print(paste("User is not authenticated, returning error message..."))
|
1093 |
-
"No tiene permisos para ver esta tabla"
|
1094 |
-
}
|
1095 |
-
},
|
1096 |
-
striped = TRUE,
|
1097 |
-
hover=TRUE,
|
1098 |
-
bordered=TRUE,
|
1099 |
-
width='100%',
|
1100 |
-
spacing="s"
|
1101 |
-
)
|
1102 |
-
|
1103 |
-
output$"3.1" = renderTable({
|
1104 |
-
if (authenticated()) {
|
1105 |
-
print(paste("User is authenticated, showing results..."))
|
1106 |
-
data <- fetch_table_per_index("3.1")
|
1107 |
-
data
|
1108 |
-
} else {
|
1109 |
-
print(paste("User is not authenticated, returning error message..."))
|
1110 |
-
"No tiene permisos para ver esta tabla"
|
1111 |
-
}
|
1112 |
-
},
|
1113 |
-
striped = TRUE,
|
1114 |
-
hover=TRUE,
|
1115 |
-
bordered=TRUE,
|
1116 |
-
width='100%',
|
1117 |
-
spacing="s"
|
1118 |
-
)
|
1119 |
-
output$"3.2" = renderTable({
|
1120 |
-
if (authenticated()) {
|
1121 |
-
print(paste("User is authenticated, showing results..."))
|
1122 |
-
data <- fetch_table_per_index("3.2")
|
1123 |
-
data
|
1124 |
-
} else {
|
1125 |
-
print(paste("User is not authenticated, returning error message..."))
|
1126 |
-
"No tiene permisos para ver esta tabla"
|
1127 |
-
}
|
1128 |
-
},
|
1129 |
-
striped = TRUE,
|
1130 |
-
hover=TRUE,
|
1131 |
-
bordered=TRUE,
|
1132 |
-
width='100%',
|
1133 |
-
spacing="s"
|
1134 |
-
)
|
1135 |
-
output$"3.3" = renderTable({
|
1136 |
-
if (authenticated()) {
|
1137 |
-
print(paste("User is authenticated, showing results..."))
|
1138 |
-
data <- fetch_table_per_index("3.3")
|
1139 |
-
data
|
1140 |
-
} else {
|
1141 |
-
print(paste("User is not authenticated, returning error message..."))
|
1142 |
-
"No tiene permisos para ver esta tabla"
|
1143 |
-
}
|
1144 |
-
},
|
1145 |
-
striped = TRUE,
|
1146 |
-
hover=TRUE,
|
1147 |
-
bordered=TRUE,
|
1148 |
-
width='100%',
|
1149 |
-
spacing="s"
|
1150 |
-
)
|
1151 |
-
|
1152 |
-
output$"export_result"=renderText({
|
1153 |
-
actualizar_mensaje_exportado()
|
1154 |
-
ifelse(exportado$se_exporto==TRUE, "Felicidades! El reporte fue exportado", "Aún no has exportado el reporte")
|
1155 |
-
})
|
1156 |
-
|
1157 |
-
observeEvent(input$exportar_reportes,{
|
1158 |
-
if (.GlobalEnv[["CURRENT_STATE"]] == "authenticated") {
|
1159 |
-
# Ensure the 'reportes' directory exists
|
1160 |
-
setwd(PROYECT_HOME)
|
1161 |
-
if (!dir.exists("reportes")) {
|
1162 |
-
dir.create("reportes")
|
1163 |
}
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
print(paste("Error generating report", index, ":", e$message))
|
1181 |
-
})
|
1182 |
}
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1195 |
}
|
1196 |
|
1197 |
# Run the application
|
|
|
|
|
1 |
#
|
2 |
# 0. routing
|
3 |
# --------
|
4 |
|
5 |
#
|
6 |
+
PROYECT_HOME=dirname(rstudioapi::getActiveDocumentContext()$path)
|
7 |
+
setwd(PROYECT_HOME)
|
8 |
+
list.files(getwd())
|
9 |
#
|
10 |
+
absolute_path=function(
|
11 |
+
APP_HOME
|
12 |
+
){
|
13 |
+
sprintf("%s/%s", PROYECT_HOME,APP_HOME)
|
14 |
+
}
|
15 |
+
absolute_path("datasource inspecciones")
|
16 |
#
|
17 |
|
18 |
#setwd(absolute_path("assets"))
|
|
|
30 |
# 1.1 custom-dependencias
|
31 |
# --------
|
32 |
|
33 |
+
CODE_HOME=absolute_path("code")
|
34 |
+
setwd(CODE_HOME)
|
35 |
source("dataframe extention.R")
|
36 |
source("Compute_YEI.R")
|
37 |
|
|
|
41 |
|
42 |
#
|
43 |
talk_states=list(
|
44 |
+
"unauthenticated"="No has ingresado credenciales válidas aún",
|
45 |
+
"authenticated"="Estás autenticado y los reportes están listos para exportar"
|
46 |
+
)
|
47 |
#
|
48 |
CURRENT_STATE="unauthenticated"
|
49 |
EXPORT_STATE=FALSE
|
|
|
53 |
input_pasword,
|
54 |
valid_credentials=data.frame(user="stockpesca", pasword="Temporal1843@!")
|
55 |
){
|
56 |
+
#
|
57 |
+
# cambia el estado de la aplicaci?n seg?n la validez de las credenciales
|
58 |
+
#
|
59 |
+
|
60 |
+
valid=
|
61 |
valid_credentials %>% dplyr::filter(user==input_user & pasword==input_pasword)
|
62 |
+
if (nrow(valid)>0)
|
63 |
+
{ .GlobalEnv[["CURRENT_STATE"]] ="authenticated"}
|
64 |
+
else {
|
65 |
+
.GlobalEnv[["CURRENT_STATE"]] ="unauthenticated"
|
66 |
+
}
|
67 |
+
|
68 |
+
print(.GlobalEnv[["CURRENT_STATE"]])
|
69 |
}
|
70 |
|
71 |
#
|
|
|
74 |
|
75 |
#
|
76 |
empty_table=data.frame(
|
77 |
+
data=c("No tiene permisos para ver esta tabla")
|
78 |
)
|
79 |
#
|
80 |
+
library(dplyr)
|
81 |
+
datasource.raw_inspecciones=function(
|
82 |
+
|
83 |
+
){
|
84 |
+
setwd(absolute_path("datasource inspecciones"))
|
85 |
+
readxl::read_excel("TABLA MAESTRA.xlsx") %>%
|
86 |
+
#head() %>%
|
87 |
+
as.data.frame()
|
88 |
+
}
|
89 |
#datasource.raw_inspecciones() %>% View()
|
90 |
inspecciones.cache=NULL
|
91 |
#inspecciones.cache=datasource.raw_inspecciones()
|
|
|
95 |
query_data=function(
|
96 |
file_path
|
97 |
){
|
98 |
+
if(.GlobalEnv[["CURRENT_STATE"]]=="unauthenticated"){
|
99 |
+
empty_table
|
100 |
+
} else {
|
101 |
+
# datasource.raw_inspecciones()
|
102 |
+
# #
|
103 |
+
# user_input_pwd="Temporal1843@!"
|
104 |
+
# db_file_name="inspecciones.accdb"
|
105 |
+
#
|
106 |
# try({
|
107 |
# #
|
108 |
# setwd(absolute_path("datasource inspecciones"))
|
|
|
123 |
# dbFetch(query)
|
124 |
# }) %>% as.data.frame()
|
125 |
#
|
126 |
+
|
127 |
+
tryCatch({
|
128 |
+
data <- readxl::read_excel(file_path)
|
129 |
+
print("Archivo leído correctamente")
|
130 |
+
data
|
131 |
+
}, error = function(e) {
|
132 |
+
print("Error al leer el archivo:")
|
133 |
+
print(e$message)
|
134 |
+
data.frame(Mensaje = "Error al leer el archivo Excel")
|
135 |
+
})
|
136 |
+
}
|
137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
}
|
139 |
|
140 |
#
|
|
|
146 |
inspecciones.activas=function(
|
147 |
inspecciones
|
148 |
){
|
149 |
+
inspecciones %>%
|
150 |
+
#
|
151 |
+
dplyr::mutate(
|
152 |
+
activa=TRUE
|
153 |
+
) %>%
|
154 |
+
dplyr::filter(
|
155 |
+
activa
|
156 |
+
)
|
157 |
}
|
158 |
#
|
159 |
inspecciones.ensamblar_variables_de_reporte=function(
|
160 |
inspecciones
|
161 |
){
|
162 |
+
inspecciones %>%
|
163 |
+
dplyr::mutate(
|
164 |
+
ano=ANO_ZARPE,
|
165 |
+
mes=MES_ZARPE,
|
166 |
+
arte=ARTE,
|
167 |
+
sitio=SITIO,
|
168 |
+
fecha=paste(ANO_ZARPE, MES_ZARPE, DIA_ZARPE, sep="+" ),
|
169 |
+
horas_faena=HORA_FAENA
|
170 |
+
)
|
171 |
}
|
172 |
#
|
173 |
tabla_de_reporte.formatear_ciclo_anual_en_columnas=
|
174 |
+
function(
|
175 |
+
Tabla_de_reporte
|
176 |
+
){
|
177 |
+
Tabla_de_reporte %>%
|
178 |
+
tidyr::pivot_wider(
|
179 |
+
names_from = mes,
|
180 |
+
names_prefix = "month_",
|
181 |
+
values_from = dplyr::last(names(.))
|
182 |
+
) %>%
|
183 |
+
Dataframe.order(
|
184 |
+
c( grep(names(.), pattern="^[^m]", value=TRUE),
|
185 |
+
paste("month_", 1:12, sep=""))
|
186 |
+
)
|
187 |
+
}
|
188 |
#
|
189 |
table_logic_per_index=list(
|
190 |
+
"1.1"=function(
|
191 |
+
inspecciones=inspecciones.cache
|
192 |
+
){
|
193 |
+
inspecciones %>%
|
194 |
+
inspecciones.activas() %>%
|
195 |
+
inspecciones.ensamblar_variables_de_reporte() %>%
|
196 |
+
|
197 |
+
split(paste(.$ano, .$mes, .$arte)) %>%
|
198 |
+
lapply(function(sub_df){
|
199 |
+
data.frame(
|
200 |
+
ano=dplyr::first(sub_df$ano),
|
201 |
+
mes=dplyr::first(sub_df$mes),
|
202 |
+
arte=dplyr::first(sub_df$arte),
|
203 |
+
reportada="(conteo) faenas activas",
|
204 |
+
faenas_activas=sub_df %>% nrow()
|
205 |
+
)
|
206 |
+
}) %>%
|
207 |
+
bind_rows() %>%
|
208 |
+
|
209 |
+
tabla_de_reporte.formatear_ciclo_anual_en_columnas()
|
210 |
+
},
|
211 |
+
"1.2"=function(
|
212 |
+
inspecciones=inspecciones.cache
|
213 |
+
){
|
214 |
+
inspecciones %>%
|
215 |
+
inspecciones.activas() %>%
|
216 |
+
inspecciones.ensamblar_variables_de_reporte() %>%
|
217 |
+
|
218 |
+
split(paste(.$ano, .$mes, .$arte, .$sitio)) %>%
|
219 |
+
lapply(function(sub_df){
|
220 |
+
data.frame(
|
221 |
+
ano=dplyr::first(sub_df$ano),
|
222 |
+
mes=dplyr::first(sub_df$mes),
|
223 |
+
arte=dplyr::first(sub_df$arte),
|
224 |
+
sitio=dplyr::first(sub_df$sitio),
|
225 |
+
reportada="(conteo) faenas activas",
|
226 |
+
faenas_activas=sub_df %>% nrow()
|
227 |
+
)
|
228 |
+
}) %>%
|
229 |
+
bind_rows() %>%
|
230 |
+
tabla_de_reporte.formatear_ciclo_anual_en_columnas()
|
231 |
+
},
|
232 |
+
"1.3"=function(
|
233 |
inspecciones=inspecciones.cache
|
234 |
+
){
|
235 |
+
inspecciones %>%
|
236 |
+
inspecciones.activas() %>%
|
237 |
+
inspecciones.ensamblar_variables_de_reporte() %>%
|
238 |
+
|
239 |
+
split(paste(.$ano, .$mes, .$arte, .$AREA, .$SUBAREA)) %>%
|
240 |
+
lapply(function(sub_df){
|
241 |
+
data.frame(
|
242 |
+
ano=dplyr::first(sub_df$ano),
|
243 |
+
mes=dplyr::first(sub_df$mes),
|
244 |
+
arte=dplyr::first(sub_df$arte),
|
245 |
+
area=dplyr::first(sub_df$AREA),
|
246 |
+
subarea=dplyr::first(sub_df$SUBAREA),
|
247 |
+
reportada="(conteo) faenas activas",
|
248 |
+
faenas_activas=nrow(sub_df)
|
249 |
+
)
|
250 |
+
}) %>%
|
251 |
+
bind_rows() %>%
|
252 |
+
tabla_de_reporte.formatear_ciclo_anual_en_columnas()
|
253 |
+
},
|
254 |
+
"1.4"=function(
|
255 |
+
inspecciones=inspecciones.cache
|
256 |
+
){
|
257 |
+
inspecciones %>%
|
258 |
+
inspecciones.activas() %>%
|
259 |
+
inspecciones.ensamblar_variables_de_reporte() %>%
|
260 |
+
|
261 |
+
split(paste(.$ano, .$mes, .$arte)) %>%
|
262 |
+
lapply(function(sub_df){
|
263 |
+
data.frame(
|
264 |
+
ano=dplyr::first(sub_df$ano),
|
265 |
+
mes=dplyr::first(sub_df$mes),
|
266 |
+
arte=dplyr::first(sub_df$arte),
|
267 |
+
reportada="dias de actividad",
|
268 |
+
dias_actividad=length(unique(sub_df$fecha))
|
269 |
+
)
|
270 |
+
}) %>%
|
271 |
+
bind_rows() %>%
|
272 |
+
|
273 |
+
tabla_de_reporte.formatear_ciclo_anual_en_columnas()
|
274 |
+
|
275 |
+
},
|
276 |
+
"1.5"=function(
|
277 |
+
inspecciones=inspecciones.cache
|
278 |
+
){
|
279 |
+
inspecciones %>%
|
280 |
+
inspecciones.activas() %>%
|
281 |
+
inspecciones.ensamblar_variables_de_reporte() %>%
|
282 |
+
|
283 |
+
split(paste(.$ano, .$mes, .$arte, .$sitio)) %>%
|
284 |
+
lapply(function(sub_df){
|
285 |
+
data.frame(
|
286 |
+
ano=dplyr::first(sub_df$ano),
|
287 |
+
mes=dplyr::first(sub_df$mes),
|
288 |
+
arte=dplyr::first(sub_df$arte),
|
289 |
+
sitio=dplyr::first(sub_df$sitio),
|
290 |
+
reportada="dias de actividad",
|
291 |
+
dias_actividad=length(unique(sub_df$fecha))
|
292 |
+
)
|
293 |
+
}) %>%
|
294 |
+
bind_rows() %>%
|
295 |
+
tabla_de_reporte.formatear_ciclo_anual_en_columnas()
|
296 |
+
},
|
297 |
+
"1.6"=function(
|
298 |
+
inspecciones=inspecciones.cache
|
299 |
+
){
|
300 |
+
inspecciones %>%
|
301 |
+
inspecciones.activas() %>%
|
302 |
+
inspecciones.ensamblar_variables_de_reporte() %>%
|
303 |
+
|
304 |
+
split(paste(.$ano, .$mes, .$arte)) %>%
|
305 |
+
lapply(function(sub_df){
|
306 |
+
data.frame(
|
307 |
+
ano=dplyr::first(sub_df$ano),
|
308 |
+
mes=dplyr::first(sub_df$mes),
|
309 |
+
arte=dplyr::first(sub_df$arte),
|
310 |
+
reportada="(promedio) de las horas de faena x (1.3)",
|
311 |
+
horas_de_faena=round(mean(sub_df$horas_faena),3)*(1.3)
|
312 |
+
)
|
313 |
+
}) %>%
|
314 |
+
bind_rows() %>%
|
315 |
+
tabla_de_reporte.formatear_ciclo_anual_en_columnas()
|
316 |
+
},
|
317 |
+
"1.7"=function(
|
318 |
+
inspecciones=inspecciones.cache
|
319 |
+
){
|
320 |
+
inspecciones %>%
|
321 |
+
inspecciones.activas() %>%
|
322 |
+
inspecciones.ensamblar_variables_de_reporte() %>%
|
323 |
+
|
324 |
+
split(paste(.$ano, .$mes, .$arte, .$AREA, .$SUBAREA )) %>%
|
325 |
+
lapply(function(sub_df){
|
326 |
+
data.frame(
|
327 |
+
ano=dplyr::first(sub_df$ano),
|
328 |
+
mes=dplyr::first(sub_df$mes),
|
329 |
+
arte=dplyr::first(sub_df$arte),
|
330 |
+
area=dplyr::first(sub_df$AREA),
|
331 |
+
subarea=dplyr::first(sub_df$SUBAREA),
|
332 |
+
reportada="(promedio) de las horas de faena x (1.3)",
|
333 |
+
horas_de_faena=round(mean(sub_df$horas_faena),3)*(1.3)
|
334 |
+
)
|
335 |
+
}) %>%
|
336 |
+
bind_rows() %>%
|
337 |
+
tabla_de_reporte.formatear_ciclo_anual_en_columnas()
|
338 |
+
}
|
339 |
)
|
340 |
|
341 |
#
|
342 |
+
setwd(CODE_HOME)
|
343 |
source("Compute_YEI.R")
|
344 |
#
|
345 |
table_logic_per_index[["2.1"]]=
|
|
|
394 |
|
395 |
"arte",
|
396 |
"sitio"
|
397 |
+
|
398 |
|
399 |
)
|
400 |
) %>%
|
|
|
435 |
GROUP_BY=c(
|
436 |
"ano",
|
437 |
"mes",
|
438 |
+
|
439 |
|
440 |
"arte",
|
441 |
"SUBGRUPO",
|
|
|
496 |
#
|
497 |
|
498 |
#
|
499 |
+
setwd(CODE_HOME)
|
500 |
source("Compute_YEI.R")
|
501 |
#
|
502 |
inspecciones.ensamblar_captura_diaria=
|
503 |
+
function(
|
504 |
+
inspecciones=inspecciones.cache
|
505 |
+
){
|
506 |
+
inspecciones %>%
|
507 |
+
|
508 |
+
inspecciones.activas() %>%
|
509 |
+
inspecciones.ensamblar_variables_de_reporte() %>%
|
510 |
+
|
511 |
+
dplyr::transmute(
|
512 |
+
captura_total=CT_KG,
|
513 |
|
514 |
+
dia_zarpe=paste(ANO_ZARPE, MES_ZARPE , DIA_ZARPE, sep="/" ),
|
515 |
+
dia_arribo=paste(ANO_ARRIBO, MES_ARRIBO, DIA_ARRIBO, sep="/" ),
|
516 |
|
517 |
+
num_pescadores=PESCADORES,
|
518 |
+
|
519 |
+
arte_pesca=ARTE,
|
520 |
+
grupo=GRUPO
|
521 |
+
) %>%
|
522 |
+
dplyr::mutate(
|
523 |
+
dia_zarpe=as.Date(dia_zarpe),
|
524 |
+
dia_arribo=as.Date(dia_arribo)
|
525 |
+
) %>%
|
526 |
+
dplyr::mutate(
|
527 |
+
num_dias=as.numeric((dia_arribo-dia_zarpe)+1)
|
528 |
+
) %>%
|
529 |
+
dplyr::mutate(
|
530 |
+
captura_diaria=round( (captura_total/num_dias),4),
|
531 |
+
captura_diaria_por_pescador=round( ( (captura_total/num_dias)/num_pescadores ),4),
|
532 |
+
)
|
533 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
534 |
#
|
535 |
table_logic_per_index[["3.1"]]=
|
536 |
function(
|
|
|
605 |
fetch_table_per_index=function(
|
606 |
index=1.1
|
607 |
){
|
608 |
+
table_logic_per_index[[index]]()
|
609 |
}
|
610 |
#
|
611 |
table.preview=function(
|
|
|
613 |
max_rows=15,
|
614 |
max_cols=8
|
615 |
){
|
616 |
+
tryCatch({
|
617 |
table[1:min(max_rows, nrow(table) ), 1:min(max_cols, ncol(nrow(table)))]
|
618 |
+
},
|
619 |
+
error = function(e){empty_table})
|
620 |
}
|
621 |
|
622 |
# 5. exportar a un reporte ?nico
|
|
|
625 |
# 6. interfaz del usuario exportar a un reporte ?nico
|
626 |
#
|
627 |
|
628 |
+
setwd(PROYECT_HOME)
|
629 |
#
|
630 |
library(shiny)
|
631 |
ui = fluidPage(
|
632 |
+
|
633 |
+
|
634 |
+
column(3,
|
635 |
+
fluidRow(
|
636 |
+
wellPanel(
|
637 |
+
shiny::HTML("<p> Bienvenido a la <strong> aplicación pesquera </strong>. Escoja una acción </p>")
|
638 |
+
)),
|
639 |
+
|
640 |
+
fluidRow(
|
641 |
+
wellPanel(
|
642 |
+
shiny::tags$strong("Credenciales"),
|
643 |
+
|
644 |
+
shiny::textInput("usuario",
|
645 |
+
label=NULL,
|
646 |
+
placeholder = "inserte usuario",
|
647 |
+
width='100%'),
|
648 |
+
shiny::passwordInput("contrasena",
|
649 |
+
label=NULL,
|
650 |
+
placeholder = "inserte contrasena",
|
651 |
+
width='100%')
|
652 |
+
# shiny::actionButton("enviar_credenciales",
|
653 |
+
# "Enviar credenciales",
|
654 |
+
# width='100%')
|
655 |
+
)),
|
656 |
+
|
657 |
+
fluidRow(
|
658 |
+
wellPanel(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
659 |
|
660 |
+
fileInput('main_file_input', 'Seleccione un archivo desde su computador',
|
661 |
+
accept = c(".xlsx")
|
662 |
+
))),
|
663 |
+
|
664 |
+
fluidRow(
|
665 |
+
wellPanel(
|
666 |
+
|
667 |
+
shiny::tags$strong("Reportes"),
|
668 |
+
shiny::tags$br(),
|
669 |
+
shiny::actionButton("exportar_reportes",
|
670 |
+
"Exportar reportes",
|
671 |
+
width='100%'),
|
672 |
+
textOutput("export_result")
|
673 |
+
),
|
674 |
+
plotOutput(
|
675 |
+
"logo",
|
676 |
+
width = "100%",
|
677 |
+
height = "200px")
|
678 |
+
),
|
679 |
+
|
680 |
+
), # column,
|
681 |
+
|
682 |
+
column(12-4,
|
683 |
+
|
684 |
+
offset = 1,
|
685 |
+
|
686 |
+
fluidRow(wellPanel(
|
687 |
+
shiny::tags$strong("Mensajes"),
|
688 |
+
textOutput("messages"))),
|
689 |
+
|
690 |
+
|
691 |
+
shiny::tags$strong("Pre-visualización de reportes"),
|
692 |
+
|
693 |
+
tabsetPanel(
|
694 |
+
|
695 |
+
tabPanel("0. Tabla maestra",
|
696 |
+
|
697 |
+
div(shiny::tableOutput("0_tabla_maestra"),
|
698 |
+
style = "font-size:50%")),
|
699 |
+
|
700 |
+
tabPanel("1. Esfuerzo",
|
701 |
+
|
702 |
+
tabsetPanel(
|
703 |
+
|
704 |
+
tabPanel(
|
705 |
+
"1.1",
|
706 |
+
div(shiny::tableOutput("1.1")),
|
707 |
+
style = "font-size:50%"),
|
708 |
+
|
709 |
+
tabPanel(
|
710 |
+
"1.2",
|
711 |
+
div(shiny::tableOutput("1.2")),
|
712 |
+
style = "font-size:50%"),
|
713 |
+
|
714 |
+
tabPanel(
|
715 |
+
"1.3",
|
716 |
+
div(shiny::tableOutput("1.3")),
|
717 |
+
style = "font-size:50%"
|
718 |
+
),
|
719 |
+
|
720 |
+
tabPanel(
|
721 |
+
"1.4",
|
722 |
+
div(shiny::tableOutput("1.4")),
|
723 |
+
style = "font-size:50%"),
|
724 |
+
|
725 |
+
tabPanel(
|
726 |
+
"1.5",
|
727 |
+
div(shiny::tableOutput("1.5")),
|
728 |
+
style = "font-size:50%"),
|
729 |
+
|
730 |
+
tabPanel(
|
731 |
+
"1.6",
|
732 |
+
div(shiny::tableOutput("1.6")),
|
733 |
+
style = "font-size:50%"),
|
734 |
+
|
735 |
+
tabPanel(
|
736 |
+
"1.7",
|
737 |
+
div(shiny::tableOutput("1.7")),
|
738 |
+
style = "font-size:50%")
|
739 |
+
)),
|
740 |
+
|
741 |
+
tabPanel("2. Captura total",
|
742 |
+
|
743 |
+
tabsetPanel(
|
744 |
+
|
745 |
+
tabPanel(
|
746 |
+
"2.1",
|
747 |
+
div(shiny::tableOutput("2.1")),
|
748 |
+
style = "font-size:50%"),
|
749 |
+
|
750 |
+
tabPanel(
|
751 |
+
"2.2",
|
752 |
+
div(shiny::tableOutput("2.2")),
|
753 |
+
style = "font-size:50%"),
|
754 |
+
|
755 |
+
tabPanel(
|
756 |
+
"2.3",
|
757 |
+
div(shiny::tableOutput("2.3")),
|
758 |
+
style = "font-size:50%"),
|
759 |
+
|
760 |
+
tabPanel(
|
761 |
+
"2.4",
|
762 |
+
div(shiny::tableOutput("2.4")),
|
763 |
+
style = "font-size:50%"),
|
764 |
+
|
765 |
+
tabPanel(
|
766 |
+
"2.5",
|
767 |
+
div(shiny::tableOutput("2.5")),
|
768 |
+
style = "font-size:50%"),
|
769 |
+
|
770 |
+
tabPanel(
|
771 |
+
"2.6",
|
772 |
+
div(shiny::tableOutput("2.6")),
|
773 |
+
style = "font-size:50%"),
|
774 |
+
|
775 |
+
tabPanel(
|
776 |
+
"2.7",
|
777 |
+
div(shiny::tableOutput("2.7")),
|
778 |
+
style = "font-size:50%")
|
779 |
+
)),
|
780 |
+
|
781 |
+
tabPanel("3. CPUE",
|
782 |
+
|
783 |
+
tabsetPanel(
|
784 |
+
|
785 |
+
tabPanel(
|
786 |
+
"3.1",
|
787 |
+
div(shiny::tableOutput("3.1")),
|
788 |
+
style = "font-size:50%"),
|
789 |
+
|
790 |
+
tabPanel(
|
791 |
+
"3.2",
|
792 |
+
div(shiny::tableOutput("3.2")),
|
793 |
+
style = "font-size:50%"),
|
794 |
+
|
795 |
+
tabPanel(
|
796 |
+
"3.3",
|
797 |
+
div(shiny::tableOutput("3.3")),
|
798 |
+
style = "font-size:50%")))
|
799 |
+
|
800 |
+
# )),
|
801 |
+
)))
|
802 |
|
803 |
|
804 |
#
|
|
|
832 |
actualizar_mensaje_exportado=reactive({
|
833 |
exportado
|
834 |
})
|
835 |
+
|
836 |
#
|
837 |
output$"0_tabla_maestra" = renderTable({
|
838 |
|
|
|
890 |
width = '100%',
|
891 |
spacing = "s"
|
892 |
)
|
893 |
+
output$"1.2" = renderTable({
|
894 |
+
if (authenticated()) {
|
895 |
+
print(paste("User is authenticated, showing results..."))
|
896 |
+
data <- fetch_table_per_index("1.2")
|
897 |
+
data
|
898 |
+
} else {
|
899 |
+
print(paste("User is not authenticated, returning error message..."))
|
900 |
+
"No tiene permisos para ver esta tabla"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
901 |
}
|
902 |
+
},
|
903 |
+
striped = TRUE,
|
904 |
+
hover=TRUE,
|
905 |
+
bordered=TRUE,
|
906 |
+
width='100%',
|
907 |
+
spacing="s"
|
908 |
+
)
|
909 |
+
|
910 |
+
output$"1.3" = renderTable({
|
911 |
+
if (authenticated()) {
|
912 |
+
print(paste("User is authenticated, showing results..."))
|
913 |
+
data <- fetch_table_per_index("1.3")
|
914 |
+
data
|
915 |
+
} else {
|
916 |
+
print(paste("User is not authenticated, returning error message..."))
|
917 |
+
"No tiene permisos para ver esta tabla"
|
|
|
|
|
918 |
}
|
919 |
+
},
|
920 |
+
striped = TRUE,
|
921 |
+
hover=TRUE,
|
922 |
+
bordered=TRUE,
|
923 |
+
width='100%',
|
924 |
+
spacing="s"
|
925 |
+
)
|
926 |
+
|
927 |
+
output$"1.4" = renderTable({
|
928 |
+
if (authenticated()) {
|
929 |
+
print(paste("User is authenticated, showing results..."))
|
930 |
+
data <- fetch_table_per_index("1.4")
|
931 |
+
data
|
932 |
+
} else {
|
933 |
+
print(paste("User is not authenticated, returning error message..."))
|
934 |
+
"No tiene permisos para ver esta tabla"
|
935 |
+
}
|
936 |
+
},
|
937 |
+
striped = TRUE,
|
938 |
+
hover=TRUE,
|
939 |
+
bordered=TRUE,
|
940 |
+
width='100%',
|
941 |
+
spacing="s"
|
942 |
+
)
|
943 |
+
output$"1.5" = renderTable({
|
944 |
+
if (authenticated()) {
|
945 |
+
print(paste("User is authenticated, showing results..."))
|
946 |
+
data <- fetch_table_per_index("1.5")
|
947 |
+
data
|
948 |
+
} else {
|
949 |
+
print(paste("User is not authenticated, returning error message..."))
|
950 |
+
"No tiene permisos para ver esta tabla"
|
951 |
+
}
|
952 |
+
},
|
953 |
+
striped = TRUE,
|
954 |
+
hover=TRUE,
|
955 |
+
bordered=TRUE,
|
956 |
+
width='100%',
|
957 |
+
spacing="s"
|
958 |
+
)
|
959 |
+
output$"1.6" = renderTable({
|
960 |
+
if (authenticated()) {
|
961 |
+
print(paste("User is authenticated, showing results..."))
|
962 |
+
data <- fetch_table_per_index("1.6")
|
963 |
+
data
|
964 |
+
} else {
|
965 |
+
print(paste("User is not authenticated, returning error message..."))
|
966 |
+
"No tiene permisos para ver esta tabla"
|
967 |
+
}
|
968 |
+
},
|
969 |
+
striped = TRUE,
|
970 |
+
hover=TRUE,
|
971 |
+
bordered=TRUE,
|
972 |
+
width='100%',
|
973 |
+
spacing="s"
|
974 |
+
)
|
975 |
+
output$"1.7" = renderTable({
|
976 |
+
if (authenticated()) {
|
977 |
+
print(paste("User is authenticated, showing results..."))
|
978 |
+
data <- fetch_table_per_index("1.7")
|
979 |
+
data
|
980 |
+
} else {
|
981 |
+
print(paste("User is not authenticated, returning error message..."))
|
982 |
+
"No tiene permisos para ver esta tabla"
|
983 |
+
}
|
984 |
+
},
|
985 |
+
striped = TRUE,
|
986 |
+
hover=TRUE,
|
987 |
+
bordered=TRUE,
|
988 |
+
width='100%',
|
989 |
+
spacing="s"
|
990 |
+
)
|
991 |
+
output$"2.1" = renderTable({
|
992 |
+
if (authenticated()) {
|
993 |
+
print(paste("User is authenticated, showing results..."))
|
994 |
+
data <- fetch_table_per_index("2.1")
|
995 |
+
data
|
996 |
+
} else {
|
997 |
+
print(paste("User is not authenticated, returning error message..."))
|
998 |
+
"No tiene permisos para ver esta tabla"
|
999 |
+
}
|
1000 |
+
},
|
1001 |
+
striped = TRUE,
|
1002 |
+
hover=TRUE,
|
1003 |
+
bordered=TRUE,
|
1004 |
+
width='100%',
|
1005 |
+
spacing="s"
|
1006 |
+
)
|
1007 |
+
output$"2.2" = renderTable({
|
1008 |
+
if (authenticated()) {
|
1009 |
+
print(paste("User is authenticated, showing results..."))
|
1010 |
+
data <- fetch_table_per_index("2.2")
|
1011 |
+
data
|
1012 |
+
} else {
|
1013 |
+
print(paste("User is not authenticated, returning error message..."))
|
1014 |
+
"No tiene permisos para ver esta tabla"
|
1015 |
+
}
|
1016 |
+
},
|
1017 |
+
striped = TRUE,
|
1018 |
+
hover=TRUE,
|
1019 |
+
bordered=TRUE,
|
1020 |
+
width='100%',
|
1021 |
+
spacing="s"
|
1022 |
+
)
|
1023 |
+
output$"2.3" = renderTable({
|
1024 |
+
if (authenticated()) {
|
1025 |
+
print(paste("User is authenticated, showing results..."))
|
1026 |
+
data <- fetch_table_per_index("2.3")
|
1027 |
+
data
|
1028 |
+
} else {
|
1029 |
+
print(paste("User is not authenticated, returning error message..."))
|
1030 |
+
"No tiene permisos para ver esta tabla"
|
1031 |
+
}
|
1032 |
+
},
|
1033 |
+
striped = TRUE,
|
1034 |
+
hover=TRUE,
|
1035 |
+
bordered=TRUE,
|
1036 |
+
width='100%',
|
1037 |
+
spacing="s"
|
1038 |
+
)
|
1039 |
+
output$"2.4" = renderTable({
|
1040 |
+
if (authenticated()) {
|
1041 |
+
print(paste("User is authenticated, showing results..."))
|
1042 |
+
data <- fetch_table_per_index("2.4")
|
1043 |
+
data
|
1044 |
+
} else {
|
1045 |
+
print(paste("User is not authenticated, returning error message..."))
|
1046 |
+
"No tiene permisos para ver esta tabla"
|
1047 |
+
}
|
1048 |
+
},
|
1049 |
+
striped = TRUE,
|
1050 |
+
hover=TRUE,
|
1051 |
+
bordered=TRUE,
|
1052 |
+
width='100%',
|
1053 |
+
spacing="s"
|
1054 |
+
)
|
1055 |
+
output$"2.5" = renderTable({
|
1056 |
+
if (authenticated()) {
|
1057 |
+
print(paste("User is authenticated, showing results..."))
|
1058 |
+
data <- fetch_table_per_index("2.5")
|
1059 |
+
data
|
1060 |
+
} else {
|
1061 |
+
print(paste("User is not authenticated, returning error message..."))
|
1062 |
+
"No tiene permisos para ver esta tabla"
|
1063 |
+
}
|
1064 |
+
},
|
1065 |
+
striped = TRUE,
|
1066 |
+
hover=TRUE,
|
1067 |
+
bordered=TRUE,
|
1068 |
+
width='100%',
|
1069 |
+
spacing="s"
|
1070 |
+
)
|
1071 |
+
output$"2.6" = renderTable({
|
1072 |
+
if (authenticated()) {
|
1073 |
+
print(paste("User is authenticated, showing results..."))
|
1074 |
+
data <- fetch_table_per_index("2.6")
|
1075 |
+
data
|
1076 |
+
} else {
|
1077 |
+
print(paste("User is not authenticated, returning error message..."))
|
1078 |
+
"No tiene permisos para ver esta tabla"
|
1079 |
+
}
|
1080 |
+
},
|
1081 |
+
striped = TRUE,
|
1082 |
+
hover=TRUE,
|
1083 |
+
bordered=TRUE,
|
1084 |
+
width='100%',
|
1085 |
+
spacing="s"
|
1086 |
+
)
|
1087 |
+
output$"2.7" = renderTable({
|
1088 |
+
if (authenticated()) {
|
1089 |
+
print(paste("User is authenticated, showing results..."))
|
1090 |
+
data <- fetch_table_per_index("2.7")
|
1091 |
+
data
|
1092 |
+
} else {
|
1093 |
+
print(paste("User is not authenticated, returning error message..."))
|
1094 |
+
"No tiene permisos para ver esta tabla"
|
1095 |
+
}
|
1096 |
+
},
|
1097 |
+
striped = TRUE,
|
1098 |
+
hover=TRUE,
|
1099 |
+
bordered=TRUE,
|
1100 |
+
width='100%',
|
1101 |
+
spacing="s"
|
1102 |
+
)
|
1103 |
+
|
1104 |
+
output$"3.1" = renderTable({
|
1105 |
+
if (authenticated()) {
|
1106 |
+
print(paste("User is authenticated, showing results..."))
|
1107 |
+
data <- fetch_table_per_index("3.1")
|
1108 |
+
data
|
1109 |
+
} else {
|
1110 |
+
print(paste("User is not authenticated, returning error message..."))
|
1111 |
+
"No tiene permisos para ver esta tabla"
|
1112 |
+
}
|
1113 |
+
},
|
1114 |
+
striped = TRUE,
|
1115 |
+
hover=TRUE,
|
1116 |
+
bordered=TRUE,
|
1117 |
+
width='100%',
|
1118 |
+
spacing="s"
|
1119 |
+
)
|
1120 |
+
output$"3.2" = renderTable({
|
1121 |
+
if (authenticated()) {
|
1122 |
+
print(paste("User is authenticated, showing results..."))
|
1123 |
+
data <- fetch_table_per_index("3.2")
|
1124 |
+
data
|
1125 |
+
} else {
|
1126 |
+
print(paste("User is not authenticated, returning error message..."))
|
1127 |
+
"No tiene permisos para ver esta tabla"
|
1128 |
+
}
|
1129 |
+
},
|
1130 |
+
striped = TRUE,
|
1131 |
+
hover=TRUE,
|
1132 |
+
bordered=TRUE,
|
1133 |
+
width='100%',
|
1134 |
+
spacing="s"
|
1135 |
+
)
|
1136 |
+
output$"3.3" = renderTable({
|
1137 |
+
if (authenticated()) {
|
1138 |
+
print(paste("User is authenticated, showing results..."))
|
1139 |
+
data <- fetch_table_per_index("3.3")
|
1140 |
+
data
|
1141 |
+
} else {
|
1142 |
+
print(paste("User is not authenticated, returning error message..."))
|
1143 |
+
"No tiene permisos para ver esta tabla"
|
1144 |
+
}
|
1145 |
+
},
|
1146 |
+
striped = TRUE,
|
1147 |
+
hover=TRUE,
|
1148 |
+
bordered=TRUE,
|
1149 |
+
width='100%',
|
1150 |
+
spacing="s"
|
1151 |
+
)
|
1152 |
+
|
1153 |
+
output$"export_result"=renderText({
|
1154 |
+
actualizar_mensaje_exportado()
|
1155 |
+
ifelse(exportado$se_exporto==TRUE, "Felicidades! El reporte fue exportado", "Aún no has exportado el reporte")
|
1156 |
+
})
|
1157 |
+
|
1158 |
+
observeEvent(input$exportar_reportes,{
|
1159 |
+
if (.GlobalEnv[["CURRENT_STATE"]] == "authenticated") {
|
1160 |
+
# Ensure the 'reportes' directory exists
|
1161 |
+
setwd(PROYECT_HOME)
|
1162 |
+
if (!dir.exists("reportes")) {
|
1163 |
+
dir.create("reportes")
|
1164 |
+
}
|
1165 |
+
setwd("reportes")
|
1166 |
+
|
1167 |
+
# Create a new workbook
|
1168 |
+
wb <- openxlsx::createWorkbook()
|
1169 |
+
|
1170 |
+
# Generate and add each report to a separate sheet
|
1171 |
+
report_indices <- c("1.1", "1.2","1.3", "1.4", "1.5", "1.6", "1.7",
|
1172 |
+
"2.1", "2.2", "2.3", "2.4", "2.5", "2.6", "2.7",
|
1173 |
+
"3.1", "3.2","3.3")
|
1174 |
+
|
1175 |
+
for (index in report_indices) {
|
1176 |
+
tryCatch({
|
1177 |
+
report_data <- fetch_table_per_index(index)
|
1178 |
+
openxlsx::addWorksheet(wb, sheetName = paste("Reporte", index))
|
1179 |
+
openxlsx::writeData(wb, sheet = paste("Reporte", index), x = report_data)
|
1180 |
+
}, error = function(e) {
|
1181 |
+
print(paste("Error generating report", index, ":", e$message))
|
1182 |
+
})
|
1183 |
+
}
|
1184 |
+
|
1185 |
+
# Save the workbook
|
1186 |
+
openxlsx::saveWorkbook(wb, "exporte_reportes.xlsx", overwrite = TRUE)
|
1187 |
+
|
1188 |
+
.GlobalEnv[["EXPORT_STATE"]] <- TRUE
|
1189 |
+
exportado$se_exporto <- TRUE
|
1190 |
+
|
1191 |
+
# Optional: Show a message or log the successful export
|
1192 |
+
print("Reports exported successfully!")
|
1193 |
+
}
|
1194 |
+
})
|
1195 |
+
|
1196 |
}
|
1197 |
|
1198 |
# Run the application
|