/* $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/changepay.xml');

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/changepay.xml',
'<View title="Change pay" showSubmit="true" submitLabel="{message.XXAS_RB_COM_SAVE}" defaultFormHandler="xxas_change_pay_pkg.save_form">
  <EditFields>

      <Hidden id="PERSON_ID"/>
      <Hidden id="ASSIGNMENT_ID"/>
      <Hidden id="GRADE_ID"/>
      <Hidden id="PAY_PROPOSAL_ID"/>
      <Hidden id="PAY_TRANSACTION_ID"/>
      <Hidden id="TRANSACTION_ID"/>
      <Hidden id="TRANSACTION_STEP_ID"/>
      <Hidden id="TRANSACTION_STATUS"/>
      <Hidden id="PAY_ANNUALIZATION_FACTOR"/>
      <Hidden id="INPUT_CURRENCY_CODE"/>
      <Hidden id="CHANGE_DATE"/>
      <Hidden id="LAST_ANNUAL_SAL"/>
      <Hidden id="ANNUALIZED_SALARY"/>
      <ListItem id="APPROVERS" style="row" listFunction="xxas_selfservice_workflow_pkg.get_workflow_details2" visible="false"/>
      
      <Poplist id="CHG_COMP" label="Change by Components" listProvider="LOOKUP_TYPE:YES_NO" enabled="true" value="N" style="radio"/>
      
      <Container id="CHANGE_SALARY" label="{message.XXAS_CHNG_PAY_CHG_SAL}" visible="true" enabled="true">
        <TextInput id="PROPOSED_SALARY_N" label="{message.XXAS_CHNG_PAY_CHG_SAL}" enabled="false" required="false" visible="true"/>
        <Poplist id="PAY_BASIS_ID" label="{message.XXAS_CHNG_PAY_SAL_BASIS}" enabled="true" visible="true" listProvider="REST:changepay/salarybasis?personId=${field.PERSON_ID}"/>
        <Poplist id="PROPOSAL_REASON" label="{message.XXAS_CHNG_PAY_CHG_REASON}" enabled="true" required="false" visible="true" listProvider="LOOKUP_TYPE:PROPOSAL_REASON"/>
        <Date id="EFFECTIVE_FROM" label="{message.XXAS_CHNG_PAY_EFF_DATE}" enabled="true" visible="true" required="true"/>
        <Poplist id="PAY_INCREASE_BY" label="{message.XXAS_CHNG_PAY_CHG_BY}" required="true" visible="true" listProvider="LOOKUP_TYPE:XXAS_PAY_INCREASE_BY" refreshOnChange="true"  hideIf="model.CHG_COMP.value.id == &apos;Y&apos;"/>
        <Number id="CHANGE_PERCENT" label="{message.XXAS_CHNG_PAY_NEW_PERCENT}" enabled="true" required="false" visible="false" refreshOnChange="true"/>
        <Number id="T_CHANGE_PERCENT" label="{message.XXAS_CHNG_PAY_NEW_PERCENT}" enabled="true" required="false" visible="false" refreshOnChange="true"/>
        <Number id="CHANGE_AMOUNT" label="{message.XXAS_CHNG_PAY_NEW_AMOUNT}" enabled="true" required="false" visible="false" refreshOnChange="true"/>
        <Number id="T_CHANGE_AMOUNT" label="{message.XXAS_CHNG_PAY_NEW_AMOUNT}" enabled="true" required="false" visible="false" refreshOnChange="true"/>
        <Number id="CHANGE_EQUIVALENT" label="{message.XXAS_CHNG_PAY_NEW_ANNUAL_EQ}" enabled="false" required="false" visible="false" refreshOnChange="true"/>
        <Number id="T_CHANGE_EQUIVALENT" label="{message.XXAS_CHNG_PAY_NEW_ANNUAL_EQ}" enabled="false" required="false" visible="false" refreshOnChange="true"/>
        <Number id="CHANGE_ANNUAL_FTE" label="{message.XXAS_CHNG_PAY_NEW_ANNUAL_FTE}" enabled="false" required="false" visible="false" refreshOnChange="true"/>
        <Number id="T_CHANGE_ANNUAL_FTE" label="{message.XXAS_CHNG_PAY_NEW_ANNUAL_FTE}" enabled="false" required="false" visible="false" refreshOnChange="true"/>
        <Number id="T_N_INCREASE_AMOUNT" label="{message.XXAS_CHNG_PAY_NEW_INC_AMOUNT}" enabled="true" required="false" visible="false" refreshOnChange="true"/>
        <Number id="N_INCREASE_AMOUNT" label="{message.XXAS_CHNG_PAY_NEW_INC_AMOUNT}" enabled="true" required="false" visible="false" refreshOnChange="true"/>
        <Number id="N_COMPARATIO" label="{message.XXAS_CHNG_PAY_NEW_COMPARATIO}" enabled="true" required="false" visible="false" refreshOnChange="true"/>
        <Number id="T_COMPARATIO" label="{message.XXAS_CHNG_PAY_NEW_COMPARATIO}" enabled="true" required="false" visible="false" refreshOnChange="true"/>
        <Number id="N_PERCENTILE" label="{message.XXAS_CHNG_PAY_NEW_PERCENTILE}" enabled="true" required="false" visible="false" refreshOnChange="true"/>
        <Number id="T_PERCENTILE" label="{message.XXAS_CHNG_PAY_NEW_PERCENTILE}" enabled="true" required="false" visible="false" refreshOnChange="true"/>
        <TextInput id="N_QUINTILE" label="{message.XXAS_CHNG_PAY_NEW_QUINTILE}" enabled="true" required="false" visible="false" refreshOnChange="true"/>
        <TextInput id="N_QUARTILE" label="{message.XXAS_CHNG_PAY_NEW_QUARTILE}" enabled="true" required="false" visible="false" refreshOnChange="true"/>
      </Container>
        

    <Container id="CHG_SAL_COMP" label="{message.XXAS_CHNG_PAY_SAL_COMPONENTS}" visible="true" enabled="true"  hideIf="model.CHG_COMP.value.id == &apos;N&apos;">
      <MultiRow id="SALARY_COMPONENTS" deleteAllowed="true" createAllowed="true" xdbUri="/public/xxas/emp/view/changepaycomponents.xml" formulaName="XXAS_BK_PAY_DETAILS_EDIT"/>
    </Container>    
    
    <TextInput id="COMMENTS_TO_APPROVER" label="{message.XXAS_RB_TCM_APPR_CMNTS}" enabled="true" required="false"/>

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