src/org/openbravo/erpCommon/ad_reports/ReportProjectBuildingSite_data.xsql
author David Baz Fayos <david.baz@openbravo.com>
Tue, 27 May 2008 15:26:10 +0000
changeset 1044 8691bbc94032
parent 423 ecf368072c48
child 1051 622bb9231928
permissions -rw-r--r--
Removed old frame parameter of windowTableId
carlos@0
     1
<?xml version="1.0" encoding="UTF-8" ?>
carlos@0
     2
<!--
carlos@0
     3
 *************************************************************************
carlos@0
     4
 * The contents of this file are subject to the Openbravo  Public  License
carlos@0
     5
 * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
carlos@0
     6
 * Version 1.1  with a permitted attribution clause; you may not  use this
carlos@0
     7
 * file except in compliance with the License. You  may  obtain  a copy of
carlos@0
     8
 * the License at http://www.openbravo.com/legal/license.html 
carlos@0
     9
 * Software distributed under the License  is  distributed  on  an "AS IS"
carlos@0
    10
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
carlos@0
    11
 * License for the specific  language  governing  rights  and  limitations
carlos@0
    12
 * under the License. 
carlos@0
    13
 * The Original Code is Openbravo ERP. 
carlos@0
    14
 * The Initial Developer of the Original Code is Openbravo SL 
carlos@0
    15
 * All portions are Copyright (C) 2001-2006 Openbravo SL 
carlos@0
    16
 * All Rights Reserved. 
carlos@0
    17
 * Contributor(s):  ______________________________________.
carlos@0
    18
 ************************************************************************
carlos@0
    19
-->
carlos@0
    20
carlos@0
    21
carlos@0
    22
carlos@0
    23
carlos@0
    24
carlos@0
    25
<SqlClass name="ReportProjectBuildingSiteData" package="org.openbravo.erpCommon.ad_reports">
carlos@0
    26
  <SqlClassComment></SqlClassComment>
carlos@0
    27
  <SqlMethod name="select" type="preparedStatement" return="multiple">
carlos@0
    28
    <SqlMethodComment></SqlMethodComment>
carlos@0
    29
    <Sql>
carlos@0
    30
    <![CDATA[
carlos@0
    31
      SELECT C_PROJECT.VALUE||'-'||C_PROJECT.NAME AS PROJECTNAME, (CASE WHEN C_BPARTNER.NAME IS NULL THEN 'SIN ADJUDICAR' ELSE REPLACE(TO_CHAR(C_BPARTNER.NAME), '&', '') END) AS BPARTNERNAME, M_PRODUCT.NAME AS PRODUCTNAME, 
carlos@0
    32
      SUM(C_PROJECTLINE.PLANNEDQTY) AS PLANNEDQTY, C_PROJECTLINE.PLANNEDPRICE AS PLANNEDPRICE, 
carlos@0
    33
      (SUM(C_PROJECTLINE.PLANNEDQTY) *C_PROJECTLINE.PLANNEDPRICE)  AS PLANNEDPOPRICE, (CASE WHEN C_BPARTNER.NAME IS NULL THEN '&#x00A0;' ELSE '' END) AS BLANK_SPACE, '1' AS NUMBER_PROJECT, '' AS NAME, '' AS ID
carlos@0
    34
      FROM C_PROJECT left join C_BPARTNER on C_PROJECT.C_BPARTNER_ID = C_BPARTNER.C_BPARTNER_ID
carlos@0
    35
                     left join C_PROJECTLINE on C_PROJECT.C_PROJECT_ID = C_PROJECTLINE.C_PROJECT_ID 
carlos@0
    36
                     left join C_LOCATION on C_PROJECT.C_LOCATION_ID = C_LOCATION.C_LOCATION_ID
carlos@0
    37
                     left join M_PRODUCT on C_PROJECTLINE.M_PRODUCT_ID = M_PRODUCT.M_PRODUCT_ID
carlos@0
    38
      WHERE C_PROJECT.ISACTIVE = 'Y'
carlos@0
    39
      AND C_PROJECT.AD_CLIENT_ID IN ('1')
carlos@0
    40
      AND C_PROJECT.AD_ORG_ID IN ('1')
carlos@0
    41
      AND 1=1
carlos@0
    42
      GROUP BY C_BPARTNER.NAME, C_PROJECT.NAME, M_PRODUCT.NAME, C_PROJECTLINE.PLANNEDQTY, C_PROJECTLINE.PLANNEDPRICE, C_PROJECT.VALUE
carlos@0
    43
      ORDER BY C_BPARTNER.NAME, C_PROJECT.VALUE
carlos@0
    44
     ]]></Sql>
carlos@0
    45
    <Parameter name="adUserClient" type="replace" optional="true" after="AND C_PROJECT.AD_CLIENT_ID IN (" text="'1'"/>
