## Should work through 2020. Each month modify these two variables:
filename <- "CWD-aug-2020"
cutdate <- "2020-08-31"
## Monthly report going out:
library(hlt)
library(CWDsurveillance)
monthly_report <- monthly_report_df(cutdate = as.Date(cutdate))
CWDsurveillance::write_report(monthly_report,
path = file.path(Sys.getenv("path_to_t_disk"), "Falkenrapporter", paste0(filename, ".xlsx")),
sheetname = filename)
##
## Check against report without Ö-nummer
##
check <- check_missing_oe_nummer()
if(length(check) == 0) {
projectnum <- hlt::html_p("No unreported TSE cases in cervids without Ö-nummer in SVALA")
} else {
projectnum <- hlt::html_table(check, tfoot = FALSE)
hlt::tag_attr(projectnum) <- list(id = "table0",
class = "svatablegrayheader",
style = "overflow-x:auto;",
border = "0")
projectnum <- html_div(projectnum)
hlt::tag_attr(projectnum) <- list(style = "width:90%;text-align:center;overflow-x:auto;margin-left:auto;margin-right:auto;")
}
##
## Check for categories of protagningsorsak:
## Protagningsorsak
check <- check_provtagningsorsak()
if(is.null(check)) {
table_cat <- hlt::html_p("No cases with invalid Provtagningsorsak")
} else {
table_cat<- hlt::html_table(check, tfoot = FALSE)
hlt::tag_attr(table_cat) <- list(id = "table2",
class = "svatablegrayheader",
style = "width:100%;",
border = "0")
for(i in seq_len(length(table_cat$content[[2]]$content))) {
hlt::tag_attr(table_cat$content[[2]]$content[[i]]$content[[15]]) <- list(style = "background-color: #FFFBCC")
hlt::tag_attr(table_cat$content[[2]]$content[[i]]$content[[18]]) <- list(style = "background-color: #FFFBCC")
}
}
table_cat <- html_div(table_cat)
hlt::tag_attr(table_cat) <- list(style = "width:90%;text-align:center;overflow-x:auto;margin-left:auto;margin-right:auto;")
##
## Report to html table
##
table_pts<- hlt::html_table(monthly_report, tfoot = FALSE)
hlt::tag_attr(table_pts) <- list(id = "table3",
class = "svatablegrayheader",
style = "width:100%;",
border = "0")
table_pts <- html_div(table_pts, class = "free dragscroll wrap")
hlt::tag_attr(table_pts) <- list(style = "width:90%;text-align:center;overflow-x:auto;margin-left:auto;margin-right:auto;")
##
## Put tables in html page
##
head <- hlt::html_head(hlt::html_meta(charset="utf-8") +
hlt::html_meta("http-equiv" = "x-ua-compatible", content = "IE=edge") +
hlt::html_meta(NAME = "ROBOTS", CONTENT = "NOINDEX, NOFOLLOW") +
hlt::html_link(rel="stylesheet", href="https://old.sva.se/assets/css/main.css") +
hlt::html_style(c(" /**/",
" /*First reset the style of the td element and then color the rows*/",
" /**/",
" .svatablegrayheader th {",
" font-weight: bold;",
" }",
" .svatablegrayheader td {",
" background-color: transparent;",
" }",
" .wrap {",
" overflow: auto;",
" max-height: 800px;",
" }")) +
hlt::html_script(content = "",
type = "text/javascript",
charset = "utf8",
src = "dragscroll.js") +
hlt::html_script(content = c("window.onload=function(){",
" var userSelection = document.getElementsByClassName('wrap');",
" for(let i = 0; i < userSelection.length; i++) {",
" userSelection[i].addEventListener('scroll',function(){",
" var translate = 'translate(0,'+this.scrollTop+'px)';",
" const allTh = this.querySelectorAll('th');",
" for( let i=0; i < allTh.length; i++ ) {",
" allTh[i].style.transform = translate;",
" }",
" })",
" }",
"}")))
page <- hlt::html_html(
hlt::html_comment(paste("Page generated with 'hlt' version:", packageVersion("hlt"), "svamap version:", packageVersion("svamap"), "at:",Sys.time())) +
head +
hlt::html_body(list(html_H1(paste("<br>CWD data monthly report - ", filename, "<br>Report produced: ", format(Sys.time(), "%d-%m-%Y %H:%M:%S"))),
html_H2("<br>Cases that do not have Ö-nummer"),
projectnum,
html_H2("<br>Cases that have a 'Provtagningsorsak' that is invalid"),
html_p("These cases have a mismatch between 'Protagningsorsak' and 'Category' or have a Provtagningsorsak that is not in the list of valid options.<br>"),
table_cat,
html_H2(paste0("<br>Cases that will be reported(<a href = 'file://sva.se/upp/Temp/Falkenrapporter/", filename, ".xlsx' download>Excel Version</a>)")),
html_p("These cases are going to be reported to SJV this month.<br>"),
table_pts), style = "margin-bottom: 50px;"))
tab <- tempfile()
capture.output(file = tab, print(page))
file.copy(tab, file.path(Sys.getenv("path_to_ESS_webpages"), "CWD/monthly_report.html"), overwrite = TRUE)
file.copy(system.file("extdata/dragscroll.js", package = "CWDsurveillance"),
file.path(Sys.getenv("path_to_ESS_webpages"), "CWD/"), overwrite = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.