Files
MBS/PROYECTO/vedir/veprrp049_1 - Copy.4gl
T

185 lines
7.0 KiB
Plaintext

GLOBALS "veprgb000.4gl"
DEFINE psimbolo CHAR(10)
FUNCTION impresion(xcotizacion_no,r_filename,r_output,xitem)
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.*,
xcotizacion_no INTEGER,
xitem SMALLINT
LET p_vetb50.cotizacion_no = xcotizacion_no
--pregunta al usuario por la salida del reporte
# CALL selectOutput() RETURNING r_filename, r_output, preview
LET preview = true
LET r_output = "PDF"
-- 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
IF r_output = "PDF" OR r_output = "Image" THEN
CALL fgl_report_selectDevice(r_output) -- changing default
CALL fgl_report_selectPreview(preview) -- changing default
LET handler = fgl_report_commitCurrentSettings() -- commit changes
ELSE
RETURN r_output
EXIT PROGRAM
END IF
ELSE
EXIT PROGRAM
END IF
--run the report
IF handler IS NOT NULL THEN -- report engine was configured ok
START REPORT imprimeO TO "imprime"
{
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 ",
"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.fecha_entrega,p_vetb50.plazo_entrega,
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
IF STATUS = NOTFOUND THEN
call FGL_WINMESSAGE("QUERY","REGISTRO NO EXISTE","STOP")
END IF
DECLARE busca_cot CURSOR FOR
SELECT a.area,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec
,a.cantidad_1,a.cantidad,
a.precio,a.porc_Desc,b.nombre_area,c.descrip_esp,c.unidad_med
FROM vetb00051 a,prtb00016 b,iptb00002 c
WHERE a.cotizacion_no = p_vetb50.cotizacion_no AND
a.area = b.area_num 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
FOREACH busca_cot INTO pvetb51.area,pvetb51.cod_n,pvetb51.cod_grupo,
pvetb51.cod_tipo,pvetb51.cod_sec,pvetb51.cantidad_1,
pvetb51.cantidad,pvetb51.precio,pvetb51.porc_desc,
nombre_area,descrip2,medida
OUTPUT TO REPORT imprimeO(p_vetb50.*,pvetb51.*)
END FOREACH
}
FOR idx = 1 TO xitem
IF arr_cotiza[idx].cod_n is not null THEN
DISPLAY "cotizacion ",r_filename
OUTPUT TO REPORT imprimeO(p_vetb50.*,arr_cotiza[idx].*)
END IF
END FOR
FINISH REPORT imprimeO
ELSE
EXIT PROGRAM
END IF
RETURN r_output
END FUNCTION
REPORT imprimeO(y,z)
DEFINE z RECORD
# fila SMALLINT,
area LIKE vetb00051.area,
nombre_area CHAR(20),
cod_n LIKE vetb00051.cod_n,
cod_grupo LIKE vetb00051.cod_grupo,
cod_tipo LIKE vetb00051.cod_tipo,
cod_sec LIKE vetb00051.cod_sec,
nombre_p CHAR(50),
unidad CHAR(3),
cantidad_1 LIKE vetb00051.cantidad_1,
cantidad LIKE vetb00051.cantidad,
precio LIKE vetb00051.precio,
porc_desc LIKE vetb00051.porc_desc,
total_p DECIMAL(10,2)
END RECORD,
y RECORD LIKE vetb00050.*,
xnombre_a 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)
OUTPUT
LEFT MARGIN 0
ORDER BY z.area,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. "
SELECT a.descrip INTO condicion.descrip
FROM vetb00012 a
WHERE a.cond_pago = y.cond_pago
SELECT a.rnc INTO p_companias.rnc FROM companias a
BEFORE GROUP OF z.area
LET total_area = 0
SELECT a.nombre_area INTO xnombre_a
FROM prtb00016 a
WHERE a.area_num = z.area
SELECT a.simbolo INTO psimbolo FROM vetb00061 a
WHERE a.ventas = p_vetb50.ventas
ON EVERY ROW
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
IF y.email IS NULL THEN
LET y.email='NO TIENE'
END IF
PRINTX p_companias.*,y.*,z.*,bruto,descuento,neto,total_area,
etiqueta,etiqueta2,etiqueta3,etiqueta4,etiqueta5,nombre_ciudad,
nombre_vend,xnombre_a,xtotal_p,
condicion.descrip,psimbolo
AFTER GROUP OF z.area
LET total_area = GROUP SUM(z.cantidad*z.precio)- GROUP SUM((z.cantidad*z.precio*(z.porc_Desc/100)))
PRINTX total_area,psimbolo
END REPORT