<?php
  // Set page title.
  $this->headTitle($this->translate('Book Bag'));

  // Set up breadcrumbs:
  $this->layout()->breadcrumbs = '<li>' . $this->searchMemory()->getLastSearchLink($this->transEsc('Search'), '', '</li> ')
?>
<h2><?=$this->transEsc('Book Bag') ?></h2>
<div id="closeWindow">
<?=$this->flashmessages()?>
</div>

<form class="form-inline" action="<?=$this->url('cart-processor')?>" method="post"  name="cartForm" data-lightbox-onsubmit="cartFormHandler">
  <input type="hidden" id="dropdown_value"/>
  <?php if (!$this->cart()->isEmpty()): ?>
    <div class="cart-controls clearfix">
      <div class="checkbox pull-left flip">
        <label>
          <input type="checkbox" name="selectAll" class="checkbox-select-all"/>
          <?=$this->transEsc('select_page')?>
        </label>
      </div>
      <button type="submit" class="btn btn-default" name="email" title="<?=$this->transEsc('bookbag_email')?>" value="1">
        <i class="fa fa-envelope-o" aria-hidden="true"></i>
        <?=$this->transEsc('Email')?>
      </button>
      <?php $exportOptions = $this->export()->getActiveFormats('bulk'); if (count($exportOptions) > 0): ?>
        <button type="submit" class="btn btn-default" name="export" title="<?=$this->transEsc('bookbag_export')?>" value="1">
          <i class="fa fa-list-alt" aria-hidden="true"></i>
          <?=$this->transEsc('Export')?>
        </button>
      <?php endif; ?>
      <button type="submit" class="btn btn-default dropdown-toggle" name="print" title="<?=$this->transEsc('print_selected')?>" value="1">
        <i class="fa fa-printer" aria-hidden="true"></i>
        <?=$this->transEsc('Print')?>
      </button>
      <?php if ($this->userlist()->getMode() !== 'disabled'): ?>
        <button type="submit" class="btn btn-default" name="saveCart" title="<?=$this->transEsc('bookbag_save')?>" value="1">
          <i class="fa fa-save" aria-hidden="true"></i>
          <?=$this->transEsc('Save')?>
        </button>
      <?php endif; ?>
      <div class="btn-group" id="cartDelete">
        <button type="submit" name="delete" class="btn btn-default dropdown-toggle" data-toggle="dropdown" id="cart-delete-label" value="1">
          <i class="fa fa-trash" aria-hidden="true"></i>
          <?=$this->transEsc('Delete')?>
        </button>
        <ul class="dropdown-menu" role="menu" aria-labelledby="cart-delete-label">
          <li><a id="cart-confirm-delete" onClick="submitFormWithButton(this, 'delete')" title="<?=$this->transEsc('confirm_delete')?>"><?=$this->transEsc('confirm_dialog_yes')?></a></li>
          <li><a><?=$this->transEsc('confirm_dialog_no')?></a></li>
        </ul>
      </div>
      <div class="btn-group">
        <button type="submit" class="btn btn-default dropdown-toggle" name="empty" data-toggle="dropdown" id="cart-empty-label" value="1">
          <i class="fa fa-close" aria-hidden="true"></i>
          <?=$this->transEsc('Empty Book Bag')?>
        </button>
        <ul class="dropdown-menu" role="menu" aria-labelledby="cart-empty-label">
          <li><a id="cart-confirm-empty" onClick="submitFormWithButton(this, 'empty')" title="<?=$this->transEsc('bookbag_confirm_empty')?>"><?=$this->transEsc('confirm_dialog_yes')?></a></li>
          <li><a onClick="$('.fa.fa-spinner').remove()"><?=$this->transEsc('confirm_dialog_no')?></a></li>
        </ul>
      </div>
    </div>
  <?php endif; ?>
  <?=$this->render('cart/contents.phtml')?>
</form>

<?
  $script = <<<JS
  function submitFormWithButton(link, name) {
    $('#dropdown_value').attr('name', name).val(1);
    $(link).closest('form').submit();
  }
JS;
?>
<?=$this->inlineScript(\Laminas\View\Helper\HeadScript::SCRIPT, $script, 'SET') ?>
