#set($title = "メール編集")
#set($menukubun = "2")
#parse( "/WEB-INF/view/common/header_admin.vm" )
<script language="JavaScript">
    <!--
	function send_check(flg){
     	if (document.mainForm.deliveryTargetMethod.value == '0') {
     		document.mainForm.status.value = '0';
     	} else if (document.mainForm.deliveryTargetMethod.value == '1') {
     		document.mainForm.status.value = '1';
     	}
		document.mainForm.submit();
		return false;
     }

	function save_mail(flg) {
		document.mainForm.status.value = flg;
     	document.mainForm.action="#q('/admin/mail/mailEdit/saveMail/')";
		document.mainForm.submit();
		return false;
     }

	function send_mail(){
     	document.mainForm.action="#q('/admin/mail/mailEdit/testMailSend/')";
		document.mainForm.submit();
		return false;
     }

    function OpenSrchWindow()
    {
		//var url='#q("/admin/mail/mailSearch/mailResevedPopup/")';
		var url='#q("/admin/mail/mailPopup/")';
		window.open(url, "userEditForm", "width=800px, height=512px,resizable=yes,scrollbars=yes ");
    }

    function change(arg){
    	if (arg == "0") {
    		$("#deliveryDate").datepick('enable');
    		$("select[name=deliveryHour]").attr("disabled",false);
			$("select[name=deliveryMin]").attr("disabled",false);

    	} else {
    		$("#deliveryDate").datepick('disable');
		$("select[name=deliveryHour]").attr("disabled",true);
		$("select[name=deliveryMin]").attr("disabled",true);
    	}
     }

    function showSendSetting(type) {
        if (type == "0") {
            document.getElementById('send_file').style.display = 'none';
            document.getElementById('enquete_id').style.display = 'none';
            document.getElementById('send_target').style.display = '';
            document.getElementById('send_group').style.display = '';
        } else {
            document.getElementById('send_file').style.display = '';
            document.getElementById('enquete_id').style.display = '';
            document.getElementById('send_group').style.display = 'none';
            document.getElementById('send_target').style.display = 'none';
        }
    }

    //-->
</script>
<script language="javascript" type="text/javascript" charset="utf-8">
<!--
	//開始日
	$(function() {
	  $('#deliveryDate').datepick({showTrigger: '#calFromDate',
	  minDate: '0m'});
	});

	$(function() {

		#if($!mailRegistForm.deliveryTargetMethod=="0")
			$("input[name=deliveryDate]").attr("disabled",false);
			$("select[name=deliveryHour]").attr("disabled",false);
			$("select[name=deliveryMin]").attr("disabled",false);
			$("#deliveryDate").datepick('enable');
		#else
			$("input[name=deliveryDate]").attr("disabled",true);
			$("select[name=deliveryHour]").attr("disabled",true);
			$("select[name=deliveryMin]").attr("disabled",true);
			$("#deliveryDate").datepick('disable');
		#end
		showSendSetting("$!mailRegistForm.sendType");
	});
	// -->
</script>
<div id="contents">
<div id="contents_main">
<div id="breadcrumbsWrap">

</div><!--[ /breadcrumbsWrap ]-->
<div id="main" class="clearfix">


<h2 class="contents_title">メール編集</h2>
<div id="right_contents">
#if($tools.getMsgs()!="")
<font color="red" size="2">入力エラーがあります。</font>
#end
#set($mail-url = $tools.getSecureUrl('/admin/mail/mailEdit/confirm/'))
<form name="mainForm" action="$!mail-url" method="post" enctype="multipart/form-data">
##<div id="search">
##<div class="clearfix">
<table border="0" cellspacing="0" cellpadding="0" class="stripe2 mgb10 w840">
##<table border="0" cellspacing="0" cellpadding="0" class="stripe3 w790">
	<tr class="gray">
		<td class="w120">ステータス</td>
		<td>
			#if($!mailRegistForm.status == 0)未配信
			#elseif($!mailRegistForm.status == 1)配信済
			#else 一時保存
			#end
		</td>
	</tr>
