{% extends '../template.html' %}
{% block title %}Report - Total Sales{% endblock %}
{% block subcontent %}
<h1>Report - Delivery Total Sales</h1>
<form>
	<select name="bystore">
		<option {% if bystore == 0 %}selected="selected"{% endif %} value=0>All</option>
		{% for k in kstore %}
		<option {% if bystore == k.id %}selected="selected"{% endif %} value={{k.id}}>{{k.kode}}</option>
		{% endfor %}
	</select>
	<select name="type">
		<option {% if type == "hourly" %}selected="selected"{% endif %} value="hourly">Hourly</option>
		<option {% if type == "daily" %}selected="selected"{% endif %} value="daily">Daily</option>
		<option {% if type == "monthly" %}selected="selected"{% endif %} value="monthly">Monthly</option>
	</select>
	<span {% if type != "hourly" %}style="display:none;"{% endif %} class="hourly">
		- {% date hourly year[2011-2030] %}
	</span>
	<span {% if type != "daily" %}style="display:none;"{% endif %} class="daily">
		- {% date daily year[2011-2030] nodate %}
	</span>
	<span {% if type != "monthly" %}style="display:none;"{% endif %} class="monthly">
		- {% date monthly year[2011-2030] nodate nomonth%}
	</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 rowspan="2">NO</th>
		<th rowspan="2">STORE</th>
		<th colspan={% if type == "hourly" %}"24"{% endif %}{% if type == "daily" %}"31"{% endif %}{% if type == "monthly" %}"12"{% endif %}>DATE</th>
		<th rowspan="2">TOTAL</th>
	</tr>
	<tr>
		{% for l in len %}<th>{{l.val}}</th>{% endfor %}
	</tr>
	{% for d in report %}
	<tr valign="top">
		
	</tr>
	{% endfor %}
</table>

{% 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();$(".hourly").hide();$(".monthly").hide();
			}
			else if ($(this).val() == "monthly") {
				$(".daily").hide();$(".hourly").hide();$(".monthly").show();
			}
			else if ($(this).val() == "hourly") {
				$(".daily").hide();$(".monthly").hide();$(".hourly").show();
			}
		});
		var y = (d.getFullYear()-2010);
		$("select[name=hourly_date] option:nth-child("+d.getDate()+")").attr('selected', "selected");
		$("select[name=hourly_month] option:eq("+d.getMonth()+")").attr('selected', "selected");
		$("select[name=hourly_year] option:nth-child("+y+")").attr('selected', "selected");
	});
</script>
{% endblock %}