Page 1 of 1

Resuable Part for Generic iOS screens - UPDATED (RDMLX)

Posted: Tue Jul 03, 2012 9:41 am
by GregSippel
I have created a Resuable Part alongside Mark D's RPG program to get a generic look and feel. This is now the new version of the file, with changes that I have made based on experience.

Please have a play and please add to it if you can

To use, download code and create it as a resuable part with name say IOSLOOK.

Download from here,
ioslookv2.txt
(20.56 KiB) Downloaded 555 times
Then put in your LongRange Resuable Part, via Define_Com Class(#IOSLOOK) Name(#IOS)
2012-09-14-08-12-18.jpg
2012-09-14-08-12-18.jpg (107.54 KiB) Viewed 17624 times
The code for the screen shot above is as follows,

* **************************************************
*
* COMPONENT: STD_PANL
*
* **************************************************
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #LRNG_FORM)
* Includes
Define_Com Class(#IOSLOOKV2) Name(#IOS2)
Define_Com Class(#prim_nmbr) Name(#pageSize) Value(20)
Define_Com Class(#prim_nmbr) Name(#endPage)
Define_Com Class(#PRIM_NMBR) Name(#W$LORD)

* Work Objects
Define_Com Class(#PRIM_ALPH) Name(#actionValue)
Define_Com Class(#PRIM_ALPH) Name(#W$CSTV)
Define Field(#retcode) Type(*char) Length(2)

* Group_bys
Group_By Name(#custData) Fields(#LTCCUSTNM #LTCCUSTEM #LTCCUSTB1 #LTCCUSTB2 #LTCCUSTBC #LTCCUSTBS #LTCCUSTBZ #LTCCUSTS1 #LTCCUSTS2 #LTCCUSTSC #LTCCUSTSS #LTCCUSTSZ #LTCCUSTPC #LTCCUSTPP #LTCCUSTPR #LTCCUSTPA #LTCCUSTCL #LTCCUSTCB #LTCDISCCD #LTCCUSTG #LTCCUSTWS)

* Form Names
Define_Com Class(#PRIM_ALPH) Name(#top)
Define_Com Class(#PRIM_ALPH) Name(#content)
Define_Com Class(#PRIM_ALPH) Name(#basicbox)
Define_Com Class(#PRIM_ALPH) Name(#billtobox)
Define_Com Class(#PRIM_ALPH) Name(#shiptobox)
Define_Com Class(#PRIM_ALPH) Name(#commsbox)

* ===============================================================
* LTCLRSD00 - Mainline
* ===============================================================
Mthroutine Name(HandleRequest) Options(*REDEFINE)

* -----------------------------------------
* Handle currently requested action (if any)
* -----------------------------------------

* Always set the USING Element to /Form.Fields at the start
#Com_Owner.Using Element('/Form.Fields')
* And Get the Current Top and Content
#COM_OWNER.Get_SharedState Variablename(currentTop) Value(#top)
#COM_OWNER.Get_SharedState Variablename(currentContent) Value(#content)
* Values
#Com_Owner.Get_SharedState Variablename('currentCustomer') Value(#W$CSTV)


If (#COM_OWNER.RequestACTION.Contains( '_' ))
#actionValue := (#COM_OWNER.RequestACTION).Substring( 1 ((#COM_OWNER.RequestACTION).PositionOf( '_' ) - 1) )
Else
#actionValue := #COM_OWNER.RequestACTION
Endif

Case Of_Field(#actionValue)


When Value_Is(= actionCustomer)

#COM_Owner.SwitchRequestPROGRAM := 'LTCLRSD01'
#COM_Owner.SwitchRequestACTION := 'DEFAULT'

When Value_Is(= actionOrders)

#COM_Owner.SwitchRequestPROGRAM := 'LTCLRSD02'
#COM_Owner.SwitchRequestACTION := 'DEFAULT'

When Value_Is(= actionSave)

#COM_OWNER.IsNewForm := false
#com_owner.handleSave

When Value_Is(= actionMapCustomer)

* Do the switch
#COM_Owner.SwitchRequestPROGRAM := 'LTCLTSD05'
#COM_Owner.SwitchRequestACTION := 'DEFAULT'

Otherwise /* Default */

#COM_OWNER.IsNewForm := true
#COM_OWNER.showDetails()

Endcase

* Always Set Current Top and Content
#COM_OWNER.Set_SharedState Variablename(currentTop) Value(#top)
#COM_OWNER.Set_SharedState Variablename(currentContent) Value(#content)
* Values
#Com_Owner.Set_SharedState Variablename('currentCustomer') Value(#W$CSTV)


Endroutine

Mthroutine Name(showDetails)

Fetch Fields(#custData) From_File(LTCCUST) With_Key(#W$CSTV)

* Init FormView
#IOS2.initFormView Formview(#COM_OWNER) Maintitle(#LTCCUSTNM + ' Details') Topbarheight(40) Topbarfullname(#top) Contentfullname(#content)

* Set Nav Buttons
#com_owner.set_button Layout_Col(1) Layout_Row(1) Name(#top + '.fields.topButton1') Text('Change Customer') Border_Cornerradius(0) Color('&4f5458') Layout_Height(30) Layout_Width(200) Buttonfacecolor('&f5f5f5') Onclick(actionCustomer)
#com_owner.set_button Layout_Col(2) Layout_Row(1) Name(#top + '.fields.topButton2') Text('Customer Orders') Border_Cornerradius(0) Color('&4f5458') Layout_Height(30) Layout_Width(200) Buttonfacecolor('&f5f5f5') Onclick(actionOrders)
#com_owner.set_button Layout_Col(3) Layout_Row(1) Name(#top + '.fields.topButton3') Text('Map Customer') Border_Cornerradius(0) Color('&4f5458') Layout_Height(30) Layout_Width(200) Buttonfacecolor('&f5f5f5') Onclick(actionMapCustomer)


*
#IOS2.initSubForm Formview(#COM_OWNER) Subform(#content)
* Setup Groupboxs on Content Form
#COM_OWNER.Set_Label Name(#content + '.fields.space1') Layout_Row(1) Layout_Col(2) Layout_Height(25)
#COM_OWNER.Set_Label Name(#content + '.fields.instruction1') Layout_Row(2) Layout_Col(2) Text('Basic Details') Font_Size(18) Color('&4A566C') Font_Bold(true) Padding(5)
#IOS2.createGroupBox Formview(#COM_OWNER) Parent(#content) Name(basicBox) Boxfullname(#basicbox) Layoutrow(3)

#COM_OWNER.Set_Label Name(#content + '.fields.space2') Layout_Row(4) Layout_Col(2) Layout_Height(25)
#COM_OWNER.Set_Label Name(#content + '.fields.instruction2') Layout_Row(5) Layout_Col(2) Text('Billing Address') Font_Size(18) Color('&4A566C') Font_Bold(true) Padding(5)
#IOS2.createGroupBox Formview(#COM_OWNER) Parent(#content) Name(billtoBox) Boxfullname(#billtobox) Layoutrow(6)

#COM_OWNER.Set_Label Name(#content + '.fields.space3') Layout_Row(7) Layout_Col(2) Layout_Height(25)
#COM_OWNER.Set_Label Name(#content + '.fields.instruction3') Layout_Row(8) Layout_Col(2) Text('Shipping Address') Font_Size(18) Color('&4A566C') Font_Bold(true) Padding(5)
#IOS2.createGroupBox Formview(#COM_OWNER) Parent(#content) Name(shiptoBox) Boxfullname(#shiptobox) Layoutrow(9)

#COM_OWNER.Set_Label Name(#content + '.fields.space4') Layout_Row(10) Layout_Col(2) Layout_Height(25)
#COM_OWNER.Set_Label Name(#content + '.fields.instruction4') Layout_Row(11) Layout_Col(2) Text('Contact Information') Font_Size(18) Color('&4A566C') Font_Bold(true) Padding(5)
#IOS2.createGroupBox Formview(#COM_OWNER) Parent(#content) Name(commsBox) Boxfullname(#commsbox) Layoutrow(12)

* Add Elements to Basic
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Name(username) Groupbox(#basicbox) Elementtype(Textbox) Labeltext('Name') Placeholder('Customer Name') Layoutrow(1) Value(#ltccustnm)
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Groupbox(#basicbox) Elementtype(divider) Layoutrow(2)

#IOS2.setGroupBoxRow Formview(#COM_OWNER) Name(creditlimit) Groupbox(#basicbox) Elementtype(Textbox) Labeltext('Credit Limit') Placeholder('0.00') Layoutrow(3) Value(#ltccustcl.asstring)
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Groupbox(#basicbox) Elementtype(divider) Layoutrow(4)

#IOS2.setGroupBoxRow Formview(#COM_OWNER) Name(discount) Groupbox(#basicbox) Elementtype(Textbox) Labeltext('Discount Level') Placeholder('00%') Layoutrow(5) Value(#ltcdisccd)
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Groupbox(#basicbox) Elementtype(divider) Layoutrow(6)

#IOS2.setGroupBoxRow Formview(#COM_OWNER) Name(website) Groupbox(#basicbox) Elementtype(Textbox) Labeltext('Website') Placeholder('http://www.company.com.au') Layoutrow(7) Value(#ltccustws)
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Groupbox(#basicbox) Elementtype(divider) Layoutrow(8)

* Add Elements to BillTo
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Name(address1) Groupbox(#billtobox) Elementtype(Textbox) Labeltext('Address') Placeholder('Customer Billing Address') Layoutrow(1) Value(#ltccustb1)
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Groupbox(#billtobox) Elementtype(divider) Layoutrow(2)

#IOS2.setGroupBoxRow Formview(#COM_OWNER) Name(address2) Groupbox(#billtobox) Elementtype(Textbox) Labeltext('') Placeholder('Customer Billing Address') Layoutrow(3) Value(#ltccustb2)
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Groupbox(#billtobox) Elementtype(divider) Layoutrow(4)

#IOS2.setGroupBoxRow Formview(#COM_OWNER) Name(city) Groupbox(#billtobox) Elementtype(Textbox) Labeltext('Billing City') Placeholder('Billing City') Layoutrow(5) Value(#ltccustbc)
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Groupbox(#billtobox) Elementtype(divider) Layoutrow(6)

#IOS2.setGroupBoxRow Formview(#COM_OWNER) Name(state) Groupbox(#billtobox) Elementtype(Textbox) Labeltext('State') Placeholder('Billing State') Layoutrow(7) Value(#ltccustbs)
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Groupbox(#billtobox) Elementtype(divider) Layoutrow(8)

#IOS2.setGroupBoxRow Formview(#COM_OWNER) Name(postcode) Groupbox(#billtobox) Elementtype(Textbox) Labeltext('Postal Code') Placeholder('Billing Postal Code') Layoutrow(9) Value(#ltccustbz)
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Groupbox(#billtobox) Elementtype(divider) Layoutrow(10)

* Add Elements to ShipTo
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Name(address1) Groupbox(#shiptobox) Elementtype(Textbox) Labeltext('Address') Placeholder('Customer Shipping Address') Layoutrow(1) Value(#ltccusts1)
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Groupbox(#shiptobox) Elementtype(divider) Layoutrow(2)

#IOS2.setGroupBoxRow Formview(#COM_OWNER) Name(address2) Groupbox(#shiptobox) Elementtype(Textbox) Labeltext('') Placeholder('Customer Shipping Address') Layoutrow(3) Value(#ltccusts2)
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Groupbox(#shiptobox) Elementtype(divider) Layoutrow(4)

#IOS2.setGroupBoxRow Formview(#COM_OWNER) Name(city) Groupbox(#shiptobox) Elementtype(Textbox) Labeltext('Billing City') Placeholder('Shipping City') Layoutrow(5) Value(#ltccustsc)
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Groupbox(#shiptobox) Elementtype(divider) Layoutrow(6)

#IOS2.setGroupBoxRow Formview(#COM_OWNER) Name(state) Groupbox(#shiptobox) Elementtype(Textbox) Labeltext('State') Placeholder('Shipping State') Layoutrow(7) Value(#ltccustss)
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Groupbox(#shiptobox) Elementtype(divider) Layoutrow(8)

#IOS2.setGroupBoxRow Formview(#COM_OWNER) Name(postcode) Groupbox(#shiptobox) Elementtype(Textbox) Labeltext('Postal Code') Placeholder('Shipping Postal Code') Layoutrow(9) Value(#ltccustsz)
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Groupbox(#shiptobox) Elementtype(divider) Layoutrow(10)

* Add Elements to Comms
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Name(service) Groupbox(#commsbox) Elementtype(Textbox) Labeltext('Customer Service') Placeholder('+61 2 9999 9999') Layoutrow(1) Value(#ltccustpc)
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Groupbox(#commsbox) Elementtype(divider) Layoutrow(2)

#IOS2.setGroupBoxRow Formview(#COM_OWNER) Name(purchasing) Groupbox(#commsbox) Elementtype(Textbox) Labeltext('Purchasing') Placeholder('+61 2 9999 9999') Layoutrow(3) Value(#ltccustpp)
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Groupbox(#commsbox) Elementtype(divider) Layoutrow(4)

#IOS2.setGroupBoxRow Formview(#COM_OWNER) Name(ar) Groupbox(#commsbox) Elementtype(Textbox) Labeltext('Recievable') Placeholder('+61 2 9999 9999') Layoutrow(5) Value(#ltccustpr)
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Groupbox(#commsbox) Elementtype(divider) Layoutrow(6)

#IOS2.setGroupBoxRow Formview(#COM_OWNER) Name(ap) Groupbox(#commsbox) Elementtype(Textbox) Labeltext('Payable') Placeholder('+61 2 9999 9999') Layoutrow(7) Value(#ltccustpa)
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Groupbox(#commsbox) Elementtype(divider) Layoutrow(8)
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Name(email) Groupbox(#commsbox) Elementtype(Textbox) Labeltext('Email') Placeholder('[email protected]') Layoutrow(9) Value(#ltccustem)
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Groupbox(#commsbox) Elementtype(divider) Layoutrow(10)


* Button under Group
#IOS2.createButton Formview(#COM_OWNER) Parent(#content) Name(signinButton) Layoutrow(14) Text('Save') Color('black') Layoutheight(50) Onclickaction(actionSave)
Endroutine


Mthroutine Name(handleSave)
Define_Com Class(#prim_alph) Name(#ltccustcla)
* Get Values
#IOS2.getElementValue Namedpath('content,basicbox,username') Formview(#COM_OWNER) Value(#ltccustnm)
#IOS2.getElementValue Namedpath('content,basicbox,creditlimit') Formview(#COM_OWNER) Value(#ltccustcla)
#ltccustcl := #ltccustcla.asnumber
#IOS2.getElementValue Namedpath('content,basicbox,discount') Formview(#COM_OWNER) Value(#LTCDISCCD)
#IOS2.getElementValue Namedpath('content,basicbox,website') Formview(#COM_OWNER) Value(#ltccustws)
#IOS2.getElementValue Namedpath('content,billtobox,address1') Formview(#COM_OWNER) Value(#ltccustb1)
#IOS2.getElementValue Namedpath('content,billtobox,address2') Formview(#COM_OWNER) Value(#ltccustb2)
#IOS2.getElementValue Namedpath('content,billtobox,city') Formview(#COM_OWNER) Value(#ltccustbc)
#IOS2.getElementValue Namedpath('content,billtobox,state') Formview(#COM_OWNER) Value(#ltccustbs)
#IOS2.getElementValue Namedpath('content,billtobox,postcode') Formview(#COM_OWNER) Value(#ltccustbz)
#IOS2.getElementValue Namedpath('content,shiptobox,address1') Formview(#COM_OWNER) Value(#ltccusts1)
#IOS2.getElementValue Namedpath('content,shiptobox,address2') Formview(#COM_OWNER) Value(#ltccusts2)
#IOS2.getElementValue Namedpath('content,shiptobox,city') Formview(#COM_OWNER) Value(#ltccustsc)
#IOS2.getElementValue Namedpath('content,shiptobox,state') Formview(#COM_OWNER) Value(#ltccustss)
#IOS2.getElementValue Namedpath('content,shiptobox,postcode') Formview(#COM_OWNER) Value(#ltccustsz)
#IOS2.getElementValue Namedpath('content,commsbox,service') Formview(#COM_OWNER) Value(#ltccustpc)
#IOS2.getElementValue Namedpath('content,commsbox,purchasing') Formview(#COM_OWNER) Value(#ltccustpp)
#IOS2.getElementValue Namedpath('content,commsbox,ar') Formview(#COM_OWNER) Value(#ltccustpr)
#IOS2.getElementValue Namedpath('content,commsbox,ap') Formview(#COM_OWNER) Value(#ltccustpa)
#IOS2.getElementValue Namedpath('content,commsbox,email') Formview(#COM_OWNER) Value(#ltccustem)

* Update File
Update Fields(#custData) In_File(ltccust) With_Key(#W$CSTV) Io_Error(*NEXT) Val_Error(*NEXT)
Endroutine
End_Com
right arrow image
right arrow image
arrow_right.png (299 Bytes) Viewed 17624 times

Re: Resuable Part for Generic iOS screens (RDMLX)

Posted: Thu Sep 13, 2012 8:46 pm
by PascalvanDoorn
Could you add the arrow_right.png to the forum?

Re: Resuable Part for Generic iOS screens - UPDATED (RDMLX)

Posted: Fri Sep 14, 2012 8:28 am
by GregSippel
Pascal,

See the updated post, it includes the right arrow for the old code and example.

Here is another example screen
2012-09-14-08-34-08.jpg
2012-09-14-08-34-08.jpg (138.49 KiB) Viewed 17624 times
Cheers
Greg

Re: Resuable Part for Generic iOS screens - UPDATED (RDMLX)

Posted: Fri Sep 14, 2012 3:07 pm
by PascalvanDoorn
Thanks

Re: Resuable Part for Generic iOS screens - UPDATED (RDMLX)

Posted: Thu Feb 21, 2013 1:15 am
by andysparra
Hi Greg,

This looks great. Have you got the example source for the second screen so we can embed a form as we are struggling to get this to work,

Thanks

Andy

Re: Resuable Part for Generic iOS screens - UPDATED (RDMLX)

Posted: Thu Feb 21, 2013 8:57 am
by GregSippel
Andy,

No worries, here is the code for this reusable part. The code in bold covers the building of the list and the add more entries functionality

* **************************************************
*
* COMPONENT: STD_PANL
*
* **************************************************
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #LRNG_FORM)
* Includes
Define_Com Class(#IOSLOOKV2) Name(#IOS2)
Define_Com Class(#LRTHMS001) Name(#THEME)

Define_Com Class(#prim_nmbr) Name(#pageSize) Value(20)
Define_Com Class(#prim_nmbr) Name(#endPage)
Define_Com Class(#PRIM_NMBR) Name(#W$LORD)
Define_Com Class(#PRIM_ALPH) Name(#APPTHEME)
Define_Com Class(#PRIM_ALPH) Name(#THEMENAME)

* Work Objects
Define_Com Class(#PRIM_ALPH) Name(#actionValue)

* Group_bys
Group_By Name(#orderData) Fields(#LTCOHDRNO #LTCOHDRTL #LTCOHDRIT #LTCOHDRPR #LTCOHDRCN #LTCOHDRDT #LTCOHDROH #LTCOHDRPD #LTCOHDRDD)
* Form Names
Define_Com Class(#PRIM_ALPH) Name(#top)
Define_Com Class(#PRIM_ALPH) Name(#content)
* ===============================================================
* LTCLRSD00 - Mainline
* ===============================================================
Mthroutine Name(HandleRequest) Options(*REDEFINE)

* -----------------------------------------
* Handle currently requested action (if any)
* -----------------------------------------

* Always set the USING Element to /Form.Fields at the start
#Com_Owner.Using Element('/Form.Fields')
*
#COM_OWNER.Set_SharedState Variablename('LTCLR_SALES_LASTRP') Value(*COMPONENT)
#COM_OWNER.Set_SharedState Variablename('LTCLR_SALES_LASTSN') Value(LTC_SALES_ORDERS)

* And Get the Current Top and Content
#COM_OWNER.Get_SharedState Variablename(LTCLR_SALES_currentTop) Value(#top)
#COM_OWNER.Get_SharedState Variablename(LTCLR_SALES_currentContent) Value(#content)

* Hold onto Theme
#Com_Owner.Get_SharedState Variablename('LTCLRDEMO_THEME') Value(#THEMENAME)
#APPTHEME := 'LTCLRDEMO_THEME_' + #THEMENAME


If (#COM_OWNER.RequestACTION.Contains( '_' ))
#actionValue := (#COM_OWNER.RequestACTION).Substring( 1 ((#COM_OWNER.RequestACTION).PositionOf( '_' ) - 1) )
Else
#actionValue := #COM_OWNER.RequestACTION
Endif

Case Of_Field(#actionValue)


When Value_Is(= actionCustomer)

#COM_Owner.SwitchRequestPROGRAM := 'LTCLRSD01'
#COM_Owner.SwitchRequestACTION := 'DEFAULT'
#Com_Owner.SwitchToFormView Named(LTC_SALES_CUST)

When Value_Is(= actionSalesGraph)

#COM_Owner.SwitchRequestPROGRAM := 'LTCLTSD17'
#COM_Owner.SwitchRequestACTION := 'DEFAULT'
#Com_Owner.SwitchToFormView Named(LTC_SALES_CUSTGRPH)




When Value_Is(= actionMore)

* Get Needed Values
#Com_Owner.Get_SharedStateNum Variablename('LTCLR_SALES_lastOrder') Value(#W$LORD)
#Com_Owner.Get_SharedStateNum Variablename('LTCLR_SALES_lastIndex') Value(#LISTCOUNT)

#COM_OWNER.IsNewForm := false
#COM_OWNER.showOrders()

When Value_Is(= actionOrder)

#COM_OWNER.Set_SharedState Variablename('LTCLR_SALES_currentOrder') Value((#COM_OWNER.RequestACTION).Substring( ((#COM_OWNER.RequestACTION).PositionOf( '_' ) + 1) ))

#COM_OWNER.Set_SharedState Variablename(LTCLR_SALES_savedOrder) Value(*blank)

#COM_Owner.SwitchRequestPROGRAM := 'LTCLRSD18'
#COM_Owner.SwitchRequestACTION := 'DEFAULT'
#Com_Owner.SwitchToFormView Named(LTC_SALES_VIEW)


When Value_Is(= actionNewOrder)

#COM_OWNER.Set_SharedState Variablename('LTCLR_SALES_currentOrder') Value('')
#COM_OWNER.Set_SharedState Variablename(LTCLR_SALES_savedOrder) Value(*blank)

#COM_Owner.SwitchRequestPROGRAM := 'LTCLRSD03'
#COM_Owner.SwitchRequestACTION := 'DEFAULT'
#Com_Owner.SwitchToFormView Named(LTC_SALES_ENTRY)


When Value_Is(= actionDetails)

#COM_Owner.SwitchRequestPROGRAM := 'LTCLRSD04'
#COM_Owner.SwitchRequestACTION := 'DEFAULT'
#Com_Owner.SwitchToFormView Named(LTC_SALES_DETS)


When Value_Is(= actionMapCustomer)

* Do the switch
#COM_Owner.SwitchRequestPROGRAM := 'LTCLTSD05'
#COM_Owner.SwitchRequestACTION := 'DEFAULT'
#Com_Owner.SwitchToFormView Named(LTC_SALES_MAP)


Otherwise /* Default */

* Set Needed Values
#listcount := 0

#COM_OWNER.IsNewForm := true
#COM_OWNER.showOrders()

Endcase

* Always Set Current Top and Content
#COM_OWNER.Set_SharedState Variablename(LTCLR_SALES_currentTop) Value(#top)
#COM_OWNER.Set_SharedState Variablename(LTCLR_SALES_currentContent) Value(#content)

Endroutine

Mthroutine Name(showOrders)
Define_Com Class(#prim_alph) Name(#ordersBox)
Define_Com Class(#prim_alph) Name(#orderRow)
Define_Com Class(#PRIM_alph) Name(#dateDate)
Define_Com Class(#PRIM_ALPH) Name(#W$CSTV)
Define_Com Class(#PRIM_ALPH) Name(#statusText)

#Com_Owner.Get_SharedState Variablename('LTCLR_SALES_CURCUST') Value(#W$CSTV)
Fetch Fields(#ltccustnm) From_File(LTCCUST) With_Key(#W$CSTV)

* Init FormView
#IOS2.initFormView Formview(#COM_OWNER) Maintitle('Sales Central - ' + #LTCCUSTNM + ' Orders') Topbarheight(0) Topbarfullname(#top) Contentfullname(#content) Topbarbackcolor(#THEME.topbkgrdcolour<#APPTHEME>) Contentbackcolor(#THEME.contntbkgrdcolour<#APPTHEME>) Divdarkcolor(#THEME.topbkgrdcolour<#APPTHEME>) Divlightcolor(#THEME.topbkgrdcolour<#APPTHEME>)

* Set Nav Buttons
* #com_owner.set_button Layout_Col(1) Layout_Row(1) Name(#top + '.fields.topButton1') Text('Change Customer') Border_Cornerradius(0) Color(#THEME.topactioncolour<#APPTHEME>) Layout_Height(30) Layout_Width(200) Buttonfacecolor(#THEME.topactionbkcolour<#APPTHEME>) Onclick(actionCustomer)
* #com_owner.set_button Layout_Col(2) Layout_Row(1) Name(#top + '.fields.topButton2') Text('Customer Details') Border_Cornerradius(0) Color(#THEME.topactioncolour<#APPTHEME>) Layout_Height(30) Layout_Width(200) Buttonfacecolor(#THEME.topactionbkcolour<#APPTHEME>) Onclick(actionDetails)
* #com_owner.set_button Layout_Col(3) Layout_Row(1) Name(#top + '.fields.topButton3') Text('Map Customer') Border_Cornerradius(0) Color(#THEME.topactioncolour<#APPTHEME>) Layout_Height(30) Layout_Width(200) Buttonfacecolor(#THEME.topactionbkcolour<#APPTHEME>) Onclick(actionMapCustomer)
*
*
* *
#IOS2.initSubForm Formview(#COM_OWNER) Subform(#content) Backcolor(#THEME.contntbkgrdcolour<#APPTHEME>)
#com_owner.Set_Form Name(#content) Grid_Row_N(1) Grid_Row_Height(25)
#com_owner.Set_Form Name(#content) Grid_Row_N(2) Grid_Row_Height(30)
#com_owner.Set_Form Name(#content) Grid_Row_N(3) Grid_Row_Height(fill)
#com_owner.Set_Form Name(#content) Grid_Row_N(4) Grid_Row_Height(20)
* #com_owner.Set_Form Name(#content) Grid_Row_N(5) Grid_Row_Height(50)
#com_owner.Set_Form Name(#content) Grid_Row_N(6) Grid_Row_Height(20)

* Set Instruction Label
#COM_OWNER.Set_Label Name(#content + '.fields.space1') Layout_Row(1) Layout_Col(2)
#COM_OWNER.Set_Label Name(#content + '.fields.instruction1') Layout_Row(2) Layout_Col(2) Text('Choose an order...') Font_Size(18) Color('&4A566C') Font_Bold(true) Padding(5)
* Setup Groupbox on Content Form
#IOS2.createGroupBox Formview(#COM_OWNER) Parent(#content) Name(orderBox) Layoutrow(3) Boxfullname(#ordersBox) Maxheight('475')
* Add Rows to Group by user
#endPage := #Listcount + #pageSize
Select Fields(#orderData) From_File(LTCOHDRV7) Where(#W$CSTV *EQ #ltccustid) With_Key(#W$CSTV #W$LORD) Nbr_Keys(*compute) Options(*STARTKEY)
Continue If(#W$LORD *EQ #ltcohdrno)
#LISTCOUNT := #LISTCOUNT + 1
* Fetch Data
* Set Row
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Groupbox(#ordersBox) Elementtype(form) Name('orderRow_' + #listcount.asstring) Layoutrow(#listcount) Layoutheight(115) Objfullname(#orderRow)

#Com_owner.set_null Property(#orderRow)
#Com_owner.set_null Property(#orderRow + '.Fields.more1')

* Set Content of Row
* Image and Spacer
#COM_OWNER.Set_Image Name(#orderRow + '.fields.logo') Resource(ordericon.png) Layout_Col(1) Layout_Row(1) Layout_Rows(4) Layout_Width(80) Layout_Height(80) Padding(5) Ontouch('actionOrder_' + #ltcohdrno.asstring)
#COM_OWNER.Set_label Name(#orderRow + '.fields.space') Border_Color('white') Layout_Col(2) Layout_Row(1) Layout_Rows(4) Layout_Width(30) Onclick('actionOrder_' + #ltcohdrno.asstring)
* Main Text Row
#dateDate := #LTCOHDRDT.asdate( CCYYMMDD ).AsDisplayString( DDxxbMMMMMMMMMbCCYY )
#COM_OWNER.Set_Label Name(#orderRow + '.fields.title1') Text(#dateDate) Color(Black) Font_Bold(true) Font_Size(20) Layout_Col(3) Layout_Row(1) Layout_Height(28) Layout_Width(250) Onclick('actionOrder_' + #ltcohdrno.asstring)
#COM_OWNER.Set_Label Name(#orderRow + '.fields.title2') Text('No : ' + #ltcohdrno.asstring) Color(Black) Font_Bold(true) Font_Size(20) Layout_Col(4) Layout_Row(1) Layout_Height(28) Layout_Width(150) Onclick('actionOrder_' + #ltcohdrno.asstring)
If (#ltcohdroh *NE N)
#COM_OWNER.Set_Label Name(#orderRow + '.fields.title3') Text(HOLD) Color(red) Font_Bold(true) Font_Size(20) Layout_Col(5) Layout_Row(1) Layout_Height(28) Layout_Width(75) Onclick('actionOrder_' + #ltcohdrno.asstring)
Endif
* Following Rows
#COM_OWNER.Set_Label Name(#orderRow + '.fields.dataline1') Text('Confirmation : ' + #ltcohdrcn + ' Total : ' + #ltcohdrtl.asstring) Color(gray) Font_Bold(true) Font_Size(12) Layout_Col(3) Layout_Row(3) Layout_Height(15) Onclick('actionOrder_' + #ltcohdrno.asstring)
#COM_OWNER.Set_Label Name(#orderRow + '.fields.dataline2') Text('Products : ' + #ltcohdrpr.asstring + ' Items : ' + #ltcohdrit.asstring) Color(gray) Font_Bold(true) Font_Size(12) Layout_Col(3) Layout_Row(4) Layout_Height(15) Onclick('actionOrder_' + #ltcohdrno.asstring)
* Status Row
#statusText := 'Accepted'
If (#ltcohdrpd *NE *zero)
#statusText := 'Packed'
Endif
If (#ltcohdrdd *NE *zero)
#statusText := 'Deliveried'
Endif
#COM_OWNER.Set_Label Name(#orderRow + '.fields.dataline3') Text('Order Status : ' + #statusText) Color(gray) Font_Bold(true) Font_Size(12) Layout_Col(3) Layout_Row(5) Layout_Height(15) Onclick('actionOrder_' + #ltcohdrno.asstring)


* Set Divider
#LISTCOUNT := #LISTCOUNT + 1
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Elementtype(divider) Groupbox(#ordersBox) Layoutrow(#listcount)
#std_flag := M
Leave If(#listcount *EQ #endPage)
#std_flag := *blank
Endselect

If (#std_flag *EQ M)
* Save last order
#com_owner.Set_SharedStateNum Variablename('LTCLR_SALES_lastOrder') Value(#ltcohdrno)
#com_owner.Set_SharedStateNum Variablename('LTCLR_SALES_lastIndex') Value(#listcount)

* Add The Get More Button
#LISTCOUNT := #LISTCOUNT + 1
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Groupbox(#ordersBox) Elementtype(form) Name('orderRow_' + #listcount.asstring) Layoutrow(#listcount) Layoutheight(115) Objfullname(#orderRow)
#com_owner.set_form Name(#orderRow) Grid_Col_N(1) Grid_Col_Width(fill)
#COM_OWNER.Set_label Name(#orderRow + '.Fields.more1') Layout_Col(1) Layout_Row(1) Layout_Height(80) Onclick(actionMore) Padding(5) Valign(middle) Textalign(center) Color(black) Text('Show More...') Font_Size(20) Font_Bold(true)
#LISTCOUNT := #LISTCOUNT + 1
#IOS2.setGroupBoxRow Formview(#COM_OWNER) Elementtype(divider) Groupbox(#ordersBox) Layoutrow(#listcount)
Endif


* Button under Group
#IOS2.createButton Formview(#COM_OWNER) Parent(#content) Name(newOrderButton) Layoutrow(5) Layoutheight(50) Text('Place new order') Color('black') Onclickaction(actionNewOrder)
Endroutine

End_Com