#*
 * Aipo is a groupware program developed by Aimluck,Inc.
 * http://aipostyle.com/
 * 
 * Copyright(C) 2010 avanza Co.,Ltd. All rights reserved.
 * http://www.avnz.co.jp/
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU 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 General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *#
## ---------------------------------------------------------------------------
#set ($tabs = [["インポート", "import", "$!jslink.getPortletById($!portlet.ID).addQueryData('template','CoordinationForGoogleCalImportScreen').addQueryData('tab','import')"], ["エクスポート", "export", "$!jslink.getPortletById($!portlet.ID).addQueryData('template','CoordinationForGoogleCalExportScreen').addQueryData('tab','export')"]])
#set ($indicator_id = "indicator-dlg-")
#set ($allday_flg = "終日予定")
#set ($err_flg = "不可")
## ---------------------------------------------------------------------------
#ALajaxtabheader($tabs $!result.currentTab)
<form name="readics" action="$!jslink.getPortletById($!portlet.ID).addQueryData('eventSubmit_doSchedule_upload_ics','1').addQueryData('act','reading').addQueryData('tab','import')" method="post" enctype="multipart/form-data">
<input type="hidden" name="secid" value="$secid" />
<input type="hidden" name="temp_folder" value="$temp_folder"/>

<div style="margin:0px 0px 5px 0px">
スケジュールを一括登録します。
<a href="$jslink.getTemplate('CoordinationForGoogleCalICSSampleFileScreen')">こちらのテンプレート</a>の形式で作成したファイルをボタン [参照...] で指定し、
ボタン [読み込む] を押してください。
確認画面が表示された後に、ボタン [登録] を押すことで、登録が完了します。
</div>
#ALtableheaderWide()
	<tr>
		<td width="150" class="caption">ICSファイルの指定</td>
		<td nowrap="nowrap">
			<input class="text" type="file" name="attachment" value="" size="30" style="ime-mode:disable">
		</td>
	</tr>
	<tr>
		<td width="150" class="caption">インポートする期間指定</td>
		<td>
			#if( "$!result.TimeSelectFlg" == "day_select" )
				#set( $div_unit_month_style = "display:none;" )
				#set( $div_unit_day_style = "display:block;" )
			#else
				#set( $div_unit_month_style = "display:block;" )
				#set( $div_unit_day_style = "display:none;" )
			#end
			<div id="div_unit_month" style="$div_unit_month_style">
				<input type="button" onClick="aipo.coordinationforgooglecal.changeSummaryUnit('day');" value="日単位指定に切り替える"/>
				<select name="view_date_year_from" id="view_date_year_from" size="1">
				#set($end_year = 2015)
				#foreach ( $num in [2000..$!{end_year}] )
					<option value="$num" #if ($!result.FromDate.Year == "$num") selected="selected" #end>$num年</option>
				#end
				</select>
				<select name="view_date_month_from" id="view_date_month_from" size="1">
				#foreach ( $num in [1..12] )
					<option value="$num" #if ($!result.FromDate.Month == "$num") selected="selected" #end>$num月</option>
				#end
				</select>
				～
				<select name="view_date_year_to" id="view_date_year_to" size="1">
				#set($end_year = 2015)
				#foreach ( $num in [2000..$!{end_year}] )
					<option value="$num" #if ($!result.ToDate.Year == "$num") selected="selected" #end>$num年</option>
				#end
				</select>
				<select name="view_date_month_to" id="view_date_month_to" size="1">
				#foreach ( $num in [1..12] )
					<option value="$num" #if ($!result.ToDate.Month == "$num") selected="selected" #end>$num月</option>
				#end
				</select>
			</div>


			<div id="div_unit_day" style="$div_unit_day_style">
				<input type="button" onClick="aipo.coordinationforgooglecal.changeSummaryUnit('month');" value="月単位指定に切り替える"/>
				<div id="from"></div> 
				～
				<div id="to"></div> 
			</div>
			#if("$!result.PeriodFlg" == "no_period")
            <input type="checkbox" name="period" value="no_period" checked>期間の指定をしない</input>
			#else
			<input type="checkbox" name="period" value="no_period">期間の指定をしない</input>
			#end
		</td>
	</tr>

	<tr>
		<td colspan="9" align="center">
			<input name="send" class="button" type="submit" value="読み込む" onclick="aimluck.io.setHiddenValue(this);" />
			<input type="hidden" id="time_change" name="time_change" value="month_select" />
			<input id="default_from_date" type="hidden" value="$!{result.FromDate.Year}/$!{result.FromDate.Month}/$!{result.FromDate.Day}" />
			<input id="default_to_date" type="hidden" value="$!{result.ToDate.Year}/$!{result.ToDate.Month}/$!{result.ToDate.Day}" />
		</td>
	</tr>
#ALtablefooter()
</form>


<form name="importics" action="$!jslink.getPortletById($!portlet.ID).addQueryData('eventSubmit_doSchedule_import_ics','1').addQueryData('act','insert').addQueryData('tab','import')" method="post" enctype="multipart/form-data">
					<input type="hidden" name="temp_folder" value="$temp_folder">
					<input type="hidden" name="secid" value="$secid" />
					<input type="hidden" name="time_change" value="$time_change" />
					<input type="hidden" name="view_date_year_from" value="$view_date_year_from" />
					<input type="hidden" name="view_date_month_from" value="$view_date_month_from" />
					<input type="hidden" name="view_date_year_to" value="$view_date_year_to" />
					<input type="hidden" name="view_date_month_to" value="$view_date_month_to" />
					<input type="hidden" name="from_date" value="$from_date" />
					<input type="hidden" name="to_date" value="$to_date" />	
					<input type="hidden" name="period" value="$period" />
