<?php global $vis_language;
$paging_list='';
   for($i=0;$i<$num_pages;$i++) $paging_list.='<option value="'.$i.'" '.(($page==$i)?'selected="selected"':'').'>'.($i+1).'</option>';?>
<section id="breadcrumb" class="row m-b m-l-none m-r-none">
   <div class="col-sm-6" id="url_header">
      <h3 class="m-b-xs text-black"><? echo $vis_language['TXTTWILIO']; ?><span id="total_cnt"> (<? echo $total_twilio_call;?>)</span></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['TXTTWILIO']; ?></li>
         </ul>
      </div>
   </div>
   <div class="col-sm-6 text-right text-left-xs m-t-lg">
<div class="btn-group pull-right">
			<button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><i class="vh vh-action text-muted"></i> <b class="caret"></b></button>
     <ul class="dropdown-menu dropdown-menu-right text-left">
        <li><a class="link" href="#/voip/twilio_message/<? echo $vis_language['TXTTWILIOMSG']; ?>" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTTWILIOMSG']; ?>',{'vis_module':'voip','vis_operation':'twilio_message'});"><? echo $vis_language['TXTMESSAGE']; ?></a></li>
         </ul>
   </div>
	    <div class="btn-group pull-right">&nbsp;
			<a title="<?= $vis_language['TXTFILTERLIST']; ?>" href="javascript:void(0);" class="btn btn-default btn-sm dropdown-toggle" onclick="$('#vis_filter_list').slideToggle();"><i style="font-size:10px;" class="vh vh-filter"></i></a>
	  </div>
      
   </div>
</section>
<div class="col-lg-12">
   <? include_once(VIS_PATH_TEMPLATE.'twilio_call_search.php');?>
</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" value="" name="vis_filter_enable" id="vis_filter_enable">
      <section class="panel panel-default">
         <div class="row wrapper clr">
            <div class="col-sm-12 tkt_left_menu">
               <div class="col-lg-3 m-l-n" id="live_domain">
					 <div class="col-sm-3 text-muted label_page"><?= $vis_language['TXTDOMAIN'];?>:</div>
					 <div class="col-sm-9 vis_doamin_div">
						  <select class='form-control selectpicker' name="vis_domain" id="vis_domain" onchange="vis_change_domain(this.value)" <? 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 = '';
									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 tkt_right_menu" id="paging">
						<button type="button" id="btn_next_page" class="btn pull-right btn-primary m-l btn_next_page" onclick="return vis_change_twilio_page2('next');"><? echo $vis_language['TXTNEXT']; ?></button>
						<button type="button" id="btn_prev_page" class="btn pull-right btn-primary m-l btn_prev_page" onclick="return vis_change_twilio_page2('prev');"><? echo $vis_language['TXTPREVIOUS']; ?></button>
						<!--<?php if($paging_list!=''){?>
						   <select name="pageing" id="paging" class="form-control input-sm selectpicker pull-right paging v-middle" onchange="return vis_change_twilio_page(this.value);" <? if($num_pages > 10) echo 'data-live-search="true"'; ?>>
						   <? echo $paging_list;?>
						   </select>
						   <div class="text-muted pull-right label_page"><? echo $vis_language['TXTPAGE']; ?>:</div>
						<?php }?>-->
					</div>
				</div>
		 </div>

		 <div class="table-responsive scroll-x" id="vis_call_list">
            <?  include_once(VIS_PATH_TEMPLATE.'twilio_call_list.php');?>
         </div>
		 
		 <div class="row wrapper clr">
            <div class="col-sm-12 tkt_left_menu"></div>
			<div class="col-sm-12 pull-right text-center-xs">
				<div  class="pull-right tkt_right_menu" id="paging">
					<button type="button" id="btn_next_page" class="btn pull-right btn-primary m-l btn_next_page" onclick="return vis_change_twilio_page2('next');"><? echo $vis_language['TXTNEXT']; ?></button>
					<button type="button" id="btn_prev_page" class="btn pull-right btn-primary m-l btn_prev_page" onclick="return vis_change_twilio_page2('prev');"><? echo $vis_language['TXTPREVIOUS']; ?></button>
				</div>
			</div>
		 </div>
      </section>
   </form>
</div>
<section class="fullFrame m-n" id="vis_no_record_search" style="display:none;">
</section>

<script>
	$(".selectpicker").selectpicker();
	function vis_change_domain(e){
		if(e!=0)$('#vis_workpanel_div').visExecution('load_area', {'vis_module':'voip', 'vis_operation':'twilio_call','vis_domain':e});
	}
	function vis_change_twilio_page(e){
        $('#vis_call_list').visExecution('load_area', {'vis_module':'voip', 'vis_operation':'twilio_call','vis_page':e, 'vis_domain':'<?php echo $vis_domain; ?>'});
    }
	function vis_change_twilio_page2(btn){
		if(btn=='next')	var e = $('#vis_next_page_no').val();
		if(btn=='prev')	var e = $('#vis_prev_page_no').val();
        $('#vis_call_list').visExecution('load_area', {'vis_module':'voip', 'vis_operation':'twilio_call','vis_page':e, 'vis_domain':'<?php echo $vis_domain; ?>'});
    }
	function hide_domain(){	$('#live_domain').toggle();	}

	$('.from_date').datetimepicker();

	function vis_apply_filter(vis_page){
		vis_page = (vis_page!=undefined && typeof(vis_page)!=undefined && vis_page != '') ? vis_page:'0';
		var data = {'vis_filter_enable':'1', 'vis_page':vis_page, 'vis_action': $("#vis_filter_list input, #vis_filter_list select").serialize() };

		$.ajax({
			url: 'index.php?vis_module=voip&vis_operation=twilio_call',
			data: data,
			type: "POST",
			dataType: "json",
			success: function(data) {
				$(".tkt_right_menu").show();
				$('#url_header').html('<h3 class="m-b-xs text-black"><? echo $vis_language['TXTFILTERRESULT']; ?><span id="total_cnt"> ('+data.total_cnt+')</span></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="#/voip/twilio_call/<? echo $vis_language['TXTTWILIO'];?>/1"><? echo $vis_language['TXTTWILIO'];?></a></li><li class="active"><? echo $vis_language['TXTFILTERRESULT']; ?></li></ul></div>').show();
				$(".vis_doamin_div").html(data.domain);
				$("#vis_call_list").html(data.list);
				$(".tkt_right_menu").html(data.paging);
				if(data.total_cnt==0){
				$(".tkt_right_menu").hide();
				$("#vis_no_record_search").show();
				}else {$("#vis_no_record_search").hide();}
				toggle_mass_actions(); // To disable header & footer mass actions on list pages
			},
			error: function(xhr, ajaxOptions, thrownError) {$("#vis_global_msg_div").visInterface("load_global_message", "Error: "+xhr.status+" - "+thrownError);}
		});

	}
</script>
<script src="<?= VIS_PATH_SCRIPT; ?>dropdown_dropup.js"></script>
