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

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/paymentmethods.xml',
'<View title="Payment methods" defaultFormHandler="xxas_payment_methods_pkg">

  <CreateFields>
      <Hidden id="PERSONAL_PAYMENT_METHOD_ID"/>
      <Poplist id="ORG_PAYMENT_METHOD_ID" label="{message.XXAS_EMP_PM_PAY_TYPE}" enabled="true" required="true" refreshOnChange="true" listProvider="VALUE_SET_NAME:Applaud Payment Method Types"/>
      <TextInput id="PRIORITY" label="{message.XXAS_EMP_PM_PTY}" enabled="true" required="false" refreshOnChange="true"/>
      <Flexfield applicationId ="801" flexCode="BANK" flexStructureCode="${param.pFlexStructureCode}" />
      <Poplist id="AMOUNT_TYPE" label="{message.XXAS_EMP_PM_AMT_TYPE}" enabled="true" required="true" refreshOnChange="true" listProvider="VALUE_SET_NAME:Applaud Payment Amount Types"/>
      <Number id="AMOUNT"   label="{message.XXAS_EMP_PM_AMT}" enabled="true" required="false"/>
      <Number id="PERCENTAGE" label="{message.XXAS_EMP_PM_PCT}" enabled="true" required="false"/>
      <Flexfield applicationId ="801" descriptiveFlexfieldName="PAY_PERSONAL_PAYMENT_METHODS"/>
      <Flexfield applicationId ="801" descriptiveFlexfieldName="Personal PayMeth Developer DF"/>
      <Attachment id="ATTACHMENTS" label="{message.XXAS_RB_EMP_ATTACHMENTS}" enabled="true" required="false" entityName="PAY_PERSONAL_PAYMENT_METHODS_F" pk1Field="INSTANCE_PK1_VALUE" categoryCode="MISC"/>
  </CreateFields>

  <EditFields>
      <Hidden id="PERSONAL_PAYMENT_METHOD_ID"/>
      <Poplist id="ORG_PAYMENT_METHOD_ID" label="{message.XXAS_EMP_PM_PAY_TYPE}" enabled="false" visible="false" required="false" refreshOnChange="true" listProvider="VALUE_SET_NAME:Applaud Payment Method Types"/>	
      <TextInput id="PRIORITY" label="{message.XXAS_EMP_PM_PTY}" enabled="true" required="false" refreshOnChange="true"/>
      <Flexfield applicationId ="801" flexCode="BANK" flexStructureCode="${param.pFlexStructureCode}" />
      <Poplist id="AMOUNT_TYPE" label="{message.XXAS_EMP_PM_AMT_TYPE}" enabled="true" required="true" refreshOnChange="true" listProvider="VALUE_SET_NAME:Applaud Payment Amount Types"/>
      <Number id="AMOUNT"   label="{message.XXAS_EMP_PM_AMT}" enabled="true" required="false"/>
      <Number id="PERCENTAGE" label="{message.XXAS_EMP_PM_PCT}" enabled="true" required="false"/>
      <Flexfield applicationId ="801" descriptiveFlexfieldName="PAY_PERSONAL_PAYMENT_METHODS"/>
      <Flexfield applicationId ="801" descriptiveFlexfieldName="Personal PayMeth Developer DF"/>
      <Attachment id="ATTACHMENTS" label="{message.XXAS_RB_EMP_ATTACHMENTS}" enabled="true" required="false" entityName="PAY_PERSONAL_PAYMENT_METHODS_F" pk1Field="INSTANCE_PK1_VALUE" categoryCode="MISC"/>
  </EditFields>

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