{% extends '../template.html' %}
{% block title %}Report - Order History{% endblock %}
{% block subcontent %}
<h1>Report - Order History</h1>
<form>
	<b>Search: <input type="text" id="find" name="find" value="{{find}}"/></b>
	<select name="type">
		<option {% if type == "daily" %}selected="selected"{% endif %} value="daily">Daily</option>
		<option {% if type == "weekly" %}selected="selected"{% endif %} value="weekly">Weekly</option>
		<option {% if type == "monthly" %}selected="selected"{% endif %} value="monthly">Monthly</option>
	</select>
	<span {% if type != "daily" %}style="display:none;"{% endif %} class="daily">
		- 
		{% date daily year[2011-2030] %}
	</span>
	<span {% if type != "weekly" %}style="display:none;"{% endif %} class="weekly">
		- <select name="weekly_date">
			<option {% if data.weekly_date == "1" %}selected="selected"{% endif %} value="1">1st week</option>
			<option {% if data.weekly_date == "8" %}selected="selected"{% endif %} value="8">2nd week</option>
			<option {% if data.weekly_date == "15" %}selected="selected"{% endif %}  value="15">3rd week</option>
			<option {% if data.weekly_date == "22" %}selected="selected"{% endif %} value="22">4th week</option>
			<option {% if data.weekly_date == "29" %}selected="selected"{% endif %} value="29">5th week</option>
		</select>
		{% date weekly year[2011-2030] nodate %}
	</span>
	<span {% if type != "monthly" %}style="display:none;"{% endif %} class="monthly">
		- {% date monthly year[2011-2030] nodate %}
	</span>
	<label><input class="pilihan" value="a" type="checkbox" name="pilihan" />Export</label>
	<input type="submit" value="Go"/>
</form><br/>
<div class="loading"><br/><br/><br/><br/><br/><br/><br/><center>- Loading -</center><br/><br/><br/><br/><br/><br/><br/></div>
<table class="data" style="background:white;display:none;">
	<tr>
		<th>Order</th>
		<th>Tgl</th>
		<th>Tlp</th>
		<th>Nama</th>
		<th>Alamat</th>
		<th>Menu</th>
		<th>Total Harga</th>
		<th>Store</th>
		<th>Agent</th>
		<th>Status</th>
		<th>Delivery Time</th>
		<th>Finish Time</th>
	</tr>
	{% for d in report %}
	<tr valign="top">
		<td>#{{d.id}}</td>
		<td>{{d.date_detail.mday}}-{{d.date_detail.mon}}-{{d.date_detail.year}}</td>
		<td>{{d.customer_telepon}}</td>
		<td>{{d.nama}}</td>
		<td>{{d.alamat}}</td>
		<td>{% for m in d.menu %}<span class="menu_item_report">{{m.nama}} ({{m.jml}})</span><br/> {% endfor %}</td>
		<td>{{d.total | currency }}</td>
		<td>{{d.store_nama}}</td>
		<td>{{d.agent}}</td>
		<td>{{d.status}}</td>
		<td>{{d.delivered}}</td>
		<td>{{d.delivery_time}}</td>
	</tr>
	{% endfor %}
</table>

{% for p in page %}
<a href="{{ p.link }}" class="{% if p.active == 'yes' %}active{% endif %} page">{{ p.number }}</a>
{% endfor %}

{% endblock %}
{% block script %}
<script type="text/javascript">
	$(document).ready(function() {
		$("#container").css('width','95%');
		$(".loading").hide();
		$("table.data").show().css('width',$("#container").width() - 200);
		$("select[name=type]").change(function() {
			if ($(this).val() == "daily") {
				$(".daily").show();$(".weekly").hide();$(".monthly").hide();
			}
			else if ($(this).val() == "weekly") {
				$(".daily").hide();$(".weekly").show();$(".monthly").hide();
			}
			else if ($(this).val() == "monthly") {
				$(".daily").hide();$(".weekly").hide();$(".monthly").show();
			}
		});
	});
</script>
{% endblock %}