/* $Id$ */
/*============================================================================*
 |                 Copyright (c) 2017 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-review.xml');

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

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

    <Hidden id="EFFECTIVE_DATE"/>
    <Hidden id="PERSON_ID"/>
    <Hidden id="TRANSACTION_ID"/>
	<Hidden id="PHONE_NUMBER_STEP_ID"/>
    <Hidden id="CHANGE_PAY_STEP_ID"/>
    <Hidden id="SUPERVISOR_STEP_ID"/>
	<Hidden id="NO_OF_DRS"/>
	<Hidden id="HAS_APPROVERS"/>

	<ListItem id="APPROVERS" label="Approvers" style="row" listFunction="xxas_new_hire_pkg.get_newhire_workflow_details" visible="true" hideIf="model.HAS_APPROVERS.value == &apos;N&apos;"/>
	
	<Container id="BASIC_DETAILS" label="{message.XXAS_MSS_BASIC_DET_GRP}" visible="true">
		<TextInput id="FIRST_NAME" label="{message.XXAS_EMP_FIRST_NAME}" enabled="false" required="false" hideIf="!model.BASIC_DETAILS.FIRST_NAME.value"/>
		<TextInput id="MIDDLE_NAMES" label="{message.XXAS_EMP_MIDDLE_NAMES}" enabled="false" required="false" hideIf="!model.BASIC_DETAILS.MIDDLE_NAMES.value"/>
		<TextInput id="LAST_NAME" label="{message.XXAS_EMP_LAST_NAME}" enabled="false" required="false" hideIf="!model.BASIC_DETAILS.LAST_NAME.value"/>
		<TextInput id="PREFIX" label="{message.XXAS_EMP_PREFIX}" enabled="false" required="false" visible="true" hideIf="!model.BASIC_DETAILS.PREFIX.value"/>
		<TextInput id="SUFFIX" label="{message.XXAS_EMP_SUFFIX}" enabled="false" required="false" visible="true" hideIf="!model.BASIC_DETAILS.SUFFIX.value"/>
		<TextInput id="PREFERRED_NAME" label="Preffered Name" enabled="false" required="false" visible="true" hideIf="!model.BASIC_DETAILS.PREFERRED_NAME.value"/>
		<TextInput id="PREVIOUS_LAST_NAME" label="{message.XXAS_EMP_PLN}"  enabled="false" required="false" visible="true" hideIf="!model.BASIC_DETAILS.PREVIOUS_LAST_NAME.value"/>
		<TextInput id="NATIONAL_IDENTIFIER" label="{message.XXAS_NH_SS_NUM}" enabled="false" hideIf="!model.BASIC_DETAILS.NATIONAL_IDENTIFIER.value"/>
		<Date      id="DATE_OF_BIRTH" label="{message.XXAS_EMP_DOB}" enabled="false" required="true" hideIf="!model.BASIC_DETAILS.DATE_OF_BIRTH.value"/>
		<Date      id="DATE_START" label="{message.XXAS_MSS_START_DATE}" enabled="false" required="true" hideIf="!model.BASIC_DETAILS.DATE_START.value"/>
		<Poplist   id="SEX" label="{message.XXAS_EMP_GENDER}" enabled="false" required="false" listProvider="LOOKUP_TYPE:SEX" hideIf="!model.BASIC_DETAILS.SEX.value"/>
		<Poplist   id="MARITAL_STATUS" label="{message.XXAS_EMP_MARITIAL_STATUS}" enabled="false" listProvider="LOOKUP_TYPE:MAR_STATUS" hideIf="!model.BASIC_DETAILS.MARITAL_STATUS.value"/>
		<TextInput id="ORG_EMAIL_ADDRESS" label="{message.XXAS_NH_EMAIL_ADDRESS}" enabled="false" hideIf="!model.BASIC_DETAILS.ORG_EMAIL_ADDRESS.value"/>
	</Container>
	
	<Container id="MAIN_ADDRESS" label="{message.XXAS_NH_MAIN_ADDRESS}" visible="true">
		<TextInput id="ADDRESS_TYPE" label="{message.XXAS_NH_ADDRESS_TYPE}" enabled="false" hideIf="!model.MAIN_ADDRESS.ADDRESS_TYPE.value"/>
		<Flexfield applicationId="800" descriptiveFlexfieldName="Address Structure" />
	</Container>
	
    <Container id="ASSIGNMENT" label="{message.XXAS_NH_ASG_DETAILS}" visible="true">
		<TextInput id="ASG_BUSINESS_GROUP_ID" label="{message.XXAS_EMP_BG}" visible="false" />
		<TextInput id="ORGANIZATION_ID" label="{message.XXAS_MSS_ORGANIZATION_ID}" visible="false" />
		<Poplist id="WORK_AT_HOME" label="{message.XXAS_NH_HOME_WORKER}" listProvider="LOOKUP_TYPE:YES_NO"  enabled="false" hideIf="!model.ASSIGNMENT.WORK_AT_HOME.value"/>
		<TextInput id="ORG_NAME" label="{message.XXAS_MSS_ORGANIZATION_ID}" enabled="false" required="false" hideIf="!model.ASSIGNMENT.ORG_NAME.value"/>
		<TextInput id="JOB_NAME" label="{message.XXAS_MSS_JOB_ID}" enabled="false" hideIf="!model.ASSIGNMENT.JOB_NAME.value"/>
		<TextInput id="POSITION_NAME" label="{message.XXAS_MSS_POSITION_ID}" enabled="false" hideIf="!model.ASSIGNMENT.POSITION_NAME.value"/>		
		<Poplist id="GRADE_ID" label="{message.XXAS_MSS_GRADE_LADDER_PGM_ID}" listProvider="REST:newhire/gradeLadderName" enabled="false" hideIf="!model.ASSIGNMENT.GRADE_ID.value"/>
		<TextInput id="GRADE_NAME" label="{message.XXAS_NH_GRADE_NAME}" enabled="false" hideIf="!model.ASSIGNMENT.GRADE_NAME.value"/>		
		<Poplist id="PAY_BASIS_ID" label="{message.XXAS_MSS_PAY_BASIS_ID}" enabled="false" required="false" listProvider="REST:newhire/payBasisId" hideIf="!model.ASSIGNMENT.PAY_BASIS_ID.value" />
		<TextInput id="SALARY_REVIEW_PERIOD" label="{message.XXAS_NH_SAL_REV_PERIOD}" enabled="false" hideIf="!model.ASSIGNMENT.SALARY_REVIEW_PERIOD.value"/>
		<Poplist id="SAL_REV_PERIOD_FREQ" label="{message.XXAS_NH_SAL_REV_FREQ}" enabled="false" required="false" listProvider="LOOKUP_TYPE:FREQUENCY" hideIf="!model.ASSIGNMENT.SAL_REV_PERIOD_FREQ.value"/>
		<TextInput id="PERF_REV_PERIOD" label="{message.XXAS_NH_PREF_REV_PERIOD}" enabled="false" hideIf="!model.ASSIGNMENT.PERF_REV_PERIOD.value"/>
		<Poplist id="PREF_REV_PERIOD_FREQ" label="{message.XXAS_NH_PREF_REV_FREQ}" enabled="false" required="false" listProvider="LOOKUP_TYPE:FREQUENCY" hideIf="!model.ASSIGNMENT.PREF_REV_PERIOD_FREQ.value"/>
		<Poplist id="LOCATION_ID" label="{message.XXAS_MSS_LOCATION_ID}" listProvider="REST:newhire/location?orgId=${field.ORGANIZATION_ID}" enabled="false" hideIf="!model.ASSIGNMENT.LOCATION_ID.value"/>
		<TextInput id="WORK_HOURS" label="{message.XXAS_NH_WORK_HOURS}"  enabled="false" hideIf="!model.ASSIGNMENT.WORK_HOURS.value"/>
		<Poplist id="FREQUENCY" label="{message.XXAS_MSS_FREQUENCY}" listProvider="LOOKUP_TYPE:FREQUENCY" enabled="false" hideIf="!model.ASSIGNMENT.FREQUENCY.value"/>
		<TextInput id="TIME_NORMAL_START" label="{message.XXAS_MSS_TIME_NORMAL_START}"  enabled="false" hideIf="!model.ASSIGNMENT.TIME_NORMAL_START.value"/>
		<TextInput id="TIME_NORMAL_FINISH" label="{message.XXAS_MSS_TIME_NORMAL_FINISH}"  enabled="false" hideIf="!model.ASSIGNMENT.TIME_NORMAL_FINISH.value"/>
		<Poplist id="ASG_CATEGORY" label="{message.XXAS_MSS_ASG_CATEGORY}" enabled="false" required="false" listProvider="VALUE_SET_NAME:CAGR_EMPLOYMENT_CATEGORY" hideIf="!model.ASSIGNMENT.ASG_CATEGORY.value" />
		<TextInput id="BILLING_TITLE" label="{message.XXAS_MSS_TITLE}"  enabled="false" hideIf="!model.ASSIGNMENT.BILLING_TITLE.value"/>
		<Combolist id="BARGAINING_UNIT_CODE" label="{message.XXAS_MSS_BARGAINING_UNIT_CODE}" enabled="false" required="false" listProvider="VALUE_SET_NAME:CAGR_BARGAINING_UNIT" longlist="true" hideIf="!model.ASSIGNMENT.BARGAINING_UNIT_CODE.value"/>
		<Poplist id="UNION_MEMBER_FLAG" label="{message.XXAS_NH_UNION_MEM}" listProvider="LOOKUP_TYPE:YES_NO"  enabled="false" hideIf="!model.ASSIGNMENT.UNION_MEMBER_FLAG.value"/>
		<Poplist id="PRIMARY_ASSIGNMENT" label="{message.XXAS_NH_PRIMARY_ASG}" listProvider="LOOKUP_TYPE:YES_NO"  enabled="false" hideIf="!model.ASSIGNMENT.PRIMARY_ASSIGNMENT.value"/>
	   
		<Container id="STATUTORY_INFO" label="{message.XXAS_MSS_ST_GRP}" visible="true">
			<Flexfield applicationShortCode="PER" flexCode="SCL"/>
    </Container>
	</Container>
	
	<Container id="PHONE_NUMBERS" label="{message.XXAS_EMP_PHONE_NUMBER}" visible="true" hideIf="!model.PHONE_NUMBER_STEP_ID.value">
		<MultiRow id="PHONE_DETAILS" toBeInSingleRow="true" xdbUri="/public/xxas/emp/view/list_phone_numbers.xml" visible="true"/>
	</Container>
	
	<Container id="CHANGE_PAY" label="{message.XXAS_NH_NEW_PAY}" visible="true" hideIf="!model.CHANGE_PAY_STEP_ID.value">
		<Date id="CHANGE_PAY_DATE" label="{message.XXAS_MSS_EFFECTIVE_DATE}" enabled="false" required="true" hideIf="!model.CHANGE_PAY.CHANGE_PAY_DATE.value"/>
		<TextInput id="SALARY_BASIS" label="{message.XXAS_NH_BASIS}"  enabled="false" hideIf="!model.CHANGE_PAY.SALARY_BASIS.value"/>
		<Number id="PROPOSED_SALARY" label="{message.XXAS_NH_PAY_AMT}"  enabled="false"  hideIf="!model.CHANGE_PAY.PROPOSED_SALARY.value" />
		<Number id="CHANGE_AMOUNT" label="{message.XXAS_NH_CHANGE_AMT}"  enabled="false"  hideIf="!model.CHANGE_PAY.CHANGE_AMOUNT.value" />
		<Number id="ANNUAL_EQUIVALENT" label="{message.XXAS_NH_ANNUAL_EQ}"  enabled="false"  hideIf="!model.CHANGE_PAY.ANNUAL_EQUIVALENT.value" />
		<Number id="ANNUAL_FULLTIME_EQ" label="{message.XXAS_NH_ANNUAL_FULLTIME_EQ}"  enabled="false"  hideIf="!model.CHANGE_PAY.ANNUAL_FULLTIME_EQ.value" />
	</Container>
	
	<Container id="NEW_MANAGER" label="{message.XXAS_MSS_NEW_MANAGER}" visible="true" hideIf="!model.SUPERVISOR_STEP_ID.value">
		<MultiRow id="NEW_MANAGER_DETAILS" toBeInSingleRow="true" xdbUri="/public/xxas/emp/view/manager_details.xml" visible="true"/>
	</Container>
	
	<Container id="NEW_DIRECT_REPORTS" label="{message.XXAS_NH_NEW_DR}" visible="true" hideIf="!model.NO_OF_DRS.value">
		<MultiRow id="DR_DETAILS" toBeInSingleRow="true" xdbUri="/public/xxas/emp/view/list_direct_reports.xml" visible="true"/>
	</Container>

  </EditFields>

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