<? global $vis_language;

	if($operation['vis_planning_type']=='reasons'){
		$label = $vis_language['TXTNOREASON'];
		$label2 = $vis_language['TXTCHANGEREASON'];
		$desc = $changes_details['reason'];
	}
	else if($operation['vis_planning_type']=='impact'){
		$label = $vis_language['TXTNOIMPACT'];
		$label2 = $vis_language['TXTIMPACT'];
		$desc = $changes_details['impact_planning'];
	}
	
	if($desc==''){?>
		<div class="row">
			<div class="col-sm-12 m-t-xs">
				<label><? echo  $label;?></label>
				<span class="m-l-sm">
				<a class="link" href="javascript:void(0);" onclick="$('#vis_changes_planning_show_<? echo $changes_details['changes_id']; ?>').visExecution('load_area',{'vis_module':'changes', 'vis_operation':'changes_planning_form', 'vis_planning_type': '<?php echo $operation['vis_planning_type'];?>', 'vis_changes_id':<? echo $changes_details['changes_id']; ?>});"><? echo $vis_language['TXTADDNEW']; ?></a></span>
			</div>	
		</div>
	<?php }
	else{?>
		<section class="pos-rlt clearfix m-b-md" id="vis_ticket_post_area_<? echo $changes_details['changes_id']; ?>">
		<div class="">
			<div class="btn-group pull-right">
				<a class="link m-r" href="javascript:void(0);" onclick="$('#vis_changes_planning_show_<? echo $changes_details['changes_id']; ?>').visExecution('load_area',{'vis_module':'changes', 'vis_operation':'changes_planning_form', 'vis_planning_type': '<?php echo $operation['vis_planning_type'];?>', 'vis_changes_id':<? echo $changes_details['changes_id']; ?>});"><? echo $vis_language['TXTEDIT']; ?></a>
				
				<a class="link" href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=changes&vis_operation=confirm_delete_planning&vis_changes_id=<? echo $changes_details['changes_id']; ?>&vis_planning_type=<?php echo $operation['vis_planning_type'];?>"><? echo $vis_language['TXTDELETE']; ?></a>
				<div class="clear"></div>
			</div>
			<div>
				<label><? echo $label2; ?></label>
			</div>			
		</div>
		<div class="wrapper">			
			<? preg_match('/(<img[^>]+>)/i', $desc, $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_planning_inline_image_<? echo $changes_details['changes_id']; ?>" onclick="load_planning_inline_images('<? echo $changes_details['changes_id']; ?>','<?=$operation['vis_planning_type']?>');"><span class="vis_load_inline_img"><? echo $vis_language['TXTSHOWINLINEIMG']; ?></span></a></div>
			<? } ?>
			<div id="vis_ticket_post_content_div_<? echo $changes_details['changes_id']; ?>">
				<div class="vis_max_img_size" id="vis_changes_post_content_text_<? echo $changes_details['changes_id']; ?>"><? if(!$show_inline_img) { echo preg_replace("/<img[^>]+\>/i", "", $desc);} else echo $desc; ?></div>
				<div id="vis_ticket_post_content_edit_<? echo $changes_details['changes_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].'"><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].'"><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>
	</section>
	<?php }
	?>
		
<script type="text/javascript">
function load_planning_inline_images(postid,type){
	var display='';	
	if($('#load_planning_inline_image_'+postid+' .vis_load_inline_img').text()==='<? echo $vis_language['TXTSHOWINLINEIMG']; ?>') {
		display=1;
		$('#load_planning_inline_image_'+postid+' .vis_load_inline_img').text('<? echo $vis_language['TXTHIDEINLINEIMG']; ?>');
	}
	else {
		display=0;
		$('#load_planning_inline_image_'+postid+' .vis_load_inline_img').text('<? echo $vis_language['TXTSHOWINLINEIMG']; ?>');
	}
	$.post( 'index.php', { 'vis_module': 'changes', 'vis_operation': 'load_inline_images', 'vis_post_id': postid , 'vis_display':display, 'vis_type':type}, function( data ) {
		$("#vis_changes_post_content_text_"+postid).html(data.vis_post_content_html);
	}, "json");
}
/*$('.pagination_ticket_post').twbsPagination({
	totalPages:<?php echo $post_paging_count; ?>,
	visiblePages:5,startPage: <?= $page;?>,
	onPageClick: function (event, page) { 
		$('#ticket_details_view #vis_ticket_post_forms').visExecution('load_operations', {'vis_module':'ticket', 'vis_operation':'<?= $operation['vis_operation'];?>', 'vis_ticket_id':<?= $ticket_details['ticket_id'];?>, 'vis_action':'load_more_post', 'vis_page':page});
	}
});*/
</script>
