<?php
$this->load->view('partials/report_start', $this->data);
$this->load->helper('report');
$report = isset($report) ? $report : array();
$from_date = isset($from_date) ? $from_date : date('d-m-Y', strtotime('-30 days'));
$to_date = isset($to_date) ? $to_date : date('d-m-Y');
$columns = isset($columns) && is_array($columns) && !empty($columns)
    ? $columns
    : report_catalogue_columns('book');
?>
<form method="post">
  <div class="row filter-row align-items-end mb-3">
    <div class="col-md-3">
      <div class="form-group mb-0">
        <label>From Date</label>
        <input type="text" class="form-control js-date" name="from_date"
               value="<?php echo htmlspecialchars($from_date); ?>" placeholder="dd-mm-yyyy" autocomplete="off" required>
      </div>
    </div>
    <div class="col-md-3">
      <div class="form-group mb-0">
        <label>To Date</label>
        <input type="text" class="form-control js-date" name="to_date"
               value="<?php echo htmlspecialchars($to_date); ?>" placeholder="dd-mm-yyyy" autocomplete="off" required>
      </div>
    </div>
    <div class="col-md-3">
      <p class="mb-0 text-muted small mt-4">Same columns as Accession Year Wise, filtered by accession date range.</p>
    </div>
    <div class="col-md-3">
      <?php $this->load->view('partials/report_actions'); ?>
    </div>
  </div>
  <?php if (!empty($date_error)) { ?>
    <div class="alert alert-warning py-2"><?php echo htmlspecialchars($date_error); ?></div>
  <?php } ?>
<?php if (!empty($searched)) { ?>
  <div class="report-results-toolbar">
  <p class="report-summary mb-0">
    <strong><?php echo count($report); ?></strong> item(s)
    · <?php echo htmlspecialchars($from_date); ?> – <?php echo htmlspecialchars($to_date); ?>
  </p>
  <?php $this->load->view('partials/report_exports'); ?>
</div>
  <?php
  $this->load->view('partials/report_datatable', array(
      'columns' => $columns,
      'rows' => $report,
      'table_id' => 'accessionDateTable',
  ));
  ?>
<?php } ?>
</form>
<?php $this->load->view('partials/report_end'); ?>
