<?php
class ControllerShippingCorreios extends Controller {
	public function rastreamento() {
		$route = explode('/', $this->request->get['route']);
		$codigo = isset($route[3]) ? trim($route[3]) : '';

?><!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>Rastreamento Correios</title>
</head>
<body>

<form name="correios" action="https://www2.correios.com.br/sistemas/rastreamento/ctrl/ctrlRastreamento.cfm" method="post">
	<input type="hidden" name="acao" value="track">
	<input type="hidden" name="btnPesq" value="Buscar">
	<?php if ($codigo == '') { ?>
		Digite o código de rastreamento no campo abaixo:<br>
		<input type="text" name="objetos" value="XX000000000BR"><br>
		<br>
		<button type="submit">ENVIAR</button>
	<?php  } else { ?>
		Aguarde, carregando...
		<input type="hidden" name="objetos" value="<?php echo $codigo; ?>">
	<?php } ?>
</form>

<?php if ($codigo != '') { ?>
<script>
document.correios.submit();
</script>
<?php } ?>

</body>
</html><?php

	}
}