304 lines
10 KiB
Plaintext
304 lines
10 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,
|
|
ximagen BYTE
|
|
|
|
FUNCTION impresion(data_imp,r_filename,r_output,xcuenta_item,etiqueta_cotiza)
|
|
|
|
|
|
DEFINE data_imp RECORD
|
|
cotizacion_no,tipo_cliente,sec_cliente INT,
|
|
fecha DATE,
|
|
sec_Vend INT,
|
|
direccion_cliente,nombre,contacto,nombre_proyecto,direccion_proyecto,nombre_ciudad,
|
|
nombre_vend,nombre_cliente VARCHAR(100),
|
|
rnc VARCHAR(11),
|
|
telefono_o,telefono_r,celular,celular1 VARCHAR(25),
|
|
email VARCHAR(100),
|
|
orden,cond_pago INT,
|
|
soportes,instalador,plazo_Entrega VARCHAR(100),
|
|
comentario VARCHAR(250),
|
|
sub_total,monto_desc,porc_itbis,neto,total_bruto,monto_itbis,total_neto DEC(12,2),
|
|
num_emp_int,vendedor_aux,bodega INT,
|
|
tbodega VARCHAR(100)
|
|
|
|
|
|
|
|
END RECORD
|
|
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,
|
|
|
|
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,
|
|
etiqueta_cotiza CHAR(30)
|
|
|
|
|
|
SET CONNECTION "MSSQL"
|
|
|
|
LET preview = TRUE
|
|
IF fgl_report_loadCurrentSettings(r_filename) THEN -- load the .4rp file
|
|
|
|
CALL fgl_report_selectDevice(r_output) -- changing default
|
|
|
|
|
|
LET handler = fgl_report_commitCurrentSettings() -- commit changes
|
|
END IF
|
|
# BODEGA
|
|
|
|
SELECT a.descripcion INTO data_imp.tbodega FROM intb00009 a WHERE a.cod_bodega = data_imp.bodega
|
|
|
|
|
|
IF handler IS NOT NULL THEN -- report engine was configured ok
|
|
|
|
START REPORT imprimeO TO XML HANDLER handler
|
|
|
|
|
|
SELECT RTRIM(a.nom1_emp)+' '+RTRIM(ISNULL(a.apell1_emp,' ')) INTO instalador FROM adtb00003 a
|
|
WHERE a.num_emp = data_imp.num_emp_int
|
|
|
|
# Vendedor Auxiliar
|
|
SELECT RTRIM(a.nom1_emp)+' '+RTRIM(ISNULL(a.apell1_emp,' ')) INTO vendedor_aux FROM adtb00003 a
|
|
WHERE a.num_emp = data_imp.vendedor_aux
|
|
|
|
SELECT a.descrip INTO condicion.descrip FROM vetb00012 a WHERE a.cond_pago = data_imp.cond_pago
|
|
|
|
DECLARE soporte CURSOR FOR
|
|
SELECT RTRIM(a.nom1_emp)||' '||a.apell1_emp FROM adtb00003 a,vetb00093 b
|
|
WHERE b.cotizacion_no = data_imp.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
|
|
# START REPORT otroimp TO XML HANDLER HANDLER #"temporal.txt"
|
|
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 = ",data_imp.cotizacion_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 ximagen 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,ximagen,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 ximagen IS NULL OR LENGTH(ximagen) < 4 THEN
|
|
LET err = "imagen en blanco ",detalle.cod_sec USING "&&&&&"
|
|
# CALL fgl_winmessage("info",err,"info")
|
|
CALL ximagen.readFile("fotodefault.jpg")
|
|
END IF
|
|
|
|
OUTPUT TO REPORT imprimeO(data_imp.*,detalle.*,descrip2,medida,etiqueta_cotiza,fila)
|
|
# OUTPUT TO REPORT otroimp(data_imp.*,detalle.*,descrip2,medida,etiqueta_cotiza,imagen,fila)
|
|
|
|
END FOREACH
|
|
FINISH REPORT imprimeO
|
|
# FINISH REPORT otroimp
|
|
|
|
|
|
ELSE
|
|
EXIT PROGRAM
|
|
END IF
|
|
RETURN r_output
|
|
END FUNCTION
|
|
|
|
REPORT imprimeO(y,z,xnombre_p,xmedida,xetiqueta,xfila)
|
|
|
|
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
|
|
cotizacion_no,tipo_cliente,sec_cliente INT,
|
|
fecha DATE,
|
|
sec_vend INT,
|
|
direccion_cliente,nombre,contacto,nombre_proyecto,direccion_proyecto,nombre_ciudad,
|
|
nombre_vend,nombre_cliente VARCHAR(100),
|
|
rnc VARCHAR(11),
|
|
telefono_o,telefono_r,celular,celular1 VARCHAR(25),
|
|
email VARCHAR(100),
|
|
orden,cond_pago INT,
|
|
soportes,instalador,plazo_entrega VARCHAR(100),
|
|
comentario VARCHAR(250),
|
|
sub_total,monto_desc,porc_itbis,neto,total_bruto,monto_itbis,total_neto DEC(12,2),
|
|
num_emp_int,vendedor_aux,bodega INT,
|
|
tbodega VARCHAR(100)
|
|
|
|
|
|
END RECORD,
|
|
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: ",y.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.simbolo INTO psimbolo FROM vetb00061 a,vetb00060 b WHERE a.ventas = b.ventas
|
|
AND b.tipo_cliente = y.tipo_cliente
|
|
|
|
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,ximagen,
|
|
instalador,xtipo_tarjeta,xtarjeta,vendedor_aux
|
|
|
|
|
|
AFTER GROUP OF z.area
|
|
# LET total_area = GROUP SUM(z.cantidad*z.precio)
|
|
LET total_area = GROUP SUM (z.cantidad*z.precio) -GROUP SUM(z.cantidad*z.precio*(z.porc_Desc/100))
|
|
PRINTX total_area
|
|
|
|
END REPORT
|
|
REPORT otroimp(y,z,xnombre_p,xmedida,xetiqueta,ximagen,xfila)
|
|
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
|
|
cotizacion_no,tipo_cliente,sec_cliente INT,
|
|
fecha DATE,
|
|
sec_vend INT,
|
|
direccion_cliente,nombre,contacto,nombre_proyecto,direccion_proyecto,nombre_ciudad,
|
|
nombre_vend,nombre_cliente VARCHAR(100),
|
|
rnc VARCHAR(11),
|
|
telefono_o,telefono_r,celular,celular1 VARCHAR(25),
|
|
email VARCHAR(100),
|
|
orden,cond_pago INT,
|
|
soportes,instalador,plazo_entrega VARCHAR(100),
|
|
comentario VARCHAR(250),
|
|
sub_total,monto_desc,porc_itbis,neto,total_bruto,monto_itbis,total_neto DEC(12,2),
|
|
num_emp_int,vendedor_aux INT
|
|
|
|
|
|
END RECORD,
|
|
xnombre_p CHAR(50),
|
|
xmedida CHAR(3),
|
|
xetiqueta CHAR(30),
|
|
|
|
pfecha,hora,etiqueta,etiqueta1,etiqueta2,etiqueta3,etiqueta4,etiqueta5 CHAR(100)
|
|
DEFINE ximagen BYTE
|
|
FORMAT
|
|
FIRST PAGE HEADER
|
|
LET pfecha = TODAY USING "DD/MM/YYYY"
|
|
LET hora = TIME
|
|
LET etiqueta = "FORMA DE PAGO: ",condicion.descrip
|
|
LET etiqueta3 = "PLAZO ENTREGA: ",y.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. "
|
|
|
|
ON EVERY ROW
|
|
PRINTX p_companias.*,y.*,z.*,pfecha,hora,etiqueta,etiqueta1,etiqueta2,etiqueta3,etiqueta4,etiqueta5
|
|
AFTER GROUP OF y.cotizacion_no
|
|
PRINT z.*
|
|
END REPORT |