##include templates\rheader.htm##
<TABLE class=report WIDTH="auto" CELLPADDING=1 CELLSPACING=0 BORDER=0 align=center style="border: solid; border-width: 1px; border-color: black;">
{BEGIN grid_row}
<!-------------------------------------  group headers ----------------------------------------->
##foreach @TABLE.arrReportGroupFields as @g##
	{BEGIN ##@g.strGroupField g##_firstnewgroup}
##if @first##
	<tr>
	##foreach Fields as @f filter @f.bReportPage order nReportPageOrder##
	<td class=blackshade>##@f.strLabel h##</td>
	##endfor##
	</tr>
##endif##
	<tr>
	##foreach @TABLE.arrReportGroupFields as @gg##
		##if @gg.nGroupOrder>=@g.nGroupOrder##
		<td class=header_##@gg.nGroupOrder## >
		<font style="font-weight:900">{$##@gg.strGroupField g##_grval}</font>
		##if @gg.nGroupInterval && @TABLE.bReportShowDetails##
		<br>{$##@gg.strGroupField g##_value}
		##endif##
		</td>
	 	##else##
		<td class=group_##@gg.nGroupOrder##>
		##if @gg.nGroupInterval && @TABLE.bReportShowDetails##
		{$##@gg.strGroupField g##_value}
		##else##
		&nbsp;
		##endif##
		</td>
		##endif##
	##endfor##
<!-------------------------------------  data ----------------------------------------->
	##foreach Fields as @f filter @f.bReportPage && @TABLE.arrReportGroupFields[strGroupField==@f.strName].len==0 order nReportPageOrder##
	<td class=data>
	##if @TABLE.bReportShowDetails##
	{$##@f.strName g##_value}</td>
	##else##
	&nbsp;
	##endif##
	##endfor##
	</tr>
	{END ##@g.strGroupField g##_firstnewgroup}
##endfor##
##if @TABLE.bReportShowDetails##
{BEGIN nonewgroup}
	##foreach @TABLE.arrReportGroupFields as @g##
		<td class=group_##@g.nGroupOrder## >
		##if @g.nGroupInterval && @TABLE.bReportShowDetails##
		{$##@g.strGroupField g##_value}
		##else##
		&nbsp;
		##endif##
		</td>
	##endfor##
	##foreach Fields as @f filter @f.bReportPage && @TABLE.arrReportGroupFields[strGroupField==@f.strName].len==0 order nReportPageOrder##
	<td class=data>
	{$##@f.strName g##_value}
	</td>
	##endfor##
	</tr>
{END nonewgroup}
##endif##
<!-------------------------------------  group summary ----------------------------------------->
##foreach @TABLE.arrReportGroupFields as @g order desc##
##if @g.bShowGroupSummary##
{BEGIN ##@g.strGroupField g##_endgroup}
<tr>
	##repeat @TABLE.arrReportGroupFields.len-@index##
	<td class=group_##@index##></td>
	##endrepeat##
	##foreach Fields as @f filter @f.strName=@g.strGroupField##
	<td class=group_##@g.nGroupOrder## colspan=##eval Fields[bReportPage].len-@g.nGroupOrder+1## >
	##message SUMMARY_FOR## ##@f.strLabel h## {$##@g.strGroupField g##_grval}
	 - {$group##@g.strGroupField g##_total_cnt} ##message RECORDS_TOTAL##</div></td>
	##endfor##
</tr>
##if Fields[bReportPage && bSum].len##
<!--  Sum -->
<tr>
	##foreach Fields as @f filter @f.bReportPage order nReportPageOrder##
		##if @g.strGroupField==@f.strName##
	<td class=group_##@g.nGroupOrder## style="border-left: solid black 1px;">##message SUM##</td>
		##elseif @f.bSum##
	<td class=group_##@g.nGroupOrder##>{$group##@g.strGroupField g##_total##@f.strName g##_sum}</td>
		##elseif @index<@g.nGroupOrder##
	<td class=group_##@index##>&nbsp;</td>
		##else##
	<td class=group_##@g.nGroupOrder##>&nbsp;</td>
		##endif##
	##endfor##
</tr>	
##endif##
##if Fields[bReportPage && bAvg].len##
<!--  Avg -->
<tr>
	##foreach Fields as @f filter @f.bReportPage order nReportPageOrder##
		##if @g.strGroupField==@f.strName##
	<td class=group_##@g.nGroupOrder##>##message AVERAGE##</td>
		##elseif @f.bAvg##
	<td class=group_##@g.nGroupOrder##>{$group##@g.strGroupField g##_total##@f.strName g##_avg}</td>
		##elseif @index<@g.nGroupOrder##
	<td class=group_##@index##>&nbsp;</td>
		##else##
	<td class=group_##@g.nGroupOrder##>&nbsp;</td>
		##endif##
	##endfor##
</tr>	
##endif##
##if Fields[bReportPage && bMin].len##
<!--  Min -->
<tr>
	##foreach Fields as @f filter @f.bReportPage order nReportPageOrder##
		##if @g.strGroupField==@f.strName##
	<td class=group_##@g.nGroupOrder##>##message MIN##</td>
		##elseif @f.bMin##
	<td class=group_##@g.nGroupOrder##>{$group##@g.strGroupField g##_total##@f.strName g##_min}</td>
		##elseif @index<@g.nGroupOrder##
	<td class=group_##@index##>&nbsp;</td>
		##else##
	<td class=group_##@g.nGroupOrder##>&nbsp;</td>
		##endif##
	##endfor##
</tr>	
##endif##
##if Fields[bReportPage && bMax].len##
<!--  Max -->
<tr>
	##foreach Fields as @f filter @f.bReportPage order nReportPageOrder##
		##if @g.strGroupField==@f.strName##
	<td class=group_##@g.nGroupOrder##>##message MAX##</td>
		##elseif @f.bMax##
	<td class=group_##@g.nGroupOrder##>{$group##@g.strGroupField g##_total##@f.strName g##_max}</td>
		##elseif @index<@g.nGroupOrder##
	<td class=group_##@index##>&nbsp;</td>
		##else##
	<td class=group_##@g.nGroupOrder##>&nbsp;</td>
		##endif##
	##endfor##
</tr>	
##endif##
{END ##@g.strGroupField g##_endgroup}
##endif##
##endfor##
{END grid_row}
##if @TABLE.bReportPageSummary || @TABLE.bReportGlobalSummary##
<tr>
##foreach Fields as @f filter @f.bReportPage order nReportPageOrder##
<td class=blackshade>##@f.strLabel h##</td>
##endfor##
</tr>
##endif##
##if @TABLE.bReportPageSummary##
<!--------------------------------------page summary-------------------------------------------->
<tr>
	<td class=pagesummary colspan=##Fields[bReportPage].len##>##message PAGE_SUMMARY## 
	 {$page_total_cnt} - ##message RECORDS_TOTAL##</td>
</tr>
##if Fields[bReportPage && bSum].len##
<!--  Sum -->
<tr>
	##foreach Fields as @f filter @f.bReportPage order nReportPageOrder##
		##if @g.strGroupField==@f.strName##
	<td class=pagesummary>##message SUM##</td>
		##elseif @f.bSum##
	<td class=pagesummary>{$page_total##@f.strName g##_sum}</td>
		##else##
	<td class=pagesummary>&nbsp;</td>
		##endif##
	##endfor##
</tr>	
##endif##
##if Fields[bReportPage && bAvg].len##
<!--  Avg -->
<tr>
	##foreach Fields as @f filter @f.bReportPage order nReportPageOrder##
		##if @g.strGroupField==@f.strName##
	<td class=pagesummary>##message AVERAGE##</td>
		##elseif @f.bAvg##
	<td class=pagesummary>{$page_total##@f.strName g##_avg}</td>
		##else##
	<td class=pagesummary>&nbsp;</td>
		##endif##
	##endfor##
</tr>	
##endif##
##if Fields[bReportPage && bMin].len##
<!--  Min -->
<tr>
	##foreach Fields as @f filter @f.bReportPage order nReportPageOrder##
		##if @g.strGroupField==@f.strName##
	<td class=pagesummary>##message MIN##</td>
		##elseif @f.bMin##
	<td class=pagesummary>{$page_total##@f.strName g##_min}</td>
		##else##
	<td class=pagesummary>&nbsp;</td>
		##endif##
	##endfor##
</tr>	
##endif##
##if Fields[bReportPage && bMax].len##
<!--  Max -->
<tr>
	##foreach Fields as @f filter @f.bReportPage order nReportPageOrder##
		##if @g.strGroupField==@f.strName##
	<td class=pagesummary>##message MAX##</td>
		##elseif @f.bMax##
	<td class=pagesummary>{$page_total##@f.strName g##_max}</td>
		##else##
	<td class=pagesummary>&nbsp;</td>
		##endif##
	##endfor##
</tr>	
##endif##
##endif##
##if @TABLE.bReportGlobalSummary##
<!--------------------------------------global summary-------------------------------------------->
<tr>
	<td class=globalsummary colspan=##Fields[bReportPage].len##>##message GLOBAL_SUMMARY## 
	 {$global_total_cnt} - ##message RECORDS_TOTAL##</td>
</tr>
##if Fields[bReportPage && bSum].len##
<!--  Sum -->
<tr>
	##foreach Fields as @f filter @f.bReportPage order nReportPageOrder##
		##if @g.strGroupField==@f.strName##
	<td class=globalsummary>##message SUM##</td>
		##elseif @f.bSum##
	<td class=globalsummary>{$global_total##@f.strName g##_sum}</td>
		##else##
	<td class=globalsummary>&nbsp;</td>
		##endif##
	##endfor##
</tr>	
##endif##
##if Fields[bReportPage && bAvg].len##
<!--  Avg -->
<tr>
	##foreach Fields as @f filter @f.bReportPage order nReportPageOrder##
		##if @g.strGroupField==@f.strName##
	<td class=globalsummary>##message AVERAGE##</td>
		##elseif @f.bAvg##
	<td class=globalsummary>{$global_total##@f.strName g##_avg}</td>
		##else##
	<td class=globalsummary>&nbsp;</td>
		##endif##
	##endfor##
</tr>	
##endif##
##if Fields[bReportPage && bMin].len##
<!--  Min -->
<tr>
	##foreach Fields as @f filter @f.bReportPage order nReportPageOrder##
		##if @g.strGroupField==@f.strName##
	<td class=globalsummary>##message MIN##</td>
		##elseif @f.bMin##
	<td class=globalsummary>{$global_total##@f.strName g##_min}</td>
		##else##
	<td class=globalsummary>&nbsp;</td>
		##endif##
	##endfor##
</tr>	
##endif##
##if Fields[bReportPage && bMax].len##
<!--  Max -->
<tr>
	##foreach Fields as @f filter @f.bReportPage order nReportPageOrder##
		##if @g.strGroupField==@f.strName##
	<td class=globalsummary>##message MAX##</td>
		##elseif @f.bMax##
	<td class=globalsummary>{$global_total##@f.strName g##_max}</td>
		##else##
	<td class=globalsummary>&nbsp;</td>
		##endif##
	##endfor##
</tr>	
##endif##
##endif##
</table>
##include templates\rfooter.htm##