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

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/contactdetails.xml',
'<View title="Contact details" defaultFormHandler="xxas_per_contact_pkg">

  <CreateFields>
    <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="EMAIL_ADDRESS" label="{message.XXAS_EMP_EMAIL_ADDRESS}" enabled="true" required="false" visible="true"/>
    <TextInput id="BLOOD_TYPE" label="{message.XXAS_EMP_BLOOD_TYPE}" enabled="true" required="false" visible="true"/>
    
    <Poplist id="CONTACT_TYPE" label="{message.XXAS_EMP_RELATIONSHIP}" enabled="true" required="true" listProvider="LOOKUP_TYPE:CONTACT" refreshOnChange="true"/>
    <Date id="DATE_START" label="{message.XXAS_EMP_RSD}" enabled="true" required="true" visible="true"/>
    <Poplist id="EMRG_CONTACT_FLAG" label="{message.XXAS_EMP_EMERGENCY_CONTACT}" enabled="true" required="true" listProvider="LOOKUP_TYPE:YES_NO" visible="true" refreshOnChange="true" showAsBoolean="true" positiveBooleanValue="Y" value="Y"/>
    <Date id="DATE_END" label="Relationship End Date" enabled="true" required="false" visible="false"/>
    <Poplist id="PRIMARY_CONTACT_FLAG" label="{message.XXAS_EMP_PRIMARY_CONTACT}" enabled="true" required="false" listProvider="LOOKUP_TYPE:YES_NO" visible="false" showAsBoolean="true" positiveBooleanValue="Y" value="N"/>
   
    <Flexfield applicationId="800" descriptiveFlexfieldName="Person Developer DF"/>
    <Flexfield applicationId="800" descriptiveFlexfieldName="Contact Relship Developer DF"/>
    <Flexfield applicationId="800" descriptiveFlexfieldName="PER_CONTACTS"/>  
    <Flexfield applicationId="800" descriptiveFlexfieldName="PER_PEOPLE"/> 
    
    <Poplist id="SEX" label="{message.XXAS_EMP_GENDER}" enabled="true" required="false" listProvider="LOOKUP_TYPE:SEX" visible="false"/>
    <TextInput id="NATIONAL_IDENTIFIER" label="{message.XXAS_EMP_NATIONAL_IDENTIFIER}" enabled="true" required="false" visible="false"/>
    <TextInput id="TOWN_OF_BIRTH" label="{message.XXAS_EMP_TWB}" enabled="true" required="false" visible="false"/>
    <TextInput id="REGION_OF_BIRTH" label="{message.XXAS_EMP_ROB}" enabled="true" required="false" visible="false"/>
    <Combolist id="COUNTRY_OF_BIRTH" label="{message.XXAS_EMP_COB}" enabled="true" required="false" visible="false" listProvider="VALUE_SET_NAME:Applaud PI Country of Birth"/>
    <Poplist id="MARITAL_STATUS" label="{message.XXAS_EMP_MARITIAL_STATUS}" enabled="true" required="false" listProvider="LOOKUP_TYPE:MAR_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="USES_TOBACCO_FLAG" label="{message.XXAS_EMP_TOBACCO_USE}" enabled="true" required="false" listProvider="LOOKUP_TYPE:TOBACCO_USER" visible="false"/>
    <Poplist id="START_LIFE_REASON_ID" label="{message.XXAS_EMP_START_RR}" enabled="true" required="false" listProvider="VALUE_SET_NAME:Applaud PI Start Relationship Reason" visible="false"/>
    <Date id="DATE_OF_BIRTH" label="{message.XXAS_EMP_DOB}" enabled="true" required="false" visible="false"/>
    <Date id="DPDNT_ADOPTION_DATE" label="{message.XXAS_EMP_ADOPTATION_DATE}" enabled="true" required="false" visible="false"/>
    <Date id="DATE_OF_DEATH" label="{message.XXAS_EMP_DEATH_DATE}" enabled="true" required="false" visible="false"/>
    <Poplist id="STUDENT_STATUS" label="{message.XXAS_EMP_STUDENT_STATUS}" enabled="true" required="false" listProvider="LOOKUP_TYPE:STUDENT_STATUS" 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="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"/>
    
    <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_PK3_VALUE" categoryCode="MISC" visible="false"/> 
  </CreateFields>
  
  <EditFields>
    <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="EMAIL_ADDRESS" label="{message.XXAS_EMP_EMAIL_ADDRESS}" enabled="true" required="false" visible="true"/>
    
    <Poplist id="CONTACT_TYPE" label="{message.XXAS_EMP_RELATIONSHIP}" enabled="true" required="true" listProvider="LOOKUP_TYPE:CONTACT" refreshOnChange="true"/>
    <Date id="DATE_START" label="{message.XXAS_EMP_RSD}" enabled="true" required="true" visible="true"/>
    <Poplist id="EMRG_CONTACT_FLAG" label="{message.XXAS_EMP_EMERGENCY_CONTACT}" enabled="true" required="true" listProvider="LOOKUP_TYPE:YES_NO" visible="true" refreshOnChange="true" showAsBoolean="true" positiveBooleanValue="Y" value="Y"/>
    <Date id="DATE_END" label="{message.XXAS_EMP_RELATIONSHIP_END_DATE}" enabled="true" required="false" visible="false"/>
    <Poplist id="PRIMARY_CONTACT_FLAG" label="{message.XXAS_EMP_PRIMARY_CONTACT}" enabled="true" required="false" listProvider="LOOKUP_TYPE:YES_NO" visible="false" showAsBoolean="true" positiveBooleanValue="Y" value="N"/>

    <Flexfield applicationId="800" descriptiveFlexfieldName="Person Developer DF"/>
    <Flexfield applicationId="800" descriptiveFlexfieldName="Contact Relship Developer DF"/>
    <Flexfield applicationId="800" descriptiveFlexfieldName="PER_CONTACTS"/>  
    <Flexfield applicationId="800" descriptiveFlexfieldName="PER_PEOPLE"/> 
    
    <Poplist id="SEX" label="{message.XXAS_EMP_GENDER}" enabled="true" required="false" listProvider="LOOKUP_TYPE:SEX" visible="false"/>
    <TextInput id="NATIONAL_IDENTIFIER" label="{message.XXAS_EMP_NATIONAL_IDENTIFIER}" enabled="true" required="false" visible="false"/>
    <Poplist id="MARITAL_STATUS" label="{message.XXAS_EMP_MARITIAL_STATUS}" enabled="true" required="false" listProvider="LOOKUP_TYPE:MAR_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="USES_TOBACCO_FLAG" label="{message.XXAS_EMP_TOBACCO_USE}" enabled="true" required="false" listProvider="LOOKUP_TYPE:TOBACCO_USER" visible="false"/>
    <Poplist id="START_LIFE_REASON_ID" label="{message.XXAS_EMP_START_RR}" enabled="true" required="false" listProvider="VALUE_SET_NAME:Applaud PI Start Relationship Reason" visible="false"/>
    <Date id="DATE_OF_BIRTH" label="{message.XXAS_EMP_DOB}" enabled="true" required="false" visible="false"/>
    <Date id="DPDNT_ADOPTION_DATE" label="{message.XXAS_EMP_ADOPTATION_DATE}" enabled="true" required="false" visible="false"/>
    <Date id="DATE_OF_DEATH" label="{message.XXAS_EMP_DEATH_DATE}" enabled="true" required="false" visible="false"/>
    <Poplist id="STUDENT_STATUS" label="{message.XXAS_EMP_STUDENT_STATUS}" enabled="true" required="false" listProvider="LOOKUP_TYPE:STUDENT_STATUS" 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="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"/>
    
    <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_PK3_VALUE" categoryCode="MISC" visible="false"/>    
  </EditFields>

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