<? global $vis_language;

$tp=0;
if(!isset($module_setting1['vis_show_priority']) || $module_setting1['vis_show_priority']==1 || $module_setting1['vis_show_priority']==2){
	$module_setting1['vis_priority']='';
}
if(!isset($module_setting1['vis_show_tickettype']) || $module_setting1['vis_show_tickettype']==1 || $module_setting1['vis_show_tickettype']==2){
	$module_setting1['vis_tickettype']='';
}
if(isset($module_setting1['vis_show_level']) && ($module_setting1['vis_show_level']==1 || $module_setting1['vis_show_level']==2)){
	$tp++;
	$module_setting1['vis_level']='';
}
if(isset($module_setting1['vis_show_category']) && ($module_setting1['vis_show_category']==1 || $module_setting1['vis_show_category']==2)){
	$tp++;
	$module_setting1['vis_category']='';
	if(isset($module_setting1['vis_show_subcategory']) && ($module_setting1['vis_show_subcategory']==1 || $module_setting1['vis_show_subcategory']==2)){
		$tp++;
		$module_setting1['vis_subcategory']='';
		if(isset($module_setting1['vis_show_item']) && ($module_setting1['vis_show_item']==1 || $module_setting1['vis_show_item']==2)){
			$tp++;
			$module_setting1['vis_item']='';
		}
	}
}
if($itil_enabled==1)$tp++;
if($tp<5){$divorspan="span";$class_properties='class="col-sm-3"';
}else{
	$divorspan="div";$class_properties='class="col-sm-2"';
}
$show_pause=0;
$due_flag =($ticket_details['pause_dtime']!='')? $ticket_details['pause_dtime']:'';
$resolution_flag = ($ticket_details['pause_rtime']!='') ? $ticket_details['pause_rtime']:'';
?>
<div class="row">
	<div class="form-group m-b-none">
		<div class="col-sm-2">
			<label class="control-label m-l-sm font-bold"><? echo $vis_language['TXTDEPARTMENT']; ?></label>
			<div id="department">
                <button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="<? if(VIS_DEPARTMENT_ACCESS!=0){ ?>$('#department').visExecution('load_area', {'vis_module': 'ticket', 'vis_operation': 'load_lists', 'vis_action': 'department', 'vis_ticket_id': <?= $operation['vis_ticket_id']?>, 'vis_selected_id': <?= $ticket_details['department_id']; ?>, 'vis_domain_id': <?= $ticket_details['domain_id']; ?>});<? } else{ ?>$('#vis_global_msg_div').visInterface('load_global_message', '<?= $vis_language['MSGACCSSDND']; ?>');<? } ?>"><span class="filter-option pull-left"><?= $ticket_details['domain_name'].' : '.$ticket_details['department_name']; ?>&nbsp;</span><span class="caret"></span></button>
			</div>
		</div>
		<div class="col-sm-2">
			<label class="control-label m-l-sm font-bold"><? echo $vis_language['TXTSTATUS']; ?></label>
			<div id="status">
                <button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="<? if(VIS_STATUS_ACCESS!=0){ ?>$('#status').visExecution('load_area', {'vis_module': 'ticket', 'vis_operation': 'load_lists', 'vis_action': 'status', 'vis_ticket_id': <?= $operation['vis_ticket_id']?>, 'vis_selected_id': <?= $ticket_details['status_id']; ?>, 'vis_domain_id': <?= $ticket_details['domain_id']; ?>, 'vis_dept_id': <?= $ticket_details['department_id']; ?>});<? } else{ ?>$('#vis_global_msg_div').visInterface('load_global_message', '<?= $vis_language['MSGACCSSDND']; ?>');<? } ?>"><span class="filter-option pull-left"  style="color:<?= $ticket_details['status_color']; ?>" ><?=  $text=wordwrap($ticket_details['ticket_status'],20, "<br />\n"); ?>&nbsp;</span><span class="caret"></span></button>
			</div>
		</div>
		<?php if(isset($module_setting1['vis_priority'])){?>
			<div class="col-sm-2">
				<label class="control-label m-l-sm font-bold"><? echo $vis_language['TXTPRIORITY']; ?></label>
				<div id="priority">
					<button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="<? if(VIS_PRIORITY_ACCESS!=0){ ?>$('#priority').visExecution('load_area', {'vis_module': 'ticket', 'vis_operation': 'load_lists', 'vis_action': 'priority', 'vis_ticket_id': <?= $operation['vis_ticket_id']?>, 'vis_selected_id': <?= $ticket_details['priority_id']; ?>, 'vis_domain_id': <?= $ticket_details['domain_id']; ?>, 'vis_dept_id': <?= $ticket_details['department_id']; ?>});<? } else{?>$('#vis_global_msg_div').visInterface('load_global_message', '<?= $vis_language['MSGACCSSDND']; ?>');<? } ?>"><span class="filter-option pull-left" style="color:<?= $ticket_details['priority_color']; ?>" ><?= 
$priority_text=wordwrap($ticket_details['ticket_priority'],20, "<br />\n"); ?>&nbsp;</span><span class="caret"></span></button>
				</div>
			</div>
		<?php }
		if(isset($module_setting1['vis_tickettype'])){?>
			<div class="col-sm-2">
				<label class="control-label m-l-sm font-bold"><? echo $vis_language['TXTTYPE']; ?></label>
				<div id="type">
					<button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="<? if(VIS_TYPE_ACCESS!=0){ ?>$('#type').visExecution('load_area', {'vis_module': 'ticket', 'vis_operation': 'load_lists', 'vis_action': 'type', 'vis_ticket_id': <?= $operation['vis_ticket_id']?>, 'vis_selected_id': <?= $ticket_details['type_id']; ?>, 'vis_domain_id': <?= $ticket_details['domain_id']; ?>, 'vis_dept_id': <?= $ticket_details['department_id']; ?>});<? } else{?>$('#vis_global_msg_div').visInterface('load_global_message', '<?= $vis_language['MSGACCSSDND']; ?>');<? } ?>"><span class="filter-option pull-left"><?= $type_text=wordwrap($ticket_details['ticket_type'],20, "<br />\n"); ?>&nbsp;</span><span class="caret"></span></button>
				</div>
			</div>
		<?php }?>
		<div class="col-sm-2">
			<label class="control-label m-l-sm font-bold"><? echo $vis_language['TXTFLAG']; ?></label>
			<div id="flag">	
                <button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="<? if(VIS_FLAG_ACCESS!=0){ ?>$('#flag').visExecution('load_area', {'vis_module': 'ticket', 'vis_operation': 'load_lists', 'vis_action': 'flag', 'vis_ticket_id': <?= $operation['vis_ticket_id']?>, 'vis_selected_id': <?= $ticket_details['flag_id']; ?>, 'vis_domain_id': <?= $ticket_details['domain_id']; ?>, 'vis_dept_id': <?= $ticket_details['department_id']; ?>});<? } else{?>$('#vis_global_msg_div').visInterface('load_global_message', '<?= $vis_language['MSGACCSSDND']; ?>');<? } ?>"><span class="filter-option pull-left"><span class="vh-stack pull-right"><i class="vh vh-flag-inner vh-stack-lg" style="color:<?= $ticket_details['flag_color'];?>"></i><i class="vh vh-flag-empty vh-stack-lg"></i></span></span><span class="caret"></span></button>
			</div>
		</div>
		<div class="col-sm-2">
            <div id="owner">
                <button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="<? if(VIS_STAFF_ACCESS!=0){ ?>$('#owner').visExecution('load_area', {'vis_module': 'ticket', 'vis_operation': 'load_lists', 'vis_action': 'owner', 'vis_ticket_id': <?= $operation['vis_ticket_id']?>,  'vis_domain_id': <?= $ticket_details['domain_id']; ?>, 'vis_department_id': <?= $ticket_details['department_id']; ?>});<? } else{?>$('#vis_global_msg_div').visInterface('load_global_message', '<?= $vis_language['MSGACCSSDND']; ?>');<? } ?>"><span class="filter-option pull-left"><?= $vis_language['TXTASSIGNEDTO']; ?>&nbsp;</span><span class="caret"></span></button>
            </div>
                <?  $owner1 = $vis_language['TXTUNASSIGNED'];
                    $owner_cnt = (!empty($owner_details) && $owner_details != -1) ? count($owner_details) : 0;
                        if ($owner_details != -1 ) {
                            foreach ($owner_details as $owner) {
                            if ($owner1 == $vis_language['TXTUNASSIGNED']) {
                                $owner1 = $owner['first_name'] . ' ' . $owner['last_name'];
                            }
                        }
                        } ?>
            </select>
            <div><? if ($owner_cnt > 1) { ?>
                <span class="m-l-sm text-sm"><? echo $vis_language['TXTMULTIPLEOWNERS'];?></span>
                <? } else { ?>
                <span class="m-l-sm text-sm"><? echo $owner1;?></span>
                <? } ?>
            </div>
		</div>
        
	</div>
