<? global $vis_language;
if($asign_twilio_staff!=-1){ ?>
<script>
/****** T W I L I O    S C R I P T **********/
	$(document).ready(function(){

		Twilio.Device.setup("<?php echo $twilio_generated_token;?>");
		var connection=null;
				
		$("#twilio_call_hangup_btn").click(function() {  
			Twilio.Device.disconnectAll();
		});
		
		Twilio.Device.incoming(function (conn) {
			
			var data = {'incoming_call_from':conn.parameters.From, 'CallSid':conn.parameters.CallSid, 'AccountSid':conn.parameters.AccountSid};
			$.ajax({
				url: 'index.php?vis_module=voip&vis_operation=twilio_incoming_call',
				data: data,
				type: "POST",
				dataType: "json",
				success: function(data) {
					$("#call_window").show();
					$("#twilio_client_details_area").html(data.twilio_data);
					$("#twilio_incoming_number").html(data.to_number);
				},
				error: function(xhr, ajaxOptions, thrownError) {$("#vis_global_msg_div").visInterface("load_global_message", "Error: "+xhr.status+" - "+thrownError);}
			});
			$("#twilio_call_accept").click(function() { 
				connection=conn;
				conn.accept();
			});
			$("#twilio_call_reject").click(function() {
				connection =conn
				conn.reject();
				$("#call_window").hide();
			});
		});
		
		Twilio.Device.connect(function (conn) {
			$("#call_window").show();
			$("#twilio_call_accept_reject").hide();
			$("#twilio_call_hangup_btn").show();
		});

		Twilio.Device.disconnect(function (conn) {
			$("#twilio_call_accept_reject").show();
			$("#twilio_call_hangup_btn").hide();
			$("#call_window").hide();
		});
		
		function toggleCallStatus(){
			$('#twilio_call_hangup_btn').toggle();
		}
	});
</script>
<?php }?>

