<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Print Bill</title>
	<script type="text/javascript" src="<?php echo $this->baseUrl ?>assets/thema/posr/js/qz-tray.js"></script>
	<script type="text/javascript" src="<?php echo $this->baseUrl ?>assets/thema/posr/js/print.js"></script>
	<script type="text/javascript" src="<?php echo $this->baseUrl ?>assets/thema/posr/js/jsrsasign-all-min.js"></script>
	<script type="text/javascript" src="<?php echo $this->baseUrl ?>assets/js/jquery-1.7.2.min.js" ></script>
	<script type="text/javascript" src="<?php echo $this->baseUrl ?>assets/js/jquery-ui-1.8.19.custom.min.js" ></script>
	<script type="text/javascript" src="<?php echo $this->baseUrl ?>assets/js/jquery.shortcuts.min.js" ></script>
</head>
<body>
	<link rel="stylesheet" type="text/css" href="<?php echo $this->baseUrl ?>/assets/thema/posr/css/print.css">
	<?php include BASEPATH.'assets/thema/posr/print/'.$this->view; ?>
</body>
<script>
(function() {
  const printKey = 'print_executed_' + Date.now();
  if (sessionStorage.getItem('print_in_progress')) {
    console.log('Print already in progress, aborting');
    return;
  }
  sessionStorage.setItem('print_in_progress', 'true');
  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', executePrint);
  } else {
    executePrint();
  }
  function executePrint() {
    printReceipt("<?php echo $this->data->printer ?>", true, "<?php echo $this->baseUrl ?>")
      .finally(() => {
        sessionStorage.removeItem('print_in_progress');
      });
  }
})();
</script>
</html>