DLG_UCHKOUT Dialog Component

Purpose

The DLG_UCHKOUT dialog component is part of the checkout process. It captures or displays the customer information required by the billing and shipping processes.

[Picture]

Description

The DLG_UCHKOUT dialog component contains the text controls necessary to enter a new customer table record or display an existing record. The DLG_UCHKOUT dialog illustrates the use of a tab control with multiple tab panes.

Containers

CHECKOUTUSER.A5W

Notable Grid Control Property Settings

Control

Property

Description

[Tab Control].1

Tab Control Properties > Tab properties > Type

Set to "Bands".

[Tab Pane].1

Tab Pane Properties > Tab label

Set to "Personal Information".

[Tab Pane].2

Tab Pane Properties > Tab label

Set to "Shipping Information".

[Tab Pane].3

Tab Pane Properties > Tab label

Set to "Contact Information".

City

Row Properties

Freeform layout set to TRUE.

Freeform template set to "{city} {state} {zip}".

State

Row Properties > Hide row

Set to TRUE.

Zip

Row Properties > Hide row

Set to TRUE.

Ship_to_Name

Control Settings > Validation rules

General > Enable rules set to TRUE.

General > Require value set to TRUE.

Ship_to_Address

Control Settings > Validation rules

General > Enable rules set to TRUE.

General > Require value set to TRUE.

Ship_to_City

Control Settings > Validation rules

General > Enable rules set to TRUE.

General > Require value set to TRUE.

Row Properties

Freeform layout set to TRUE.

Freeform template set to "Ship_to_City} {Ship_to_State} {Ship_to_Zip}".

Ship_to_State

Row Properties > Hide row

Set to TRUE.

Ship_to_Zip

Row Properties > Hide row

Set to TRUE.

Email

Control Settings > Validation rules

General > Enable rules set to TRUE.

General > Require value set to TRUE.

Text Format > Regular Expression  set to "\b[A-Z0-9a-z._%-]+@[A-Z0-9a-z._%-]+\.[A-Za-z]{2,4}\b".

Notable Component Property Settings

Property

Description

Dialog Footer Layout > Freeform layout

Changed to TRUE.

Dialog Footer Layout > Dialog footer template

Changed to "<div align="center">{SubmitButton}&nbsp;<input class="BlueWhiteButton" type="submit" value="&nbsp;&nbsp;Clear Entries&nbsp;&nbsp;" name="clearbutton"></div>".

Event Code

The AfterValidate event code starts by checking the session.dataclear variable. If it is TRUE, there is no data to validate and the script exits.

if session.dataclear = .T. ' skip validate if clearing data

    end

end if

Next, the script sets session.__protected__chkoutprogress to 2, indicating that this page is complete.

session.__protected__chkoutprogress = 2

The following statements copy the values in the various controls on the dialog component in the session.__protected__chkout dot variable.

dim session.__protected__chkout as P

property_recurse_assign(session.__protected__chkout, CurrentForm.Controls)

The customerid control has a non-null value, the script uses this value to retrieve the corresponding record from the customer table.

if CurrentForm.Controls.customerid <> "" ' values came from a table record

    query.filter = "customer_id = " + quote(CurrentForm.Controls.customerid) ' find the record

    query.order = ""

    tbl = table.open("[PathAlias.ADB_Path]\customer.dbf")

    qdx = tbl.query_create()

If the query finds a single record, then the script writes the values in the dialog's controls into the fields of the customer record.

    if qdx.records_get() = 1 then 'record found - update

        tbl.change_begin()

        tbl.Firstname = alltrim(CurrentForm.Controls.First_Name)

        tbl.Lastname = alltrim(CurrentForm.Controls.Last_Name)

        tbl.Company = alltrim(CurrentForm.Controls.company)

        tbl.Email = alltrim(CurrentForm.Controls.Email)

        tbl.Phone = transform(remspecial(CurrentForm.Controls.phone),"@R (999) 999-9999") ' convert to standard mask template

        tbl.Bill_address_1 = alltrim(CurrentForm.Controls.addr1)

        tbl.Bill_address_2 = alltrim(CurrentForm.Controls.addr2)

        tbl.Bill_city = alltrim(CurrentForm.Controls.city)

        tbl.Bill_state_region = alltrim(CurrentForm.Controls.state)

        tbl.Bill_postal_code = alltrim(CurrentForm.Controls.zip)

        tbl.Ship_to_name = alltrim(CurrentForm.Controls.Ship_to_Name)

        tbl.Ship_address_1 = alltrim(CurrentForm.Controls.Ship_to_Address)

        tbl.Ship_address_2 = alltrim(CurrentForm.Controls.saddr2)

        tbl.Ship_city = alltrim(CurrentForm.Controls.Ship_to_City)

        tbl.Ship_state_region = alltrim(CurrentForm.Controls.Ship_to_State)

        tbl.Ship_postal_code = alltrim(CurrentForm.Controls.Ship_to_Zip)

        tbl.change_end()

    end if

    tbl.close()

