#*
 * Aipo is a groupware program developed by Aimluck,Inc.
 * Copyright (C) 2004-2010 Aimluck,Inc.
 * http://aipostyle.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 ($indicator_str = "データを送信")
#set ($action_str = "更新する")
#set ($subtitle = 'タイムカード編集')
#set ($event_submit = "eventSubmit_doExtTimecard_update")
#set ($tabs = [[$subtitle, "",""]])
#set ($indicator_id = "indicator-dlg-")

#set ($start_hour = $result.TimecardSystem.ChangeHour)
#set ($end_hour = $start_hour - 1)
## ---------------------------------------------------------------------------
#ALdialogheader($subtitle)
#ALerrmsg($errmsgs)
<div id="messageDiv"></div>
#ALajaxIndicator("$!portlet.ID" "${indicator_str}しています...")

#if($!result.IsPast)
#ALajaxscreenformheader("exttimecardForm" $jslink $portlet "ExtTimecardFormJSONScreen" "aipo.exttimecard.onSubmit(this); aimluck.io.submit(this,'$indicator_id','$!portlet.ID',aipo.exttimecard.onReceiveMessage)")
#else
#ALajaxscreenformheader("exttimecardForm" $jslink $portlet "ExtTimecardFormJSONScreen" "aimluck.io.submit(this,'$indicator_id','$!portlet.ID',aipo.exttimecard.onReceiveMessage)")
#end

#if($mode=="new_form")
<input type="hidden" name="mode" value="insert" />
#else
<input type="hidden" name="mode" value="update" />
#end

#ALtableheaderWide()
#ALtdcaption($!result.getFieldName('punch_date'))
<input type="hidden" name="punch_date_year" value=$!result.PunchDate.Year />
<input type="hidden" name="punch_date_month" value=$!result.PunchDate.Month />
<input type="hidden" name="punch_date_day" value=$!result.PunchDate.Day />
<input type="hidden" name="punch_date_hour" value="0" />
<input type="hidden" name="punch_date_minute" value="0" />
<input type="hidden" name="old_clock_in_time_hour" value="$!result.ClockInTime.Hour" />
<input type="hidden" name="old_clock_in_time_minute" value="$!result.ClockInTime.Minute" />
<input type="hidden" name="old_clock_out_time_hour" value="$!result.ClockOutTime.Hour" />
<input type="hidden" name="old_clock_out_time_minute" value="$!result.ClockOutTime.Minute" />

<!-- <input type="hidden" name="punch_date_second" value="0" /> -->
#ALtditem($!result.DateStr)

#ALtdcaption("#ALrequired($!result.getFieldName('type'))")
#ALtditemheader()
<input name="type" type="radio" value="P" id="typeP_$!{portlet.ID}" #if ($!result.Type.toString() == "P") checked="checked" #end /><label for="typeP_$!{portlet.ID}">出勤</label>
<input name="type" type="radio" value="A" id="typeA_$!{portlet.ID}" #if ($!result.Type.toString() == "A") checked="checked" #end /><label for="typeA_$!{portlet.ID}">欠勤</label>
<input name="type" type="radio" value="H" id="typeH_$!{portlet.ID}" #if ($!result.Type.toString() == "H") checked="checked" #end /><label for="typeH_$!{portlet.ID}">有休</label>
<input name="type" type="radio" value="C" id="typeC_$!{portlet.ID}" #if ($!result.Type.toString() == "C") checked="checked" #end /><label for="typeC_$!{portlet.ID}">代休</label>
<input name="type" type="radio" value="E" id="typeE_$!{portlet.ID}" #if ($!result.Type.toString() == "E") checked="checked" #end /><label for="typeE_$!{portlet.ID}">その他</label>
#ALtditemfooter()

