<?= $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>
<?= $this->include('templates/' . $viewDatas['layout'] . '/index_top'); ?>
<?= form_open("", $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): ?>
        <?= getListLabel_RecordHelper($field, $viewDatas) ?>
      <?php endforeach ?>
      <th>작업</th>
    </tr>
  </thead>
  <tbody>
    <?php $cnt = 0 ?>
    <?php $old_zone = "" ?>
    <?php foreach ($viewDatas['entitys'] as $entity): ?>
      <tr <?= $entity->locked != 'on' ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?>>
        <?php $viewDatas['cnt'] = $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt); ?>
        <?php $viewDatas['entity'] = $entity; ?>
        <?php $viewDatas['old_zone'] = $old_zone ?>
        <td class="text-center text-wrap">
          <?= getListButton_RecordHelper('sync', $viewDatas, ["style" => "cursor:pointer"]) ?>
        </td>
        <?php foreach ($viewDatas['fields'] as $field): ?>
          <td><?= getFieldView_RecordHelper($field,  $viewDatas) ?></td>
        <?php endforeach ?>
        <td>
          <?= getListButton_RecordHelper('delete',  $viewDatas) ?>
        </td>
      </tr>
      <?php $old_zone = $entity->getParent() ?>
      <?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_RecordHelper($field, DEFAULTS['EMPTY'], $viewDatas) ?>
    <?php endforeach ?>
    <li class="nav-item"><?= form_submit("", '일괄처리', ['formaction' => current_url() . '/batchjob', "class" => "btn btn-outline btn-warning"]) ?></li>
    <li class="nav-item"><?= getListButton_RecordHelper('create', $viewDatas, ["style" => "cursor:pointer"]) ?></li>
  </ul>
</div>
<?= form_close() ?>
<div class=" index_pagination"><?= $viewDatas['pagination'] ?></div>
<?php if (in_array($viewDatas['action_form'], [FORMS['MODAL'], FORMS['IFRAME']])): ?>
  <?= $this->include('templates/' . $viewDatas['layout'] . '/' . $viewDatas['action_form']); ?>
<?php endif ?>
<?= $this->endSection() ?>