<script type="text/javascript">
	$(document).ready(function() {
		var on  = '&#9733;';
		var off = '&#9734;';

		$(".rating .star").hover(function() {
			var e = $(this);
			var box = e.closest(".rating");
			var val = e.attr('value');

			box.find('.star').each(function(i, e) {
				if ($(e).attr('value') <= val) {
					$(e).html(on);
				}
				else {
					$(e).html(off);
				}
			});
		}, function () {
			var e = $(this);
			var box = e.closest(".rating");
			var input = $("#" + box.attr('for'));
			var val = input.val();

			box.find('.star').each(function(i, e) {
				if ($(e).attr('value') <= val) {
					$(e).html(on);
				}
				else {
					$(e).html(off);
				}
			});
		});

		$(".rating .star").click(function() {
			var e = $(this);
			var box = e.closest(".rating");
			var val = e.attr('value');

			var input = $("#" + box.attr('for'));
			input.val(val);
		});
	});
</script>

<{if $order}>

	<{if $get.voted}>

		<div class="notification success closeable">
			<p><span>Tak!</span> Din anmeldelse er modtaget.</p>
			<a class="close" href="#"></a>
		</div>

		<{assign var="products" value=$order->getProducts()}>
		<{include file="product-box.html" title="Andre købte også" products=$webshop->getAlsoBought($products)}>

	<{else}>

		<h1>Din ordre</h1>

		<{assign var="products" value=$order->getOrderProducts()}>

		<form action="" method="post">

			<{section name="i" loop=$products}>
				<div class="row">

					<div class="col-lg-4 col-md-6">
						<{assign var="images" value=$products[i]->getImages()}>
						<{section name="j" loop=$images max=1}>
							<img src="<{$images[j]->getSrc(50, 50, 'box')}>" alt="" style="border-radius:100px;">
						<{/section}>

						<strong><{$products[i]->getAmount()}> stk. <{$products[i]->getName()|escape}></strong>
						<small><{$webshop->getCurrency()}> <{$products[i]->getUnitPrice()|number_format:2:",":"."}></small>

						<{assign var="attributes" value=$products[i]->getAttributes()}>
						<{if $attributes}>
							<ul>
								<{section name="j" loop=$attributes}>
									<li><{$attributes[j].name}>: <{$attributes[j].val}></li>
								<{/section}>
							</ul>
						<{/if}>
					</div>

					<div class="col-lg-2 col-md-6">
						<div class="form-group">
							Din vurdering:

							<div class="rating" for="rating_<{$products[i]->getProductId()}>">
								<span class="star" value="1">&#9733;</span>
								<span class="star" value="2">&#9734;</span>
								<span class="star" value="3">&#9734;</span>
								<span class="star" value="4">&#9734;</span>
								<span class="star" value="5">&#9734;</span>
							</div>

							<input type="hidden" id="rating_<{$products[i]->getProductId()}>" name="rating[<{$products[i]->getProductId()}>]" value="">
						</div>
					</div>

					<div class="col-lg-6 col-md-6">
						<div class="form-group">
							<textarea placeholder="Skriv din anmeldelse af produkter her" class="form-control" name="description[<{$products[i]->getProductId()}>]"></textarea>
						</div>
					</div>

				</div>
			<{/section}>

			<div class="form-group my-4">
				<input class="btn btn-primary button color" type="submit" value="Skriv anmeldelse"/>
			</div>

		</form>

	<{/if}>

<{/if}>