	<% if @trOpen %>
		<% # close the previously opened tr %>
		<% while @wday_index < padTill %>
			<%
			disable = !@editable
			if @editable
				#hookCellEditPerm = call_hook(:view_cell_edit, :entry => entry)
				if @edittimelogs.blank?
					disable = !@prev_template && !entry.nil? && !entry.editable_by?(User.current)
				else
					if (@edittimelogs == 'true')
						disable = !@prev_template && !entry.nil? && !(to_boolean(@edittimelogs))
					elsif (@edittimelogs == 'false')
						if (!@manage_projects.blank? && @manage_projects.size > 0 && User.current.id != @user.id)
							disable = !@prev_template && !entry.nil? && !(to_boolean(@edittimelogs))
						else
							disable = !@prev_template && !entry.nil? && !entry.editable_by?(User.current)
						end
					end
				end
				if !entry.nil?
					disable = disable && !entry.id.blank?
				end
				disable = false if validateERPPermission('A_TE_PRVLG')
				disable = true if !@prev_template && isBilledTimeEntry(entry) || (entry&.has_attribute?('payroll_id') && entry&.payroll_id.to_i > 0)
			end
			disable = (!@prev_template && entry&.wkstatus&.status == 'a') if entry&.wkstatus&.status == 'a'
			spentForId = entry.present? && entry.spent_for.present? && !@prev_template ? entry.spent_for.id : nil
			holiday = WkPublicHoliday.getHolidays(params[:user_id], (@startday + @wday_index) - 1)
			holiday = holiday.length > 0
			hrs = ''
			isTemplate ||= false
			if entry.present? && entry&.hours.present? && (isTemplate || !@prev_template)
				hrs = "%.2f" % entry.hours
			end
			%>
			<%#if this is from a previous template, don't print the hours%>
			<td class="hours">
				<div style="float: left; ">
				<%=h text_field_tag('hours' + @row.to_s() +'[]', hrs ,:size => "#{controller.textfield_size}",
				:disabled => disable, class: "hrs_col_" + @wday_index.to_s(),
				:onchange => "validateTotal(this, #{@wday_index},'#{controller.maxHour}');") %>
				<%=h hidden_field_tag('ids' + @row.to_s() +'[]', entry.nil? || @prev_template ? '' : entry.id) %>
				<%=h hidden_field_tag('disabled' + @row.to_s() +'[]', disable ) %>
				<%= hidden_field_tag('spentForId' + @row.to_s() +'[]', spentForId ) %>
				<%= hidden_field_tag('holiday_' + @row.to_s() +"_"+ @wday_index.to_s(), holiday, class: "holidays" ) %>

				<% if controller.showAttachments %>
				<!-- Attachments -->
				<span id="<%= 'attachdiv_' + @row.to_s() + '_' + @wday_index.to_s %>"  style="display: none"  class="allAttach">
					<fieldset id="<%= 'attachment_' + @row.to_s() + '_' + @wday_index.to_s %>" class="attachment">
						<legend><%=l(:label_attachment)%></legend>
						<% if !@prev_template && entry.present? && entry.attachments.any? %>
							<%= attachments_links entry, { editable: true, deletable: true, hideImage: true, author: false} %>
						<% end %>
						<fieldset>
							<legend><%=l(:label_attachment_plural)%></legend>
							<%= render partial: 'attachments/form', locals: { attachment_param: "attachments_"+ @row.to_s() + '_' + @wday_index.to_s } %>
						</fieldset>
					</fieldset>
				</span>
				<% end %>
				<% cvs = [] %>
				<% show_custfield_img = false %>
				<% if Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].blank? ||
					Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].to_i == 0 %>
					<% show_custfield_img = true %>
					<%=h hidden_field_tag('comments' + @row.to_s() +'[]', entry.nil? || @prev_template && !isTemplate ? '' : entry.comments) %>
					<% comment = nil %>
					<% comment = entry.nil? || @prev_template && !isTemplate ? '' : entry.comments %>
					<% cvs << comment unless comment.blank? %>
				<% end %>

				<% if !Setting.plugin_redmine_wktime['wktime_use_detail_popup'].blank? &&
					Setting.plugin_redmine_wktime['wktime_use_detail_popup'].to_i == 1 %>

					<% show_custfield_img = true %>
					<% if !@new_custom_field_values.blank? %>
						<% custom_field_values = entry.nil? || @prev_template ?  @new_custom_field_values : entry.custom_field_values %>
						<% custom_field_values.each do |custom_value| %>

							<%if !((!Setting.plugin_redmine_wktime['wktime_enter_cf_in_row1'].blank? &&
								Setting.plugin_redmine_wktime['wktime_enter_cf_in_row1'].to_i == custom_value.custom_field.id) ||
								(!Setting.plugin_redmine_wktime['wktime_enter_cf_in_row2'].blank? &&
								Setting.plugin_redmine_wktime['wktime_enter_cf_in_row2'].to_i == custom_value.custom_field.id))%>

								<% cv = custom_value.custom_field.multiple? ?  custom_value.value.join(',') : custom_value.value %>
								<%=h hidden_field_tag('_custom_field_values_' + custom_value.custom_field.id.to_s + "_" + @row.to_s() +'[]', cv) %>
								<% cvs << cv unless cv.blank? %>

							<% end %>
						<% end %>
					<% end %>


					<% if show_custfield_img %>
					  	<% imgname ="" %>
						<% if !cvs.blank?  || !comment.blank? || !@prev_template && entry.present? && entry.attachments.any? %>
							<% imgname = "withcommant.png" %>
						<% else %>
							<% imgname = "withoutcommant.png" %>
						<% end %>
						<% if !@new_custom_field_values.blank? || ( Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].blank? ||
									Setting.plugin_redmine_wktime['wktime_enter_comment_in_row'].to_i == 0)  %>
								<% image_tg = image_tag("#{imgname}", :id => 'custfield_img' + @row.to_s() +'_', :name => 'custfield_img' + @row.to_s() +'[]',
									:plugin => "redmine_wktime",:title => "#{entry.nil? || @prev_template && !isTemplate || cvs.blank? ? '' : cvs.join(',')}") %>
							<% else %>
								<%= image_tg ="" %>
							<% end %>

						<% if disable %>
							<%= image_tg %>
						<% else %>
							<%= link_to image_tg, "javascript:showComment(#{@row.to_s}, #{@wday_index}, '#{l(:label_attribute_plural)}');" %>
						<% end %>
					<% end %>

				<% end %>
				</div>
			</td>
			<% @wday_index += 1 %>
		<% end %>
		<% if padAt == 'end' %>
			<td align="center">
			<% if @editable %>
				<%= link_to image_tag('delete.png'), "javascript:deleteRow(#{@row.to_s}, '#{l(:notice_unable_delete_time_entry)}');",
						:data => {:confirm => l(:text_are_you_sure)},	# :method => :delete,
						:title => l(:button_delete) %>
			<% end %>
			</td>
			</tr>
			<% @trOpen = false %>
		<% end %>
	<% end %>