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

## ---------------------------------------------------------------------------
#set ($tabs = [["タイムカード一覧", "",""]])
## ---------------------------------------------------------------------------
#ALajaxtabheader($tabs "")
#ALspacebothheader()
#ALtableheaderSimpleWide()
#ALtdcaption('表示切替')
#ALtditemheader()
<div>
<select name="target_group_name" onchange="aipo.viewPage(this.options[this.selectedIndex].value, '$!portlet.ID')">
<option value="$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","ExtTimecardListScreen").addQueryData("target_group_name","all").addQueryData("target_user_id","none"))">（グループ全体）</option>
#foreach( $record in $!result.MyGroupList )
<option value="$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","ExtTimecardListScreen").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.MyGroupList.size() > 0) && ($result.PostMap.size() > 0))
<option value="$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","ExtTimecardListScreen").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","ExtTimecardListScreen").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')">
<option value="$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","ExtTimecardListScreen").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","ExtTimecardListScreen").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
</select>
</div>

#ALtditemfooter()
#ALtablefooter()

#if($result.DateListKeys.size() == 0)
<div class="message">指定された条件に該当するタイムカードはありません。</div>
#else
    
#if($!result.TargetUserId != "")
#if($!result.hasAclXlsExport())
<div>
<form name="ExtTimecard" action="$jslink.getTemplate('ExtTimecardXlsExportScreen')" method="post">
#ALtableheaderSimpleWide()
#ALtdcaption('エクスポート')
#ALtditemheader() 現在表示している一覧を
#ALsubmit('eventSubmit_doExtTimecard_download' 'ダウンロードする')
#ALtditemfooter()
#ALtablefooter()
<input type="hidden" name="target_user_id" value="$!result.TargetUserId"/>
##<input type="hidden" name="view_date_year" value="$!result.ViewDate.Year"/>
##<input type="hidden" name="view_date_month" value="$!result.ViewDate.Month"/>
<input type="hidden" name="view_month" value="$!result.ViewMonth"/>
</form>
</div>
#end

<table border="0" cellspacing="0" cellpadding="2">
<tr valign="middle"><td>
<a href="javascript:void(0);" onclick="aipo.viewPage('$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","ExtTimecardListScreen").addQueryData("view_month",$!{result.PrevMonth.toString()}))', '$!portlet.ID');" title="前月へ">
<img src="images/schedule/arrow_left.gif" border="0" alt="前月へ" /></a>&nbsp;
</td><td nowrap="nowrap" class="center"><span style="font-weight:bold">
$!{result.ViewMonth.Year} 年 $!{result.ViewMonth.Month} 月
</span></td><td>
<a href="javascript:void(0);" onclick="aipo.viewPage('$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","ExtTimecardListScreen").addQueryData("view_month",$!{result.NextMonth.toString()}))', '$!portlet.ID');" title="翌月へ">
<img src="images/schedule/arrow_right.gif" border="0" alt="翌月へ" /></a>&nbsp;
</td><td>
<a href="javascript:void(0);" onclick="aipo.viewPage('$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","ExtTimecardListScreen").addQueryData("view_month",$!{result.CurrentMonth.toString()}))', '$!portlet.ID');" title="今月へ">
<img src="images/schedule/schedule_currentmonth.gif" border="0" alt="今月へ" /></a>&nbsp;
</td></tr></table>

#if($!result.TargetUserId == $!result.UserId) #set($col_count = 6) #else #set($col_count = 5) #end

#ALtableheaderWide()
<tr>
#ALtdheadThin("日付")
#ALtdheadThin("勤務形態")
#ALtdheadThin("出勤")
#ALtdheadThin("退勤")
#ALtdheadThin("外出")
#ALtdheadThin("復帰")
#ALtdheadThin("就業")
#ALtdheadThin("残業")
#ALtdheadThin("休出")
#ALtdheadWide("修正理由、備考")
#if($!result.TargetUserId == $!result.UserId)
#ALtdheadThin(' ')
#end
</tr>

#foreach ($rdlist in $result.DateListKeys)
#set($isrd = $rdlist.IsResultData)
#if($isrd)
#set($rd = $rdlist.Rd)
#else
#set($rd = "")
#end

