Files
DECOMARMOL/PROYECTO/vedir/veprrp049_1.4gl
T
2026-09-22 20:38:51 -04:00

219 lines
7.9 KiB
Plaintext

GLOBALS "veprgb000.4gl"
DEFINE psimbolo CHAR(10),
instalador,soportes,xsoportes VARCHAR(200),
err char(30)
FUNCTION impresion(xcotizacion_no,r_filename,r_output,xcuenta_item,etiqueta_cotiza)
DEFINE detalle RECORD
area VARCHAR (60),
cod_n INT,
cod_grupo INT,
cod_tipo INT,
cod_sec INT,
descripcion CHAR(80),
cantidad_1 DEC(12,5),
cantidad DEC(12,5),
precio DEC(12,2),
porc_desc DEC(12,2),
nombre_file CHAR(50)
END RECORD,
imagen BYTE,
fila smallint
DEFINE 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
pvetb51 RECORD LIKE vetb00051.*,
historico CHAR(1),
xcuenta_item smallint,
xcotizacion_no INT,
etiqueta_cotiza CHAR(30)
SET CONNECTION "MSSQL"
--pregunta al usuario por la salida del reporte
# CALL selectOutput() RETURNING r_filename, r_output, preview
LET preview = TRUE
-- configure report engine; the functions prefixed fgl that are called here are part of the GRW API
IF fgl_report_loadCurrentSettings(r_filename) THEN -- load the .4rp file
# CALL fgl_report_selectDevice(r_output) -- changing default
# CALL fgl_report_selectPreview(preview) -- changing default
LET handler = fgl_report_commitCurrentSettings() -- commit changes
END IF
--run the report
IF handler IS NOT NULL THEN -- report engine was configured ok
START REPORT imprimeO TO XML HANDLER handler
LET selec =
"SELECT a.cotizacion_no,CONVERT(CHAR(10),a.fecha,103),a.nombre_cliente,a.tipo_cliente,a.sec_cliente, ",
"a.nombre_proyecto,a.direccion_cliente,a.direccion_proyecto,a.telefono_r, ",
"a.telefono_o,a.contacto,a.email,a.tipo_precio,a.beeper,a.celular, ",
"a.prima,a.fax1,a.celular1,a.fax,a.plazo_entrega, ",
"a.comentario,b.descrip,a.sec_vend,CAST(RTRIM(c.nom1_emp) AS VARCHAR) +' '+ CAST(RTRIM(c.apell1_emp) AS VARCHAR),a.porc_itbi, ",
"a.total_bruto,a.sub_total,a.monto_desc,a.monto_itbi,a.total_neto, ",
"a.monto_dolar,d.simbolo,b.descrip,a.num_emp_inst ",
"FROM vetb00050 a,vetb00012 b,adtb00003 c,vetb00061 d ",
"WHERE a.cotizacion_no = ? and ",
" a.cond_pago = b.cond_pago AND ",
" a.sec_Vend = c.num_Emp AND a.ventas = d.ventas "
PREPARE comando FROM selec
EXECUTE comando USING xcotizacion_no
INTO p_vetb50.cotizacion_no,p_vetb50.fecha,p_vetb50.nombre_cliente,p_vetb50.tipo_cliente,
p_vetb50.sec_cliente,p_vetb50.nombre_proyecto,p_vetb50.direccion_cliente,
p_vetb50.direccion_proyecto,p_vetb50.telefono_r,p_vetb50.telefono_o,
p_vetb50.contacto,p_vetb50.email,p_vetb50.tipo_precio,p_vetb50.beeper,
p_vetb50.celular,p_vetb50.prima,p_vetb50.fax1,p_vetb50.celular1,p_vetb50.fax,p_vetb50.plazo_entrega,
p_vetb50.comentario,condicion.descrip,p_vetb50.sec_vend,nombre_vend,p_vetb50.porc_itbi,
p_vetb50.total_bruto,p_vetb50.sub_total,p_vetb50.monto_desc,p_vetb50.monto_itbi,
p_vetb50.total_neto,p_vetb50.monto_dolar,psimbolo,condicion.descrip,p_vetb50.num_emp_inst
IF STATUS = NOTFOUND THEN
call FGL_WINMESSAGE("QUERY","REGISTRO NO EXISTE","STOP")
END IF
SELECT RTRIM(a.nom1_emp)+' '+RTRIM(ISNULL(a.apell1_emp,' ')) INTO instalador FROM adtb00003 a
WHERE a.num_emp = p_vetb50.num_emp_inst
DECLARE soporte CURSOR FOR
SELECT RTRIM(a.nom1_emp)||' '||a.apell1_emp FROM adtb00003 a,vetb00093 b
WHERE b.cotizacion_no = p_vetb50.cotizacion_no AND a.num_emp = b.sec_vend
LET soportes = NULL
LET idx = 1
FOREACH soporte INTO xsoportes
LET soportes = xsoportes CLIPPED
IF idx > 1 THEN
LET soportes = xsoportes CLIPPED,", ",soportes CLIPPED
END IF
LET idx = idx+1
END FOREACH
LET selec =
"SELECT a.descripcion_area,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec ",
" ,a.cantidad_1,a.cantidad, ",
" a.precio,a.porc_Desc,a.descripcion,c.unidad_med,a.foto_producto,a.secuencia ",
"FROM vetb00051 a,iptb00002 c ",
"WHERE a.cotizacion_no = ",xcotizacion_no," AND ",
" a.cod_n = c.cod_n AND ",
" a.cod_grupo = c.cod_grupo AND ",
" a.cod_tipo = c.cod_tipo AND ",
" a.cod_Sec = c.cod_sec ",
" ORDER BY a.secuencia "
PREPARE comando1 FROM selec
DECLARE busca_cot CURSOR FOR comando1
LOCATE imagen IN MEMORY
FOREACH busca_cot INTO detalle.area,detalle.cod_n,detalle.cod_grupo,
detalle.cod_tipo,detalle.cod_sec,detalle.cantidad_1,
detalle.cantidad,detalle.precio,detalle.porc_desc,
descrip2,medida,imagen,fila
IF descrip2 IS NULL THEN
SELECT a.descrip_esp INTO descrip2
FROM iptb00002 a
WHERE a.cod_n = pvetb51.cod_n AND
a.cod_grupo = pvetb51.cod_grupo AND
a.cod_tipo = pvetb51.cod_tipo AND
a.cod_sec = pvetb51.cod_sec
END IF
IF imagen IS NULL OR LENGTH(imagen) < 4 THEN
LET err = "imagen en blanco ",detalle.cod_sec USING "&&&&&"
# CALL fgl_winmessage("info",err,"info")
CALL imagen.readFile("fotodefault.jpg")
END IF
OUTPUT TO REPORT imprimeO(p_vetb50.*,detalle.*,descrip2,medida,etiqueta_cotiza,imagen,fila)
END FOREACH
FINISH REPORT imprimeO
ELSE
EXIT PROGRAM
END IF
RETURN r_output
END FUNCTION
REPORT imprimeO(y,z,xnombre_p,xmedida,xetiqueta,ximagen,xfila)
DEFINE ximagen BYTE
DEFINE z RECORD
area VARCHAR (60),
cod_n INT,
cod_grupo INT,
cod_tipo INT,
cod_sec INT,
descripcion CHAR(80),
cantidad_1 DEC(12,5),
cantidad DEC(12,5),
precio DEC(12,2),
porc_desc DEC(12,2),
nombre_file CHAR(50)
END RECORD,
xfila smallint,
y RECORD LIKE vetb00050.*,
xnombre_a,xetiqueta CHAR(30),
xnombre_p CHAR(50),
xmedida CHAR(3),
xtotal_p,bruto,descuento,neto,total_area DEC(12,2),
parea,pfecha,hora,etiqueta,etiqueta1,etiqueta2,etiqueta3,etiqueta4,etiqueta5 CHAR(100),
xorden INT
OUTPUT
LEFT MARGIN 0
ORDER BY z.area,xfila,z.cod_n,z.cod_grupo,z.cod_tipo,z.cod_sec
FORMAT
PAGE HEADER
LET pfecha = TODAY USING "DD/MM/YYYY"
LET hora = TIME
LET etiqueta = "FORMA DE PAGO: ",condicion.descrip
LET etiqueta3 = "PLAZO ENTREGA: ",p_vetb50.plazo_entrega
LET etiqueta4 = "COMENTARIO: "
LET etiqueta5 = "Entre la empresa ",p_companias.nombre CLIPPED," de una parte y de la otra parte:"
LET etiqueta1 = "Las variaciones en las tonalidades y vetas se entienden como parte de la naturaleza de las piedras naturales."
LET etiqueta2 = " No somos responsables en las tardanzas en la entrega cuando esten sujetas a especificaciones de medidas y/o terminaciones. "
BEFORE GROUP OF z.area
LET total_area = 0
ON EVERY ROW
# BUSCA ORDEN
LET xorden = null
SELECT a.num_oc INTO xorden
FROM prtb00012 a
WHERE a.cotizacion_no = y.cotizacion_no AND a.status_t IS NULL
LET bruto = 0
LET descuento = 0
LET bruto = z.cantidad * z.precio
LET descuento = (z.cantidad*z.precio*(z.porc_Desc/100))
LET xtotal_p = bruto - descuento
LET y.sub_total = y.sub_total + y.monto_desc
PRINTX p_companias.*,y.*,z.*,bruto,descuento,neto,
etiqueta,etiqueta2,etiqueta3,etiqueta4,etiqueta5,nombre_ciudad,
nombre_vend,xnombre_p,xmedida,xtotal_p,
condicion.descrip,psimbolo,xorden,xetiqueta,soportes,ximagen,
instalador
AFTER GROUP OF z.area
LET total_area = GROUP SUM(z.cantidad*z.precio)
PRINTX total_area
END REPORT