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

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/clocked-in.xml',
'<View title="Clock out" showSubmit="true" submitLabel="{message.XXAS_RB_COM_SAVE}" defaultFormHandler="xxas_tcm_missed_punch_pkg.clocked_in_form_handler">
  <EditFields>

    <Container id="BASIC_GRP">

     <Hidden id="TIME_PROD"/>
     <Hidden id="CURRENT_STATE_CODE"/>
     <Hidden id="PERSON_ID"/>
     <Hidden id="PENDING_CLOCK_ID"/>
     <Hidden id="LOGGED_PERSON_ID"/>
     <Combolist id="EMPLOYEE" label="{message.XXAS_TCM_MIS_PUNCH_EMPLOYEE}" required="false" enabled="false" visible="false"
      listProvider="REST:missed-punch/form/employee-details?id=${field.PERSON_ID}&amp;dateStart=${field.START_DATE}" 
      hideIf="model.BASIC_GRP.PERSON_ID.value == model.BASIC_GRP.LOGGED_PERSON_ID.value" longlist="true" style="tags" multipleSelection="true"/>
     <Combolist id="ASSIGNMENT_ID" label="{message.XXAS_TCM_MIS_PUNCH_JOB}" required="false" enabled="false" visible="true"
      listProvider="REST:missed-punch/form/emp-worker-asg?q={searchText}&amp;dateStart=${field.START_DATE}&amp;personId=${field.PERSON_ID}"/>
     <Hidden id="START_DATE"/>
	 <Date id="START_DATE_TIME" label="{message.XXAS_TCM_MIS_PUNCH_START_DATE}" visible="true" enabled="false"/>
     <Combolist id="PAYMENT_TYPE_ID" label="{message.XXAS_TCM_MIS_PUNCH_PAY_TYPE}" enabled="false" required="false" visible="true"
      listProvider="REST:missed-punch/form/payment-types?q={searchText}&amp;effDate=${field.START_DATE}&amp;asgId=${field.ASSIGNMENT_ID}"/>
     <Hidden id="TIME_RANGE"/>
     <TimeRange id="TIME_RANGE" startDateVisible="false" startTimeEnabled="false" endDateVisible="false" endTimeVisible="true"/>	 

    </Container>

  </EditFields>

</View>');

xxas_forms_pkg.update_forms_resource('/public/xxas/emp/view/clocked-in.xml');

END;
/
COMMIT;
EXIT;