end if

The Activate event code tests to see if the session.dataclear variable exists and is TRUE. If so, it erases the values of the dialog's controls and the session.__protected__chkout variable, the exits. Finally, it sets session.dataclear to FALSE.

if eval_valid("session.dataclear") = .T. then

    if session.dataclear = .t. then

        CurrentForm.Controls.customerid =""

        CurrentForm.Controls.addr1 = ""

        CurrentForm.Controls.addr2 = ""

        CurrentForm.Controls.city = ""

        CurrentForm.Controls.company = ""

        CurrentForm.Controls.customerid = ""

        CurrentForm.Controls.Email = ""

        CurrentForm.Controls.First_Name = ""

        CurrentForm.Controls.Last_Name = ""

        CurrentForm.Controls.phone = ""

        CurrentForm.Controls.Ship_to_Address = ""

        CurrentForm.Controls.saddr2 = ""

        CurrentForm.Controls.Ship_to_City= ""

        CurrentForm.Controls.Ship_to_Name = ""

        CurrentForm.Controls.Ship_to_State = ""

        CurrentForm.Controls.state = ""

        CurrentForm.Controls.Ship_to_Zip = ""

        CurrentForm.Controls.zip = ""

        property_recurse_assign(session.__protected__chkout, CurrentForm.Controls) ' clear session variable

        session.dataclear = .F. 'clear once unless reset on page

        end

    end if

end if

The next step is to test if the session.enteruserdata variable (a customer ID) exists and is NULL. If this is the case, the script copies the data from session.__protected__chkout into the dialog's controls. This variable contains data saved info from a previous visit to this page.

if eval_valid("session.enteruserdata") then

    if session.enteruserdata = "" then

        if eval_valid("session.__protected__chkout")

            property_recurse_assign(CurrentForm.Controls, session.__protected__chkout)

        end if

If the session.enteruserdata variable contains data, the script uses it to find the appropriate customer record. If it finds a record, the script copies the record data into the dialog's controls.

    else

        query.filter = "alltrim(customer_id) = " + quote(session.enteruserdata)

        query.order = ""

        tbl = table.open("[PathAlias.ADB_Path]\customer.dbf")

        qdx = tbl.query_create()

        if qdx.records_get() = 1 then 'record found

            CurrentForm.Controls.customerid = alltrim(tbl.Customer_id)

            CurrentForm.Controls.First_Name = alltrim(tbl.Firstname)

            CurrentForm.Controls.Last_Name = alltrim(tbl.Lastname)

            CurrentForm.Controls.company = alltrim(tbl.Company)

            CurrentForm.Controls.Email = alltrim(tbl.Email)

            CurrentForm.Controls.phone = alltrim(tbl.Phone)

            CurrentForm.Controls.addr1 = alltrim(tbl.Bill_address_1)

            CurrentForm.Controls.addr2 = alltrim(tbl.Bill_address_2)

            CurrentForm.Controls.city = alltrim(tbl.Bill_city)

            CurrentForm.Controls.state = alltrim(tbl.Bill_state_region)

            CurrentForm.Controls.zip = alltrim(tbl.Bill_postal_code)

            if tbl.Ship_same = .T.

                CurrentForm.Controls.Ship_to_Name = alltrim(tbl.Firstname) + " "+alltrim(tbl.Lastname)

                CurrentForm.Controls.Ship_to_Address = alltrim(tbl.Bill_address_1)

                CurrentForm.Controls.saddr2 = alltrim(tbl.Bill_address_2)

                CurrentForm.Controls.Ship_to_City = alltrim(tbl.Bill_city)

                CurrentForm.Controls.Ship_to_State = alltrim(tbl.Bill_state_region)

                CurrentForm.Controls.Ship_to_Zip = alltrim(tbl.Bill_postal_code)

            else         

                CurrentForm.Controls.Ship_to_Name = alltrim(tbl.Ship_to_name)

                CurrentForm.Controls.Ship_to_Address = alltrim(tbl.Ship_address_1)

                CurrentForm.Controls.saddr2 = alltrim(tbl.Ship_address_2)

                CurrentForm.Controls.Ship_to_City = alltrim(tbl.Ship_city)

                CurrentForm.Controls.Ship_to_State = alltrim(tbl.Ship_state_region)

                CurrentForm.Controls.Ship_to_Zip = alltrim(tbl.Ship_postal_code)

            end if

        end if

        tbl.close()

    end if

Next, the script sets session.enteruserdata to NULL.

    session.enteruserdata = ""

If session.enteruserdata does not exist, but session.__protected__chkout does exist, the script copies the contents of session.__protected__chkout into the dialog's controls.

elseif eval_valid("session.__protected__chkout")

    property_recurse_assign(CurrentForm.Controls, session.__protected__chkout)

end if

See Also

Web Publishing Components

Supported By

Alpha Five Version 7 and Above