<report>
<title>General Sales Report</title>
	<level>
		<title>Yearly Overview</title>
		<sql>SELECT A.account_id as account, from_unixtime(date_orig,"%Y") as yearmonth, count(id) as sales, sum(total_amt) as amount from %%AGILE_DB_PREFIX%%invoice A</sql>
		<criteria>A.site_id = %%DEFAULT_SITE%% AND billing_status=1</criteria>
		<orderby>GROUP BY yearmonth ORDER BY yearmonth ASC</orderby>
		<indent>0</indent>
		<column>
			<display>Year:</display>
			<field>yearmonth</field>
			<aggregate>true</aggregate>
			<visible>true</visible> 
		</column>
		<column>
			<display>Sales</display>
			<field>sales</field>
			<total>true</total>
		</column>
		<column>
			<display>Revenue</display>
			<field>amount</field>
			<total>true</total>
			<format>dol,2</format>
			<total_format>dol,2</total_format>
		</column> 
	</level>
	<break />
	<graph type="bar" title="" width="600" height="300" x_angle="0" direction="horizontal">
		<dataset>
			<sql>SELECT from_unixtime(date_orig,"%Y") as yearmonth, sum(total_amt) as amount from %%AGILE_DB_PREFIX%%invoice A</sql>
			<criteria>A.site_id = %%DEFAULT_SITE%%</criteria>
			<orderby>GROUP BY yearmonth ORDER BY yearmonth ASC</orderby>
		</dataset>
	</graph>	

	
	<break />
	
	
	<level>
		<title>Monthly Overview</title>
		<sql>SELECT A.account_id as account, from_unixtime(date_orig,"%M, %Y") as yearmonth, count(id) as sales, sum(total_amt) as amount from %%AGILE_DB_PREFIX%%invoice A</sql>
		<criteria>A.site_id = %%DEFAULT_SITE%% AND billing_status=1</criteria>
		<orderby>GROUP BY yearmonth ORDER BY yearmonth ASC</orderby>
		<indent>0</indent>
		<column>
			<display>Month and Year:</display>
			<field>yearmonth</field>
			<aggregate>true</aggregate>
			<visible>true</visible> 
		</column>
		<column>
			<display>Sales</display>
			<field>sales</field>
			<total>true</total>
		</column>
		<column>
			<display>Revenue</display>
			<field>amount</field>
			<total>true</total>
			<format>dol,2</format>
			<total_format>dol,2</total_format>
		</column> 
	</level> 
	<break /> 
	<graph type="bar" title="" width="600" height="300" x_angle="0" direction="vertical">
		<dataset>
			<sql>SELECT from_unixtime(date_orig,"%M, %Y") as yearmonth, sum(total_amt) as amount from %%AGILE_DB_PREFIX%%invoice A</sql>
			<criteria>A.site_id = %%DEFAULT_SITE%%</criteria>
			<orderby>GROUP BY yearmonth ORDER BY yearmonth ASC</orderby>
		</dataset>
	</graph>	

	
	<break />

	
	<level>
		<title>Weekly Overview</title>
		<sql>SELECT A.account_id as account, from_unixtime(date_orig,"%Y-%u") as yearmonth, count(id) as sales, sum(total_amt) as amount from %%AGILE_DB_PREFIX%%invoice A</sql>
		<criteria>A.site_id = %%DEFAULT_SITE%% AND billing_status=1</criteria>
		<orderby>GROUP BY yearmonth ORDER BY yearmonth ASC</orderby>
		<indent>0</indent>
		<column>
			<display>Year and Week Number:</display>
			<field>yearmonth</field>
			<aggregate>true</aggregate>
			<visible>true</visible> 
		</column>
		<column>
			<display>Sales</display>
			<field>sales</field>
			<total>true</total>
		</column>
		<column>
			<display>Revenue</display>
			<field>amount</field>
			<total>true</total>
			<format>dol,2</format>
			<total_format>dol,2</total_format>
		</column> 
	</level> 
	<break /> 
	<graph type="line" title="" width="800" height="300" x_angle="0" direction="vertical">
		<dataset>
			<sql>SELECT from_unixtime(date_orig,"%Y-%u") as yearmonth, sum(total_amt) as amount from %%AGILE_DB_PREFIX%%invoice A</sql>
			<criteria>A.site_id = %%DEFAULT_SITE%%</criteria>
			<orderby>GROUP BY yearmonth ORDER BY yearmonth ASC</orderby>
		</dataset>
	</graph>	

	<break />	
	
	
	<level>
		<title>Daily Overview</title>
		<sql>SELECT A.account_id as account, from_unixtime(date_orig,"%m-%d-%Y") as yearmonth, count(id) as sales, sum(total_amt) as amount from %%AGILE_DB_PREFIX%%invoice A</sql>
		<criteria>A.site_id = %%DEFAULT_SITE%% AND billing_status=1</criteria>
		<orderby>GROUP BY yearmonth ORDER BY yearmonth ASC</orderby>
		<indent>0</indent>
		<column>
			<display>Month, Day, and Year:</display>
			<field>yearmonth</field>
			<aggregate>true</aggregate>
			<visible>true</visible> 
		</column>
		<column>
			<display>Sales</display>
			<field>sales</field>
			<total>true</total>
		</column>
		<column>
			<display>Revenue</display>
			<field>amount</field>
			<total>true</total>
			<format>dol,2</format>
			<total_format>dol,2</total_format>
		</column> 
	</level> 
	<break /> 
	<graph type="line" title="" width="800" height="300" x_angle="0" direction="vertical">
		<dataset>
			<sql>SELECT from_unixtime(date_orig,"%m-%d-%Y") as yearmonth, sum(total_amt) as amount from %%AGILE_DB_PREFIX%%invoice A</sql>
			<criteria>A.site_id = %%DEFAULT_SITE%%</criteria>
			<orderby>GROUP BY yearmonth ORDER BY yearmonth ASC</orderby>
		</dataset>
	</graph>	

	<break />	

	
	<level>
		<title>Hourly Overview</title>
		<sql>SELECT A.account_id as account, from_unixtime(date_orig,"%k") as yearmonth, count(id) as sales, sum(total_amt) as amount from %%AGILE_DB_PREFIX%%invoice A</sql>
		<criteria>A.site_id = %%DEFAULT_SITE%% AND billing_status=1</criteria>
		<orderby>GROUP BY yearmonth ORDER BY yearmonth ASC</orderby>
		<indent>0</indent>
		<column>
			<display>Hour of Day:</display>
			<field>yearmonth</field>
			<aggregate>true</aggregate>
			<visible>true</visible> 
		</column>
		<column>
			<display>Sales</display>
			<field>sales</field>
			<total>true</total>
		</column>
		<column>
			<display>Revenue</display>
			<field>amount</field>
			<total>true</total>
			<format>dol,2</format>
			<total_format>dol,2</total_format>
		</column> 
	</level> 
	<break /> 
	<graph type="line" title="" width="800" height="300" x_angle="0" direction="vertical">
		<dataset>
			<sql>SELECT from_unixtime(date_orig,"%k") as yearmonth, sum(total_amt) as amount from %%AGILE_DB_PREFIX%%invoice A</sql>
			<criteria>A.site_id = %%DEFAULT_SITE%%</criteria>
			<orderby>GROUP BY yearmonth ORDER BY yearmonth ASC</orderby>
		</dataset>
	</graph>	
 	
</report>