/* $Id$ */
/*============================================================================*
 |                 Copyright (c) 2014 Applaud Solutions UK Ltd                |
 |                             All rights reserved                            |
 *===========================================================================*/

SET VERIFY OFF
SET FEEDBACK OFF
SET SCAN OFF
WHENEVER OSERROR  EXIT FAILURE ROLLBACK
WHENEVER SQLERROR EXIT FAILURE ROLLBACK


DECLARE 

  e_dir_exists EXCEPTION;
  PRAGMA EXCEPTION_INIT(e_dir_exists, -31003);

  e_does_not_exists EXCEPTION;
  PRAGMA EXCEPTION_INIT(e_does_not_exists , -31001);

  result boolean;
  
BEGIN

  BEGIN

    result := DBMS_XDB.createfolder('/public/xxas/');
    result := DBMS_XDB.createfolder('/public/xxas/emp/');
    result := DBMS_XDB.createfolder('/public/xxas/emp/view/');

  EXCEPTION
    WHEN e_dir_exists THEN
      NULL;
  END;

  
  BEGIN

    DBMS_XDB.DeleteResource('/public/xxas/emp/view/htmlvacancy.xml');

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/htmlvacancy.xml',
'<View title="Vacancy" defaultFormHandler="xxas_vacancy_pkg.post_create_vacancy">

  <EditFields>

    <Container id="OVERVIEW_GRP" label="Overview">
      <Hidden id="PERSON_ID"/>
      <Hidden id="VACANCY_ID"/>
      <Hidden id="TRANSACTION_ID"/>
      <TextInput id="VACANCY_NAME" label="Vacancy Name" required="true" visible="true"/>
      <Poplist id="STATUS_CODE" label="Status" listProvider="LOOKUP_TYPE:VACANCY_STATUS" enabled="false"/>
      <Date id="DATE_FROM" label="Start Date" required="true"/>
      <Date id="DATE_TO" label="End Date"/>
      <Number id="NUMBER_OF_OPENINGS" label="Total Openings" visible="false"/>
      <Number id="BUDGET_VALUE" label="Number of Openings"/>
      <Poplist id="BUSINESS_GROUP_ID" label="Business Group" listProvider="VALUE_SET_NAME:XXAS_Recruiting_Business_Groups" enabled="false" required="true"/>
      <Combolist id="MANAGER_ID" label="Manager" listProvider="REST:peoplesearch" longlist="true" refreshOnChange="true"/>
      <Combolist id="POSITION_ID" label="Position" listProvider="VALUE_SET_NAME:XXAS_Recruiting_Positions"  required="true" refreshOnChange="true"/>
      <Combolist id="JOB_ID" label="Job Title" listProvider="VALUE_SET_NAME:XXAS_Recruiting_Jobs" refreshOnChange="true"/>
      <Combolist id="LOCATION_ID" label="Location" listProvider="VALUE_SET_NAME:XXAS_Recruiting_Locations" refreshOnChange="true"/>
      <Combolist id="ORGANIZATION_ID" label="Organization" listProvider="VALUE_SET_NAME:XXAS_Recruiting_Organizations" refreshOnChange="true"/>
      <Combolist id="GRADE_ID" label="Grade" listProvider="VALUE_SET_NAME:XXAS_Recruiting_Grades" refreshOnChange="true"/>
      <Poplist id="PROFESSIONAL_AREA" label="Professional Area" visible="true" listProvider="LOOKUP_TYPE:IRC_PROFESSIONAL_AREA"/>
      <Poplist id="EMPLOYEE_FLAG" label="Employee" value="Y" listProvider="LOOKUP_TYPE:YES_NO" showAsBoolean="true" positiveBooleanValue="Y"/>
      <Poplist id="CONTRACTOR_FLAG" label="Contractor" value="Y" listProvider="LOOKUP_TYPE:YES_NO" showAsBoolean="true" positiveBooleanValue="Y"/>
      <Poplist id="EMPLOYMENT_CATEGORY" label="Employment Status" listProvider="LOOKUP_TYPE:IRC_EMP_CAT"/>
      <Flexfield applicationId ="800" descriptiveFlexfieldName="PER_VACANCIES"/>
    </Container>

    <Container id="COMPENSATION_GRP" label="Compensation Information" enabled="false">
      <Number id="MIN_SALARY" label="Salary Minimum"/>
      <Number id="MAX_SALARY" label="Salary Maximum"/>
      <Poplist id="SALARY_CURRENCY" label="Currency" listProvider="VALUE_SET_NAME:Applaud Currencies"/>
      <Poplist id="BUDGET_TYPE_CODE" label="Budget Type" visible="false" value="HEAD" listProvider="LOOKUP_TYPE:BUDGET_MEASUREMENT_TYPE"/>
      <Poplist id="SALARY_PERIOD_CODE" label="Salary Period" listProvider="LOOKUP_TYPE:PAY_BASIS" visible="false" value="ANNUAL"/>
      <MultiRow id="VARIABLE_COMP_ELEMENTS" xdbUri="/public/xxas/emp/view/vacancyvarcompelements.xml" toBeInSingleRow="true" createAllowed="true" createLabel="Add Compensation"/>
      <Flexfield applicationId ="801" flexCode="GRP"/>
    </Container>
    
    <Container id="TRAVEL_GRP" label="Travel Information">
      <Poplist id="TRAVEL_PERCENTAGE" label="Amount of Travel" listProvider="LOOKUP_TYPE:IRC_TRAVEL_PERCENTAGE"/>
      <Poplist id="WORK_AT_HOME" label="Work at Home" listProvider="LOOKUP_TYPE:IRC_WORK_AT_HOME"/>
    </Container>

    <Container id="SKILLS_GRP" label="Skills">
      <MultiRow id="COMPETENCE_ELEMENTS" createAllowed="true" toBeInSingleRow="true" createLabel="Add Skill" xdbUri="/public/xxas/emp/view/vacancycompetencies.xml" />
	</Container>
	
	<Container id="QUALIFICATION_GRP" label="Qualifications">
      <Poplist id="MIN_QUAL_LEVEL_ID" label="Minimum Qualification" listProvider="VALUE_SET_NAME:Applaud Qualification Types"/>
      <Poplist id="MAX_QUAL_LEVEL_ID" label="Maximum Qualification" listProvider="VALUE_SET_NAME:Applaud Qualification Types"/>
      <Flexfield applicationId ="800" descriptiveFlexfieldName="IRC_SEARCH_CRITERIA" columnNamePrefix="ISC_"/>
    </Container>
    
    <Container id="ASSESSMENT_GRP" label="Assessment">
      <Poplist id="ASSESSMENT_ID" label="Assessment" listProvider="VALUE_SET_NAME:XXAS_HTML_VACANCY_ASSESSMENTS"/>
    </Container>
    
    <Container id="SECURITY_METHOD_GRP" label="Security Method">
      <Poplist id="SECURITY_METHOD" label="Security Method" listProvider="LOOKUP_TYPE:IRC_SECURITY_METHOD"/>
    </Container>
    
    <Container id="REC_TEAM_GRP" label="Recruiting Team">
      <MultiRow id="TEAM_MEMBERS" xdbUri="/public/xxas/emp/view/htmlvacancyteam.xml" toBeInSingleRow="true" createAllowed="true" createLabel="Add Team Member"/>
    </Container>
    
    <Container id="AGENCIES_GRP" label="Agencies">
      <MultiRow id="AGENCY_VACANCIES" xdbUri="/public/xxas/emp/view/vacancyagency.xml" toBeInSingleRow="true" createAllowed="true" createLabel="Add Agency"/>
    </Container>
    
    <Container id="COMMUNICATION_GRP" label="Communication Properties" visible="false" enabled="true">
      <Poplist id="DEFAULT_COMM_STATUS" label="Default Communication Status" required="false" listProvider="LOOKUP_TYPE:IRC_COMM_DEFAULT_COMM_STATUS"/>
      <Poplist id="AUTO_NOTIFICATION_FLAG" label="Send Notification" value="N" listProvider="LOOKUP_TYPE:YES_NO" showAsBoolean="true" positiveBooleanValue="Y"/>
      <Poplist id="ALLOW_ATTACHMENT_FLAG" label="Allow Attachments" required="false" listProvider="LOOKUP_TYPE:IRC_COMM_ALLOW_ATTACHMENT_FLAG"/>
      <Poplist id="ALLOW_ADD_RECIPIENTS" label="Add Recipients"  required="false" listProvider="LOOKUP_TYPE:IRC_COMM_ALLOW_ADD_RECIPIENTS"/>
      <Poplist id="DEFAULT_MODERATOR" label="Moderator"  required="false" listProvider="LOOKUP_TYPE:IRC_COMM_DEFAULT_MODERATOR"/>
    </Container>
	
    <Container id="RECRUITER_GRP" label="Recruiter Details">
	<Combolist id="RECRUITER_ID" label="Recruiter Name" listProvider="REST:peoplesearch" longlist="true" refreshOnChange="true"/>
	</Container>
	
	
    <Container id="JOB_POSTING_GRP" label="Format Job Posting">
      <TextInput id="POSTING_NAME" label="Job Posting Title" required="true"/>
      <TextInput id="POSTING_JOB_TITLE" label="Job Title"/>
      <TextInput id="POSTING_ORG_NAME" label="Organization Name"/>
      <TextArea id="POSTING_ORG_DESCRIPTION" label="Department Description" richText="true"/>
      <TextArea id="POSTING_BRIEF_DESCRIPTION" label="Brief Posting Description" richText="true"/>
      <TextArea id="POSTING_DETAILED_DESCRIPTION" label="Detailed Description" richText="true"/>
      <TextArea id="POSTING_JOB_REQUIREMENTS" label="External Job Requirements" richText="true"/>
      <TextArea id="POSTING_ADDITIONAL_DETAILS" label="Internal Job Requirements" richText="true"/>
      <TextArea id="POSTING_HOW_TO_APPLY" label="How to Apply" richText="true"/>
      <TextInput id="IMAGE_URL" label="Graphic"/>
      <Poplist id="DISPLAY_RECRUITER_INFO" label="Display Recruiter Details" value="N" listProvider="LOOKUP_TYPE:YES_NO" showAsBoolean="true" positiveBooleanValue="Y"/>
      <Flexfield applicationId ="800" descriptiveFlexfieldName="IRC_POSTING_CONTENTS"/>
      
    </Container>    
    
    <Container id="REC_ACTIVITY_GRP" label="Recruiting Sites">
      <MultiRow id="RECRUITMENT_ACTIVITIES" createAllowed="true" createLabel="Add Site" toBeInSingleRow="true" label="Recruiting Sites" xdbUri="/public/xxas/emp/view/vacancyrecruitmentactivities.xml"/>
    </Container>   
    
    <Container id="ATTACH_GRP" label="Attachments">
      <MultiRow id="ATTACHMENTS" createAllowed="true" toBeInSingleRow="true" createLabel="Add Attachment" xdbUri="/public/xxas/emp/view/attach.xml" />
    </Container>
    
    <Container id="APPROVERS_GRP" label="Approvers" reviewOnly="true">
      <MultiRow id="APPROVERS" label="Approvers" toBeInSingleRow="true" xdbUri="/public/xxas/emp/view/approver.xml"/>
      <TextArea id="COMMENTS_TO_APPROVER" label="Comments to Approver"/>
    </Container> 

  </EditFields>

</View>' ); 
xxas_forms_pkg.update_forms_resource('/public/xxas/emp/view/htmlvacancy.xml');
END;

/
COMMIT;
EXIT;
