<?= $this->extend($viewDatas['layout']['layout']) ?>
<?= $this->section('content') ?>
<link href="/css/admin/form.css" media="screen" rel="stylesheet" type="text/css" />
<script src="/js/admin/form.js" referrerpolicy="origin"></script>
<link href="/css/<?= $viewDatas['layout']['path'] ?>/index.css" media="screen" rel="stylesheet" type="text/css" />
<style>
  textarea.note-box {
    width: 100%;
    min-height: 150px;
    height: 100%;
    /* 부모의 높이를 꽉 채움 */
    resize: none;
    box-sizing: border-box;
  }
</style>
<?= session('message') ? $viewDatas['helper']->alertTrait(session('message')) : ""; ?>
<div class="layout_top"><?= $this->include($viewDatas['layout']['layout'] . '/top'); ?></div>
<!-- Layout Middle Start -->
<table class="layout_middle">
  <tr>
    <td class="layout_left">
      <!-- Layout Left Start -->
      <?= $this->include($viewDatas['layout']['layout'] . '/left_menu'); ?>
      <!-- Layout Left End -->
    </td>
    <td class="layout_right">
      <!-- Layout Right Start -->
      <div class="layout_header"><?= $this->include("{$viewDatas['layout']['template']}/index_header"); ?></div>
      <div id="container" class="layout_content">
        <div class="index_body p-4">
          <!-- index_body -->
          <div class="row align-items-end rounded border border-gray p-2 mt-3">
            <table class="table table-bordered table-hover table-striped m-0 p-0">
              <tr class="text-center">
                <th rowspan="2">
                  <div> <?= $viewDatas['entity']->getTitle() ?></div>
                  <div> <?= $viewDatas['helper']->getListButton('invoice', "[청구서발행]", $viewDatas) ?></div>
                  <div class="mt-3"><?= $viewDatas['helper']->getListButton('addService', "서비스추가", $viewDatas) ?></div>
                </th>
                <th>도코</th>
                <th>치바</th>
                <th>VPN</th>
                <th>일반</th>
                <th>방어</th>
                <th>전용</th>
                <th>이벤트</th>
                <th>테스트</th>
                <th>대체</th>
                <th>쿠폰</th>
                <th>예치금</th>
                <th>포인트</th>
                <th>전체요금</th>
                <th>전체미납금</th>
              </tr>
              <tr class="text-center">
                <td><?= $viewDatas['totalCounts']['tokyo_summary'] ?></td>
                <td><?= $viewDatas['totalCounts']['chiba_summary'] ?></td>
                <td><?= $viewDatas['totalCounts']['vpn']['summary'] ?></td>
                <td><?= $viewDatas['totalCounts']['normal']['summary'] ?></td>
                <td><?= $viewDatas['totalCounts']['defence']['summary'] ?></td>
                <td><?= $viewDatas['totalCounts']['dedicated']['summary'] ?></td>
                <td><?= $viewDatas['totalCounts']['event']['summary'] ?></td>
                <td><?= $viewDatas['totalCounts']['test']['summary'] ?></td>
                <td><?= $viewDatas['totalCounts']['alternative']['summary'] ?></td>
                <td><?= $viewDatas['helper']->getListButton("coupon", $viewDatas['entity']->getCouponBalance(), $viewDatas) ?></td>
                <td><?= $viewDatas['helper']->getListButton("account", number_format($viewDatas['entity']->getAccountBalance()) . "원", $viewDatas) ?></td>
                <td><?= $viewDatas['helper']->getListButton("point", number_format($viewDatas['entity']->getPointBalance()), $viewDatas) ?></td>
                <td><?= array_key_exists($viewDatas['entity']->getPK(), $viewDatas['totalAmounts']) ? number_format($viewDatas['totalAmounts'][$viewDatas['entity']->getPK()]) : 0 ?>원</td>
                <td><?= $viewDatas['helper']->getListButton('unpaid', "", $viewDatas) ?></td>
              </tr>
            </table>
          </div>
          <?= form_open("/admin/customer/client/history/{$viewDatas['entity']->getPK()}?return_url=" . urlencode(current_url()), ['method' => "post"]) ?>
          <div class="row align-items-center rounded border border-gray p-2 mt-3">
            <div class="col-1">
              <div class="text-center fw-bold">고객 비고</div>
            </div>
            <div class="col-10">
              <?= $viewDatas['helper']->getFieldForm('history', $viewDatas['entity']->getHistory(), $viewDatas) ?>
            </div>
            <div class="col-1">
              <?= form_submit('', '저장', array("class" => "btn btn-outline btn-primary")); ?>
            </div>
          </div>
          <?= form_close() ?>
          <?= view_cell("\App\Cells\Customer\ServiceCell::detail", ['clientinfo_uid' => $viewDatas['entity']->getPK()]) ?>
          <?= view_cell("\App\Cells\PaymentCell::detail", ['clientinfo_uid' => $viewDatas['entity']->getPK()]) ?>
        </div>
        <!-- index_body -->
      </div>
      <div class="layout_footer"><?= $this->include("{$viewDatas['layout']['template']}/index_footer"); ?></div>
      <!-- Layout Right End -->
    </td>
  </tr>
</table>
<!-- Layout Middle End -->
<div class="layout_bottom"><?= $this->include($viewDatas['layout']['layout'] . '/bottom'); ?></div>
<?= $this->endSection() ?>