<div>
	<ul class="nav navbar-nav hidden-xs">
		<li class="dropdown" id="ticketmenu">
			<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <i class="vh vh-bars-3"></i> </a>
			<section class="dropdown-menu aside-md bg-white fadeInLeft global_m">
			    <div class="row m-l-none m-r-none m-b-none" id="global_menu">
					<script language="javascript">
						$('#global_menu').visExecution('load_area', {'vis_module':"home", 'vis_operation':'load_global_menu'});
					</script>
				</div>
			</section>
		</li>
		<li id="homenav"><a href="#/home/quick_view/<? echo $vis_language['TXTHOME']; ?>" class="vis_main_menu"><span class="hidden-nav-xs"><? echo $vis_language['TXTHOME']; ?></span></a></li>
		<li id="inboxnav"><a href="#/ticket/filter_ticket/<? echo $vis_language['TXTTICKETS']; ?>/1" class="vis_main_menu"><span class="hidden-nav-xs"> <? echo $vis_language['TXTINBOX']; ?></span></a>  </li>
		<li id="clientnav"><a href="#/client/view_clients/<? echo $vis_language['TXTCLIENTS']; ?>" class="vis_main_menu"><span class="hidden-nav-xs"> <? echo $vis_language['TXTCLIENTS']; ?></span></a></li>
		<li class="dropdown" id="toolbardiv">
			<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <i class="vh vh-grid-round"></i> </a>
			<section class="dropdown-menu aside-lg bg-white on animated fadeInLeft" id="vis_left_toolbar_section">
				<div class="row m-l-none m-r-none m-t m-b text-center" id="vis_left_toolbar_div">
					<script language="javascript">
						$('#vis_left_toolbar_div').visExecution('load_area', {'vis_module':"home", 'vis_operation':'load_menu_toolbar'});
					</script>
				</div>
			</section>
		</li>
	</ul>
	<ul class="nav navbar-nav navbar-right m-n hidden-xs nav-user user">
		<li class="hidden-xs " id="icon_global_search2">
            <input class="form-control search" autocomplete="off" type="text" placeholder="Search" id="vis_global_searchbar" name="vis_global_searchbar" onfocus="var temp=this.value;this.value='';this.value=temp">
          <span class="icon-search"></span>
          <section id="search_result" class="dropdown-menu aside-xl">
         
          </section>
		</li>
		<li class="hidden-xs dropdown" id="newdiv">
			<a class="dropdown-toggle" data-toggle="dropdown" id="" href="javascript:void(0);" title="<?= $vis_language['TXTNEW']; ?>">
				<i class="vh vh-plus" style="font-size:10px;"></i> <?= $vis_language['TXTNEW']; ?>
				<span class="caret"></span>
			</a>
			<ul class="dropdown-menu">
				<li>
					<a href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=ticket&vis_operation=new_ticket_step_one&vis_static_area=vis_open_new_dialog"><? echo $vis_language['TXTTICKET']; ?></a>
				</li>
				<? if(VIS_ITIL==1 && (isset($module['itil']) && $module['itil']==1)){?>
				<li>
					<a href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=problem&vis_operation=new_problem_step_one&vis_static_area=vis_open_new_dialog"><? echo $vis_language['TXTPROBLEM']; ?></a>
				</li>
				<li>
					<a href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=changes&vis_operation=new_changes_step_one&vis_static_area=vis_open_new_dialog"><? echo $vis_language['TXTCHANGE']; ?></a>
				</li>
				<li>
					<a href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=releases&vis_operation=new_release_step_one&vis_static_area=vis_open_new_dialog"><? echo $vis_language['TXTRELEASE']; ?></a>
				</li>
                <li>
					<a href="#/ticket/service_request/<? echo $vis_language['TXTITILREQUESTSERVICE']; ?>"><? echo $vis_language['TXTITILREQUESTSERVICE']; ?></a>
				</li>
				<? }?>
				<li>
					<a href="javascript:void(0);" onclick="$('#vis_workpanel_div').visExecution('load_module','Add client',{'vis_module':'client','vis_operation':'new_client', 'cache':true, 'vis_client_id':0});"><? echo $vis_language['TXTCLIENT']; ?></a>
				</li>
    <li>
					<a href="javascript:void(0);" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTADDORGANIZATION']; ?>',{'vis_module':'client','vis_operation':'new_client_group', 'cache':true});"><? echo $vis_language['TXTORGANIZATION']; ?></a>
				</li>
    <? if(isset($module['blabber']) && $module['blabber']==1 && VIS_MODULE_ACCESS_BLABBER==1) {?>
    	<li>
					<a href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=blabber&vis_operation=add_new_blab&cache=true"><? echo $vis_language['TXTBLABS']; ?></a>
				</li>
    <? } ?>
    
				<? if(isset($module['task']) && $module['task']==1 && VIS_MODULE_ACCESS_TASK==1) {?>
				<li>
					<a href="javascript:void(0);" onclick="$('#vis_workpanel_div').visExecution('load_module','Add Task',{'vis_module':'home','vis_operation':'new_task', 'cache':true});"><? echo $vis_language['TXTTASK']; ?></a>
				</li>
				<? } ?>
				
          	</ul>
		</li>
		<li class="hidden-xs" id="vis_notify_container">
			<script language="javascript">
				$("#vis_notify_container").visExecution('load_area', {'vis_module':'staff', 'vis_operation':'load_notification'});
			</script>
		</li>
		<?php if($twilio_details!=-1){
			
			$color_class = ($forward_details!=-1 && $forward_details[0]['forward_number']!='') ? 'yellow' : (($forward_details[0]['status']=='0')? 'red':'green');
			?>
		<li class="hidden-xs dropdown" id="">
			<a class="dropdown-toggle" data-toggle="dropdown" id="" href="javascript:void(0);" title="<?= $vis_language['TXTTWILIO']; ?>">
				<div id='call_color_icon'><span class="vh-call-box <?php echo $color_class;?>"></span></div><!--<span class="caret"></span>-->
			</a>
			<ul class="dropdown-menu">
			<?php if($asign_twilio_staff!=-1){?>
				<li><a href="javascript:void(0);" onclick="javascript:update_twilio_staff_status(1);"><i class="vh vh-call vh-green vh-lg"></i> <?=$vis_language['TXTONLINE']; ?></a></li>
				<li><a href="javascript:void(0);" onclick="javascript:update_twilio_staff_status(0);"><i class="vh vh-call vh-red vh-lg"></i> <?=$vis_language['TXTOFFLINE']; ?></a></li>
				<li><a href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=voip&vis_operation=twilio_forword_to"><i class="vh vh-call vh-yellow vh-lg"></i> <?=$vis_language['TXTFORWORDTO']?></a></li>
				<li id="vis_twilio_forward_to_details"><a href="javascript:void(0);"><i class="vh vh-mail-forward vh-yellow vh-lg"></i> <?=$forward_details[0]['forward_number']?></a><a href="javascript:void(0);" style="float:right;margin-top:-36px"  onclick="javascript:remove_twilio_forward();"><i class="vh vh-cross m-t-sm"></i></a>
				</li>
			<?php } ?>	
			
			
				<li><a href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=voip&vis_operation=twilio_new_call"><i class="vh vh-call vh-green vh-lg"></i> <?=$vis_language['TXTCALL']?></a></li>
				<li><a href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=voip&vis_operation=new_twilio_message"><i class="vh vh-sms vh-blue vh-lg"></i> <?=$vis_language['TXTSENDMESSAGE']?></a></li>
			</ul>

		</li>
		<?php } //twilio
		
		##Exotel
			if($exotel_details!=-1){ ?>
				<li class="hidden-xs dropdown" id="">
			<a class="dropdown-toggle" data-toggle="dropdown" id="" href="javascript:void(0);" title="<?= $vis_language['TXTEXOTEL']; ?>">
				<div id='call_color_icon'><span class="vh-call-box <?php echo $color_class;?>"></span></div><!--<span class="caret"></span>-->
			</a>
			<ul class="dropdown-menu">
				<li><a href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=voip&vis_operation=connect_customer_to_agent&vis_static_area=vis_open_new_dialog&vis_call_type=1" ><i class="vh vh-call vh-green vh-lg"></i> <?=$vis_language['TXTCONNECTCUSTTOAGENT']?></a></li>
				<?php /* ?><li><a href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=voip&vis_operation=connect_customer_to_agent&vis_static_area=vis_open_new_dialog&vis_call_type=2" ><i class="vh vh-call vh-green vh-lg"></i> <?=$vis_language['TXTCONNECTCUSTTOFLOW']?></a></li><?php */?>
				
				<li><a href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=voip&vis_operation=sms_send_view&vis_static_area=vis_open_new_dialog&vis_call_type=3"><i class="vh vh-sms vh-blue vh-lg"></i> <?=$vis_language['TXTSENDMESSAGE']?></a></li>
				<li><a href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=voip&vis_operation=sms_send_view&vis_static_area=vis_open_new_dialog&vis_call_type=4"><i class="vh vh-sms vh-blue vh-lg"></i> <?=$vis_language['TXTSENDBULKSMS']?></a></li>
			</ul>
			<?php }			
		###Exotel 
		##Aircall
		if($aircall_details!=-1){ ?>
				<li class="hidden-xs dropdown" id="">
			<a class="dropdown-toggle" data-toggle="dropdown" id="" href="javascript:void(0);" onClick="window.open('https://app.aircall.io','Aircall app','width=340,height=600')" title="<?= $vis_language['TXTAIRCALL']; ?>">
				<div id='call_color_icon'><span class="vh-call-box <?php echo $color_class;?>"></span></div><!--<span class="caret"></span>-->
			</a>
			<!--<ul class="dropdown-menu">
				<li>
					<iframe src="https://app.aircall.io" style="height:600px;width:341px;  border: none;" >
							<p>Your browser does not support iframes.</p>
					</iframe>
				</li>
			</ul>-->
			<?php }				
		###Aircall
		?>
			
		<li class="dropdown" id="vis_top_user_detail_menu">
			<a href="#" class="dropdown-toggle" data-toggle="dropdown">
                <? if($staff[0]['image_name']!='' && is_file(VIS_PATH_PROFILE.$staff[0]['image_name']) && $staff[0]['image_name']!='default.jpg'){?>
   <div class="l-avatar pull-left" id="vis_header_profile_img">
				<img class="sm" src="<?= VIS_PATH_PROFILE.$staff[0]['image_name'];?>">
		    </div>
      <? }else{?>
   <div class="l-avatar pull-left" id="vis_header_profile_img">
   <? if($staff[0]['first_name']!=''){
				$firstname=preg_split('//u', $staff[0]['first_name'], -1, PREG_SPLIT_NO_EMPTY);
$lastname=preg_split('//u', $staff[0]['last_name'], -1, PREG_SPLIT_NO_EMPTY);
				?>
    <div class="sm"><? echo ucfirst($firstname[0]).ucfirst($lastname[0]);?></div>
    <? }else{ ?>
    <img class="sm" src="<?= VIS_PATH_PROFILE.'default.jpg';?>">
    <? }?>
		    </div>
      <? }?> <?= $staff[0]['first_name'].' '.$staff[0]['last_name']; ?> <b class="caret"></b>
        </a>
        <ul class="dropdown-menu animated fadeInRight">
            <li>
                <span class="arrow top"></span> <a href="#/home/profile_view/<? echo $vis_language['TXTPROFILE']; ?>"><? echo $vis_language['TXTPROFILE']; ?></a>
            </li>
            <?php if(VIS_ALERT_ACCESS==1) { ?>
            <li>
                <a href="#/home/view_alerts/<? echo $vis_language['TXTALERTS']; ?>"><? echo $vis_language['TXTALERTS']; ?></a>
            </li><? } ?>
            <li>
                <a href="#/home/view_views/<? echo $vis_language['TXTVIEWS']; ?>"><? echo $vis_language['TXTVIEWS']; ?></a>
            </li>
            <li>
                <a href="#/home/view_macros/<? echo $vis_language['TXTMACROS']; ?>"><? echo $vis_language['TXTMACROS']; ?></a>
            </li>
            <?php if(VIS_SELF_AUTO_ASSIGN_TICKET==1) { ?>
            <li class="divider"></li>
			<li>
				<a>
				<? $status = ($autoAssignStaff[0]['access']==0)?1:0;?>
				  <label><? echo$vis_language['TXTAUTOASSIGN']; ?></label>		
                  <label class="switch sm">
					  <? $status = ($autoAssignStaff[0]['access']==1)?"off":"on";?>
                  <input type="checkbox" <? if($autoAssignStaff[0]['access']==1) echo 'checked="checked"'; else '';?> name="vis_status"  id="vis_status1" onchange="$(this).visExecution('load_area', {'vis_module':'staff', 'vis_operation':'change_auto_assign_setting', 'vis_status':'<?= $status; ?>','vis_staff_id':'<? echo VIS_STAFF_ID;?>','vis_profile':1})">
                  <span ></span>
              </a>
			</li><? } ?>
            <li class="divider"></li>
            <li>
                <a href="javascript:void(0);" onclick="$('#vis_main_panel_div').visExecution('load_area', {'vis_module':'home', 'vis_operation':'logout'});"><? echo$vis_language['TXTLOGOUT']; ?></a>
            </li>
        </ul>
		</li>
		<?php if(VIS_ADMIN_ACCESS!=-1) {?>
		<li id="setingdiv">
			<a href="#/setting/setting_menu/<?= $vis_language['TXTSETTINGS']; ?>" title="<?= $vis_language['TXTSETTINGS']; ?>">
				<i class="vh vh-action "></i>
			</a>
		</li>
		<? } ?>
		<script>
		function gethelppopup(){
			var hashn=window.location.hash; 
			var functionname=hashn.split('/'); 
			$("#vh-helps").attr('data-toggle','ajaxModal'); 
			if(functionname[2]=='integration_list' || functionname[2]=='single_login_details' || functionname[2]=='api_integration' || functionname[2]=='module_details' || (functionname[2]=='filter_ticket' && functionname[4] ==21) || (functionname[2]=='view_sentmail' && functionname[4] ==1) || (functionname[2]=='new_integration' && functionname[4] ==1) || (functionname[2]=='new_integration' && functionname[4] ==10) || (functionname[2]=='new_integration' && functionname[4] ==29) || (functionname[2]=='integration_update' && functionname[4] ==16)){
			$("#vh-helps").attr('data-modal-arguments','vis_module=staff&vis_operation=get_help_doc&vis_doc_id='+functionname[2]+'&vis_integration_doc='+functionname[4]);
			} else if(functionname[1]=='billing' && functionname[2] =='quick_view')
			{
			$("#vh-helps").attr('data-modal-arguments','vis_module=staff&vis_operation=get_help_doc&vis_doc_id=Summary');	
			}
			else if(functionname[2]=='report_list' && functionname[4] =='Reports?&show_report=2')
			{
			$("#vh-helps").attr('data-modal-arguments','vis_module=staff&vis_operation=get_help_doc&vis_doc_id=all_report');	
			}
			else if(functionname[2]=='graphical_report')
			{
			$("#vh-helps").attr('data-modal-arguments','vis_module=staff&vis_operation=get_help_doc&vis_doc_id='+functionname[2]+functionname[4]);	
			}
			else if(functionname[2]=='integration_update')
			{   
			var type = document.getElementById("vis_type").value;
			$("#vh-helps").attr('data-modal-arguments','vis_module=staff&vis_operation=get_help_doc&vis_doc_id='+functionname[2]+'&vis_integration_doc='+type);
			}
			else{
			$("#vh-helps").attr('data-modal-arguments','vis_module=staff&vis_operation=get_help_doc&vis_doc_id='+functionname[2]);
			}
			}	
		</script>
		<?php if($show_help==1 || !isset($show_help)) { ?>
		<li id="">
			<a id="vh-helps"  title="<? echo 'Help'; ?>" href="javascript:void(0);" onclick="gethelppopup();">
				<i class="vh vh-question vh-lg"></i>
			</a>
		</li>
		<?php } ?>
	</ul>
