<!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">
<body>
<form id="batchmod-form" method="post" action="${actionURI}">
<fieldset><legend>バッチで変更する属性</legend>
<table class="properties">
	<tr py:for="row in group(fields, 2, lambda f: f.type != 'textarea')"
		py:with="fullrow = len(row) == 1">
		<py:for each="idx, field in enumerate(row)">
			<th style="text-align: left" class="col${idx + 1}"
				py:if="idx == 0 or not fullrow">
				<input py:if="field" type="checkbox" id="bmod_flag_${field.name}" name="bmod_flag_${field.name}" />
				<label py:if="field" for="bmod_value_${field.name}" class="disabled">${field.label or field.name}:</label>
			</th>
			<td class="col${idx + 1}" py:if="idx == 0 or not fullrow"
				colspan="${fullrow and 3 or None}">
			<py:choose test="field.type" py:if="field">
				<select py:when="'select'" id="bmod_value_${field.name}"
					name="bmod_value_${field.name}" disabled="disabled">
					<option py:if="field.optional" />
					<option py:for="option in field.options" py:content="option"/>
				</select>
				<textarea py:when="'textarea'" id="bmod_value_${field.name}"
					name="bmod_value_${field.name}" cols="${field.width}"
					rows="${field.height}" disabled="disabled" />
				<span py:when="'checkbox'"> <input type="checkbox"
					id="bmod_value_${field.name}" name="bmod_value_${field.name}"
					value="1" disabled="disabled" /> <input type="hidden"
					name="bmod_value_checkbox_${field.name}" value="1" /> </span>
				<label py:when="'radio'"
					py:for="idx, option in enumerate(field.options)" class="disabled">
					<input type="radio" name="bmod_value_${field.name}" 
					value="${option}" disabled="disabled" /> ${option} 
				</label>
				<input py:otherwise="" type="text" id="bmod_value_${field.name}"
					name="bmod_value_${field.name}" value="" disabled="disabled" />
			</py:choose>
			</td>
		</py:for>
	</tr>
	<tr>
		<th style="text-align: left"><input type="checkbox"
			id="bmod_flag_comment" name="bmod_flag_comment" checked="checked" /> <label
			for="bmod_value_comment">コメント:</label></th>
		<td class="fullrow" colspan="3"><input type="text"
			id="bmod_value_comment" name="bmod_value_comment" value="" size="70" />
		</td>
	</tr>
</table>
<div>
<input type="hidden" name="selectedTickets" value=""/>
<input type="submit" id="batchmod" name="batchmod" value="チケットの一括更新" /></div>
<py:for each="constraint_name, constraint in constraints.items()">
  <py:for each="constraint_value in constraint['values']">
    <input type="hidden" name="${constraint_name}" value="${constraint_value}" />
    <input py:if="constraint['mode']" type="hidden" name="${constraint_name}_mode" value="${constraint['mode']}" />
  </py:for>
</py:for>
<py:for each="column in col">
  <input type="hidden" name="col" value="${column}" />
</py:for>
<input py:if="req.args['group']" type="hidden" name="group" value="${req.args['group']}" />
<input py:if="req.args['groupdesc']" type="hidden" name="groupdesc" value="${req.args['groupdesc']}" />
</fieldset>
<script type="text/javascript">
jQuery(document).ready(function($){
  $("table.listing tr td.id").each(
    function() {
      tId=$(this).text().substring(1); 
      $(this).before('<td><input type="checkbox" name="selectedTicket" class="bmod_selector" value="'+tId+'"/></td>');
    }  
  ) 
  $("table.listing tr th.id").each(
    function() { 
      $(this).before('<th class="bmod_selector"><input type="checkbox" name="bmod_toggleGroup" /></th>');
    }  
  ) 
  $("input[@name='bmod_toggleGroup']").click(function() { 
    $("tr td input.bmod_selector",$(this).parents("table.listing")).attr("checked",this.checked);
  })
  <py:for each="field in fields">
    $("input[@id=bmod_flag_${field.name}]").click(function() { $("*[@name=bmod_value_${field.name}]").enable(this.checked);} )
  </py:for>
  $("input#bmod_flag_comment").click(function() {enableControl("bmod_value_comment",this.checked);} )
  $("form#batchmod-form").submit(function() {
    var selectedTix=[];    
    $("input[@name=selectedTicket]:checked").each( function(){ selectedTix.push(this.value);} ); 
    $("input[@name=selectedTickets]").val(selectedTix);
  })
  $(document.getElementById("columns")).toggleClass("collapsed");
});
</script>
</form>
</body>
</html>