carlos@0
    46
    <Parameter name="adUserOrg" type="replace" optional="true" after="AND C_PROJECT.AD_ORG_ID IN (" text="'1'"/>
carlos@0
    47
    <Parameter name="dateFrom" optional="true" after="AND 1=1"><![CDATA[ AND C_PROJECT.CREATED >= to_date(?)]]></Parameter>
carlos@0
    48
    <Parameter name="dateTo" optional="true" after="AND 1=1"><![CDATA[ AND C_PROJECT.CREATED < to_date(?)]]></Parameter>
carlos@0
    49
    <Parameter name="cbPartnerId" optional="true" type="argument" after="AND 1=1"><![CDATA[ AND C_PROJECT.C_BPARTNER_ID IN]]></Parameter>
carlos@423
    50
    <Parameter name="cProjectId" optional="true" after="AND 1=1"><![CDATA[ AND C_PROJECT.C_PROJECT_ID = TO_NUMBER(?)]]></Parameter>
carlos@0
    51
    <Parameter name="cProductCategoryId" optional="true" type="argument" after="AND 1=1"><![CDATA[ AND M_PRODUCT.M_PRODUCT_CATEGORY_ID IN]]></Parameter>
carlos@0
    52
    <Parameter name="cProjectKind" optional="true" type="argument" after="AND 1=1"><![CDATA[ AND C_PROJECT.PROJECTKIND IN]]></Parameter>
carlos@0
    53
    <Parameter name="cProjectPhase" optional="true" type="argument" after="AND 1=1"><![CDATA[ AND C_PROJECT.PROJECTPHASE IN]]></Parameter>
carlos@0
    54
    <Parameter name="cProjectStatus" optional="true" type="argument" after="AND 1=1"><![CDATA[ AND C_PROJECT.PROJECTSTATUS IN]]></Parameter>
carlos@0
    55
    <Parameter name="cProjectPublic" optional="true" after="AND 1=1"><![CDATA[ AND C_PROJECT.PUBLICPRIVATE = ?]]></Parameter>
carlos@0
    56
    <Parameter name="cRegionId" optional="true" type="argument" after="AND 1=1"><![CDATA[ AND C_LOCATION.C_REGION_ID IN]]></Parameter>
carlos@423
    57
    <Parameter name="salesRep" optional="true" after="AND 1=1"><![CDATA[ AND C_PROJECT.SALESREP_ID = TO_NUMBER(?)]]></Parameter>
carlos@0
    58
    <Parameter name="productId" optional="true" type="argument" after="AND 1=1"><![CDATA[ AND M_PRODUCT.M_PRODUCT_ID IN]]></Parameter>
carlos@0
    59
  </SqlMethod>
carlos@0
    60
  <SqlMethod name="set" type="constant" return="multiple">
carlos@0
    61
      <SqlMethodComment></SqlMethodComment>
carlos@0
    62
      <Sql></Sql>
carlos@0
    63
  </SqlMethod>
carlos@0
    64
  <SqlMethod name="bPartnerDescription" type="preparedStatement" return="String" default="">
carlos@0
    65
    <SqlMethodComment></SqlMethodComment>
carlos@0
    66
    <Sql>
carlos@0
    67
    SELECT NAME FROM C_BPARTNER 
carlos@423
    68
    WHERE C_BPARTNER_ID = TO_NUMBER(?)
carlos@0
    69
    </Sql>
carlos@0
    70
    <Parameter name="cBpartnerId"/>
carlos@0
    71
  </SqlMethod>
carlos@0
    72
  <SqlMethod name="selectProject" type="preparedStatement" return="String" default="">
carlos@0
    73
    <SqlMethodComment></SqlMethodComment>
carlos@0
    74
    <Sql>
carlos@0
    75
    SELECT VALUE || ' - ' ||NAME FROM C_PROJECT 
carlos@423
    76
    WHERE C_PROJECT_ID = TO_NUMBER(?)
carlos@0
    77
    </Sql>
carlos@0
    78
    <Parameter name="cProjectId"/>
carlos@0
    79
  </SqlMethod>
carlos@0
    80
  <SqlMethod name="selectRegionId" type="preparedStatement" return="String" default="">
carlos@0
    81
    <SqlMethodComment></SqlMethodComment>
carlos@0
    82
    <Sql>
carlos@0
    83
    SELECT INITCAP(NAME) AS NAME FROM C_REGION 
carlos@423
    84
    WHERE C_REGION_ID = TO_NUMBER(?)
carlos@0
    85
    </Sql>
carlos@0
    86
    <Parameter name="cRegionId"/>
carlos@0
    87
  </SqlMethod>
carlos@0
    88
  <SqlMethod name="selectProjectkind" type="preparedStatement" return="String" default="">
