{strip}
{*}------------------------------------- CALC TOTALS -------------------------------------{*}
{$sums_staff=array()}{$sums_projects=array()}
{foreach item=total from=$totals}
    {assign var="totalproject" value="total`$total->project_id`"}
    {if !isset($sums_projects.$totalproject)}{$sums_projects.$totalproject=0}{/if}
    {foreach item=staff from=$staff_list}
        {assign var="totalstaff" value="total`$staff->id`"}
        {if !isset($sums_staff.$totalstaff)}{$sums_staff.$totalstaff=0}{/if}
        {if isset($total->$totalstaff)}
            {$sums_staff.$totalstaff=$sums_staff.$totalstaff+$total->$totalstaff}
            {$sums_projects.$totalproject=$sums_projects.$totalproject+$total->$totalstaff}
        {/if}
    {/foreach}
{/foreach}
{/strip}
{strip}
    "{$i.reporting_rep_project|forcsv}"{chr(9)}
    {foreach item=staff from=$staff_list}
        {assign var="totalstaff" value="total`$staff->id`"}
        {if isset($sums_staff.$totalstaff) && !empty($sums_staff.$totalstaff)}{*}-- Hide empty staff --{*}
            "{$staff->staff_name|forcsv}"{chr(9)}
        {/if}
    {/foreach}
{/strip}
{foreach item=total from=$totals}{strip}
    {assign var="totalproject" value="total`$total->project_id`"}
    {if isset($sums_projects.$totalproject) && !empty($sums_projects.$totalproject)}{*}-- Hide empty projects --{*}
        {"\n"}
        "{$total->project}"{chr(9)}
        {foreach item=staff from=$staff_list}
            {assign var="totalstaff" value="total`$staff->id`"}
            {if isset($sums_staff.$totalstaff) && !empty($sums_staff.$totalstaff)}{*}-- Hide empty staff --{*}
                {if isset($total->$totalstaff) && !empty($total->$totalstaff)}{*}-- Hide empty staff --{*}
                    {isfloat value=$total->$totalstaff maxf=2 no_tsd=true}{chr(9)}
                {else}
                    " "{chr(9)}
                {/if}
            {/if}
        {/foreach}
    {/if}
{/strip}{/foreach}