/*
 * Author       : puneet_nagpal
 * Generated on : 22-Nov-2009 23:30:44
 * Version      : 3.0
 */
application "Order Collection Application"
{
    type = public
    date format = "dd-MMM-yyyy"
    time zone = "America/Los_Angeles"
    section Home
    {
        form  Master_Data
        {
            displayname  =  "Master Data"
            
            must  have  Product_Name1
            (
                displayname  =  "Product Name"
                type  =  text
            )

            must  have  Inventory_Levels
            (
                displayname  =  "Inventory Levels"
                type  =  number
                width  =  20
            )

            must  have  Unit_Price
            (
                displayname  =  "Unit Price"
                type  =  INR
                width  =  20
            )

            actions
            {
                on add
                {
                    Submit
                    (
                        type  =  submit
                        displayname  =  "Submit"
                    )
                    Reset
                    (
                        type  =  reset
                        displayname  =  "Reset"
                    )
                }
                on edit
                {
                    Update
                    (
                        type  =  submit
                        displayname  =  "Update"
                    )
                    Cancel
                    (
                        type  =  cancel
                        displayname  =  "Cancel"
                    )
                }
            }
        }

        form  Order_Form
        {
            displayname  =  "Order Form"
            
            must  have  Customer_name
            (
                displayname  =  "Customer name"
                type  =  text
            )

            must  have  Address
            (
                type  =  textarea
            )

            must  have  Product_Name
            (
                displayname  =  "Product Name"
                type  =  picklist
                values  =  {"Sugar Free Condoms",   "Pan Flavored Condoms",   "Ginger Flavored Condoms",   "Black Coffee Condoms",   "VIBGYOR Condoms"}
                defaultvalue  =  "(Select One)"
            )

            must  have  Quantity
            (
                type  =  number
                width  =  20
            )

            Order_Value
            (
                displayname  =  "Order Value"
                type  =  INR
                width  =  20
            )

            actions
            {
                on add
                {
                    Submit
                    (
                        type  =  submit
                        displayname  =  "Submit"
                        on validate
                        {
                            //You can drag and drop tasks from the immediate left pane
                            //Below is the SAMPLE validation script
                            current  =  Master_Data  [Product_Name1 == input.Product_Name];
                            if (current.Inventory_Levels  <  input.Quantity)
                            {
                                alert "invalid input";
                                cancel submit;
                            }
                            else
                            {
                                current.Inventory_Levels = (current.Inventory_Levels  -  input.Quantity);
                                input.Order_Value = (input.Quantity  *  current.Unit_Price);
                            }
                        }
                    )
                    Reset
                    (
                        type  =  reset
                        displayname  =  "Reset"
                    )
                }
                on edit
                {
                    Update
                    (
                        type  =  submit
                        displayname  =  "Update"
                    )
                    Cancel
                    (
                        type  =  cancel
                        displayname  =  "Cancel"
                    )
                }
            }
        }

        list  Order_Form_View
        {
            displayname = "Order Form View"
            show  all  rows  from  Order_Form 
            (
                Customer_name as "Customer name"
                Address
                Quantity
                Order_Value as "Order Value"
                Product_Name as "Product Name"
            )
            options
            (
                display rows = 100
            )
        }

        list  Master_Data_View
        {
            displayname = "Master Data View"
            show  all  rows  from  Master_Data 
            (
                Product_Name1 as "Product Name"
                Inventory_Levels as "Inventory Levels"
                Unit_Price as "Unit Price"
            )
            options
            (
                display rows = 100
            )
        }

    }

}
