<? global $vis_language, $request_data; 
    $post_count=count($post_details);
?>
<section id="breadcrumb" class="row m-b m-l-none m-r-none">
    <div class="col-sm-5 col-xs-5">
        <h3 class="m-b-xs text-black"><i class="vh vh-change-management vh-brown vh-lg"></i> <span><?php echo($changes_details['changes_hash']); ?></span></h3>
        <ul class="breadcrumb bg-empty no-border m-b-xxs no-padder">
            <li><a class="link" href="#/home/quick_view/<?= $vis_language['TXTHOME'];?>" onclick="$('#vis_workpanel_div').visExecution('load_module','<?= $vis_language['TXTHOME'];?>',{'vis_module':'home','vis_operation':'quick_view', 'vis_action':'#/home/quick_view/<?= $vis_language['TXTHOME'];?>'});"><?= $vis_language['TXTHOME'];?></a></li>
            <li><a class="link" href="#/changes/filter_changes/<? echo $vis_language['TXTCHANGES']; ?>/12"><?= $vis_language['TXTCHANGES']; ?></a></li>
            <li class="active"><?php echo($changes_details['changes_hash']); ?></li>
        </ul>
    </div>
    <div class="clearfix col-sm-7 text-right text-left-xs m-t-lg">
        <div class="row">
			<div class="col-sm-12">
				<div class="pull-right">
					<div class="btn-group">
						<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 href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=changes&vis_operation=get_changes_properties&vis_static_area=vis_ticket_property_form&vis_changes_id=<? echo $changes_details['changes_id']; ?>&vis_staff_id=<? echo $changes_details['changes_from']; ?>&vis_domain_id=<? echo $changes_details['domain_id']; ?>"><? echo $vis_language['TXTPROPERTIES']; ?></a></li>
							<li><a href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=changes&vis_operation=new_note&vis_static_area=vis_ticket_note_form&vis_changes_id=<? echo $changes_details['changes_id']; ?>&vis_staff_id=<? echo $changes_details['changes_from']; ?>&vis_domain_id=<? echo $changes_details['domain_id']; ?>"><? echo $vis_language['TXTNOTEADD']; ?></a></li>
							<li id="repldiv"><a id="vis_change" href="javascript:void(0);" onclick="check_link_ticket_exist(<? echo $total_ticket;?>);"><? echo $vis_language['TXTREPLYALLLINKEDTICKET']; ?></a></li>
						</ul>                            
					</div>
				</div>
				</div>
			</div>
    </div>
    <div class="m-l-md clr">
    </div>
