<!DOCTYPE openRPTDef>
<report>
 <title>Time Phased Production By Item</title>
 <name>TimePhasedProductionByItem</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(&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;plancode_id&quot;) ?>
         ( SELECT (plancode_code||'-'||plancode_name)
             FROM plancode
            WHERE plancode_id=&lt;? value(&quot;plancode_id&quot;) ?>)
       &lt;? elseif exists(&quot;plancode_pattern&quot;) ?>
         text(&lt;? value(&quot;plancode_pattern&quot;) ?>)
       &lt;? else ?>
         text('All Planner Codes')
       &lt;? endif ?>
       AS plancode ;</sql>
 </querysource>
 <querysource>
  <name>detail</name>
  <sql>SELECT findPeriodStart(calitem_id) AS pstart,
       findPeriodEnd(calitem_id) AS pend,
       (formatDate(findPeriodStart(calitem_id)) || '-' || formatDate(findPeriodEnd(calitem_id))) AS period,
       item_number,
       uom_name,
       warehous_code,
       formatQty(SUM(summProd(itemsite_id, calitem_id))) AS f_unit
  FROM itemsite, item, uom, whsinfo,
       (SELECT rcalitem_id AS calitem_id
          FROM rcalitem
         WHERE (rcalitem_id in (
&lt;? foreach(&quot;period_id_list&quot;) ?>
  &lt;? if not isfirst(&quot;period_id_list&quot;) ?>
    ,
  &lt;? endif ?>
  &lt;? value(&quot;period_id_list&quot;) ?>
&lt;? endforeach ?>
                               ))
         UNION
        SELECT acalitem_id as calitem_id
          FROM acalitem
         WHERE (acalitem_id in (
&lt;? foreach(&quot;period_id_list&quot;) ?>
  &lt;? if not isfirst(&quot;period_id_list&quot;) ?>
    ,
  &lt;? endif ?>
  &lt;? value(&quot;period_id_list&quot;) ?>
&lt;? endforeach ?>
                               ))
        ) AS calitem
 WHERE ((itemsite_warehous_id=warehous_id)
   AND (itemsite_item_id=item_id)
   AND (item_inv_uom_id=uom_id)
&lt;? if exists(&quot;warehous_id&quot;) ?>
   AND (itemsite_warehous_id=&lt;? value(&quot;warehous_id&quot;) ?>)
&lt;? endif ?>
&lt;? if exists(&quot;plancode_id&quot;) ?>
   AND (itemsite_plancode_id=&lt;? value(&quot;plancode_id&quot;) ?>)
&lt;? elseif exists(&quot;plancode_pattern&quot;) ?>
   AND (itemsite_plancode_id IN (SELECT plancode_id FROM plancode WHERE (plancode_code ~ &lt;? value(&quot;plancode_pattern&quot;) ?>)))
&lt;? endif ?>
  )
GROUP BY pstart, pend, period, item_number, warehous_code, uom_name
ORDER BY pstart, item_number, warehous_code;</sql>
 </querysource>
 <rpthead>
  <height>221</height>
  <field>
   <rect>
    <x>140</x>
    <y>80</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>plancode</column>
   </data>
  </field>
  <label>
   <rect>
    <x>615</x>
    <y>200</y>
    <width>35</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>145</x>
    <y>10</y>
    <width>580</width>
    <height>38</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>18</size>
    <weight>bold</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Time Phased Production By Item</string>
  </label>
  <line>
   <xstart>5</xstart>
   <ystart>215</ystart>
   <xend>745</xend>
   <yend>215</yend>
   <weight>2</weight>
  </line>
  <label>
   <rect>
    <x>10</x>
    <y>200</y>
    <width>250</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Period</string>
  </label>
  <label>
   <rect>
    <x>320</x>
    <y>200</y>
    <width>120</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Item Number</string>
  </label>
  <label>
   <rect>
    <x>15</x>
    <y>80</y>
    <width>120</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Planner Code:</string>
  </label>
  <label>
   <rect>
    <x>30</x>
    <y>105</y>
    <width>105</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>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>warehouse</column>
   </data>
  </field>
  <label>
   <rect>
    <x>660</x>
    <y>200</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Qty.</string>
  </label>
  <label>
   <rect>
    <x>530</x>
    <y>200</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>UOM</string>
  </label>
 </rpthead>
 <pghead>
  <firstpage/>
  <height>6</height>
 </pghead>
 <pghead>
  <height>21</height>
  <label>
   <rect>
    <x>10</x>
    <y>0</y>
    <width>250</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Period</string>
  </label>
  <label>
   <rect>
    <x>320</x>
    <y>0</y>
    <width>114</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Item Number</string>
  </label>
  <label>
   <rect>
    <x>530</x>
    <y>0</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>UOM</string>
  </label>
  <label>
   <rect>
    <x>660</x>
    <y>0</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Qty.</string>
  </label>
  <label>
   <rect>
    <x>615</x>
    <y>0</y>
    <width>35</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Site</string>
  </label>
  <line>
   <xstart>5</xstart>
   <ystart>15</ystart>
   <xend>745</xend>
   <yend>15</yend>
   <weight>2</weight>
  </line>
 </pghead>
 <section>
  <name>detail</name>
  <group>
   <name>detail</name>
   <column>pstart</column>
   <head>
    <height>6</height>
    <field>
     <rect>
      <x>10</x>
      <y>5</y>
      <width>250</width>
      <height>15</height>
     </rect>
     <font>
      <face>Arial</face>
      <size>8</size>
      <weight>bold</weight>
     </font>
     <hcenter/>
     <vcenter/>
     <data>
      <query>detail</query>
      <column>period</column>
     </data>
    </field>
   </head>
  </group>
  <detail>
   <key>
    <query>detail</query>
   </key>
   <height>16</height>
   <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>f_unit</column>
    </data>
   </field>
   <field>
    <rect>
     <x>615</x>
     <y>0</y>
     <width>35</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>320</x>
     <y>0</y>
     <width>200</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>item_number</column>
    </data>
   </field>
   <field>
    <rect>
     <x>530</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>uom_name</column>
    </data>
   </field>
  </detail>
 </section>
 <pgfoot>
  <height>16</height>
  <field>
   <rect>
    <x>690</x>
    <y>0</y>
    <width>51</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>
  <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>Context Query</query>
    <column>report_date</column>
   </data>
  </field>
  <label>
   <rect>
    <x>600</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>
  <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>
