<div class="div-left">
 <table>
	<%
		me = false
		my_direct_report = false
		my_report = false 
		check = false
		if validateERPPermission('A_TE_PRVLG') && !isSupervisor
			opt_proj = true
		else
			opt_proj = false
		end
		opt_grp =false
		projectid = session[controller_name].try(:[], :project_id)
		groupid =session[controller_name].try(:[], :group_id)
		userid = session[controller_name].try(:[], :user_id)
		filter_type = session[controller_name].try(:[], :filter_type)
		if filter_type == '1' 
				opt_proj = true	
		elsif filter_type == '2'
			opt_grp = true
		elsif filter_type.blank? ||  filter_type == '3'
			check = true
			me = true	
		elsif filter_type == '4'
			check = true	
			my_direct_report = true	
		elsif filter_type == '5'
			check = true	
			my_report = true	
		end
		
	%>

	<% if isSupervisor() || validateERPPermission('A_TE_PRVLG') %>
		<% if isSupervisor() %>
		<tr>
			<th><%= radio_button_tag 'filter_type', '6', check, 
			:onclick => '$("#group_id").attr("disabled", true);$("#project_id").attr("disabled", true);$("#user_id").attr("disabled", true);
		$(".reportersDD").attr("disabled", false);' %>
			<%=l(:label_reporters)%></th>
			<td>
				<%= select_tag('filter_type', options_for_select(supervisorReporters, :selected => filter_type), :onchange => "reportersChanged(this)", class: "reportersDD" ) %>
			</td>
		</tr>
		<% end %>
 </table>
<table>
	<% if !@manage_view_spenttime_projects.blank? %>
		<tr>
			<th><%= radio_button_tag 'filter_type', '1', opt_proj,
			 :onclick => 'progrpChanged(this, "#{User.current.id}", true);$("#user_id").removeAttr("disabled");$("#group_id").attr("disabled", true);$("#project_id").removeAttr("disabled");$(".reportersDD").attr("disabled", true);' %>
			<%=l(:field_project)%></th>
			<td class="project" align="left"><%=h select_tag('project_id', 
				options_for_select(options_for_wktime_project(@manage_view_spenttime_projects),
				:selected => !projectid.nil? ? projectid.to_i: @selected_project.id),:disabled => @use_group,
				:onchange => "projChanged(this, #{User.current.id}, true);") %></td>
		</tr>
	<% end %>
	<% if !@groups.blank? %>
		<tr>
			<th><%= radio_button_tag 'filter_type', '2', opt_grp, 
			:onclick => 'progrpChanged(this, "#{User.current.id}", true);$("#user_id").removeAttr("disabled");$("#group_id").removeAttr("disabled");$("#project_id").attr("disabled", true);$(".reportersDD").attr("disabled", true);' %>
			<%=l(:label_group_plural)%></th>
			<td>
				<%=h select_tag('group_id',
				options_for_select( @groups.collect {|p| [p.name, p.id ]},
				:selected => (groupid.nil? ? 0 : groupid)),:disabled => !@use_group,
				:onchange => "grpChanged(this, #{User.current.id}, true);") %>
			</td>
		</tr>
	<% end %>
	<tr>
		<th><%=l(:label_member)%></th>
		<td>
		<%# show the blank value if more than one user is in the list %>
		<%=h select_tag('user_id',
			options_for_select( [[l(:all_users_for_select),"0"]] + (@members.blank? ? [] : @members),
				:selected => userid.nil? ? (@user.nil? ? User.current.id : @user.id) : userid),
			:onchange => 'this.form.submit();') %></td>
	</tr>

</table>
<script type="text/javascript"> 
$(document).ready(function()
{
	<% if me %> 
		$("#user_id").attr("disabled", true);
	<% end %>
	<% if me || my_direct_report || my_report %>
		$("#group_id").attr("disabled", true);
		$("#project_id").attr("disabled", true);
	<% end %>
	<% if opt_proj %>
		$("#group_id").attr("disabled", true);
		$("#project_id").removeAttr("disabled");
		$("#user_id").attr("disabled", false);
		$(".reportersDD").attr("disabled", true);
	<% end %>
	<% if opt_grp %>
		$("#project_id").attr("disabled", true);
		$(".reportersDD").attr("disabled", true);
		$("#group_id").removeAttr("disabled");
	<% end %>
});
userCurrentUrl ="<%= "#{url_for(:controller => 'wktime', :action => 'getMyReportUsers')}" %>";
 </script>
 <% else %>
	</table>
 <% end %>
</div>