#*
 * 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/>.
 *#

## ---------------------------------------------------------------------------

<div class="relativeBlock" style="margin-bottom:10px;">
<div class="absoluteRight">
<div class="auiSelectButton">
<ul>
#set($tab = ["ブロック", "calendar","$!jslink.getPortletById($!portlet.ID).addQueryData('template','ScheduleScreen').addQueryData('tab','calendar')"])
<li #if ($tab.get(1) == $!result.Viewtype) class="active"#end><a class="first" style="width:6em;" href="javascript:void(0);" onclick="aipo.viewPage('$!utils.escapeXML($tab.get(2))', '$!portlet.ID');"><span>$tab.get(0)</span></a></li>
#set($tab = ["日", "oneday-group","$!jslink.getPortletById($!portlet.ID).addQueryData('template','ScheduleScreen').addQueryData('tab','oneday-group')"])
<li #if ($tab.get(1) == $!result.Viewtype) class="active"#end><a style="width:3em;" href="javascript:void(0);" onclick="aipo.viewPage('$!utils.escapeXML($tab.get(2))', '$!portlet.ID');"><span>$tab.get(0)</span></a></li>
#set($tab = ["週", "weekly-group", "$!jslink.getPortletById($!portlet.ID).addQueryData('template','ScheduleScreen').addQueryData('tab','weekly-group')"])
<li #if ($tab.get(1) == $!result.Viewtype) class="active"#end><a style="width:3em;" href="javascript:void(0);" onclick="aipo.viewPage('$!utils.escapeXML($tab.get(2))', '$!portlet.ID');"><span>$tab.get(0)</span></a></li>
#set($tab = ["月", "monthly", "$!jslink.getPortletById($!portlet.ID).addQueryData('template','ScheduleScreen').addQueryData('tab','monthly')"])
<li #if ($tab.get(1) == $!result.Viewtype) class="active"#end><a class="last" style="width:3em;" href="javascript:void(0);" onclick="aipo.viewPage('$!utils.escapeXML($tab.get(2))', '$!portlet.ID');"><span>$tab.get(0)</span></a></li>
</ul>
</div>
</div>

<div class="clearfix">
<div class="auiSelectButton">
<ul>
<li style="width:4em;margin-right:10px;">
<a href="javascript:void(0);" class="btn" onclick="aipo.viewPage('$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","$!{schedulescreen}").addQueryData("view_month",$!{result.CurrentMonth.toString()}))', '$!portlet.ID');"><span>今月</span></a>
</li>
<li style="margin-right:5px;">
<a href="javascript:void(0);" class="btn arrow" onclick="aipo.viewPage('$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","$!{schedulescreen}").addQueryData("view_month",$!{result.PrevYear.toString()}))', '$!portlet.ID');"><span><img src="themes/$!theme/images/icon/icon_arrow_l_w.gif" alt="前年へ"></span></a>
</li>
<li>
<a href="javascript:void(0);" class="first arrow" onclick="aipo.viewPage('$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","$!{schedulescreen}").addQueryData("view_month",$!{result.PrevMonth.toString()}))', '$!portlet.ID');"><span><img src="themes/$!theme/images/icon/icon_arrow_l.gif" alt="前月へ"></span></a>
</li>
<li style="margin-right:5px;">
<a href="javascript:void(0);" class="last arrow" onclick="aipo.viewPage('$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","$!{schedulescreen}").addQueryData("view_month",$!{result.NextMonth.toString()}))', '$!portlet.ID');"><span><img src="themes/$!theme/images/icon/icon_arrow_r.gif" alt="翌月へ"></span></a>
</li>
<li style="margin-right:10px;">
<a href="javascript:void(0);" class="btn arrow" onclick="aipo.viewPage('$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","$!{schedulescreen}").addQueryData("view_month",$!{result.NextYear.toString()}))', '$!portlet.ID');"><span><img src="themes/$!theme/images/icon/icon_arrow_r_w.gif" alt="翌年へ"></span></a>
</li>
</ul>
</div>
<div style="height:24px; line-height:24px; overflow:hidden;"><strong>$!{result.ViewMonth.Year}年$!{result.ViewMonth.Month}月</strong></div>
</div>

