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

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/changeasg.xml',
'<View showSubmit="true" submitLabel="{message.XXAS_RB_COM_SAVE}" title="Change assignment" defaultFormHandler="xxas_change_assignment_pkg.submit_change_asg_request">

  <EditFields>
    <Container id="BASIC_GRP">
      <Hidden id="CONTINGENT_WORKER"/>
      <Hidden id="PERSON_ID"/>
      <Hidden id="OBJECT_VERSION_NUMBER"/>
      <Hidden id="ASSIGNMENT_ID"/>
      <Hidden id="TRANSACTION_ID"/>
      <Hidden id="TRANSACTION_STEP_ID"/>
      <Hidden id="BUSINESS_GROUP_ID"/>
      <Hidden id="SUPERVISOR_ID"/>
      <Hidden id="VACANCY_ID"/>
      <Hidden id="ASSIGNMENT_TYPE"/>
      <Hidden id="SOURCE_TYPE"/>
      <Hidden id="ESTABLISHMENT_ID"/>
      <Hidden id="JOB_POST_SOURCE_NAME"/>
      <Hidden id="ASSIGNMENT_CATEGORY"/>
      <Hidden id="SUPERVISOR_ASSIGNMENT_ID"/>
      <Hidden id="HAS_FUTURE_DATED_RECORDS"/>
      <Hidden id="EFFECTIVE_START_DATE"/>
      <Hidden id="EFFECTIVE_END_DATE"/>
      <ListItem id="APPROVERS" style="row" listFunction="xxas_selfservice_workflow_pkg.get_workflow_details2" visible="false"/>
      <Poplist id="EFFECTIVE_DATE_OPTION" label="{message.XXAS_MSS_EFFECTIVE_DATE_OPTION}" visible="true" required="true" listProvider="LOOKUP_TYPE:XXAS_MSS_EFFECTIVE_DATE_OPTION" enabled="true"/>
      <Date id="EFFECTIVE_FROM_LDW" enabled="true" label="{message.XXAS_MSS_EFFECTIVE_DATE}" visible="true" required="true" hideIf="!model.BASIC_GRP.EFFECTIVE_DATE_OPTION.value || model.BASIC_GRP.EFFECTIVE_DATE_OPTION.value.id == &apos;A&apos;"/>
      <Date id="EFFECTIVE_FROM_FAD" enabled="false" label="{message.XXAS_MSS_EFFECTIVE_DATE}" visible="false" hideIf="!model.BASIC_GRP.EFFECTIVE_DATE_OPTION.value || model.BASIC_GRP.EFFECTIVE_DATE_OPTION.value.id == &apos;E&apos;"/>
      <Poplist id="CHANGE_ASG_ACTION_GP" label="{message.XXAS_MSS_CHANGE_ASG_ACTION_GP}" required="true" listProvider="LOOKUP_TYPE:XXAS_MSS_CHANGE_ASG_ACTION_GP" enabled="true" refreshOnChange="true"/>
      <Combolist id="ORGANIZATION_ID" label="{message.XXAS_MSS_ORGANIZATION_ID}" listProvider="REST:asgdef-fieldsearch/bg/organization?q={searchText}&amp;bgId=${field.BUSINESS_GROUP_ID}" 
       longlist="true" visible="false" required="true"/>
      <Combolist id="JOB_ID" label="{message.XXAS_MSS_JOB_ID}" listProvider="REST:asgdef-fieldsearch/bg/org/pos/job?q={searchText}&amp;bgId=${field.BUSINESS_GROUP_ID}&amp;orgId=${fieldNR.ORGANIZATION_ID}&amp;posId=${fieldNR.POSITION_ID}" 
       longlist="true" visible="false" refreshOnChange="true"/>
      <Combolist id="POSITION_ID" label="{message.XXAS_MSS_POSITION_ID}" listProvider="REST:asgdef-fieldsearch/bg/org/job/position?q={searchText}&amp;bgId=${field.BUSINESS_GROUP_ID}&amp;orgId=${fieldNR.ORGANIZATION_ID}&amp;jobId=${fieldNR.JOB_ID}" 
       longlist="true" visible="false" refreshOnChange="true"/>
      <Combolist id="LOCATION_ID" label="{message.XXAS_MSS_LOCATION_ID}" listProvider="REST:asgdef-fieldsearch/location?q={searchText}&amp;bgId=${field.BUSINESS_GROUP_ID}" longlist="true" visible="false"/>

      <Combolist id="GRADE_ID" label="{message.XXAS_MSS_GRADE_ID}" listProvider="REST:asgdef-fieldsearch/bg/position/job/grade?q={searchText}&amp;bgId=${field.BUSINESS_GROUP_ID}&amp;posId=${fieldNR.POSITION_ID}&amp;jobId=${fieldNR.JOB_ID}" 
       longlist="true" visible="false" refreshOnChange="true"/>

      <Poplist id="ASG_CATEGORY" label="{message.XXAS_MSS_ASG_CATEGORY}" listProvider="LOOKUP_TYPE:EMP_CAT" visible="false"/>
      <Poplist id="EMPLOYEE_CATEGORY" label="{message.XXAS_MSS_EMPLOYEE_CATEGORY}" listProvider="LOOKUP_TYPE:EMPLOYEE_CATG" visible="false"/>

      <Poplist id="CWK_ASG_CATEGORY" label="{message.XXAS_MSS_ASG_CATEGORY}" listProvider="LOOKUP_TYPE:CWK_ASG_CATEGORY" visible="false"/>

      <Number id="NORMAL_HOURS" label="{message.XXAS_MSS_NORMAL_HOURS}" visible="false"/>
      <Poplist id="FREQUENCY" label="{message.XXAS_MSS_FREQUENCY}" listProvider="LOOKUP_TYPE:FREQUENCY" visible="false" hideIf="!model.BASIC_GRP.NORMAL_HOURS.value"/>
      <TextInput id="TIME_NORMAL_START" label="{message.XXAS_MSS_TIME_NORMAL_START}" visible="false"/>
      <TextInput id="TIME_NORMAL_FINISH" label="{message.XXAS_MSS_TIME_NORMAL_FINISH}" visible="false"/>
      <Poplist id="WORK_AT_HOME" label="{message.XXAS_MSS_WORK_AT_HOME}" listProvider="LOOKUP_TYPE:YES_NO" enabled="true" value="N" showAsBoolean="true" 
       positiveBooleanValue="Y" visible="false"/>

      <TextInput id="TITLE" label="{message.XXAS_MSS_TITLE}" visible="false"/>
      <TextInput id="PROJECT_TITLE" label="{message.XXAS_MSS_PROJECT_TITLE}" visible="false"/>

      <Poplist id="CHANGE_REASON" label="{message.XXAS_MSS_CHANGE_REASON}" listProvider="LOOKUP_TYPE:EMP_ASSIGN_REASON" visible="false"/>
      <Poplist id="CWK_CHANGE_REASON" label="{message.XXAS_MSS_CHANGE_REASON}" listProvider="LOOKUP_TYPE:CWK_ASSIGN_REASON" visible="false"/>

    </Container>

    <Container id="ADDL_INFO_GRP" label="{message.XXAS_MSS_ADDL_INFO_GRP}">
      <Flexfield applicationShortCode="PER" descriptiveFlexfieldName="PER_ASSIGNMENTS"/>
      <TextInput id="COMMENTS_TO_APPROVER" label="{message.XXAS_RB_TCM_APPR_CMNTS}" enabled="true" required="false" visible="true"/>
    </Container>

    <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/changeasg.xml');
END;
/
COMMIT;
EXIT;
