src/org/openbravo/erpCommon/ad_reports/ReportOffer_data.xsql
author David Baz Fayos <david.baz@openbravo.com>
Tue, 27 May 2008 15:26:10 +0000
changeset 1044 8691bbc94032
parent 752 bc18bf2d37e1
child 4377 e82f8f4f93e5
permissions -rw-r--r--
Removed old frame parameter of windowTableId
<?xml version="1.0" encoding="UTF-8" ?>
<!--
 *************************************************************************
 * 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-2006 Openbravo SL 
 * All Rights Reserved. 
 * Contributor(s):  ______________________________________.
 ************************************************************************
-->


<SqlClass name="ReportOfferData" package="org.openbravo.erpCommon.ad_reports">
  <SqlClassComment></SqlClassComment>
  <SqlMethod name="select" type="preparedStatement" return="multiple">
    <SqlMethodComment></SqlMethodComment>
    <Sql>
    <![CDATA[
        SELECT C_BPARTNER_ID, M_OFFER_ID, C_BPARTNER_NAME, DATEFROM, DATETO,
        ADDAMT, DISCOUNT, FIXED, C_BPARTNER_ID AS ID, C_BPARTNER_NAME AS NAME,
        M_OFFER_NAME, 'datawarehouseclose' AS CLASS_TREE,
        M_OFFER_ID ||':'||C_BPARTNER_ID AS M_OFFER_ID_C_BPARTNER_ID
        FROM(SELECT M_OFFER_BPARTNER.C_BPARTNER_ID, M_OFFER.M_OFFER_ID, M_OFFER.NAME AS M_OFFER_NAME,
             C_BPARTNER.NAME AS C_BPARTNER_NAME, M_OFFER.DATEFROM, M_OFFER.DATETO,
             M_OFFER.AD_CLIENT_ID, M_OFFER.AD_ORG_ID, M_OFFER.ADDAMT,
             M_OFFER.DISCOUNT, M_OFFER.FIXED
             FROM M_OFFER, M_OFFER_BPARTNER, C_BPARTNER
             WHERE M_OFFER.BPARTNER_SELECTION = 'N'
             AND M_OFFER.M_OFFER_ID = M_OFFER_BPARTNER.M_OFFER_ID
             AND M_OFFER_BPARTNER.C_BPARTNER_ID = C_BPARTNER.C_BPARTNER_ID
             UNION
             SELECT C_BPARTNER.C_BPARTNER_ID, M_OFFER.M_OFFER_ID, M_OFFER.NAME AS M_OFFER_NAME,
             C_BPARTNER.NAME AS C_BPARTNER_NAME, M_OFFER.DATEFROM, M_OFFER.DATETO,
             M_OFFER.AD_CLIENT_ID, M_OFFER.AD_ORG_ID, M_OFFER.ADDAMT,
             M_OFFER.DISCOUNT, M_OFFER.FIXED
             FROM M_OFFER, C_BPARTNER
             WHERE M_OFFER.BPARTNER_SELECTION = 'Y'
             AND C_BPARTNER.C_BPARTNER_ID NOT IN (SELECT C_BPARTNER_ID FROM M_OFFER_BPARTNER WHERE M_OFFER_ID = M_OFFER.M_OFFER_ID)) A
        WHERE A.AD_CLIENT_ID IN ('1')
        AND A.AD_ORG_ID IN ('1')
        AND DATEFROM >= TO_DATE(?)
        AND (DATETO IS NULL OR DATETO <= TO_DATE(?))
        AND 1=1
        ORDER BY C_BPARTNER_NAME, M_OFFER_NAME
      ]]></Sql>
    <Parameter name="adUserClient" type="replace" optional="true" after="A.AD_CLIENT_ID IN (" text="'1'"/>
    <Parameter name="adUserOrg" type="replace" optional="true" after="A.AD_ORG_ID IN (" text="'1'"/>
    <Parameter name="datefrom"/>
    <Parameter name="dateto"/>    
    <Parameter name="parBPartnerId" optional="true" type="argument" after="AND 1=1"><![CDATA[ AND A.C_BPARTNER_ID IN]]></Parameter>
  </SqlMethod>
  <SqlMethod name="set" type="constant" return="multiple">
      <SqlMethodComment></SqlMethodComment>
      <Sql></Sql>
  </SqlMethod>
   <SqlMethod name="selectBpartner" type="preparedStatement" return="multiple">
    <SqlMethodComment></SqlMethodComment>
    <Sql>
    <![CDATA[
      SELECT C_BPARTNER_ID AS ID, C_BPARTNER.NAME
      FROM C_BPARTNER
      WHERE AD_ORG_ID IN ('1') 
      AND AD_CLIENT_ID IN ('1') 
      AND (1=2 )
     ]]></Sql>
     <Parameter name="adOrgClient" type="replace" optional="true" after="AD_ORG_ID IN (" text="'1'"/>
     <Parameter name="adUserClient" type="replace" optional="true" after="AND AD_CLIENT_ID IN (" text="'1'"/>
     <Parameter name="cBpartnerId" optional="true" type="argument" after="(1=2" text=" OR C_BPARTNER_ID IN"/>
  </SqlMethod>
</SqlClass>