<?php foreach ($serviceCellDatas['entities'] as $entity): ?>
  <?php $serviceCellDatas['entity'] = $entity ?>
  <div class="rounded border border-gray p-2 mt-3">
    <table class="table table-bordered table-striped">
      <tr class="text-center">
        <th style="width: 120px">서비스정보</th>
        <th>서버</th>
        <th style="width: 600px">서비스 비고</th>
        <th style="width: 200px">결제처리</th>
      </tr>
      <tr class="text-left">
        <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>
        <td class="text-center" nowrap><?= view('cells/service/server', ['serverEntities' => $serviceCellDatas['childServers'][$entity->getPK()]]) ?></td>
        <td class="text-center" nowrap>
          <?= form_open("/admin/customer/service/history/{$entity->getPK()}?return_url=" . urlencode(current_url()), ['method' => "post"]) ?>
          <textarea name="history" class="form-control note-box"><?= $entity->getHistory() ?></textarea>
          <?= form_submit('', '저장', array("class" => "btn btn-outline btn-primary m-3")); ?>
          <?= form_close() ?>
        </td>
        <td>
          <table class="table m-0 p-0">
            <tr>
              <th class="fw-bold" nowrap>결제일</th>
              <td nowrap><?= $entity->getBillingAT() ?></td>
            </tr>
            <tr>
              <th class="fw-bold" nowrap>결제금</th>
              <td class="amount-green" nowrap><?= number_format(intval($entity->getAmount())) ?>원</td>
            </tr>
            <tr>
              <th class="fw-bold" nowrap>미납금</th>
              <td class="amount-red" nowrap>
                <?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; ?>