<%= javascript_include_tag 'leaverequest', :plugin => "redmine_wktime" %>
<h2><%= @leaveReqEntry.blank? ? l(:label_new_leave_request) : l(:label_edit_leave_request) %></h2>
<%= form_tag({:action => 'save'}, :method => :post) do %>
	<%= hidden_field_tag('lveReqID', @leaveReqEntry.try(:id)) %>
	<%= hidden_field_tag('user_id', @leaveReqEntry.blank? ? User.current.id : @leaveReqEntry.user_id) %>
	<% isUser = @leaveReqEntry.try(:user_id) == User.current.id %>
	<% 
		if @leaveReqStatus == 'S' && isLeaveReqAdmin && !isUser
			show = true
			disable = false
		else
			show = @leaveReqEntry.present? ? @leaveReqEntry.reviewer_comment ? true : false : false
			disable = true
		end
	%>
	<fieldset class="box tabular">
		<table>
			<tr>
				<th align="left"><%= l(:label_user_name) %></th>
				<td align="left"><%=  @leaveReqEntry.blank? ? User.current.name : @leaveReqEntry.try(:user_name) %></td>
			<tr>
			<tr>
				<th align="left"><%= l(:field_status) %></th>
				<td align="left"><%= getLeaveStatus[@leaveReqStatus] %></td>
			<tr>
			<tr>
				<th align="left"><%= l(:label_leave_type) %></th>
				<td align="left">
					<%=h select_tag("leave_type_id", options_for_select(get_leave_type, selected: @leaveReqEntry.try(:leave_type_id)), 
						disabled: @readonly) %>					
					<span id="AvailableHours" style="padding-left: 5px;"></span>
				</td>
			<tr>
			<tr>
				<%= ("<th>" + l(:label_date_start_end, :start => ("</th><th align='left'>" + 
					date_field_tag('start_date', @leaveReqEntry.try(:startDate), :id => 'start_date', :size => 8, 
						onchange: "dateRangeValidation('start_date', 'end_date')", disabled: @readonly) + calendar_for('start_date')), 
					:end => (date_field_tag('end_date', @leaveReqEntry.try(:endDate), :id => 'end_date', :size => 8, 
						onchange: "dateRangeValidation('start_date', 'end_date')", disabled: @readonly) + calendar_for('end_date')))).html_safe 
				%>
			</tr>
			<tr>
				<th align="left"><%= l(:label_comment) %></th>
				<td align="left">
					<%= text_area_tag("leave_reasons", @leaveReqEntry.try(:leave_reasons), rows: 5, cols: 60, disabled: @readonly) %>
				</td>
			</tr>
			<% if show %>
				<tr>
					<th align="left"><%= l(:label_reviewer_cmt) %></th>
					<td align="left">
						<%= text_area_tag("reviewer_comment", @leaveReqEntry.try(:reviewer_comment), rows: 5, cols: 60, disabled: disable ) %>
					</td>
				</tr>
			<% end %>
		</table>
	</fieldset>
	<div>
		<% getButtonLabels.each do |key, label| %>
			<%= submit_tag(l(label), name: "submit_" + key) %>
		<% end %>
	</div>	
<% end %>