</div>
<? if ($owner_cnt > 1) { ?>
<div class="wrapper-sm m-b-none m-t-xs" id="vis_assigned_to_<?= $ticket_details['ticket_id'];?>">		
	<div class="row">			
		<div class="form-group clear m-b-xs m-t-xs">
			<? include(VIS_PATH_TEMPLATE."assigned_owner_list.php");?>
		</div>
	</div>
</div>
<? } ?>
<div class="wrapper-sm<? if(isset($owner_cnt) && $owner_cnt <= 1) { echo ' m-t'; }?> b m-b-none vis_new m-b">
	<div class="row">
		<div class="col-sm-3 m-t-xs">
			<label><? echo $vis_language['TXTSLAPLAN']?></label>
			<span class="label vh-green-bg m-l-xs"><? echo ($ticket_details['slaplan_id'] > 0) ? $ticket_details['sla_name'] : (($ticket_details['slaplan_id'] == 0 && $ticket_details['rdue_time'] > 0 || $ticket_details['sdue_time'] > 0) ? $vis_language['TXTCUSTDUETIME'] : $vis_language['TXTNONE']);?></span>
		</div>
		<div class="col-sm-3 m-t-xs">
			<label><? echo $vis_language['TXTDUETIME']?></label>
			<? if($due_flag!='')echo (is_numeric($due_flag))?'<span class="vh-green m-l-sm"><i class="vh vh-clock"></i> '.count_remain_time($due_flag) : '<span class="m-l-sm"><i class="vh vh-clock"></i> '.$due_flag;
			elseif($ticket_details['due_time']<=0 && $ticket_details['user_replied']==1 && $ticket_details['status_id']!=3 && $ticket_details['sdue_time']!=0) echo '<span class="m-l-sm vh-danger"><i class="vh vh-clock"></i> '.$vis_language['TXTOVERDUE']; elseif($ticket_details['due_time']>0 && $ticket_details['user_replied']==1 && $ticket_details['status_id']!=3) {$show_pause=1;echo '<span class="vh-green m-l-sm"><i class="vh vh-clock"></i> '.count_remain_time($ticket_details['due_time']);} else echo '<span class="m-l-sm"><i class="vh vh-clock"></i> '.$vis_language['TXTUNDUE']; ?> </span>
		</div>
		<div class="col-sm-3 m-t-xs">
			<label><? echo $vis_language['TXTRESOLUTIONTIME']; ?></label>
			 <? if($resolution_flag!='')echo (is_numeric($resolution_flag))?'<span class="vh-green m-l-sm"><i class="vh vh-clock"></i> '.count_remain_time($resolution_flag) : '<span class="m-l-sm"><i class="vh vh-clock"></i> '.$resolution_flag;
			elseif($ticket_details['resolution_time']<=0 && $ticket_details['status_id']!=3 && $ticket_details['rdue_time']!=0) echo '<span class=" m-l-sm vh-danger"><i class="vh vh-clock"></i> '.$vis_language['TXTOVERDUE']; elseif($ticket_details['resolution_time']>0 && $ticket_details['status_id']!=3) {$show_pause=1;echo '<span class="vh-green m-l-sm"><i class="vh vh-clock"></i> '.count_remain_time(($ticket_details['resolution_time']));} else echo '<span class="m-l-sm"><i class="vh vh-clock"></i> '.$vis_language['TXTUNDUE']; ?></span>
		</div>
		<?php if($resolution_flag!='' || $due_flag!=''){?>
			<div class="col-sm-3 m-t-xs">
				<a class="link pull-right" href="javascript:void(0)" onclick="$('#vis_global_msg_div').visExecution('load_operations',{'vis_module':'ticket', 'vis_operation':'resume_ticket_sla','vis_ticket_id':'<?= $ticket_details['ticket_id']?>'});"><i class="vh vh-stopwatch"></i> <? echo $vis_language['TXTRESUMESLA']; ?></a>
			</div>
		<?php }else if($show_pause==1){?>
			<div class="col-sm-3 m-t-xs">
				<a class="link  pull-right" href="javascript:void(0)" onclick="$('#vis_global_msg_div').visExecution('load_operations',{'vis_module':'ticket', 'vis_operation':'pause_ticket_sla','vis_ticket_id':'<?= $ticket_details['ticket_id']?>'});"><i class="vh vh-stopwatch"></i> <? echo $vis_language['TXTPAUSESLA'];?></a>
			</div>
		<?php }?>
		<!--<div class="col-sm-3 m-t-xs">
			<ul class="navSeprator no-padder m-n">
				<li><a id="toggle_recipients_people" href="javascript:void(0);" onclick="toggle_recipients_people();" class="link m-l-xs"><?= $vis_language['TXTSHOWRECIPIENTNPEOPLE']?></a></li>
				<li id="show_vis_ticket_tags"<? if($tag_details!=-1) echo ' style="display:none";'?>><a href="javascript:void(0);" onclick="$('#vis_ticket_tags').show();" class="link"><?= $vis_language['TXTADDTAG']?></a></li>
			</ul>
		</div>-->
	</div>
