<script type="text/javascript" src="<?= VIS_PATH_SCRIPT; ?>datatables/data-tables/DT_bootstrap.js"></script>
<? 
    global $vis_language;
    $html='';    
    if($report!=-1) { ?>
	
<table cellpadding="0" cellspacing="0" border="0" class="table table-hover b-t b-light m-b-none" id="datatable">
		<thead class="table_head">
		<tr>
		    <th><? echo $vis_language['TXTTICKETHASH']; ?></th>
			<th><? echo $vis_language['TXTSUBJECT']; ?></th>
			<th><? echo $vis_language['TXTCLIENTNAME']; ?></th>	
			<th><? echo $vis_language['TXTEMAIL']; ?></th>
			<th><? echo $vis_language['TXTORGN']; ?></th>
			<th><? echo $vis_language['TXTCREATEDON']; ?></th>
			<th><? echo $vis_language['TXTRATING']; ?></th>		
			<?php echo ($custom_group!= -1)?'<th>'.$vis_language['TXTUSERFEEDBACK'].'</th>':'';	?>				
		</tr>		
		</thead>
		<tbody>		
     <?    for($i=0;$i<count($report);$i++) {
		    	 			if($report[$i]['first_name'] =='' && $report[$i]['last_name']=='')
					$client_name = '-';
				else
					$client_name = $report[$i]['first_name'].' '.$report[$i]['last_name'];
            $html.='<tr><td><a href="#/ticket/ticket_details/'.$report[$i]['ticket_hash'].'/'.$report[$i]['ticket_id'].'">'.$report[$i]['ticket_hash'].'</a></td><td>'. $report[$i]['subject'].'</td><td>'.$client_name.'</td><td>'.$report[$i]['email'].'</td><td>'.$report[$i]['group_name'].'</td><td>'.format_datetime($report[$i]['receive_date']).'</td><td>';
			$html.= '<span class="vh-yellow m-l-xs">';
            for($cn=0;$cn<5;$cn++) 
			$html.=($cn<$report[$i]['rating'])?'<i class="vh vh-star"></i>':'<i class="vh vh-star-empty"></i>';
            $rates[$report[$i]['rating']]++;
            $html.='</td>';
             if($custom_group!= -1) {if($report[$i]['feedback']!=-1) { $html.='<td><a class="link m-l-xs" href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=ticket&vis_operation=get_ticket_feedback&vis_static_area=vis_feedback_popup_form&vis_ticket_id='.$report[$i]['ticket_id'] .'&vis_department_id='.$report[$i]['department_id'].'">view</a></td>';}
            else $html.='<td>-</td>';
           }
			$html.='</tr></span>';
        }  		echo $html;?>
             </tbody> 
</table>
        <script>
		$("#vis_export_rpt_<?= $operation['vis_operation'] ?>").show(); 
		$("#vis_export_rpt_<?= $operation['vis_operation'] ?>").html('<a href="javascript:void(0);" class="vis_button_export btn btn-primary btn-sm" data-toggle="ajaxModal" data-modal-arguments="vis_module=report&vis_operation=add_report_inqueue&vis_static_area=vis_open_new_dialog&duration=<? echo $data['duration']; ?>&from_date=<? echo strtotime($data['from_date']); ?>&to_date=<? echo strtotime($data['to_date']);?>&client_id=<? echo $data['client_id'];?>&vis_client_id=<? echo $data['vis_client_id'];?>&domain_id=<?=$data['domain_id'];?>&vis_criteria=<? $data['vis_criteria'];?>&report_type=16" onclick="" type="button"><? echo $vis_language['TXTEXPORT']; ?></a>');
		
		$("#vis_schedule_rpt_<?= $operation['vis_operation'] ?>").show(); 
		$("#vis_schedule_rpt_<?= $operation['vis_operation'] ?>").html('<a href="javascript:void(0);" class="vis_button_export btn btn-primary btn-sm" data-toggle="ajaxModal" data-modal-arguments="vis_module=report&vis_operation=add_schedule_report_inqueue&vis_static_area=vis_open_new_dialog&duration=<? echo $data['duration']; ?>&from_date=<? echo strtotime($data['from_date']); ?>&to_date=<? echo strtotime($data['to_date']);?>&client_id=<? echo $data['client_id'];?>&vis_client_id=<? echo $data['vis_client_id'];?>&domain_id=<?=$data['domain_id'];?>&vis_criteria=<? $data['vis_criteria'];?>&report_type=16" onclick="" type="button"><? echo $vis_language['TXTSCHEDULE']; ?></a>');
		</script> <?
    }   
    else  {
		 $operation['no_record']=1;
         include(VIS_PATH_TEMPLATE.'no_record_yet.php');
        ?>
             <script> $("#vis_export_rpt_<?= $operation['vis_operation'] ?>").hide();
              $("#vis_schedule_rpt_<?= $operation['vis_operation'] ?>").hide();
             </script>          
        <?php
 } 
?>
	<script>
$(document).ready(function() {	
$('#datatable').dataTable({		
        "bPaginate" : true,
        "aaSorting":  [],
        "iDisplayLength": <?php echo SECURITY_DATA_PER_PAGE;?>,
		"sDom": '<"top"iflp<"clear">>rt<"bottom"iflp<"clear">>', 		
	    "bFilter" : false,
		"bLengthChange": false,
		"bInfo": false,
		"aoColumns": [
		  	{ "bSortable": true },
            { "bSortable": true },			
			{ "bSortable": true },	
			<?if($custom_group!= -1){ ?> { "bSortable": false },<?php } ?>  
		  	{ "bSortable": true },
		  	{ "bSortable": true },
		  	{ "bSortable": true },
		  	{ "bSortable": true }			
		]
	});
});	
</script>
