<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
<?= $this->section('content') ?>
<?php if ($error = session('error')): echo $viewDatas['helper']->alert($error) ?><?php endif ?>
<!-- Layout Right Start -->
<div id="container" class="layout_content">
  <link href="/css/<?= $viewDatas['layout'] ?>/index.css" media="screen" rel="stylesheet" type="text/css" />
  <div class="index_body">
    <?= form_open(current_url(),  ["method" => "get"]) ?>
    <nav class="index_top navbar navbar-expand-lg">
      <div class="container-fluid">
        <nav class="condition nav">
          조건:
          <?php foreach ($viewDatas['control']['filter_fields'] as $field): ?>
            <?= $viewDatas['helper']->getFieldForm($field, $viewDatas[$field] ? $viewDatas[$field] : old($field), $viewDatas, ['index_content_top_filter' => 'true']) ?>&nbsp;
          <?php endforeach ?>
          <button class="btn btn-outline-primary" type="submit">검색</button>
        </nav>
        <nav class="pageinfo nav justify-content-end">
          Page:<?= $viewDatas['page'] ?>/<?= $viewDatas['total_page'] ?>
          <?= form_dropdown('per_page', $viewDatas['page_options'], $viewDatas['per_page'], ['onChange' => 'this.form.submit()']) ?>
          / 총:<?= $viewDatas['total_count'] ?>
        </nav>
      </div>
    </nav>
    <?= form_close() ?>
    <?= form_open(current_url(), ['id' => 'batchjob_form', 'method' => "post"]) ?>
    <table class="index_table data table table-bordered table-hover table-striped" data-rtc-resizable-table="reisze_table">
      <thead>
        <tr>
          <th class="index_head_short_column">번호</th>
          <?php foreach ($viewDatas['control']['index_fields'] as $field): ?>
            <th data-rtc-resizable="<?= $field ?>"><?= $viewDatas['helper']->getListLabel($field, $viewDatas) ?></th>
          <?php endforeach ?>
          <th class="index_head_short_column">작업</th>
        </tr>
      </thead>
      <tbody>
        <?php $cnt = 0 ?>
        <?php foreach ($viewDatas['entities'] as $entity): ?>
          <?php $viewDatas['entity'] = $entity; ?>
          <tr <?= $viewDatas['helper']->getListRowColor($entity) ?>>
            <?php $viewDatas['cnt'] = $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt); ?>
            <td><?= $viewDatas['helper']->getListButton('modify', $viewDatas) ?></td>
            <?php foreach ($viewDatas['control']['index_fields'] as $field): ?>
              <td><?= $viewDatas['helper']->getFieldView($field, $entity->$field, $viewDatas) ?></td>
            <?php endforeach ?>
            <td nowrap>
              <?= $viewDatas['helper']->getListButton('view', $viewDatas) ?>&nbsp;
              <?= $viewDatas['helper']->getListButton('delete', $viewDatas) ?>
            </td>
          </tr>
          <?php $cnt++ ?>
        <?php endforeach ?>
      </tbody>
    </table>
    <?= $this->include("templates/{$viewDatas['layout']}/index_content_bottom"); ?>
    <?= form_close() ?>
  </div>
  <div class="index_bottom"><?= $this->include("templates/common/" . (isset($viewDatas['modal_type']) ? $viewDatas['modal_type'] : 'modal_iframe')); ?></div>
  <script type="text/javascript" src="/js/<?= $viewDatas['layout'] ?>/index.js"></script>
</div>
<!-- Layout Middle End -->
<?= $this->endSection() ?>