</div>

<?php  if($total_approvals>0){ ?>
<div class="wrapper-sm<? if(isset($owner_cnt) && $owner_cnt <= 1) { echo ' m-t'; }?> b m-b-none vis_new m-b">
					<div class="row">
					<? //THIS ONE FOR TICKET APPROVALS STARTS ?>

					<? //THIS ONE FOR SEND APPROVAL LABLE STRATS?>

					<div class="col-sm-4 m-t-xs">
					<label><? echo $vis_language['TXTAPPROVALSTATUS'];?></label>
					</div>

					<? //THIS ONE FOR SEND APPROVAL LABLE ENDS ?>

					<div class="col-sm-4 m-t-xs">
					<label></label>
					<span class="m-l-xs" id="">
					<?php if($single_details[0]['approvals_status']==0 && $single_details!=-1){ 
					if($single_details[0]['staff_id']==VIS_STAFF_ID){?>
					<a class="link"  href="javascript:void(0);" onclick="change_status(<? echo $single_details[0]['approvals_id'].', 1, '.$single_details[0]['staff_id'];?>);" title="<? echo $vis_language['TXTAPPROVE']; ?>"><?= $vis_language['TXTAPPROVE'];?></a> / 

					<a class="link"  href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=ticket&vis_operation=reject_approvals&from=ticket&vis_ticket_id=<? echo $ticket_details['ticket_id'];?>&vis_approvals_id=<? echo $single_details[0]['approvals_id'];?>" title="<? echo $vis_language['TXTITILREJECT']; ?>"><?= $vis_language['TXTITILREJECT'];?></a>
					<?php }
					}?></span>
					</div>



					<div class="col-sm-4 m-t-xs">
					<label><? echo $vis_language['TXTAPPROVALSTATUS'].'  ';?>  </label>
					<? if($approvals_status==-1) echo '<span class="label m-l-xs label-default">'.$vis_language['TXTNOTREQUESTED'].'</span>';
					if($approvals_status==0) echo '<span class="label m-l-xs label-default">'.$vis_language['TXTREQUESTED'].'</span>';
					if($approvals_status==1)echo '<span class="label m-l-xs vh-green-bg">'.$vis_language['TXTAPPROVED'].'</span>';
					if($approvals_status==2) echo '<span class="label m-l-xs label-default">'.$vis_language['TXTCANCELED'].'</span>';
					if($approvals_status==3) echo '<span class="label m-l-xs vh-red-bg">'.$vis_language['TXTREJECTED'].'</span>';
					?>
					</div>

					<? //THIS ONE FOR TICKET APPROVALS ENDS ?>
					</div>
	</div>
 <? }?>
