<%@ page import="com.ubnt.data.Voucher" %>
<%@ page import="java.util.List" %>
<%@ page import="com.ubnt.ace.view.JspHelper" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%

List vouchers = (List) request.getAttribute("vouchers");

%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta http-equiv="x-ua-compatible" content="IE=8" />
	<title>Vouchers</title>
<style type="text/css">
<%=JspHelper.renderTemplate(request, "bundle/voucher.css", null)%>
</style>
</head>
<body onload="self.focus(); window.print()">
	<% for (int i=0; i<vouchers.size(); i++) {
		Voucher voucher = (Voucher) vouchers.get(i);
		String code = voucher.getString("code");
		code = code.substring(0, 5)+"-"+code.substring(5);
		voucher.put("code", code);
		
		int duration = voucher.getInt("duration");
		int days = duration / 1440;
		int hours = (duration % 1440) / 60;
		int minutes = duration % 60;
		String valid = (days > 0 ? days + " days" : "") + (hours > 0 ? hours + " hours" : "") + (minutes  > 0 ? minutes  + " minutes" : "");
		voucher.put("valid", valid);

		out.print(JspHelper.renderTemplate(request, "bundle/voucher.html", voucher));
	} %>
</body>
</html>
