You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					76 lines
				
				1.6 KiB
			
		
		
			
		
	
	
					76 lines
				
				1.6 KiB
			| 
											4 years ago
										 | #' dccb UI Function | ||
|  | #' | ||
|  | #' @description A shiny Module. | ||
|  | #' | ||
|  | #' @param id,input,output,session Internal parameters for {shiny}. | ||
|  | #' | ||
|  | #' @noRd  | ||
|  | #' | ||
|  | #' @importFrom shiny NS tagList  | ||
|  | mod_dccb_ui <- function(id){ | ||
|  |   ns <- NS(id) | ||
|  |   tagList( | ||
|  |     fluidRow( | ||
|  |       column( | ||
|  |         width = 6, | ||
|  |         fluidRow( | ||
|  |           # "Credits", | ||
|  |           mod_inbox_ui(ns("credit")) | ||
|  |         ) | ||
|  |          | ||
|  |       ), | ||
|  |       column( | ||
|  |         width = 6, | ||
|  |         fluidRow( | ||
|  |           # "Open", | ||
|  |           mod_inbox_ui(ns("debit")) | ||
|  |         ) | ||
|  |          | ||
|  |       ) | ||
|  |       ), | ||
|  |     fluidRow( | ||
|  |       column( | ||
|  |         width = 6, | ||
|  |         fluidRow( | ||
|  |           # "Contracts", | ||
|  |           mod_inbox_ui(ns("contracts")) | ||
|  |         ) | ||
|  |          | ||
|  |       ), | ||
|  |       column( | ||
|  |         width = 6, | ||
|  |         fluidRow( | ||
|  |           # "Business Partners", | ||
|  |           mod_inbox_ui(ns("bps")) | ||
|  |         ) | ||
|  |          | ||
|  |       ) | ||
|  |     ) | ||
|  |   ) | ||
|  | } | ||
|  |      | ||
|  | #' dccb Server Functions | ||
|  | #' | ||
|  | #' @noRd  | ||
|  | mod_dccb_server <- function(id, dat){ | ||
|  |   moduleServer( id, function(input, output, session){ | ||
|  |     ns <- session$ns | ||
|  |     credit<- sum(dat[dat$negative,]$amount) | ||
|  |     debit<- sum(dat[!dat$negative,]$amount) | ||
|  |     contracts<-length(unique(dat$contract_account)) | ||
|  |     bps<-length(unique(dat$business_partner)) | ||
|  |      | ||
|  |     mod_inbox_server("credit", ttl="Credit",val=paste0(round(credit/1000000), "M")) | ||
|  |     mod_inbox_server("debit",ttl="Open",val=paste0(round(debit/1000000), "M")) | ||
|  |     mod_inbox_server("contracts",ttl="Contracts",val=contracts) | ||
|  |     mod_inbox_server("bps",ttl="BPs",val=bps) | ||
|  |      | ||
|  |   }) | ||
|  | } | ||
|  |      | ||
|  | ## To be copied in the UI | ||
|  | # mod_dccb_ui("dccb_ui_1") | ||
|  |      | ||
|  | ## To be copied in the server | ||
|  | # mod_dccb_server("dccb_ui_1") |