<!DOCTYPE openRPTDef>
<report>
 <title>List Transfer Orders</title>
 <name>ListTransferOrders</name>
 <description></description>
 <size>Letter</size>
 <portrait/>
 <topmargin>50</topmargin>
 <bottommargin>50</bottommargin>
 <rightmargin>50</rightmargin>
 <leftmargin>50</leftmargin>
 <querysource>
  <name>head</name>
  <sql>SELECT &lt;? if exists("src_warehous_id") ?>
         ( SELECT warehous_code
             FROM whsinfo
            WHERE (warehous_id=&lt;? value("src_warehous_id") ?>) )
       &lt;? else ?>
         text('All Sites')
       &lt;? endif ?> AS src_warehous_code,
       &lt;? if exists("dest_warehous_id") ?>
         ( SELECT warehous_code
             FROM whsinfo
            WHERE (warehous_id=&lt;? value("dest_warehous_id") ?>) )
       &lt;? else ?>
          text('All Sites')
       &lt;? endif ?> AS dest_warehous_code,
       CASE WHEN (&lt;? value ("tohead_status") ?>='C') THEN 'Closed'
            WHEN (&lt;? value ("tohead_status") ?>='O') THEN 'Open'
            ELSE text('All Statuses')
            END AS status;
</sql>
 </querysource>
 <querysource>
  <name>detail</name>
  <sql>SELECT tohead_number,
       tohead_srcname,
       tohead_trnsname,
       tohead_destname,
       formatDate(tohead_orderdate) AS f_orderdate,
       formatDate(MIN(toitem_schedshipdate)) AS f_scheddate,
       formatDate(DATE(MAX(shipitem_shipdate))) AS f_shipdate,
       CASE WHEN (tohead_status='C') THEN 'Closed'
            WHEN (tohead_status='O') THEN 'Open'
            ELSE tohead_status
            END AS status
  FROM tohead, toitem LEFT OUTER JOIN
       (shipitem JOIN
        shiphead ON (shipitem_shiphead_id=shiphead_id
                    AND shiphead_order_type='TO')
       ) ON (shipitem_orderitem_id=toitem_id)
 WHERE ((toitem_tohead_id=tohead_id)
   AND  (toitem_status&lt;>'X')
&lt;? if exists("tohead_status") ?>
   AND (tohead_status=&lt;? value("tohead_status") ?>)
&lt;? elseif exists("excludeClosed") ?>
   AND (tohead_status &lt;> 'C')
&lt;? endif ?>
&lt;? if exists("src_warehous_id") ?>
   AND  (tohead_src_warehous_id=&lt;? value("src_warehous_id") ?>)
&lt;? endif ?>
&lt;? if exists("dest_warehous_id") ?>
   AND  (tohead_dest_warehous_id=&lt;? value("dest_warehous_id") ?>)
&lt;? endif ?>
)
GROUP BY tohead_number, tohead_srcname, tohead_trnsname, tohead_destname,
         tohead_orderdate, tohead_status