</div>
ユーザー：
<select onchange="aipo.viewPage(this.options[this.selectedIndex].value, '$!portlet.ID')" style="margin:0 0 5px; vertical-align:middle;">
<option value="$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","$!{schedulescreen}").addQueryData("target_group_name","all").addQueryData("target_user_id","none"))">（グループ全体）</option>
#if ($result.FacilityList.size() > 0)
<option value="$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","$!{schedulescreen}").addQueryData("target_group_name","Facility"))" #if ($!result.TargetGroupName && $!result.TargetGroupName == "Facility") selected="selected" #end>施設一覧</option>
#end
#foreach( $record in $result.MyGroupList )
<option value="$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","$!{schedulescreen}").addQueryData("target_group_name",$!{record.Name.toString()}).addQueryData("target_user_id","none"))" #if($!result.TargetGroupName == $!record.Name.toString()) selected="selected" #end>$!record.AliasName</option>
#end
#if($!{result.GroupList} && ($result.GroupList.size() > 0) && ${result.PostMap} && ($result.PostMap.size() > 0))
<option value="$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","$!{schedulescreen}").addQueryData("target_group_name","all").addQueryData("target_user_id", "none"))" #if ($!result.CurrentFilter == $!record.Name.toString()) selected="selected" #end>----------</option>
#end
#foreach( $record in $result.PostMap )
<option value="$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","$!{schedulescreen}").addQueryData("target_group_name",$!{record.GroupName.toString()}).addQueryData("target_user_id", "none"))" #if($!result.TargetGroupName == $!record.GroupName.toString()) selected="selected" #end>$!record.PostName</option>
#end
</select>
<select name="target_user_id" onchange="aipo.viewPage(this.options[this.selectedIndex].value, '$!portlet.ID')" style="margin:0 0 5px; vertical-align:middle;">
<option value="$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","$!{schedulescreen}").addQueryData("target_group_name",$!{result.TargetGroupName}).addQueryData("target_user_id","none"))">（ユーザー／施設の選択）</option>
#foreach($record in $!result.Users)
<option value="$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","$!{schedulescreen}").addQueryData("target_group_name",$!{result.TargetGroupName}).addQueryData("target_user_id",$!{record.UserId.toString()}))" #if($!result.TargetUserId != "all") #if($!result.TargetUserId == $!record.UserId.toString()) selected="selected" #end #end>$!record.AliasName</option>
#end
#if(($result.Users.size() > 0) && ($result.FacilityList.size() > 0))
<option value="$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","$!{schedulescreen}").addQueryData("target_group_name","all").addQueryData("target_user_id", "none"))" #if ($result.CurrentFilter && $!result.CurrentFilter == $!record.Name.toString()) selected="selected" #end>----------</option>
#end
#foreach($record in $!result.FacilityList)
<option value="$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","$!{schedulescreen}").addQueryData("target_group_name",$!{result.TargetGroupName}).addQueryData("target_user_id","f$!{record.FacilityId.toString()}"))" #if($!result.TargetUserId != "all") #if($!result.TargetUserId == "f$!record.FacilityId.toString()") selected="selected" #end #end>$!record.FacilityName</option>
#end
</select>
#if($!result.Users.size() <= 0 && $!result.FacilityList.size() <= 0)
<div class="message">選択したグループには、ユーザーおよび施設が登録されていません。</div>
#else
#ALtableheaderCalendar("100%")
<tr>
<th class='sunday'>
日<br />
<img src="images/common/dot.gif" width="50" height="1" alt="" />
</th>
<th>
月<br />
<img src="images/common/dot.gif" width="50" height="1" alt="" />
</th>
<th>
火<br />
<img src="images/common/dot.gif" width="50" height="1" alt="" />
</th>
<th>
水<br />
<img src="images/common/dot.gif" width="50" height="1" alt="" />
</th>
<th>
木<br />
<img src="images/common/dot.gif" width="50" height="1" alt="" />
</th>
<th>
金<br />
<img src="images/common/dot.gif" width="50" height="1" alt="" />
</th>
<th class='saturday'>
土<br />
<img src="images/common/dot.gif" width="50" height="1" alt="" />
</th>
</tr>
#set($entityids = "")
#set($weekListSize = $result.Container.WeekList.size())
#set($weekcount = 0)
#foreach($record4 in $result.Container.WeekList)
#set($termConListSize = ${result.TermContainer.getWeekList($weekcount).size()})
#if($!{result.ToDoContainer.getWeekList($weekcount)})
#set($todoConList = $!{result.ToDoContainer.getWeekList($weekcount)})
#if($!todoConList) #set($todoConListSize = $!{todoConList.size()}) #else #set($todoConListSize = 0) #end
#else #set($todoConListSize = 0)
#end
<tr>
#foreach($record in $record4.DayList)
#set($getScheduleDetailLink = $!jslink.getPortletById($!portlet.ID).addQueryData('template','ScheduleDetailJSONScreen').addQueryData('view_date', $!{record.Date.toString()}))
#set ($color_style = "")
#set ($color_style_holiday = "")
#set ($color_style_othermonth = "")
#set ($holiday_name = "")
#if($!{record.Date.Value.Day} == 0)
#set ($color_style = " sunday2")
#elseif($!{record.Date.Value.Day} == 6)
#set ($color_style = " saturday2")
#end
#if($!{record.isHoliday()})
#set ($color_style_holiday = " holiday2")
#set ($holiday_name = "${record.Holiday.Name}")
#end
#if(! ($!{result.ViewMonth.Month.toString()} == ${record.Date.Month.toString()}))
#set ($color_style_othermonth = " off2")
#end

