<?  global $vis_language;?>  
<?php if(count($chat_data)>0){?>
<form name="vis_<?php echo $operation['vis_operation']; ?>_form" id="vis_<?php echo $operation['vis_operation']; ?>_form">
   <input type="hidden" name="vis_current_operation" value="<?php echo $operation['vis_current_operation']; ?>" />
	  <section class="panel panel-default"> 
         <div class="row wrapper clr">
           	<div  class="col-sm-12 pull-right text-center-xs">
                <div class="col-lg-3 m-l-n" id="live_domain">
                 <div class="col-sm-2 text-muted label_page"><?= $vis_language['TXTDOMAIN'];?>:</div>
                 <div class="col-sm-6">
                      <select class='form-control selectpicker' name="vis_domain" id="vis_domain" onchange="vis_change_livechat(this)" <? if(count($department) > 10) echo 'data-live-search="true"' ?>>
                          <? for($i=0;$i<count($department);$i++) 
						     {
								 if($vis_domain == $department[$i]['domain_id'])
								    $chk = 'selected="selected"';
								 else
								    $chk = '';
							 
								 for($l=0;$l<count($livechat_setting);$l++)
								 {
									if($livechat_setting[$l]['domain_id'] == $department[$i]['domain_id'])
						  			{ 
										
									 	echo '<option '.$chk.' value="'.$department[$i]['domain_id'].'">'.$department[$i]['domain_name'].'</option>'; 
									}
									 	 
								 }
						          
							 }?>
                                
                      </select>
                  </div>
                </div>
              </div>
              <div  class="col-sm-12 pull-right text-center-xs">
                 <div class="pull-right" id="paging">	 
                     <select name="page_no" id="page_no" class="form-control input-sm selectpicker pull-right paging v-middle" onchange="vis_change_livechat_page(this);">
                       <?php if($chat_object->pages>1)
                             {
                                 for($p=0;$p<$chat_object->pages;$p++)
                                 {
                                    $page_no = $p+1;
                                     if($page == $page_no)
                                        $chk = 'selected="selected"';
                                     else
                                        $chk  = '';	
                                    echo '<option '.$chk.' value="'.$page_no.'">'.$page_no.'</option>';
                                 }
                             }else
                             {
                                 echo '<option>1</option>';   
                             }?>
                      </select>
                       <div class="text-muted pull-right label_page"><? echo $vis_language['TXTPAGE'];?>:</div>
                  </div>
              </div>
         </div>
         <div class="table-responsive scroll-x" >
            <table class="table table-hover b-t b-light m-b-none" data-ride="datatables">
               <thead class="table_head">
                  <tr>
                     <!--<th>
                        <div class="btn-group">
                           <label class="checkbox m-n m-r-sm i-checks"  style="float: left;"><input type="checkbox"><i></i></label>		
                        </div>
                     </th>-->
                     <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>              
					 <th class="txt_nowrap"><? echo $vis_language['TXTSTAFF'];?></th>
                  </tr>
               </thead>
               <tbody>
                  <?
                      for($i=0;$i<count($chat_data);$i++) {
						  $chat_msg = $chat_data[$i]->messages;
						  if($chat_data[$i]->visitor->email!=''){
						 	 $visitor_email = $chat_data[$i]->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':'chat_detail','vis_chat_id':'<?php echo $chat_data[$i]->id;?>','vis_chk_domain':'<?php echo $vis_domain;?>'});">
							<?php
						  echo '<td width="25%">';
						  for($j=0;$j<3;$j++)
						  {
						  	$usr_type = $chat_msg[$j]->user_type;
							if($usr_type == 'visitor')							 
							echo $chat_msg[$j]->text;
						  }
						  echo '</td>';		
						  echo '<td class="txt_nowrap">'.$chat_data[$i]->visitor_ip.'</td>';
						  echo '<td class="txt_nowrap">'.ucfirst($chat_data[$i]->visitor_name).'</td>';
						  echo '<td class="txt_nowrap">'.$visitor_email.'</td>';
  					   	  echo '<td>'.format_datetime(strtotime($chat_data[$i]->started)).'</td>';
						  echo '<td class="txt_nowrap">'.ucfirst($chat_data[$i]->agents[0]->display_name).'</td>';
						  echo '</tr>';
 					  }
					 ?>    
		       </tbody>
            </table>
             </div>
      </section>
   </form>
<? }else{?>
	<form name="vis_<?php echo $operation['vis_operation']; ?>_form" id="vis_<?php echo $operation['vis_operation']; ?>_form">
   <input type="hidden" name="vis_current_operation" value="<?php echo $operation['vis_current_operation']; ?>" />
	  <section class="panel panel-default"> 
         <div class="row wrapper clr">
           	<div  class="col-sm-12 pull-right text-center-xs">
                <div class="col-lg-3 m-l-n" id="live_domain">
                 <div class="col-sm-2 text-muted label_page"><?= $vis_language['TXTDOMAIN'];?>:</div>
                 <div class="col-sm-6">
                      <select class='form-control selectpicker' name="vis_domain" id="vis_domain" onchange="vis_change_livechat(this)" <? if(count($department) > 10) echo 'data-live-search="true"' ?>>
                          <? for($i=0;$i<count($department);$i++) 
						     {
								 if($vis_domain == $department[$i]['domain_id'])
								    $chk = 'selected="selected"';
								 else
								    $chk = '';
							 
								 for($l=0;$l<count($livechat_setting);$l++)
								 {
									if($livechat_setting[$l]['domain_id'] == $department[$i]['domain_id'])
						  			{ 
										
									 	echo '<option '.$chk.' value="'.$department[$i]['domain_id'].'">'.$department[$i]['domain_name'].'</option>'; 
									}
									 	 
								 }
						          
							 }?>
                                
                      </select>
                  </div>
                </div>
              </div>
         </div>
         <? include(VIS_PATH_TEMPLATE.'no_record_yet.php');?>
      </section>
   </form>
<?
} ?>