{% block main_sections %}
<div class="container border-top-0" style="page-break-after: always; height: 9.3in;">
  {% set title = "Inspection Report" %}
  {% include "nassco/pacp/page_title.html" %}
  {% include "nassco/pacp/table_header_row.html" %}
  <table class="w-full mt-1" style="border-collapse: collapse; width: 100%;">
    <thead>
      <tr>
        <th class="text-center font-extra-small box flex-1 border-bottom-0 border-left-0" style="padding: 8px; border: 1px solid #000;">No:</th>
        <th class="text-center font-extra-small box flex-2 border-bottom-0 border-left-0" style="padding: 8px; border: 1px solid #000;">Upstream MH:</th>
        <th class="text-center font-extra-small box flex-2 border-bottom-0 border-left-0" style="padding: 8px; border: 1px solid #000;">Downstream MH:</th>
        <th class="text-center font-extra-small box flex-1 border-bottom-0 border-left-0" style="padding: 8px; border: 1px solid #000;">Date (YYYY/MM/DD):</th>
        <th class="text-center font-extra-small box flex-2 border-bottom-0 border-left-0" style="padding: 8px; border: 1px solid #000;">Road:</th>
        <th class="text-center font-extra-small box flex-1 border-bottom-0 border-left-0" style="padding: 8px; border: 1px solid #000;">Material:</th>
        <th class="text-center font-extra-small box flex-2 border-bottom-0 border-left-0" style="padding: 8px; border: 1px solid #000;">Length Surveyed:</th>
        <th class="text-center font-extra-small box flex-2 border-bottom-0 border-left-0 border-right-0" style="padding: 8px; border: 1px solid #000;">Total Length:</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="text-center font-extra-small box h-1 flex-1 border-left-0" style="padding: 8px; border: 1px solid #000;">1</td>
        <td class="text-center font-extra-small box h-1 flex-2 border-left-0" style="padding: 8px; border: 1px solid #000;">
          {% if inspection.header.measurements.upstream_mh_number %}
          {{ inspection.header.measurements.upstream_mh_number }}
          {% else %}
          N/A
          {% endif %}
        </td>
        <td class="text-center font-extra-small box h-1 flex-2 border-left-0" style="padding: 8px; border: 1px solid #000;">
          {% if inspection.header.measurements.downstream_mh_number %}
          {{ inspection.header.measurements.downstream_mh_number }}
          {% else %}
          N/A
          {% endif %}
        </td>
        <td class="text-center font-extra-small box h-1 flex-1 border-left-0" style="padding: 8px; border: 1px solid #000;">
          {% if inspection.header.survey.survey_date %}
          {{ inspection.header.survey.survey_date.strftime("%Y/%m/%d") }}
          {% else %}
          N/A
          {% endif %}
        </td>
        <td class="text-center font-extra-small box h-1 flex-2 border-left-0" style="padding: 8px; border: 1px solid #000;">
          {% if inspection.header.location.street %}
          {{ inspection.header.location.street }}
          {% else %}
          N/A
          {% endif %}
        </td>
        <td class="text-center font-extra-small box h-1 flex-1 border-left-0" style="padding: 8px; border: 1px solid #000;">
          {% if inspection.header.pipe.material %}
          {{ inspection.header.pipe.material.label }}
          {% else %}
          N/A
          {% endif %}
        </td>
        <td class="text-center font-extra-small box h-1 flex-2 border-left-0" style="padding: 8px; border: 1px solid #000;">
          {% if inspection.header.pipe.length_surveyed %}
          {{ "%.2f"|format(inspection.header.pipe.length_surveyed) }} {{ measurement_units }}
          {% else %}
          N/A
          {% endif %}
        </td>
        <td class="text-center font-extra-small box h-1 flex-2 border-left-0 border-right-0" style="padding: 8px; border: 1px solid #000;">
          {% if inspection.header.pipe.total_length %}
          {{ "%.2f"|format(inspection.header.pipe.total_length) }} {{ measurement_units }}
          {% endif %}
        </td>
      </tr>
    </tbody>
  </table>
  
  <div class="row font-small box h-1 w-full border-top-0 border-left-0 border-right-0" style="color: red; font-weight: bold; padding: 8px; border: 1px solid #000;">
    <p class="text-center mx-auto">Diameter = {% if inspection.header.pipe.height %}{{ (inspection.header.pipe.height|int if inspection.header.pipe.height|int == inspection.header.pipe.height else inspection.header.pipe.height)|string|replace('.', ',') }} {{ pipe_size_units }}{% else %}N/A{% endif %}</p>
  </div>
  <div class="row font-small box h-1 w-full mt-2 border-left-0 border-right-0" style="color: red; font-weight: bold; padding: 8px; border: 1px solid #000;">
    <p class="text-center mx-auto">CCTV Length = {% if inspection.header.pipe.total_length %}{{ "%.2f"|format(inspection.header.pipe.total_length) }} {{ measurement_units }}{% else %}N/A{% endif %}</p>
  </div>
</div>
{% endblock %}
