/*
 * Author       : nandhini.p
 * Generated on : 30-Jul-2009 15:53:32
 * Version      : 3.0
 */
application "SMS"
{
    allow html = true
    date format = "dd-MMM-yyyy"
    time zone = "Asia/Calcutta"
    section Home
    {
        form  SMS_Details
        {
            displayname  =  "SMS Details"
            
            must  have  To
            (
                displayname  =  "To :"
                type  =  number
                width  =  20
                maxchar  =  15
            )

            must  have  Text_to_content
            (
                displayname  =  "Content to send :"
                type  =  textarea
            )

            actions
            {
                on add
                {
                    Submit
                    (
                        type  =  submit
                        displayname  =  "Submit"
                        on success
                        {
                            thisapp.sendSMS(input.To, input.Text_to_content);
                        }
                    )
                    Reset
                    (
                        type  =  reset
                        displayname  =  "Reset"
                    )
                }
                on edit
                {
                    Update
                    (
                        type  =  submit
                        displayname  =  "Update"
                    )
                    Cancel
                    (
                        type  =  cancel
                        displayname  =  "Cancel"
                    )
                }
            }
        }

        list  SMS_Details_View
        {
            displayname = "SMS Details View"
            show  all  rows  from  SMS_Details 
            (
                To as "To :"
                Text_to_content as "Text to content :"
            )
            options
            (
                display rows = 10
            )
        }

    }

    functions
    {
        void sendSMS(int to, string text)
        {
            sendmail
            (
                To       :  "sms@messaging.clickatell.com" 
                From     :  zoho.loginuserid                 
                Subject  :  "SMS" 
                Message  :  "user:clickatellusername\npassword:clickatellpassword\napi_id: APIKEY\nfrom:ZohoCreator\nto:" + input.to + "\ntext:" + input.text 
                Content type :  Plain Text 
            )
        }

    }

}

