<? global $vis_language;?>
<section id="breadcrumb" class="row m-b m-l-none m-r-none">
	<div class="col-sm-4" id="url_header">
	  <h3 class="m-b-xs text-black"><? echo $vis_language['TXTZOPIM']; ?></h3>
	  <div>
		 <ul class="breadcrumb bg-empty no-border m-b-xxs no-padder">
			<li><a class="link" href="#/home/quick_view/<? echo $vis_language['TXTHOME']; ?>"><? echo $vis_language['TXTHOME']; ?></a></li>
			<li class="active"><? echo $vis_language['TXTZOPIM']; ?></li>
		 </ul>
	  </div>
	</div>
    <div class="col-sm-8 text-right text-left-xs m-t-lg">
		<ul class="navSeprator m-n bred_rlink">
			<li><a href="javascript:void(0);" class="link padder" onclick="$('#vis_filter_list').slideToggle();hide_domain();"><?= $vis_language['TXTFILTERLIST']; ?></a></li>
		</ul>
	</div>
</section>

<div class="col-lg-12">
   <? include_once(VIS_PATH_TEMPLATE.'zopim_search.php'); // filter list?>
</div>
<div class="col-lg-12">
   <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="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 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($zopim_setting);$l++){
									if($zopim_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>
         <div class="table-responsive scroll-x" id="vis_livechat_list">
			 <? 
                            if(isset($operation['vis_visitor_email']) || isset($operation['vis_visitor_name']) ) 
                                include(VIS_PATH_TEMPLATE.'ajax_zopim_search.php');
                            else
                                include_once(VIS_PATH_TEMPLATE.'ajax_zopim.php');
                         ?>
		 </div>
      </section>
   </form>
</div>

<script>
    function vis_change_livechat(e){
        if(e.value==0) $("#vis_livechat_list").hide();
        else $('#vis_livechat_list').visExecution('load_area', {'vis_module':'chat', 'vis_operation':'zopim_chat','vis_domain':e.value});
    }
	 function vis_change_livechat_page(e){
        if(e.value==0) $("#vis_livechat_list").hide();
        else $('#vis_livechat_list').visExecution('load_area', {'vis_module':'chat', 'vis_operation':'zopim_chat','vis_page':e.value,'vis_domain':<?php echo $vis_domain; ?>});
    }
	function hide_domain()
	{
		$('#live_domain').toggle();
	}
	$('.from_date').datetimepicker({
                    format: "<?php echo VIS_DATETIMEPICKER_FORMAT;?>"
                });
	$('.to_date').datetimepicker({
                    format: "<?php echo VIS_DATETIMEPICKER_FORMAT;?>"
                });
	function vis_livechat_filter()
	{
		$('#url_header').html('<h3 class="m-b-xs text-black"><? echo $vis_language['TXTFILTERRESULT']; ?></h3><div><ul class="breadcrumb bg-empty no-border m-b-xxs no-padder"><li><a class="link" href="#/home/quick_view/<? echo $vis_language['TXTHOME']; ?>"><? echo $vis_language['TXTHOME']; ?></a></li> <li><a class="link" href="#/chat/zopim_chat/<? echo $vis_language['TXTZOPIM'];?>/1"><? echo $vis_language['TXTZOPIM'];?></a></li><li class="active"><? echo $vis_language['TXTFILTERRESULT']; ?></li></ul></div>').show();
	        var date_from = $.trim($('#from_date').val());
		var date_to = $.trim($('#to_date').val());
		var visitor_email = $.trim($('#vis_visitor_email').val());
                var visitor_name = $.trim($('#vis_visitor_name').val());
		var page_no = $.trim($('#page_no').val());
		var vis_domain = $.trim($('#vis_domain').val());
		//alert(date_from+'>'+date_to+'>'+field_search);
        $('#vis_livechat_list').visExecution('load_area', {'vis_module':'chat', 'vis_operation':'zopim_chat','vis_page':page_no,'vis_visitor_email':visitor_email,'vis_visitor_name':visitor_name,'vis_date_from':date_from,'vis_date_to':date_to,'vis_domain':vis_domain,'vis_filter_enable':1});

	}
$(document).ready(function() {
$('#datatable').dataTable({
       "bPaginate" : true,
	    "iDisplayLength": 25,
		"sDom": 'ltipr',
		  "bLengthChange": false,
		    "bInfo": false,
		"aoColumns": [null,	null, null, null, null, null]
	});
});
</script>
