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

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/personbasicdetails.xml',
'<View title="Person basic details" defaultFormHandler="xxas_per_basic_details_pkg">

  <EditFields>

    <Poplist id="ACTION_TYPE" label="{message.XXAS_EMP_CHNG_TYPE}" enabled="true" required="true" visible="false" value="CHANGE" listProvider="VALUE_SET_NAME:Applaud PI Action Type"/>
    <Date id="DT_EFFECTIVE_DATE" label="{message.XXAS_EMP_CHNG_EFF_DATE}" visible="false" enabled="true" required="false"/>
    <Poplist id="TITLE" label="{message.XXAS_RB_EMP_EXP_JT}" enabled="true" required="false" listProvider="LOOKUP_TYPE:TITLE"/>
    <TextInput id="FIRST_NAME" label="{message.XXAS_EMP_FIRST_NAME}" enabled="true" required="false"/>
    <TextInput id="MIDDLE_NAMES" label="{message.XXAS_EMP_MIDDLE_NAMES}" enabled="true" required="false"/>
    <TextInput id="PRE_NAME_ADJUNCT" label="{message.XXAS_EMP_PREFIX}" enabled="true" required="false" visible="false"/>
    <TextInput id="LAST_NAME" label="{message.XXAS_EMP_LAST_NAME}" enabled="true" required="true"/>
    <TextInput id="SUFFIX" label="{message.XXAS_EMP_SUFFIX}" enabled="true" required="false" visible="false"/>
    <TextInput id="HONORS" label="{message.XXAS_EMP_HONOURS}" enabled="true" required="false" visible="false"/>
    <TextInput id="KNOWN_AS" label="{message.XXAS_EMP_PREFERRED_NAME}" enabled="true" required="false"/>
    <TextInput id="PREVIOUS_LAST_NAME" label="{message.XXAS_EMP_PLN}" enabled="true" required="false" visible="false"/>
    <Flexfield applicationId="800" descriptiveFlexfieldName="Person Developer DF"/>
    <TextInput id="TOWN_OF_BIRTH" label="{message.XXAS_EMP_TWB}" enabled="true" required="false"/>
    <TextInput id="REGION_OF_BIRTH" label="{message.XXAS_EMP_ROB}" enabled="true" required="false"/>
    <Combolist id="COUNTRY_OF_BIRTH" label="{message.XXAS_EMP_COB}" enabled="true" required="false" listProvider="VALUE_SET_NAME:Applaud PI Country of Birth"/>
    <Combolist id="NATIONALITY" label="{message.XXAS_EMP_NATIONALITY}" enabled="true" required="false" listProvider="LOOKUP_TYPE:NATIONALITY"/>
    <Date id="DATE_OF_DEATH" label="{message.XXAS_EMP_DEATH_DATE}" enabled="true" required="false" visible="false"/>
    <Poplist id="SEX" label="{message.XXAS_EMP_GENDER}" enabled="true" required="true" listProvider="LOOKUP_TYPE:SEX"/>
    <Poplist id="MARITAL_STATUS" label="{message.XXAS_EMP_MARITIAL_STATUS}" enabled="true" required="false" listProvider="LOOKUP_TYPE:MAR_STATUS"/>
    <Poplist id="STUDENT_STATUS" label="{message.XXAS_EMP_STUDENT_STATUS}" enabled="true" required="false" listProvider="LOOKUP_TYPE:STUDENT_STATUS" visible="false"/>
    <Poplist id="REGISTERED_DISABLED_FLAG" label="{message.XXAS_EMP_DISABILITY_STATUS}" enabled="true" required="false" listProvider="LOOKUP_TYPE:REGISTERED_DISABLED" visible="false"/>
    <Poplist id="ON_MILITARY_SERVICE" label="{message.XXAS_EMP_COML}" enabled="true" required="false" listProvider="LOOKUP_TYPE:YES_NO" visible="false" showAsBoolean="true" positiveBooleanValue="Y"/>
    <Poplist id="SECOND_PASSPORT_EXISTS" label="{message.XXAS_EMP_SECOND_PE}" enabled="true" required="false" listProvider="LOOKUP_TYPE:YES_NO" visible="false"  showAsBoolean="true" positiveBooleanValue="Y"/>
    <Combolist id="CORRESPONDENCE_LANGUAGE" label="{message.XXAS_EMP_CL}" enabled="true" required="false" listProvider="VALUE_SET_NAME:Applaud PI Correspondence Language" visible="false"/>
    <Poplist id="USES_TOBACCO_FLAG" label="{message.XXAS_EMP_TOBACCO_USE}" enabled="true" required="false" listProvider="LOOKUP_TYPE:TOBACCO_USER" visible="false"/>
    <Date id="DPDNT_ADOPTION_DATE" label="{message.XXAS_EMP_ADOPTATION_DATE}" enabled="true" required="false" visible="false"/>
    <Date id="DATE_EMPLOYEE_DATA_VERIFIED" label="{message.XXAS_EMP_DATE_LV}" enabled="true" required="false" visible="false"/>
    <Poplist id="COORD_BEN_NO_CVG_FLAG" label="{message.XXAS_EMP_NOT_MP}" enabled="true" required="false" listProvider="LOOKUP_TYPE:YES_NO" visible="false" showAsBoolean="true" positiveBooleanValue="Y"/>
    <Poplist id="DPDNT_VLNTRY_SVCE_FLAG" label="{message.XXAS_EMP_VOLUNTARY_SERVICE}" enabled="true" required="false" listProvider="LOOKUP_TYPE:YES_NO" visible="false" showAsBoolean="true" positiveBooleanValue="Y"/>
    <Number id="FTE_CAPACITY" label="{message.XXAS_EMP_FTA}" enabled="true" visible="false" required="false"/>
    <Combolist id="BENEFIT_GROUP_ID" label="{message.XXAS_EMP_BENEFIT_GROUP}" enabled="true" required="false" visible="false" listProvider="VALUE_SET_NAME:Applaud PI Benefits Group"/>
    <TextInput id="MAILSTOP" label="{message.XXAS_EMP_MAILSTOP}" enabled="true" required="false" visible="false"/>
    <TextInput id="EMAIL_ADDRESS" label="{message.XXAS_EMP_EMAIL_ADDRESS}" enabled="true" required="false" visible="false"/>
    <Poplist id="BLOOD_TYPE" label="{message.XXAS_EMP_BLOOD_TYPE}" enabled="true" required="false" visible="false" listProvider="LOOKUP_TYPE:BLOOD_TYPE"/>
    <Poplist id="WORK_SCHEDULE" label="{message.XXAS_EMP_AVAILABILITY_SH}" enabled="true" required="false" visible="false" listProvider="LOOKUP_TYPE:WORK_SCHEDULE"/>
    <Date id="LAST_MEDICAL_TEST_DATE" label="{message.XXAS_EMP_LAST_MTD}" enabled="true" visible="false" required="false"/>
    <TextInput id="LAST_MEDICAL_TEST_BY" label="{message.XXAS_EMP_LAST_MT}" enabled="true" visible="false" required="false"/>
    <Poplist id="EXPENSE_CHECK_SEND_ADDRESS" label="{message.XXAS_EMP_EXPENSE}" enabled="true" required="false" visible="false" listProvider="LOOKUP_TYPE:HOME_OFFICE"/>

    <Flexfield applicationId ="800" descriptiveFlexfieldName="PER_PEOPLE"/>
    
    <TextInput id="COMMENTS_TO_APPROVER" label="{message.XXAS_RB_TCM_APPR_CMNTS}" enabled="true" required="false"/>
    
    <Attachment id="ATTACHMENTS" label="{message.XXAS_RB_EMP_ATTACHMENTS}" enabled="true" required="false" entityName="PQH_SS_ATTACHMENT"
                pk1Field="INSTANCE_PK2_VALUE" categoryCode="MISC"/>
    
  </EditFields>

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