<?php if($tp>0){?>
<div class="row">
	<div class="form-group m-b-none">
		<?php if(isset($module_setting1['vis_level'])){?>
			<div <?=$class_properties?>>
				
				<label class="control-label m-l-sm font-bold"><? echo $vis_language['TXTTICKETLEVEL']; ?></label>
				<<?=$divorspan?> id="level">
					<button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="<? if(VIS_TICKET_LEVEL_ACCESS!=0){ ?>$('#level').visExecution('load_area', {'vis_module': 'ticket', 'vis_operation': 'load_lists', 'vis_action': 'level', 'vis_ticket_id': <?= $operation['vis_ticket_id']?>, 'vis_selected_id': <?= ($ticket_details['ticket_level']=='')?0:$ticket_details['level_id']; ?>, 'vis_domain_id': <?= $ticket_details['domain_id']; ?>, 'vis_dept_id': <?= $ticket_details['department_id']; ?>});<? } else{?>$('#vis_global_msg_div').visInterface('load_global_message', '<?= $vis_language['MSGACCSSDND']; ?>');<? } ?>"><span class="filter-option pull-left"><?= ($ticket_details['ticket_level']=='')?$vis_language['TXTSELECT']:$ticket_details['ticket_level']; ?>&nbsp;</span><span class="caret"></span></button>
				</<?=$divorspan?>>
			</div>
		<?php }
		if(isset($module_setting1['vis_category'])){?>
			<div <?=$class_properties?>>
				<label class="control-label m-l-sm font-bold"><? echo $vis_language['TXTTICKETCATEGORY']; ?></label>
				<<?=$divorspan?> id="ticket_category">
					<button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="<? if(VIS_TICKET_CATEGORY_ACCESS!=0){ ?>$('#ticket_category').visExecution('load_area', {'vis_module': 'ticket', 'vis_operation': 'load_lists', 'vis_action': 'ticket_category', 'vis_ticket_id': <?= $operation['vis_ticket_id']?>, 'vis_selected_id': <?= ($ticket_details['ticket_category']=='')?0:$ticket_details['category_id']; ?>, 'vis_domain_id': <?= $ticket_details['domain_id']; ?>, 'vis_dept_id': <?= $ticket_details['department_id']; ?>});<? } else{ ?>$('#vis_global_msg_div').visInterface('load_global_message', '<?= $vis_language['MSGACCSSDND']; ?>');<? } ?>"><span class="filter-option pull-left"><?= ($ticket_details['ticket_category']=='')?$vis_language['TXTSELECT']:$ticket_details['ticket_category']; ?>&nbsp;</span><span class="caret"></span></button>
				</<?=$divorspan?>>
			</div>
		<?php }
		if(isset($module_setting1['vis_subcategory'])){?>
			<div <?=$class_properties?>>
				<label class="control-label m-l-sm font-bold"><? echo $vis_language['TXTTICKETSUBCATEGORY']; ?></label>
				<<?=$divorspan?> id="ticket_subcateogy">
					<button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="<? if(VIS_TICKET_CATEGORY_ACCESS!=0){ ?>$('#ticket_subcateogy').visExecution('load_area', {'vis_module': 'ticket', 'vis_operation': 'load_lists', 'vis_action': 'ticket_subcateogy', 'vis_ticket_id': <?= $operation['vis_ticket_id']?>, 'vis_selected_id': <?= ($ticket_details['ticket_sub_cateogy']=='')?0:$ticket_details['subcategory_id']; ?>, 'vis_category_id': <?= $ticket_details['category_id']; ?>, 'vis_domain_id': <?= $ticket_details['domain_id']; ?>, 'vis_dept_id': <?= $ticket_details['department_id']; ?>});<? } else{?>$('#vis_global_msg_div').visInterface('load_global_message', '<?= $vis_language['MSGACCSSDND']; ?>');<? } ?>"><span class="filter-option pull-left"><?= ($ticket_details['ticket_sub_cateogy']=='')?$vis_language['TXTSELECT']:$ticket_details['ticket_sub_cateogy']; ?>&nbsp;</span><span class="caret"></span></button>
				</<?=$divorspan?>>
			</div>
		<?php }
		if(isset($module_setting1['vis_item'])){?>
			<div <?=$class_properties?>>
				<label class="control-label m-l-sm font-bold"><? echo $vis_language['TXTTICKETITEM']; ?></label>
				<<?=$divorspan?> id="ticket_item">
					<button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="<? if(VIS_TICKET_CATEGORY_ACCESS!=0){ ?>$('#ticket_item').visExecution('load_area', {'vis_module': 'ticket', 'vis_operation': 'load_lists', 'vis_action': 'ticket_item', 'vis_ticket_id': <?= $operation['vis_ticket_id']?>, 'vis_selected_id': <?= ($ticket_details['ticket_item']=='')?0:$ticket_details['item_id']; ?>, 'vis_subcategory_id': <?= $ticket_details['subcategory_id']; ?>, 'vis_domain_id': <?= $ticket_details['domain_id']; ?>, 'vis_dept_id': <?= $ticket_details['department_id']; ?>});<? } else{?>$('#vis_global_msg_div').visInterface('load_global_message', '<?= $vis_language['MSGACCSSDND']; ?>');<? } ?>"><span class="filter-option pull-left"><?= ($ticket_details['ticket_item']=='')?$vis_language['TXTSELECT']:$ticket_details['ticket_item']; ?>&nbsp;</span><span class="caret"></span></button>
				</<?=$divorspan?>>
			</div>
		<?php }
		if($itil_enabled==1){if(isset($module_setting1['vis_assets_location'])){ ?>
		<div <?=$class_properties?>>
			<label class="control-label m-l-sm font-bold"><? echo $vis_language['TXTLOCATION']; ?></label>
			<<?=$divorspan?> id="assets_location">	
                <button data-toggle="dropdown" class="btn bg-empty btn-sm dropdown-toggle action_btn bg-white" type="button" onclick="<? if(VIS_TICKET_LOCATION_ACCESS!=0){ ?>$('#assets_location').visExecution('load_area', {'vis_module': 'ticket', 'vis_operation': 'load_lists', 'vis_action': 'assets_location', 'vis_ticket_id': <?= $operation['vis_ticket_id']?>, 'vis_selected_id': <?= $ticket_details['location_id']; ?>, 'vis_domain_id': <?= $ticket_details['domain_id']; ?>, 'vis_dept_id': <?= $ticket_details['department_id']; ?>});<? } else{?>$('#vis_global_msg_div').visInterface('load_global_message', '<?= $vis_language['MSGACCSSDND']; ?>');<? } ?>"><span class="filter-option pull-left"><?= ($ticket_details['assets_location']=='')?$vis_language['TXTSELECT']:$ticket_details['assets_location']; ?>&nbsp;</span><span class="caret"></span></button>
			</<?=$divorspan?>>
		</div>
		<?php }}?>
	</div>
</div><br>
<?php }?>
<?php if($itil_enabled==1){
if($service_ticket_details!=-1){?>
    <div class="btn-group">
        <button class="btn btn-default btn-xs btn-rounded" onclick="show_services(<?= $service_ticket_details[0]['service_item_id'];?>);"><? echo $vis_language['TXTITILSERVICEREQUEST']; ?></button>
    </div>
<? }?>
<div class="btn-group">    
    <button class="btn btn-default btn-xs btn-rounded" onclick="show_ci_cmdb(<? if($attach_ci_details!=-1) echo $attach_ci_details[0]['child_id']; else echo '0';?>);"><? echo $vis_language['TXTCI']; ?> (<? if(isset($attach_ci_details) && $attach_ci_details!=-1) echo count($attach_ci_details); else echo '0';?>)</button>
</div>
<div class="btn-group">    
    <button class="btn btn-default btn-xs btn-rounded" onclick="show_problem_cmdb(<? if($attach_problem_details!=-1) echo $attach_problem_details[0]['child_id']; else echo '0';?>);"><?= $vis_language['TXTPROBLEMS']; ?> (<? if(isset($attach_problem_details) && $attach_problem_details!=-1) echo '1'; else echo '0'; ?>)</button>
</div>
<div class="btn-group">
    <button class="btn btn-default btn-xs btn-rounded" onclick="show_changes_cmdb(<? if($attach_changes_details!=-1) echo $attach_changes_details[0]['child_id']; else echo '0';?>);"><? echo $vis_language['TXTCHANGES']; ?> (<? if(isset($attach_changes_details) && $attach_changes_details!=-1) echo '1'; else echo '0'; ?>)</button>
</div>
<?php } if(VIS_MODULE_ACCESS_TASK==1){?>
<div class="btn-group">
	<button class="btn btn-default btn-xs btn-rounded" onclick="show_ticket_task();"><? echo $vis_language['TXTTASKS'];?> (<? if(isset($attach_task_details) && $attach_task_details!=-1) echo count($attach_task_details); else echo '0'; ?>)</button>
</div><? } ?>
<? if($ticket_details['client_id'] > 0) {
		$recepients=explode(',', $ticket_details['recipients']); 
		$people=explode(',', $ticket_details['people']);  
		if($people[0]=='')$people=0; else $people=count($people); 
		if($recepients[0]=='')$recepients=''; else $recepients=count($recepients);?>
<div class="btn-group">    
    <button class="btn btn-default btn-xs btn-rounded" onclick="show_recipients();"><? echo $vis_language['TXTRECIPIENTNPEOPLE']; ?> (<span id="participient_count"><?= $recepients+$people;?></span>)</button>
</div>
<? }
if($tag_details!=-1) $tag_count=count($tag_details); else $tag_count=0;?>
<div class="btn-group">    
    <button class="btn btn-default btn-xs btn-rounded" onclick="show_tags();"><? echo $vis_language['TXTTAGS']; ?> (<span id="tags_count"><?= $tag_count;?></span>)</button>
