<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">
  <xi:include href="layout.html" />
  <xi:include href="macros.html" />

      <head>
	<title>作業時間入力</title>
    <script type="text/javascript" src="${chrome.htdocs_location}js/wikitoolbar.js"></script>
    <script type="text/javascript" py:choose="">
      $(document).ready(function() {
          $("div.description").find("h1,h2,h3,h4,h5,h6").addAnchor("Link to this section");
        });
    </script>
      </head>

      <body>
<div id="content">
<br />
<br />
<h1>作業時間入力</h1>
作業時間とタスクの残り時間を入力します。最低でも1日一回入力を行ってください。<br />
「作業履歴を見る」から最近のあなたの作業内容を確認することができます。

<form action="${req.href('timeline')}">
<input type="hidden" name="from" value="${today.year}/${today.month}/${today.day}" />
<input type="hidden" name="daysback" value="2"/>
<input type="hidden" name="authors" value="${req.authname}"/>
<input type="hidden" name="build" value="on"/>
<input type="hidden" name="wiki" value="on"/>
<input type="hidden" name="ticket" value="on"/>
<input type="hidden" name="milestone" value="on"/>
<input type="hidden" name="changeset" value="on"/>
<input type="hidden" name="update" value="更新"/>
<input type="submit" value="作業履歴を見る" />
</form>

<form method="post" action="${req.href('worktime')}" autocomplete="off"  >
<div py:for="m in tickets.keys()" py:with="mtickets = tickets[m]">
<h2>${m}</h2>
<table border="0" cellspacing="0" cellpadding="0" class="listing tickets">
<thead>
  <tr>
    <th>ID</th>
    <th style="min-width: 20em;">概要</th>
    <th style="min-width: 7em;">分類</th>
    <th>担当者</th>
    <th style="min-width: 6em;">優先度</th>
    <th>マイルストーン</th>
    <th>集計に<br />含める?</th>
    <th>今日の<br />作業時間</th>
    <th>残作業時間</th>
    <th>作業時間計<br />　/見積時間</th>
  </tr>
</thead>
<tbody>
    <div py:for="p in mtickets.keys()" py:with="ptickets = mtickets[p]">
<!--        <div py:for="t in ptickets" >-->
    <tr>
    
    <th colspan="10" style="background:#ddd;"><a
    href="${req.href.ticket()}/${p[0]}">${p[1]}(#${p[0]})</a></th>
    </tr>  
          <tr py:for="ticket in ptickets" 
      style="${'background: #aaa;' if ticket.billable=='false' else None}">
    <th><a href="${req.href.ticket()}/${ticket.id}#field_totalhours">#${ticket.id}</a></th>
    <th>${ticket.summary}</th>
    <th>${ticket.type}</th>
    <th>${ticket.owner}</th>
    <th>${ticket.priority}</th>
    <th>${ticket.milestone}</th>
    <th><input type="checkbox" name="billable_${ticket.id}" checked="${ticket.billable=='true' or None}" onchange="
if(this.checked){ 
 $('#hours_${ticket.id}').removeAttr('readonly');
} else {
 $('#hours_${ticket.id}').attr('readonly','readonly');
}
"/></th>
    <th  style="white-space:nowrap;">
      <span py:if="not ticket.reported">
 <input name="hours_${ticket.id}" id="hours_${ticket.id}" size="2" type="text"
readonly="${ticket.billable=='false' or None}"
onchange="
remained_org = $('#remainedhours_${ticket.id}_old');
if(this.value!=''){
   remained = parseFloat(remained_org.text())-parseFloat(this.value); 
} else {
   remained = parseFloat(remained_org.text());
} 
if(remained &lt;= 0){
  remained = 0;
  $('#closedummy_${ticket.id}').attr('style','display:show;');
} else {
  $('#closedummy_${ticket.id}').attr('style','display:none;');
  $('#close_${ticket.id}').attr('checked', false);
}
$('#remainedhours_${ticket.id}').val(remained);
"/>
<span name="closedummy_${ticket.id}" id="closedummy_${ticket.id}" style="display:none;"><br />closeする?<input type="checkbox" name="close_${ticket.id}" id="closed_${ticket.id}" /></span>
</span>
      <span py:if="ticket.reported">本日の作業は入力済み</span>
    </th>
    <th style="white-space:nowrap;">
      <span id="remainedhours_${ticket.id}_old" name="remainedhours_${ticket.id}_old">${float(ticket.estimatedhours)-float(ticket.totalhours)}</span>h
      ⇒
      <span py:if="not ticket.reported">
        <input name="remainedhours_${ticket.id}" id="remainedhours_${ticket.id}" 
               readonly="${ticket.billable=='false' or None}"
               value="${float(ticket.estimatedhours)-float(ticket.totalhours)}" type="text" size="2" 
onchange="
  if(parseFloat(this.value)==0){
    $('#closedummy_${ticket.id}').attr('style','display:show;');
  } else {
    $('#closedummy_${ticket.id}').attr('style','display:none;');
  }
"
/>h
      </span>
      <span py:if="ticket.reported">${float(ticket.estimatedhours)-float(ticket.totalhours)}h(入力済)</span>
    </th>
    <th style="white-space:nowrap;">${ticket.totalhours}h/${ticket.estimatedhours}h</th>
  </tr>
   </div>


</tbody>
</table>
 </div>

<input type="submit" value="作業時間を反映" />
</form>
<ul>
<li>作業を入力済みのチケットに作業時間を入力したい場合は、各チケットの作業時間の項目に作業時間を入力してください。</li>
</ul>
</div>
</body>
</html>