ORDER BY tohead_number;</sql>
 </querysource>
 <rpthead>
  <height>221</height>
  <label>
   <rect>
    <x>10</x>
    <y>200</y>
    <width>50</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>T/O #</string>
  </label>
  <label>
   <rect>
    <x>200</x>
    <y>200</y>
    <width>100</width>
    <height>11</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Transit</string>
  </label>
  <label>
   <rect>
    <x>300</x>
    <y>200</y>
    <width>100</width>
    <height>11</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>To</string>
  </label>
  <label>
   <rect>
    <x>700</x>
    <y>200</y>
    <width>50</width>
    <height>11</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Status</string>
  </label>
  <label>
   <rect>
    <x>600</x>
    <y>200</y>
    <width>100</width>
    <height>11</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Shipped</string>
  </label>
  <label>
   <rect>
    <x>95</x>
    <y>200</y>
    <width>100</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>From</string>
  </label>
  <label>
   <rect>
    <x>400</x>
    <y>200</y>
    <width>100</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Ordered</string>
  </label>
  <label>
   <rect>
    <x>375</x>
    <y>10</y>
    <width>350</width>
    <height>38</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>18</size>
    <weight>bold</weight>
   </font>
   <right/>
   <vcenter/>
   <string>List Transfer Orders</string>
  </label>
  <label>
   <rect>
    <x>500</x>
    <y>200</y>
    <width>100</width>
    <height>11</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Scheduled</string>
  </label>
  <label>
   <rect>
    <x>15</x>
    <y>105</y>
    <width>120</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>From Site:</string>
  </label>
  <line>
   <xstart>5</xstart>
   <ystart>215</ystart>
   <xend>745</xend>
   <yend>215</yend>
   <weight>2</weight>
  </line>
  <field>
   <rect>
    <x>140</x>
    <y>150</y>
    <width>100</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>status</column>
   </data>
  </field>
  <label>
   <rect>
    <x>15</x>
    <y>130</y>
    <width>120</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>To Site:</string>
  </label>
  <field>
   <rect>
    <x>140</x>
    <y>105</y>
    <width>200</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>src_warehous_code</column>
   </data>
  </field>
  <field>
   <rect>
    <x>140</x>
    <y>130</y>
    <width>200</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>dest_warehous_code</column>
   </data>
  </field>
  <label>
   <rect>
    <x>15</x>
    <y>150</y>
    <width>120</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Status:</string>
  </label>
 </rpthead>
 <pghead>
  <firstpage/>
  <height>5</height>
 </pghead>
 <pghead>
  <height>21</height>
  <label>
   <rect>
    <x>600</x>
    <y>0</y>
    <width>100</width>
    <height>11</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Shipped</string>
  </label>
  <label>
   <rect>
    <x>10</x>
    <y>0</y>
    <width>50</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>T/O #</string>
  </label>
  <label>
   <rect>
    <x>300</x>
    <y>0</y>
    <width>100</width>
    <height>11</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>To</string>
  </label>
  <line>
   <xstart>5</xstart>
   <ystart>15</ystart>
   <xend>745</xend>
   <yend>15</yend>
   <weight>2</weight>
  </line>
  <label>
   <rect>
    <x>700</x>
    <y>0</y>
    <width>50</width>
    <height>11</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Status</string>
  </label>
  <label>
   <rect>
    <x>500</x>
    <y>0</y>
    <width>100</width>
    <height>11</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Scheduled</string>
  </label>
  <label>
   <rect>
    <x>95</x>
    <y>0</y>
    <width>100</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>From</string>
  </label>
  <label>
   <rect>
    <x>400</x>
    <y>0</y>
    <width>100</width>
    <height>11</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Ordered</string>
  </label>
  <label>
   <rect>
    <x>200</x>
    <y>0</y>
    <width>100</width>
    <height>11</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Transit</string>
  </label>
 </pghead>
 <section>
  <name>detail</name>
  <detail>
   <key>
    <query>detail</query>
   </key>
   <height>15</height>
   <field>
    <rect>
     <x>5</x>
     <y>0</y>
     <width>85</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>tohead_number</column>
    </data>
   </field>
   <field>
    <rect>
     <x>600</x>
     <y>0</y>
     <width>100</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>f_shipdate</column>
    </data>
   </field>
   <field>
    <rect>
     <x>200</x>
     <y>0</y>
     <width>95</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>tohead_trnsname</column>
    </data>
   </field>
   <field>
    <rect>
     <x>300</x>
     <y>0</y>
     <width>95</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>tohead_destname</column>
    </data>
   </field>
   <field>
    <rect>
     <x>95</x>
     <y>0</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>tohead_srcname</column>
    </data>
   </field>
   <field>
    <rect>
     <x>500</x>
     <y>0</y>
     <width>100</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>f_scheddate</column>
    </data>
   </field>
   <field>
    <rect>
     <x>400</x>
     <y>0</y>
     <width>100</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>f_orderdate</column>
    </data>
   </field>
   <field>
    <rect>
     <x>700</x>
     <y>0</y>
     <width>50</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>status</column>
    </data>
   </field>
  </detail>
 </section>
 <pgfoot>
  <height>15</height>
  <label>
   <rect>
    <x>615</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>Page:</string>
  </label>
  <field>
   <rect>
    <x>705</x>
    <y>0</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>
  <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>90</x>
    <y>0</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>
 </pgfoot>
</report>
