Files
MBS/PROYECTO/otrodir/dashboard.4gl
T

97 lines
3.6 KiB
Plaintext

DEFINE usuarios,xclave VARCHAR(50),
ano,pmes SMALLINT,
gastos RECORD
categoria VARCHAR(20),
numero_mes SMALLINT,
mes VARCHAR(30),
cuenta_no VARCHAR(20),
descripcion VARCHAR(100),
balance_inicial,actividad,balance_final,presupuesto DEC(12,2),
departamento INT,
titulo_departamento VARCHAR(100)
END RECORD
MAIN
LET usuarios = 'jsoto'
LET xclave = 'lmmjvsd2014'
CONNECT TO "smarmotech" USER usuarios USING xclave
CALL dashboard(usuarios,xclave)
END MAIN
FUNCTION dashboard(usuario,clave)
DEFINE usuario,clave VARCHAR(50),
pdepartamento,idx,xmes INT,
ptitulo_depto VARCHAR(100),
handler om.SaxDocumentHandler, -- return value from fgl_report_commitCurrentSettings()
r_filename STRING, -- filename of Report Design Document including .4rp extension
r_output STRING, -- output format option
preview INTEGER -- TRUE/FALSE, to set preview option
SELECT a.departamento, b.nom_dpto INTO pdepartamento,ptitulo_depto
FROM seg0001 a,adtb00001 b WHERE a.usuario = usuario AND
a.departamento = b.departamento
LET gastos.titulo_departamento = ptitulo_depto
DISPLAY "departamento ",pdepartamento
LET ano = YEAR(TODAY)
LET pmes =3 # MONTH(TODAY)
# GASTOS
DECLARE busca_gastos CURSOR FOR
SELECT 'Gastos',a.numero_mes,a.mes,a.cuenta,a.descripcioncuenta,
SUM(a.debito-a.credito),SUM(a.balance),
ISNULL(SUM(a.presupuesto),0)
FROM vwanalitico a
WHERE a.ano = ano AND
a.numero_mes <= pmes AND
a.codigodepartamento = pdepartamento AND
a.control = 7
GROUP BY a.numero_mes,a.mes,a.cuenta,a.descripcioncuenta
{ UNION
SELECT 'Presupuesto',a.numero_mes,a.mes,a.cuenta,a.descripcioncuenta,ISNULL(SUM(b.valor),0),'0',ISNULL(SUM(b.valor),0)
FROM vwanalitico a,pgtb00003 b
WHERE a.ano = ano AND
a.numero_mes <= pmes AND
a.codigodepartamento = pdepartamento AND
a.codigodepartamento = b.departamento AND
a.cuenta = b.cuenta_no AND
a.control = 7
GROUP BY a.numero_mes,a.mes,a.cuenta,a.descripcioncuenta
}
LET r_filename = 'dashboard.4rp'
LET r_output = 'SVG'
LET preview = 1
LET idx = 1
FOREACH busca_gastos INTO gastos.categoria,gastos.numero_mes,gastos.mes, gastos.cuenta_no,
gastos.descripcion,
gastos.actividad,gastos.balance_final,gastos.presupuesto
IF idx = 1 THEN
IF fgl_report_loadCurrentSettings(r_filename) THEN
CALL fgl_report_selectDevice(r_output) -- changing default
CALL fgl_report_selectPreview(preview) -- changing default
LET handler = fgl_report_commitCurrentSettings() -- commit changes
START REPORT pizzarra TO XML HANDLER HANDLER
ELSE
EXIT PROGRAM
END IF
END IF
OUTPUT TO REPORT pizzarra()
LET idx = 1
END FOREACH
FINISH REPORT pizzarra
END FUNCTION
REPORT pizzarra()
DEFINE nombre_cia VARCHAR(100),
kmes INT
FORMAT
FIRST PAGE HEADER
SELECT a.nombre INTO nombre_cia FROM companias a
ON EVERY ROW
PRINTX nombre_cia,gastos.cuenta_no,gastos.mes,gastos.balance_final
END REPORT