</div>

<div class="btn-group">    
    <button class="btn btn-default btn-xs btn-rounded" onclick="show_approvals();"><? echo $vis_language['TXTAPPROVALS']; ?> (<span id="approval_count"><?= $total_approvals;?></span>)</button>
</div>

<div id="vis_ticket_task" class="wrapper-sm m-b-none" style="display:none;">	
</div>
<?php if($itil_enabled==1){
if(isset($service_ticket_details) && $service_ticket_details!=-1){?>
<div id="services_detail" class="wrapper-sm m-b-none m-t" style="display:none;">	
</div>
<?php }?>
<div id="vis_ci_cmdb" class="wrapper-sm m-b-none m-t" style="display:none;">
	<div class="row">
    	<div class="col-sm-12 m-t-xs">
			<label><? echo  $vis_language['TXTITILNOCIASSOCIATED'];?></label>
			<span class="m-l-sm"><a class="link"  href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=cmdb&vis_operation=attach_ci_cmdb&vis_ticket_id=<? echo $operation['vis_ticket_id'];?>&vis_domain_id=<? echo $ticket_details['domain_id'];?>&vis_dept_id=<? echo $ticket_details['department_id'];?>" title="<? echo $vis_language['TXTATTACHCI']; ?>"><?= $vis_language['TXTATTACHCI'];?></a></span>
	</div>	
	</div>
</div>
<div id="vis_problem_cmdb" class="wrapper-sm m-b-none m-t" style="display:none;">
	<div class="row">
   		<div class="col-sm-12 m-t-xs">
			<label><? echo  $vis_language['TXTITILNOPROBLEMLINKED'];?></label>
			<span class="m-l-sm"><a class="link"  href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=setting&vis_operation=attach_problem_cmdb&vis_ticket_id=<? echo $operation['vis_ticket_id'];?>&vis_domain_id=<? echo $ticket_details['domain_id'];?>&vis_dept_id=<? echo $ticket_details['department_id'];?>" title="<? echo $vis_language['TXTITILLINKPROBLEM']; ?>"><?= $vis_language['TXTITILLINKPROBLEM'];?></a></span>
      	</div>
	</div>
</div>
<div id="vis_changes_cmdb" class="wrapper-sm m-b-none m-t" style="display:none;">
	<div class="row">
  		<div class="col-sm-12 m-t-xs">
			<label><? echo  $vis_language['TXTITILNOCHANGESLINKED'];?></label>
			<span class="m-l-sm"><a class="link"  href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=changes&vis_operation=attach_changes_cmdb&vis_ticket_id=<? echo $operation['vis_ticket_id'];?>&vis_domain_id=<? echo $ticket_details['domain_id'];?>&vis_dept_id=<? echo $ticket_details['department_id'];?>" title="<? echo $vis_language['TXTITILLINKCHANGES']; ?>"><?= $vis_language['TXTITILLINKCHANGES'];?></a></span>
        </div>
	</div>
</div>
<?php }?>
<div class="wrapper-sm m-b-none m-t-xs" style="display:none;" id="vis_recipients_people">		
	<div class="row">			
		<div class="form-group clear m-b-xs m-t-xs" id="vis_recipients_<?= $ticket_details['ticket_id'] ?>">
			<? include(VIS_PATH_TEMPLATE."recipients_list.php");?>
		</div>
		<div class="form-group clear m-b-none m-t-sm" id="vis_peoples_<?= $ticket_details['ticket_id'] ?>">
			<? $is_people_set=1; include(VIS_PATH_TEMPLATE."peoples_list.php");?>
		</div>
	</div>
