{extends file=$smarty.const.SMARTY_LAYOUT_CONTENT_LIST_TABLE_CURRENT_DATA}

{block name="listing-tr-class"}
    {if $smarty.const.CURRENT_ID_USER == $rowFields['idUser'] and !$rowFields['viewed']}
        default
    {/if}
{/block}

{block name="listing-td-content-name"}
    <div>
        {$rowFields['name']} #{$rowFields['idReport']}
    </div>
    <div class="grey">
        ({$rowFields['categoryName']})
    </div>
{/block}

{block name="listing-td-content-source"}
    <div style="float:right" class="grey">{$_LANG['reportsManagement']['reports']['trigger'][$rowFields['execTrigger']]}</div>
    <div>{$_LANG['reports']['source']['name'][$rowFields['source']]}</div>
{/block}

{block name="listing-td-content-startTime"}
    {if $rowFields['status']=='pending'}
        {$lang['index']['list']['startTime']}: {$rowFields['setToStartTime']|dateTimeFormat:'dateWithHMS'}
    {/if}

    {if in_array($rowFields['status'], ['finished', 'stopping', 'stopped', 'error'])}
        <div>
            {$lang['index']['list']['startedTime']}: {$rowFields['startTime']|dateTimeFormat:'dateWithHMS'}
        </div>
        {if $rowFields['endTime']}
            <div>
                {$lang['index']['list']['endedTime']}: {$rowFields['endTime']|dateTimeFormat:'dateWithHMS'}
                <span class="times">({$lang['index']['list']['duration']}: {$rowFields['durationReadable']})</span>
            </div>
        {/if}
    {/if}

    {if in_array($rowFields['status'], ['generating', 'pausing', 'paused'])}
        <div>
            {$lang['index']['list']['startedTime']}: {$rowFields['startTime']|dateTimeFormat:'dateWithHMS'}
            <span class="times">({$lang['index']['list']['duration']}: {$rowFields['startTimeElapsed']})</span>
        </div>
    {/if}

{/block}

{block name="listing-td-content-status"}
    {if in_array($rowFields['status'], ['generating', 'pausing', 'paused'])}
        <div class="grey" style="float:right">{$lang['index']['list']['pid']}: {$rowFields['pid']}</div>
    {/if}
    <div class="status_{$rowFields['status']}"
         {if $rowFields['status']=='stopping'}
             tooltip="{$lang['index']['list']['reportStoppingTooltip']}"
         {/if}
        {if $rowFields['status']=='pausing'}
            tooltip="{$lang['index']['list']['reportPausingTooltip']}"
        {/if}
    >{$_LANG['Reports']['statusName'][$rowFields['status']]}</div>
    {if $rowFields['status']=='generating'}
        {if $smarty.const.TIMESTAMP-$rowFields['lastTouch']<1}
            <div class="lastTouchNormal">{$lang['index']['list']['lastRefreshNow']}</div>
        {elseif $smarty.const.TIMESTAMP-$rowFields['lastTouch']>=1200} {* no refresh for more than 20 minutes *}
            <div class="lastTouchProblem" tooltip="{$lang['index']['list']['reportKilledTooltip']}">{$lang['index']['list']['lastRefresh']|sprintf:$rowFields['lastTouchElapsed']}</div>
        {else}
            <div class="lastTouchNormal">{$lang['index']['list']['lastRefresh']|sprintf:$rowFields['lastTouchElapsed']}</div>
        {/if}
    {/if}
{/block}

{block name="listing-td-content-progress"}
    {if in_array($rowFields['status'], ['generating', 'pausing', 'paused'])}
        <div>
            {$rowFields['phaseName']}
        </div>
        <div class="grey">
            {$rowFields['stepName']} @{$rowFields['stepPercent']}%
        </div>
    {/if} {* TODO: si progress bar - phasePercent *}
    {if $rowFields['status']=='error'}
        <div class="errorMessage">{$rowFields['errorMessage']|truncate:170}</div>
    {/if}
{/block}

{block name="listing-td-content-id"}
    <div>
        {$rowFields['addTime']|dateTimeFormat:'dateWithHMS'}
    </div>
    <div class="grey">
        #{$rowFields['id']}
    </div>

{/block}