#set($outcomes = $rdlist.OutgoingComeback)
#set($listsize = $outcomes.size())
#set($saturday_sunday_holiday = $rdlist.IsSaturdayOrSundayOrHoliday)
#set($beforeafter = $rdlist.BeforeAfter)
#set($entityid = "")
#if($isrd)
#set($entityid = $rd.TimecardId.toString())
#else
#set($entityid = "new")
#end

#set($class = "")
#if($saturday_sunday_holiday == 1)
#set($class = "saturday")
#elseif($saturday_sunday_holiday == 2)
#set($class = "sunday")
#elseif($saturday_sunday_holiday == 3)
#set($class = "holiday")
#end
#if($beforeafter == 0)
#set($class = "today")
#end

<tr>
#ALtdcellAtt($rdlist.DateStr "nowrap='nowrap' rowspan='$listsize' class='$class'")
#ALtdcellheaderAtt("align='center' rowspan='$listsize' class='$class'")
<a href="javascript:void(0);" onclick="aipo.common.showDialog('$!utils.escapeXML($!jslink.getPortletById($!portlet.ID).addQueryData("template","ExtTimecardSystemDetailScreen").addQueryData("entityid",$result.TimecardSystem.SystemId))');">$result.TimecardSystem.SystemName</a>
#ALtdcellfooter()

#if($beforeafter > 0)

#if($!{rd.IsTypeA} || $!{rd.IsTypeH} || $!{rd.IsTypeC} || $!{rd.IsTypeE} || $!{rd.IsTypeP})
<td nowrap='nowrap' align='center' colspan='7' class="$class">
#if($!{rd.IsTypeA})
    欠勤
#elseif($!{rd.IsTypeH})
    有休
#elseif($!{rd.IsTypeC})
    代休
#elseif($!{rd.IsTypeE})
    その他
#elseif($!{rd.IsTypeP})
    出勤
#end
</td>
#else
#ALtdcellAtt(" " "class='$class'")
#ALtdcellAtt(" " "class='$class'")
#ALtdcellAtt(" " "class='$class'")
#ALtdcellAtt(" " "class='$class'")
#ALtdcellAtt(" " "class='$class'")
#ALtdcellAtt(" " "class='$class'")
#ALtdcellAtt(" " "class='$class'")
#end

<td rowspan='$listsize' class='$class'>
#if($!{rd.ReasonFlg})
修正理由：$!{rd.Reason}
#if($!{rd.RemarksFlg})
	、
#end
#end
#if($!{rd.RemarksFlg})
備考：$!{rd.Remarks}
#end
</td>

#if($!result.TargetUserId == $!result.UserId)
#ALtdcellAtt("#ALajaxbuttonLinkCallback('編集' $!jslink.getPortletById($!portlet.ID).addQueryData('template','ExtTimecardFormScreen').addQueryData('eventSubmit_doExtTimecard_form','1').addQueryData('entityid', $entityid).addQueryData('date', $rdlist.Date) 'images/icon/icon_edit.gif' $!portlet.ID 'aipo.exttimecard.onLoadExtTimecardDialog')" "nowrap='nowrap' rowspan='$listsize' class='$class'")
#end

#else

#set($first = 0)
#foreach ($outcome in $outcomes)

#if($first == 0)

#if($!{rd.IsTypeA} || $!{rd.IsTypeH} || $!{rd.IsTypeC} || $!{rd.IsTypeE})
<td nowrap='nowrap' align='center' colspan='7' class="$class">
#if($!{rd.IsTypeA})
    欠勤
#elseif($!{rd.IsTypeH})
    有休
#elseif($!{rd.IsTypeC})
    代休
#elseif($!{rd.IsTypeE})
    その他
#end
</td>
<td rowspan='$listsize' class='$class'>
#if($!{rd.ReasonFlg})
修正理由：$!{rd.Reason}
#if($!{rd.RemarksFlg})
	、
#end
#end
#if($!{rd.RemarksFlg})
備考：$!{rd.Remarks}
#end
</td>
#if($!result.TargetUserId == $!result.UserId)
#ALtdcellAtt("#ALajaxbuttonLinkCallback('編集' $!jslink.getPortletById($!portlet.ID).addQueryData('template','ExtTimecardFormScreen').addQueryData('eventSubmit_doExtTimecard_form','1').addQueryData('entityid', $entityid).addQueryData('date', $rdlist.Date) 'images/icon/icon_edit.gif' $!portlet.ID 'aipo.exttimecard.onLoadExtTimecardDialog')" "nowrap='nowrap' rowspan='$listsize' class='$class'")
#end
#else
#if($rdlist.IsNotNullClockInTime)
        #ALtdcellAtt("$!{rd.ClockInTime.Hour}時$!{rd.ClockInTime.Minute}分" "nowrap='nowrap' align='center' rowspan='$listsize' class='$class'")
