<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<title>Gift card</title>
		<link href='http://fonts.googleapis.com/css?family=Abel' rel='stylesheet' type='text/css'>
		<link href='http://fonts.googleapis.com/css?family=Atomic+Age' rel='stylesheet' type='text/css'>
		<link rel="stylesheet" type="text/css" href="/assets/css/giftcard/reset.css">
		<link rel="stylesheet" type="text/css" href="/assets/css/giftcard/brown.css">
		<style type="text/css">
		.legal{
			font-family: 'Abel', sans-serif;
			color: #887973;
			font-size:9px;
			margin-top: 325px;
			position: absolute;
			width: 816px;
			text-align: center;
		}
		.mobile{
			color: #FFF;
			position: absolute;
			text-align: left;
			font-size: 12px;
			width: 519px;
			margin-left: 269px;
			margin-top: 210px;
		}
		.info{
			font-size:34px;
		}
		</style>
	</head>
	<body>
<?php 
// Workaround to avoid image be cached
$imageCached = date( 'dHis' );
$count = 0;
$newPage = true;
$giftcards = $this->giftcards;
if( sizeof( $giftcards ) > 0 ) {
	foreach( $giftcards as $giftcard ){
		$message = $giftcard->message;
		if( !$message || $message == '' ){
			$message = 'crunchbutton.com';
		}
		if( !$giftcard ){ continue; }
		$count++;
		if( $giftcard->id_restaurant ){
			$restaurant = $giftcard->restaurant();
			$restaurant_name = $restaurant->name;			
		} else {
			$restaurant_name = 'Crunchbutton';
		}
		if( $newPage ){
			$newPage = false;
			?>
			<div class="page">
			<?php
		}
	?><div class="giftcard"><div class="value <?php if( $giftcard->value > 9 ){ echo 'small'; } ?>"><?php echo $giftcard->value;?></div><div class="info">crunchbutton.com/gift/<?php echo $giftcard->code;?></div><div class="legal">Valid for $<?php echo $giftcard->value; ?> off one order on crunchbutton.com for new users only. One per user. Has no cash value and is not a jelly donut. Not valid for past orders. Will not be replaced if lost or stolen. May be canceled any time without notice.</div>
	<div class="mobile">Or use our iPhone app and, in the Notes section of your order, enter: <?php echo $giftcard->code;?></div>
	<img  style="width:816px;"  src="/assets/images/giftcard/print-brown.svg?<?php echo $imageCached; ?>"/></div>
	<?php 
		if( $count % 3 == 0 ){
			$newPage = true;
			echo '</div><div class="page"></div>';
		}
	} 
} else {
	echo 'Oops, is seems you are trying to print a gift card that was already redemmed!';
}
?>
	</body>
</html>