<?php if (preg_match('/[0-9]/', $code)) { ?>
<div class="buttons">
	<div class="alert alert-success hide" role="alert" id="success"></div>
	<div class="alert alert-danger hide" role="alert" id="warning"></div>

	<div class="pull-right">
		<a id="button-confirm" class="btn btn-primary" style="cursor:pointer" onClick="pagarBoleto()">Confirmar pedido e gerar boleto</a>
		<div id="MoipWidget" data-token="<?php echo $code; ?>" callback-method-success="funcaoSucesso" callback-method-error="funcaoFalha"></div>
	</div>
</div>

<link href="catalog/view/javascript/moip/colorbox/colorbox.css" rel="stylesheet" media="all">
<script type="text/javascript" src="catalog/view/javascript/moip/colorbox/jquery.colorbox-min.js"></script>

<script type="text/javascript"><!--
var funcaoSucesso = function(data){
	$.colorbox({
		iframe:true,
		open:true,
		href:data.url,
		innerWidth:'90%',
		innerHeight:'90%',
		onClosed: function () {
			$.ajax({
				type: 'GET',
				url: 'index.php?route=payment/moip_boleto/confirm',
				cache: false,
				success: function() {
					location.href = '<?php echo $continue; ?>';
				}
			});
		}
	});
};

var funcaoFalha = function(data) {
	$('#warning').removeClass('hide').html(data.Mensagem);
};

var pagarBoleto = function() {
	MoipWidget({"Forma": "BoletoBancario"});
}
//-->
</script>

<?php } else { ?>
	<div class="alert alert-danger" role="alert" id="warning"><?php echo $code; ?></div>
<?php } ?>