</section>
<div class="col-lg-12 b-t b-light" id="ticket_details_view">
	<div class="form-group m-l-n clear m-b-xs m-t-xs">
		<div class="padder h4 font-bold">
			<span id="vis_ticket_subject">
				<span><? echo $vis_language['TXTSUBJECT']; ?></span>
				<span class="text-lt h4 l-h font-bold">: <? if($changes_details['changes_from']==0){?><i class="vh vh-information-round vh-blue" title="<?= $vis_language['TXTINTERNALTICKET']?>"></i><? } ?><? echo $changes_details['subject']; ?></span> 
			</span>
		</div>
	</div>
   
	<div>
		<ul class="navSeprator no-padder m-b-n">
			<li><label><? echo $vis_language['TXTCREATEDBY']?></label>
				<a href="#/setting/staff_details/<?php echo $staff_info[0]['user_name']?>/<?= $changes_details['changes_from']?>" class="link m-l-xs" onmouseover="javascript:show_user_details(2,<?= $changes_details['changes_from']?>,null,null,1);" id="user_<?= $changes_details['changes_from'];?>" onmouseout="hide_user_details(this);"> <?= $staff_info[0]['first_name'].' '.$staff_info[0]['last_name']." < ".$staff_info[0]['email']." >"; ?></a>
			</li>
			<li><label><? echo $vis_language['TXTCREATIONDATE']; ?></label><span class="text-muted m-l-xs"><? echo format_datetime($changes_details['date_created']); ?></span></li>
			<li><label><? echo $vis_language['TXTMODIFICATIONDATE']; ?></label><span class="text-muted m-l-xs"><?php echo format_datetime($changes_details['date_modified']); ?></span></li>
		</ul>
	</div>
	<div id="vis_ticket_reply_<? echo $changes_details['changes_id']; ?>" style="display:none"></div>
	<div id="vis_ticket_forward_<? echo $changes_details['changes_id']; ?>" style="display:none"></div>
	<section class="panel panel-default m-t-xs">
		<header class="panel-heading text-right bg-light clearfix">
			<ul class="nav nav-tabs pull-left no-borders" id="tabs"> 
				<li id="ticket_details" class="active"><a href="#vis_details_list_<? echo $changes_details['changes_id']; ?>" data-toggle="tab" onclick="$('#vis_details_list_<? echo $changes_details['changes_id']; ?>').visExecution('load_operations',{'vis_module':'changes', 'vis_operation':'get_details', 'vis_action':'details', 'vis_changes_id':'<? echo $changes_details['changes_id']; ?>', 'vis_department_id':'<? echo $changes_details['department_id']; ?>', 'vis_readonly':1});set_active_tab('ticket_details');"><? echo $vis_language['TXTCHANGESDETAILS']; ?></a></li>
				<li id="audit_log"><a href="#vis_details_list_<? echo $changes_details['changes_id']; ?>" data-toggle="tab" onclick="$('#vis_details_list_<? echo $changes_details['changes_id']; ?>').visExecution('load_operations',{'vis_module':'changes', 'vis_operation':'get_details', 'vis_action':'audit_log', 'vis_changes_id':'<? echo $changes_details['changes_id']; ?>'});set_active_tab('audit_log');"><? echo $vis_language['TXTAUDITLOG']; ?></a></li>
				
				<li id="notes"<?if(count($note_details)==0) echo 'style="display:none;"'; else echo 'style="display:block;"';?>><a href="#vis_details_list_<? echo $changes_details['changes_id']; ?>" data-toggle="tab" onclick="$('#vis_details_list_<? echo $changes_details['changes_id']; ?>').visExecution('load_area',{'vis_module':'changes', 'vis_operation':'get_details', 'vis_action':'notes', 'vis_domain_id':<? echo $changes_details['domain_id']; ?>, 'vis_client_id':<? echo $changes_details['changes_from']; ?>, 'vis_changes_id':<? echo $changes_details['changes_id']; ?>});set_active_tab('notes');"><? echo $vis_language['TXTNOTES']; ?></a></li>
                
			</ul>
		</header>
		<div class="panel-body">
			<div class="tab-content">
				<div class="tab-pane active" id="vis_details_list_<? echo $changes_details['changes_id']; ?>">
					<script language="javascript">
						$('#vis_details_list_<? echo $changes_details['changes_id']; ?>').visExecution('load_operations',{'vis_module':'changes', 'vis_operation':'get_details', 'vis_action':'details', 'vis_changes_id':'<? echo $changes_details['changes_id']; ?>', 'vis_department_id':'<? echo $changes_details['department_id']; ?>', 'vis_readonly':1});
					</script>
				</div>
			</div>
		</div>
	</section>
	<section id="vis_ticket_post_forms">
	<input type="hidden" id ="tot_tick_cnt" value="0" >
		<? include(VIS_PATH_TEMPLATE.'changes_description.php'); ?>
	</section>
	
	<section id="changes_planning_plan_<? echo $changes_details['changes_id']; ?>">
		<script language="javascript">
			$('#changes_planning_plan_<? echo $changes_details['changes_id']; ?>').visExecution('load_operations',{'vis_module':'changes', 'vis_operation':'get_details', 'vis_action':'plan', 'vis_changes_id':'<? echo $changes_details['changes_id']; ?>', 'vis_department_id':'<? echo $changes_details['department_id']; ?>', 'vis_readonly':1});
		</script>
	</section>
</div>
<script>
$(".selectpicker").selectpicker();
function set_active_tab(tab_id){
	var active = $("#tabs .active").attr("id");
	$("#"+active).removeClass("active");
	$("#"+tab_id).addClass("active").show();
	var parent_div = $("#vis_details_list_<?= $changes_details['changes_id'];?>").parent().parent();
	if(parent_div.hasClass("p-l-none") && parent_div.hasClass("p-r-none"))
		parent_div.removeClass("p-l-none").removeClass("p-r-none");
	else if(parent_div.hasClass("no-padder"))
		parent_div.removeClass("no-padder");
		
	if($("#ticket_details_view #tabs #invoices.active").length
	|| $("#ticket_details_view #tabs #history.active").length
	|| $("#ticket_details_view #tabs #link.active").length) 
		parent_div.addClass("no-padder");
	else if($("#ticket_details_view #tabs #time_track.active").length || $("#ticket_details_view #tabs #history.active").length || $("#ticket_details_view #tabs #audit_log.active").length)
		parent_div.addClass("p-l-none").addClass("p-r-none");	
}
function check_link_ticket_exist(link_ticket)
{   link_ticket = (link_ticket==0)?$("#tot_tick_cnt").val():link_ticket;
   if(link_ticket>0)
   {
		$('#vis_change').attr('data-toggle','ajaxModal');
		$('#vis_change').attr('data-modal-arguments','vis_module=ticket&vis_operation=get_tickets_reply&vis_changes_id=<? echo $changes_details['changes_id']; ?>');
   }
   else 
   {
		$("#vis_global_msg_div").visInterface("load_global_message", "<? echo $vis_language['MSGNOLINKTICKETFOUND'];?>");
		return false;
   }
	  
}
</script>
