<?
    global $vis_language;
    $paging_list='';
    for($i=0;$i<$page_count;$i++) $paging_list.='<option value="'.$i.'" '.(($page==$i)?'selected="selected"':'').'>'.($i+1).'</option>';
?>
<div id="vis_report_list"><div class="vis_main_window vis_shadow vis_round_corner">
    <div class="vis_main_header"><? echo $report['report_name']; ?> (<? echo $report_info['total']; ?>)</div>
    <div class="vis_main_window_content vis_round_corner">
    <table cellpadding="0" cellspacing="0" width="100%"><tr><td></td><td align="right"><? echo $vis_language['TXTPAGE']; ?>: <select name="pageing" style="width:40px" onchange="$(this).parents('#vis_report_list').visExecution('load_area', {'vis_module':'report', 'vis_operation':'view_report', 'vis_report_id':<? echo $report['report_id']; ?>, 'vis_page':this.value})"><? echo $paging_list; ?></select></td></tr><tr><td colspan="2">
    <div class="vis_seperator_horizontal"></div></td></tr></table><table cellpadding="0" cellspacing="0" width="100%" class="vis_list_table">
    <tr><? for($i=0;$i<count($report_fields);$i++) echo '<th>'.$vis_language['vis_'.$report_fields[$i]['field_name']].'</th>'; ?></tr><?
    for($i=0;$i<count($report_result);$i++) {
        echo '<tr>';
        for($j=0;$j<count($report_fields);$j++) {
            echo '<td>';
            if(isset($report_result[$i]['ticket_id']) && is_numeric($report_result[$i]['ticket_id'])) {
                echo '<a href="#/ticket/ticket_details/'.$report_result[$i]['ticket_hash'].'/'.$report_result[$i]['ticket_id'].'">';
                if($report_fields[$j]['field_name']=='ticket_receive_date' || $report_fields[$j]['field_name']=='ticket_modify_date') echo format_datetime($report_result[$i][$report_fields[$j]['field_name']]);
                elseif($report_fields[$j]['field_name']=='ticket_due_time' || $report_fields[$j]['field_name']=='ticket_resolution_time') {
                    if($report_result[$i]['status_id']==3 || $report_result[$i]['user_replied']==0) echo 'Undue';
                    elseif($report_result[$i][$report_fields[$j]['field_name']]<0) echo 'Overdue';
                    else echo count_remain_time($report_result[$i][$report_fields[$j]['field_name']]);
                }
                else echo $report_result[$i][$report_fields[$j]['field_name']];
                echo '</a>';
            }
            elseif(isset($report_result[$i]['first_name']) || isset($report_result[$i]['email'])) {
                echo '<a href="#/client/client_details/'.$report_result[$i]['first_name'].' '.$report_result[$i]['last_name'].'/'.$report_result[$i]['client_id'].'">'.$report_result[$i][$report_fields[$j]['field_name']].'</a>';
            }
            else echo $report_result[$i][$report_fields[$j]['field_name']];
            echo '</td>';
        }
        echo '</tr>';
    } ?></table>
    </div>
</div>