<div class="row">
	<div class="col-md-12">
			<%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %>
				<% if period_type != false %>
					<div class="row">
						<div class="form-group col-md-2">
							<label>Select Period</label>
							<select name="period" id="sel_period" class="form-control">
								<option value="0">Today</option>
								<option value="1">Yesterday</option>
								<option value="2">This week</option>
								<option value="3">Last week</option>
								<option value="4">Last 7 days</option>
								<option value="5">This month</option>
								<option value="6">Last month</option>
								<option value="7">Last 30 days</option>
								<option value="8">This year</option>
								<option value="9">Last year</option>
							</select>
						</div>
						<input type="hidden" name="report_type" value="daily_sale" id="sel_sale_type">
						<!-- <div class="form-group col-md-2">
							<label>Select Type</label>
							<select name="sale_type" id="sel_sale_type" class="form-control">
								<option value="0">All Sale Type</option>
								<option value="1">Revenue Only</option>
								<option value="2">Discount Only</option>
								<option value="3">Void Only</option>
								<option value="4">Taxes Only</option>
								<option value="5">Other Amount Only</option>
							</select>
						</div> -->
						<div class="form-group col-md-3">					
							<!-- <label class="">Select Shift Period</label> -->
				  			<label class="">From</label>
							<input data-behaviour='datepicker' class="form-control" name="from" id="from" type="text" placeholder="From date">
						</div>
						<div class="form-group col-md-3">
							<label class="">To</label>
							<input data-behaviour='datepicker' class="form-control" name="to" id="to" type="text" placeholder="To date">
						</div>
						<div class="form-group col-md-2 margin-top-20">
							<input type="submit" value="Generate Report" class='btn btn-primary'>
						</div>							
					</div>													
				<% end %>
				
				<!-- <div class="row">
					<% if defined? show_monthly %>
						<div class="span3" style="margin-bottom:10px;">
							<input type="hidden" id="report_type" name="report_type" value="0">
							<div class="btn-group" data-toggle="buttons-radio">
							  <button id="btn_report_type_1" onclick="$('#report_type').val(1)" type="button" class="btn btn-inverse">Monthly</button>
							  <button id="btn_report_type_2" onclick="$('#report_type').val(2)" type="button" class="btn btn-inverse">Yearly</button>
							</div>
						</div>
					<% end %>
				</div> -->
	
				<div class="row">
					<div class="form-group">
					<% if defined? promotions %>
						<%= select_tag "promotion", options_for_select(@promotions, :selected => params[:promotion_type]), :class => "form-control" %>
					<% end %>
					
					<% if defined? menu_types %>
						<%= select_tag "menu_type", options_for_select(@menu_types, :selected => params[:menu_type]), :class => "form-control" %>	
					<% end %>
					
					<% if defined? payments %>
						<%= select_tag "payment_type", options_for_select(@payments, :selected => params[:payment_type]), :class => "form-control" %>	
					<% end %>
					
					<% if defined? shift_name %>
						<!-- Temporary no needs
						<select name="shift_name" id="shift_name"></select> 
						-->
					<% end %>

					<% if defined? cashiers %>
						<%= select_tag "cashier", options_from_collection_for_select(@cashiers,"id","name"),:prompt => "All Cashier Stations", :class => "form-control" %>
					<% end %>
						
					<% if defined? singer %>
						<%= select_tag "singer", options_from_collection_for_select(singer,"id","name"),:prompt => "All Vocal List", :class => "form-control" %>
					<% end %>
					
					<% if defined? bsm %>		
						<%= select_tag "singer", options_from_collection_for_select(bsm,"id","name"),:prompt => "All BSM List", :class => "form-control" %>
					<% end %>		
					
					<% if defined? guest_role %>
						<%= select_tag "guest_role", options_from_collection_for_select(@guest_role,"id","name"),:prompt => "Vocal/BSM List", :class => "form-control" %>
					<% end %>
					
					<% if defined? list_by_payment_type %> <!-- for report detail by credit and foc -->
						<%= select_tag "payment_type_list", options_for_select(@payment_list, :selected => params[:payment_type_list]), :class => "form-control" %>	
					<% end %>				
					
					<% if defined? products %>
						<%= select_tag "product", options_from_collection_for_select(@products,"id","name"),:prompt => "All Products", :class => "form-control" %>	
					<% end %>

					<% if defined? items %>	
						<%= select_tag "item", options_for_select(@items, :selected => params[:item_type]), :class => "form-control" %>			
					<% end %>
					</div>
				</div>

				<!-- <div class="row">
					<div class="col-md-12">
						<input type="submit" value="Generate Report" class='btn btn-primary'>
					</div>
				</div> -->
				
			<% end %>		
	</div>
</div>

<script type="text/javascript">
$(function(){
	$('#custom_excel').hide();
	
	$('#custom_excel').click(function(){
		var url = $('#custom_excel').attr('data-url');
		$('#frm_report').attr('action',url)
		$('#frm_report').submit();
		// window.location = url;
	});
	
	var item = $('#item').val();
	var payment_type = $('#payment_type');
	
	if(item == 'order'){
		$('#cashier').hide();
		$('#waiter').show();
		if(payment_type){
			$('#payment_type').hide();
		}		
	}
	else if(item == 'sale'){
		$('#waiter').hide();
		$('#cashier').show();
	}
	else{
		$('#waiter').hide();
		$('#cashier').show();		
		$("#item").val('sale');
	}
});

//Reset the form to pervious values
$("#branch").val(<%=params[:branch]%>);
$("#waiter").val("<%=params[:waiter]%>");
$("#cashier").val(<%=params[:cashier]%>);
$("#product").val(<%=params[:product]%>);
$("#singer").val(<%=params[:singer]%>);
$("#item").val('<%=params[:item]%>');
$("#guest_role").val('<%=params[:guest_role]%>');


$("#from").val("<%=params[:from]%>");
$("#to").val("<%=params[:to]%>");
$("#sel_period").val(<%=params[:period]%>);
$("#sel_sale_type").val(<%=params[:sale_type]%>);

<% if params[:period_type] == 1 || params[:period_type] == "1" %>
	$("#rd_period_type_1").attr("checked","checked");
<% else %>
	$("#rd_period_type_0").attr("checked","checked");
<% end %>
$(".btn-group button").removeClass("active");
<% report_type = params[:report_type].blank? ? "0" : params[:report_type] %>
$("#btn_report_type_<%= report_type %>").addClass("active");

$('#item').change(function(){
	var item = $('#item').val();
	var payment_type = $('#payment_type');

	if(item == 'sale'){
		$('#waiter').hide();
		$('#cashier').show();		
		if(payment_type){
			$('#payment_type').show();
		}
	}
	else{
		$('#cashier').hide();
		$('#waiter').show();
		if(payment_type){
			$('#payment_type').hide();
		}
	}
});
</script> 