<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
<?= $this->section('content') ?>
<?php if ($error = session('error')): echo $viewDatas['service']->getHelper()->alert($error) ?><?php endif ?>
<div class="layout_top"><?= $this->include(LAYOUTS[$viewDatas['layout']]['path'] . '/top'); ?></div>
<!-- Layout Middle Start -->
<table class="layout_middle">
  <tr>
    <td class="layout_left">
      <!-- Layout Left Start -->
      <?= $this->include(LAYOUTS[$viewDatas['layout']]['path'] . '/left_menu'); ?>
      <!-- Layout Left End -->
    </td>
    <td class="layout_right">
      <!-- Layout Right Start -->
      <div class="layout_header"><?= $this->include("templates/{$viewDatas['layout']}/index_header"); ?></div>
      <div id="container" class="layout_content">
        <link href="/css/<?= $viewDatas['layout'] ?>/index.css" media="screen" rel="stylesheet" type="text/css" />
        <style>
          table.layout_middle td.layout_right div#container * {
            font-size: 12px;
          }

          .note-box {
            height: 150px;
            resize: none;
          }
        </style>
        <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><a href="/admin/customer/payment?clientinfo_uid=<?= $viewDatas['entity']->getPK() ?>">[청구서발행]</a></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_total'] ?></td>
                <td><?= $viewDatas['totalCounts']['chiba_total'] ?></td>
                <td><?= $viewDatas['totalCounts']['vpn']['total'] ?></td>
                <td><?= $viewDatas['totalCounts']['normal']['total'] ?></td>
                <td><?= $viewDatas['totalCounts']['defence']['total'] ?></td>
                <td><?= $viewDatas['totalCounts']['dedicated']['total'] ?></td>
                <td><?= $viewDatas['totalCounts']['event']['total'] ?></td>
                <td><?= $viewDatas['totalCounts']['test']['total'] ?></td>
                <td><?= $viewDatas['totalCounts']['alternative']['total'] ?></td>
                <td><?= $viewDatas['entity']->getCouponBalance() ?>%</td>
                <td><?= $viewDatas['entity']->getSaleRate() ?>%</td>
                <td><?= $viewDatas['entity']->getAccountBalance() ?></td>
                <td><?= array_key_exists($viewDatas['entity']->getPK(), $viewDatas['totalAmounts']) ? number_format($viewDatas['totalAmounts'][$viewDatas['entity']->getPK()]) : 0 ?></td>
                <td><?= array_key_exists($viewDatas['entity']->getPK(), $viewDatas['unPaids']) ? number_format($viewDatas['unPaids'][$viewDatas['entity']->getPK()]['amount']) : 0 ?></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">
              <textarea name="history" class="form-control note-box"><?= $viewDatas['entity']->getHistory() ?></textarea>
            </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", ['userinfo_uid' => $viewDatas['entity']->getPK()]) ?>
        </div>
        <!-- index_body -->
      </div>
      <div class="layout_footer"><?= $this->include("templates/{$viewDatas['layout']}/index_footer"); ?></div>
      <!-- Layout Right End -->
    </td>
  </tr>
</table>
<!-- Layout Middle End -->
<div class="layout_bottom"><?= $this->include(LAYOUTS[$viewDatas['layout']]['path'] . '/bottom'); ?></div>
<?= $this->endSection() ?>