From f52d5fa3dd38a2909ad4ba776ce1b259802fc5c3 Mon Sep 17 00:00:00 2001 From: Christian Oswald Date: Wed, 29 Apr 2026 08:31:24 +0200 Subject: [PATCH] contact feld und note(purpose) in buchungen_mod eintragen --- R/postings/buchungen_mod.R | 68 +++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/R/postings/buchungen_mod.R b/R/postings/buchungen_mod.R index 29293fa..9bf6c17 100755 --- a/R/postings/buchungen_mod.R +++ b/R/postings/buchungen_mod.R @@ -1,28 +1,38 @@ -# module_buchungen.R +## +## Datum : 2026-04-29_08-17 +## Name : Christian Oswald +## Datei : buchungen_mod.R +## Projekt : gemfin-shiny +## Kommentar: Modul für die Anzeige der Buchungen - praktisch Hauptformular +## +## * UI ---- buchungenUI <- function(id) { ns <- NS(id) tagList( useShinyjs(), + ## ** Tabelle ---- h3("Hauptbuchungen"), fluidRow( column(8, reactableOutput(ns("buchungen_table")), hr(), + ## ** Gegenbuchungen ---- h3("Details / Gegenbuchungen"), uiOutput(ns("details_table")) , - - - ), - + ), + ## ** Eingabefelder ---- column(4, selectizeInput(ns("contact"), label = "Kontakt", choices = get_contact_choices(conn), selected = NA, width = "100%"), textAreaInput(ns("note"), label = "Verwendungszweck", value = NA, width = "100%"), + + ## ** Anhänge ---- h3("Dateien"), uiOutput(ns("attachments_ui")), fileInput(ns("anhang"), NULL, multiple = TRUE, accept = c(".pdf", ".jpg", ".png", ".xlsx", ".docx"), width = "100%"), + ## ** Buttons ---- div( style = "display: flex; flex-direction: column; gap: 10px; align-items: flex-start;", @@ -39,12 +49,7 @@ buchungenUI <- function(id) { size = "sm", style = "material-flat", color = "success", block = TRUE, icon = icon("floppy-disk")), ) ) - ), - - - - - + ) ) } @@ -52,7 +57,7 @@ buchungenServer <- function(id, conn, r_global) { moduleServer(id, function(input, output, session) { ns <- session$ns - # ── Reactive Variablen ---- + ## ** Reactive Variablen ---- postings_data <- reactiveVal(read_buch_tabelle(conn)) sel_details <- reactiveVal(NULL) selected_trans_id <- reactiveVal(NULL) @@ -62,9 +67,8 @@ buchungenServer <- function(id, conn, r_global) { - # ── Filter ---- + ## ** Filter ---- aktiver_filter <- reactive(r_global$buchungen_filter) - gefilterte_daten <- reactive({ d <- postings_data() f <- aktiver_filter() @@ -79,8 +83,7 @@ buchungenServer <- function(id, conn, r_global) { else d }) - - # ── Haupttabelle rendern ---- + ## ** Haupttabelle rendern ---- output$buchungen_table <- renderReactable({ reset_trigger() f_reactable( @@ -91,15 +94,24 @@ buchungenServer <- function(id, conn, r_global) { filterable = TRUE, ) }) - + ## ** Auswahl anzeigen ---- sel <- reactive(getReactableState("buchungen_table", "selected")) observeEvent(sel(), ignoreInit = T, { + idwert <- gefilterte_daten()$id[sel()] + record <- read_posting(conn, idwert) + record_entry <- read_entry(conn, record$entry_id) + updateSelectizeInput(session, "contact", selected = record_entry$contact_id) +updateTextAreaInput(session, "note", value = record_entry$purpose) + + + + output$details_table <- renderUI({ req(sel()) - # Daten laden + ## *** Daten-Gegenbuchungen laden ---- df <- read_buch_entries(conn, gefilterte_daten()$entry_id[sel()]) sel_details(df) - + ## *** Gegenbuchungen rendern ---- rows <- lapply(1:nrow(df), function(ind) { fluidRow(class = "details-row", # HIER: Index an die ID hängen! @@ -116,8 +128,6 @@ buchungenServer <- function(id, conn, r_global) { }) tagList(rows) }) - - }) observeEvent(input$save_trans, { @@ -166,21 +176,19 @@ buchungenServer <- function(id, conn, r_global) { }) - # ── Anhänge ---- + ## ** Anhänge ---- output$attachments_ui <- renderUI({ req(sel_details()) entry_id <- - dbxSelect(conn, paste0("SELECT entry_id FROM postings WHERE id=", - sel_details()$id[1])) %>% pull - att <- dbxSelect(conn, paste0( - "SELECT * FROM attachments WHERE entry_id = ", entry_id - )) + dbxSelect(conn, paste0("SELECT entry_id FROM postings WHERE id=", sel_details()$id[1])) %>% + pull + att <- dbxSelect(conn, paste0("SELECT * FROM attachments WHERE entry_id = ", entry_id )) if (nrow(att) == 0) return(p("Keine Anhänge vorhanden.")) - + ## *** Anhänge anzeigen ---- tagList(lapply(seq_len(nrow(att)), function(i) { ext <- tools::file_ext(att$original_name[i]) filename <- paste0("attachments/", att$id[i], ".", ext) - + ## *** Anhang öffnen ---- observeEvent(input[[paste0("open_att_", att$id[i])]], { showModal(modalDialog( tags$iframe(src = filename, width = "100%", height = "600px", @@ -191,7 +199,7 @@ buchungenServer <- function(id, conn, r_global) { footer = modalButton("Schließen") )) }, ignoreInit = TRUE, once = FALSE) - + ## *** Buttons Anhänge ---- div( actionLink(ns(paste0("open_att_", att$id[i])), att$original_name[i]), actionLink(ns(paste0("del_att_", att$id[i])), "✕",