#if($result.Results.size() ==0 || !$result.Results)
#foreach ($record in $!result.ErrorMsg)
    <span class="caution">$record</span><br/>
#end
#else
#foreach ($record in $!result.ErrorMsg)
    <span class="caution">$record</span><br/>
#end

<div style="width:100%; overflow:auto;">
<table class="tableWrapper" style="margin: 1px -10000px 1px 1px"><tbody><tr><td>
<table class="listTable" width="1500px">
	<tbody>
		<tr>
			<th nowrap="nowrap" class="head">登録</th>
			<th nowrap="nowrap" class="head">予定</th>
			<th nowrap="nowrap" class="head">場所</th>
			<th nowrap="nowrap" class="head">内容</th>
			<th nowrap="nowrap" class="head">開始日時</th>
			<th nowrap="nowrap" class="head">終了日時</th>
			<th nowrap="nowrap" class="head">公開設定</th>
			<th nowrap="nowrap" class="head">繰り返し(期限)</th>
			<th nowrap="nowrap" class="head">作成日</th>
			<th nowrap="nowrap" class="head">更新日</th>
		</tr>
#foreach ($record in $!result.results)
		<tr>
			#if("$record.ErrorFlag"=="$err_flg")
            <td class="item" nowrap="nowrap"><span class="caution">(※)$record.ErrorFlag</span></td>
			#else
			<td class="item">$record.ErrorFlag</td>				
		    #end
			<td class="item" nowrap="nowrap">$record.Summary</td>
			<td class="item" >$record.Location</td>
			<td class="item" >$record.Description</td>
			#if("$record.StartEndTimeErr" == "$err_flg")
				#if("$record.RepeatRule" == "$allday_flg")
                    <td class="item" nowrap="nowrap"><span class="caution">(※)$record.StartDate.Year年$record.StartDate.Month月$record.StartDate.Day日</span></td>
				#else
                    <td class="item" nowrap="nowrap"><span class="caution">(※)$record.StartDate.Year年$record.StartDate.Month月$record.StartDate.Day日 $record.StartDate.Hour時$record.StartDate.Minute分</span></td>
				#end
				#if("$record.RepeatRule" == "$allday_flg")
                    <td class="item" nowrap="nowrap"><span class="caution">(※)$record.EndDate.Year年$record.EndDate.Month月$record.EndDate.Day日</span></td>
				#else
                    <td class="item" nowrap="nowrap"><span class="caution">(※)$record.EndDate.Year年$record.EndDate.Month月$record.EndDate.Day日 $record.EndDate.Hour時$record.EndDate.Minute分</span></td>
				#end
			#else
				#if("$record.RepeatRule" == "$allday_flg")
					<td class="item" nowrap="nowrap">$record.StartDate.Year年$record.StartDate.Month月$record.StartDate.Day日</td>
				#else
					<td class="item" nowrap="nowrap">$record.StartDate.Year年$record.StartDate.Month月$record.StartDate.Day日 $record.StartDate.Hour時$record.StartDate.Minute分</td>
				#end
				#if("$record.RepeatRule" == "$allday_flg")
					<td class="item" nowrap="nowrap">$record.EndDate.Year年$record.EndDate.Month月$record.EndDate.Day日</td>
				#else
					<td class="item" nowrap="nowrap">$record.EndDate.Year年$record.EndDate.Month月$record.EndDate.Day日 $record.EndDate.Hour時$record.EndDate.Minute分</td>
				#end
			#end
			<td class="item">$record.Classification</td>
			<td class="item" nowrap="nowrap">$record.RepeatRule</td>
			#if("$record.CreatedTimeErr" == "$err_flg")
            <td class="item" nowrap="nowrap"><span class="caution">(※)$record.Created.Year年$record.Created.Month月$record.Created.Day日</span></td>
			#else
			<td class="item" nowrap="nowrap">$record.Created.Year年$record.Created.Month月$record.Created.Day日</td>
			#end
			#if("$record.LastModifiedTimeErr" == "$err_flg")
            <td class="item" nowrap="nowrap"><span class="caution">(※)$record.LastModified.Year年$record.LastModified.Month月$record.LastModified.Day日</span></td>
			#else
			<td class="item" nowrap="nowrap">$record.LastModified.Year年$record.LastModified.Month月$record.LastModified.Day日</td>
			#end
		</tr>
#end
			<tr>
				<td colspan="10" align="center">
					#if($result.ErrorStrings.size() > 0)
					<input name="send" class="button" type="submit" value="正常な部分のみ登録する" onclick="aimluck.io.setHiddenValue(this);" />
					#else
					<input name="send" class="button" type="submit" value="登録する" onclick="aimluck.io.setHiddenValue(this);" />
					#end
					<input name="cancel" class="button" type="submit" value="キャンセル" onclick="returnTopPage(this.form);" />
				</td>
			</tr>
	</tbody>
</table>
</td></tr></tbody></table>
</div>
#end
</form>

#ALajaxtabfooter()

<script type="text/javascript">
<!-- 
#if( "$!result.TimeSelectFlg" == "day_select" )
dojo.addOnLoad(aipo.coordinationforgooglecal.changeSummaryUnit)
#end

function returnTopPage(form){
	form.action = "$!jslink.getPortletById($!portlet.ID).addQueryData('eventSubmit_doSchedule_import_ics','1').addQueryData('tab','import')";
	aimluck.io.submit(form, '${indicator_id}','$!portlet.ID',aipo.coordinationforgooglecal.onReceiveMessage);
	return false;
}
//-->
</script>