<?php
// echo '<pre>'; print_r($orders); exit;
?>
<!DOCTYPE html>
<html dir="<?php echo $direction; ?>" lang="<?php echo $lang; ?>">
<head>
<meta charset="UTF-8" />
	<title>Etiqueta - Correios</title>
	<base href="<?php echo $base; ?>" />
	<link rel="stylesheet" type="text/css" href="../admin/view/stylesheet/etiqueta_correios.css" />
	<script type="text/javascript" src="../admin/view/javascript/codigo_de_barra/codigo_de_barra.js"></script>
	<script type="text/javascript" src="../admin/view/javascript/codigo_de_barra/funcao.js"></script>
</head>
<body onload="updateBarcode()">

	<?php foreach ($orders as $order) { ?>
	<?php

	$chancela = '';

	switch ($order['shipping_code']) {
	case "correios.41106":
	case "correios.04510":
	case "correios.41262":
	case "correios.41068":
	case "correios.04669":
	case "correios.41300":
	case "correios.04693":
		$chancela = 'chancela_pac.jpg';
		break;

	case "correios.40010":
	case "correios.04014":
	case "correios.40045":
	case "correios.40096":
	case "correios.04162":
	case "correios.40436":
	case "correios.40444":
	case "correios.40568":
	case "correios.40606":
	case "correios.40126":
		$chancela = 'chancela_sedex.jpg';
		break;

	case "correios.40215":
		$chancela = 'chancela_sedex10.jpg';
		break;

	case "correios.40169":
		$chancela = 'chancela_sedex12.jpg';
		break;

	case "correios.40290":
		$chancela = 'chancela_sedexhoje.jpg';
		break;

	case "correios.81019":
	case "correios.81027":
	case "correios.81035":
	case "correios.81868":
	case "correios.81833":
	case "correios.81850":
		$chancela = 'chancela_esedex.jpg';
		break;

	case "pickup_hdw.pickup_hdw":
		$chancela = 'chancela_pickup.jpg';
		break;
	}

	if (stripos($order['shipping_method'], 'motoboy') !== false) {
		$chancela = 'chancela_motoboy.jpg';
	}

	?>
	<div id="print">
		<table width="391" class="tabela1" cellpadding="14" cellspacing="0">
		<tr><td width="51%" valign="top">
				<table border="0" cellpadding="0" cellspacing="0" width="100%">
				<tbody>
					<tr>
						<td valign="bottom"><img src="../image/etiqueta/destinatario_peq.gif" border="0"></td>
						<?php if ($chancela != '' && file_exists(DIR_IMAGE . "catalog/correios/{$chancela}")) { ?>
						<td align="right"><img src="../image/catalog/correios/<?php echo $chancela; ?>"></td>
						<?php } ?>
					</tr>
				</tbody>
				</table>

				<table border="0" cellpadding="0" cellspacing="0" width="100%" height="150">
				<tbody><tr><td valign="top"><span class="style1"><?php echo $order['shipping_address']; ?></span></td></tr></tbody>
				</table>
				<?php /* ?><div style="min-height:269px;">
					<img src="../image/etiqueta/destinatario_peq.gif" border="0">
					<?php if ($chancela != '' && file_exists(DIR_IMAGE . "catalog/correios/{$chancela}")) { ?>
						<img src="../image/catalog/correios/<?php echo $chancela; ?>" align="right">
					<?php } ?>
					<span class="style1"><?php echo $order['shipping_address']; ?></span>
				</div><?php */ ?>

				<div align="center" class="style4">
					<input style="display: none;" id="barcodeValue" type="text" name="value" value="<?php echo $order['customer_cep']; ?>" />
					<img id="barcodeImage">
				</div>

				<hr align="center" width="100%" color="silver" size="1">

				<div class="style2">
					<b>Remetente:</b><br>
					<span class="transforme">
						<?php echo $order['store_name']; ?><br>
						<?php /* ?><?php echo $order['loja_owner']; ?><br><?php */ ?>
						<?php echo $order['loja_endereco']; ?>
						<?php /* ?><?php echo $order['loja_telefone']; ?><br><?php */ ?>
						<?php /* ?><?php echo $order['loja_fax']; ?><br><?php */ ?>
						<?php /* ?><?php echo $order['loja_email']; ?><br><?php */ ?>
					</span>
				</div>
		</td></tr>
		</table>
	</div>
	<?php } ?>

	<div class="right">
		<p align="center">
			<a href="javascript:Imprimir('print');"/><button class="bot">Imprimir</button></a>
		</p>
	</div>

</body>
</html>