<?  global $vis_language;
 if(count($chat_data)>0){?>

            <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 class="txt_nowrap"><? echo $vis_language['TXTDATE']; ?></th>  
                     <th class="txt_nowrap"><? echo $vis_language['TXTVISITORNAME'];?></th>
                     <th class="txt_nowrap"><? echo $vis_language['TXTVISITOREMAIL']; ?></th>             
                  	 <th class="txt_nowrap"><? echo $vis_language['TXTSTAFF'];?></th>
                     <th class="txt_nowrap"><? echo $vis_language['TXTCHATURL'];?></th>
                  </tr>
               </thead>
               <tbody>
              
                  <?
                      for($i=0;$i<count($chat_data);$i++) {
						  
						  $operator_data=$this->get_agent_data($vis_domain);
						  for($s=0;$s<count($operator_data);$s++){
							  //echo $operator_data[$i]->id .'=='. $operator_id;
							  if($operator_data[$s]->id == $chat_data[$i]->operator_created_id){
								  $staff_name =  $operator_data[$s]->first_name.' '.$operator_data[$s]->last_name;
								  $staff_email =  $operator_data[$s]->email;
							  }
						  }
						  if($chat_data[$i]->client_name!='' || $chat_data[$i]->client_email!='' ){
						  	 $visitor_name = $chat_data[$i]->client_name;
							 $visitor_email = $chat_data[$i]->client_email;
						  }else{
							 $visitor_name = $vis_language['TXTNOTSPECIFIED'];
							 $visitor_email= $vis_language['TXTNOTSPECIFIED'];
						  }?>
						  <tr style="cursor:pointer;" onclick="$('#vis_workpanel_div').visExecution('load_module','<?php echo $vis_language["TXTCHATTRANSCRIPT"];?>',{'vis_module':'chat','vis_operation':'userlike_detail','vis_chat_id':'<?php echo $chat_data[$i]->id;?>','vis_visitor_name':'<?php echo $visitor_name;?>','vis_visitor_email':'<?php echo $visitor_email;?>','vis_staff_name':'<?php echo $staff_name;?>','vis_staff_email':'<?php echo $staff_email;?>','vis_chat_url':'<?php echo $chat_data[$i]->url;?>','vis_userlike_domain':'<?php echo $vis_domain;?>'});">
						  <?php echo '<td>'.format_datetime(strtotime($chat_data[$i]->created_at));?>
                          <?php echo '</td>';
						  echo '<td class="txt_nowrap">'.ucfirst($visitor_name).'</td>';
						  echo '<td class="txt_nowrap">'.$visitor_email.'</td>';
  					 	  
						  echo '<td class="txt_nowrap">'.ucfirst($staff_name).'</td>';
						  echo '<td>'.$chat_data[$i]->url.'</td>';
						  echo '</tr>';
 					  }?>    
		       </tbody>
            </table>
         
   <script type="text/javascript" src="<?= VIS_PATH_SCRIPT; ?>datatables/data-tables/DT_bootstrap.js"></script>
<script>
$(document).ready(function() {	
$('#datatable').dataTable({		
       "bPaginate" : true,	
	    "iDisplayLength": 25,
		"sDom": 'ltipr',
		  "bLengthChange": false,
		    "bInfo": false,
		"aoColumns": [
			{ "bSortable": true },
		  	{ "bSortable": false },
		  	null,
		  	null,
		  	null,		  
		]
	});
});	
</script>
<? 
}
else
{
 include(VIS_PATH_TEMPLATE.'no_record_yet.php');
} ?>