<td class="day${color_style}${color_style_holiday}${color_style_othermonth}">
<div class="calendarDay clearfix">#if($!{record.isHoliday()})<span class="alignleft small">${holiday_name}</span>#end<span class="alignright small">$!{record.Date.Day}</span></div>
</td>
#end
</tr>
### 期間スケジュール（ここから） ###
#if($termConListSize > 0)
#foreach($termcontainer in ${result.TermContainer.getWeekList($weekcount)})
<tr>
#set($nottermcount = 0)
#foreach($record in $termcontainer.DayList)
#set ($color_style = "")
#set ($color_style_holiday = "")
#set ($color_style_othermonth = "")
#if($!{result.Today.Value} == $!{record.Date.Value})
#set ($color_style = " today")
#elseif($!{record.Date.Value.Day} == 0)
#set ($color_style = " sunday")
#elseif($!{record.Date.Value.Day} == 6)
#set ($color_style = " saturday")
#end
#if($!{record.isHoliday()})
#set ($color_style_holiday = " holiday")
#end
#if(! ($!{result.ViewMonth.Month.toString()} == ${record.Date.Month.toString()}))
#set ($color_style_othermonth = " off")
#end
#if( ! $record.isTermNull() )

#set($entityids = "$!{entityids}$!{record.TermResultData.ScheduleId},")
##if($record.TermResultData.isShowDetail())
#set ($col_span = $!{record.TermResultData.Rowspan})
#set($addScheduleLink = "$!jslink.getPortletById($!portlet.ID).addQueryData('template','ScheduleDetailScreen').addQueryData('entityid',$!{record.TermResultData.ScheduleId}).addQueryData('userid', $!{result.TargetUserId}).addQueryData('view_date', $!{record.Date.toString()})")
<td colspan="$col_span" class="term${color_style}${color_style_holiday}${color_style_othermonth}">
#if(${record.TermResultData.isShowDetail()})
<div id="$!{portlet.ID}-$!{record.TermResultData.ScheduleId}" class="calerndarTermScheduleDiv small schedule-$!{portlet.ID}-$!{record.TermResultData.ScheduleId}">
<a href="javascript:void(0);" onclick="aipo.common.showDialog('$!utils.escapeXML($addScheduleLink)', '$!portlet.ID', aipo.schedule.onLoadScheduleDetail);" class="small">$!{record.TermResultData.WbrName}
#if(!${record.TermResultData.isPublic()})&nbsp;<img class="icon_schedule" src="images/schedule/schedule_secret.gif" alt="非公開" title="非公開" />#else<img class="dot_schedule" src="images/common/dot.gif" alt="" />#end
#if(${record.TermResultData.isTmpreserve()})<img class="icon_schedule" src="images/schedule/schedule_tmpreserve.gif" alt="仮スケジュール" title="仮スケジュール" />#end
</a>
#else
<div id="$!{portlet.ID}-$!{record.TermResultData.ScheduleId}" class="calerndarTermScheduleDiv small">
$!{record.TermResultData.WbrName}
#if(!${record.TermResultData.isPublic()})
<img class="icon_schedule" src="images/schedule/schedule_secret.gif" alt="非公開" title="非公開" />
#end
#if(${record.TermResultData.isTmpreserve()})
<img class="icon_schedule" src="images/schedule/schedule_tmpreserve.gif" alt="仮スケジュール" title="仮スケジュール" />
#end
#end
</div>
</td>
#set ($col_span = $col_span - 1)
##end
#else
<td class="term${color_style}${color_style_holiday}${color_style_othermonth}" #if($col_span > 0 ) style="display:none" #else style="display:" #end></td>
#set ($col_span = $col_span - 1)
#end
#end
</tr>
#end
#end
### 期間スケジュール（ここまで） ###
<tr>
#foreach($record in $record4.DayList)
#set ($color_style = "")
#set ($color_style_holiday = "")
#set ($color_style_othermonth = "")
#set ($holiday_name = "")
#if($!{result.Today.Value} == $!{record.Date.Value})
#set ($color_style = " today")
#elseif($!{record.Date.Value.Day} == 0)
#set ($color_style = " sunday")
#elseif($!{record.Date.Value.Day} == 6)
#set ($color_style = " saturday")
#end
#if($!{record.isHoliday()})
#set ($color_style_holiday = " holiday")
#set ($holiday_name = "${record.Holiday.Name}")
#end
#if(! ($!{result.ViewMonth.Month.toString()} == ${record.Date.Month.toString()}))
#set ($color_style_othermonth = " off")
#end

