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

207 lines
8.0 KiB
Plaintext

GLOBALS "veprgb000.4gl"
DEFINE psimbolo CHAR(10)
MAIN
DEFER INTERRUPT
CALL ARG_VAL(1) RETURNING usuarios
CALL ARG_VAL(2) RETURNING clave
CALL ARG_VAL(3) RETURNING impresor
# LET usuarios = "jsoto"
# LET clave="lmmjvsd2009"
CONNECT TO "smarmotech" USER usuarios USING clave
CALL startlog("veprrp049.log")
SELECT a.* INTO p_companias.* FROM companias a
CALL impresion()
END MAIN
FUNCTION impresion()
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)
OPEN WINDOW w1 WITH FORM "vefmwd049"
INPUT BY NAME p_vetb50.cotizacion_no,historico
AFTER INPUT
IF int_flag THEN
CALL msg(2)
LET int_flag = false
EXIT PROGRAM
END IF
EXIT INPUT
END INPUT
--pregunta al usuario por la salida del reporte
# CALL selectOutput() RETURNING r_filename, r_output, preview
LET r_filename ='veprrp049.4rp'
LET r_output='PDF'
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
# CALL fgl_winmessage("veprrp049",r_output,"stop")
# CALL fgl_winmessage("veprrp049",preview,"stop")
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 "imprime"
IF historico = "N" THEN
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 "
ELSE
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 historicoMTECH.dbo.vetb00050 a,historicoMTECH.dbo.vetb00012 b,historicoMTECH.dbo.adtb00003 c,historicoMTECH.dbo.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 "
END IF
PREPARE comando FROM selec
EXECUTE comando USING p_vetb50.cotizacion_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
IF historico = "N" THEN
LET selec =
"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 "
ELSE
LET selec =
"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 historicoMTECH.dbo.vetb00051 a,historicoMTECH.dbo.prtb00016 b,historicoMTECH.dbo.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 "
END IF
PREPARE comando1 FROM selec
DECLARE busca_cot CURSOR FOR comando1
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.*,nombre_Area,descrip2,medida)
END FOREACH
FINISH REPORT imprimeO
ELSE
EXIT PROGRAM
END IF
END FUNCTION
REPORT imprimeO(y,z,xnombre_a,xnombre_p,xmedida)
DEFINE z RECORD like vetb00051.*,
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. "
BEFORE GROUP OF z.area
LET total_area = 0
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
PRINTX p_companias.*,y.*,z.*,bruto,descuento,neto,total_area,
etiqueta,etiqueta2,etiqueta3,etiqueta4,etiqueta5,nombre_ciudad,
nombre_vend,xnombre_a,xnombre_p,xmedida,xtotal_p,
condicion.descrip,psimbolo,condicion.descrip
AFTER GROUP OF z.area
LET total_area = GROUP SUM(z.cantidad*z.precio)
PRINTX total_area,psimbolo
END REPORT