<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
<?= $this->section('content') ?>
<div id="container" class="content">
  <link href="/css/<?= $viewDatas['layout'] ?>/form.css" media="screen" rel="stylesheet" type="text/css" />
  <div class="action_form" style="width:600px;">
    <!-- 청구서 정보 -->
    <table class=" table table-bordered text-center">
      <tbody>
        <tr>
          <th class="p-0">메일 제목</th>
          <td colspan="3">서비스 요금 청구서 </td>
        </tr>
        <tr>
          <th class="p-0">발신자</th>
          <td class="p-0">support@priem-idc.jp</td>
          <th class="p-0">발행일</th>
          <td class="p-0"><?= date("Y-m-d") ?></td>
        </tr>
      </tbody>
    </table>
    <!-- 서비스 테이블 -->
    <?php foreach ($viewDatas['entities'] as $entity): ?>
      <table class="table table-sm table-bordered text-center">
        <tr>
          <th class="p-0">관리자명</th>
          <th class="p-0">총 결제 금액</th>
        </tr>
        <tr>
          <td class="p-0"><?= $entity['name'] ?></td>
          <td class="p-0"><?= number_format($entity['total_amount']) ?>원</td>
        </tr>
        <tr>
          <td colspan="2">
            <table class="table table-sm table-bordered">
              <tr>
                <th class="p-0">코드</th>
                <th class="p-0">항목</th>
                <th class="p-0">지급기한</th>
              </tr>
              <?php foreach ($entity['services'] as $service): ?>
                <tr>
                  <td class="p-0"><?= $service['code'] ?></td>
                  <td class="p-0">
                    <ol>
                      <?php foreach ($service['items'] as $item): ?>
                        <li class="m-0 p-0">
                          <div class="row align-items-start p-0">
                            <div class="col text-start"><?= $item['item_type'] ?></div>
                            <div class="col text-nowrap"><?= $item['item_uid'] ?></div>
                            <div class="col text-end text-nowrap"><?= number_format($item['amount']) ?>원</div>
                          </div>
                        </li>
                      <?php endforeach; ?>
                    </ol>
                  </td>
                  <td class="p-0 text-nowrap"><?= $service['billing_at'] ?></td>
                </tr>
              <?php endforeach; ?>
            </table>
          </td>
        </tr>
      </table>
    <?php endforeach; ?>
    <?= $this->include("{$viewDatas['layout']}/payment/invoice_info"); ?>
    <?= $this->include("{$viewDatas['layout']}/payment/invoice_mobile"); ?>
  </div>
</div>
<?= $this->endSection() ?>