<? global $vis_language;

	if($operation['vis_planning_type']=='reasons'){
		$label = $vis_language['TXTNOREASON'];
		$desc = $changes_details['reason'];
		$changes_attachments = $changes_details['reasons_attachment'];
	}
	else if($operation['vis_planning_type']=='impact'){
		$label = $vis_language['TXTNOIMPACT'];
		$desc =  $changes_details['impact_planning'];
		$changes_attachments = $changes_details['impact_attachment'];
	}
	?>
		
<form class="form-horizontal" method="post" enctype="multipart/form-data" name="vis_problem_analysis_edit" id="vis_problem_analysis_edit_<? echo $changes_details['changes_id']; ?>">
	<div class="form-group">
		<div class="col-sm-12">
			<textarea name="vis_planning_desc" id="vis_planning_desc" class="form-control"><? echo $desc; ?></textarea>
		</div>
	</div>
	<div class="form-group">
		<div class="col-sm-12">
			<input type="file" name="files[]" multiple="multiple" onchange="$(this).visExecution('upload_file', {'vis_static_area':'#vis_csve_attachments', 'vis_form':'vis_problem_analysis_edit_<? echo $changes_details['changes_id']; ?>', 'vis_form_attachment_area':'#vis_attachments'})" class="filestyle" data-input="false" data-icon="true" data-iconName="vh-chat" data-classButton="btn btn-link link"  data-buttonText="<?=$vis_language['TXTATTACHFILE']?>" data-badge="true"/><input type="hidden" name="vis_location" value="<? echo VIS_DOMAIN; ?>" />
			<input type="hidden" name="vis_attachments" id="vis_attachments" value="<?=$changes_attachments?>" />
			<div id="vis_csve_attachments">
			<?php
				if($attachments!=-1) {
					for($j=0;$j<count($attachments);$j++){
			?>
				<div class="btn-group wrapper-xxs">
					<span class="btn btn-xs alert-success"><?php echo $attachments[$j]['file_name'];?></span>
					<button onclick="$(this).parent().remove(); $(this).visExecution('load_operations', {'vis_module':'ticket', 'vis_operation':'remove_attachment', 'vis_attachment_id':<?php echo $attachments[$j]['attachment_id'];?>});vis_remove_attachment(<?php echo $attachments[$j]['attachment_id'];?>,'vis_attachments');" data-dismiss="alert" type="button" class="btn btn-xs alert-success"><i class="vh vh-cross"></i></button>
				</div>
			<?php }}?>
			</div>
		</div>
	</div>
	<div class="form-group">
		<div class="col-sm-12">		    
			<input name="vis_changes_id" type="hidden" value="<? echo $changes_details['changes_id']; ?>" />
			<span class="btn btn-default" onclick="$('#vis_changes_planning_show_<? echo $changes_details['changes_id']; ?>').hide();$('#vis_changes_planning_show_<? echo $changes_details['changes_id']; ?>').html('');"><? echo $vis_language['TXTDISCARD']; ?></span>
			<span class="btn btn-primary m-l-xs" onclick="$(this).visExecution('submit_form',{'vis_module':'changes', 'vis_operation':'update_changes_planning', 'vis_form':'vis_problem_analysis_edit_<? echo $changes_details['changes_id']; ?>', 'vis_planning_type' : '<?php echo $operation['vis_planning_type'];?>'});"><? echo $vis_language['TXTSAVE']; ?></span>
        </div>
    </div>
</form>
<script src="<?= VIS_PATH_SCRIPT; ?>file-input/bootstrap-filestyle.min.js"></script>
<script type="text/javascript">
	$(document).ready(function () {
		$(":file").filestyle({input: false});
	});
	<? if(!defined('VIS_HTML_EDITOR') || VIS_HTML_EDITOR==1) { ?>    
		$(function(){
			$('#vis_planning_desc').redactor({
				buttonSource: true,
				minHeight: 100, // pixels
				maxHeight: 100,
				imageUpload: "index.php?vis_tmpst="+new Date().getTime()+"&vis_module=ticket&vis_operation=upload_file&vis_static_area=editor_image_upload",
				imageUploadParam: 'files',                
				focus: true,			
                deniedTags: ['html', 'head', 'link', 'body', 'meta', 'script','applet'],
                plugins: ['source']
			});
		});
	<? } ?>
	function vis_remove_attachment(ticket_id, attach_location){
		var loc = '';
		loc = (attach_location != "" && typeof(attach_location) != "undefined") ? attach_location : "vis_image_attachments";
		$("#" + loc).val( $("#" + loc).val().replace(ticket_id + ',', '') );
	}
/*function load_inline_images(postid){
	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': 'ticket', 'vis_operation': 'load_inline_images', 'vis_post_id': postid , 'vis_display':display}, function( data ) {
		$("#vis_ticket_post_content_text_"+postid).html(data.vis_post_content_html);
	}, "json");
}
*/

</script>
