<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE report PUBLIC "-//JFreeReport//DTD report definition//EN//simple/version 0.8.5"
                        "http://jfreereport.sourceforge.net/report-085.dtd">

<report bottommargin="36" leftmargin="36" name="Sales Report" pageformat="LETTER" rightmargin="36" topmargin="36" orientation="portrait">

<parser-config>
    <property name="Group_by">TERRITORY</property>
    <property name="Amount">SOLD_PRICE</property>
    <property name="steel-wheels-location">/ViewAction?solution=samples&amp;path=steel-wheels/reports&amp;</property>      
</parser-config>
 
<configuration>
      <property name="org.jfree.report.modules.output.pageable.pdf.Encoding">iso-8859-15</property>
</configuration>

<reportheader fontname="SanSerif">
</reportheader>
<reportfooter>
     <drawable-field x="0" y="9" width="100%" keepAspectRatio="true" scale="true" height="500" fieldname="PieChart"/>
</reportfooter>

 <pageheader fontname="SanSerif" fontsize="8" fontstyle="plain">
    <band x="0" y="0"> 
    <line color="#5C7485" weight="2" width="100%" x1="0%" x2="100%" y1="0" y2="0"/>
    <line color="#5C7485" weight=".5" width="100%" x1="0%" x2="100%" y1="3" y2="3"/>
    <band x="0" y="9">
    <message-field vertical-alignment="middle" alignment="right" height="14" width="50%" x="50%" y="0">Steel Wheels, Inc.</message-field>
	<message-field vertical-alignment="middle" alignment="right" height="14" width="50%" x="50%" y="14">Summary of Sales by Territory</message-field>
    <message-field vertical-alignment="middle" alignment="right" height="14" width="50%" x="50%" y="28">From $(time_start) through $(time_stop)</message-field>
    </band>
    <!-- message-field vertical-alignment="middle" alignment="left" height="10" width="33%" x="0%" y="16">$(username)</message-field -->
    <imageref src="${serverBaseURL}/sw-style/active/sw_logo.jpg" width="50%" height="40" keepAspectRatio="true" scale="true" x="0%" y="14"/>
    <line color="white" weight=".5" x1="0%" x2="100%" y1="56" y2="56"/>
    <line color="#5C7485" weight=".5" x1="0%" x2="100%" y1="57" y2="57"/>
    <line color="#5C7485" weight="2" width="100%" x1="0%" x2="100%" y1="60" y2="60"/>
    <rectangle color="white" fill="false" height="9" width="100%" x="0" y="61"/>
    </band>
    <!--  
		<imageref src="${serverBaseURL}/pentaho/images/sw_text_rgb.jpg" width="40%" height="25" keepAspectRatio="true" scale="true" alignment="center" x="30%" />
		<label height="12" width="100%" y="30" color="#C90404" alignment="center">Customer Sales Summary</label>
		<label height="12" width="100%" y="45" color="#C90404" alignment="center">Year to Date 2005</label>
    -->     
 </pageheader>
 <pagefooter fontname="SanSerif">
	<message-field alignment="center" fontname="Arial" fontsize="8" height="10" width="20%" x="40%">$(PageofPages)</message-field>
    <message-field height="10" width="40%" alignment="left" fontname="Arial" fontsize="8">Confidential Material</message-field>
    <label alignment="right" height="10" href="http://www.pentaho.org" width="50%" x="50%" y="15">Pentaho Sample Report</label>   
    <message-field height="10" width="50%" y="15">Report Run: $(report.date)</message-field>
    
 </pagefooter>
 <groups>
   <group name="dummy group">
    <groupheader fontname="SanSerif">
    <band x="0" y="0">
		<rectangle color="#5C7485" draw="false" fill="true" height="15" width="100%" x="0" y="0"/>
   	  	<message-field height="15" width="79%" x="1%" color="white" alignment="left" y="0" vertical-alignment="middle" nullstring="">$(territory_name) - $(productline_name) - $(employee_name) - $(product_name)</message-field>
		<label height="15" width="15%" x="80%" y="0" color="white" alignment="right" vertical-alignment="middle">Sales ($)</label>
   		<label height="15" width="5%" x="95%" alignment="left" vertical-alignment="middle" ></label>
    </band>
    </groupheader>  
      
      <groupfooter pagebreak-after-print="false">
 		<line x2="95%" x1="80%" y2="6" y1="6" weight=".75" width="15%" color="black" height="1"/>
		<rectangle color="#FFC607" draw="false" fill="true" height="15" width="100%" x="0" y="7"/>
 		<message-field vertical-alignment="middle" fontname="Arial" fontsize="10" fontstyle="bold" height="15" width="50%" x="5%" y="7">Total </message-field>
        <label color="#5C7485" fontsize="7" height="15" width="15%" x="25%" alignment="center" vertical-alignment="middle" y="7"></label>
        <label color="#5C7485" fontsize="7" height="15" width="15%" x="40%" alignment="center" vertical-alignment="middle" y="7"></label>
        <label color="#5C7485" fontsize="7" height="15" width="15%" x="55%" alignment="center" vertical-alignment="middle" y="7"></label>
        <label height="15" width="5%" x="70%" alignment="left" vertical-alignment="middle" y="7"></label>
 		<number-field vertical-alignment="middle" height="15" width="15%" fieldname="totalsales" format="$ #,###" fontsize="10" fontname="Arial" fontstyle="bold" x="80%" y="7" alignment="right" />
   		<label height="15" width="5%" x="95%" alignment="left" vertical-alignment="middle" y="7"></label>
 		<line x2="95%" x1="80%" y2="23" y1="23" weight=".5" color="black"/>
		<line x2="95%" x1="80%" y2="25" y1="25" weight=".5" color="black"/>
      </groupfooter>
    </group>
 </groups>
 <items fontname="SanSerif" fontsize="9" fontstyle="plain" layout-cachable="false" visible="true">
            <rectangle name="background" x="5%" y="0" width="95%" height="15" color="#DFDFDF"/>
    	  	<string-field height="15" width="20%" fieldname="${Group_by}" x="5%" alignment="left" vertical-alignment="middle"></string-field>
            <label name="ProductLineLink" color="#5C7485" fontsize="7" height="15" width="10%" x="25%" alignment="center" vertical-alignment="middle" >>>Product Lines</label>
            <label name="ProductLink" color="#5C7485" fontsize="7" height="15" width="10%" x="35%" alignment="center" vertical-alignment="middle" >>>Products</label>
            <label name="EmployeeLink" color="#5C7485" fontsize="7" height="15" width="10%" x="45%" alignment="center" vertical-alignment="middle" >>>Sales Reps</label>
            <label name="CustomerLink" color="#5C7485" fontsize="7" height="15" width="10%" x="55%" alignment="center" vertical-alignment="middle" >>>Customers</label>            
            <label height="15" width="15%" x="65%" alignment="left" vertical-alignment="middle" ></label>
      		<number-field height="15" width="15%" fieldname="${Amount}" x="80%" alignment="right" format="#,###" vertical-alignment="middle"></number-field>
      		<label height="15" width="5%" x="95%" alignment="left" vertical-alignment="middle" ></label>
 </items>
   <functions>
     <function name="backgroundTrigger" class="org.jfree.report.function.ElementVisibilitySwitchFunction">
       <properties>
         <property name="element">background</property>
         <property name="numberOfElements">1</property>
       </properties>
     </function>
    <property-ref name="report.date"/>
    <property-ref name="territory_name"/>
    <property-ref name="employee_name"/>
    <property-ref name="product_name"/>
    <property-ref name="productline_name"/>
    <property-ref name="territory"/>
    <property-ref name="employee"/>
    <property-ref name="product"/>
    <property-ref name="productline"/>
    <property-ref name="time_start"/>
    <property-ref name="time_stop"/>
    <property-ref name="output-type"/>
    <function class="org.jfree.report.function.PageOfPagesFunction" name="PageofPages"/>
    <expression class="org.jfree.report.function.TextFormatExpression" name="DrilltoProductLines">
      <properties>
        <property name="pattern">${pentahoBaseURL}${steel-wheels-location}action=Sales_by_Productline.xaction&amp;territory={0}&amp;productline={1}&amp;time_start={2}&amp;time_stop={3}&amp;type={4}</property>
        <property name="field[0]">${Group_by}</property>
        <property name="field[1]">productline</property>
        <property name="field[2]">time_start</property>
        <property name="field[3]">time_stop</property>
        <property name="field[4]">output-type</property>
        <property name="urlEncodeValues">true</property>
      </properties>
    </expression>
    <function class="org.jfree.report.function.CreateHyperLinksFunction" name="AddProductLineHRef">
      <properties>
        <property name="field">DrilltoProductLines</property>
        <property name="element">ProductLineLink</property>
      </properties>
    </function>
    <expression class="org.jfree.report.function.TextFormatExpression" name="DrilltoProduct">
      <properties>
        <property name="pattern">${pentahoBaseURL}${steel-wheels-location}action=Sales_by_Product.xaction&amp;territory={0}&amp;productline={1}&amp;time_start={2}&amp;time_stop={3}&amp;type={4}</property>
        <property name="field[0]">${Group_by}</property>
        <property name="field[1]">productline</property>
        <property name="field[2]">time_start</property>
        <property name="field[3]">time_stop</property>
        <property name="field[4]">output-type</property>
        <property name="urlEncodeValues">true</property>
      </properties>
    </expression>
    <function class="org.jfree.report.function.CreateHyperLinksFunction" name="AddProductHRef">
      <properties>
        <property name="field">DrilltoProduct</property>
        <property name="element">ProductLink</property>
      </properties>
    </function>
        <expression class="org.jfree.report.function.TextFormatExpression" name="DrilltoEmployee">
      <properties>
        <property name="pattern">${pentahoBaseURL}${steel-wheels-location}action=Sales_by_Employee.xaction&amp;territory={0}&amp;productline={1}&amp;time_start={2}&amp;time_stop={3}&amp;type={4}</property>
        <property name="field[0]">${Group_by}</property>
        <property name="field[1]">productline</property>
        <property name="field[2]">time_start</property>
        <property name="field[3]">time_stop</property>
        <property name="field[4]">output-type</property>
        <property name="urlEncodeValues">true</property>
      </properties>
    </expression>
    <function class="org.jfree.report.function.CreateHyperLinksFunction" name="AddEmployeeHRef">
      <properties>
        <property name="field">DrilltoEmployee</property>
        <property name="element">EmployeeLink</property>
      </properties>
    </function>
    <expression class="org.jfree.report.function.TextFormatExpression" name="DrilltoCustomers">
      <properties>
        <property name="pattern">${pentahoBaseURL}${steel-wheels-location}action=Sales_by_Customer.xaction&amp;territory={0}&amp;productline={1}&amp;time_start={2}&amp;time_stop={3}&amp;type={4}</property>
        <property name="field[0]">${Group_by}</property>
        <property name="field[1]">productline</property>
        <property name="field[2]">time_start</property>
        <property name="field[3]">time_stop</property>
        <property name="field[4]">output-type</property>
        <property name="urlEncodeValues">true</property>
      </properties>
    </expression>
    <function class="org.jfree.report.function.CreateHyperLinksFunction" name="AddCustomerHRef">
      <properties>
        <property name="field">DrilltoCustomers</property>
        <property name="element">CustomerLink</property>
      </properties>
    </function>
    <function name="totalsales" class="org.jfree.report.function.TotalGroupSumFunction">
    	<properties>
    		<property name="field">${Amount}</property>
    	</properties>
    </function>
       <!-- This makes sure, that we can access the parameter as if it was a column from the table -->
    <property-ref name="${Group_by}"/>
    <property-ref name="${Amount}"/>
    <property-ref name="productline"/>
    <expression class="org.pentaho.plugin.jfreereport.reportcharts.PieSetCollectorFunction" name="chartDataSource">
      <properties>
        <property name="seriesColumn">${Group_by}</property>
        <property name="valueColumn">${Amount}</property>
        <property name="summaryOnly">false</property>       
      </properties>
      </expression>      
     <expression class="org.pentaho.plugin.jfreereport.reportcharts.PieChartExpression" name="PieChart">
      <properties>
        <property name="title">Sales by ${Group_by}</property>
        <property name="titleFont">Arial-BOLD-14</property>
        <property name="labelFont">Arial--16</property>
        <property name="legendFont">Arial--16</property>
        <property name="backgroundColor">#C8D0D5</property>
        <property name="showBorder">false</property>
        <property name="dataSource">chartDataSource</property>
        <property name="legendLocation">BOTTOM</property>
		<property name="showLegend">true</property>
		<property name="chartWidth">1000</property>
		<property name="chartHeight">600</property>
		<property name="useDrawable">true</property>
		<property name="ignoreNulls">true</property>
		<property name="ignoreZeros">true</property>
		<property name="pieLabelFormat">{0} {2}</property>
		<property name="pieLegendLabelFormat">{0} [$ {1}]</property>
		<property name="explodeSegment">maxValue</property>
		<property name="explodePct">.20</property>	
      </properties>
    </expression>
  </functions>
</report>