<style>
  .note-box {
    width: 100%;
    height: 140px;
    resize: none;
  }
</style>
<?php foreach ($serviceCellDatas['entities'] as $entity): ?>
  <?php $serviceCellDatas['entity'] = $entity ?>
  <div class="rounded border border-gray p-2 mt-3">
    <div style="font-size:15px">서비스 목록</div>
    <table class="table table-bordered table-hover table-striped">
      <tr class="text-center">
        <th style="width: 120px">서비스 상세정보</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>
          <div>[<?= $entity->getServerEntity()->getTitle() ?>]</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>
        </td>
        <?= view_cell("\App\Cells\Equipment\ServerPartCell::parttable", [
          'serverinfo_uid' => $entity->getServerEntity()->getPK(),
          'types' => SERVERPART['ALL_PARTTYPES'],
          'template' => 'part_detail'
        ]) ?>
        <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">
                <?php if (array_key_exists($entity->getPK(), $serviceCellDatas['unPaids'])): ?>
                  총 <a href="/admin/customer/payment?clientinfo_uid=<?= $entity->getClientInfoUID() ?>&serviceinfo_uid=<?= $entity->getPK() ?>"><?= $serviceCellDatas['unPaids'][$entity->getPK()]['cnt'] ?>건/<?= number_format($serviceCellDatas['unPaids'][$entity->getPK()]['amount']) ?></a>원
                <?php endif ?>
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
  </div>
<?php endforeach; ?>