<form id="vis_email_template_form" name="vis_email_template_form" method="post" class="form-horizontal">
   <input type="hidden" name="vis_etemplate_id" value="<? echo $etemplate_details['etemplate_id']; ?>" /> <input type="hidden" name="vis_default_id" value="<? echo $etemplate_details['default_id']; ?>" />
   <input type="hidden" name="vis_operation" value="update_etemplate" /><input type="hidden" name="vis_module" value="setting" />
   <div class="form-group">
      <label class="col-sm-2 control-label"><? echo $vis_language['TXTTITLE']; ?></label>
      <div class="col-sm-10">
         <input class="form-control input-sm" type="text"  name="vis_etemplatename" id="vis_etemplatename" value="<? echo $etemplate_details['etemplate_name']; ?>" >
      </div>
   </div>
    <div class="form-group">
			<label class="col-sm-2 control-label"><? echo $vis_language['TXTLANGUAGE']; ?></label>
			<div class="col-sm-10">
				<select class="form-control input-sm selectpicker" id="vis_language" name="vis_language" <? if(count($language_list)>10) echo 'data-live-search="true"';?> onchange="edit_content(this.value);"> <?
				if($language_list!=-1){
				for($i=0;$i<count($language_list);$i++) { ?>
					<option value="<? echo $language_list[$i]['language_id']; ?>"<? if($etemplate_details['language']==$language_list[$i]['language_id']) echo ' selected="selected"'?>><? echo $language_list[$i]['language_name']; ?></option><?
				} } else { ?><option value="1"><? echo "Default english"; ?></option><? } ?> </select>
			</div>
		</div> 
	<div class="form-group">
               <label class="col-sm-2 control-label"><? echo $vis_language['TXTDISPLAYORDER']; ?></label>
               <div class="col-sm-10">
                  <input class="form-control input-sm" type="text" name="vis_displayorder" id="vis_displayorder" value="<? echo $etemplate_details['display_order']; ?>" >
               </div>
    </div>
   <div class="form-group">
      <label class="col-sm-2 control-label"><? echo $vis_language['TXTSUBJECT']; ?></label>
      <div class="col-sm-10">
         <input class="form-control input-sm" type="text" name="vis_subject" id="vis_subject" value="<? //echo $etemplate_details['subject']; ?>">
      </div>
   </div>
   <div class="form-group">
      <label class="col-sm-2 control-label"><? echo $vis_language['TXTCONTENT']; ?></label>
      <div class="col-sm-10">
          <textarea name="vis_etemplate_content" id="vis_etemplate_content" class="form-control"><? //echo $etemplate_details['content']; ?></textarea>
      </div>
   </div>
   <?php if($etemplate_details['default_id']==0) {?>
   <div class="form-group">
         <label class="col-sm-2 control-label"><? echo $vis_language['TXTATTACHMENT']; ?></label>
         <div class="col-sm-10">
                  <div class="radio i-checks m-r-lg pull-left">
				  <label>
                  <input type="radio" <?php echo ($etemplate_details['attachment_setting']==1)?'checked="checked"':'';?> value="1"  name="vis_attachment_setting"><i></i>
                  <? echo $vis_language['TXTYES']; ?></label></div>
                  <div class="radio i-checks pull-left">
				  <label>
                  <input type="radio" <?php echo ($etemplate_details['attachment_setting']==0)?'checked="checked"':'';?> value="0"  name="vis_attachment_setting"><i></i>
                  <? echo $vis_language['TXTNO']; ?> </label></div>
         </div>
      </div>
      <? } else{ ?>
       <input type="hidden"  value="1"  name="vis_attachment_setting" />
      <? }?>
   <div class="form-group">
      <label class="col-sm-2 control-label"><? echo $vis_language['TXTSTATUS']; ?></label>
      <div class="col-sm-1" id="email_template_status">
         <label class="switch" id="vis_disable" <? if($etemplate_details['is_enabled']==0) echo 'radio-no-uncheck'; ?>  ">
         <input type="checkbox"  name="vis_status"  id="vis_status" <? if($etemplate_details['is_enabled']==1) echo ' checked="checked"'; ?>   > 
         <span ></span>
         </label>
      </div>
   </div>
   <div class="line b-b line-lg pull-in"></div>
   <br/>             
   <div class="form-group">
      <div class="col-sm-4 col-sm-offset-2">
         <button type="button" class="btn btn-primary" onclick="$('#vis_workpanel_div').visExecution('submit_form',{'vis_module':'setting', 'vis_operation':'update_etemplate', 'vis_form':'vis_email_template_form' })"><? echo $vis_language['TXTUPDATE']; ?></button>
      </div>
   </div>
   </div>
</form>
<script>
<? if(!defined('VIS_HTML_EDITOR') || VIS_HTML_EDITOR==1) { ?>
 $(function(){
		$('#vis_etemplate_content').redactor({
			buttonSource: true,
			minHeight: 180, // pixels
			maxHeight: 180,
			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']
		});
	}); 
	<? }?>
	edit_content($("#vis_language").val());
	function edit_content(lang_id)
	{
		 $.ajax
		({
		url: 'index.php',
		data: {'vis_module':"setting", 'vis_operation':"etemplate_details" ,'vis_template_id':'<? echo $etemplate_details['etemplate_id'];?>','vis_lang':lang_id},
		type: "POST",
		dataType: "json",
		success: function(data)
		{
			if(data.res!='0'){
				 $("#vis_subject").val(data.res.subject);
				 <? if (!defined('VIS_HTML_EDITOR') || VIS_HTML_EDITOR == 1) { ?>
				 $('#vis_etemplate_content').redactor('code.set', data.res.content);
				 <?} else { ?>
				 $("#vis_etemplate_content").val(data.res.content);
				 <? } ?>
				// $("#email_template_status").html('<label class="switch  <? if(data.res.is_enabled=='0') echo 'radio-no-uncheck'; ?>  "><input type="checkbox"  name="vis_status"  id="vis_status" <? if(data.res.is_enabled=='1') echo ' checked="checked"'; ?>   > <span ></span></label>');
				//if(data.res.is_enabled=='0'){ $("#vis_disable").attr('class','switch radio-no-uncheck'); $("#vis_status").removeAttr('checked');}
				//else  {$("#vis_status").attr('checked','checked');$("#vis_disable").attr('class','switch');}
			 }
			 else{
				  $("#vis_subject").val('');
				 <? if (!defined('VIS_HTML_EDITOR') || VIS_HTML_EDITOR == 1) { ?>
				 $('#vis_etemplate_content').redactor('code.set', '');
				 <?} else { ?>
				 $("#vis_etemplate_content").val('');
				 <? } ?>
				 //$("#email_template_status").html('<label class="switch  "><input type="checkbox"  name="vis_status"  id="vis_status" checked="checked" ><span ></span></label>');
			 }
		}
		});	
	}
</script>
<script src="<?= VIS_PATH_SCRIPT; ?>file-input/bootstrap-filestyle.min.js"></script>
