summaryrefslogtreecommitdiffstats
path: root/data/templates/products/entry.html
blob: 64b2aa46b844df705c6bbdb1801955cdec09db1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<h2>Product Information</h2>
<p>
	<table class="table table-bordered table-nonfluid">
		<tr><th>EAN</th><td>{{{EAN}}}</td></tr>
		<tr><th>Name</th><td>{{{NAME}}}</td></tr>
		<tr><th>Category</th><td>{{{CATEGORY}}}</td></tr>
		<tr><th>Amount</th><td>{{{AMOUNT}}}</td></tr>
		<tr><th>State</th><td><button id="statebutton" type="button" class="btn {{{BTNSTATE}}}" {{{ISADMIN2}}}>{{{STATE}}}</button></td></tr>
	</table>
</p></p>

<h2>Price History</h2>
<table class="table table-bordered table-nonfluid">
	<tr><th>Valid Since</th><th>Memberprice</th><th>Guestprice</th></tr>
	{{{PRICES}}}
</table>

<div id="new_price" style="display: {{{ISADMIN}}};">
	<form action="/products/{{{EAN}}}/newprice" class="form-inline">
		<input class="form-control" name="member" type="number" step="0.01" min="0.01" placeholder="Member" />
		<input class="form-control" name="guest"  type="number" step="0.10" min="0.10" placeholder="Guest" />
		<button type="submit" class="btn btn-primary">Add new Prices</button>
	</form>
</div>

<h2>Restock</h2>
<table class="table table-bordered table-nonfluid">
	<tr><th>Date</th><th>Amount</th><th>Unit Price</th><th>Supplier</th><th>Best before Date</th></tr>
	{{{RESTOCKS}}}
</table>

<div id="restock" style="display: {{{ISADMIN}}};">
		
	<form action="/products/{{{EAN}}}/restock" class="form-horizontal">
		<div class="control-group">
			<label class="control-label">Amount</label>
			<div class="controls">
				<input name="amount" type="number" min="1" placeholder="Amount" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">Price per Piece</label>
			<div class="controls">
				<input name="price"  type="number" step="0.01" min="0.00" placeholder="Price"  />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">Suppplier</label>
			<div class="controls">
				<select name="supplier">
					{{{SUPPLIERS}}}
				</select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">Best Before Date</label>
			<div class="controls">
				<input name="best_before_date"  type="date" />
			</div>
		</div>
		<div class="control-group">
			<div class="controls">
				<button type="submit" class="btn btn-primary"><i class="icon-plus"></i> Restock</button>
			</div>
		</div>
	</form>
</div>

<script>
$('#statebutton').on('click', function (e) {
	var req = $.getJSON(
		"/products/{{{EAN}}}/togglestate",
		function( data ) {
			if(data["state"] == "deprecated") {
				$('#statebutton').html("Deprecated")
				$('#statebutton').addClass("btn-danger")
				$('#statebutton').removeClass("btn-success")
			} else if(data["state"] == "active") {
				$('#statebutton').html("Active")
				$('#statebutton').addClass("btn-success")
				$('#statebutton').removeClass("btn-danger")
			} else {
				console.error("unknown state")
				console.info(data)
			}
		}
	);
});
</script>