/* $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/newhire.xml');

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/newhire.xml',
'<View title="New Hire" showSubmit="true"  isStepper="Y">

  <EditFields>
  
    <Stepper id="step1" title="{message.XXAS_MSS_BASIC_DET_GRP}" postAsParentFields="true">
	 <Container id="OVERVIEW_GRP" description="{message.XXAS_NH_BASIC_DET_DESC}" >
	  <Hidden id="PERSON_ID" />
	  <Hidden id="BUSINESS_GROUP_ID" />
	  <Combolist id="BUSINESS_GROUP_1" label="{message.XXAS_EMP_BG}" visible="true" listProvider="VALUE_SET_NAME:XXAS_Business_Groups" longlist="true" triggerName="NEW_HIRE_BUSINESS_GROUP" triggerMethod="POST"/>
	  <TextInput id="FIRSTNAME" label="{message.XXAS_EMP_FIRST_NAME}" visible="true" triggerName="NEW_HIRE_GET_FIRST_NAME" triggerMethod="POST"/>
	  <TextInput id="LASTNAME" label="{message.XXAS_EMP_LAST_NAME}" visible="true" required="true" triggerName="NEW_HIRE_LAST_NAME" triggerMethod="POST" />
	  <Date id="DATE_FROM" label="{message.XXAS_MSS_START_DATE}" visible="true" triggerName="NEW_HIRE_START_DATE" triggerMethod="POST"/>
	  <Number id="PH_NO" label="{message.XXAS_NH_PERSONAL_PHN}" visible="true" triggerName="MGR_NH_PHONE_NO_DEFAULT" triggerMethod="POST"/>
	  <Date id="DOB" label="{message.XXAS_EMP_DOB}" visible="true" triggerName="NEW_HIRE_GET_DOB" triggerMethod="POST"/>
	  <TextInput id="SOCIAL_SECURITY" label="{message.XXAS_NH_SS_NUM}" visible="true" required="true" triggerName="MGR_NEW_HIRE_PER_DUP_CHK" triggerMethod="POST"/>
	  <TextInput id="POTENTIALS" visible="false"/>
	  <Poplist id="MATCHES" label="" enabled="true" value="N" style="radio" triggerName="MGR_NEW_HIRE_PER_DUP_SEL" triggerMethod="POST"/>
	  <ListItem id="DUP_PERSON" style="row" visible="true" listFunction="xxas_new_hire_pkg.get_list_item_value"/>
	  <Poplist id="INST_MESSAGE" label="{message.XXAS_NH_INST_MSG}" listProvider="LOOKUP_TYPE:YES_NO" visible="false" showAsBoolean="true" positiveBooleanValue="Y"/>
	  <TextInput id="ERR_MESSAGE" visible="false"/>
	  <TextInput id="WARN_MESSAGE" visible="false"/>	  
	 </Container> 
    </Stepper>
	
	<Stepper id="step2" title="{message.XXAS_NH_PERSONAL_INFO}">
		
		<Hidden id="PERSON_ID"/>
		<Hidden id="BUSINESS_GROUP_2" />
        <Container id="HIRE_DETAILS" label="{message.XXAS_NH_HIRE_DETAILS}" visible="true">
			<Date id="START_DATE_ID" enabled="false" label="{message.XXAS_MSS_START_DATE}" visible="true" />
			<Combolist id="PERSON_TYPE_ID" label="{message.XXAS_MSS_PERSON_TYPE}" listProvider="REST:newhire/personType?bgId=${fieldNR.BUSINESS_GROUP_2}" enabled="true" required="false"/>
		</Container>

		<Container id="BASIC_DETAILS" label="{message.XXAS_NH_NAME}" visible="true">
			<Poplist id="TITLE_APP" label="{message.XXAS_RB_EMP_EXP_JT}" enabled="true" required="false" listProvider="LOOKUP_TYPE:TITLE"/>
			<TextInput id="FIRST_NAME_APP" label="{message.XXAS_EMP_FIRST_NAME}" enabled="true" required="false"/>
			<TextInput id="MIDDLE_NAMES_APP" label="{message.XXAS_EMP_MIDDLE_NAMES}" enabled="true" required="false"/>
			<TextInput id="LAST_NAME_APP" label="{message.XXAS_EMP_LAST_NAME}" enabled="true" required="true" visible="true"/>
			<TextInput id="PRE_NAME_ADJUNCT_APP" label="{message.XXAS_EMP_PREFIX}" description="{message.XXAS_NH_PREFIX_DES}" enabled="true" required="false" visible="true"/>
			<TextInput id="SUFFIX_APP" label="{message.XXAS_EMP_SUFFIX}" description="{message.XXAS_NH_SUFFIX_DES}" enabled="true" required="false" visible="true"/>
			<TextInput id="KNOWN_AS_APP" label="{message.XXAS_NH_PREFFERED_NAME}" description="{message.XXAS_NH_KNOWN_AS_DES}" enabled="true" required="false" visible="true"/>
			<TextInput id="PREVIOUS_LAST_NAME_APP" label="{message.XXAS_EMP_PLN}" description="{message.XXAS_NH_PREVIOUS_NAME_DES}" enabled="true" required="false" visible="true"/>
		</Container>
    
		<Container id="OTHER_DETAILS" label="{message.XXAS_NH_OTHER_DETAILS}" visible="true">
			<TextInput id="NATIONAL_IDENTIFIER_APP" label="{message.XXAS_NH_SOCIAL_SECURITY}" enabled="true" required="false"/>
			<Date id="DATE_OF_BIRTH_APP" label="{message.XXAS_EMP_DOB}" enabled="true" required="true" visible="true"/>
			<Poplist id="SEX_APP" label="{message.XXAS_EMP_GENDER}" enabled="true" required="true" listProvider="LOOKUP_TYPE:SEX"/>
			<Poplist id="MARITAL_STATUS_APP" label="{message.XXAS_EMP_MARITIAL_STATUS}" enabled="true" required="false" listProvider="LOOKUP_TYPE:MAR_STATUS"/>
			<TextInput id="EMAIL_ADDRESS_APP" label="{message.XXAS_NH_EMAIL_ADDRESS}" enabled="true" required="false" visible="true"/>
		</Container>
    
		<Container id="MAIN_ADDRESS" label="{message.XXAS_NH_MAIN_ADDRESS}" visible="true">
		    <Poplist id="ADDRESS_TYPE" label="{message.XXAS_NH_ADDRESS_TYPE}" listProvider="LOOKUP_TYPE:ADDRESS_TYPE"/>
			<Flexfield applicationId="800" descriptiveFlexfieldName="Address Structure" />
		</Container>
    
      	<Container id="PHONE_NO" label="{message.XXAS_EMP_PHONE_NUMBERS}" visible="true">
			<MultiRow id="PHONE_NUMBERS" createAllowed="true" deleteAllowed="true" toBeInSingleRow="true" xdbUri="/public/xxas/emp/view/nh-phone-number.xml"/>
		</Container>
    </Stepper>
	
    <Stepper id="step3" title="{message.XXAS_NH_ASG_DETAILS}">
		<Hidden id="PERSON_ID"/>
		<Hidden id="BUSINESS_GROUP_3"/>
		
		<Container id="DEPARTMENT" label="{message.XXAS_MSS_ORGANIZATION_ID}" visible="true">
			<Combolist id="ORGANIZATION_ID" label="{message.XXAS_MSS_ORGANIZATION_ID}" listProvider="REST:newhire/organization?bgId=${field.BUSINESS_GROUP_3}" longlist="true" visible="true" enabled="true" required="true" triggerName="NEW_HIRE_GET_LOC_ID" triggerMethod="POST"/>
		    <Hidden id="LOCATION_ID" />
			<TextInput id="LOCATION_NAME" label="{message.XXAS_MSS_LOCATION_ID}" enabled="false" required="false"/>
		</Container>
	
		<Container id="JOB" label="{message.XXAS_EMP_JOB}" visible="true">
			<Combolist id="JOB_TITLE" label="{message.XXAS_MSS_JOB_ID}" enabled="true" required="false" listProvider="REST:newhire/job?bgId=${field.BUSINESS_GROUP_3}" longlist="true" refreshOnChange="true"/>
			<Poplist id="IS_MANAGER" label="{message.XXAS_NH_IS_MGR}" listProvider="LOOKUP_TYPE:YES_NO" required="false" triggerName="MGR_NEW_HIRE_NEW_DR_COMP" triggerMethod="POST" enabled="true" visible="true" showAsBoolean="true" positiveBooleanValue="Y"/>
		</Container>
	
		<Container id="POSITION" label="{message.XXAS_MSS_POSITION_ID}" visible="true">
			<Poplist id="POSITION_ID" label="{message.XXAS_MSS_POSITION_ID}" listProvider="REST:newhire/position?bgId=${field.BUSINESS_GROUP_3}&amp;orgId=${fieldNR.ORGANIZATION_ID}&amp;jobId=${fieldNR.JOB_TITLE}" longlist="true" visible="true" refreshOnChange="true"/>
		</Container>
	
		<Container id="GRADE" label="{message.XXAS_EMP_GRADE}" visible="true">    
            <Combolist id="GRADE_LADDER_ID" label="{message.XXAS_MSS_GRADE_LADDER_PGM_ID}" listProvider="REST:newhire/gradeladder?bgId=${field.BUSINESS_GROUP_3}" longlist="true" visible="true" refreshOnChange="true"/>
            <Combolist id="GRADE_NAME_ID" label="{message.XXAS_NH_GRADE_NAME}" listProvider="REST:newhire/gradeName?bgId=${field.BUSINESS_GROUP_3}&amp;gradeLadderId=${fieldNR.GRADE_LADDER_ID}&amp;jobId=${fieldNR.JOB_TITLE}" longlist="true" visible="true" refreshOnChange="true"/>
            <Combolist id="CEILING_POINT" label="{message.XXAS_NH_CEILING_POINT}" listProvider="REST:newhire/specialceiling?bgId=${field.BUSINESS_GROUP_3}&amp;gradeId=${fieldNR.GRADE_NAME_ID}" longlist="true" visible="true" refreshOnChange="true"/>
            <TextInput id="CEILING_STEP" label="{message.XXAS_NH_CEILING_STEP}" hideIf="!model.GRADE.CEILING_POINT.value" />    
        </Container>
	
		<Container id="PEOPLE_GROUP" label="{message.XXAS_MSS_PG_GRP}" visible="true">
			<Flexfield applicationShortCode="PAY" flexCode="GRP" flexStructureCode="PEOPLE_GROUP_FLEXFIELD"/>
		</Container>

		<Container id="STATUTORY_INFO" label="{message.XXAS_MSS_ST_GRP}" visible="true">
			<Flexfield applicationShortCode="PER" flexCode="SCL" flexStructureCode="AU_STATUTORY_INFO."/>
		</Container>
	
		<Container id="OTHER_ASG_INFO" label="{message.XXAS_NH_ASG_INFO}" visible="true">
		
			<TextInput id="PA_BILLING_TITLES" label="{message.XXAS_NH_PA_BILL}" enabled="true" required="false"/>
			<Poplist id="BUSINESS_GROUP" label="{message.XXAS_EMP_BG}" enabled="true" required="false" listProvider="VALUE_SET_NAME:ADS Business Group" />
			<Combolist id="MOVE_EMPLOYEE" label="{message.XXAS_NH_MOVE_EMP}" listProvider="LOOKUP_TYPE:YES_NO" required="false"  enabled="true" visible="true" />
			<Poplist id="ALT_BG_SUPERVISOR" label="{message.XXAS_NH_ALT_BG_SUP}" enabled="true" required="false" listProvider="REST:newhire/AltBGSupervisor?bgId=${field.BUSINESS_GROUP_3}" longlist="true" />
			<Poplist id="EMPLOYEE_CATEGORY" label="{message.XXAS_MSS_EMPLOYEE_CATEGORY}" enabled="true" required="false" listProvider="VALUE_SET_NAME:CAGR_EMPLOYEE_CATEGORY" />
			<Poplist id="ASSIGNMENT_CATEGORY" label="{message.XXAS_MSS_ASG_CATEGORY}" enabled="true" required="false" listProvider="VALUE_SET_NAME:CAGR_EMPLOYMENT_CATEGORY" />
			<Combolist id="BARGAINING_UNIT" label="{message.XXAS_MSS_BARGAINING_UNIT_CODE}" enabled="true" required="false" listProvider="VALUE_SET_NAME:CAGR_BARGAINING_UNIT" longlist="true"/>
			<Poplist id="labour_union_member" label="{message.XXAS_NH_UNION_MEM}" listProvider="LOOKUP_TYPE:YES_NO" required="false" refreshOnChange="false" enabled="true" visible="true"  showAsRadio="false" showAsBoolean="true" positiveBooleanValue="Y"/>
		
		</Container>
	
		<Container id="SALARY_INFORMATION" label="{message.XXAS_MSS_PAY_GRP}" visible="true">
			<Poplist id="PAY_BASIS_ID" label="{message.XXAS_MSS_PAY_BASIS_ID}" enabled="true" required="false" listProvider="REST:newhire/payBasis?bgId=${field.BUSINESS_GROUP_3}" />
			<TextInput id="SAL_REVIEW_PERIOD" label="{message.XXAS_NH_SAL_REV_PERIOD}" enabled="true" required="false"/>
			<Poplist id="SAL_REVIEW_PERIOD_FREQUENCY" label="{message.XXAS_NH_SAL_REV_FREQ}" enabled="true" required="false" listProvider="LOOKUP_TYPE:FREQUENCY"/>
			<TextInput id="PERF_REVIEW_PERIOD" label="{message.XXAS_NH_PREF_REV_PERIOD}" enabled="true" required="false"/>
			<Poplist id="PERF_REVIEW_PERIOD_FREQUENCY" label="{message.XXAS_NH_PREF_REV_FREQ}" enabled="true" required="false" listProvider="LOOKUP_TYPE:FREQUENCY"/>
		</Container>
	
		<Container id="PROJECT_INFO" label="{message.XXAS_NH_PROJ_INFO}" visible="true">
			<TextInput id="BILLING" label="{message.XXAS_MSS_TITLE}" enabled="true" required="false"/>
		</Container>	
    </Stepper>
	
	<Stepper id="step4" title="{message.XXAS_NH_PAY_DETAILS}" postAsParentFields="true" >

	  <Poplist id="PROPOSED_CHANGE_PAY" label="{message.XXAS_NH_CHNG_PAY_PROPOSE}" listProvider="LOOKUP_TYPE:YES_NO" required="false"  visible="true"  showAsRadio="false" showAsBoolean="true" positiveBooleanValue="Y"/>
        
	  <Container id="CHANGE_PAY" hideIf="!(model.PROPOSED_CHANGE_PAY.value) || (model.PROPOSED_CHANGE_PAY.value == &apos;N&apos;)">
		
		<Poplist id="CHG_COMP" label="{message.XXAS_NH_CHNG_PAY_COMP}" listProvider="LOOKUP_TYPE:YES_NO" triggerName="MGR_NEW_HIRE_PAY_COMP_CHG_DET" triggerMethod="POST" enabled="true" value="N" style="radio"/>
		
			<TextInput id="PROPOSED_SALARY_N" label="{message.XXAS_CHNG_PAY_CHG_SAL}" enabled="false" required="false" 	visible="false"/>
			<Poplist id="PROPOSAL_REASON" label="{message.XXAS_NH_CHNG_PAY_CHG_REASON}" enabled="true" required="false" visible="true" listProvider="LOOKUP_TYPE:PROPOSAL_REASON"/>
			<Date id="EFFECTIVE_FROM" label="{message.XXAS_CHNG_PAY_EFF_DATE}" enabled="true" visible="true" required="true"/>
			<Poplist id="PAY_INCREASE_BY" label="{message.XXAS_NH_CHNG_PAY_CHG_BY}" required="true" visible="true" listProvider="LOOKUP_TYPE:XXAS_NH_PAY_INCREASE_BY" triggerName="MGR_NEW_HIRE_PAY_COMP_CHG" triggerMethod="POST" hideIf="model.CHANGE_PAY.CHG_COMP.value.id == &apos;Y&apos;"/>
			<Number id="CHANGE_AMOUNT" label="{message.XXAS_CHNG_PAY_NEW_AMOUNT}" enabled="true" required="false" visible="true" hideIf="(model.CHANGE_PAY.PAY_INCREASE_BY.value.id != &apos;AMOUNT&apos;)" triggerName="MGR_NEW_HIRE_PAY_CHG" triggerMethod="POST" />
			<Number id="CHANGE_EQUIVALENT" label="{message.XXAS_CHNG_PAY_NEW_ANNUAL_EQ}" enabled="true" required="false" visible="true" hideIf="(model.CHANGE_PAY.PAY_INCREASE_BY.value.id != &apos;EQUIVALENT&apos;)" triggerName="MGR_NEW_HIRE_PAY_CHG" triggerMethod="POST" />
			<Number id="CHANGE_ANNUAL_FTE" label="{message.XXAS_CHNG_PAY_NEW_ANNUAL_FTE}" enabled="true" required="false" visible="true" hideIf="(model.CHANGE_PAY.PAY_INCREASE_BY.value.id != &apos;FTE&apos;)" triggerName="MGR_NEW_HIRE_PAY_CHG" triggerMethod="POST"/>
			<Number id="T_CHANGE_AMOUNT" label="{message.XXAS_CHNG_PAY_NEW_AMOUNT}" enabled="false" required="false" visible="false" />
			<Number id="T_CHANGE_ANNUAL_FTE" label="{message.XXAS_CHNG_PAY_NEW_ANNUAL_FTE}" enabled="false" required="false" visible="false" />
		    <Number id="T_CHANGE_EQUIVALENT" label="{message.XXAS_CHNG_PAY_NEW_ANNUAL_EQ}" enabled="false" required="false" visible="false" />
		
		<Container id="CHG_SAL_COMP" label="{message.XXAS_CHNG_PAY_SAL_COMPONENTS}" visible="true" enabled="true"  hideIf="model.CHANGE_PAY.CHG_COMP.value.id == &apos;N&apos;">
          <MultiRow id="SALARY_COMPONENTS" deleteAllowed="true" createAllowed="true" includeEmptyRow="true" xdbUri="/public/xxas/emp/view/nh_changepaycomponents.xml" formulaName="XXAS_BK_PAY_DETAILS_EDIT"/>
        </Container>
	  </Container>

    </Stepper>
	
    <Stepper id="step5" title="{message.XXAS_NH_ORG_STRUCTURE}">
		<Container id="ASSIGN_NEW_MGR" label="{message.XXAS_NH_NEW_MGR}" >
			<Combolist id="NEW_MANAGER" label="{message.XXAS_NH_NEW_MGR}" enabled="true" listProvider="REST:peoplesearch/dir-reportee?q={searchText}" longlist="true"/>
		</Container>
		
		<Container id="ASSIGN_NEW_DR" label="{message.XXAS_NH_ASSIGN_NEW_DR}"  description="{message.XXAS_NH_NEW_DR_DESC}">
			<MultiRow id="NEW_DIRECT_REPORTS" createAllowed="true" createLabel="{message.XXAS_NH_ADD_REPORT}" visible="true" includeEmptyRow="true" xdbUri="/public/xxas/emp/view/nh-newdirectreports.xml" formulaName="XXAS_NEW_HIRE_PH_GET_SET"/>
		</Container>
    </Stepper>
	
   </EditFields>

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