<?
    global $vis_language, $request_data;
    $post_count=count($post_details); ?>
<section id="vis_ticket_post_<? echo $problems_details['problem_id']; ?>">

	<section class="panel panel-default pos-rlt clearfix m-b-md" id="vis_ticket_post_area_<? echo $problems_details['problem_id']; ?>">
		<div class="panel-heading b-b b-light padder-v">
			<div class="btn-group pull-right">
				<button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
				<ul class="dropdown-menu dropdown-menu-right text-left" role="menu">
					<li><a href="javascript:void(0);" onclick="$('#vis_ticket_post_content_edit_<? echo $problems_details['problem_id']; ?>').visExecution('load_area',{'vis_module':'problem', 'vis_operation':'problem_description_edit', 'vis_problem_id':<? echo $problems_details['problem_id']; ?>});"><? echo $vis_language['TXTEDIT']; ?></a></li>
				</ul>
				<div class="clear"></div>
			</div>
			<div>
				<label><? echo $vis_language['TXTDESCRIPTION']; ?></label>
			</div>			
		</div>
		<div class="panel-body wrapper">			
			<? preg_match('/(<img[^>]+>)/i', stripslashes($problems_details['description']), $matches);
				if(!$show_inline_img && !empty($matches)){ ?>
			<div class="text-right col-sm-12 p-r-none"><a href="javascript:void(0);" class="link m-l-sm" id="load_inline_image_<? echo $problems_details['problem_id']; ?>" onclick="load_desc_inline_images('<? echo $problems_details['problem_id']; ?>','desc');"><span class="vis_load_inline_img"><? echo $vis_language['TXTSHOWINLINEIMG']; ?></span></a></div>
			<? } ?>
			<div id="vis_ticket_post_content_div_<? echo $problems_details['problem_id']; ?>">
				<div class="vis_max_img_size" id="vis_ticket_post_content_text_<? echo $problems_details['problem_id']; ?>"><? if(!$show_inline_img) { echo preg_replace("/<img[^>]+\>/i", "", stripslashes($problems_details['description']));} else echo stripslashes($problems_details['description']); ?></div>
				<div id="vis_ticket_post_content_edit_<? echo $problems_details['problem_id']; ?>"></div>
			</div>        
			<? if($attachments!=-1) { 
				$images=''; $files='';
				for($j=0;$j<count($attachments);$j++) { 
					if (!preg_match('/image/',$attachments[$j]['file_type'])) { 
					  $files.='<div class="btn-group wrapper-xxs p-l-none"><a class="btn btn-xs alert-success no-border" href="'.$attachments[$j]['domain_url'];
					   if(VIS_DOMAIN==$attachments[$j]['file_location']) $files.= 'manage/';
						$files.='?vis_module=export&vis_operation=get_attachment&vis_attachment='.$attachments[$j]['attachment_id'].'&'.VIS_STAFF_COOKIE.'='.$_COOKIE[VIS_STAFF_COOKIE].'&get_area=1'.'"><span class="vis-icon-med vis-icon-article"></span>&nbsp;'.$attachments[$j]['file_name'].'</a></div>';
				   }
				   else {
					   $imagedetails=explode("/",$attachments[$j]['content']);
					   $imagename=file_exists(VIS_PATH_FILES.'thumb_'.end($imagedetails))?'thumb_'.end($imagedetails):end($imagedetails);
					   $images.='<li><a href="'.$attachments[$j]['domain_url'];
					   if(VIS_DOMAIN==$attachments[$j]['file_location']) $images.= 'manage/';
						$images.='?vis_module=export&vis_operation=get_attachment&vis_attachment='.$attachments[$j]['attachment_id'].'&'.VIS_STAFF_COOKIE.'='.$_COOKIE[VIS_STAFF_COOKIE].'&get_area=1'.'"><img width="100" height="100" src="'./*$attachments[$j]['domain_url'].*/VIS_PATH_FILES.$imagename.'" alt="'.$attachments[$j]['file_name'].'" title="'.$attachments[$j]['file_name'].'"/></a></li>';
				   }
				  }
				  if($images!='') { ?>
			<?php echo '<div class="b b-t m-sm b-dashed m-l-none m-r-none"></div><div class="clear"><ul class="vis_inline_images nav navbar-nav hidden-xs">'.$images.'</ul></div>';
				}
				if($files!='') {  ?>
			<div class="b b-t m-sm b-dashed m-l-none m-r-none"></div>
			<?php echo $files; 
				}
				}?>
			<div class="wrapper-sm m-b-none"></div>
			<div class="btn-group">
				<a class="btn btn-default btn-xm btn-rounded" href="javascript:void(0);" onclick="$('#vis_problem_analysis_show_<? echo $problems_details['problem_id']; ?>').visExecution('load_area',{'vis_module':'problem', 'vis_operation':'get_details','vis_action': 'analysis', 'vis_analysis_type': 'rootcause', 'vis_problem_id':<? echo $problems_details['problem_id']; ?>});"><? echo $vis_language['TXTROOTCAUSE']; ?></a>
			</div>
			<div class="btn-group">
				<a class="btn btn-default btn-xm btn-rounded" href="javascript:void(0);" onclick="$('#vis_problem_analysis_show_<? echo $problems_details['problem_id']; ?>').visExecution('load_area',{'vis_module':'problem', 'vis_operation':'get_details','vis_action': 'analysis', 'vis_analysis_type': 'impact', 'vis_problem_id':<? echo $problems_details['problem_id']; ?>});"><? echo $vis_language['TXTIMPACT']; ?></a>
			</div>
			<div class="btn-group">
				<a class="btn btn-default btn-xm btn-rounded" href="javascript:void(0);" onclick="$('#vis_problem_analysis_show_<? echo $problems_details['problem_id']; ?>').visExecution('load_area',{'vis_module':'problem', 'vis_operation':'get_details','vis_action': 'analysis', 'vis_analysis_type': 'symptons', 'vis_problem_id':<? echo $problems_details['problem_id']; ?>});"><? echo $vis_language['TXTSYMPTONS']; ?></a>
			</div>
			<div id="vis_problem_analysis_show_<? echo $problems_details['problem_id']; ?>" class="wrapper-sm m-b-none m-t">
			</div>
		</div>
	</section>
</section>

<script type="text/javascript">
function load_desc_inline_images(postid,type){
	var display='';	
	if($('#load_inline_image_'+postid+' .vis_load_inline_img').text()==='<? echo $vis_language['TXTSHOWINLINEIMG']; ?>') {
		display=1;
		$('#load_inline_image_'+postid+' .vis_load_inline_img').text('<? echo $vis_language['TXTHIDEINLINEIMG']; ?>');
	}
	else {
		display=0;
		$('#load_inline_image_'+postid+' .vis_load_inline_img').text('<? echo $vis_language['TXTSHOWINLINEIMG']; ?>');
	}
	
	$.post( 'index.php', { 'vis_module': 'problem', 'vis_operation': 'load_inline_images', 'vis_post_id': postid , 'vis_display':display, 'vis_type':type}, function( data ) {
		$("#vis_ticket_post_content_text_"+postid).html(data.vis_post_content_html);
	}, "json");
}
</script>
