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

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/contactphonenumbers.xml',
'<View deleteAllowed="true" title="Contact phone numbers" defaultFormHandler="xxas_per_contact_phone_pkg.create_emp_view_row">
  <CreateFields>
    <Hidden id="TRANSACTION_ID"/>
    <Hidden id="TRANSACTION_STEP_ID"/>
    <Hidden id="TRANSACTION_TYPE"/>
    <Hidden id="PHONE_ID"/>
    <Hidden id="OBJECT_VERSION_NUMBER"/>
    <Hidden id="PERSON_ID"/>
    <Date id="DATE_FROM" label="{message.XXAS_EMP_EFFECTIVE_FROM}" enabled="true" required="true" visible="false"/>
    <Date id="DATE_TO" label="{message.XXAS_EMP_EFFECTIVE_TO}" enabled="true" required="false" visible="false"/>
    <TextInput id="PHONE_NUMBER" label="{message.XXAS_EMP_NUMBER}" enabled="true" required="true"/>
    <Poplist id="PHONE_TYPE" label="{message.XXAS_RB_NOTE_TYPE}" enabled="true" required="true" listProvider="LOOKUP_TYPE:PHONE_TYPE"/>
    <Flexfield applicationId="800" descriptiveFlexfieldName="PER_PHONES"/>
    <TextInput id="COMMENTS_TO_APPROVER" label="{message.XXAS_RB_TCM_APPR_CMNTS}" enabled="true" required="false" visible="false"/>
    <Attachment id="ATTACHMENTS" label="{message.XXAS_RB_EMP_ATTACHMENTS}" enabled="true" required="false" entityName="PQH_SS_ATTACHMENT" pk1Field="INSTANCE_PK2_VALUE" categoryCode="MISC" visible="false"/>
  </CreateFields>
</View>' ); 
xxas_forms_pkg.update_forms_resource('/public/xxas/emp/view/contactphonenumbers.xml');
END;
/
COMMIT;
EXIT;
