119 lines
4.5 KiB
Plaintext
119 lines
4.5 KiB
Plaintext
|
|
DEFINE data RECORD
|
|
categoria VARCHAR(50),
|
|
mes VARCHAR(20),
|
|
cuenta VARCHAR(20),
|
|
descripcion VARCHAR(40),
|
|
valor,presupuesto DEC(12,2)
|
|
END RECORD,
|
|
hand om.SaxDocumentHandler,
|
|
r_filename VARCHAR(40),
|
|
r_output VARCHAR(5),
|
|
preview BOOLEAN
|
|
|
|
MAIN
|
|
|
|
CONNECT TO "smarmotech" USER 'jsoto' USING 'lmmjvsd2014'
|
|
|
|
CALL setupreporte()
|
|
CALL runnreport()
|
|
END MAIN
|
|
FUNCTION setupreporte()
|
|
LET r_filename = 'graficas.4rp'
|
|
LET r_output = "SVG"
|
|
LET preview = TRUE
|
|
IF fgl_reporte_commitsettings(r_filename) THEN
|
|
END IF
|
|
END FUNCTION
|
|
FUNCTION runreport(hand)
|
|
DEFINE
|
|
hand om.SaxDocumentHandler
|
|
LET r_filename = 'graficas'
|
|
LET hand = configureReport(r_filename || '.4rp', 'SVG', TRUE)
|
|
DECLARE busca_data CURSOR FOR
|
|
SELECT 'Gastos',a.mes,a.cuenta,a.descripcion,SUM(a.balance),a.presupuesto
|
|
FROM vwanalitico a
|
|
WHERE a.ano = 2020 AND a.numero_mes <= 10 AND a.codigodepartamento = 2300 AND a.control = '7'
|
|
GROUP BY a.mes,a.cuenta,a.descripcion
|
|
|
|
START REPORT report_all TO XML HANDLER hand
|
|
FOREACH busca_data INTO data.*
|
|
OUTPUT TO REPORT report_all(data.*)
|
|
IF fgl_report_getErrorStatus() THEN
|
|
DISPLAY "FGL: STOPPING REPORT, msg=\"",fgl_report_getErrorString(),"\""
|
|
EXIT FOREACH
|
|
END IF
|
|
END FOREACH
|
|
FINISH REPORT report_all
|
|
DISPLAY "Produced "||fgl_report_getTotalNumberOfPages()||" page(s)"
|
|
|
|
CLOSE busca_data
|
|
END FUNCTION
|
|
FUNCTION configureReport(filename, outputformat, preview)
|
|
DEFINE
|
|
filename STRING,
|
|
outputformat STRING,
|
|
preview INTEGER,
|
|
retval INTEGER,
|
|
fieldNames STRING,
|
|
renderingHints om.SaxAttributes,
|
|
GREDIR STRING
|
|
|
|
-- load the 4rp file
|
|
IF filename.getIndexOf("Generic List",1)>0 THEN
|
|
IF NOT fgl_report_loadCurrentSettings(NULL) THEN
|
|
EXIT PROGRAM
|
|
END IF
|
|
CALL promptForFieldsToPrint("OrderReport.rdd","report_all_orders") RETURNING retval,fieldNames
|
|
IF NOT retval THEN
|
|
RETURN NULL
|
|
END IF
|
|
IF filename.getIndexOf("New Generic List",1)>0 THEN
|
|
CALL fgl_report_setAutoformatType("NEW LIST")
|
|
IF filename!="New Generic List.4rp" THEN
|
|
LET renderingHints=om.saxAttributes.create()
|
|
LET GREDIR=fgl_getenv("GREDIR")
|
|
CALL renderingHints.addAttribute("fglAutoformatTemplateURL",GREDIR||"/templates/"||filename.subString(18,filename.getLength()-4))
|
|
CALL renderingHints.addAttribute("fglAutoformatOrganizationName","Four Js Development Tools")
|
|
CALL renderingHints.addAttribute("fglAutoformatKeyText"," ")
|
|
CALL renderingHints.addAttribute("fglAutoformatSelectionText","Sorted by Customers and Orders")
|
|
CALL renderingHints.addAttribute("fglAutoformatPrintingInformationText","Revenue List")
|
|
CALL fgl_report_setRenderingHints(renderingHints)
|
|
CALL fgl_report_setPageMargins("1.5cm","1.5cm","1.5cm","1.5cm")
|
|
END IF
|
|
ELSE
|
|
CALL fgl_report_setAutoformatType("FLAT LIST")
|
|
END IF
|
|
CALL fgl_report_configureAutoformatOutput(NULL,8,NULL,"Order List",fieldNames,NULL)
|
|
CALL fgl_report_configurePageSize("a4length","a4width")
|
|
CALL fgl_report_configureXLSDevice(NULL,NULL,FALSE,NULL,NULL,NULL,TRUE) #preserve spaces and merge pages in XLS output
|
|
CALL fgl_report_setTitle("Order List")
|
|
ELSE
|
|
CALL promptForPivotDialogIfAny(filename,"6,2","4,0,2") RETURNING retval, controlBlock.* #Zip code, Unitprice and Unitcost by Product category and Shipping area
|
|
IF NOT retval THEN
|
|
RETURN NULL
|
|
END IF
|
|
IF NOT fgl_report_loadCurrentSettings(filename) THEN
|
|
EXIT PROGRAM
|
|
END IF
|
|
END IF
|
|
|
|
-- change some parameters
|
|
IF filename == "OrderLabels.4rp" THEN
|
|
CALL fgl_report_selectLogicalPageMapping("labels")
|
|
CALL fgl_report_setPaperMargins("5mm", "5mm", "4mm", "4mm")
|
|
CALL fgl_report_configureLabelOutput("a4width", "a4length", NULL, NULL, 2, 6)
|
|
END IF
|
|
CALL fgl_report_selectDevice(outputformat)
|
|
CALL fgl_report_selectPreview(preview)
|
|
|
|
IF outputformat=="Browser" AND preview THEN
|
|
CALL ui.Interface.frontCall( "standard", "launchurl", [fgl_report_getBrowserURL()], [] )
|
|
END IF
|
|
|
|
-- use the report
|
|
RETURN fgl_report_commitCurrentSettings()
|
|
|
|
END FUNCTION
|
|
|