#if($!result.IsPast)
#ALtdcaption($!result.getFieldName('clock_in_time'))
#ALtditemheader()
<select name="clock_in_time_hour" size="1" >
<option value="-1">--</option>
#foreach ( $num in [$start_hour..23] )
<option value="$num" #if ($!result.ClockInTime.Hour == "$num") selected="selected" #end>$num時</option>
#end
#if ($end_hour > -1)
#set($num = 23)
#foreach ( $num2 in [0..$end_hour] )
#set($num = $num + 1)
<option value="$num" #if ($!result.ClockInTime.Hour == "$num2") selected="selected" #end>$num2時</option>
#end
#end
</select>
<select name="clock_in_time_minute" size="1">
<option value="-1">--</option>
#foreach ( $num in [0..59] )
<option value="$num" #if ($!result.ClockInTime.Minute == "$num") selected="selected" #end>$num分</option>
#end
</select>
～
<select name="clock_out_time_hour" size="1" >
<option value="-1">--</option>
#foreach ( $num in [$start_hour..23] )
<option value="$num" #if ($!result.ClockOutTime.Hour == "$num") selected="selected" #end>$num時</option>
#end
#if ($end_hour > -1)
#set($num = 23)
#foreach ( $num2 in [0..$end_hour] )
#set($num = $num + 1)
<option value="$num" #if ($!result.ClockOutTime.Hour == "$num2") selected="selected" #end>$num2時</option>
#end
#end
</select>
<select name="clock_out_time_minute" size="1">
<option value="-1">--</option>
#foreach ( $num in [0..59] )
<option value="$num" #if ($!result.ClockOutTime.Minute == "$num") selected="selected" #end>$num分</option>
#end
</select>
<br />
<h2>$!result.getFieldName('reason')&nbsp;<span class="small">#ALcaution("(必須)")</span></h2>
#ALtextfield('reason' $!result.Reason '90%' 50 'active')

#ALtditemfooter()

#ALtdcaption($!result.getFieldName('outgoing_comeback'))
#ALtditemheader()
#foreach ( $outcome in [1..5] )
<span id="rest_num${outcome}" #if($outcome > $result.RestNum) style="display:none" #end>
	
<select name=outgoing_time$!{outcome}_hour size="1" >
<option value="-1">--</option>
#foreach ( $num in [$start_hour..23] )
<option value="$num" #if ($!result.getOutgoingTime($outcome).Hour == "$num") selected="selected" #end>$num時</option>
#end
#if ($end_hour > -1)
#set($num = 23)
#foreach ( $num2 in [0..$end_hour] )
#set($num = $num + 1)
<option value="$num" #if ($!result.getOutgoingTime($outcome).Hour == "$num2") selected="selected" #end>$num2時</option>
#end
#end
</select>
<select name=outgoing_time$!{outcome}_minute size="1">
<option value="-1">--</option>
#foreach ( $num in [0..59] )
<option value="$num" #if ($!result.getOutgoingTime($outcome).Minute == "$num") selected="selected" #end>$num分</option>
#end
</select>
～
<select name=comeback_time$!{outcome}_hour size="1" >
<option value="-1">--</option>
#foreach ( $num in [$start_hour..23] )
<option value="$num" #if ($!result.getComebackTime($outcome).Hour == "$num") selected="selected" #end>$num時</option>
#end
#if ($end_hour > -1)
#set($num = 23)
#foreach ( $num2 in [0..$end_hour] )
#set($num = $num + 1)
<option value="$num" #if ($!result.getComebackTime($outcome).Hour == "$num2") selected="selected" #end>$num2時</option>
#end
#end
</select>
<select name=comeback_time$!{outcome}_minute size="1">
<option value="-1">--</option>
#foreach ( $num in [0..59] )
<option value="$num" #if ($!result.getComebackTime($outcome).Minute == "$num") selected="selected" #end>$num分</option>
#end
</select>
<input class="plus$outcome" type="button" name="plus$outcome" id="plus$outcome" value="+" onClick="aipo.exttimecard.displayOutCome(this)" #if(!($outcome == $result.RestNum)) style="display:none" #end />
<br />
</span>

#end
#ALtditemfooter()
#end

#ALtdcaption($!result.getFieldName('remarks'))
#ALtditem("#ALtextfield('remarks' $!result.Remarks '90%' 50 'active')")

#ALtablefooter()
#ALbuttonheader()
#ALsubmit($event_submit $action_str)#ALajaxbuttonClose()
#ALbuttonfooter()
#ALformfooter()
#ALdialogfooter()
