src-db/database/model/triggers/AD_SYSTEM_INFO_TRG2.xml
changeset 1984 6072e1cf1838
child 2067 c73cf7263093
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-db/database/model/triggers/AD_SYSTEM_INFO_TRG2.xml	Mon Nov 17 17:19:51 2008 +0000
@@ -0,0 +1,65 @@
+<?xml version="1.0"?>
+  <database name="TRIGGER AD_SYSTEM_INFO_TRG2">
+    <trigger name="AD_SYSTEM_INFO_TRG2" table="AD_SYSTEM_INFO" fires="after" insert="false" update="true" delete="false" foreach="row">
+      <body><![CDATA[
+
+/*************************************************************************
+* The contents of this file are subject to the Openbravo  Public  License
+* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+* Version 1.1  with a permitted attribution clause; you may not  use this
+* file except in compliance with the License. You  may  obtain  a copy of
+* the License at http://www.openbravo.com/legal/license.html
+* Software distributed under the License  is  distributed  on  an "AS IS"
+* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+* License for the specific  language  governing  rights  and  limitations
+* under the License.
+* The Original Code is Openbravo ERP.
+* The Initial Developer of the Original Code is Openbravo SL
+* All portions are Copyright (C) 2001-2008 Openbravo SL
+* All Rights Reserved.
+* Contributor(s):  ______________________________________.
+************************************************************************/
+
+exist NUMBER := 0;
+indTempName NVARCHAR2(50) := 'System Customization';
+indTempPackage NVARCHAR2(50) := 'mySystem.CustomizationTemplate';
+
+BEGIN
+  If :old.customization_Allowed='N' and :new.customization_Allowed='Y' then
+  
+    select count(*) into exist
+    from AD_MODULE
+    where TYPE = 'T'
+    and ISINDEVELOPMENT = 'Y';
+    
+    if (exist > 0) then
+      RAISE_APPLICATION_ERROR(-20631,'There is already an active Industry Template.');
+    else
+      Insert into AD_MODULE (
+        AD_MODULE_ID,AD_CLIENT_ID,AD_ORG_ID,ISACTIVE,CREATED,CREATEDBY,UPDATED,UPDATEDBY,
+        NAME,VERSION,DESCRIPTION,
+        HELP,
+        URL,TYPE,LICENSE,
+        ISINDEVELOPMENT,ISDEFAULT,SEQNO,JAVAPACKAGE,
+        LICENSETYPE,AUTHOR,STATUS,UPDATE_AVAILABLE,ISTRANSLATIONREQUIRED,AD_LANGUAGE,HASCHARTOFACCOUNTS,
+        ISTRANSLATIONMODULE,HASREFERENCEDATA,ISREGISTERED,UPDATEINFO,UPDATE_VER_ID) 
+      values (
+        get_uuid(),'0','0','Y',now(),'0',now(),'0',
+        to_char(indTempName),'1.0.0', to_char(indTempName) || ' is an autogenerated industry template to store all the customizations made to module core.',
+        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.',
+        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',
+        'Y','N',null,to_char(indTempPackage),
+        'OtherOS',null,null,null,'Y','en_US','N',
+        'N','N',null,null,null);
+    end if;
+  end if;
+  
+  If (:old.customization_Allowed='Y' and :new.customization_Allowed='N') then
+    delete from AD_MODULE
+    where name = indTempName;
+  end if;
+
+END AD_SYSTEM_INFO_TRG2
+]]></body>
+    </trigger>
+  </database>