</div>
<script>
<?php if($forward_details==-1 || $forward_details[0]['forward_number']==''){?>
	$("#vis_twilio_forward_to_details").hide();
<?php }?>
/*$('#vis_global_searchbar').keyup(function(e){
    if(e.keyCode == 13)
    {
        var search_string = $("#vis_global_searchbar").val();
        $.post("index.php?vis_module=staff&vis_operation=search_global&vis_tmpst="+new Date().getTime(), { 'vis_data': search_string }, function(data) {
            $("#vis_global_searchbar").parent().addClass('open');
            $('#search_result').show().html(data);
												$('#search_result').append('<input type="hidden" id="vis_global_searchbarn" value="0">');
        });
    }
});*/

//new code module id:- 1 ticket,2 client, 3 solution,4 forums, 5 organization, 6 Problems, 7 release, 8 change
$('#vis_global_searchbar').keypress(function(e){

var data='<div><section class="bg-white"><input type="hidden" id="vis_global_searchbarn" value="0" >';
data +='<div class="col-md-6 col-sm-6 m-b-sm"><div class="m-b-sm media list-group-item modulesearch" id="1" ><div class="media-body block m-b-none searchitemd" id="ticketm"><i id="ticketm1" class="vh vh-ticket vh-brown vh-lg m-r-sm"></i> <?= $vis_language['TXTTICKETS']; ?></div></div></div>';


data +='<div class="col-md-6 col-sm-6 m-b-sm"><div class="m-b-sm media list-group-item modulesearch" id="2" ><div class="media-body block m-b-none searchitemd" id="clientm"> <i  id="clientm1" class="vh vh-client vh-brown vh-lg m-r-sm"></i> <?= $vis_language['TXTCLIENT']; ?></div></div></div>';

data +='<div class="col-md-6 col-sm-6 m-b-sm"><div class="m-b-sm media list-group-item modulesearch" id="5" ><div class="media-body block m-b-none searchitemd" id="organizationm"> <i id="organizationm1" class="vh vh-organisation vh-brown vh-lg m-r-sm"></i> <?= $vis_language['TXTORGANIZATION']; ?></div></div></div>';

<? if(isset($module['solutions']) && $module['solutions']==1 && VIS_MODULE_ACCESS_SELFHELP==1){?>
data +='<div class="col-md-6 col-sm-6 m-b-sm"><div class="media list-group-item modulesearch" id="3" ><div class="media-body block m-b-none searchitemd" id="solutionm"> <i id="solutionm1" class="vh vh-self-help vh-red vh-lg m-r-sm"></i> <?= $vis_language['TXTSELFHELP']; ?></div></div></div>';
<? }?>

<? if(isset($module['forums']) && $module['forums']==1 && VIS_MODULE_ACCESS_FORUMS==1) {?>
data +='<div class="col-md-6 col-sm-6 m-b-sm"><div class="media list-group-item modulesearch" id="4" ><div class="media-body block m-b-none searchitemd" id="forumm"> <i id="forumm1" class="vh vh-staff-group vh-green vh-lg m-r-sm"></i> <?= $vis_language['TXTFORUMS']; ?></div></div></div>';
<? }?>


<? if(VIS_ITIL==1 && (isset($module['itil']) && $module['itil']==1)){?>
data +='<div class="col-md-6 col-sm-6 m-b-sm"><div class="media list-group-item modulesearch" id="6" ><div class="media-body block m-b-none searchitemd" id="problemsm"> <i id="problemsm1" class="vh vh-problem-management vh-red vh-lg m-r-sm"></i> <?= $vis_language['TXTPROBLEMS']; ?></div></div></div>';

data +='<div class="col-md-6 col-sm-6 m-b-sm"><div class="media list-group-item modulesearch" id="8" ><div class="media-body block m-b-none searchitemd" id="changem"> <i id="changem1" class="vh vh-change-management vh-brown vh-lg m-r-sm"></i> <?= $vis_language['TXTCHANGES']; ?></div></div></div>';

data +='<div class="col-md-6 col-sm-6 m-b-sm"><div class="media list-group-item modulesearch" id="7" ><div class="media-body block m-b-none searchitemd" id="releasem"> <i id="releasem1" class="vh vh-release-management vh-green vh-lg m-r-sm"></i> <?= $vis_language['TXTRELEASES']; ?></div></div></div>';


<? }?>

<? if(isset($module['drive']) && $module['drive']==1 && VIS_MODULE_ACCESS_SELFHELP==1){?>
//data +='<div class="col-md-6 col-sm-6 m-b-sm"><div class="media list-group-item modulesearch" id="9" ><div class="media-body block m-b-none searchitemd" id="solutionm"> <i id="solutionm1" class="vh vh-my-drive vh-lg m-r-sm"></i> <?//= $vis_language['TXTSELFHELP']; ?></div></div></div>';
<? }?>

data +='<div class="col-md-12 col-sm-12 m-b-sm text-right"><a href="#/ticket/ticket_search/Search" class="link"><span class="media-body block m-b-none"><?= $vis_language['TXTADVANCEDSEARCH'];?></span></a></div><div class="clearfix"></div></section></div>';

$("#vis_global_searchbar").parent().addClass('open');
$(this).parent().addClass('searchbgli');
$('#vis_global_searchbar').addClass('focusonsearch');
$('#search_result').show().html(data);
});

