<?= $this->extend("layouts/{$viewDatas['layout']}") ?>
<?= $this->section('content') ?>
<link href="/css/<?= $viewDatas['layout'] ?>/content.css" media="screen" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/<?= $viewDatas['layout'] ?>/content.js"></script>
<?= form_open(current_url(), array("method" => "get")) ?>
<nav class="index_top navbar navbar-expand-lg">
  <div class="container-fluid">
    <nav class="condition nav">
      조건검색:
      <?php foreach ($viewDatas['filter_fields'] as $field): ?>
        <?= getFieldForm_ZoneHelper($field, $viewDatas[$field], $viewDatas) ?>
      <?php endforeach ?>
    </nav>
    <nav class="search nav justify-content-center">
      검색어:<?= form_input('word', $viewDatas['word']) ?>
      검색일:<?= form_input('start', $viewDatas['start'], ["class" => "calender"]) ?><?= form_input('end', $viewDatas['end'], ["class" => "calender"]) ?>
      <?= form_submit('', '검색하기') ?>
      <?= anchor(current_url() . '/excel?' . $viewDatas['uri']->getQuery(), ICONS['EXCEL'], ["target" => "_self", "class" => "excel"]) ?>
    </nav>
    <nav class="pageinfo nav justify-content-end">
      페이지정보 : <?= $viewDatas['page'] ?>/<?= $viewDatas['total_page'] ?>
      <?= form_dropdown('per_page', $viewDatas['page_options'], $viewDatas['per_page'], array('onChange' => 'this.form.submit()')) ?>
      / 총:<?= $viewDatas['total_count'] ?>
    </nav>
  </div>
</nav>
<?= form_close() ?>
<?= form_open(current_url() . '/batchjob', $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
<table class="index_table table table-bordered table-hover table-striped">
  <thead>
    <tr>
      <th>번호</th>
      <?php foreach ($viewDatas['fields'] as $field): ?>
        <?= getListHeaders_ZoneHelper($field, $viewDatas) ?>
      <?php endforeach ?>
      <th>작업</th>
    </tr>
  </thead>
  <tbody>
    <?php $cnt = 0 ?>
    <?php foreach ($viewDatas['entitys'] as $entity): ?>
      <tr id="<?= $entity->getPK() ?>" <?= $entity->status != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)">
        <td class="text-center text-wrap">
          <?= form_checkbox(["id" => "checkbox_uid_{$entity->getPK()}", "name" => "batchjob_uids[]", "value" => $entity->getPK(), "class" => "batchjobuids_checkboxs"]); ?>
          <?= anchor(current_url() . '/modify/' . $entity->getPK(), $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt), ["target" => "_self"]) ?>
        </td>
        <?php foreach ($viewDatas['fields'] as $field): ?>
          <td><?= getListColumns_ZoneHelper($field, $entity, $viewDatas) ?></td>
        <?php endforeach ?>
        <td>
          <?= anchor(current_url() . '/delete/' . $entity->getPK(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
        </td>
      </tr>
      <?php $cnt++ ?>
    <?php endforeach ?>
  </tbody>
</table>
<div class="index_bottom">
  <ul class="nav justify-content-center">
    <li class="nav-item"><?= form_checkbox(array("id" => "batchjobuids_checkbox")) ?>ALL</li>
    <?php foreach ($viewDatas['batchjob_fields'] as $field): ?>
      <?= getFieldForm_ZoneHelper($field, DEFAULTS['EMPTY'], $viewDatas) ?>
    <?php endforeach ?>
    <li class="nav-item"><?= form_submit('', '일괄처리', array("class" => "btn btn-outline btn-warning")) ?></li>
    <li class="nav-item">
      <?= anchor(current_url() . '/create', '입력', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
    </li>
  </ul>
</div>
<div class="index_pagination"><?= $viewDatas['pagination'] ?></div>
<?= form_close() ?>
<div class="index_form">
  <div id="index_create_form"></div>
</div>
<script>
  document.addEventListener('DOMContentLoaded', function() {
    loadContentForm(
      "<?= base_url(strtolower($viewDatas["class_path"]) . "/create") ?>",
      document.getElementById('index_create_form')
    );
  });
</script>
<?= $this->endSection() ?>