<? global $vis_language;

	if($operation['vis_plan_type']=='rollout'){
		$label = $vis_language['TXTROLLOUTPLAN'];
		$desc = $changes_details['rollout'];
		$attachments = $rollout_attachment;
		$changes_attachments = $changes_details['rollout_attachment	'];
	}
	else if($operation['vis_plan_type']=='backout'){
		$label = $vis_language['TXTBACKOUTPLAN'];
		$desc = $changes_details['backout'];
		$attachments = $backout_attachment;
		$changes_attachments = $changes_details['backout_attachment	'];
	}
	
	?>
		
<form class="form-horizontal" method="post" enctype="multipart/form-data" name="vis_problem_solution_edit" id="vis_problem_solution_edit_<?=$operation['vis_plan_type']?><? echo $changes_details['changes_id']; ?>">
	<div class="panel-heading b-b b-light">
		<div class="clear">
			<div class="row">
				<div class="m-l pull-left">
					<label class="pull-left"><? echo $label; ?></label>
				</div>
			</div>
		</div>
	</div>
	<div class="panel-collapse wrapper">
	
	<div class="form-group">
		<div class="col-sm-12">
			<textarea name="vis_description" id="vis_description<?=$operation['vis_plan_type']?>" 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_solution_edit_<?=$operation['vis_plan_type']?><? 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 text-right">		    
			<input name="vis_changes_id" type="hidden" value="<? echo $changes_details['changes_id']; ?>" />
						
			<span class="btn btn-default" onclick="$('#vis_solution_<? 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});"><? echo $vis_language['TXTDISCARD']; ?></span>
			
			<span class="btn btn-primary m-l-xs" onclick="$(this).visExecution('submit_form',{'vis_module':'changes', 'vis_operation':'update_change_plan', 'vis_form':'vis_problem_solution_edit_<?=$operation['vis_plan_type']?><? echo $changes_details['changes_id']; ?>', 'vis_plan_type' : '<?php echo $operation['vis_plan_type'];?>', 'vis_domain':'<? echo $changes_details['domain_id']; ?>'})";><? echo $vis_language['TXTSAVE']; ?></span>
        </div>
    </div>
	</div>
</form>
 <? if (!defined('VIS_HTML_EDITOR') || VIS_HTML_EDITOR == 1) { ?>	<script src="<?= VIS_PATH_PLUGINS; ?>redactor/source.js"></script> <?}?>
<script src="<?= VIS_PATH_SCRIPT; ?>file-input/bootstrap-filestyle.min.js"></script>
<script type="text/javascript">
	<? if(!defined('VIS_HTML_EDITOR') || VIS_HTML_EDITOR==1) { ?>    
		$(function(){
			$('#vis_description<?=$operation['vis_plan_type']?>').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,
				paragraphize: false,
		        replaceDivs: false,
                linebreaks: true,
                plugins: ['source'],
                deniedTags: ['html', 'head', 'link', 'body', 'meta', 'script','applet']
			});
		});
	<? } ?>
	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 + ',', '') );
	}
</script>
