<!DOCTYPE openRPTDef>
<report>
 <title>Work Order History by Item</title>
 <name>WOHistoryByItem</name>
 <description></description>
 <size>Letter</size>
 <portrait/>
 <topmargin>50</topmargin>
 <bottommargin>50</bottommargin>
 <rightmargin>50</rightmargin>
 <leftmargin>50</leftmargin>
 <querysource>
  <name>Detail</name>
  <sql>SELECT formatWONumber(wo_id) AS wonumber,
       wo_status, warehous_code,
       formatQty(wo_qtyord) AS ordered,
       formatQty(wo_qtyrcv) AS received,
       formatDate(wo_startdate) AS startdate,
       formatDate(wo_duedate) AS duedate,
       &lt;? if exists(&quot;showCosts&quot;) ?>
         formatCost(wo_postedvalue)
       &lt;? else ?>
         text('')
       &lt;? endif ?>
       AS value
  FROM wo, itemsite, whsinfo
 WHERE ((wo_itemsite_id=itemsite_id)
   AND (itemsite_warehous_id=warehous_id)
   AND (itemsite_item_id=&lt;? value(&quot;item_id&quot;) ?>)
&lt;? if exists(&quot;showOnlyTopLevel&quot;) ?>
   AND ((wo_ordtype&lt;>'W') OR (wo_ordtype IS NULL))
&lt;? endif ?>
&lt;? if exists(&quot;warehous_id&quot;) ?>
   AND (itemsite_warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)
&lt;? endif ?>
   AND (wo_duedate BETWEEN &lt;? value(&quot;startDate&quot;) ?> AND &lt;? value(&quot;endDate&quot;) ?>) )
