<style>
  .note-box {
    width: 100%;
    height: 140px;
    resize: none;
  }
</style>
<?php foreach ($serviceCellDatas['entities'] as $entity): ?>
  <?php $serviceCellDatas['entity'] = $entity ?>
  <?php $unpaids = $serviceCellDatas['paymentService']->getUnPaids('serviceinfo_uid', ['serviceinfo_uid' => $entity->getPK()]) ?>
  <div class="rounded border border-gray p-2 mt-3">
    <table class="table table-bordered table-hover table-striped">
      <tr class="text-center">
        <th style="width: 120px"><a href="#">[상세정보]</a></th>
        <th style="width: 120px">사이트/위치/형식</th>
        <th style="width: 250px">CPU / 메모리 / 저장장치</th>
        <th style="width: 250px">OS / SOFTWARE</th>
        <th style="width: 200px">IP주소</th>
        <th style="width: 200px">CS</th>
        <th>서비스 비고</th>
        <th style="width: 200px">결제처리</th>
      </tr>
      <tr class="text-left">
        <td rowspan="4" class="text-center">
          <div><?= $entity->getCode() ?></div>
          <div><?= $entity->getServerEntity()->getCode() ?></div>
        </td>
        <td class="text-center">
          <div><?= $serviceCellDatas['service']->getHelper()->getFieldView('site', $entity->getSite(), $serviceCellDatas) ?></div>
          <div><?= $serviceCellDatas['service']->getHelper()->getFieldView('location', $entity->getLocation(), $serviceCellDatas) ?></div>
          <div><?= $serviceCellDatas['service']->getHelper()->getFieldView('type', $entity->getType(), $serviceCellDatas) ?></div>
        </td>
        <?= view_cell("\App\Cells\Equipment\ServerPartCell::parttable", ['serverinfo_uid' => $entity->getServerEntity()->getPK(), 'types' => SERVERPART['SERVICE_PARTTYPES'], 'template' => 'partdetail']) ?>
        <td>
          <?= form_open("/admin/customer/service/history/{$entity->getPK()}?return_url=" . urlencode(current_url()), ['method' => "post"]) ?>
          <div class="row align-items-center">
            <div class="col-10">
              <textarea name="history" class="form-control note-box"><?= $entity->getHistory() ?></textarea>
            </div>
            <div class="col-2">
              <?= form_submit('', '저장', array("class" => "btn btn-outline btn-primary")); ?>
            </div>
          </div>
          <?= form_close() ?>
        </td>
        <td rowspan="4">
          <table class="table m-0 p-0">
            <tr>
              <th class="fw-bold">결제일</th>
              <td><?= $entity->getBillingAT() ?></td>
            </tr>
            <tr>
              <th class="fw-bold">결제금</th>
              <td class="amount-green"><?= number_format(intval($entity->getAmount())) ?>원</td>
            </tr>
            <tr>
              <th class="fw-bold">미납금</th>
              <td class="amount-red"><?= array_key_exists('amount', $unpaids) ? number_format($unpaids['amount']) : 0 ?>원</td>
            </tr>
            <tr>
              <td colspan="2" class="text-center"><a href="/admin/customer/payment?clientinfo_uid=<?= $entity->getClientInfoUID() ?>"><button class="btn btn-success">결제내역</button></a></td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
  </div>
<?php endforeach; ?>