Commit inicial: fuentes MBS ERP (Genero 6) + .gitignore + docs/SETUP_PC_MBS.md

This commit is contained in:
2026-08-18 20:59:52 -04:00
commit 454973e269
5978 changed files with 2664094 additions and 0 deletions
+135
View File
@@ -0,0 +1,135 @@
IMPORT util
IMPORT com
IMPORT os
IMPORT security
TYPE t_sync_cmd RECORD
oper STRING,
data STRING
END RECORD
DEFINE s, cmd,usuario,clave STRING
MAIN
CONNECT TO 'smarmotech' USER 'jsoto' USING 'lmmjvsd2014'
CALL categorias()
END MAIN
FUNCTION categorias()
DEFINE metodo,url,selec,ret,res STRING,
categoria DYNAMIC ARRAY OF RECORD
id INT,
NAME,
slug ,
parent,
description,
DISPLAY STRING,
IMAGE STRING,
menu_order INT,
COUNT INT,
links STRING,
self STRING,
collection STRING,
UP STRING
END RECORD
,
http_req com.HTTPRequest,
http_resp com.HTTPResponse,
data t_sync_cmd,
idx,idfamilia INT
LET url = 'https://shop.marmotech.com.do/wp-json/wc/v3/products/categories'
LET selec = "SELECT id_familia FROM familia WHERE descripcion like ? "
PREPARE buscaf FROM selec
LET selec = "UPDATE familia set parentcode = ?,code=? WHERE id_familia = ? "
PREPARE familia FROM selec
LET selec = "UPDATE categorias set code = ? where descripcion_esp = ? "
PREPARE dcategoria FROM selec
# LET data.oper = 'products/categories'
# LET data.data = util.JSON.stringify(categoria)
# LET cmd= util.JSON.stringify(data)
LET cmd = url CLIPPED,"?per_page=45"
# DISPLAY "cmd ",cmd
CALL sync_send_command(url,cmd) RETURNING ret,res
# DISPLAY "RESPUESTA ",ret," ",util.JSON.stringify(res)
CALL util.JSON.parse(res,categoria)
# DISPLAY "PARSEADA ",categoria.getLength()
FOR idx = 1 TO categoria.getLength()
LET categoria[idx].name = categoria[idx].name CLIPPED,'%'
DISPLAY "BUSCANDO LA CAT ",categoria[idx].NAME
EXECUTE buscaf INTO idfamilia USING categoria[idx].NAME
IF STATUS !=NOTFOUND THEN
EXECUTE familia USING categoria[idx].parent,categoria[idx].id, idfamilia
ELSE
DISPLAY "NO ENCONTRE LA CAT ",categoria[idx].NAME
END IF
# EXECUTE dcategoria USING categoria[idx].id,categoria[idx].name
# DISPLAY "familia ",categoria[idx].name," ID ",categoria[idx].ID, " parent ",categoria[idx].parent
END FOR
END FUNCTION
FUNCTION sync_send_command(url, cmd)
DEFINE url, cmd STRING
DEFINE result, tmp STRING
DEFINE http_req com.HTTPRequest
DEFINE http_resp com.HTTPResponse
LET usuario = "ck_f41ca9ba9ec888d82243a7c24717af625c26f834"
LET clave = "cs_dbd762cb45184e3badc5a114b8f4a30c19f114fc"
TRY LET http_req = com.HTTPRequest.Create(cmd)
CALL http_req.setAuthentication(usuario,clave,"Basic",NULL)
CALL http_req.setKeepConnection(TRUE)
# CALL http_req.setConnectionTimeout(40)
# CALL http_req.setTimeout(40)
CALL http_req.setMethod("GET")
CALL http_req.setCharset("UTF-8")
# CALL http_req.doTextRequest(cmd)
CALL http_req.doRequest()
LET http_resp=http_req.getResponse()
IF http_resp.getStatusCode() != 200 THEN
RETURN http_resp.getStatusCode(), http_resp.getStatusDescription()
END IF
LET tmp = http_resp.getStatusDescription()
IF (tmp == "OK" || tmp == "no error" ) THEN
RETURN -1, SFMT("HTTP request status description: %1 ",tmp)
END IF
LET result = http_resp.getTextResponse()
CATCH
RETURN -2, SFMT("HTTP request error: STATUS=%1 (%2)",STATUS,SQLCA.SQLERRM)
END TRY
RETURN 0, result
END FUNCTION
FUNCTION show_sync_err(msg)
DEFINE msg STRING
CALL fgl_winmessage(%"ERROR", msg, "exclamation")
END FUNCTION
FUNCTION b64_to_file(str_b64,f_sal)
DEFINE f_sal,str_b64,str_aux STRING
TRY
CALL security.Base64.SaveBinary(f_sal,str_b64)
CATCH
DISPLAY " data ",str_b64
LET str_aux="Unable to convert Base64 String to file :",STATUS
CALL fgl_winmessage("Error",str_aux,"stop")
END TRY
END FUNCTION
+103
View File
@@ -0,0 +1,103 @@
IMPORT util
IMPORT com
IMPORT os
IMPORT security
TYPE t_sync_cmd RECORD
oper STRING,
data STRING
END RECORD
DEFINE s, cmd,usuario,clave STRING
MAIN
CONNECT TO 'smarmotech' USER 'jsoto' USING 'lmmjvsd2014'
CALL categorias()
END MAIN
FUNCTION categorias()
DEFINE metodo,url,selec,ret,res STRING,
categoria RECORD
NAME,IMAGE STRING
END RECORD,
http_req com.HTTPRequest,
http_resp com.HTTPResponse,
data t_sync_cmd
LET url = 'https://shop.marmotech.com.do/wp-json/wc/v3/products/categories'
LET selec = "SELECT a.descripcion_esp FROM categorias a ORDER BY a.id_categoria"
PREPARE comando FROM selec
DECLARE busca_cat CURSOR FOR comando
LET data.oper = 'products/categories'
FOREACH busca_cat INTO categoria.*
LET data.data = util.JSON.stringify(categoria)
LET cmd= util.JSON.stringify(data)
LET cmd = url CLIPPED,"?name=",categoria.NAME CLIPPED
CALL sync_send_command(url,cmd) RETURNING ret,res
DISPLAY "RESPUESTA ",ret," ",res
END FOREACH
END FUNCTION
FUNCTION sync_send_command(url, cmd)
DEFINE url, cmd STRING
DEFINE result, tmp STRING
DEFINE http_req com.HTTPRequest
DEFINE http_resp com.HTTPResponse
LET usuario = "ck_f41ca9ba9ec888d82243a7c24717af625c26f834"
LET clave = "cs_dbd762cb45184e3badc5a114b8f4a30c19f114fc"
TRY LET http_req = com.HTTPRequest.Create(cmd)
CALL http_req.setAuthentication(usuario,clave,"Basic",NULL)
CALL http_req.setKeepConnection(TRUE)
CALL http_req.setConnectionTimeout(40)
CALL http_req.setTimeout(40)
CALL http_req.setMethod("POST")
CALL http_req.setCharset("UTF-8")
DISPLAY "data ",cmd
# CALL http_req.doTextRequest(cmd)
CALL http_req.doRequest()
LET http_resp=http_req.getResponse()
IF http_resp.getStatusCode() != 200 THEN
RETURN http_resp.getStatusCode(), http_resp.getStatusDescription()
END IF
LET tmp = http_resp.getStatusDescription()
IF (tmp == "OK" || tmp == "no error" ) THEN
RETURN -1, SFMT("HTTP request status description: %1 ",tmp)
END IF
LET result = http_resp.getTextResponse()
CATCH
RETURN -2, SFMT("HTTP request error: STATUS=%1 (%2)",STATUS,SQLCA.SQLERRM)
END TRY
RETURN 0, result
END FUNCTION
FUNCTION show_sync_err(msg)
DEFINE msg STRING
CALL fgl_winmessage(%"ERROR", msg, "exclamation")
END FUNCTION
FUNCTION b64_to_file(str_b64,f_sal)
DEFINE f_sal,str_b64,str_aux STRING
TRY
CALL security.Base64.SaveBinary(f_sal,str_b64)
CATCH
DISPLAY " data ",str_b64
LET str_aux="Unable to convert Base64 String to file :",STATUS
CALL fgl_winmessage("Error",str_aux,"stop")
END TRY
END FUNCTION
+103
View File
@@ -0,0 +1,103 @@
IMPORT util
IMPORT com
IMPORT os
IMPORT security
TYPE t_sync_cmd RECORD
oper STRING,
data STRING
END RECORD
DEFINE s, cmd,usuario,clave STRING
MAIN
CONNECT TO 'smarmotech' USER 'jsoto' USING 'lmmjvsd2014'
CALL familias()
END MAIN
FUNCTION familias()
DEFINE metodo,url,selec,ret,res STRING,
categoria RECORD
NAME,IMAGE STRING
END RECORD,
http_req com.HTTPRequest,
http_resp com.HTTPResponse,
data t_sync_cmd
LET url = 'https://shop.marmotech.com.do/wp-json/wc/v3/products/categories'
LET selec = "SELECT a.descripcion FROM familia a ORDER BY a.id_familia"
PREPARE comando FROM selec
DECLARE busca_cat CURSOR FOR comando
LET data.oper = 'products/categories'
FOREACH busca_cat INTO categoria.*
LET data.data = util.JSON.stringify(categoria)
LET cmd= util.JSON.stringify(data)
LET cmd = url CLIPPED,"?name=",categoria.NAME CLIPPED
CALL sync_send_command(url,cmd) RETURNING ret,res
DISPLAY "RESPUESTA ",ret," ",res
END FOREACH
END FUNCTION
FUNCTION sync_send_command(url, cmd)
DEFINE url, cmd STRING
DEFINE result, tmp STRING
DEFINE http_req com.HTTPRequest
DEFINE http_resp com.HTTPResponse
LET usuario = "ck_f41ca9ba9ec888d82243a7c24717af625c26f834"
LET clave = "cs_dbd762cb45184e3badc5a114b8f4a30c19f114fc"
TRY LET http_req = com.HTTPRequest.Create(cmd)
CALL http_req.setAuthentication(usuario,clave,"Basic",NULL)
CALL http_req.setKeepConnection(TRUE)
CALL http_req.setConnectionTimeout(40)
CALL http_req.setTimeout(40)
CALL http_req.setMethod("POST")
CALL http_req.setCharset("UTF-8")
DISPLAY "data ",cmd
# CALL http_req.doTextRequest(cmd)
CALL http_req.doRequest()
LET http_resp=http_req.getResponse()
IF http_resp.getStatusCode() != 200 THEN
RETURN http_resp.getStatusCode(), http_resp.getStatusDescription()
END IF
LET tmp = http_resp.getStatusDescription()
IF (tmp == "OK" || tmp == "no error" ) THEN
RETURN -1, SFMT("HTTP request status description: %1 ",tmp)
END IF
LET result = http_resp.getTextResponse()
CATCH
RETURN -2, SFMT("HTTP request error: STATUS=%1 (%2)",STATUS,SQLCA.SQLERRM)
END TRY
RETURN 0, result
END FUNCTION
FUNCTION show_sync_err(msg)
DEFINE msg STRING
CALL fgl_winmessage(%"ERROR", msg, "exclamation")
END FUNCTION
FUNCTION b64_to_file(str_b64,f_sal)
DEFINE f_sal,str_b64,str_aux STRING
TRY
CALL security.Base64.SaveBinary(f_sal,str_b64)
CATCH
DISPLAY " data ",str_b64
LET str_aux="Unable to convert Base64 String to file :",STATUS
CALL fgl_winmessage("Error",str_aux,"stop")
END TRY
END FUNCTION
+103
View File
@@ -0,0 +1,103 @@
IMPORT util
IMPORT com
IMPORT os
IMPORT security
TYPE t_sync_cmd RECORD
oper STRING,
data STRING
END RECORD
DEFINE s, cmd,usuario,clave STRING
MAIN
CONNECT TO 'smarmotech' USER 'jsoto' USING 'lmmjvsd2014'
CALL familias()
END MAIN
FUNCTION familias()
DEFINE metodo,url,selec,ret,res STRING,
categoria RECORD
NAME,IMAGE STRING
END RECORD,
http_req com.HTTPRequest,
http_resp com.HTTPResponse,
data t_sync_cmd
LET url = 'https://shop.marmotech.com.do/wp-json/wc/v3/products/categories'
LET selec = "SELECT a.descripcion FROM familia a ORDER BY a.id_familia"
PREPARE comando FROM selec
DECLARE busca_cat CURSOR FOR comando
LET data.oper = 'products/categories'
FOREACH busca_cat INTO categoria.*
LET data.data = util.JSON.stringify(categoria)
LET cmd= util.JSON.stringify(data)
LET cmd = url CLIPPED,"?name=",categoria.NAME CLIPPED
CALL sync_send_command(url,cmd) RETURNING ret,res
DISPLAY "RESPUESTA ",ret," ",res
END FOREACH
END FUNCTION
FUNCTION sync_send_command(url, cmd)
DEFINE url, cmd STRING
DEFINE result, tmp STRING
DEFINE http_req com.HTTPRequest
DEFINE http_resp com.HTTPResponse
LET usuario = "ck_f41ca9ba9ec888d82243a7c24717af625c26f834"
LET clave = "cs_dbd762cb45184e3badc5a114b8f4a30c19f114fc"
TRY LET http_req = com.HTTPRequest.Create(cmd)
CALL http_req.setAuthentication(usuario,clave,"Basic",NULL)
CALL http_req.setKeepConnection(TRUE)
CALL http_req.setConnectionTimeout(40)
CALL http_req.setTimeout(40)
CALL http_req.setMethod("POST")
CALL http_req.setCharset("UTF-8")
DISPLAY "data ",cmd
# CALL http_req.doTextRequest(cmd)
CALL http_req.doRequest()
LET http_resp=http_req.getResponse()
IF http_resp.getStatusCode() != 200 THEN
RETURN http_resp.getStatusCode(), http_resp.getStatusDescription()
END IF
LET tmp = http_resp.getStatusDescription()
IF (tmp == "OK" || tmp == "no error" ) THEN
RETURN -1, SFMT("HTTP request status description: %1 ",tmp)
END IF
LET result = http_resp.getTextResponse()
CATCH
RETURN -2, SFMT("HTTP request error: STATUS=%1 (%2)",STATUS,SQLCA.SQLERRM)
END TRY
RETURN 0, result
END FUNCTION
FUNCTION show_sync_err(msg)
DEFINE msg STRING
CALL fgl_winmessage(%"ERROR", msg, "exclamation")
END FUNCTION
FUNCTION b64_to_file(str_b64,f_sal)
DEFINE f_sal,str_b64,str_aux STRING
TRY
CALL security.Base64.SaveBinary(f_sal,str_b64)
CATCH
DISPLAY " data ",str_b64
LET str_aux="Unable to convert Base64 String to file :",STATUS
CALL fgl_winmessage("Error",str_aux,"stop")
END TRY
END FUNCTION
+146
View File
@@ -0,0 +1,146 @@
IMPORT util
IMPORT com
IMPORT os
IMPORT security
TYPE t_sync_cmd RECORD
oper STRING,
data STRING
END RECORD
DEFINE s, cmd,usuario,clave STRING
MAIN
CONNECT TO 'smarmotech' USER 'jsoto' USING 'lmmjvsd2014'
CALL familias()
END MAIN
FUNCTION familias()
DEFINE metodo,url,selec,ret,res STRING,
producto1 RECORD
name,
type STRING,
regular_price STRING,
description ,
short_description STRING
END RECORD,
http_req com.HTTPRequest,
http_resp com.HTTPResponse,
data t_sync_cmd
LET url = 'https://shop.marmotech.com.do/wp-json/wc/v3/products'
LET selec = "SELECT a.descripcion FROM familia a ORDER BY a.id_familia"
LET producto1.name = 'PRUEBA15'
LET PRODUCTO1.type='simple'
LET producto1.regular_price = '21.98'
LET producto1.description='ESTA ES LA DESCRIPCION LARGA DEL PRODUCTO'
LET producto1.short_description = 'Esta es la descripcion corta'
# LET data.oper = 'products'
# LET cmd = util.JSON.stringify(producto1)
LET cmd = '{
"name": "Premium Quality",
"type": "simple",
"regular_price": "21.99",
"description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
"short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
"categories": [
{
"id": 9
},
{
"id": 14
}
],
"images": [
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg"
},
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg"
}
]
}'
# LET cmd = util.JSON.stringify(data)
CALL sync_send_command(url,cmd) RETURNING ret,res
DISPLAY "RESPUESTA ",ret," ",res
{ PREPARE comando FROM selec
DECLARE busca_cat CURSOR FOR comando
LET data.oper = 'products/categories'
FOREACH busca_cat INTO categoria.*
LET data.data = util.JSON.stringify(categoria)
LET cmd= util.JSON.stringify(data)
LET cmd = url CLIPPED,"?name=",categoria.NAME CLIPPED
CALL sync_send_command(url,cmd) RETURNING ret,res
DISPLAY "RESPUESTA ",ret," ",res
END FOREACH
}
END FUNCTION
FUNCTION sync_send_command(url, cmd)
DEFINE url, cmd STRING
DEFINE result, tmp STRING
DEFINE http_req com.HTTPRequest
DEFINE http_resp com.HTTPResponse
LET usuario = "ck_f41ca9ba9ec888d82243a7c24717af625c26f834"
LET clave = "cs_dbd762cb45184e3badc5a114b8f4a30c19f114fc"
TRY LET http_req = com.HTTPRequest.Create(url)
CALL http_req.setAuthentication(usuario,clave,"Basic",NULL)
CALL http_req.setKeepConnection(TRUE)
CALL http_req.setConnectionTimeout(40)
CALL http_req.setTimeout(40)
CALL http_req.setMethod("POST")
CALL http_req.setCharset("UTF-8")
DISPLAY "data ",cmd
CALL http_req.doTextRequest(cmd)
#CALL http_req.doRequest()
LET http_resp=http_req.getResponse()
IF http_resp.getStatusCode() != 200 THEN
RETURN http_resp.getStatusCode(), http_resp.getStatusDescription()
END IF
LET tmp = http_resp.getStatusDescription()
IF (tmp == "OK" || tmp == "no error" ) THEN
RETURN -1, SFMT("HTTP request status description: %1 ",tmp)
END IF
LET result = http_resp.getTextResponse()
CATCH
RETURN -2, SFMT("HTTP request error: STATUS=%1 (%2)",STATUS,SQLCA.SQLERRM)
END TRY
RETURN 0, result
END FUNCTION
FUNCTION show_sync_err(msg)
DEFINE msg STRING
CALL fgl_winmessage(%"ERROR", msg, "exclamation")
END FUNCTION
FUNCTION b64_to_file(str_b64,f_sal)
DEFINE f_sal,str_b64,str_aux STRING
TRY
CALL security.Base64.SaveBinary(f_sal,str_b64)
CATCH
DISPLAY " data ",str_b64
LET str_aux="Unable to convert Base64 String to file :",STATUS
CALL fgl_winmessage("Error",str_aux,"stop")
END TRY
END FUNCTION