<input type="hidden" name="status" value="$!mailRegistForm.status">
<input type="hidden" name="enqueteMailId" value="$!mailRegistForm.enqueteMailId">
	<tr class="gray">
		<td style="vertical-align:top">メール件名</td>
		<td><input name="subject" type="text" / class="w600"  value="$!escape.html($!mailRegistForm.subject)">
		#if($!tools.getMsg("subject")) <br/>$tools.getMsg("subject") #end
		</td>
	</tr>
	<tr>
		<td style="vertical-align:top">配信先</td>
		<td>
			<input type="radio" name="sendType" onclick="showSendSetting('0');" value="0" #if($!mailRegistForm.sendType == "0") checked="checked" #end>配信グループ&nbsp;&nbsp;
			<input type="radio" name="sendType" onclick="showSendSetting('1');" value="1" #if($!mailRegistForm.sendType == "1") checked="checked" #end>ファイルアップロード
			<br><br>
			<div id="send_group">
			<select name="deliveryGroupId" id="deliveryGroupId"  class="w600">
				<option value=""></option>
					#foreach($genreItem in $deliveryGroupList)
						#if($mailRegistForm.deliveryGroupId && $genreItem.deliveryGroupId == $mailRegistForm.deliveryGroupId)
							<option value="$!genreItem.deliveryGroupId" selected>#he($!genreItem.deliveryGroupName)</option>
						#else
							<option value="$!genreItem.deliveryGroupId">#he($!genreItem.deliveryGroupName)</option>
						#end
					#end
			</select>
			</div>
			<div id="send_file">
				<input type="file" name="file" size="60" id="File" multiple="multiple">
			</div>
		#if($!tools.getMsg("deliveryGroupId")) $tools.getMsg("deliveryGroupId") #end
		</td>
	</tr>
	<tr id="enquete_id">
		<td>アンケートID</td>
		<td>
			<input name="enqueteId" type="text" class="w100" value="$!escape.html($!mailRegistForm.enqueteId)">
			#if($!tools.getMsg("enqueteId")) <BR>$tools.getMsg("enqueteId") #end
		</td>
	</tr>
	<tr>
		<td>差出人名(From)</td>
		<td>$!mailRegistForm.sender</td>
		<input type="hidden" name="sender" value="$!mailRegistForm.sender">
	</tr>
	<tr>
		<td style="vertical-align:top">メール本文</td>
		<td>
	 		<textarea name="mailBody" cols="35" rows="20" class="w600 mgt5">$!mailRegistForm.mailBody</textarea>
	 		#if($!tools.getMsg("mailBody")) <BR>$tools.getMsg("mailBody") #end
	 	<br>
	 	<input type="button" class="button" onClick="OpenSrchWindow();" value="予約語挿入"/>&nbsp;&nbsp;&nbsp;
		<button class="button" onclick="save_mail('2'); return false;">一時保存</button>&nbsp;&nbsp;&nbsp;
		</td>
	</tr>

<!--	<tr>

	<td align="left">
		<input type="button" class="button" onClick="OpenSrchWindow();" value="予約語挿入"/>&nbsp;&nbsp;&nbsp;
		<button class="button" onclick="save_mail('2'); return false;">一時保存</button>&nbsp;&nbsp;&nbsp;
	</td>
	</tr>