carlos@0
    89
    <SqlMethodComment></SqlMethodComment>
carlos@0
    90
    <Sql>
carlos@0
    91
    SELECT (CASE WHEN arl_t.NAME IS NULL THEN arl.NAME ELSE arl_t.NAME END) AS NAME 
carlos@0
    92
    FROM AD_REF_LIST arl left join AD_REF_LIST_TRL arl_t on arl.ad_ref_list_id = arl_t.ad_ref_list_id
carlos@0
    93
                                                         AND arl_t.AD_LANGUAGE = ?
carlos@0
    94
    WHERE arl.ad_reference_id = 800004 
carlos@0
    95
    AND arl.isActive = 'Y' 
carlos@0
    96
    AND 1=1
carlos@0
    97
    </Sql>
carlos@0
    98
    <Parameter name="adLanguage"/>
carlos@0
    99
    <Parameter name="projectkind" optional="true" type="argument" after="AND 1=1"><![CDATA[ AND arl.VALUE IN]]></Parameter>
carlos@0
   100
  </SqlMethod>
carlos@0
   101
  <SqlMethod name="selectProjectphase" type="preparedStatement" return="String" default="">
carlos@0
   102
    <SqlMethodComment></SqlMethodComment>
carlos@0
   103
    <Sql>
carlos@0
   104
    SELECT (CASE WHEN arl_t.NAME IS NULL THEN arl.NAME ELSE arl_t.NAME END) AS NAME 
carlos@0
   105
    FROM AD_REF_LIST arl left join AD_REF_LIST_TRL arl_t  on arl.ad_ref_list_id = arl_t.ad_ref_list_id 
carlos@0
   106
                                                        AND arl_t.AD_LANGUAGE = ?
carlos@0
   107
    WHERE arl.ad_reference_id = 800003 
carlos@0
   108
    AND arl.isActive = 'Y' 
carlos@0
   109
    AND 1=1
carlos@0
   110
    </Sql>
carlos@0
   111
    <Parameter name="adLanguage"/>
carlos@0
   112
    <Parameter name="projectphase" optional="true" type="argument" after="AND 1=1"><![CDATA[ AND arl.VALUE IN]]></Parameter>
carlos@0
   113
  </SqlMethod>
carlos@0
   114
  <SqlMethod name="selectProjectstatus" type="preparedStatement" return="String" default="">
carlos@0
   115
    <SqlMethodComment></SqlMethodComment>
carlos@0
   116
    <Sql>
carlos@0
   117
    SELECT (CASE WHEN arl_t.NAME IS NULL THEN arl.NAME ELSE arl_t.NAME END) AS NAME 
carlos@0
   118
    FROM AD_REF_LIST arl left join AD_REF_LIST_TRL arl_t on  arl.ad_ref_list_id = arl_t.ad_ref_list_id
carlos@0
   119
                                                        AND arl_t.AD_LANGUAGE = ?
carlos@0
   120
    WHERE arl.ad_reference_id = 800002 
carlos@0
   121
    AND arl.isActive = 'Y' 
carlos@0
   122
    AND 1=1
carlos@0
   123
    </Sql>
carlos@0
   124
    <Parameter name="adLanguage"/>
carlos@0
   125
    <Parameter name="projectstatus" optional="true" type="argument" after="AND 1=1"><![CDATA[ AND arl.VALUE IN]]></Parameter>
carlos@0
   126
  </SqlMethod>
carlos@0
   127
  <SqlMethod name="selectProjectpublic" type="preparedStatement" return="String" default="">
carlos@0
   128
    <SqlMethodComment></SqlMethodComment>
carlos@0
   129
    <Sql>
carlos@0
   130
    SELECT (CASE WHEN arl_t.NAME IS NULL THEN arl.NAME ELSE arl_t.NAME END) AS NAME 
carlos@0
   131
    FROM AD_REF_LIST arl left join AD_REF_LIST_TRL arl_t on arl.ad_ref_list_id = arl_t.ad_ref_list_id 
carlos@0
   132
                                                        AND arl_t.AD_LANGUAGE = ?
carlos@0
   133
    WHERE arl.ad_reference_id = 800005 
carlos@0
   134
    AND arl.isActive = 'Y' 
carlos@0
   135
    AND arl.VALUE = ?
carlos@0
   136
    </Sql>
carlos@0
   137
    <Parameter name="adLanguage"/>
carlos@0
   138
    <Parameter name="projectpublic"/>
carlos@0
   139
  </SqlMethod>
carlos@0
   140
  <SqlMethod name="selectSalesRep" type="preparedStatement" return="String" default="">
carlos@0
   141
    <SqlMethodComment></SqlMethodComment>
