protected void doPost(HttpServletRequest req, HttpServletResponse res) 
			throws ServletException, IOException {
		
		String url = "/";

		PurchaseViewHelper purchaseViewHelper =
				ViewHelperFactory.getInstance().getPurchaseViewHelper(req);
		
		Customer customer = (Customer) req.getSession().getAttribute("loggedInCustomer");

		if (purchaseViewHelper.checkEnoughFunds()) {

			if (purchaseViewHelper.checkEnoughStock()) {
				purchaseViewHelper.decreaseStock();
				purchaseViewHelper.decreaseCustomerBalance();
				purchaseViewHelper.emptyBasket();
				
				DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
				Calendar cal = Calendar.getInstance();
				cal.setTime(new Date());
				cal.add(Calendar.DATE, 3);
				String deliveryDate = df.format(cal.getTime());
				
				req.setAttribute("msg", "" + customer.getForename() 
						+ ", your order has been successful. "
						+ "Your item(s) will be delivered by " + deliveryDate);
				req.setAttribute("link", "back to "
						+ "<a href=\"/GAMER/shop?action=home\">shopping</a>");
				url += "UserMsg.jsp";
			}
			else {
				purchaseViewHelper.updateBasketStock();
				req.setAttribute("purchaseStockIssue", "notEnoughStock");
				url += "Basket.jsp";
			}
		}
		else {
			req.setAttribute("msg", "You have insufficient funds to complete this transaction. Please contact your bank.");
			req.setAttribute("link", "return to "
					+ "<a href=\"shop?action=basket\">basket</a>");
			url += "UserMsg.jsp";
		}
		getServletContext().getRequestDispatcher(url).forward(req, res);
	}