-->
	<tr id="send_target">
		<td style="vertical-align:top">配信対象</td>
		<td>
			<select name="deliveryTargetType" id="deliveryTargetType"  class="w200">
				<option value=""></option>
				<option value="0" #if ( "$!{mailRegistForm.deliveryTargetType}" == "0" ) selected #end>PC用のアドレスのみ</option>
				<option value="1" #if ( "$!{mailRegistForm.deliveryTargetType}" == "1" ) selected #end>携帯用のアドレスのみ</option>
			</select>
		#if($!tools.getMsg("deliveryTargetType")) <BR>$tools.getMsg("deliveryTargetType") #end
		</td>
	</tr>

	</tr>
	<tr>
		<td style="vertical-align:top">テスト配信</td>
		<td>&nbsp;&nbsp;メールアドレス
	<input name="testMail" type="text" / class="w300 mgl10" value="$!escape.html($!mailRegistForm.testMail)">
	<input type="submit" name="button" id="button" onclick="send_mail(); return false;" value="送信" / class="w60">
	#if($!tools.getMsg("testMail")) <BR>$tools.getMsg("testMail") #end
		</td>
	</tr>
	<tr>
		<td rowspan="2" style="vertical-align:top">配信方法</td>
		<td>
		#if($!mailRegistForm.deliveryTargetMethod)
			<input type="radio" name="deliveryTargetMethod" onclick="change('0');" value="0" #if($!mailRegistForm.deliveryTargetMethod == "0")checked#end>時間指定&nbsp;&nbsp;
		#else
			<input type="radio" name="deliveryTargetMethod" onclick="change('0');" value="0" >時間指定&nbsp;&nbsp;
		#end
			##<input name="" type="text" / class="w90 mgl10">

			<input name="deliveryDate" id="deliveryDate" type="text" / class="w90 mgl10" value="$!escape.html($!mailRegistForm.deliveryDate)">
			<div style="display: none;"><img id="calFromDate" src="/em/images/icon_cal.gif" style="padding-left:5px;padding-right:5px; vertical-align: middle;"></div>

			<select name="deliveryHour" id="deliveryHour"  class="w50 mgl5">
				<option value=""></option>
				#foreach($mm in [0..23])
					#if($!mailRegistForm.deliveryHour && $!mailRegistForm.deliveryHour != "")
						#if($mm == $!mailRegistForm.deliveryHour)
							<option value="$!mm" selected>#he($!mm)</option>
						#else
							<option value="$!mm">#he($!mm)</option>
						#end
					#else
						<option value="$!mm">#he($!mm)</option>
					#end
				#end
			</select>時
			<select name="deliveryMin" id="deliveryMin"  class="w50 mgl50">
				<option value=""></option>
				#foreach($mm in ['00','10','20','30','40','50'])
					#if($!mailRegistForm.deliveryMin && $!mailRegistForm.deliveryMin != "")
						#if($mm == $!mailRegistForm.deliveryMin)
							<option value="$!mm" selected>#he($!mm)</option>
						#else
							<option value="$!mm">#he($!mm)</option>
						#end
					#else
						<option value="$!mm">#he($!mm)</option>
					#end
				#end
			</select>分
		#if($!tools.getMsg("deliveryDate")) <br>$tools.getMsg("deliveryDate") $tools.getMsg("deliveryDate_1") $tools.getMsg("deliveryDate_2") #end
		#if($!tools.getMsg("deliveryHour")) $tools.getMsg("deliveryHour") #end
		#if($!tools.getMsg("deliveryMin")) $tools.getMsg("deliveryMin") #end
		</td>
	</tr>
	<tr>
		<td>
		#if($!mailRegistForm.deliveryTargetMethod)
			<input type="radio" name="deliveryTargetMethod" onclick="change('1');" value="1" #if($!mailRegistForm.deliveryTargetMethod == "1")checked#end>即時配信&nbsp;&nbsp;
		#else
			<input type="radio" name="deliveryTargetMethod" onclick="change('1');" value="1" >即時配信&nbsp;&nbsp;
		#end
		#if($!tools.getMsg("deliveryTargetMethod")) 
			<BR>$tools.getMsg("deliveryTargetMethod") 
		#end

		</td>
	</tr>

</table>
<div class="btn_area2" style="width:840px;">
		<button class="button" onclick="send_check('1'); return false;">配信予約</button>
</div>
##</div>
##</div>

</form>
</div>
</div>
<div id="contents_bottom">
<img src="/em/images/bg_contents_bottom.jpg" width="1036" height="15" /> </div> </div>
</div>
</div>
</div>

#parse( "/WEB-INF/view/common/footer_admin.vm" )