<td class="topNone${color_style}${color_style_holiday}${color_style_othermonth}">
#if($record.ScheduleList.size() <= 0)
<div class="calendarBody">
<div class="calendarScheduleDiv">
#if($!{result.hasAuthoritySelfInsert()} && (!$result.TargetUserId.startsWith('f') || $!{result.hasAuthorityFacilityInsert()}))
#if($result.TargetUserId.startsWith('f'))
#set($addScheduleLink = "$!jslink.getPortletById($!portlet.ID).addQueryData('template','ScheduleFormScreen').addQueryData('entityid','new').addQueryData('form_start', $!{record.Date.toString()}).addQueryData('form_end', $!{record.Date.toString()}).addQueryData('facility_to', $result.TargetUserId.substring(1))")
#elseif(($result.UserId != $result.TargetUserId) && $result.TargetUserName)
#set($addScheduleLink = "$!jslink.getPortletById($!portlet.ID).addQueryData('template','ScheduleFormScreen').addQueryData('entityid','new').addQueryData('form_start', $!{record.Date.toString()}).addQueryData('form_end', $!{record.Date.toString()}).addQueryData('member_to', $result.TargetUserName)")
#else
#set($addScheduleLink = "$!jslink.getPortletById($!portlet.ID).addQueryData('template','ScheduleFormScreen').addQueryData('entityid','new').addQueryData('form_start', $!{record.Date.toString()}).addQueryData('form_end', $!{record.Date.toString()})")
#end
<a href="javascript:void(0);" onclick="aipo.common.showDialog('$!utils.escapeXML($addScheduleLink)', '$!portlet.ID', aipo.schedule.onLoadScheduleDialog)" title="予定追加"><img class="icon_schedule" src="images/icon/icon_edit.gif" alt="予定追加" /></a>
#end
</div>
</div>
#else
#foreach($record2 in $record.ScheduleList)
#if(! ${record2.isDummy()})
<div>
#set($entityids = "$!{entityids}$!{record2.ScheduleId},")
#if($record2.isShowDetail())
#set($addScheduleLink = "$!jslink.getPortletById($!portlet.ID).addQueryData('template','ScheduleDetailScreen').addQueryData('entityid', $!{record2.ScheduleId}).addQueryData('userid', $!{result.TargetUserId}).addQueryData('view_date', $!{record.Date.toString()})")
<div class="calendarScheduleDiv">
<div class="small">$!{record2.Date}</div>
<div class="small schedule-$!{portlet.ID}-$!{record2.ScheduleId}"><a href="javascript:void(0);" onclick="aipo.common.showDialog('$!utils.escapeXML($addScheduleLink)', '$!portlet.ID', aipo.schedule.onLoadScheduleDetail)" class="small">$!{record2.WbrName}</a></div>
</div>
#else
<div class="calendarScheduleDiv">
<div class="small">$!{record2.Date}</div>
<div class="small">$!{record2.WbrName}</div>
</div>
#end
#if(! ${record2.isPublic()})
<img class="icon_schedule" src="images/schedule/schedule_secret.gif" alt="非公開" title="非公開" />
#end
#if($record2.isDuplicate())
<img class="icon_schedule" src="images/schedule/schedule_duplicate.gif" alt="重複スケジュール" title="重複スケジュール" />
#end
#if(${record2.isRepeat()})
<img class="icon_schedule" src="images/schedule/schedule_repeat.gif" alt="繰り返し" title="繰り返し" />
#end
#if($record2.isTmpreserve())
<img class="icon_schedule" src="images/schedule/schedule_tmpreserve.gif" alt="仮スケジュール" title="仮スケジュール" />
#end
</div>
#end
#end
<div class="calendarScheduleDiv">
#if($!{result.hasAuthoritySelfInsert()} && (!$result.TargetUserId.startsWith('f') || $!{result.hasAuthorityFacilityInsert()}))
#if($result.TargetUserId.startsWith('f'))
#set($addScheduleLink = "$!jslink.getPortletById($!portlet.ID).addQueryData('template','ScheduleFormScreen').addQueryData('entityid','new').addQueryData('form_start', $!{record.Date.toString()}).addQueryData('form_end', $!{record.Date.toString()}).addQueryData('facility_to', $result.TargetUserId.substring(1))")
#elseif(($result.UserId != $result.TargetUserId) && $result.TargetUserName)
#set($addScheduleLink = "$!jslink.getPortletById($!portlet.ID).addQueryData('template','ScheduleFormScreen').addQueryData('entityid','new').addQueryData('form_start', $!{record.Date.toString()}).addQueryData('form_end', $!{record.Date.toString()}).addQueryData('member_to', $result.TargetUserName)")
#else
#set($addScheduleLink = "$!jslink.getPortletById($!portlet.ID).addQueryData('template','ScheduleFormScreen').addQueryData('entityid','new').addQueryData('form_start', $!{record.Date.toString()}).addQueryData('form_end', $!{record.Date.toString()})")
#end
<a href="javascript:void(0);" onclick="aipo.common.showDialog('$!utils.escapeXML($addScheduleLink)', '$!portlet.ID', aipo.schedule.onLoadScheduleDialog)" title="予定追加"><img class="icon_schedule" src="images/icon/icon_edit.gif" alt="予定追加" /></a>
#end
</div>
#end
<div class="calendarFooter"></div>
</td>
#end
</tr>

