<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
  layout:decorator="/templates/layout">
  <head>
  	<title>Shopping cart</title>
  </head>
<body>
<div layout:fragment="content">
	<div th:if="${errors.isEmpty()}">
		<div class="jumbotron">
			<h1>TPC Web Commerce Benchmark (TPC-W)</h1>
		</div>
		<div class="promotional">
			<div class="pull-left" th:each="item : ${promotional}">
				<a th:href="@{'/product-detail?I_ID=' + ${item.IId}}">
					<img th:src="@{ ${imgResourceUrl} + '/' + ${item.IThumbnail}" src="" width="100" height="100" />
				</a>
			</div>
			<div class="clearfix"></div>
		</div>
		
		<hr />
		<div th:if="${cart != null and cart.shoppingCartLines != null}">
			<form action="" method="get">
				<table class="table">
					<thead>
						<tr>
							<th>
								QTY
							</th>
							<th>
								Product
							</th>
						</tr>
					</thead>
					<tbody>
						<tr th:each="line, i : ${cart.shoppingCartLines}">
							<td>
								<input type="hidden" th:name="'I_ID_' + ${i.index}" th:value="${line.item.IId}" />
								<input th:name="'QTY_' + ${i.index}" size="3" th:value="${line.sclQty}" />
							</td>
							<td>
								Title: <i th:text="${line.item.ITitle}"></i> - Backing: 
								<span th:text="${line.item.IBacking}"></span><br />
								SRP. $<span th:text="${line.item.ISrp}"></span>
								<span style="color: red;"><strong>Your Price: <span th:text="${line.item.ICost}"></span></strong></span>
							</td>
						</tr>
					</tbody>
				</table>
				<strong>Subtotal: <span th:text="${subTotal}"></span></strong>
				<div style="text-align: center">
					<a class="btn" th:href="@{${checkoutUrl}}">Checkout</a>
					<a class="btn" th:href="@{${homeUrl}}">Home</a>
				</div>
				<p style="text-align:center">
					If you have changed the quantities and/or taken anything out<br />
					of your shopping cart, click here to refresh your shopping cart:
				</p>
				<input type="hidden" name="ADD_FLAG" value="N" />
				<input type="hidden" name="SHOPPING_ID" th:value="${cart.scId}" />
				<input th:if="${customerId}" type="hidden" name="C_ID" th:value="${customerId}"/>
				<input type="submit" value="Update" class="btn" />
			</form>
		</div>
		<div th:unless="${cart != null and cart.shoppingCartLines != null}">
			Empty cart!
		</div>
		
	</div>
	<div th:unless="${errors.isEmpty()}">
		<div class="alert alert-error">
			<div th:each="error : ${errors}" th:text="error"></div>
		</div>
	</div>
</div>
</body>
</html>