carlos@0
   142
    <Sql><![CDATA[
carlos@0
   143
      SELECT (AD_User.Firstname||' '||AD_USER.LASTNAME) as name 
carlos@0
   144
      FROM AD_User
carlos@0
   145
      WHERE AD_User.AD_Org_ID IN('1') 
carlos@0
   146
      AND AD_User.AD_Client_ID IN('1')  
carlos@0
   147
      AND EXISTS (SELECT * FROM C_BPartner bp WHERE AD_User.C_BPartner_ID=bp.C_BPartner_ID AND bp.IsSalesRep='Y')
carlos@423
   148
      AND AD_USER.AD_USER_ID = TO_NUMBER(?)
carlos@0
   149
      AND AD_User.isActive = 'Y' 
carlos@0
   150
    ]]></Sql>
carlos@0
   151
    <Parameter name="adOrgClient" type="replace" optional="true" after="AD_User.AD_Org_ID IN(" text="'1'"/>
carlos@0
   152
    <Parameter name="adUserClient" type="replace" optional="true" after="AD_User.AD_Client_ID IN(" text="'1'"/>
carlos@0
   153
    <Parameter name="adUserId"/>
carlos@0
   154
  </SqlMethod>
carlos@0
   155
  <SqlMethod name="selectProduct" type="preparedStatement" return="String" default="">
carlos@0
   156
    <SqlMethodComment></SqlMethodComment>
carlos@0
   157
    <Sql>
carlos@0
   158
    SELECT M_PRODUCT.NAME AS NAME 
carlos@0
   159
    FROM M_PRODUCT
carlos@423
   160
    WHERE M_PRODUCT.M_PRODUCT_ID = TO_NUMBER(?)
carlos@0
   161
    </Sql>
carlos@0
   162
    <Parameter name="productId"/>
carlos@0
   163
  </SqlMethod>
carlos@0
   164
  <SqlMethod name="selectMproduct" type="preparedStatement" return="multiple">
carlos@0
   165
    <SqlMethodComment></SqlMethodComment>
carlos@0
   166
    <Sql>
carlos@0
   167
    <![CDATA[
carlos@0
   168
      SELECT M_PRODUCT.M_PRODUCT_ID AS ID,M_PRODUCT.NAME
carlos@0
   169
      FROM M_PRODUCT
carlos@0
   170
      WHERE AD_ORG_ID IN ('1') 
carlos@0
   171
      AND AD_CLIENT_ID IN ('1') 
carlos@0
   172
      AND (1=2 )
carlos@0
   173
     ]]></Sql>
carlos@0
   174
     <Parameter name="adOrgClient" type="replace" optional="true" after="AD_ORG_ID IN (" text="'1'"/>
carlos@0
   175
     <Parameter name="adUserClient" type="replace" optional="true" after="AND AD_CLIENT_ID IN (" text="'1'"/>
carlos@0
   176
     <Parameter name="mProductId" optional="true" type="argument" after="(1=2" text=" OR M_PRODUCT_ID IN"/>
carlos@0
   177
  </SqlMethod>
carlos@0
   178
  <SqlMethod name="selectBpartner" type="preparedStatement" return="multiple">
carlos@0
   179
    <SqlMethodComment></SqlMethodComment>
carlos@0
   180
    <Sql>
carlos@0
   181
    <![CDATA[
carlos@0
   182
      SELECT C_BPARTNER_ID AS ID, C_BPARTNER.NAME
carlos@0
   183
      FROM C_BPARTNER
carlos@0
   184
      WHERE AD_ORG_ID IN ('1') 
carlos@0
   185
      AND AD_CLIENT_ID IN ('1') 
carlos@0
   186
      AND (1=2 )
carlos@0
   187
     ]]></Sql>
carlos@0
   188
     <Parameter name="adOrgClient" type="replace" optional="true" after="AD_ORG_ID IN (" text="'1'"/>
carlos@0
   189
     <Parameter name="adUserClient" type="replace" optional="true" after="AND AD_CLIENT_ID IN (" text="'1'"/>
carlos@0
   190
     <Parameter name="cBpartnerId" optional="true" type="argument" after="(1=2" text=" OR C_BPARTNER_ID IN"/>
carlos@0
   191
  </SqlMethod>
carlos@0
   192
  <SqlMethod name="selectCategoryId" type="preparedStatement" return="String" default="">
carlos@0
   193
    <SqlMethodComment></SqlMethodComment>
carlos@0
   194
    <Sql>
carlos@0
   195
    SELECT NAME FROM M_PRODUCT_CATEGORY 
carlos@0
   196
    WHERE 1=1
carlos@0
   197
    </Sql>
carlos@0
   198
    <Parameter name="category" optional="true" type="argument" after="WHERE 1=1"><![CDATA[ AND M_PRODUCT_CATEGORY_ID IN]]></Parameter>
carlos@0
   199
  </SqlMethod>
carlos@0
   200
</SqlClass>