/* $Id: xxas_tcm_missed_punch_xml_upd.sql 5405 2018-04-11 11:15:35Z rsadhananthan $ */
/*============================================================================*
 |                 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/missed-punch.xml');

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/missed-punch.xml',
'<View title="Missed punch" showSubmit="true" submitLabel="{message.XXAS_RB_COM_SAVE}" defaultFormHandler="xxas_tcm_missed_punch_pkg.update_punch_details">
  <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"/>
     <Hidden id="CURRENT_APPROVER_ROLE"/>
     <ListItem id="APPROVERS" style="row" listFunction="xxas_tcm_missed_punch_pkg.get_approvers" visible="false"/>
     <Combolist id="EMPLOYEE" label="{message.XXAS_TCM_MIS_PUNCH_EMPLOYEE}" required="false" enabled="false" visible="true"
      listProvider="REST:missed-punch/form/employee-details?q={searchText}&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"/>
     <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"/>
     <Poplist id="REASON_FOR_MISS" label="{message.XXAS_TCM_MIS_PUNCH_REASON_FOR}" listProvider="LOOKUP_TYPE:XXAS_TCM_MISSED_CLOCK_REASONS" enabled="true"
      required="true" visible="true"/>

     <TextArea id="OTHER_MORE_DETAIL" label="{message.XXAS_TCM_MIS_PUNCH_OTHER_DET}" enabled="true" required="true" visible="true" 
      maxChars="4000" hideIf="!model.BASIC_GRP.REASON_FOR_MISS.value || model.BASIC_GRP.REASON_FOR_MISS.value.id != &apos;OTHER&apos;"/>

    </Container>

  </EditFields>

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