#*
 * Aipo is a groupware program developed by Aimluck,Inc.
 * Copyright (C) 2004-2011 Aimluck,Inc.
 * http://www.aipo.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *#

## ---------------------------------------------------------------------------
#if($mode=="new_form")
#set ($action_str = "追加する")
#set ($event_submit = "eventSubmit_doWebmail_insert_account")
#set ($subtitle = "新規メールアカウント追加")
#else
#set ($action_str = "更新する")
#set ($event_submit = "eventSubmit_doWebmail_update_account")
#set ($subtitle = "メールアカウント設定")
#end
#set ($indicator_id = "indicator-dlg-")
##----------------------------------------------------------------------------------
#ALdialogheader($subtitle)
#if(! ($mode=="new_form") && $!result.AccountId == 0)
#ALbuttonheader()
<div class="message">メールアカウントを選択してください。</div>
#ALajaxbuttonClose()
#ALbuttonfooter()
#else

#ALajaxIndicator("$indicator_id" "$!portlet.ID" "")
#ALerrmsg($errmsgs)
<div id="messageDiv"></div>
#ALajaxscreenformheader("webmailForm" $jslink $portlet "WebMailAccountFormJSONScreen" "aimluck.io.submit(this,'$indicator_id','$!portlet.ID',aipo.webmail.onReceiveMessage)")
#if($mode=="new_form")
<input type="hidden" name="mode" value="insert" />
#else
<input type="hidden" name="mode" value="update" />
#end
#ALtableheaderWide()
#ALtdcaptionAtt("#ALrequired($!result.getFieldName('account_name'))" "style='width:210px;'")
#ALtditem("#ALtextfield('account_name' $!result.AccountName '60%' 20 'active')")
#ALtdcaptionAtt("#ALrequired($!result.getFieldName('smtpserver_name'))" "style='width:210px;'")
#ALtditem("#ALtextfield('smtpserver_name' $!result.SmtpserverName '60%' 50 'disabled')#ALcaution('（半角英数字）')")
#ALtdcaptionAtt("#ALrequired($!result.getFieldName('pop3server_name'))" "style='width:210px;'")
#ALtditem("#ALtextfield('pop3server_name' $!result.Pop3serverName '60%' 50 'disabled')#ALcaution('（半角英数字）')")
#ALtdcaptionAtt("#ALrequired($!result.getFieldName('pop3user_name'))" "style='width:210px;'")
#ALtditem("#ALtextfield('pop3user_name' $!result.Pop3userName '60%' 50 'disabled')#ALcaution('（半角英数字）')")
#ALtdcaptionAtt("#ALrequired($!result.getFieldName('pop3_password'))" "style='width:210px;'")
#ALtditemheader()
<input class="text" name="pop3_password" value="$!result.Pop3Password" type="password" size="20" maxlength="50" >#ALcaution('（半角英数字）')
#ALtditemfooter()
#ALtdcaptionAtt("#ALrequired($!result.getFieldName('mail_user_name'))" "style='width:210px;'")
#ALtditem("#ALtextfield('mail_user_name' $!result.MailUserName '60%' 50 'active')")
#ALtdcaptionAtt("#ALrequired($!result.getFieldName('mail_address'))" "style='width:210px;'")
#ALtditem("#ALtextfield('mail_address' $!result.MailAddress '60%' 50 'disabled')#ALcaution('（半角英数字）')")
#ALtdcaptionAtt("#ALrequired($!result.getFieldName('smtp_port'))" "style='width:210px;'")
#ALtditem("#ALtextfield('smtp_port' $!result.SmtpPort '60%' 5 'disabled')#ALcaution('（半角数字）')")
#ALtdcaptionAtt("#ALrequired($!result.getFieldName('pop3_port'))" "style='width:210px;'")
#ALtditem("#ALtextfield('pop3_port' $!result.Pop3Port '60%' 5 'disabled')#ALcaution('（半角数字）')")
#ALtdcaptionAtt("#ALrequired($!result.getFieldName('auth_send_flg'))" "style='width:210px;'")
#ALtditemheader()
<input name="auth_send_flg" type="radio" value="0" id="$!{portlet.ID}auth_send_id0" #if ($!result.AuthSendFlg.toString() == "0") checked="checked" #end onclick="aipo.webmail.switchAuthSend(this)" />
<label for="$!{portlet.ID}auth_send_id0">認証なし</label>
<input name="auth_send_flg" type="radio" value="1" id="$!{portlet.ID}auth_send_id1" #if ($!result.AuthSendFlg.toString() == "1") checked="checked" #end onclick="aipo.webmail.switchAuthSend(this)" />
<label for="$!{portlet.ID}auth_send_id1">POP before SMTP</label>
<input name="auth_send_flg" type="radio" value="2" id="$!{portlet.ID}auth_send_id2" #if ($!result.AuthSendFlg.toString() == "2") checked="checked" #end onclick="aipo.webmail.switchAuthSend(this)" />
<label for="$!{portlet.ID}auth_send_id2">SMTP認証</label>
<span id="smtp_auth_field" style="display:#if (! ($!result.AuthSendFlg.toString() == "2"))none#end">
<div class="spaceTop">
<h3>SMTP認証情報#ALcaution('（半角英数字）')</h3>
<div style="padding:3px;width:70px;float:left;clear:both;">ユーザー</div>#ALtextfield('auth_send_user_id' $!{result.AuthSendUserId} '60%' 50 'disabled')
<br/>
<div style="padding:3px;width:70px;float:left;clear:both;">パスワード</div>#ALpasswdfield('auth_send_user_password' $!{result.AuthSendUserPasswd} '60%' 50 'disabled')
</div>
</span>
#ALtditemfooter()
#ALtdcaptionAtt("$!result.getFieldName('auth_receive_flag')" "style='width:210px;'")
#ALtditemheader()
<input name="auth_receive_flag" type="radio" value="0" id="$!{portlet.ID}auth_receive_id0" #if ($!result.AuthReceiveFlg.toString() == "0") checked="checked" #end>
<label for="$!{portlet.ID}auth_receive_id0">標準</label>
<input name="auth_receive_flag" type="radio" value="1" id="$!{portlet.ID}auth_receive_id1" #if ($!result.AuthReceiveFlg.toString() == "1") checked="checked" #end>
<label for="$!{portlet.ID}auth_receive_id1">APOP</label>
#ALtditemfooter()
#ALtdcaptionAtt("$!result.getFieldName('smtp_encryption_flag')" "style='width:210px;'")
#ALtditemheader()
<input name="smtp_encryption_flag" type="radio" value="0" id="$!{portlet.ID}smtp_encryption_id0" #if ($!result.SmtpEncryptionFlag.toString() == "0") checked="checked" #end>
<label for="$!{portlet.ID}smtp_encryption_id0">暗号化しない</label>
<input name="smtp_encryption_flag" type="radio" value="1" id="$!{portlet.ID}smtp_encryption_id1" #if ($!result.SmtpEncryptionFlag.toString() == "1") checked="checked" #end>
<label for="$!{portlet.ID}smtp_encryption_id1">SSL暗号化</label>
#ALtditemfooter()
#ALtdcaptionAtt("$!result.getFieldName('pop3_encryption_flag')" "style='width:210px;'")
#ALtditemheader()
<input name="pop3_encryption_flag" type="radio" value="0" id="$!{portlet.ID}pop3_encryption_id0" #if ($!result.Pop3EncryptionFlag.toString() == "0") checked="checked" #end>
<label for="$!{portlet.ID}pop3_encryption_id0">暗号化しない</label>
<input name="pop3_encryption_flag" type="radio" value="1" id="$!{portlet.ID}pop3_encryption_id1" #if ($!result.Pop3EncryptionFlag.toString() == "1") checked="checked" #end>
<label for="$!{portlet.ID}pop3_encryption_id1">SSL暗号化</label>
#ALtditemfooter()
#ALtdcaptionAtt($!result.getFieldName("del_at_pop3_flg") "style='width:210px;'")
<td class="item" nowrap="nowrap">
<input name="del_at_pop3_flg" type="radio" value="1" id="$!{portlet.ID}del_at_pop3_flg_enable_id" #if ($!result.DelAtPop3Flg.toString() == "1") checked="checked" #end onclick="aipo.webmail.switchDelAtPop3(this)">
<label for="$!{portlet.ID}del_at_pop3_flg_enable_id">有効</label>
<input name="del_at_pop3_flg" type="radio" value="0" id="$!{portlet.ID}del_at_pop3_flg_disable_id" #if ($!result.DelAtPop3Flg.toString() == "0") checked="checked" #end onclick="aipo.webmail.switchDelAtPop3(this)">
<label for="$!{portlet.ID}del_at_pop3_flg_disable_id">無効</label>
<span id="del_at_pop3_flg_on_field" style="display:#if (! ($!result.DelAtPop3Flg.toString() == "0"))none;#end">
<br/><input name="del_at_pop3_before_days_flg" type="checkbox" value="1" id="$!{portlet.ID}del_at_pop3_for_days_flg_enable_id" #if ($!result.DelAtPop3BeforeDaysFlg.toString() == "1") checked="checked" #end>
<select name="del_at_pop3_before_days" witdth="30%">
#foreach ( $num in [1..100] )
<option value="$num" #if ($!result.DelAtPop3BeforeDays.toString() == "$num") selected #end>$num</option>
#end
</select>
<label for="$!{portlet.ID}del_at_pop3_for_days_flg_enable_id">日以上前の受信メールを自動的に削除</label>
</span>
<br />
<div style="font-size:.7em;">
※ご使用のメールサーバーの設定によっては、<br />
　メールが削除されないことがございます。
</div>
</td>
#ALtdcaptionAtt($!result.getFieldName("non_received_flg") "style='width:210px;'")
#ALtditemheader()
<input name="non_received_flg" type="radio" value="1" id="$!{portlet.ID}non_received_flg_enable_id" #if ($!result.NonReceivedFlg.toString() == "1") checked="checked" #end>
<label for="$!{portlet.ID}non_received_flg_enable_id">有効</label>
<input name="non_received_flg" type="radio" value="0" id="$!{portlet.ID}non_received_flg_disable_id" #if ($!result.NonReceivedFlg.toString() == "0") checked="checked" #end>
<label for="$!{portlet.ID}non_received_flg_disable_id">無効</label>
#ALtditemfooter()
#ALtdcaptionAtt("$!result.getFieldName('signature')" "style='width:210px;'")
#ALtditem("#ALtextarea('signature' $!result.Signature 10 20)")
#ALtablefooter()
#ALbuttonheader()
#ALsubmit($event_submit $action_str)#ALajaxbuttonClose()
#ALbuttonfooter()
#ALformfooter()
#end
#ALdialogfooter()
