<!DOCTYPE openRPTDef>
<report>
 <title>Time Phased Production By Planner Code</title>
 <name>TimePhasedProductionByPlannerCode</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,
       &lt;? if exists(&quot;inventoryUnits&quot;) ?>
         text('Qty.')
       &lt;? elseif exists(&quot;capacityUnits&quot;) ?>
         text('Capacity')
       &lt;? elseif exists(&quot;altCapacityUnits&quot;) ?>
         text('Alt. Capacity')
       &lt;? else ?>
         text('ERROR')
       &lt;? endif ?>
       AS lbl_unittype,
       &lt;? if exists(&quot;showInactive&quot;) ?>
         text('Showing Active and Inactive Item Sites')
       &lt;? else ?>
         text('Showing Active Item Sites Only')
       &lt;? endif ?>
       AS lbl_showing ;</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,
       plancode_code,
       &lt;? if exists(&quot;inventoryUnits&quot;) ?>
         uom_name
       &lt;? elseif exists(&quot;capacityUnits&quot;) ?>
         itemcapuom(item_id)
       &lt;? elseif exists(&quot;altCapacityUnits&quot;) ?>
         itemaltcapuom(item_id)
       &lt;? else ?>
         text('')
       &lt;? endif ?>
       AS f_uom,
       warehous_code,
       &lt;? if exists(&quot;inventoryUnits&quot;) ?>
         formatQty(SUM(summProd(itemsite_id, calitem_id)))
       &lt;? elseif exists(&quot;capacityUnits&quot;) ?>
         formatQty(SUM(summProd(itemsite_id, calitem_id) * itemcapinvrat(item_id)))
       &lt;? elseif exists(&quot;altCapacityUnits&quot;) ?>
         formatQty(SUM(summProd(itemsite_id, calitem_id) * itemaltcapinvrat(item_id)))
       &lt;? else ?>
         formatQty(SUM(summProd(itemsite_id, calitem_id)))
       &lt;? endif ?>
       AS f_unit
  FROM itemsite, item, uom, whsinfo, plancode,
       (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)
&lt;? if not exists(&quot;showInactive&quot;) ?>
   AND (itemsite_active)
&lt;? endif ?>
   AND (itemsite_item_id=item_id)
   AND (item_inv_uom_id=uom_id)
   AND (itemsite_plancode_id=plancode_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 (plancode_id=&lt;? value(&quot;plancode_id&quot;) ?>)
&lt;? elseif exists(&quot;plancode_pattern&quot;) ?>
   AND (plancode_code ~ &lt;? value(&quot;plancode_pattern&quot;) ?>)
&lt;? endif ?>
  )
GROUP BY pstart, pend, period, plancode_code, warehous_code, f_uom
ORDER BY pstart, plancode_code, warehous_code, f_uom;</sql>
 </querysource>
 <rpthead>
  <height>221</height>
  <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>
  <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>
  <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>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>
  <field>
   <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/>
   <data>
    <query>head</query>
    <column>lbl_unittype</column>
   </data>
  </field>
  <line>
   <xstart>5</xstart>
   <ystart>215</ystart>
   <xend>745</xend>
   <yend>215</yend>
   <weight>2</weight>
  </line>
  <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>Planner Code</string>
  </label>
  <field>
   <rect>
    <x>360</x>
    <y>80</y>
    <width>380</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>lbl_showing</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>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>
  <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>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 Planner Code</string>
  </label>
 </rpthead>
 <pghead>
  <firstpage/>
  <height>6</height>
 </pghead>
 <pghead>
  <height>21</height>
  <field>
   <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/>
   <data>
    <query>head</query>
    <column>lbl_unittype</column>
   </data>
  </field>
  <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>
  <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>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>Planner Code</string>
  </label>
 </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>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>f_uom</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>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>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>plancode_code</column>
    </data>
   </field>
  </detail>
 </section>
 <pgfoot>
  <height>16</height>
  <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>
  <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>
 </pgfoot>
</report>
