modules/org.openbravo.userinterface.selector/src-db/database/model/triggers/OBUISEL_SELECTOR_TRL_TRG.xml
changeset 9076 c4f1a5c7d7c2
child 10772 802557f42def
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.userinterface.selector/src-db/database/model/triggers/OBUISEL_SELECTOR_TRL_TRG.xml	Fri Dec 10 19:47:45 2010 +0100
@@ -0,0 +1,71 @@
+<?xml version="1.0"?>
+  <database name="TRIGGER OBUISEL_SELECTOR_TRL_TRG">
+    <trigger name="OBUISEL_SELECTOR_TRL_TRG" table="OBUISEL_SELECTOR" fires="after" insert="true" update="true" delete="false" foreach="row">
+      <body><![CDATA[
+
+/*************************************************************************
+* The contents of this file are subject to the Openbravo  Public  License
+* Version  1.1  (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 SLU
+* All portions are Copyright (C) 2010 Openbravo SLU
+* All Rights Reserved.
+* Contributor(s):  ______________________________________.
+************************************************************************/
+  devTemplate NUMBER;
+  devModule   CHAR(1);
+  currentModuleID  VARCHAR2(32);
+  vAux NUMBER;
+
+BEGIN
+    
+    IF AD_isTriggerEnabled()='N' THEN RETURN;
+    END IF;
+
+    -- Insert trl entries for module language
+    IF INSERTING THEN
+        INSERT
+            INTO OBUISEL_Selector_Trl
+            (
+            OBUISEL_Selector_Trl_ID, OBUISEL_Selector_ID, AD_Language_ID, AD_Client_ID,
+            AD_Org_ID, IsActive, Created,
+            CreatedBy, Updated, UpdatedBy,
+            Name, Description, Help,
+            IsTranslated
+            )
+        SELECT get_uuid(), :new.OBUISEL_Selector_ID,
+            AD_Language.AD_Language_ID, :new.AD_Client_ID, :new.AD_Org_ID,
+            :new.IsActive, :new.Created, :new.CreatedBy,
+            :new.Updated, :new.UpdatedBy, :new.Name,
+            :new.Description, :new.Help, 'N'
+            FROM AD_Language, AD_Module M
+            WHERE AD_Language.IsActive='Y'
+            AND IsSystemLanguage='Y'
+            AND M.AD_Module_ID = :new.AD_Module_ID
+            AND M.AD_Language != AD_Language.AD_Language;
+    END IF;
+    
+    -- Set trl entries to not translated
+    IF UPDATING THEN
+        IF (
+            COALESCE(:old.Name, '.') <> COALESCE(:NEW.Name, '.')
+            OR COALESCE(:old.Description, '.') <> COALESCE(:NEW.Description, '.')
+            OR COALESCE(:old.Help, '.') <> COALESCE(:NEW.Help, '.'))
+        THEN
+            UPDATE OBUISEL_Selector_Trl
+            SET IsTranslated='N',
+                Updated=now()
+            WHERE OBUISEL_Selector_ID=:new.OBUISEL_Selector_ID;
+        END IF;
+    END IF;
+END OBUISEL_SELECTOR_TRL_TRG
+]]></body>
+    </trigger>
+  </database>