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

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/leaveofabsence.xml',
'<View title="Leave of absence" defaultFormHandler="xxas_absence_management_pkg">
  <CreateFields>
    <Combolist id="OVERRIDE_ASSIGNMENT_ID" label="{message.XXAS_EMP_ABS_OR_ASG_ID}" required="false" visible="false" enabled="true" longlist="false"
     listProvider="VALUE_SET_NAME:Applaud Employee Worker Assignments"/>
    <Poplist id="LEAVE_STATUS" label="{message.XXAS_EMP_ABS_STATUS}" visible="false" refreshOnChange="true" enabled="true" required="false" listProvider="VALUE_SET_NAME:Applaud Absence Statuses"/>
    <Poplist id="ABSENCE_TYPE_ID" label="{message.XXAS_EMP_ABS_TYPE}" enabled="true" required="true" refreshOnChange="true" listProvider="VALUE_SET_NAME:Applaud Absence Types"/>
    <Poplist id="ABS_ATTENDANCE_REASON_ID" label="{message.XXAS_EMP_REASON}" enabled="true" required="false" visible="false"/>
    <Date id="DATE_NOTIFICATION" label="{message.XXAS_EMP_NOTIFIED}" enabled="true" required="false" visible="false"/>
    <Date id="DATE_PROJECTED_START" label="{message.XXAS_EMP_START_DATE_PROJ}" enabled="true" visible="false" required="false"/>
    <Time id="TIME_PROJECTED_START" label="{message.XXAS_EMP_START_TIME_PROJ}" enabled="true" visible="false" required="false"/>
    <Date id="DATE_PROJECTED_END" label="{message.XXAS_EMP_END_DATE_PROJ}" enabled="true" visible="false" required="false"/>
    <Time id="TIME_PROJECTED_END" label="{message.XXAS_EMP_END_TIME_PROJ}" enabled="true" visible="false" required="false"/>
    <Date id="DATE_START" label="{message.XXAS_EMP_START_DATE}" enabled="true" required="true"/>
    <Time id="TIME_START" label="{message.XXAS_EMP_START_TIME}" enabled="true" required="false"/>
    <Date id="DATE_END" label="{message.XXAS_EMP_END_DATE}" enabled="true" required="false"/>
    <Time id="TIME_END" label="{message.XXAS_EMP_END_TIME}" enabled="true" required="false"/>
    <Number id="ABSENCE_DAYS" label="{message.XXAS_EMP_DURATION_D}" enabled="true" required="false"/>
    <Number id="ABSENCE_HOURS" label="{message.XXAS_EMP_DURATION_H}" enabled="true" required="false"/>
    <Combolist id="REPLACEMENT_PERSON_ID" label="{message.XXAS_REPLACED_BY}" visible="true" enabled="true" required="false" longlist="true" listProvider="VALUE_SET_NAME:Applaud Per People List"/>
    <Flexfield applicationId="800" descriptiveFlexfieldName="PER_ABSENCE_ATTENDANCES" descriptiveFlexContextCode="${param.pInformationType}"/>
    <Flexfield applicationId="800" descriptiveFlexfieldName="PER_ABS_DEVELOPER_DF" descriptiveFlexContextCode="${param.pDeveloperContextCode}"/>
    <TextInput id="COMMENTS_TO_APPROVER" label="{message.XXAS_RB_TCM_APPR_CMNTS}" enabled="true" required="false" visible="true"/>
    <Attachment id="ATTACHMENTS" label="{message.XXAS_RB_EMP_ATTACHMENTS}" enabled="true" required="false" entityName="PQH_SS_ATTACHMENT" pk1Field="INSTANCE_PK2_VALUE" categoryCode="MISC"/>
  </CreateFields>
  <EditFields>
    <Hidden id="ABSENCE_ATTENDANCE_ID" />
    <Poplist id="LEAVE_STATUS" label="{message.XXAS_EMP_ABS_STATUS}" visible="false" refreshOnChange="true" enabled="true" required="false" listProvider="VALUE_SET_NAME:Applaud Absence Statuses"/>
    <Poplist id="ABSENCE_TYPE_ID" label="{message.XXAS_EMP_ABS_TYPE}" enabled="false" required="true" refreshOnChange="true" listProvider="VALUE_SET_NAME:Applaud Absence Types"/>
    <Poplist id="ABS_ATTENDANCE_REASON_ID" label="{message.XXAS_EMP_REASON}" enabled="true" required="false" visible="false"/>
    <Date id="DATE_NOTIFICATION" label="{message.XXAS_EMP_NOTIFIED}" enabled="true" required="false" visible="false"/>
    <Date id="DATE_PROJECTED_START" label="{message.XXAS_EMP_START_DATE_PROJ}" enabled="true" visible="false" required="false"/>
    <Time id="TIME_PROJECTED_START" label="{message.XXAS_EMP_START_TIME_PROJ}" enabled="true" visible="false" required="false"/>
    <Date id="DATE_PROJECTED_END" label="{message.XXAS_EMP_END_DATE_PROJ}" enabled="true" visible="false" required="false"/>
    <Time id="TIME_PROJECTED_END" label="{message.XXAS_EMP_END_TIME_PROJ}" enabled="true" visible="false" required="false"/>
    <Date id="DATE_START" label="{message.XXAS_EMP_START_DATE}" enabled="true" required="true"/>
    <Time id="TIME_START" label="{message.XXAS_EMP_START_TIME}" enabled="true" required="false"/>
    <Date id="DATE_END" label="{message.XXAS_EMP_END_DATE}" enabled="true" required="false"/>
    <Time id="TIME_END" label="{message.XXAS_EMP_END_TIME}" enabled="true" required="false"/>
    <Number id="ABSENCE_DAYS" label="{message.XXAS_EMP_DURATION_D}" enabled="true" required="false"/>
    <Number id="ABSENCE_HOURS" label="{message.XXAS_EMP_DURATION_H}" enabled="true" required="false"/>
    <Combolist id="REPLACEMENT_PERSON_ID" label="{message.XXAS_REPLACED_BY}" visible="true" enabled="true" required="false" longlist="true" listProvider="VALUE_SET_NAME:Applaud Per People List"/>
    <Flexfield applicationId="800" descriptiveFlexfieldName="PER_ABSENCE_ATTENDANCES" descriptiveFlexContextCode="${param.pInformationType}"/>
    <Flexfield applicationId="800" descriptiveFlexfieldName="PER_ABS_DEVELOPER_DF" descriptiveFlexContextCode="${param.pDeveloperContextCode}"/>
    <TextInput id="COMMENTS_TO_APPROVER" label="{message.XXAS_RB_TCM_APPR_CMNTS}" enabled="true" required="false" visible="true"/>
    <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/leaveofabsence.xml');
END;
/
COMMIT;
EXIT;