src-db/database/model/functions/AD_PARENT_MENU_ELEMENT.xml
author Juan Pablo Aroztegi <juanpablo.aroztegi@openbravo.com>
Wed, 03 Sep 2008 17:55:37 +0000
changeset 1605 8a0fe0193bef
parent 756 ae11e4610537
child 6701 690d2af86089
permissions -rw-r--r--
Merge r2.5x intro trunk
carlos@0
     1
<?xml version="1.0"?>
adrian@94
     2
  <database name="FUNCTION AD_PARENT_MENU_ELEMENT">
adrian@94
     3
    <function name="AD_PARENT_MENU_ELEMENT" type="VARCHAR">
juanpablo@1605
     4
      <parameter name="p_nodeid" type="VARCHAR" mode="in">
antonio@735
     5
        <default/>
antonio@735
     6
      </parameter>
juanpablo@1605
     7
      <parameter name="p_clientid" type="VARCHAR" mode="in">
antonio@735
     8
        <default/>
antonio@735
     9
      </parameter>
antonio@735
    10
      <parameter name="p_language" type="VARCHAR" mode="in">
antonio@735
    11
        <default/>
antonio@735
    12
      </parameter>
gorkaion@239
    13
      <body><![CDATA[/*************************************************************************
carlos@0
    14
* The contents of this file are subject to the Openbravo  Public  License
carlos@0
    15
* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
carlos@0
    16
* Version 1.1  with a permitted attribution clause; you may not  use this
carlos@0
    17
* file except in compliance with the License. You  may  obtain  a copy of
carlos@0
    18
* the License at http://www.openbravo.com/legal/license.html
carlos@0
    19
* Software distributed under the License  is  distributed  on  an "AS IS"
carlos@0
    20
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
carlos@0
    21
* License for the specific  language  governing  rights  and  limitations
carlos@0
    22
* under the License.
carlos@0
    23
* The Original Code is Openbravo ERP.
carlos@0
    24
* The Initial Developer of the Original Code is Openbravo SL
carlos@0
    25
* All portions are Copyright (C) 2001-2006 Openbravo SL
carlos@0
    26
* All Rights Reserved.
carlos@0
    27
* Contributor(s):  ______________________________________.
carlos@0
    28
************************************************************************/
carlos@0
    29
/*************************************************************************
carlos@0
    30
* Title: Return 'Org Level' if orgID is a leaf of the org tree
carlos@0
    31
*    where parentOrgID is the root. Else return -1
carlos@0
    32
************************************************************************/
juanpablo@1605
    33
  v_treeID varchar2(32) ;
juanpablo@1605
    34
  v_Parent varchar(32) ; --OBTG:varchar2--
carlos@0
    35
  v_Name   VARCHAR2(1000) ;
carlos@0
    36
BEGIN
carlos@0
    37
  SELECT MAX(AD_TREE_MENU_ID)
carlos@0
    38
  INTO v_treeID
carlos@0
    39
  FROM AD_CLIENTINFO
carlos@0
    40
  WHERE AD_CLIENT_ID=p_clientID;
carlos@0
    41
carlos@0
    42
  SELECT MAX(PARENT_ID), MAX(case when AD_MENU_TRL.NAME IS NULL then AD_MENU.NAME else AD_MENU_TRL.NAME end)
carlos@0
    43
  INTO v_Parent, v_Name
carlos@0
    44
  FROM AD_TREENODE, AD_MENU
carlos@0
    45
    left join AD_MENU_TRL on AD_MENU.AD_MENU_ID = AD_MENU_TRL.AD_MENU_ID
carlos@0
    46
                            AND AD_MENU_TRL.AD_LANGUAGE = p_Language
carlos@0
    47
  WHERE AD_TREE_ID = v_TreeID
carlos@0
    48
  AND NODE_ID = p_NodeID
carlos@0
    49
  AND NODE_ID = AD_MENU.AD_MENU_ID;
carlos@0
    50
carlos@0
    51
  WHILE v_Parent IS NOT NULL
carlos@0
    52
  LOOP
juanpablo@1605
    53
    IF v_Parent = '0' THEN
carlos@0
    54
        RETURN v_Name;
carlos@0
    55
    END IF;
carlos@0
    56
carlos@0
    57
    SELECT MAX(PARENT_ID), MAX(case when AD_MENU_TRL.NAME IS NULL then AD_MENU.NAME else AD_MENU_TRL.NAME end) || '  ||  ' || v_Name
carlos@0
    58
      INTO v_Parent, v_Name
carlos@0
    59
      FROM AD_TREENODE, AD_MENU
carlos@0
    60
        left join AD_MENU_TRL on AD_MENU.AD_MENU_ID = AD_MENU_TRL.AD_MENU_ID
carlos@0
    61
                            AND AD_MENU_TRL.AD_LANGUAGE = p_Language
carlos@0
    62
      WHERE AD_TREE_ID = v_TreeID
carlos@0
    63
      AND NODE_ID = v_Parent
carlos@0
    64
      AND NODE_ID = AD_MENU.AD_MENU_ID;
carlos@0
    65
  END LOOP;
carlos@0
    66
  RETURN(v_Name) ;
adrian@170
    67
END AD_PARENT_MENU_ELEMENT
gorkaion@239
    68
]]></body>
adrian@94
    69
    </function>
adrian@94
    70
  </database>