<?= $this->extend('layouts/front') ?>
<?= $this->section('content') ?>
<div class="content">
  <div class="top">
    <?= form_open(current_url(), array("method" => "get")) ?>
    <ul class="nav">
      조건검색:<?php foreach ($viewDatas['fieldFilters'] as $field) : ?><?= getFieldFilter_UserHelper($field, $viewDatas[$field], $viewDatas) ?><?php endforeach ?>
      <?= $this->include('templates/front/index_head') ?>
    </ul>
    <?= form_close() ?>
  </div>
  <?= form_open(current_url() . '/batchjob', $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
  <table class="table table-bordered table-hover table-striped">
    <tr>
      <th>번호</th>
      <?php foreach ($viewDatas['fields'] as $field) : ?><th><?= getFieldIndex_Column_UserHelper($field, $viewDatas) ?></th><?php endforeach ?>
    </tr>
    <?php $cnt = 0 ?>
    <?php foreach ($viewDatas['entitys'] as $entity) : ?>
      <tr id="<?= $entity->getPrimaryKey() ?>" <?= $entity->getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)">
        <td>
          <!-- 사용자가 자신의 작성한것인지 확인되면 update 가능-->
          <?php if ($this->viewDatas[SESSION_NAMES['ISLOGIN']] && $entity->getUser_Uid() == $this->viewDatas['auth'][AUTH_FIELDS['ID']]) : ?>
            <?= anchor(current_url() . '/update/' . $entity->getPrimaryKey(), $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt), ["target" => "_self"]) ?>
          <?php endif ?>
        </td>
        <?php foreach ($viewDatas['fields'] as $field) : ?>
          <td nowrap><?= getFieldIndex_Row_UserHelper($field, $entity, $viewDatas) ?></td>
        <?php endforeach ?>
        <td>
          <!-- 사용자가 자신의 작성한것인지 확인되면 delete 가능-->
          <?php if ($this->viewDatas[SESSION_NAMES['ISLOGIN']] && $entity->getUser_Uid() == $this->viewDatas['auth'][AUTH_FIELDS['ID']]) : ?>
            <?= anchor(current_url() . '/delete/' . $entity->getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
          <?php endif ?>
        </td>
      </tr>
      <?php $cnt++ ?>
    <?php endforeach ?>
  </table>
  <div class="bottom">
    <ul class="nav justify-content-center">
      <!-- 사용자가 쓰기권한이 있는지 확인-->
      <?php if (isRole_CommonHelper($this->viewDatas['currentRoles'], $this->viewDatas['category'], CATEGORY_ROLE_FIELDS['WRITE'])) : ?>
        <li class="nav-item"><?= anchor(current_url() . '/insert', '입력', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?></li>
      <?php endif ?>
    </ul>
    <?= $viewDatas['pagination'] ?>
  </div>
  <?= form_close() ?>
</div>
<?= $this->endSection() ?>