#else
#if($saturday_sunday_holiday == 0)
#if($!result.TargetUserId == $!result.UserId)
#ALtdcellAtt("#ALajaxbuttonLinkCallback('未入力' $!jslink.getPortletById($!portlet.ID).addQueryData('template','ExtTimecardFormScreen').addQueryData('eventSubmit_doExtTimecard_form','1').addQueryData('entityid', $entityid).addQueryData('date', $rdlist.Date) 'images/icon/icon_edit.gif' $!portlet.ID 'aipo.exttimecard.onLoadExtTimecardDialog')" "nowrap='nowrap' rowspan='$listsize' class='$class'")
#else
#ALtdcellAtt('' "class='$class'")
#end
#else
#ALtdcellAtt("" "nowrap='nowrap' align='center' rowspan='$listsize' class='$class'")
#end
#end

#if($rdlist.IsNotNullClockOutTime)
    #ALtdcellAtt("$!{rd.ClockOutTime.Hour}時$!{rd.ClockOutTime.Minute}分" "nowrap='nowrap' align='center' rowspan='$listsize' class='$class'")
#else
#if($saturday_sunday_holiday == 0)
#if($!result.TargetUserId == $!result.UserId)
#ALtdcellAtt("#ALajaxbuttonLinkCallback('未入力' $!jslink.getPortletById($!portlet.ID).addQueryData('template','ExtTimecardFormScreen').addQueryData('eventSubmit_doExtTimecard_form','1').addQueryData('entityid', $entityid).addQueryData('date', $rdlist.Date) 'images/icon/icon_edit.gif' $!portlet.ID 'aipo.exttimecard.onLoadExtTimecardDialog')" "nowrap='nowrap' rowspan='$listsize' class='$class'")
#else
#ALtdcellAtt('' "class='$class'")
#end
#else
#ALtdcellAtt("" "nowrap='nowrap' align='center' rowspan='$listsize' class='$class'")
#end
#end

#ALtdcellAtt($outcome.get('outgoing') "align='center' nowrap='nowrap' class='$class'")
#ALtdcellAtt($outcome.get('comeback') "align='center' nowrap='nowrap' class='$class'")
#ALtdcellAtt("$!{rdlist.getHourToString($!{rdlist.getWorkHourWithoutRestHour(true)})}" "align='center' rowspan='$listsize' class='$class'")
#ALtdcellAtt("$!{rdlist.getHourToString($!{rdlist.getOvertimeHourWithoutRestHour(true)})}" "align='center' rowspan='$listsize' class='$class'")
#ALtdcellAtt("$!{rdlist.getHourToString($!{rdlist.getOffHour(true)})}" "align='center' rowspan='$listsize' class='$class'")

<td rowspan='$listsize' class='$class'>
#if($!{rd.ReasonFlg})
修正理由：$!{rd.Reason}
#if($!{rd.RemarksFlg})
	、
#end
#end
#if($!{rd.RemarksFlg})
備考：$!{rd.Remarks}
#end
</td>

#if($!result.TargetUserId == $!result.UserId)
#ALtdcellAtt("#ALajaxbuttonLinkCallback('編集' $!jslink.getPortletById($!portlet.ID).addQueryData('template','ExtTimecardFormScreen').addQueryData('eventSubmit_doExtTimecard_form','1').addQueryData('entityid', $entityid).addQueryData('date', $rdlist.Date) 'images/icon/icon_edit.gif' $!portlet.ID 'aipo.exttimecard.onLoadExtTimecardDialog')" "nowrap='nowrap' rowspan='$listsize' class='$class'")
#end

#end

#set($first = 1)
</tr>

#else

<tr>
#ALtdcellAtt($outcome.get('outgoing') "align='center' nowrap='nowrap' class='$class'")
#ALtdcellAtt($outcome.get('comeback') "align='center' nowrap='nowrap' class='$class'")
</tr>

#end
#end


#end

</tr>

#end
#ALtablefooter()
#else
<div class="message">指定されたグループにはユーザーが所属していません。</div>
#end
#end
#ALspacebothfooter()
#ALajaxtabfooter()
