<!DOCTYPE openRPTDef>
<report>
 <title>Addresses Master List</title>
 <name>AddressesMasterList</name>
 <description></description>
 <grid>
  <snap/>
  <show/>
  <x>0.05</x>
  <y>0.05</y>
 </grid>
 <size>Letter</size>
 <landscape/>
 <topmargin>50</topmargin>
 <bottommargin>50</bottommargin>
 <rightmargin>50</rightmargin>
 <leftmargin>50</leftmargin>
 <querysource>
  <name>detail</name>
  <sql>SELECT * 
FROM (
SELECT 'Contact' AS type, cntct_first_name AS first,
       cntct_last_name AS last, crmacct_number, cntct_phone AS phone,
       cntct_email AS email, cntct_fax AS fax, addr.*
FROM addr, cntct LEFT OUTER JOIN crmacct ON (cntct_crmacct_id=crmacct_id)
WHERE (cntct_addr_id=addr_id)
UNION
SELECT 'Ship-To' AS type, shipto_num AS first,
       shipto_name AS last, crmacct_number, '' AS phone,
       '' AS email, '' AS fax, addr.*
FROM addr, shiptoinfo LEFT OUTER JOIN crmacct ON (shipto_cust_id=crmacct_cust_id
)
WHERE (shipto_addr_id=addr_id)
UNION
SELECT 'Vendor' AS type, vend_number AS first,
       vend_name AS last, crmacct_number, '' AS phone,
       '' AS email, '' AS fax, addr.*
FROM addr, vendinfo LEFT OUTER JOIN crmacct ON (vend_id=crmacct_vend_id)
WHERE (vend_addr_id=addr_id)
UNION
SELECT 'Vendor Address' AS type, vendaddr_code AS first,
       vendaddr_name AS last, crmacct_number, '' AS phone,
       '' AS email, '' AS fax, addr.*
FROM addr, vendaddrinfo LEFT OUTER JOIN crmacct ON (vendaddr_vend_id=crmacct_vend_id)
WHERE (vendaddr_addr_id=addr_id)
UNION
SELECT 'Site' AS type, warehous_code AS first,
       warehous_descrip AS last, '' AS crmacct_number, '' AS phone,
       '' AS email, '' AS fax, addr.*
FROM addr, whsinfo
WHERE (warehous_addr_id=addr_id)

UNION
SELECT '' AS type, '' AS first, '' AS last,
       '' AS crmacct_number, '' AS phone,
       '' AS email,
       '' AS fax, addr.*
FROM addr
WHERE addr_id NOT IN (
            SELECT cntct_addr_id FROM cntct WHERE (cntct_addr_id IS NOT NULL)
            UNION SELECT shipto_addr_id FROM shiptoinfo WHERE (shipto_addr_id IS NOT NULL) 
            UNION SELECT vend_addr_id FROM vendinfo WHERE (vend_addr_id IS NOT NULL)
            UNION SELECT vendaddr_addr_id FROM vendaddrinfo WHERE (vendaddr_addr_id IS NOT NULL)
            UNION SELECT warehous_addr_id FROM whsinfo WHERE (warehous_addr_id IS NOT NULL))
) data
&lt;? foreach("char_id_text_list") ?>
  LEFT OUTER JOIN charass charass_alias&lt;? literal("char_id_text_list") ?> ON ((charass_alias&lt;? literal("char_id_text_list") ?>.charass_target_type='ADDR') 
                                                                    AND  (charass_alias&lt;? literal("char_id_text_list") ?>.charass_target_id=addr_id)
                                                                    AND  (charass_alias&lt;? literal("char_id_text_list") ?>.charass_char_id=&lt;? value("char_id_text_list") ?>))
  LEFT OUTER JOIN char char_alias&lt;? literal("char_id_text_list") ?> ON (charass_alias&lt;? literal("char_id_text_list") ?>.charass_char_id=char_alias&lt;? literal("char_id_text_list") ?>.char_id)
