<?php require __DIR__ . '/../../layouts/header.php'; ?>

<div class="container-fluid py-3">
  <div class="d-flex align-items-center justify-content-between flex-wrap gap-2 mb-3">
    <h4 class="mb-0"><?= e(t('proceedings') ?? 'Proceedings') ?></h4>

    <div class="d-flex gap-2">
      <form method="get" action="<?= e(base_path('admin/proceedings')) ?>" class="d-flex gap-2">
        <select name="conference_id" class="form-select" onchange="this.form.submit()">
          <?php foreach(($confs??[]) as $c): ?>
            <option value="<?= (int)$c['id'] ?>" <?= ((int)$confId===(int)$c['id'])?'selected':'' ?>>
              <?= e(($c['title_ar']??'') ?: ($c['title_en']??('Conference #'.$c['id']))) ?>
            </option>
          <?php endforeach; ?>
        </select>
      </form>

      <form method="post" action="<?= e(base_path('action/proceedings/publish')) ?>">
        <input type="hidden" name="conference_id" value="<?= (int)$confId ?>">
        <button class="btn btn-success">
          <i class="fa fa-bullhorn"></i> <?= e(t('publish') ?? 'Publish') ?>
        </button>
      </form>

      <a class="btn btn-outline-secondary" href="<?= e(base_path('admin/production?conference_id='.(int)$confId)) ?>">
        <i class="fa fa-arrow-left"></i> <?= e(t('back') ?? 'Back') ?>
      </a>
    </div>
  </div>

  <div class="card shadow-sm border-0">
    <div class="card-body">
      <div class="table-responsive">
        <table class="table table-hover align-middle">
          <thead>
            <tr>
              <th>#</th>
              <th><?= e(t('title') ?? 'Title') ?></th>
            </tr>
          </thead>
          <tbody>
            <?php if(empty($rows)): ?>
              <tr><td colspan="2" class="text-center text-muted py-4">—</td></tr>
            <?php else: foreach($rows as $r): ?>
              <tr>
                <td><?= (int)$r['id'] ?></td>
                <td><?= e((string)($r['title_en'] ?? ($r['title'] ?? ''))) ?></td>
              </tr>
            <?php endforeach; endif; ?>
          </tbody>
        </table>
      </div>
    </div>
  </div>
</div>

<?php require __DIR__ . '/../../layouts/footer.php'; ?>
