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

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/cico.xml',
'<View title="Log Time" showSubmit="false" defaultFormHandler="xxas_cico_entry_pkg.dynamic_cico_form" clientAutosave="false">
  <EditFields>

     <Hidden id="HIDE_FORGOT_LINK"/>
     <Hidden id="PERSON_ID"/>     
     <Combolist id="JOB_ID" label="{message.XXAS_TCM_EVENT_JOB}" required="true" 
      listProvider="REST:calendar-event/search/emp-worker-asgs?q={searchText}&amp;dateStart=-1&amp;personId=-1" triggerName="CICO_JOB_PAYMENT" triggerMethod="POST"/>
     <Combolist id="PAYMENT_TYPE_ID" label="{message.XXAS_TCM_EVENT_PAYMENT_TYPE}" longlist="false" required="true"/> 
     
     <Hidden id="FIELD1"/>
     <Hidden id="FIELD2"/>
     <Hidden id="FIELD3"/>
     <Hidden id="FIELD4"/>
     <Hidden id="FIELD5"/>

     <Item id="LOC_TIMER" style="row" itemFunction="xxas_cico_entry_pkg.get_timer_xml"/>

  </EditFields>

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