&lt;? endforeach ?>
&lt;? foreach("char_id_list_list") ?>
  LEFT OUTER JOIN charass charass_alias&lt;? literal("char_id_list_list") ?> ON ((charass_alias&lt;? literal("char_id_list_list") ?>.charass_target_type='ADDR') 
                                                                    AND  (charass_alias&lt;? literal("char_id_list_list") ?>.charass_target_id=addr_id)
                                                                    AND  (charass_alias&lt;? literal("char_id_list_list") ?>.charass_char_id=&lt;? value("char_id_list_list") ?>))
  LEFT OUTER JOIN char char_alias&lt;? literal("char_id_list_list") ?> ON (charass_alias&lt;? literal("char_id_list_list") ?>.charass_char_id=char_alias&lt;? literal("char_id_list_list") ?>.char_id)
&lt;? endforeach ?>
&lt;? foreach("char_id_date_list") ?>
  LEFT OUTER JOIN charass charass_alias&lt;? literal("char_id_date_list") ?> ON ((charass_alias&lt;? literal("char_id_date_list") ?>.charass_target_type='ADDR') 
                                                                    AND  (charass_alias&lt;? literal("char_id_date_list") ?>.charass_target_id=addr_id)
                                                                    AND  (charass_alias&lt;? literal("char_id_date_list") ?>.charass_char_id=&lt;? value("char_id_date_list") ?>))
  LEFT OUTER JOIN char char_alias&lt;? literal("char_id_date_list") ?> ON (charass_alias&lt;? literal("char_id_date_list") ?>.charass_char_id=char_alias&lt;? literal("char_id_date_list") ?>.char_id)