function backtosearch(){
	var search_string = $('#vis_global_searchbar').val(); 
	var data='<div><section class="bg-white"><input type="hidden" id="vis_global_searchbarn" value="'+search_string+'" >';
	data +='<div class="col-md-6 col-sm-6 m-b-sm"><div class="m-b-sm media list-group-item modulesearch" id="1" ><div class="media-body block m-b-none searchitemd" id="ticketm"><i id="ticketm1" class="vh vh-ticket vh-brown vh-lg m-r-sm"></i> <?= $vis_language['TXTTICKETS']; ?></div></div></div>';

data +='<div class="col-md-6 col-sm-6 m-b-sm"><div class="m-b-sm media list-group-item modulesearch" id="2" ><div class="media-body block m-b-none searchitemd" id="clientm"> <i  id="clientm1" class="vh vh-client vh-brown vh-lg m-r-sm"></i> <?= $vis_language['TXTCLIENT']; ?></div></div></div>';

data +='<div class="col-md-6 col-sm-6 m-b-sm"><div class="m-b-sm media list-group-item modulesearch" id="5" ><div class="media-body block m-b-none searchitemd" id="organizationm"> <i id="organizationm1" class="vh vh-organisation vh-brown vh-lg m-r-sm"></i> <?= $vis_language['TXTORGANIZATION']; ?></div></div></div>';

<? if(isset($module['solutions']) && $module['solutions']==1 && VIS_MODULE_ACCESS_SELFHELP==1){?>
data +='<div class="col-md-6 col-sm-6 m-b-sm"><div class="media list-group-item modulesearch" id="3" ><div class="media-body block m-b-none searchitemd" id="solutionm"> <i id="solutionm1" class="vh vh-self-help vh-red vh-lg m-r-sm"></i> <?= $vis_language['TXTSELFHELP']; ?></div></div></div>';
<? }?>

<? if(isset($module['forums']) && $module['forums']==1 && VIS_MODULE_ACCESS_FORUMS==1) {?>
data +='<div class="col-md-6 col-sm-6 m-b-sm"><div class="media list-group-item modulesearch" id="4" ><div class="media-body block m-b-none searchitemd" id="forumm"> <i id="forumm1" class="vh vh-staff-group vh-green vh-lg m-r-sm"></i> <?= $vis_language['TXTFORUMS']; ?></div></div></div>';
<? }?>


<? if(VIS_ITIL==1 && (isset($module['itil']) && $module['itil']==1)){?>
data +='<div class="col-md-6 col-sm-6 m-b-sm"><div class="media list-group-item modulesearch" id="6" ><div class="media-body block m-b-none searchitemd" id="problemsm"> <i id="problemsm1" class="vh vh-problem-management vh-red vh-lg m-r-sm"></i> <?= $vis_language['TXTPROBLEMS']; ?></div></div></div>';

data +='<div class="col-md-6 col-sm-6 m-b-sm"><div class="media list-group-item modulesearch" id="8" ><div class="media-body block m-b-none searchitemd" id="changem"> <i id="changem1" class="vh vh-change-management vh-brown vh-lg m-r-sm"></i> <?= $vis_language['TXTCHANGES']; ?></div></div></div>';

data +='<div class="col-md-6 col-sm-6 m-b-sm"><div class="media list-group-item modulesearch" id="7" ><div class="media-body block m-b-none searchitemd" id="releasem"> <i id="releasem1" class="vh vh-release-management vh-green vh-lg m-r-sm"></i> <?= $vis_language['TXTRELEASES']; ?></div></div></div>';


<? }?>
<? if(isset($module['drive']) && $module['drive']==1 && VIS_MODULE_ACCESS_SELFHELP==1){?>
//data +='<div class="col-md-6 col-sm-6 m-b-sm"><div class="media list-group-item modulesearch" id="9" ><div class="media-body block m-b-none searchitemd" id="drivem"> <i id="drivem1" class="vh vh-my-drive vh-lg m-r-sm"></i> <?//= $vis_language['TXTSELFHELP']; ?></div></div></div>';
<? }?>

data +='<div class="col-md-12 col-sm-12 m-b-sm text-right"><a href="#/ticket/ticket_search/Search" class="link"><span class="media-body block m-b-none"><?= $vis_language['TXTADVANCEDSEARCH'];?></span></a></div><div class="clearfix"></div></section></div>';
$('#search_result').show().html(data);	
}

