src-db/database/model/triggers/AD_SYSTEM_INFO_TRG2.xml
changeset 1984 6072e1cf1838
child 2067 c73cf7263093
equal deleted inserted replaced
1983:2c72549c241b 1984:6072e1cf1838
       
     1 <?xml version="1.0"?>
       
     2   <database name="TRIGGER AD_SYSTEM_INFO_TRG2">
       
     3     <trigger name="AD_SYSTEM_INFO_TRG2" table="AD_SYSTEM_INFO" fires="after" insert="false" update="true" delete="false" foreach="row">
       
     4       <body><![CDATA[
       
     5 
       
     6 /*************************************************************************
       
     7 * The contents of this file are subject to the Openbravo  Public  License
       
     8 * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
       
     9 * Version 1.1  with a permitted attribution clause; you may not  use this
       
    10 * file except in compliance with the License. You  may  obtain  a copy of
       
    11 * the License at http://www.openbravo.com/legal/license.html
       
    12 * Software distributed under the License  is  distributed  on  an "AS IS"
       
    13 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
       
    14 * License for the specific  language  governing  rights  and  limitations
       
    15 * under the License.
       
    16 * The Original Code is Openbravo ERP.
       
    17 * The Initial Developer of the Original Code is Openbravo SL
       
    18 * All portions are Copyright (C) 2001-2008 Openbravo SL
       
    19 * All Rights Reserved.
       
    20 * Contributor(s):  ______________________________________.
       
    21 ************************************************************************/
       
    22 
       
    23 exist NUMBER := 0;
       
    24 indTempName NVARCHAR2(50) := 'System Customization';
       
    25 indTempPackage NVARCHAR2(50) := 'mySystem.CustomizationTemplate';
       
    26 
       
    27 BEGIN
       
    28   If :old.customization_Allowed='N' and :new.customization_Allowed='Y' then
       
    29   
       
    30     select count(*) into exist
       
    31     from AD_MODULE
       
    32     where TYPE = 'T'
       
    33     and ISINDEVELOPMENT = 'Y';
       
    34     
       
    35     if (exist > 0) then
       
    36       RAISE_APPLICATION_ERROR(-20631,'There is already an active Industry Template.');
       
    37     else
       
    38       Insert into AD_MODULE (
       
    39         AD_MODULE_ID,AD_CLIENT_ID,AD_ORG_ID,ISACTIVE,CREATED,CREATEDBY,UPDATED,UPDATEDBY,
       
    40         NAME,VERSION,DESCRIPTION,
       
    41         HELP,
       
    42         URL,TYPE,LICENSE,
       
    43         ISINDEVELOPMENT,ISDEFAULT,SEQNO,JAVAPACKAGE,
       
    44         LICENSETYPE,AUTHOR,STATUS,UPDATE_AVAILABLE,ISTRANSLATIONREQUIRED,AD_LANGUAGE,HASCHARTOFACCOUNTS,
       
    45         ISTRANSLATIONMODULE,HASREFERENCEDATA,ISREGISTERED,UPDATEINFO,UPDATE_VER_ID) 
       
    46       values (
       
    47         get_uuid(),'0','0','Y',now(),'0',now(),'0',
       
    48         to_char(indTempName),'1.0.0', to_char(indTempName) || ' is an autogenerated industry template to store all the customizations made to module core.',
       
    49         to_char(indTempName) || ' is an autogenerated industry template to store all the customizations made to module core. Only one industry template can be active at the same time.',
       
    50         null,'T','The Openbravo Public License Version 1.1 ("OBPL") consists of the Mozilla Public License Version 1.1, modified to be specific to Openbravo, with the Additional Terms in Exhibit B. The original Mozilla Public License 1.1 can be found at: http://www.mozilla.org/MPL/MPL-1.1.html',
       
    51         'Y','N',null,to_char(indTempPackage),
       
    52         'OtherOS',null,null,null,'Y','en_US','N',
       
    53         'N','N',null,null,null);
       
    54     end if;
       
    55   end if;
       
    56   
       
    57   If (:old.customization_Allowed='Y' and :new.customization_Allowed='N') then
       
    58     delete from AD_MODULE
       
    59     where name = indTempName;
       
    60   end if;
       
    61 
       
    62 END AD_SYSTEM_INFO_TRG2
       
    63 ]]></body>
       
    64     </trigger>
       
    65   </database>