Commit inicial: fuentes MBS ERP (Genero 6) + .gitignore + docs/SETUP_PC_MBS.md
This commit is contained in:
@@ -0,0 +1,266 @@
|
||||
IMPORT os
|
||||
GLOBALS "ipprgb000.4gl"
|
||||
DEFINE rcol,filename,idioma_office,fila_excel STRING,
|
||||
p_res,xi,prow SMALLINT,
|
||||
prog VARCHAR(10),
|
||||
imagenprinc BYTE,
|
||||
foldersimagenes STRING
|
||||
DEFINE result,resultdir,rutadir STRING
|
||||
|
||||
MAIN
|
||||
DEFER INTERRUPT
|
||||
CALL STARTLOG("iprp49.log")
|
||||
CALL ARG_VAL(1) RETURNING usuarios
|
||||
CALL ARG_VAL(2) RETURNING clave
|
||||
|
||||
CONNECT to "smarmotech" AS "SQL_C" USER usuarios USING clave
|
||||
--CONNECT to "smarmotech" USER usuarios USING clave
|
||||
CALL ipprrp049()
|
||||
END MAIN
|
||||
FUNCTION ipprrp049()
|
||||
DEFINE data RECORD
|
||||
categories VARCHAR(50),
|
||||
enable VARCHAR(10),
|
||||
family VARCHAR(50),
|
||||
parent VARCHAR(30),
|
||||
groups VARCHAR(30),
|
||||
brand,color VARCHAR(50),
|
||||
descripcion_config_en_US,descripcion_config_es_ES,description_en_US,
|
||||
description_es_ES,image_1_dcm,image_conf,name_en_US,name_es_ES
|
||||
STRING,
|
||||
cod_n,cod_grupo,cod_tipo,cod_Sec INT,
|
||||
nombre_file_foto STRING,
|
||||
codid INT,
|
||||
precio FLOAT,
|
||||
sku VARCHAR(30)
|
||||
|
||||
END RECORD
|
||||
DEFINE rec RECORD
|
||||
path STRING,
|
||||
name STRING,
|
||||
wildcards STRING,
|
||||
caption STRING
|
||||
END RECORD
|
||||
DEFINE rec1 RECORD
|
||||
path STRING,
|
||||
caption STRING
|
||||
END RECORD
|
||||
|
||||
OPEN WINDOW w1 WITH FORM "ipfmrp049"
|
||||
INPUT BY NAME idioma_office
|
||||
CONSTRUCT criterio ON b.categoria FROM idcategoria
|
||||
ON ACTION imagenes
|
||||
IF filename IS NULL THEN
|
||||
CALL fgl_winmessage("INFO","DEBE BUSCAR EL TEMPLATE","INFO")
|
||||
CONTINUE CONSTRUCT
|
||||
END IF
|
||||
LET rec1.path = "/tmp"
|
||||
LET rec1.caption = "Select directory"
|
||||
CALL ui.Interface.frontCall("standard","openDir",[rec1.*],[resultdir])
|
||||
|
||||
IF resultdir IS NULL THEN
|
||||
CALL fgl_winmessage("INFO","No directory fue seleccionado.","INFO")
|
||||
EXIT CONSTRUCT
|
||||
ELSE
|
||||
DISPLAY BY NAME resultdir
|
||||
END IF
|
||||
BEFORE CONSTRUCT
|
||||
CALL otcategorias("CONSTRUCT")
|
||||
|
||||
ON ACTION buscarfile ATTRIBUTE(TEXT="Buscar Archivo")
|
||||
|
||||
LET rec.path = "./"
|
||||
LET rec.name = "excel files"
|
||||
LET rec.wildcards = "*.xls *.xlsx"
|
||||
LET rec.caption = "Open file"
|
||||
CALL ui.Interface.frontCall("standard","openFile",[rec.*],[result])
|
||||
|
||||
IF idioma_office = "E" THEN
|
||||
LET fila_excel = "F"
|
||||
ELSE
|
||||
LET fila_excel = "R"
|
||||
END IF
|
||||
|
||||
LET filename = result
|
||||
CALL ui.Interface.frontCall("standard","shellexec", [filename], [p_res] )
|
||||
CALL chqDdeError(p_res,"shellexec "||filename)
|
||||
|
||||
DISPLAY BY NAME filename
|
||||
ON ACTION procesa
|
||||
|
||||
CALL ui.Interface.frontCall("WINDDE","DDEConnect", [prog,filename], [p_res] )
|
||||
CALL chqDdeError(p_res,"DDEConnect "||filename)
|
||||
|
||||
CALL ui.Interface.refresh()
|
||||
IF filename IS NULL OR LENGTH(filename) < 11 THEN
|
||||
CALL fgl_winmessage("INFO","EL FILE PARA IMPORTAR LA DATA NO SE HA ESPECIFICADO O EL NOMBRE ES MUY CORTO","INFO")
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
LET selec =
|
||||
"select b.descripcion_esp as categoria,'1',d.descripcion as familia,' ',' ',c.descripcion as marca,
|
||||
' ',c.detalle_us,c.detalle_esp,a.descripcion_us,a.descripcion_user,' ',' ',a.descripcion_us,a.descripcion,
|
||||
a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,a.nombre_file_foto,a.codid
|
||||
FROM iptb00016 a,categorias b,
|
||||
brand c,familia d
|
||||
WHERE a.id_categoria = b.id_categoria and a.id_brand = c.id_brand and
|
||||
a.id_familia = d.id_familia
|
||||
"
|
||||
{"select b.descripcion_esp as categoria,'1',d.descripcion as familia,a.descripcion_us,a.propiedades,c.descripcion as marca,
|
||||
a.propiedades1,a.descripcion,a.descripcion_user,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec
|
||||
FROM iptb00016 a,categorias b,
|
||||
brand c,familia d
|
||||
WHERE a.id_categoria = b.id_categoria and a.id_brand = c.id_brand and
|
||||
a.id_familia = d.id_familia
|
||||
"}
|
||||
IF filename IS NULL THEN
|
||||
CALL fgl_winmessage("INFO","DEBE BUSCAR EL TEMPLATE","INFO")
|
||||
CONTINUE CONSTRUCT
|
||||
END IF
|
||||
IF resultdir IS NULL THEN
|
||||
CALL fgl_winmessage("INFO","DEBE ELEGIR EL FOLDER PARA LA GALERIA DE FOTOS","INFO")
|
||||
CONTINUE CONSTRUCT
|
||||
END IF
|
||||
PREPARE comando FROM selec
|
||||
DECLARE busca CURSOR FOR comando
|
||||
|
||||
LET prow = 2
|
||||
|
||||
|
||||
FOREACH busca INTO data.*
|
||||
LET data.sku = data.cod_n USING "&&&&","-",data.cod_grupo USING "&&&&","-",
|
||||
data.cod_tipo USING "&&&&","-",data.cod_sec USING "&&&&&&&"
|
||||
LET rutadir = resultdir CLIPPED,"/",data.sku CLIPPED,'.jpg'
|
||||
|
||||
CALL guardafoto(data.codid,rutadir)
|
||||
|
||||
LET rcol = "C1"
|
||||
LET xi = prow
|
||||
CALL pru_new_dde(data.sku,rcol,xi,fila_excel,filename,'EXCEL')
|
||||
|
||||
LET rcol = "C2"
|
||||
LET xi = prow
|
||||
CALL pru_new_dde(data.categories,rcol,xi,fila_excel,filename,'EXCEL')
|
||||
|
||||
LET rcol = "C3"
|
||||
LET xi = prow
|
||||
CALL pru_new_dde(data.enable,rcol,xi,fila_excel,filename,'EXCEL')
|
||||
|
||||
LET rcol = "C4"
|
||||
LET xi = prow
|
||||
CALL pru_new_dde(data.family,rcol,xi,fila_excel,filename,'EXCEL')
|
||||
|
||||
LET rcol = "C5"
|
||||
LET xi = prow
|
||||
CALL pru_new_dde(data.parent,rcol,xi,fila_excel,filename,'EXCEL')
|
||||
|
||||
LET rcol = "C6"
|
||||
LET xi = prow
|
||||
CALL pru_new_dde(data.brand,rcol,xi,fila_excel,filename,'EXCEL')
|
||||
|
||||
|
||||
LET rcol = "C7"
|
||||
LET xi = prow
|
||||
CALL pru_new_dde(data.color,rcol,xi,fila_excel,filename,'EXCEL')
|
||||
|
||||
LET rcol = "C8"
|
||||
LET xi = prow
|
||||
CALL pru_new_dde(data.descripcion_config_en_US,rcol,xi,fila_excel,filename,'EXCEL')
|
||||
|
||||
LET rcol = "C9"
|
||||
LET xi = prow
|
||||
CALL pru_new_dde(data.descripcion_config_es_ES,rcol,xi,fila_excel,filename,'EXCEL')
|
||||
|
||||
LET rcol = "C10"
|
||||
LET xi = prow
|
||||
CALL pru_new_dde(data.description_en_US,rcol,xi,fila_excel,filename,'EXCEL')
|
||||
|
||||
LET rcol = "C11"
|
||||
LET xi = prow
|
||||
CALL pru_new_dde(data.description_es_ES,rcol,xi,fila_excel,filename,'EXCEL')
|
||||
|
||||
LET rcol = "C12"
|
||||
LET xi = prow
|
||||
CALL pru_new_dde(data.name_en_US,rcol,xi,fila_excel,filename,'EXCEL')
|
||||
|
||||
|
||||
LET rcol = "C14"
|
||||
LET xi = prow
|
||||
CALL pru_new_dde(rutadir,rcol,xi,fila_excel,filename,'EXCEL')
|
||||
|
||||
CALL galeria(data.codid)
|
||||
|
||||
LET prow = prow + 1
|
||||
|
||||
END FOREACH
|
||||
IF prow < 3 THEN
|
||||
CALL fgl_winmessage("INFO","NO EXISTEN INFORMACIONES CON ESTA CONDICION","INFO")
|
||||
END IF
|
||||
AFTER CONSTRUCT
|
||||
|
||||
IF int_flag THEN
|
||||
CALL fgl_Winmessage("INFO","OPERACION CANCELADA","INFO")
|
||||
LET int_flag = FALSE
|
||||
EXIT CONSTRUCT
|
||||
END IF
|
||||
EXIT CONSTRUCT
|
||||
END CONSTRUCT
|
||||
|
||||
CLOSE WINDOW w1
|
||||
END FUNCTION
|
||||
FUNCTION guardafoto(idcod,ruta)
|
||||
DEFINE bfoto BYTE,
|
||||
idcod INT,
|
||||
ruta,nombrefile,ret STRING
|
||||
|
||||
LOCATE bfoto IN MEMORY
|
||||
|
||||
SELECT a.foto INTO bfoto FROM iptb00016 a
|
||||
WHERE a.codid = idcod
|
||||
|
||||
IF os.Path.exists(ruta) THEN
|
||||
CALL os.Path.delete(ruta) RETURNING ret
|
||||
|
||||
END IF
|
||||
CALL bfoto.writeFile(ruta)
|
||||
FREE bfoto
|
||||
END FUNCTION
|
||||
|
||||
FUNCTION galeria(xidcod)
|
||||
DEFINE xidcod,i,col INT,
|
||||
arrgal DYNAMIC ARRAY OF RECORD
|
||||
nombre_file STRING,
|
||||
imagen BYTE
|
||||
END RECORD,
|
||||
rutadirgal,ret STRING
|
||||
|
||||
DECLARE busca_gal CURSOR FOR
|
||||
SELECT a.nombre_file,a.imagen FROM iptb00018 a
|
||||
WHERE a.codid = xidcod
|
||||
LET i = 1
|
||||
LET rutadirgal = resultdir CLIPPED,"/galeria"
|
||||
IF os.Path.exists(rutadirgal) THEN
|
||||
ELSE
|
||||
CALL os.Path.mkdir(rutadirgal) RETURNING ret
|
||||
END IF
|
||||
LOCATE arrgal[i].imagen IN MEMORY
|
||||
LET col = 15
|
||||
FOREACH busca_gal INTO arrgal[i].*
|
||||
|
||||
LET rutadir = rutadirgal CLIPPED,"/",arrgal[i].nombre_file
|
||||
DISPLAY xidcod," ruta galeria ",rutadir
|
||||
CALL arrgal[i].imagen.writeFile(rutadir)
|
||||
|
||||
LET rcol = "C",col USING "<<<"
|
||||
LET xi = prow
|
||||
CALL pru_new_dde(rutadir,rcol,xi,fila_excel,filename,'EXCEL')
|
||||
|
||||
FREE arrgal[i].imagen
|
||||
# IF i < 7 THEN
|
||||
# EXIT FOREACH
|
||||
# END IF
|
||||
LET i = i +1
|
||||
LET col = col + 1
|
||||
LOCATE arrgal[i].imagen IN MEMORY
|
||||
END FOREACH
|
||||
END FUNCTION
|
||||
Reference in New Issue
Block a user