$('#vis_global_searchbar').focusout(function(e){ 
var search_string = $(this).val(); 
$('#vis_global_searchbarn').val(search_string);

if(search_string==''){
$("#vis_global_searchbar").parent().removeClass('searchbgli');
}
});



$(document).on('click', '.modulesearch', function(e){
	var moduleid=parseInt($(this).attr('id'));
	// var search_string = $("#vis_global_searchbarn").val();
	 var search_string = $("#vis_global_searchbar").val();
		//alert(search_string+'---'+moduleid);
		if(moduleid <=0){ return false;}
        $.post("index.php?vis_module=staff&vis_operation=search_global&vis_tmpst="+new Date().getTime(), { 'vis_data': search_string, 'vis_srmodule': moduleid }, function(data) {
            $("#vis_global_searchbar").parent().addClass('open');
            $('#search_result').show().html(data);
												$('#search_result').append('<input type="hidden" id="vis_global_searchbarn" value="0">');
								});
});

//end new code

function remove_twilio_forward(){
	var data = {'vis_remove_forward':1};
	$.ajax({
		url: 'index.php?vis_module=voip&vis_operation=remove_twilio_forward',
		data: data,
		type: "POST",
		dataType: "json",
		success: function(data) {
			if(data.status=='success'){
				$("#vis_global_msg_div").visInterface("load_global_message", "<?=$vis_language['MSGSUCCOPRT']?>");
				$("#vis_twilio_forward_to_details").hide();
				if(data.color=='red'){
					$("#call_color_icon").html('<span class="vh-call-box red"></span>');
				}if(data.color=='green'){
					$("#call_color_icon").html('<span class="vh-call-box green"></span>');
				}if(data.color=='yellow'){
					$("#call_color_icon").html('<span class="vh-call-box yellow"></span>');
				}
			}else{
				$("#vis_global_msg_div").visInterface("load_global_message", "<?=$vis_language['MSGERROPRT']?>");
			}
		},
		error: function(xhr, ajaxOptions, thrownError) {$("#vis_global_msg_div").visInterface("load_global_message", "Error: "+xhr.status+" - "+thrownError);}
	});
}
function update_twilio_staff_status(id){
	var data = {'vis_status':id};
	$.ajax({
		url: 'index.php?vis_module=voip&vis_operation=update_twilio_staff_status',
		data: data,
		type: "POST",
		dataType: "json",
		success: function(data) {
			if(data.status=='success'){
				$("#vis_global_msg_div").visInterface("load_global_message", "<?=$vis_language['MSGSUCCOPRT']?>");
				if(data.color=='red'){
					$("#call_color_icon").html('<span class="vh-call-box red"></span>');
				}if(data.color=='green'){
					$("#call_color_icon").html('<span class="vh-call-box green"></span>');
				}if(data.color=='yellow'){
					$("#call_color_icon").html('<span class="vh-call-box yellow"></span>');
				}
			}else{
				$("#vis_global_msg_div").visInterface("load_global_message", "<?=$vis_language['MSGERROPRT']?>");
			}
			
		},
		error: function(xhr, ajaxOptions, thrownError) {$("#vis_global_msg_div").visInterface("load_global_message", "Error: "+xhr.status+" - "+thrownError);}
	});
}
function help_toggle(){
	$('#help_doc').toggle();
}

</script>


