guides:o4w:examples:example_mobile

Mobile Pizza Ordering Application

Subroutine O4W_MMM_PIZZA(CTLENTID, EVENT, REQUEST)

$Insert O4WCOMMON

$Insert O4WEQUATES

pageOptions = o4wmobileoptions("page","b"):O4WDataStyle("", "data-add-back-btn", "true")

hdrOptions = o4wmobileoptions("header")

contentOptions = o4wmobileoptions("content")

dialogOptions = o4wmobileoptions("dialog","b")

Begin Case

Case EVENT _EQC "CREATE"

O4WSetMobile(1)

O4WFORM()

* build first page of mobile application

O4WSectionStart("menuPage", pageOptions)

O4WSectionStart("menuHdr", hdrOptions)

O4WHeader("mmmPizza Menu", 3)

* build the navigation bar

Gosub makeNav

O4WSectionEnd("menuHdr")

O4WBreak()

O4WBreak()

O4WSectionStart("menuContent", O4WMarkedOptions('1'):contentOptions)

Gosub buildMenu

O4WButton("Submit Order", "BTN_SUBMIT", O4WMarkedOptions('1'))

O4WQualifyEvent("BTN_SUBMIT", "CLICK")

O4WSectionEnd("menuContent")

O4WSectionEnd("menuPage")

 

* build second page

O4WSectionStart("locPage", pageOptions)

O4WSectionStart("locHdr", hdrOptions)

O4WHeader("mmmPizza Locations", 3)

* use same menu bar

Gosub makeNav

O4WSectionEnd("locHdr")

O4WBreak()

O4WBreak()

O4WSectionStart("locContent", O4WMarkedOptions('1'):contentOptions)

* use standard O4W API to build this output

O4WTableStart("locTable", o4wmobiletableoptions("1", "", "33"))

O4WSetCell(1, 1, '', o4wtablecelloptions("","","1")) ;* mark as a 'header'

O4WText("Location: ")

O4WSetCell(1, 2)

address = "99 Kinderkamack Rd":@VM:"First Floor":@VM:"Westwood, NJ 07675"

* O4WText(address)

g_address = Delete(address, 1, 2, 0) ;* remove the 2nd address line for google display

Convert @VM To "," In g_address

O4WText(address)

o4wsetcell(2,2)

O4WLink("Map", O4W_LINKTYPE_NORMAL$, "http://maps.google.com/maps?q=":g_address, 'mapDisplayTab', '', O4WMobileButtonOptions('','','b'))

O4WTableEnd("locTable")

O4WSectionEnd("locContent")

O4WSectionEnd("locPage")

 

* build a section for any dialogs we want to pop up

o4wsectionstart("menuDialogPage", o4wmarkedoptions("0"):dialogOptions)

O4WText("Thanks for your order!  Your order number is pending...")

o4wsectionend("menuDialogPage")

 

Case event _eqc "CLICK"

O4WResponse()

* Load in the submitted order

BSTICKS = O4WGetValue("BSTICKS")

GBREAD = O4WGetValue("GBREAD")

WINGS = O4WGetValue("WINGS")

* Display an acknowledgement

o4wsectionstart("menuDialogPage", dialogOptions:o4wresponseoptions())

O4WSectionStart("dlgHdr", hdrOptions)

O4WHeader("mmmPizza Order", 3)

O4WSectionEnd("dlgHdr")

O4WBreak()

O4WBreak()

O4WSectionStart("dlgContent", O4WMarkedOptions('0'):contentOptions)

* use standard O4W API to build this output

O4WText("Thanks for your order!  We're busy baking it right right...your order number is #":DATE():TIME())

O4WSectionEnd("dlgContent")

o4wsectionend("menuDialogPage")

O4WDialog("menuDialogPage", "Order Received")

 

 

End Case

Return 0

makeNav:

* create menu bar

o4wsectionstart("pizzaNavbar", O4WMobileOptions("navbar"))

o4wliststart(0)

o4wlistitem()

O4WLink("Menu", O4W_LINKTYPE_LOCAL$, "menuPage")

o4wlistitem()

O4WLink("Location", O4W_LINKTYPE_LOCAL$, "locPage")

o4wlistend()

o4wsectionend("pizzaNavbar")

Return

buildMenu:

O4WSectionStart("menuGroups", o4wmobileoptions("collapsible-set"):o4wmarkedoptions("0"))

O4WSectionStart("appDetails", o4wmobileoptions("collapsible"):o4wmarkedoptions("0"))

o4wheader("Appetizers", 3)

O4WText("Bread Sticks", "", O4WTextOptions("BSTICKS"))

O4WRadioButton("No", "0", "BSTICKS", "BSTICKS_0", o4wmarkedoptions(1))

O4WRadioButton("Yes", "1", "BSTICKS", "BSTICKS_1")

o4wbreak()

O4WText("Garlic Bread", "", O4WTextOptions("GBREAD"))

