Commit inicial: fuentes MBS ERP (Genero 6) + .gitignore + docs/SETUP_PC_MBS.md
This commit is contained in:
@@ -0,0 +1,299 @@
|
||||
#
|
||||
# FOURJS_START_COPYRIGHT(U,2011)
|
||||
# Property of Four Js*
|
||||
# (c) Copyright Four Js 2011, 2019. All Rights Reserved.
|
||||
# * Trademark of Four Js Development Tools Europe Ltd
|
||||
# in the United States and elsewhere
|
||||
#
|
||||
# Four Js and its suppliers do not warrant or guarantee that these samples
|
||||
# are accurate and suitable for your purposes. Their inclusion is purely for
|
||||
# information purposes only.
|
||||
# FOURJS_END_COPYRIGHT
|
||||
#
|
||||
|
||||
GLOBALS "ws_shoppingCart.inc"
|
||||
|
||||
TYPE GoodsListType DYNAMIC ARRAY OF RECORD
|
||||
SERIAL INTEGER,
|
||||
DESCRIPTION STRING,
|
||||
UnitPrice FLOAT
|
||||
END RECORD
|
||||
|
||||
TYPE CartListType DYNAMIC ARRAY OF RECORD
|
||||
SERIAL INTEGER,
|
||||
DESCRIPTION STRING,
|
||||
Quantity INTEGER
|
||||
END RECORD
|
||||
|
||||
CONSTANT GoodSource = 1
|
||||
CONSTANT CartSource = 2
|
||||
|
||||
MAIN
|
||||
|
||||
DEFINE user STRING
|
||||
CLOSE WINDOW SCREEN
|
||||
|
||||
IF num_args()==1 THEN
|
||||
LET ShoppingCart_ShoppingCartPortTypeSoap12Endpoint.Address.URI = Retrieve_URL()
|
||||
END IF
|
||||
|
||||
OPEN WINDOW win WITH FORM "Shopping" ATTRIBUTE (TEXT="ShoppingCart demo")
|
||||
|
||||
|
||||
MENU
|
||||
ON ACTION login
|
||||
LET USER = LogInDialog()
|
||||
IF USER IS NOT NULL THEN
|
||||
DISPLAY BY NAME user
|
||||
CALL DoShoppingDialog(user)
|
||||
LET USER = NULL
|
||||
DISPLAY BY NAME user
|
||||
END IF
|
||||
|
||||
ON ACTION CLOSE
|
||||
EXIT MENU
|
||||
|
||||
|
||||
END MENU
|
||||
|
||||
CLOSE WINDOW win
|
||||
|
||||
END MAIN
|
||||
|
||||
FUNCTION LogInDialog()
|
||||
DEFINE user STRING
|
||||
OPEN WINDOW w2 WITH FORM "User" ATTRIBUTE (TEXT="Log In",STYLE="dialog")
|
||||
INPUT BY NAME user ATTRIBUTES (UNBUFFERED)
|
||||
ON ACTION accept
|
||||
IF user IS NOT NULL THEN
|
||||
EXIT INPUT
|
||||
END IF
|
||||
AFTER FIELD user
|
||||
IF user IS NULL THEN
|
||||
NEXT FIELD user
|
||||
END IF
|
||||
ON ACTION cancel
|
||||
EXIT INPUT
|
||||
END INPUT
|
||||
CLOSE WINDOW w2
|
||||
RETURN user
|
||||
END FUNCTION
|
||||
|
||||
|
||||
FUNCTION DoShoppingDialog(user)
|
||||
DEFINE USER STRING
|
||||
DEFINE goodList GoodsListType
|
||||
DEFINE cartList CartListType
|
||||
DEFINE DragSource INTEGER
|
||||
DEFINE DragSerial INTEGER
|
||||
DEFINE DragIndex INTEGER
|
||||
DEFINE dnd ui.DragDrop
|
||||
DEFINE wsstatus INTEGER
|
||||
DEFINE ind INTEGER
|
||||
DEFINE found BOOLEAN
|
||||
DEFINE SESSION STRING
|
||||
DEFINE TOTAL FLOAT
|
||||
|
||||
#
|
||||
# Reset session
|
||||
#
|
||||
LET ShoppingCart_ShoppingCartPortTypeSoap12Endpoint.Binding.Cookie = NULL
|
||||
|
||||
#
|
||||
# Initialize ShoppingCart for given user
|
||||
# and store session identifier
|
||||
#
|
||||
LET GetShoppingCartRequest.login = user
|
||||
CALL GetShoppingCart_g() RETURNING wsstatus
|
||||
CASE wsstatus
|
||||
WHEN 0
|
||||
FOR ind = 1 TO GetShoppingCartResponse.list.element.getLength()
|
||||
LET goodList[ind].* = GetShoppingCartResponse.list.element[ind].*
|
||||
END FOR
|
||||
LET SESSION = ShoppingCart_ShoppingCartPortTypeSoap12Endpoint.Binding.Cookie
|
||||
OTHERWISE
|
||||
ERROR "[", wsError.code, "] ", wsError.description
|
||||
END CASE
|
||||
|
||||
|
||||
#
|
||||
# Retrieve old ShoppingCart from current user (if any)
|
||||
#
|
||||
CALL GetGoodsInCart_g() RETURNING wsstatus
|
||||
CASE wsstatus
|
||||
WHEN 0
|
||||
FOR ind = 1 TO GetGoodsInCartResponse.goods.element.getLength()
|
||||
LET cartList[ind].* = GetGoodsInCartResponse.goods.element[ind].*
|
||||
END FOR
|
||||
OTHERWISE
|
||||
ERROR "[", wsError.code, "] ", wsError.description
|
||||
END CASE
|
||||
|
||||
|
||||
INITIALIZE DragIndex TO NULL
|
||||
|
||||
DIALOG ATTRIBUTE(Unbuffered)
|
||||
|
||||
DISPLAY ARRAY goodList TO sr_goods.*
|
||||
|
||||
ON DRAG_START(dnd)
|
||||
LET DragSource = GoodSource
|
||||
LET DragIndex = arr_curr()
|
||||
LET DragSerial = goodList[DragIndex].SERIAL
|
||||
|
||||
ON DRAG_FINISHED(dnd)
|
||||
INITIALIZE DragSource TO NULL
|
||||
|
||||
ON DRAG_ENTER(dnd)
|
||||
IF DragSource IS NULL THEN
|
||||
CALL dnd.setOperation(NULL)
|
||||
END IF
|
||||
|
||||
ON DROP (dnd)
|
||||
IF DragSource == GoodSource THEN
|
||||
CALL dnd.dropInternal()
|
||||
ELSE
|
||||
#
|
||||
# Remove one good from cart
|
||||
#
|
||||
CALL RemoveFromCart(DragSerial) RETURNING wsstatus
|
||||
CASE wsstatus
|
||||
WHEN 0
|
||||
# Update cart dialog
|
||||
LET cartList[DragIndex].Quantity = cartList[DragIndex].Quantity -1
|
||||
IF cartList[DragIndex].Quantity == 0 THEN
|
||||
CALL cartList.deleteElement(DragIndex)
|
||||
END IF
|
||||
WHEN FaultID_BadSessionError
|
||||
ERROR "[BadSessionError] ", BadSessionError.msg
|
||||
OTHERWISE
|
||||
ERROR "[", wsError.code, "] ", wsError.description
|
||||
END CASE
|
||||
|
||||
END IF
|
||||
END DISPLAY
|
||||
|
||||
DISPLAY ARRAY cartList TO sr_cart.*
|
||||
ON DRAG_START(dnd)
|
||||
LET DragSource = CartSource
|
||||
LET DragIndex = arr_curr()
|
||||
LET DragSerial = cartList[DragIndex].SERIAL
|
||||
|
||||
ON DRAG_FINISHED(dnd)
|
||||
INITIALIZE DragSource TO NULL
|
||||
|
||||
ON DRAG_ENTER(dnd)
|
||||
IF DragSource IS NULL THEN
|
||||
CALL dnd.setOperation(NULL)
|
||||
END IF
|
||||
|
||||
ON DROP(dnd)
|
||||
IF DragSource == CartSource THEN
|
||||
CALL dnd.dropInternal()
|
||||
ELSE
|
||||
#
|
||||
# Add given good to cart
|
||||
#
|
||||
CALL AddToCart(DragSerial) RETURNING wsstatus
|
||||
CASE wsstatus
|
||||
WHEN 0
|
||||
# Update cart dialog
|
||||
LET FOUND = FALSE
|
||||
FOR ind = 1 TO cartList.getLength()
|
||||
IF cartList[ind].SERIAL == DragSerial THEN
|
||||
LET cartList[ind].Quantity = cartList[ind].Quantity +1
|
||||
LET FOUND = TRUE
|
||||
END IF
|
||||
END FOR
|
||||
IF NOT FOUND THEN
|
||||
CALL cartList.appendElement()
|
||||
LET ind = cartList.getLength()
|
||||
LET cartList[ind].SERIAL = goodList[DragIndex].SERIAL
|
||||
LET cartList[ind].DESCRIPTION = goodList[DragIndex].DESCRIPTION
|
||||
LET cartList[ind].Quantity = 1
|
||||
END IF
|
||||
WHEN FaultID_BadSessionError
|
||||
ERROR "[BadSessionError] ", BadSessionError.msg
|
||||
OTHERWISE
|
||||
ERROR "[", wsError.code, "] ", wsError.description
|
||||
END CASE
|
||||
END IF
|
||||
END DISPLAY
|
||||
|
||||
ON ACTION ORDER
|
||||
#
|
||||
# Order goods
|
||||
#
|
||||
CALL OrderCart() RETURNING wsstatus, total
|
||||
CASE wsstatus
|
||||
WHEN 0
|
||||
INITIALIZE cartList TO NULL
|
||||
CALL fgl_winmessage("Order","Total price :"||total,"information")
|
||||
WHEN FaultID_BadSessionError
|
||||
ERROR "[BadSessionError] ", BadSessionError.msg
|
||||
OTHERWISE
|
||||
ERROR "[", wsError.code, "] ", wsError.description
|
||||
END CASE
|
||||
|
||||
EXIT DIALOG
|
||||
|
||||
ON ACTION discard
|
||||
#
|
||||
# Order goods
|
||||
#
|
||||
CALL DiscardCart() RETURNING wsstatus
|
||||
CASE wsstatus
|
||||
WHEN 0
|
||||
INITIALIZE cartList TO NULL
|
||||
CALL fgl_winmessage("Discard","Cart discarded","information")
|
||||
WHEN FaultID_BadSessionError
|
||||
ERROR "[BadSessionError] ", BadSessionError.msg
|
||||
OTHERWISE
|
||||
ERROR "[", wsError.code, "] ", wsError.description
|
||||
END CASE
|
||||
|
||||
ON ACTION close
|
||||
EXIT PROGRAM
|
||||
|
||||
END DIALOG
|
||||
|
||||
END FUNCTION
|
||||
|
||||
|
||||
FUNCTION Retrieve_URL()
|
||||
DEFINE url STRING
|
||||
DEFINE custo STRING
|
||||
OPEN WINDOW w2 WITH FORM "EnterURL" ATTRIBUTE (TEXT="Web Services URL",STYLE="naked")
|
||||
LET url = arg_val(1)
|
||||
INPUT BY NAME url WITHOUT DEFAULTS ATTRIBUTE (UNBUFFERED)
|
||||
ON ACTION ACCEPT
|
||||
EXIT INPUT
|
||||
ON CHANGE url
|
||||
IF url=="Customize" THEN
|
||||
LET url="http://host:port/ShoppingCart"
|
||||
PROMPT "Enter your URL" FOR url ATTRIBUTES (WITHOUT DEFAULTS)
|
||||
IF NOT INT_FLAG THEN
|
||||
LET INT_FLAG = false
|
||||
EXIT INPUT
|
||||
ELSE
|
||||
LET url = arg_val(1)
|
||||
END IF
|
||||
END IF
|
||||
ON ACTION CANCEL
|
||||
EXIT PROGRAM
|
||||
END INPUT
|
||||
LET INT_FLAG = false
|
||||
CLOSE WINDOW w2
|
||||
RETURN url
|
||||
END FUNCTION
|
||||
|
||||
FUNCTION fillcombourls(cb)
|
||||
DEFINE cb ui.ComboBox
|
||||
IF cb.getTag()=="COMBO" THEN
|
||||
CALL cb.addItem(arg_val(1),"(Standalone) "||arg_val(1))
|
||||
CALL cb.addItem("http://localhost:6394/ws/r/demo/ShoppingCart","(Httpdispatch) http://localhost:6394/ws/r/demo/ShoppingCart")
|
||||
CALL cb.addItem("http://localhost/gas/ws/r/demo/ShoppingCart","(FastCGI) http://localhost/gas/ws/r/demo/ShoppingCart")
|
||||
CALL cb.addItem("http://localhost/gas/ws/r/demo/ShoppingCart","(ISAPI) http://localhost/gas/ws/r/demo/ShoppingCart")
|
||||
CALL cb.addItem("Customize","(Customize) Click here to add your own URL")
|
||||
END IF
|
||||
END FUNCTION
|
||||
Reference in New Issue
Block a user