#if($todoConListSize > 0)
#foreach($todocontainer in ${result.ToDoContainer.getWeekList($weekcount)})
<tr>
#set($nottodocount = 0)
#foreach($record in $todocontainer.DayList)
#if( ! $record.isTodoNull() )
#if($nottodocount > 0)
#ALtdcellAtt("" "colspan='$nottodocount'")
#end
#ALtdcellheaderAtt("colspan='$!{record.ToDoResultData.Rowspan}' align='center'")
<div class="calerndarTodoDiv small">
#if($result.TargetUserId == $result.UserId)
<a class="small" href="javascript:void(0);" onclick="aipo.common.showDialog('$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","ToDoDetailScreen").addQueryData("entityid",$!{record.ToDoResultData.TodoId}))');">
#else
<a class="small" href="javascript:void(0);" onclick="aipo.common.showDialog('$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","ToDoPublicDetailScreen").addQueryData("entityid",$!{record.ToDoResultData.TodoId}))');">
#end
##<a class="small" href="javascript:void(0);" onclick="aipo.common.showDialog('$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","ToDoDetailScreen").addQueryData("entityid",$!{record.ToDoResultData.TodoId}))');">
$!{record.ToDoResultData.TodoName}
#if(! ${record.ToDoResultData.isPublic()})
<img class="icon_schedule" src="images/schedule/schedule_secret.gif" alt="非公開" title="非公開" />
#end
</a>
</div>
</td>
#set($nottodocount = 0)
#elseif (! $record.isHasTodo() )
#set($nottodocount = $nottodocount + 1)
#end
#end
#if($nottodocount > 0)
#ALtdcellAtt("" "colspan='$nottodocount'")
#end
</tr>
#end
#end

#set($weekcount = $weekcount + 1)
#end
#ALtablefooter()
#end

#if($!ajax_onloadimage)
  <img src="images/common/dot.gif" width="1" height="1" onload="aipo.schedule.setupTooltip('$!{getScheduleDetailLink}', '$!entityids', '$!portlet.ID');ptConfig['$!portlet.ID'].reloadFunction = aipo.reloadPage;" />
#else
  <script type="text/javascript" language="JavaScript">
    //<![CDATA[
    dojo.addOnLoad(function(){
      aipo.schedule.setupTooltip('$!{getScheduleDetailLink}', '$!entityids', '$!portlet.ID');
      ptConfig['$!portlet.ID'].reloadFunction = aipo.reloadPage;
    });
    //]]>
  </script>
#end
