/* $Id$ */
/*============================================================================*
 |                 Copyright (c) 2018 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/otl-timecard-event.xml');

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/otl-timecard-event.xml',
'<View title="Log Time" showSubmit="true" submitLabel="{message.XXAS_RB_COM_SAVE}" defaultFormHandler="xxas_otl_timecard_entry_pkg.update_timecard_entry">
  <EditFields>

    <Container id="BASIC_GRP">

     <Hidden id="PERSON_ID"/>
     <Hidden id="ASSIGNMENT_ID"/>
     <Hidden id="TIMECARD_ID"/>
     <Hidden id="TIMECARD_SUMMARY_ID"/>
     <Hidden id="TIMECARD_SUMMARY_OVN"/>
     <Hidden id="TIMECARD_OVN"/>
     <Hidden id="TIMECARD_DATE_FROM"/>
     <Hidden id="SOURCE_BLOCK"/>
     <Hidden id="SAVED_SEARCH_ID"/>
     <Hidden id="CURRENT_STATE_CODE"/>
     <Hidden id="TIMECARD_SUMMARY_START_DATE"/>
     <Hidden id="TIMECARD_SUMMARY_END_DATE"/>
     <Hidden id="TIMECARD_START_DATE"/>
     <Hidden id="CALLED_VIEW"/>
     <Hidden id="DATE_START"/>
     <ListItem id="APPROVERS" style="row" listFunction="xxas_timecard_entry_pkg.get_approvers" visible="false"/>
     <Combolist id="EMPLOYEES" label="{message.XXAS_OTL_EVENT_EMPLOYEES}" emptyValue="{message.XXAS_OTL_EVENT_EMPLOYEES_SRCH}" 
      listProvider="REST:calendar-event/search/per-dr-only-and-savedsearch?q={searchText}&amp;dateStart=${fieldNR.DATE_START}&amp;savedSearchId=${fieldNR.SAVED_SEARCH_ID}"
      required="true" longlist="true" visible="true" enabled="true" multipleSelection="true" style="tags"
      triggerName="OTL_HOURSTYPE_OL_TIMECARDS" triggerMethod="POST" hideIf="!model.BASIC_GRP.CALLED_VIEW.value || model.BASIC_GRP.CALLED_VIEW.value == &apos;EMP&apos;"/>
     <Hidden id="FIELD1"/>
     <Hidden id="FIELD2"/>
     <Hidden id="FIELD3"/>
     <Hidden id="FIELD4"/>
     <Hidden id="FIELD5"/>
     <Hidden id="FIELD6"/>
     <Hidden id="FIELD7"/>
     <Hidden id="FIELD8"/>
     <Hidden id="FIELD9"/>
     <Hidden id="FIELD10"/>
     <Hidden id="FIELD11"/>
     <Hidden id="FIELD12"/>
     <Hidden id="FIELD13"/>
     <Hidden id="FIELD14"/>
     <Hidden id="FIELD15"/>
     <Hidden id="FIELD16"/>
     <Hidden id="FIELD17"/>
     <Hidden id="FIELD18"/>
     <Hidden id="FIELD19"/>
     <Hidden id="FIELD20"/>
    </Container>

    <Container id="ADDL_INFO_GRP" label="{message.XXAS_OTL_EVENT_ADD_DETAILS}">
      <TextArea id="COMMENTS_TO_APPROVER" label="{message.XXAS_OTL_APPR_CMNTS}" enabled="true" required="false" 
       visible="true" maxChars="2000"/>
      <MultiRow id="ATTACHMENTS" createAllowed="true" createLabel="{message.XXAS_OTL_EVENT_ADD_ATTACH}" xdbUri="/public/xxas/emp/view/attach.xml"/>
    </Container>

    <Container id="OVERLAP_ENTRIES" label="{message.XXAS_OTL_EVENT_OL_ENTRIES}">
     <ListItem id="OL_ENTRIES_LI" label="{message.XXAS_OTL_EVENT_OL_ENTRIES}" visible="true"
      listFunction="xxas_otl_timecard_entry_pkg.ol_timecard_entries"/>
    </Container>

  </EditFields>

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