<? global $vis_language; ?>
<section id="breadcrumb" class="row m-b m-l-none m-r-none">
	<div class="col-sm-6">
		<h3 class="m-b-xs text-black"><span><? echo $vis_language['TXTAIRCALL'];?></h3>
		<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"><a class="link" href="#/setting/setting_menu/<? echo $vis_language['TXTSETTINGS'];?>" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTSETTINGS'];?>',{'vis_module':'setting','vis_operation':'setting_menu'});"><? echo $vis_language['TXTSETTINGS'];?></a></li>
			<li><? echo $vis_language['TXTAIRCALL']; ?></li>
		</ul>
	</div>
   <!--
   <? if($aircall_details !=-1 && !empty($aircall_details)) {?> 
	  <div class="col-sm-6 text-right text-left-xs m-t-lg">
			  <ul class="navSeprator m-n bred_rlink">
				<li><a href="#/setting/aircall_apps/aircall-Apps/<? echo $aircall_details['integration_id']; ?>" class="link"><? echo $vis_language['TXTEXOTELAPPS']; ?></a></li>
			</ul>
		</div>
		<? } ?>   
   -->
</section>
<section class="padder">
	<section class='panel panel-default'>
		<header class="panel-heading sub_header"><? echo $vis_language['TXTAIRCALL']; ?></header>
		<div class="panel-body">
			<form method="post" name="vis_integration_form" id="vis_integration_form" class="form-horizontal">
				<div class="form-group">
					 <label class="col-sm-2 control-label"><? echo $vis_language['TXTALLDOMAIN']; ?></label>
					 <div class="col-sm-2">
						<? /*?><div class="checkbox m-n i-checks pull-left "><label><input type="checkbox" name="vis_sign_all_domain" id="vis_sign_all_domain" onchange="toggle_dept_list();" value="1" checked="checked" <? //if($vis_all_domain==1) echo ' checked="checked"'; ?>/><i></i></label></div><? */ ?>
						<div class="checkbox m-n i-checks pull-left "><label><input type="checkbox" name="vis_sign_all_domain" id="vis_sign_all_domain" onchange="toggle_dept_list();" value="1" <? if($aircalldetails!=-1) echo ' checked="checked"';//if($vis_all_domain==1) echo ' checked="checked"'; ?>/><i></i></label></div>
					 </div>
				</div>
				<div class="form-group vis_doamin_div">
					<label class="col-sm-2 control-label"><?= $vis_language['TXTDOMAIN']; ?></label>
					<div class='col-sm-10'>
						<select class='form-control input-sm selectpicker' name="vis_domain" id="vis_domain" onchange="vis_change_domain(this.value)" <? if(count($department) > 10) echo 'data-live-search="true"' ?>>
							<option value="0">-- <? echo $vis_language['TXTSELECTDOMAIN']; ?> --</option>
							<? 
							for($i=0;$i<count($department);$i++){ 
								if($aircalldetails==-1 && $aircall_details['domain_id'] == $department[$i]['domain_id']){
									$selected = "selected";
								}else{
									$selected = "";
								}
								echo '<option value="'.$department[$i]['domain_id'].'" '.$selected.'>'.$department[$i]['domain_name'].'</option>';
							} ?>
						</select>
					</div>
				</div>
				<div id="vis_aircall_area"></div>
		</div>
	</section>
</section>
<script>
	function vis_change_domain(e){
        if(e==0) $("#vis_aircall_area").hide();
        else $('#vis_aircall_area').visExecution('load_area', {'vis_module':'setting', 'vis_operation':'aircall_setting', 'vis_domain':e});
    }
    if($('#vis_sign_all_domain').is(":checked")){
		$('.vis_doamin_div').hide();
		vis_change_domain('all');
	}

	function toggle_dept_list(){
		if($('#vis_sign_all_domain').is(":checked")) {$('.vis_doamin_div').hide(); vis_change_domain('all');}
		else {
			$('#vis_aircall_area').hide();
			$('.vis_doamin_div').show();
			$("div.vis_doamin_div select").val("0").change();
		}
	}
	$(function(){
		var val = '<? echo ($aircalldetails==-1)? $aircall_details['domain_id'] : 'all';?>';
		vis_change_domain(val);
	});
</script>