O4WRadioButton("No", "0", "GBREAD", "GBREAD_0", o4wmarkedoptions(1))

O4WRadioButton("Yes", "1", "GBREAD", "GBREAD_1")

o4wbreak()

O4WText("Hot Wings", "", O4WTextOptions("WINGS"))

O4WListBox("None", "0", "WINGS", "", "WINGS_0", o4wmarkedoptions(1))

O4WListBox("Half Dozen", "6", "WINGS", "", "WINGS_6")

O4WListBox("Dozen", "12", "WINGS", "", "WINGS_12")

O4WListBox("Jumbo", "24", "WINGS", "", "WINGS_24")

o4wbreak()

o4wsectionEnd("appDetails")

 

O4WSectionStart("entreeDetails", o4wmobileoptions("collapsible"):o4wmarkedoptions("0"))

o4wheader("Entrees", 3)

O4WText("Pizza", "", O4WTextOptions("PIZZA"))

O4WListBox("Personal", "1", "PIZZA", "", "PIZZA_1", o4wmarkedoptions(1))

O4WListBox("Medium", "2", "PIZZA", "", "PIZZA_2")

O4WListBox("Large", "3", "PIZZA", "", "PIZZA_3")

o4wbreak()

o4wsectionstart("toppingsChoices", o4wmobileoptions("fieldcontain"):o4wmarkedoptions("0"))

opts = O4WFieldsetOptions("Toppings"):O4WMOBILEOPTIONS("controlgroup"):o4wmarkedoptions("0")

o4wsectionstart("toppingsFieldset", opts)

O4WCheckBox("Pepperoni", "P", "TOPPINGS", "TOPPINGS_P")

O4WCheckBox("Sausage", "S", "TOPPINGS", "TOPPINGS_S")

O4WCheckBox("Ham", "H", "TOPPINGS", "TOPPINGS_H")

O4WCheckBox("Meatball", "M", "TOPPINGS", "TOPPINGS_M")

O4WCheckBox("Chicken", "C", "TOPPINGS", "TOPPINGS_C")

o4wsectionend("toppingsFieldset")

o4wsectionstart("toppingsChoices")

o4wbreak()

O4WText("Sauce", "", O4WTextOptions("SAUCE"))

O4WRadioButton("Red", "0", "SAUCE", "SAUCE_0", o4wmarkedoptions(1))

O4WRadioButton("White (Garlic)", "1", "SAUCE", "SAUCE_1")

o4wbreak()

o4wsectionEnd("entreeDetails")

O4WSectionStart("drinkDetails", o4wmobileoptions("collapsible"):o4wmarkedoptions("0"))

o4wheader("Drinks", 3)

o4wsectionstart("sodaChoices", o4wmobileoptions("fieldcontain"):o4wmarkedoptions("0"))

o4wsectionstart("sodaFieldset", O4WFieldsetOptions("Soda"):O4WMOBILEOPTIONS("controlgroup"):o4wmarkedoptions("0"))

O4WCheckBox("Coke", "C", "SODA", "SODA_C")

O4WCheckBox("Diet Coke", "D", "SODA", "SODA_D")

O4WCheckBox("Sprite", "S", "SODA", "SODA_S")

o4wsectionend("sodaFieldset")

o4wsectionend("sodaChoices")

o4wbreak()

o4wsectionstart("juiceChoices", o4wmobileoptions("fieldcontain"):o4wmarkedoptions("0"))

o4wsectionstart("juiceFieldset", O4WFieldsetOptions("Juices"):O4WMOBILEOPTIONS("controlgroup"):o4wmarkedoptions("0"))

O4WCheckBox("Apple", "A", "JUICE", "JUICE_A")

O4WCheckBox("Orange", "O", "JUICE", "JUICE_O")

O4WCheckBox("Cranberry", "C", "JUICE", "JUICE_C")

o4wsectionend("juiceFieldset")

o4wsectionend("juiceChoices")

o4wbreak()

o4wsectionEnd("drinkDetails")

O4WSectionStart("dessertDetails", o4wmobileoptions("collapsible"):o4wmarkedoptions("0"))

o4wheader("Desserts", 3)

O4WText("Cheesecake", "", O4WTextOptions("CCAKE"))

O4WRadioButton("No", "0", "CCAKE", "CCAKE_0", o4wmarkedoptions(1))

O4WRadioButton("Yes", "1", "CCAKE", "CCAKE_1")

o4wbreak()

O4WText("Italian Ice", "", O4WTextOptions("ICE"))

O4WListBox("None", "0", "ICE", "", "ICE_0", o4wmarkedoptions(1))

O4WListBox("Cherry", "1", "ICE", "", "ICE_1")

O4WListBox("Lemon", "2", "ICE", "", "ICE_2")

o4wbreak()

o4wsectionEnd("dessertDetails")

O4WSectionEnd("menuGroups")

return
  • guides/o4w/examples/example_mobile.txt
  • Last modified: 2023/08/20 14:12
  • by 127.0.0.1