ORDER BY wo_startdate DESC, wo_number, wo_subnumber;
    </sql>
 </querysource>
 <querysource>
  <name>head</name>
  <sql>SELECT item_number,
       item_descrip1,
       item_descrip2,
       &lt;? if exists(&quot;warehous_id&quot;) ?>
         (SELECT warehous_code
            FROM whsinfo
           WHERE (warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>))
       &lt;? else ?>
         text('All Sites')
       &lt;? endif ?>
       AS warehouse,
       &lt;? if exists(&quot;showOnlyTopLevel&quot;) ?>
         text('Only Show Top Level Work Orders')
       &lt;? else ?>
         text('')
       &lt;? endif ?>
       AS lbl_toplevel,
       &lt;? if exists(&quot;showCosts&quot;) ?>
         text('Cost')
       &lt;? else ?>
         text('')
       &lt;? endif ?>
       AS lbl_cost,
       formatDate(&lt;? value(&quot;startDate&quot;) ?>, 'Earliest') AS startdate,
       formatDate(&lt;? value(&quot;endDate&quot;) ?>, 'Latest') AS enddate
  FROM item
 WHERE (item_id=&lt;? value(&quot;item_id&quot;) ?>);</sql>
 </querysource>
 <rpthead>
  <height>191</height>
  <label>
   <rect>
    <x>490</x>
    <y>170</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Due Date</string>
  </label>
  <label>
   <rect>
    <x>405</x>
    <y>170</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Start Date</string>
  </label>
  <field>
   <rect>
    <x>135</x>
    <y>85</y>
    <width>300</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>item_descrip1</column>
   </data>
  </field>
  <field>
   <rect>
    <x>550</x>
    <y>85</y>
    <width>150</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>enddate</column>
   </data>
  </field>
  <field>
   <rect>
    <x>445</x>
    <y>105</y>
    <width>250</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>lbl_toplevel</column>
   </data>
  </field>
  <label>
   <rect>
    <x>10</x>
    <y>170</y>
    <width>100</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>W/O Number</string>
  </label>
  <label>
   <rect>
    <x>320</x>
    <y>170</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Received</string>
  </label>
  <label>
   <rect>
    <x>114</x>
    <y>170</y>
    <width>50</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Status</string>
  </label>
  <label>
   <rect>
    <x>30</x>
    <y>125</y>
    <width>100</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Site:</string>
  </label>
  <field>
   <rect>
    <x>550</x>
    <y>65</y>
    <width>150</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>startdate</column>
   </data>
  </field>
  <field>
   <rect>
    <x>135</x>
    <y>105</y>
    <width>300</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>item_descrip2</column>
   </data>
  </field>
  <line>
   <xstart>5</xstart>
   <ystart>185</ystart>
   <xend>740</xend>
   <yend>185</yend>
   <weight>2</weight>
  </line>
  <label>
   <rect>
    <x>170</x>
    <y>170</y>
    <width>50</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Site</string>
  </label>
  <label>
   <rect>
    <x>240</x>
    <y>10</y>
    <width>484</width>
    <height>38</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>18</size>
    <weight>bold</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Work Order History By Item</string>
  </label>
  <label>
   <rect>
    <x>235</x>
    <y>170</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Ordered</string>
  </label>
  <field>
   <rect>
    <x>135</x>
    <y>125</y>
    <width>150</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>warehouse</column>
   </data>
  </field>
  <field>
   <rect>
    <x>135</x>
    <y>65</y>
    <width>305</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>item_number</column>
   </data>
  </field>
  <label>
   <rect>
    <x>445</x>
    <y>85</y>
    <width>100</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>End Date:</string>
  </label>
  <label>
   <rect>
    <x>445</x>
    <y>65</y>
    <width>100</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Start Date:</string>
  </label>
  <field>
   <rect>
    <x>660</x>
    <y>170</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>lbl_cost</column>
   </data>
  </field>
  <label>
   <rect>
    <x>30</x>
    <y>65</y>
    <width>100</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Item Number</string>
  </label>
 </rpthead>
 <pghead>
  <firstpage/>
  <height>6</height>
 </pghead>
 <pghead>
  <height>31</height>
  <label>
   <rect>
    <x>405</x>
    <y>10</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Start Date</string>
  </label>
  <label>
   <rect>
    <x>170</x>
    <y>10</y>
    <width>50</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Site</string>
  </label>
  <label>
   <rect>
    <x>114</x>
    <y>10</y>
    <width>50</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Status</string>
  </label>
  <line>
   <xstart>5</xstart>
   <ystart>25</ystart>
   <xend>740</xend>
   <yend>25</yend>
   <weight>2</weight>
  </line>
  <label>
   <rect>
    <x>320</x>
    <y>10</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Received</string>
  </label>
  <field>
   <rect>
    <x>660</x>
    <y>10</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>lbl_cost</column>
   </data>
  </field>
  <label>
   <rect>
    <x>490</x>
    <y>10</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Due Date</string>
  </label>
  <label>
   <rect>
    <x>10</x>
    <y>10</y>
    <width>100</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>W/O Number</string>
  </label>
  <label>
   <rect>
    <x>235</x>
    <y>10</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Ordered</string>
  </label>
 </pghead>
 <section>
  <name>detail</name>
  <detail>
   <key>
    <query>Detail</query>
   </key>
   <height>16</height>
   <field>
    <rect>
     <x>405</x>
     <y>0</y>
     <width>80</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <hcenter/>
    <vcenter/>
    <data>
     <query>Detail</query>
     <column>startdate</column>
    </data>
   </field>
   <field>
    <rect>
     <x>170</x>
     <y>0</y>
     <width>50</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <hcenter/>
    <vcenter/>
    <data>
     <query>Detail</query>
     <column>warehous_code</column>
    </data>
   </field>
   <field>
    <rect>
     <x>490</x>
     <y>0</y>
     <width>80</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <hcenter/>
    <vcenter/>
    <data>
     <query>Detail</query>
     <column>duedate</column>
    </data>
   </field>
   <field>
    <rect>
     <x>10</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>wonumber</column>
    </data>
   </field>
   <field>
    <rect>
     <x>114</x>
     <y>0</y>
     <width>50</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <hcenter/>
    <vcenter/>
    <data>
     <query>Detail</query>
     <column>wo_status</column>
    </data>
   </field>
   <field>
    <rect>
     <x>235</x>
     <y>0</y>
     <width>80</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <right/>
    <vcenter/>
    <data>
     <query>Detail</query>
     <column>ordered</column>
    </data>
   </field>
   <field>
    <rect>
     <x>320</x>
     <y>0</y>
     <width>80</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <right/>
    <vcenter/>
    <data>
     <query>Detail</query>
     <column>received</column>
    </data>
   </field>
   <field>
    <rect>
     <x>660</x>
     <y>0</y>
     <width>80</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <right/>
    <vcenter/>
    <data>
     <query>Detail</query>
     <column>value</column>
    </data>
   </field>
  </detail>
 </section>
 <pgfoot>
  <height>16</height>
  <field>
   <rect>
    <x>95</x>
    <y>0</y>
    <width>114</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>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>5</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>
 </pgfoot>
</report>
