<?  global $vis_language;?>  
<?php if(count($response->chats)>0){?>
       <table class="table table-hover b-t b-light m-b-none" id="datatables">
		   <thead class="table_head">
			  <tr>
				 <th width="25%"><? echo $vis_language['TXTMESSAGE']; ?></th>   
				 <th class="txt_nowrap"><? echo $vis_language['TXTIPADDRESS'];?></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['TXTDATE']; ?></th>              				 
			  </tr>
		   </thead>
		   <tbody>
			  <?
				 for($c=0;$c<count($response->chats);$c++){
                                        
					 if($response->chats[$c]->visitor->email!=''){
						 $visitor_email = $response->chats[$c]->visitor->email;
					  }else{
						 $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':'zopim_detail','vis_chat_id':'<?php echo $response->chats[$c]->id;?>','vis_domain':'<?php echo $vis_domain;?>'});">
						<?php
                                                if(($response->chats[$c]->count->total) > 0) { 
                                                    for($i=0;$i<=count($response->chats[$c]->history);$i++) {
                                                    if($response->chats[$c]->history[$i]->msg !='') {
                                                     echo '<td width="25%">'.$response->chats[$c]->history[$i]->msg.'</td>';        
                                                      $i = count($response->chats[$c]->history);
                                                    }                                                  
                                                   }
                                                }
                                                else
                                                    echo '<td width="25%">'.$response->chats[$c]->message.'</td>';                                               
                                                    echo '<td class="txt_nowrap">'.$response->chats[$c]->session->ip.'</a></td>';
                                                    echo '<td class="txt_nowrap">'.ucfirst($response->chats[$c]->visitor->name).'</td>';
                                                    echo '<td class="txt_nowrap">'.$visitor_email.'</td>';
                                                    echo '<td>'.format_datetime(strtotime($response->chats[$c]->session->start_date)).'</td>';						 
                                                    echo '</tr>';
				  }
				 ?>    
		   </tbody>
		</table>
	<script type="text/javascript" src="<?= VIS_PATH_SCRIPT; ?>datatables/data-tables/DT_bootstrap.js"></script>
	<script>
		$(document).ready(function() {	
		$('#datatables').dataTable({		
			   "bPaginate" : true,	
                           "aaSorting": [[ 4, "asc" ]],
				"iDisplayLength": 25,
				"sDom": 'ltipr',
				  "bLengthChange": false,
					"bInfo": false,
				"aoColumns": [null,	null, null, null, null]
			});
		});
		</script>
  <? 
}else
{
 include(VIS_PATH_TEMPLATE.'no_record_yet.php');
} ?>