</div>
<div class="wrapper-sm m-b-none" style="display:none;" id="vis_ticket_tags">
	<div class="row">
		<div class="form-group clear m-b-none m-t-xs" id="vis_tags_<?= $ticket_details['ticket_id'] ?>">
			<? include(VIS_PATH_TEMPLATE."ticket_tags_list.php");?>
		</div>		
	</div>
</div>

<div class="wrapper-sm m-b-none" style="display:none;" id="vis_ticket_approvals">
	<div class="row">
		<div class="form-group clear m-b-none m-t-xs" id="vis_approvals_<?= $ticket_details['ticket_id'] ?>">
			<? include(VIS_PATH_TEMPLATE."ticket_approval_list.php");?>
		</div>		
	</div>
</div>

<? if($note_details != -1){
	include(VIS_PATH_TEMPLATE."ticket_note_details.php");
   } 
   if($custom_field_var!=-1){ ?>
       <section class="panel panel-default pos-rlt clearfix m-b-none m-t-sm" id="ticket_customfields">
			<div class="panel-heading b-b b-light" style="background-color:#eee;">
				<div class="clear">
					<div class="row">
						<div class="m-l pull-left">
							<label class="pull-left"><? echo $vis_language['TXTCUSTOMFIELDS']; ?></label>
						</div>
						<div class="pull-right m-r-lg">
                            <?  if($readonly==1 &&  $nodata !=1) { ?><a class="link" onclick="load_customfields_details();" href="javascript:void(0);"><?= $vis_language['TXTEDIT']; ?></a><? } ?>
						</div>
					</div>
				</div>
			</div>
			<div class="panel-collapse wrapper">
				<form class="form-horizontal" name="frm_edit_custom" id="frm_edit_custom" method="post"><?= $custom_field_var; ?></form>
			</div>			
		</section>
<? 

} ?>
<? ///////////////  
					if($custom_field_varfeedback!=-1 && $custIds!=-1){ ?>
					   <section class="panel panel-default pos-rlt clearfix m-b-none m-t-sm" id="ticket_customfields">
								<div class="panel-heading b-b b-light" style="background-color:#eee;">
									<div class="clear">
										<div class="row">
											<div class="m-l pull-left">
												<label class="pull-left"><? echo $vis_language['TXTUSERFEEDBACK']; ?></label>
											</div>
											<div class="pull-right m-r-lg">
												
											</div>
										</div>
									</div>
								</div>
								<div class="panel-collapse wrapper">
									<form class="form-horizontal" name="frm_edit_custom" id="frm_edit_custom" method="post"><?= $custom_field_varfeedback; ?></form>
								</div>			
							</section>
					<? } ////////////// ?>
<script>  
    $(".selectpicker").selectpicker();
				function change_status(id, status, staff_id) {
	
		var data = { vis_ticket_id:"<?=$ticket_details['ticket_id'];?>", approve_id:id, status:status, staff_id:staff_id};
		$.ajax({
			url: 'index.php?vis_module=<?=$operation['vis_module'];?>&vis_operation=change_approve_status',
			data: data,
			type: "POST",
			success: function(data) {
				
				$('#vis_global_msg_div').visInterface('load_global_message', '<?php echo $vis_language['MSGSUCCOPRT'];?>');$('#vis_details_list_<? echo $ticket_details['ticket_id']; ?>').visExecution('load_operations',{'vis_module':'ticket', 'vis_operation':'get_details', 'vis_action':'details', 'vis_ticket_id':'<? echo $ticket_details['ticket_id']; ?>', 'open_approvals':'yes'});
			},
			error: function(xhr, ajaxOptions, thrownError) {$("#vis_global_msg_div").visInterface("load_global_message", "Error: "+xhr.status+" - "+thrownError);}
		});
		
	}
 
</script>
