/*
 * Author       : zchelp
 * Generated on : 22-Nov-2009 22:34:59
 * Version      : 3.0
 */
application "Recruitment"
{
    type = public
    date format = "dd-MMM-yyyy"
    time zone = "America/Los_Angeles"
    section Admin_Add_opening
    {
        displayname = "Admin - Add opening"
        form  New_Opening
        {
            displayname  =  "Add new opening"
            
            must  have  Position_Name
            (
                displayname  =  "Position Name"
                type  =  text
                width  =  30
                maxchar  =  30
            )

            must  have  Status
            (
                type  =  picklist
                values  =  {"Open",   "Closed"}
            )

            must  have  Position_Type
            (
                displayname  =  "Position Type"
                type  =  picklist
                values  =  {"Full Time",   "Part Time"}
            )

            must  have  Experience
            (
                type  =  picklist
                values  =  {"Fresher",   "Experience 1yr",   "Experience 2+yrs",   "Experience 5+yrs",   "Experience 10+yrs"}
            )

            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"
                    )
                }
            }
        }

    }

    section View_Openings
    {
        displayname = "View Openings"
        list  Available_openings
        {
            displayname = "Available openings"
            show  all  rows  from  New_Opening 
            (
                Position_Name as "Position Name"
                Status
                Position_Type as "Position Type"
                Experience
            )
            filters 
            (
                "Openings"  :  Status == "Open"
            )
            options
            (
                display rows = 100
            )
        }

        list  All_job_profiles
        {
            displayname = "All job profiles"
            show  all  rows  from  New_Opening 
            (
                Position_Name as "Position Name"
                Status
                Position_Type as "Position Type"
                Experience
            )
            options
            (
                display rows = 100
            )
        }

    }

    section Post_Application
    {
        displayname = "Post Application"
        form  New_Applicant
        {
            displayname  =  "Add your resume"
            
            must  have  Applicant_Name
            (
                displayname  =  "Your Name"
                type  =  text
                width  =  30
                maxchar  =  30
            )

            must  have  Email_ID
            (
                displayname  =  "Email ID"
                type  =  email
                width  =  30
                maxchar  =  30
            )

            Date_of_Birth
            (
                displayname  =  "Date of Birth"
                type  =  date
            )

            must  have  Education
            (
                type  =  picklist
                values  =  {"B.E",   "B.Tech",   "B.Sc",   "B.Com",   "B.A",   "M.A",   "M.S",   "M.Com",   "M.Sc",   "MBA",   "MCA",   "M.E",   "M.Tech",   "Diploma"}
            )

            Experience
            (
                type  =  picklist
                values  =  {"Fresher",   "Experience 1yr",   "Experience 2+yrs",   "Experience 5+yrs",   "Experience 10+yrs"}
            )

            Applied_For
            (
                displayname  =  "Applied For"
                type  =  picklist
                values  =  New_Opening.Position_Name
            )

            Address
            (
                type  =  textarea
            )

            Call_for_written_test
            (
                type  =  checkbox
                private  =  true
                defaultvalue  =  false
            )

            actions
            {
                on add
                {
                    Submit
                    (
                        type  =  submit
                        displayname  =  "Submit"
                        on success
                        {
                            opening  =  New_Opening  [Position_Name == input.Applied_For];
                            if (opening.Status  ==  "Closed")
                            {
                                sendmail
                                (
                                    To       :  input.Email_ID 
                                    From     :  zoho.adminuserid 
                                    Subject  :  "Reg application for job posted at recruitment.zohocreator.com" 
                                    Message  :  "The job profile " + input.Applied_For + " for which you have applied is not currently open " 
                                )
                            }
                            else if (opening.Experience  ==  input.Experience)
                            {
                                sendmail
                                (
                                    To       :  "manager-recruitment@adventnet.com" 
                                    From     :  zoho.adminuserid 
                                    Subject  :  "Applicants resume matches job profile" 
                                    Message  :  input.Applicant_Name + " matches the job profile<br> Contach Info: " + input.Email_ID 
                                )
                            }
                            else
                            {
                                sendmail
                                (
                                    To       :  input.Email_ID 
                                    From     :  zoho.adminuserid 
                                    Subject  :  "Reg application for job posted at recruitment.zohocreator.com" 
                                    Message  :  "The experience required for the job profile " + input.Applied_For + "does not match yours" 
                                )
                            }
                        }
                    )
                    Reset
                    (
                        type  =  reset
                        displayname  =  "Reset"
                    )
                }
                on edit
                {
                    Update
                    (
                        type  =  submit
                        displayname  =  "Update"
                    )
                    Cancel
                    (
                        type  =  cancel
                        displayname  =  "Cancel"
                    )
                }
            }
        }

    }

    section Admin_View_applications
    {
        displayname = "Admin - View applications"
        list  View_all_applications
        {
            displayname = "View all applications"
            show  all  rows  from  New_Applicant 
            (
                Applicant_Name as "Your Name"
                Email_ID as "Email ID"
                Date_of_Birth as "Date of Birth"
                Education
                Experience
                Applied_For as "Applied For"
                Address
            )
            options
            (
                display rows = 100
            )
        }

    }

    section Admin_Shortlisted_candidates
    {
        displayname = "Admin - Shortlisted candidates"
        list  View_shortlisted_candidates
        {
            displayname = "View shortlisted candidates"
            show  all  rows  from  shortlisted_candidates 
            (
                Candidate_Name as "Name of the candidate"
                Referred_By as "Referred By"
                Hiring_Manager as "Hiring Manager"
                Resume_Status as "Resume Status"
                Date_Field
                Comments
            )
            options
            (
                display rows = 100
            )
        }

        form  shortlisted_candidates
        {
            displayname  =  "Update shortlisted candidates list"
            
            Candidate_Name
            (
                displayname  =  "Name of the candidate"
                type  =  picklist
                values  =  New_Applicant[Call_for_written_test].Applicant_Name
            )

            Referred_By
            (
                displayname  =  "Referred By"
                type  =  text
                width  =  30
                maxchar  =  30
            )

            Hiring_Manager
            (
                displayname  =  "Hiring Manager"
                type  =  text
                width  =  30
                maxchar  =  30
            )

            Resume_Status
            (
                displayname  =  "Resume Status"
                type  =  picklist
                values  =  {"Call for a Written Test",   "Call for an Interview",   "Completed Written Test",   "Being considered for the Job",   "Job offered",   "Rejected"}
                on update
                {
                    candidate  =  New_Applicant  [Applicant_Name == input.Candidate_Name];
                    if (input.Resume_Status  ==  "Call for a Written Test")
                    {
                        sendmail
                        (
                            To       :  candidate.Email_ID 
                            From     :  zoho.adminuserid 
                            Subject  :  "Reg application for job posted at recruitment.zohocreator.com" 
                            Message  :  "Hello " + input.Candidate_Name + ",<br><br> Please appear for a written test to be conducted on " + input.Date_Field + "<br> <br>  Best Regards,<br> Recruitment Manager" 
                        )
                    }
                    else if (input.Resume_Status  ==  "Call for an Interview")
                    {
                        sendmail
                        (
                            To       :  candidate.Email_ID 
                            From     :  zoho.adminuserid 
                            Subject  :  "Reg application for job posted at recruitment.zohocreator.com" 
                            Message  :  (("Hello " + input.Candidate_Name + ", <br> Congratulations. You have cleared the written test. Please appear for an interview to be held on ") + input.Date_Field) + "<br> <br>  Best Regards,<br> Recruitment Manager" 
                        )
                    }
                }
            )

            Date_Field
            (
                type  =  date
            )

            Comments
            (
                type  =  textarea
            )

            actions
            {
                on add
                {
                    Submit
                    (
                        type  =  submit
                        displayname  =  "Submit"
                        on success
                        {
                            candidate  =  New_Applicant  [Applicant_Name == input.Candidate_Name];
                            if (input.Resume_Status  ==  "Call for a Written Test")
                            {
                                sendmail
                                (
                                    To       :  candidate.Email_ID 
                                    From     :  zoho.adminuserid 
                                    Subject  :  "Reg application for job posted at recruitment.zohocreator.com" 
                                    Message  :  "Hello " + input.Candidate_Name + ",<br><br> Please appear for a written test to be conducted on " + input.Date_Field + "<br> <br>  Best Regards,<br> Recruitment Manager" 
                                )
                            }
                            else if (input.Resume_Status  ==  "Call for an Interview")
                            {
                                sendmail
                                (
                                    To       :  candidate.Email_ID 
                                    From     :  zoho.adminuserid 
                                    Subject  :  "Reg application for job posted at recruitment.zohocreator.com" 
                                    Message  :  (("Hello " + input.Candidate_Name + ", <br> Congratulations. You have cleared the written test. Please appear for an interview to be held on ") + input.Date_Field) + "<br> <br>  Best Regards,<br> Recruitment Manager" 
                                )
                            }
                        }
                    )
                    Reset
                    (
                        type  =  reset
                        displayname  =  "Reset"
                    )
                }
                on edit
                {
                    Update
                    (
                        type  =  submit
                        displayname  =  "Update"
                    )
                    Cancel
                    (
                        type  =  cancel
                        displayname  =  "Cancel"
                    )
                }
            }
        }

    }

}
