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

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/qualifications.xml',
'<View title="Qualifications" defaultFormHandler="xxas_qualifications_pkg">

  <CreateFields>
    <Hidden id="MODE"/>
    <Combolist id="QUALIFICATION_TYPE_ID" label="{message.XXAS_RB_NOTE_TYPE}" enabled="true" required="true" listProvider="VALUE_SET_NAME:Applaud Qualification Types"/>
    <TextInput id="TITLE" label="{message.XXAS_RB_EMP_EXP_JT}" enabled="true" required="false"/>
    <Date id="START_DATE" label="{message.XXAS_EMP_STUDY_START_DATE}" enabled="true" required="false"/>
    <Date id="END_DATE" label="{message.XXAS_EMP_ACTUAL_CDATE}" enabled="true" required="false"/>
    <Poplist id="STATUS_CODE" label="{message.XXAS_RB_TCM_STATUS}" enabled="true" listProvider="LOOKUP_TYPE:PER_SUBJECT_STATUSES"/>
    <TextInput id="GRADE_ATTAINED" label="{message.XXAS_EMP_GRADE}" enabled="true" required="false"/>
    
    <Flexfield applicationId="800" descriptiveFlexfieldName="Qualification Developer DF"/>
    <Flexfield applicationId="800" descriptiveFlexfieldName="PER_QUALIFICATIONS" columnNamePrefix="QUA_"/>

   
    <Combolist id="ESTABLISHMENT" label="{message.XXAS_EMP_SCHOOL}" enabled="true" required="true" listProvider="REST:Establish-search/Establish?q={searchText}" allowNewValues="true" longlist = "true"/>
   
    <Date id="ATTENDED_START_DATE" label="{message.XXAS_EMP_ATTENDANCE_SD}" enabled="true" required="false"/>
    <Date id="ATTENDED_END_DATE" label="{message.XXAS_EMP_ATTENDANCE_ED}" enabled="true" required="false"/>
    <Poplist id="FULL_TIME_FLAG" label="{message.XXAS_EMP_FULL_TIME}" enabled="true" listProvider="LOOKUP_TYPE:YES_NO" showAsBoolean="true" positiveBooleanValue="Y" value="N"/>

    <Flexfield applicationId="800" descriptiveFlexfieldName="PER_ESTABLISHMENT_ATTENDANCES" columnNamePrefix="PEA_"/>
    
    <TextInput id="AWARDING_BODY" label="{message.XXAS_EMP_AW_BODY}" enabled="true" required="false"/>
    <Date id="AWARDED_DATE" label="{message.XXAS_EMP_AWARD_ON}" enabled="true" required="false"/>
    <TextInput id="GROUP_RANKING" label="{message.XXAS_EMP_GROUP_RANKING}" enabled="true" required="false"/>

    <TextInput id="LICENSE_NUMBER" label="{message.XXAS_EMP_LICENCE_NUMBER}" enabled="true" required="false"/>
    <Date id="EXPIRY_DATE" label="{message.XXAS_EMP_EXPIRY_DATE}" enabled="true" required="false"/>
    <TextInput id="LICENSE_RESTRICTIONS" label="{message.XXAS_EMP_LICENCE_RESTRICTION}" enabled="true" required="false"/>
    
    <Poplist id="TUITION_METHOD" label="{message.XXAS_EMP_TUTION_METHOD}" enabled="true" listProvider="LOOKUP_TYPE:PER_TUITION_METHODS"/>
    <Number id="FEE" label="{message.XXAS_EMP_FEE}" enabled="true" required="false"/>
    <Combolist id="FEE_CURRENCY_CODE" label="{message.XXAS_EMP_FEE_CURRENCY}" enabled="true" listProvider="VALUE_SET_NAME:Applaud Currencies"/>
    <TextInput id="REIMBURSEMENT_ARRANGEMENTS" label="{message.XXAS_EMP_RC}" enabled="true" required="false"/>

    <Number id="TRAINING_COMPLETED_AMOUNT" label="{message.XXAS_EMP_TCA}" enabled="true" required="false"/>
    <TextInput id="TRAINING_COMPLETED_UNITS" label="{message.XXAS_EMP_TCU}" enabled="true" required="false"/>
    <Number id="TOTAL_TRAINING_AMOUNT" label="{message.XXAS_EMP_TTA}" enabled="true" required="false"/>
    
    <TextInput id="COMMENTS_TO_APPROVER" label="{message.XXAS_RB_TCM_APPR_CMNTS}" enabled="true" required="false"/>
    
    <Attachment id="ATTACHMENTS" label="{message.XXAS_RB_EMP_ATTACHMENTS}" enabled="true" required="false" entityName="PQH_SS_ATTACHMENT"
                pk1Field="INSTANCE_PK2_VALUE" categoryCode="MISC" visible="false"/> 
                
  </CreateFields>
  
  <EditFields>
    <Hidden id="MODE"/>
    <Hidden id="ATTENDANCE_ID"/>
    <Hidden id="PEA_OBJECT_VERSION_NUMBER"/>
    <Combolist id="QUALIFICATION_TYPE_ID" label="{message.XXAS_RB_NOTE_TYPE}" enabled="false" required="true" listProvider="VALUE_SET_NAME:Applaud Qualification Types"/>
    <TextInput id="TITLE" label="{message.XXAS_RB_EMP_EXP_JT}" enabled="true" required="false"/>
    <Date id="START_DATE" label="{message.XXAS_EMP_STUDY_START_DATE}" enabled="true" required="false"/>
    <Date id="END_DATE" label="{message.XXAS_EMP_ACTUAL_CDATE}" enabled="true" required="false"/>
    <Poplist id="STATUS_CODE" label="{message.XXAS_RB_TCM_STATUS}" enabled="true" listProvider="LOOKUP_TYPE:PER_SUBJECT_STATUSES"/>
    <TextInput id="GRADE_ATTAINED" label="{message.XXAS_EMP_GRADE}" enabled="true" required="false"/>
    
    <Flexfield applicationId="800" descriptiveFlexfieldName="Qualification Developer DF"/>
    <Flexfield applicationId="800" descriptiveFlexfieldName="PER_QUALIFICATIONS" columnNamePrefix="QUA_"/>

    <Combolist id="ESTABLISHMENT" label="{message.XXAS_EMP_SCHOOL}" enabled="true" required="true" listProvider="REST:Establish-search/Establish?q={searchText}" allowNewValues="true" longlist = "true"/>
    <Date id="ATTENDED_START_DATE" label="{message.XXAS_EMP_ATTENDANCE_SD}" enabled="true" required="false"/>
    <Date id="ATTENDED_END_DATE" label="{message.XXAS_EMP_ATTENDANCE_ED}" enabled="true" required="false"/>
    <Poplist id="FULL_TIME_FLAG" label="{message.XXAS_EMP_FULL_TIME}" enabled="true" listProvider="LOOKUP_TYPE:YES_NO" showAsBoolean="true" positiveBooleanValue="Y" value="N"/>

    <Flexfield applicationId="800" descriptiveFlexfieldName="PER_ESTABLISHMENT_ATTENDANCES" columnNamePrefix="PEA_"/>
    
    <TextInput id="AWARDING_BODY" label="{message.XXAS_EMP_AW_BODY}" enabled="true" required="false"/>
    <Date id="AWARDED_DATE" label="{message.XXAS_EMP_AWARD_ON}" enabled="true" required="false"/>
    <TextInput id="GROUP_RANKING" label="{message.XXAS_EMP_GROUP_RANKING}" enabled="true" required="false"/>

    <TextInput id="LICENSE_NUMBER" label="{message.XXAS_EMP_LICENCE_NUMBER}" enabled="true" required="false"/>
    <Date id="EXPIRY_DATE" label="{message.XXAS_EMP_EXPIRY_DATE}" enabled="true" required="false"/>
    <TextInput id="LICENSE_RESTRICTIONS" label="{message.XXAS_EMP_LICENCE_RESTRICTION}" enabled="true" required="false"/>
    
    <Poplist id="TUITION_METHOD" label="{message.XXAS_EMP_TUTION_METHOD}" enabled="true" listProvider="LOOKUP_TYPE:PER_TUITION_METHODS"/>
    <Number id="FEE" label="{message.XXAS_EMP_FEE}" enabled="true" required="false"/>
    <Combolist id="FEE_CURRENCY_CODE" label="{message.XXAS_EMP_FEE_CURRENCY}" enabled="true" listProvider="VALUE_SET_NAME:Applaud Currencies"/>
    <TextInput id="REIMBURSEMENT_ARRANGEMENTS" label="{message.XXAS_EMP_RC}" enabled="true" required="false"/>

    <Number id="TRAINING_COMPLETED_AMOUNT" label="{message.XXAS_EMP_TCA}" enabled="true" required="false"/>
    <TextInput id="TRAINING_COMPLETED_UNITS" label="{message.XXAS_EMP_TCU}" enabled="true" required="false"/>
    <Number id="TOTAL_TRAINING_AMOUNT" label="{message.XXAS_EMP_TTA}" enabled="true" required="false"/>
    
    <TextInput id="COMMENTS_TO_APPROVER" label="{message.XXAS_RB_TCM_APPR_CMNTS}" enabled="true" required="false"/>
    
    <Attachment id="ATTACHMENTS" label="{message.XXAS_RB_EMP_ATTACHMENTS}" enabled="true" required="false" entityName="PQH_SS_ATTACHMENT"
                pk1Field="INSTANCE_PK2_VALUE" categoryCode="MISC" visible="false"/> 
                
  </EditFields>

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