237 lines
8.6 KiB
Plaintext
237 lines
8.6 KiB
Plaintext
GLOBALS "veprgb000.4gl"
|
|
DEFINE psimbolo CHAR(10),
|
|
instalador,soportes,xsoportes,vendedor_aux VARCHAR(200),
|
|
err char(30),
|
|
xtipo_tarjeta,xtarjeta VARCHAR(50),
|
|
kvendedor INT
|
|
DEFINE p_vetb501 RECORD LIKE vetb00050.*
|
|
|
|
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 imprimeO1 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,a.tipo_tarjeta,a.tarjeta,a.sec_vend_aux ",
|
|
"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_VETB501.cotizacion_no,P_VETB501.fecha,P_VETB501.nombre_cliente,P_VETB501.tipo_cliente,
|
|
P_VETB501.sec_cliente,P_VETB501.nombre_proyecto,P_VETB501.direccion_cliente,
|
|
P_VETB501.direccion_proyecto,P_VETB501.telefono_r,P_VETB501.telefono_o,
|
|
P_VETB501.contacto,P_VETB501.email,P_VETB501.tipo_precio,P_VETB501.beeper,
|
|
P_VETB501.celular,P_VETB501.prima,P_VETB501.fax1,P_VETB501.celular1,P_VETB501.fax,P_VETB501.plazo_entrega,
|
|
P_VETB501.comentario,condicion.descrip,P_VETB501.sec_vend,nombre_vend,P_VETB501.porc_itbi,
|
|
P_VETB501.total_bruto,P_VETB501.sub_total,P_VETB501.monto_desc,P_VETB501.monto_itbi,
|
|
P_VETB501.total_neto,P_VETB501.monto_dolar,psimbolo,condicion.descrip,P_VETB501.num_emp_inst,
|
|
xtipo_tarjeta,xtarjeta,kvendedor
|
|
|
|
IF STATUS = NOTFOUND THEN
|
|
call FGL_WINMESSAGE("QUERY","REGISTRO NO EXISTE","STOP")
|
|
RETURN
|
|
END IF
|
|
|
|
SELECT RTRIM(a.nom1_emp)+' '+RTRIM(ISNULL(a.apell1_emp,' ')) INTO instalador FROM adtb00003 a
|
|
WHERE a.num_emp = P_VETB501.num_emp_inst
|
|
|
|
# Vendedor Auxiliar
|
|
SELECT RTRIM(a.nom1_emp)+' '+RTRIM(ISNULL(a.apell1_emp,' ')) INTO vendedor_aux FROM adtb00003 a
|
|
WHERE a.num_emp = kvendedor
|
|
|
|
|
|
DECLARE soporte CURSOR FOR
|
|
SELECT RTRIM(a.nom1_emp)||' '||a.apell1_emp FROM adtb00003 a,vetb00093 b
|
|
WHERE b.cotizacion_no = P_VETB501.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 ",
|
|
" a.precio,a.porc_Desc,a.descripcion,c.unidad_med,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.area,a.secuencia,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec "
|
|
|
|
DISPLAY "cotiza ",xcotizacion_no
|
|
|
|
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,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
|
|
DISPLAY "data ",imagen
|
|
|
|
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 imprimeO1(P_VETB501.*,detalle.*,descrip2,medida,etiqueta_cotiza,fila)
|
|
|
|
END FOREACH
|
|
FINISH REPORT imprimeO1
|
|
|
|
|
|
ELSE
|
|
EXIT PROGRAM
|
|
END IF
|
|
RETURN r_output
|
|
END FUNCTION
|
|
|
|
REPORT imprimeO1(y,z,xnombre_p,xmedida,xetiqueta,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_VETB501.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
|
|
IF instalador IS NULL THEN
|
|
LET instalador='NO TIENE'
|
|
END IF
|
|
|
|
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,
|
|
instalador,xtipo_tarjeta,xtarjeta,vendedor_aux
|
|
|
|
|
|
AFTER GROUP OF z.area
|
|
LET total_area = GROUP SUM(z.cantidad*z.precio)
|
|
|
|
PRINTX total_area
|
|
|
|
END REPORT
|