&lt;? endforeach ?>
WHERE true
&lt;? if not exists("showInactive") ?> AND addr_active &lt;? endif ?>
&lt;? literal("charClause") ?>
ORDER BY addr_country, addr_state, addr_city,
         addr_postalcode, addr_line1, addr_line2,
         addr_line3, type, last, first;</sql>
 </querysource>
 <rpthead>
  <height>156</height>
  <label>
   <rect>
    <x>270</x>
    <y>136</y>
    <width>95</width>
    <height>12</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <top/>
   <string>First Name / Number</string>
  </label>
  <label>
   <rect>
    <x>625</x>
    <y>136</y>
    <width>120</width>
    <height>12</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <top/>
   <string>Phone</string>
  </label>
  <label>
   <rect>
    <x>140</x>
    <y>121</y>
    <width>120</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Line 2</string>
  </label>
  <label>
   <rect>
    <x>135</x>
    <y>136</y>
    <width>120</width>
    <height>12</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <top/>
   <string>Use of Address</string>
  </label>
  <label>
   <rect>
    <x>375</x>
    <y>136</y>
    <width>120</width>
    <height>12</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <top/>
   <string>Last Name / Name</string>
  </label>
  <line>
   <xstart>6.33333</xstart>
   <ystart>150.333</ystart>
   <xend>995.333</xend>
   <yend>150.333</yend>
   <weight>2</weight>
  </line>
  <label>
   <rect>
    <x>625</x>
    <y>121</y>
    <width>120</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Country</string>
  </label>
  <label>
   <rect>
    <x>10</x>
    <y>121</y>
    <width>120</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Line 1</string>
  </label>
  <label>
   <rect>
    <x>375</x>
    <y>121</y>
    <width>120</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>City</string>
  </label>
  <label>
   <rect>
    <x>540</x>
    <y>5</y>
    <width>450</width>
    <height>37</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>18</size>
    <weight>bold</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Addresses Master List</string>
  </label>
  <label>
   <rect>
    <x>500</x>
    <y>121</y>
    <width>120</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>State/Province</string>
  </label>
  <label>
   <rect>
    <x>270</x>
    <y>121</y>
    <width>95</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Line 3</string>
  </label>
  <label>
   <rect>
    <x>875</x>
    <y>136</y>
    <width>120</width>
    <height>12</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <top/>
   <string>Email Address</string>
  </label>
  <label>
   <rect>
    <x>500</x>
    <y>136</y>
    <width>120</width>
    <height>12</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <top/>
   <string>Account</string>
  </label>
  <label>
   <rect>
    <x>750</x>
    <y>136</y>
    <width>120</width>
    <height>12</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <top/>
   <string>Fax</string>
  </label>
  <label>
   <rect>
    <x>750</x>
    <y>121</y>
    <width>120</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Postal Code</string>
  </label>
  <text>
   <rect>
    <x>5</x>
    <y>36</y>
    <width>725</width>
    <height>15</height>
   </rect>
   <bottompad>12</bottompad>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <top/>
   <data>
    <query>Parameter Query</query>
    <column>filter</column>
   </data>
  </text>
 </rpthead>
 <pghead>
  <firstpage/>
  <height>6</height>
 </pghead>
 <pghead>
  <height>38</height>
  <label>
   <rect>
    <x>270</x>
    <y>-1</y>
    <width>95</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Line 3</string>
  </label>
  <label>
   <rect>
    <x>625</x>
    <y>19</y>
    <width>120</width>
    <height>12</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <top/>
   <string>Phone</string>
  </label>
  <label>
   <rect>
    <x>500</x>
    <y>19</y>
    <width>120</width>
    <height>12</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <top/>
   <string>Account</string>
  </label>
  <label>
   <rect>
    <x>135</x>
    <y>14</y>
    <width>120</width>
    <height>12</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <top/>
   <string>Use of Address</string>
  </label>
  <label>
   <rect>
    <x>500</x>
    <y>-1</y>
    <width>120</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>State/Province</string>
  </label>
  <label>
   <rect>
    <x>625</x>
    <y>-1</y>
    <width>120</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Country</string>
  </label>
  <label>
   <rect>
    <x>270</x>
    <y>14</y>
    <width>95</width>
    <height>12</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <top/>
   <string>First Name / Number</string>
  </label>
  <line>
   <xstart>5</xstart>
   <ystart>31</ystart>
   <xend>992</xend>
   <yend>31</yend>
   <weight>2</weight>
  </line>
  <label>
   <rect>
    <x>875</x>
    <y>19</y>
    <width>120</width>
    <height>12</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <top/>
   <string>Email Address</string>
  </label>
  <label>
   <rect>
    <x>375</x>
    <y>14</y>
    <width>120</width>
    <height>12</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <top/>
   <string>Last Name / Name</string>
  </label>
  <label>
   <rect>
    <x>375</x>
    <y>-1</y>
    <width>120</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>City</string>
  </label>
  <label>
   <rect>
    <x>135</x>
    <y>-1</y>
    <width>120</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Line 2</string>
  </label>
  <label>
   <rect>
    <x>750</x>
    <y>19</y>
    <width>120</width>
    <height>12</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <top/>
   <string>Fax</string>
  </label>
  <label>
   <rect>
    <x>750</x>
    <y>-1</y>
    <width>120</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Postal Code</string>
  </label>
  <label>
   <rect>
    <x>10</x>
    <y>-1</y>
    <width>120</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Line 1</string>
  </label>
 </pghead>
 <section>
  <name>detail</name>
  <group>
   <name>Address</name>
   <column>addr_id</column>
   <head>
    <height>22</height>
    <field>
     <rect>
      <x>375</x>
      <y>5</y>
      <width>120</width>
      <height>15</height>
     </rect>
     <font>
      <face>Arial</face>
      <size>8</size>
      <weight>bold</weight>
     </font>
     <left/>
     <vcenter/>
     <data>
      <query>detail</query>
      <column>addr_city</column>
     </data>
    </field>
    <field>
     <rect>
      <x>750</x>
      <y>5</y>
      <width>120</width>
      <height>15</height>
     </rect>
     <font>
      <face>Arial</face>
      <size>8</size>
      <weight>bold</weight>
     </font>
     <left/>
     <vcenter/>
     <data>
      <query>detail</query>
      <column>addr_postalcode</column>
     </data>
    </field>
    <field>
     <rect>
      <x>625</x>
      <y>5</y>
      <width>120</width>
      <height>15</height>
     </rect>
     <font>
      <face>Arial</face>
      <size>8</size>
      <weight>bold</weight>
     </font>
     <left/>
     <vcenter/>
     <data>
      <query>detail</query>
      <column>addr_country</column>
     </data>
    </field>
    <field>
     <rect>
      <x>140</x>
      <y>5</y>
      <width>120</width>
      <height>15</height>
     </rect>
     <font>
      <face>Arial</face>
      <size>8</size>
      <weight>bold</weight>
     </font>
     <left/>
     <vcenter/>
     <data>
      <query>detail</query>
      <column>addr_line2</column>
     </data>
    </field>
    <field>
     <rect>
      <x>10</x>
      <y>5</y>
      <width>120</width>
      <height>15</height>
     </rect>
     <font>
      <face>Arial</face>
      <size>8</size>
      <weight>bold</weight>
     </font>
     <left/>
     <vcenter/>
     <data>
      <query>detail</query>
      <column>addr_line1</column>
     </data>
    </field>
    <field>
     <rect>
      <x>500</x>
      <y>5</y>
      <width>120</width>
      <height>15</height>
     </rect>
     <font>
      <face>Arial</face>
      <size>8</size>
      <weight>bold</weight>
     </font>
     <left/>
     <vcenter/>
     <data>
      <query>detail</query>
      <column>addr_state</column>
     </data>
    </field>
    <field>
     <rect>
      <x>270</x>
      <y>5</y>
      <width>100</width>
      <height>15</height>
     </rect>
     <font>
      <face>Arial</face>
      <size>8</size>
      <weight>bold</weight>
     </font>
     <left/>
     <vcenter/>
     <data>
      <query>detail</query>
      <column>addr_line3</column>
     </data>
    </field>
   </head>
  </group>
  <detail>
   <key>
    <query>detail</query>
   </key>
   <height>12</height>
   <field>
    <rect>
     <x>375</x>
     <y>0</y>
     <width>100</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <left/>
    <top/>
    <data>
     <query>detail</query>
     <column>last</column>
    </data>
   </field>
   <field>
    <rect>
     <x>750</x>
     <y>0</y>
     <width>120</width>
     <height>12</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <left/>
    <top/>
    <data>
     <query>detail</query>
     <column>fax</column>
    </data>
   </field>
   <field>
    <rect>
     <x>500</x>
     <y>0</y>
     <width>100</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <left/>
    <top/>
    <data>
     <query>detail</query>
     <column>crmacct_number</column>
    </data>
   </field>
   <field>
    <rect>
     <x>625</x>
     <y>0</y>
     <width>100</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <left/>
    <top/>
    <data>
     <query>detail</query>
     <column>phone</column>
    </data>
   </field>
   <field>
    <rect>
     <x>270</x>
     <y>0</y>
     <width>100</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <left/>
    <top/>
    <data>
     <query>detail</query>
     <column>first</column>
    </data>
   </field>
   <field>
    <rect>
     <x>875</x>
     <y>0</y>
     <width>100</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <left/>
    <top/>
    <data>
     <query>detail</query>
     <column>email</column>
    </data>
   </field>
   <field>
    <rect>
     <x>140</x>
     <y>0</y>
     <width>100</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <left/>
    <top/>
    <data>
     <query>detail</query>
     <column>type</column>
    </data>
   </field>
  </detail>
 </section>
 <pgfoot>
  <height>17</height>
  <field>
   <rect>
    <x>90</x>
    <y>-1</y>
    <width>100</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>Context Query</query>
    <column>report_date</column>
   </data>
  </field>
  <label>
   <rect>
    <x>855</x>
    <y>-1</y>
    <width>85</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Page:</string>
  </label>
  <label>
   <rect>
    <x>0</x>
    <y>0</y>
    <width>85</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Report Date:</string>
  </label>
  <field>
   <rect>
    <x>945</x>
    <y>-1</y>
    <width>40</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>Context Query</query>
    <column>page_number</column>
   </data>
  </field>
 </pgfoot>
</report>
