<template>
  <Filters
    @run-report="() => exportToPDF(reportMeta, data, true)"
    @reset-form="data = []"
    :report-button="true"
    @run-search="() => filterData(filters)"
    class="mb-4"
  >
    <Type2 @update:filters="(value) => (filters = value)" />
  </Filters>

  <div id="data">
    <DxDataGrid
      ref="dataGridRef"
      :allow-column-reordering="true"
      class="max-h-[calc(100vh-140px)] mb-10"
      :data-source="data"
      v-if="loadingData == false"
      :show-column-lines="true"
      :show-row-lines="false"
      :show-borders="true"
      :row-alternation-enabled="true"
      :hover-state-enabled="true"
      @selection-changed="onDataSelectionChanged"
      @exporting="onExporting"
      :allow-column-resizing="true"
      column-resizing-mode="widget"
      :word-wrap-enabled="true"
    >
      <DxGrouping expand-mode="rowClick" :auto-expand-all="false" />
      <DxSelection mode="single" />
      <DxPaging :enabled="false" />
      <DxScrolling column-rendering-mode="virtual" mode="virtual" />

      <DxSearchPanel :visible="true" :highlight-case-sensitive="true" />
      <DxExport
        :enabled="true"
        :formats="['pdf', 'xlsx', 'document']"
        :allow-export-selected-data="false"
      />
      <DxColumnFixing :enabled="true" />

      <DxColumn
        v-if="grouping.length > 0"
        v-for="(group, index) in grouping"
        :width="150"
        alignment="center"
        :data-field="group.data"
        :caption="group.caption"
        css-class="custom-table-column"
        cell-template="formatText"
        :group-index="index"
      />
      <DxColumn
        alignment="center"
        :min-width="170"
        data-type="text"
        data-field="nama_ulp"
        caption="Nama Unit"
        css-class="custom-table-column"
        cell-template="formatText"
      />
      <DxColumn
        alignment="center"
        caption="Jumlah Dispatching Time Gangguan"
        css-class="custom-table-column"
      >
        <DxColumn alignment="center" caption="MoM" css-class="custom-table-column">
          <DxColumn
            :width="150"
            alignment="center"
            data-field="mom_bulan_kemarin"
            data-type="number"
            :caption="`${getMonthName(lastMonth)} ${lastYearMoM}`"
            css-class="custom-table-column"
            cell-template="formatNumberMomLastMonthLastYear"
          />
          <DxColumn
            :visible="false"
            :width="150"
            alignment="center"
            data-field="count_mom_bulan_kemarin"
            data-type="number"
            :caption="`Count ${getMonthName(lastMonth)} ${lastYearMoM}`"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
          <DxColumn
            :visible="false"
            :width="150"
            alignment="center"
            data-field="cal_mom_bulan_kemarin"
            :caption="`Cal ${getMonthName(lastMonth)} ${lastYearMoM}`"
            data-type="number"
            css-class="custom-table-column"
            cell-template="formatNumber"
            :calculate-cell-value="
              (rowData: any) => rowData.count_mom_bulan_kemarin * rowData.mom_bulan_kemarin
            "
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="mom_bulan_ini"
            data-type="number"
            :caption="`${getMonthName(currentMonth)} ${currentYear}`"
            css-class="custom-table-column"
            cell-template="formatNumberMomCurrentMonthCurrentYear"
          />
          <DxColumn
            :visible="false"
            :width="150"
            alignment="center"
            data-field="count_mom_bulan_ini"
            data-type="number"
            :caption="`Count ${getMonthName(currentMonth)} ${currentYear}`"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
          <DxColumn
            :visible="false"
            :width="150"
            alignment="center"
            data-field="cal_mom_bulan_ini"
            data-type="number"
            css-class="custom-table-column"
            cell-template="formatNumber"
            :calculate-cell-value="
              (rowData: any) => rowData.count_mom_bulan_ini * rowData.mom_bulan_ini
            "
          />
          <DxColumn
            :width="70"
            alignment="center"
            data-field="persen_mom"
            data-type="number"
            caption="%"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
        </DxColumn>
        <DxColumn alignment="center" caption="YoY" css-class="custom-table-column">
          <DxColumn
            :width="150"
            alignment="center"
            data-field="yoy_tahun_kemarin"
            data-type="number"
            :caption="`s.d ${getMonthName(currentMonth)} ${lastYear}`"
            css-class="custom-table-column"
            cell-template="formatNumberYoyCurrentMonthLastYear"
          />
          <DxColumn
            :visible="false"
            :width="150"
            alignment="center"
            data-field="count_yoy_tahun_kemarin"
            data-type="number"
            :caption="`Count ${getMonthName(currentMonth)} ${lastYear}`"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
          <DxColumn
            :visible="false"
            :width="150"
            alignment="center"
            data-field="cal_yoy_tahun_kemarin"
            data-type="number"
            css-class="custom-table-column"
            cell-template="formatNumber"
            :calculate-cell-value="
              (rowData: any) => rowData.count_yoy_tahun_kemarin * rowData.yoy_tahun_kemarin
            "
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="yoy_tahun_ini"
            data-type="number"
            :caption="`s.d ${getMonthName(currentMonth)} ${currentYear}`"
            css-class="custom-table-column"
            cell-template="formatNumberYoyCurrentMonthCurrentYear"
          />
          <DxColumn
            :visible="false"
            :width="150"
            alignment="center"
            data-field="count_yoy_tahun_ini"
            data-type="number"
            :caption="`Count ${getMonthName(currentMonth)} ${currentYear}`"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
          <DxColumn
            :visible="false"
            :width="150"
            alignment="center"
            data-field="cal_yoy_tahun_ini"
            data-type="number"
            css-class="custom-table-column"
            cell-template="formatNumber"
            :calculate-cell-value="
              (rowData: any) => rowData.count_yoy_tahun_ini * rowData.yoy_tahun_ini
            "
          />
          <DxColumn
            :width="70"
            alignment="center"
            data-field="persen_yoy"
            data-type="number"
            caption="%"
            css-class="custom-table-column"
            cell-template="formatNumber"
          />
        </DxColumn>
      </DxColumn>

      <DxSummary :calculate-custom-summary="calculateCustomSummary">
        <DxTotalItem
          :display-format="`RATA-RATA`"
          show-in-column="nama_ulp"
          css-class="text-white !text-left"
        />
        <DxTotalItem
          column="mom_bulan_kemarin"
          name="mom_bulan_kemarin"
          summary-type="custom"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxTotalItem
          column="count_mom_bulan_kemarin"
          name="count_mom_bulan_kemarin"
          summary-type="custom"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxTotalItem
          column="cal_mom_bulan_kemarin"
          name="cal_mom_bulan_kemarin"
          summary-type="custom"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxTotalItem
          column="mom_bulan_ini"
          name="mom_bulan_ini"
          summary-type="custom"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxTotalItem
          column="cal_mom_bulan_ini"
          name="cal_mom_bulan_ini"
          summary-type="custom"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxTotalItem
          column="count_mom_bulan_ini"
          name="count_mom_bulan_ini"
          summary-type="custom"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxTotalItem
          column="persen_mom"
          name="persen_mom"
          summary-type="custom"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatPercentage(e.value)"
        />
        <DxTotalItem
          column="yoy_tahun_kemarin"
          name="yoy_tahun_kemarin"
          summary-type="custom"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxTotalItem
          column="cal_yoy_tahun_kemarin"
          name="cal_yoy_tahun_kemarin"
          summary-type="custom"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxTotalItem
          column="count_yoy_tahun_kemarin"
          name="count_yoy_tahun_kemarin"
          summary-type="custom"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxTotalItem
          column="yoy_tahun_ini"
          name="yoy_tahun_ini"
          summary-type="custom"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxTotalItem
          column="cal_yoy_tahun_ini"
          name="cal_yoy_tahun_ini"
          summary-type="custom"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxTotalItem
          column="count_yoy_tahun_ini"
          name="count_yoy_tahun_ini"
          summary-type="custom"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxTotalItem
          column="persen_yoy"
          name="persen_yoy"
          summary-type="custom"
          display-format="{0}"
          css-class="text-white !text-right"
          :customize-text="(e: any) => formatPercentage(e.value)"
        />

        <DxGroupItem
          :show-in-group-footer="false"
          :align-by-column="true"
          summary-type="custom"
          display-format="{0}"
          show-in-column="mom_bulan_kemarin"
          name="mom_bulan_kemarin"
          column="mom_bulan_kemarin"
          css-class="!text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxGroupItem
          :show-in-group-footer="false"
          :align-by-column="true"
          summary-type="custom"
          display-format="{0}"
          show-in-column="cal_mom_bulan_kemarin"
          name="cal_mom_bulan_kemarin"
          column="cal_mom_bulan_kemarin"
          css-class="!text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxGroupItem
          :show-in-group-footer="false"
          :align-by-column="true"
          summary-type="custom"
          display-format="{0}"
          show-in-column="count_mom_bulan_kemarin"
          name="count_mom_bulan_kemarin"
          column="count_mom_bulan_kemarin"
          css-class="!text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxGroupItem
          :show-in-group-footer="false"
          :align-by-column="true"
          summary-type="custom"
          show-in-column="mom_bulan_ini"
          name="mom_bulan_ini"
          column="mom_bulan_ini"
          css-class="!text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxGroupItem
          :show-in-group-footer="false"
          :align-by-column="true"
          summary-type="custom"
          show-in-column="cal_mom_bulan_ini"
          name="cal_mom_bulan_ini"
          column="cal_mom_bulan_ini"
          css-class="!text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxGroupItem
          :show-in-group-footer="false"
          :align-by-column="true"
          summary-type="custom"
          show-in-column="count_mom_bulan_ini"
          name="count_mom_bulan_ini"
          column="count_mom_bulan_ini"
          css-class="!text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxGroupItem
          :show-in-group-footer="false"
          :align-by-column="true"
          summary-type="custom"
          show-in-column="persen_mom"
          name="persen_mom"
          column="persen_mom"
          css-class="!text-right"
          :customize-text="(e: any) => formatPercentage(e.value)"
        />
        <DxGroupItem
          :show-in-group-footer="false"
          :align-by-column="true"
          summary-type="custom"
          show-in-column="yoy_tahun_kemarin"
          name="yoy_tahun_kemarin"
          column="yoy_tahun_kemarin"
          css-class="!text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxGroupItem
          :show-in-group-footer="false"
          :align-by-column="true"
          summary-type="custom"
          show-in-column="cal_yoy_tahun_kemarin"
          name="cal_yoy_tahun_kemarin"
          column="cal_yoy_tahun_kemarin"
          css-class="!text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxGroupItem
          :show-in-group-footer="false"
          :align-by-column="true"
          summary-type="custom"
          show-in-column="count_yoy_tahun_kemarin"
          name="count_yoy_tahun_kemarin"
          column="count_yoy_tahun_kemarin"
          css-class="!text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxGroupItem
          :show-in-group-footer="false"
          :align-by-column="true"
          summary-type="custom"
          show-in-column="yoy_tahun_ini"
          name="yoy_tahun_ini"
          column="yoy_tahun_ini"
          css-class="!text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxGroupItem
          :show-in-group-footer="false"
          :align-by-column="true"
          summary-type="custom"
          show-in-column="cal_yoy_tahun_ini"
          name="cal_yoy_tahun_ini"
          column="cal_yoy_tahun_ini"
          css-class="!text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxGroupItem
          :show-in-group-footer="false"
          :align-by-column="true"
          summary-type="custom"
          show-in-column="count_yoy_tahun_ini"
          name="count_yoy_tahun_ini"
          column="count_yoy_tahun_ini"
          css-class="!text-right"
          :customize-text="(e: any) => formatNumber(e.value)"
        />
        <DxGroupItem
          :show-in-group-footer="false"
          :align-by-column="true"
          summary-type="custom"
          show-in-column="persen_yoy"
          name="persen_yoy"
          column="persen_yoy"
          css-class="!text-right"
          :customize-text="(e: any) => formatPercentage(e.value)"
        />
      </DxSummary>

      <template #formatNumber="{ data }">
        <p class="text-right cursor-pointer" @click="setRequirements('', 0, 0)">
          {{
            isNumber(data.text)
              ? data.column.caption == '%'
                ? formatPercentage(data.text)
                : formatNumber(data.text)
              : data.text
          }}
        </p>
      </template>

      <template #formatNumberMomLastMonthLastYear="{ data }">
        <p
          class="text-right cursor-pointer"
          @click="setRequirements('mom', lastMonth, lastYearMoM)"
        >
          {{
            isNumber(data.text)
              ? data.column.caption == '%'
                ? formatPercentage(data.text)
                : formatNumber(data.text)
              : data.text
          }}
        </p>
      </template>

      <template #formatNumberMomCurrentMonthCurrentYear="{ data }">
        <p
          class="text-right cursor-pointer"
          @click="setRequirements('mom', currentMonth, currentYear)"
        >
          {{
            isNumber(data.text)
              ? data.column.caption == '%'
                ? formatPercentage(data.text)
                : formatNumber(data.text)
              : data.text
          }}
        </p>
      </template>

      <template #formatNumberYoyCurrentMonthLastYear="{ data }">
        <p
          class="text-right cursor-pointer"
          @click="setRequirements('yoy', currentMonth, lastYear)"
        >
          {{
            isNumber(data.text)
              ? data.column.caption == '%'
                ? formatPercentage(data.text)
                : formatNumber(data.text)
              : data.text
          }}
        </p>
      </template>

      <template #formatNumberYoyCurrentMonthCurrentYear="{ data }">
        <p
          class="text-right cursor-pointer"
          @click="setRequirements('yoy', currentMonth, currentYear)"
        >
          {{
            isNumber(data.text)
              ? data.column.caption == '%'
                ? formatPercentage(data.text)
                : formatNumber(data.text)
              : data.text
          }}
        </p>
      </template>

      <template #formatText="{ data }">
        <p class="!text-left cursor-pointer" @click="setRequirements('', 0, 0)">
          {{ data.text }}
        </p>
      </template>
    </DxDataGrid>
  </div>

  <DetailDialog
    :open="dialogDetail"
    title="Detail Dispatching Time Gangguan"
    @on-close="closedialogDetail"
    :full-width="true"
  >
    <div class="w-full mb-4 lg:w-[70%] lg:float-left">
      <div class="p-4 bg-white rounded-xl lg:mr-4">
        <DxDataGrid
          :allow-column-reordering="true"
          class="max-h-[calc(100vh-140px)]"
          :data-source="dataSub"
          :show-column-lines="true"
          :show-row-lines="false"
          :show-borders="true"
          :row-alternation-enabled="true"
          :hover-state-enabled="true"
          @selection-changed="onDataSubSelectionChanged"
          :column-width="100"
          @exporting="onExportingDetail"
          :allow-column-resizing="true"
          column-resizing-mode="widget"
        >
          <DxSelection mode="single" />
          <DxPaging :page-size="20" :enabled="true" />
          <DxPager
            :visible="true"
            :allowed-page-sizes="[20, 50, 100]"
            display-mode="full"
            :show-page-size-selector="true"
            :show-info="true"
            :show-navigation-buttons="true"
          />

          <DxSearchPanel :visible="true" :highlight-case-sensitive="true" />
          <DxExport
            :enabled="true"
            :formats="['pdf', 'xlsx', 'document']"
            :allow-export-selected-data="false"
          />

          <DxColumn
            css-class="custom-table-column"
            :width="50"
            alignment="center"
            :calculate-display-value="(item: any) => dataSub.findIndex((i) => i == item) + 1"
            data-type="number"
            caption="No"
            cell-template="formatNumber"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="nama_ulp"
            caption="ULP"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="no_laporan"
            caption="No Laporan"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="waktu_lapor"
            caption="Tgl/Jam Lapor"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="waktu_response"
            caption="Tgl/Jam Datang"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="waktu_recovery"
            caption="Tgl/Jam Nyala"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="durasi_response_time"
            caption="Durasi Response Time"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatTime"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="durasi_recovery_time"
            caption="Durasi Recovery Time"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatTime"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Durasi Penugasan Regu"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatTime"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Durasi Perjalanan Regu"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatTime"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field=""
            caption="Dispatch Oleh"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatTime"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="idpel_nometer"
            caption="IDPEL/NO METER"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatTime"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="nama_pelapor"
            caption="Nama Pelapor"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="200"
            alignment="center"
            data-field="alamat_pelapor"
            caption="Alamat Pelapor"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="no_telp_pelapor"
            caption="No Tlp Pelapor"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="200"
            alignment="center"
            data-field="keterangan_pelapor"
            caption="Keterangan Pelapor"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="200"
            alignment="center"
            data-field=""
            caption="Sumber Lapor"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="200"
            alignment="center"
            data-field=""
            caption="Diselesaikan Oleh"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="150"
            alignment="center"
            data-field="status_akhir"
            caption="Status"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatTime"
          />
          <DxColumn
            :width="200"
            alignment="center"
            data-field=""
            caption="Referensi Marking"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="200"
            alignment="center"
            data-field=""
            caption="Kode Gangguan"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="200"
            alignment="center"
            data-field=""
            caption="Janis Gangguan"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />
          <DxColumn
            :width="200"
            alignment="center"
            data-field=""
            caption="Tindakan"
            :allow-resizing="false"
            css-class="custom-table-column"
            cell-template="formatText"
          />

          <template #formatText="{ data }">
            <p class="text-left cursor-pointer">
              {{ data.text }}
            </p>
          </template>

          <template #formatNumber="{ data }">
            <p class="text-right cursor-pointer">
              {{ data.text }}
            </p>
          </template>

          <template #formatTime="{ data }">
            <p class="text-right cursor-pointer">
              {{ parseInt(data.text) ? formatWaktu(data.text) : '-' }}
            </p>
          </template>
        </DxDataGrid>
      </div>
    </div>

    <div class="w-full mb-4 lg:w-[30%] lg:float-right">
      <div class="p-4 space-y-2 bg-white rounded-xl">
        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">ULP:</h3>
          <InputText :readonly="true" :value="dataSubSelected?.nama_ulp" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">No Laporan:</h3>
          <InputText :readonly="true" :value="dataSubSelected?.no_laporan" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Tgl/Jam Lapor:</h3>
          <InputText :readonly="true" :value="dataSubSelected?.waktu_lapor" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Tgl/Jam Datang:</h3>
          <InputText
            :readonly="true"
            :value="dataSubSelected?.waktu_response"
            class-name="flex-1"
          />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Tgl/Jam Nyala:</h3>
          <InputText
            :readonly="true"
            :value="dataSubSelected?.waktu_recovery"
            class-name="flex-1"
          />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Durasi Response Time:</h3>
          <InputText
            :readonly="true"
            :value="
              parseInt(dataSubSelected?.durasi_response_time)
                ? formatWaktu(dataSubSelected?.durasi_response_time)
                : '-'
            "
            class-name="flex-1"
          />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Durasi Recovery Time:</h3>
          <InputText
            :readonly="true"
            :value="
              parseInt(dataSubSelected?.durasi_recovery_time)
                ? formatWaktu(dataSubSelected?.durasi_recovery_time)
                : '-'
            "
            class-name="flex-1"
          />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Durasi Penugasan Regu:</h3>
          <InputText :readonly="true" value="" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Durasi Perjalanan Regu:</h3>
          <InputText :readonly="true" value="" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Dispatch Oleh:</h3>
          <InputText :readonly="true" value="" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">IDPEL/NO METER:</h3>
          <InputText :readonly="true" :value="dataSubSelected?.idpel_nometer" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Nama Pelapor:</h3>
          <InputText :readonly="true" :value="dataSubSelected?.nama_pelapor" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Alamat Pelapor:</h3>
          <InputText
            :readonly="true"
            type="textarea"
            :value="dataSubSelected?.alamat_pelapor"
            class-name="flex-1"
          />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">No Telp Pelapor:</h3>
          <InputText
            :readonly="true"
            :value="dataSubSelected?.no_telp_pelapor"
            class-name="flex-1"
          />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Keterangan Pelapor:</h3>
          <InputText
            :readonly="true"
            :value="dataSubSelected?.keterangan_pelapor"
            class-name="flex-1"
          />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Sumber Lapor:</h3>
          <InputText :readonly="true" value="" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Diselesaikan Oleh:</h3>
          <InputText :readonly="true" value="" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Status:</h3>
          <InputText :readonly="true" :value="dataSubSelected?.status_akhir" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Referensi Marking:</h3>
          <InputText :readonly="true" value="" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Kode Gangguan:</h3>
          <InputText :readonly="true" value="" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Janis Gangguan:</h3>
          <InputText :readonly="true" value="" class-name="flex-1" />
        </div>

        <div class="flex flex-row items-center justify-between w-full">
          <h3 class="text-sm font-medium w-[135px] text-gray-800">Tindakan:</h3>
          <InputText :readonly="true" value="" class-name="flex-1" />
        </div>
      </div>
    </div>
  </DetailDialog>
  <BufferDialog v-if="loadingData || loadingSubData" />
</template>

<script setup lang="ts">
import Filters from '@/components/Form/Filters.vue'
import Type2 from '@/components/Form/FiltersType/Type2.vue'
import { onMounted, ref } from 'vue'
import { DxDataGrid } from 'devextreme-vue'
import {
  DxColumn,
  DxColumnFixing,
  DxExport,
  DxGroupItem,
  DxGrouping,
  DxPager,
  DxPaging,
  DxScrolling,
  DxSearchPanel,
  DxSelection,
  DxSummary,
  DxTotalItem
} from 'devextreme-vue/data-grid'
import { getMonthName } from '@/utils/texts'
import { queries, requestGraphQl } from '@/utils/api/api.graphql'
import { formatNumber, formatPercentage, isNumber } from '@/utils/numbers'
import { apolloClient } from '@/utils/api/api.graphql'
import { provideApolloClient } from '@vue/apollo-composable'
import DetailDialog from '@/components/Dialogs/DetailDialog.vue'
import { formatWaktu } from '@/components/Form/FiltersType/reference'
import InputText from '@/components/InputText.vue'
import BufferDialog from '@/components/Dialogs/BufferDialog.vue'
import {
  exportToPDF,
  exportToXLSX,
  exportDetailToPDF,
  exportDetailToXLSX,
  exportToDOCX,
  exportDetailToDOCX
} from '@/report/Monalisa/Gangguan/Rekap/MonalisaGR_DispatchingTimeGangguan'

const client = apolloClient()
provideApolloClient(client)
const lastMonth = ref(new Date().getMonth() == 1 ? 12 : new Date().getMonth() - 1)
const lastYearMoM = ref(
  new Date().getMonth() == 1 ? new Date().getFullYear() - 1 : new Date().getFullYear()
)
const currentYear = ref(new Date().getFullYear())
const currentMonth = ref(new Date().getMonth())
const lastYear = ref(currentYear.value - 1)
const position = { of: '#data' }
const showIndicator = ref(true)
const shading = ref(true)
const showPane = ref(true)
const data = ref<any[]>([])
const dataSub = ref<any[]>([])
const dataSelected = ref<any>()
const dataSubSelected = ref<any>()
const dialogDetail = ref(false)
const closedialogDetail = () => (dialogDetail.value = false)
const loadingData = ref(false)
const loadingSubData = ref(false)
const dataType = ref('')
const dataYear = ref(new Date().getFullYear())
const dataMonth = ref(new Date().getMonth())
const reportMeta = ref({
  regional: { id: 0, name: 'Semua Regional' },
  uid: { id: 0, name: 'Semua Unit Induk Distribusi/Wilayah' },
  up3: { id: 0, name: 'Semua Unit Pelaksanaan Pelayanan Pelanggan' },
  ulp: { id: 0, name: 'Semua Unit Layanan Pelanggan' },
  bulan: { id: new Date().getMonth(), name: getMonthName(new Date().getMonth()) },
  tahun: { id: new Date().getFullYear(), name: new Date().getFullYear().toString() },
  periode: '',
  lastMonth: new Date().getMonth() == 1 ? 12 : new Date().getMonth() - 1,
  lastYearMoM: new Date().getMonth() == 1 ? new Date().getFullYear() - 1 : new Date().getFullYear(),
  currentMonth: new Date().getMonth(),
  currentYear: new Date().getFullYear(),
  lastYear: new Date().getFullYear() - 1
})

const grouping = ref<any[]>([
  {
    data: 'nama_regional',
    caption: 'Regional'
  },
  {
    data: 'nama_uid',
    caption: 'UID'
  },
  {
    data: 'nama_up3',
    caption: 'UP3'
  }
])

let mom_bulan_kemarin = 0
let count_mom_bulan_kemarin = 0
let cal_mom_bulan_kemarin = 0

let mom_bulan_ini = 0
let count_mom_bulan_ini = 0
let cal_mom_bulan_ini = 0

let yoy_tahun_kemarin = 0
let count_yoy_tahun_kemarin = 0
let cal_yoy_tahun_kemarin = 0

let yoy_tahun_ini = 0
let count_yoy_tahun_ini = 0
let cal_yoy_tahun_ini = 0
const calculateCustomSummary = (options: any) => {
  if (options.name === 'count_mom_bulan_kemarin') {
    if (options.summaryProcess === 'calculate') {
      count_mom_bulan_kemarin += options.value
    } else if (options.summaryProcess === 'finalize') {
      options.totalValue = count_mom_bulan_kemarin
    }
  }

  if (options.name === 'cal_mom_bulan_kemarin') {
    if (options.summaryProcess === 'calculate') {
      cal_mom_bulan_kemarin += options.value
    } else if (options.summaryProcess === 'finalize') {
      options.totalValue = cal_mom_bulan_kemarin
    }
  }

  if (options.name === 'mom_bulan_kemarin') {
    if (options.summaryProcess === 'start') {
      cal_mom_bulan_kemarin = 0
      count_mom_bulan_kemarin = 0
    } else if (options.summaryProcess === 'calculate') {
      mom_bulan_kemarin += options.value
    } else if (options.summaryProcess === 'finalize') {
      options.totalValue = cal_mom_bulan_kemarin / count_mom_bulan_kemarin
    }
  }

  if (options.name === 'count_mom_bulan_ini') {
    if (options.summaryProcess === 'calculate') {
      count_mom_bulan_ini += options.value
    } else if (options.summaryProcess === 'finalize') {
      options.totalValue = count_mom_bulan_ini
    }
  }

  if (options.name === 'cal_mom_bulan_ini') {
    if (options.summaryProcess === 'calculate') {
      cal_mom_bulan_ini += options.value
    } else if (options.summaryProcess === 'finalize') {
      options.totalValue = cal_mom_bulan_ini
    }
  }

  if (options.name === 'mom_bulan_ini') {
    if (options.summaryProcess === 'start') {
      cal_mom_bulan_ini = 0
      count_mom_bulan_ini = 0
    } else if (options.summaryProcess === 'calculate') {
      mom_bulan_ini += options.value
    } else if (options.summaryProcess === 'finalize') {
      options.totalValue = cal_mom_bulan_ini / count_mom_bulan_ini
    }
  }

  if (options.name === 'persen_mom') {
    if (options.summaryProcess === 'start') {
      mom_bulan_kemarin = 0
      mom_bulan_ini = 0
    } else if (options.summaryProcess === 'finalize') {
      options.totalValue =
        mom_bulan_kemarin == 0 ? 0 : ((mom_bulan_kemarin - mom_bulan_ini) / mom_bulan_kemarin) * 100
    }
  }

  if (options.name === 'count_yoy_tahun_kemarin') {
    if (options.summaryProcess === 'calculate') {
      count_yoy_tahun_kemarin += options.value
    } else if (options.summaryProcess === 'finalize') {
      options.totalValue = count_yoy_tahun_kemarin
    }
  }

  if (options.name === 'cal_yoy_tahun_kemarin') {
    if (options.summaryProcess === 'calculate') {
      cal_yoy_tahun_kemarin += options.value
    } else if (options.summaryProcess === 'finalize') {
      options.totalValue = cal_yoy_tahun_kemarin
    }
  }

  if (options.name === 'yoy_tahun_kemarin') {
    if (options.summaryProcess === 'start') {
      cal_yoy_tahun_kemarin = 0
      count_yoy_tahun_kemarin = 0
    } else if (options.summaryProcess === 'calculate') {
      yoy_tahun_kemarin += options.value
    } else if (options.summaryProcess === 'finalize') {
      options.totalValue = cal_yoy_tahun_kemarin / count_yoy_tahun_kemarin
    }
  }

  if (options.name === 'count_yoy_tahun_ini') {
    if (options.summaryProcess === 'calculate') {
      count_yoy_tahun_ini += options.value
    } else if (options.summaryProcess === 'finalize') {
      options.totalValue = count_yoy_tahun_ini
    }
  }

  if (options.name === 'cal_yoy_tahun_ini') {
    if (options.summaryProcess === 'calculate') {
      cal_yoy_tahun_ini += options.value
    } else if (options.summaryProcess === 'finalize') {
      options.totalValue = cal_yoy_tahun_ini
    }
  }

  if (options.name === 'yoy_tahun_ini') {
    if (options.summaryProcess === 'start') {
      cal_yoy_tahun_ini = 0
      count_yoy_tahun_ini = 0
    } else if (options.summaryProcess === 'calculate') {
      yoy_tahun_ini += options.value
    } else if (options.summaryProcess === 'finalize') {
      options.totalValue = cal_yoy_tahun_ini / count_yoy_tahun_ini
    }
  }

  if (options.name === 'persen_yoy') {
    if (options.summaryProcess === 'start') {
      yoy_tahun_kemarin = 0
      yoy_tahun_ini = 0
    } else if (options.summaryProcess === 'finalize') {
      options.totalValue =
        yoy_tahun_kemarin == 0 ? 0 : ((yoy_tahun_kemarin - yoy_tahun_ini) / yoy_tahun_kemarin) * 100
    }
  }
}

const setRequirements = (type: string, month: number, year: number) => {
  dataType.value = type
  dataYear.value = year
  dataMonth.value = month
}

const onExporting = (e: any) => {
  if (e.format === 'pdf') {
    exportToPDF(reportMeta.value, data.value)
  } else if (e.format === 'xlsx') {
    exportToXLSX(reportMeta.value, e)
  } else {
    exportToDOCX(reportMeta.value, data.value)
  }
}

const onExportingDetail = (e: any) => {
  if (e.format === 'pdf') {
    exportDetailToPDF(reportMeta.value, dataSub.value)
  } else if (e.format === 'xlsx') {
    exportDetailToXLSX(reportMeta.value, e)
  } else {
    exportDetailToDOCX(reportMeta.value, dataSub.value)
  }
}

const resetData = () => {
  data.value = []
  dataSub.value = []
}

const filterData = async (params: any) => {
  resetData()
  const { regional, ulp, uid, up3, bulan, tahun } = params

  var groupList: any[] = [
    {
      data: 'nama_regional',
      caption: 'Regional'
    },
    {
      data: 'nama_uid',
      caption: 'UID'
    },
    {
      data: 'nama_up3',
      caption: 'UP3'
    }
  ]

  if (uid?.id != 0) {
    groupList.forEach((item, index) => {
      if (item.caption == 'Regional') {
        groupList.splice(index, 1)
      }
    })

    if (up3?.id != 0) {
      groupList.forEach((item, index) => {
        if (item.caption == 'UID') {
          groupList.splice(index, 1)
        }
      })

      if (ulp?.id != 0) {
        groupList.forEach((item, index) => {
          if (item.caption == 'UP3') {
            groupList.splice(index, 1)
          }
        })
      }
    }
  }
  grouping.value = groupList

  const query = {
    namaRegional: regional.name == 'Semua Regional' ? '' : regional.name,
    idUid: uid ? uid.id : 0,
    idUp3: up3 ? up3.id : 0,
    idUlp: ulp ? ulp.id : 0,
    bulan: bulan ? bulan.id : currentMonth.value,
    tahun: bulan ? tahun.id : currentYear.value
  }
  loadingData.value = true
  await requestGraphQl(queries.monalisa.gangguan.rekap.dispatchingTimeGangguan, query)
    .then((result) => {
      if (result.data.data != undefined) {
        data.value = result.data.data.monalisaDispatchingTimeGangguan
      } else {
        data.value = []
      }

      reportMeta.value = {
        regional: regional,
        uid: uid,
        up3: up3,
        ulp: ulp,
        bulan: bulan,
        tahun: tahun,
        periode: `${bulan.name} ${tahun.name}`,
        lastMonth: lastMonth.value,
        lastYearMoM: lastYearMoM.value,
        currentMonth: currentMonth.value,
        currentYear: currentYear.value,
        lastYear: lastYear.value
      }
    })
    .catch((err) => {
      console.error(err)
    })
    .finally(() => {
      loadingData.value = false
    })
  lastMonth.value = bulan.id == 1 ? 12 : bulan.id - 1
  lastYearMoM.value = bulan.id == 1 ? tahun.id - 1 : tahun.id
  currentMonth.value = bulan.id
  currentYear.value = tahun.id
  lastYear.value = tahun.id - 1
}

const getDetail = async () => {
  const selected = dataSelected.value

  const query = {
    bulan: dataMonth.value,
    tahun: dataYear.value,
    idUlp: selected?.id_ulp ? selected?.id_ulp : 0,
    idUid: selected?.id_uid ? selected?.id_uid : 0,
    idUp3: selected?.id_up3 ? selected?.id_up3 : 0
  }

  loadingSubData.value = true
  await requestGraphQl(
    dataType.value == 'yoy'
      ? queries.monalisa.gangguan.rekap.dispatchingTimeGangguanDetailYoy
      : queries.monalisa.gangguan.rekap.dispatchingTimeGangguanDetailMom,
    query
  )
    .then((result) => {
      if (result.data.data != undefined) {
        if (dataType.value == 'yoy') {
          dataSub.value = result.data.data.detailMonalisaDispatchingTimeGangguanYoy
        } else {
          dataSub.value = result.data.data.detailMonalisaDispatchingTimeGangguanMoM
        }
      } else {
        dataSub.value = []
      }
    })
    .catch((err) => {
      console.error(err)
    })
    .finally(() => {
      loadingSubData.value = false
      dialogDetail.value = true
    })
}

const dataGridRef = ref<DxDataGrid | null>(null)
const clearSelection = () => {
  const dataGrid = dataGridRef.value!.instance!
  dataGrid.clearSelection()
}
const showDetail = () => {
  clearSelection()
  dataSubSelected.value = null
  if (dataType.value == 'yoy' || dataType.value == 'mom') {
    getDetail()
  }
}
const onDataSelectionChanged = ({ selectedRowsData }: any) => {
  if (selectedRowsData[0] != undefined) {
    dataSelected.value = selectedRowsData[0]
    showDetail()
  }
}

const onDataSubSelectionChanged = ({ selectedRowsData }: any) => {
  const data = selectedRowsData[0]
  dataSubSelected.value = data
}

const filters = ref()
onMounted(() => {
  if (import.meta.env.DEV) {
    data.value = [
      {
        id: 0,
        nama_regional: 'REGIONAL SUMKAL',
        id_uid: 120,
        nama_uid: 'WILAYAH SUMATERA UTARA',
        id_up3: 12100,
        nama_up3: 'UP3 PEMATANG SIANTAR',
        id_ulp: 12102,
        nama_ulp: 'ULP LIMA PULUH',
        mom_bulan_ini: 0.6666667,
        mom_bulan_kemarin: 0.5,
        count_mom_bulan_ini: 12,
        count_mom_bulan_kemarin: 8,
        persen_mom: -33.33333333333333,
        yoy_tahun_ini: 0.6551724,
        yoy_tahun_kemarin: 1.9324324,
        count_yoy_tahun_ini: 29,
        count_yoy_tahun_kemarin: 74,
        persen_yoy: 66.09597299252472
      },
      {
        id: 1,
        nama_regional: 'REGIONAL SULMAPANA',
        id_uid: 41,
        nama_uid: 'WILAYAH MALUKU DAN MALUKU UTARA',
        id_up3: 412,
        nama_up3: 'UP3 TERNATE',
        id_ulp: 41230,
        nama_ulp: 'ULP BACAN',
        mom_bulan_ini: 1.3445379,
        mom_bulan_kemarin: 1.6041666,
        count_mom_bulan_ini: 119,
        count_mom_bulan_kemarin: 48,
        persen_mom: 16.184655680453996,
        yoy_tahun_ini: 1.4439834,
        yoy_tahun_kemarin: 2.8314607,
        count_yoy_tahun_ini: 241,
        count_yoy_tahun_kemarin: 1068,
        persen_yoy: 49.00217348350128
      },
      {
        id: 2,
        nama_regional: 'REGIONAL JMB',
        id_uid: 101,
        nama_uid: 'DISTRIBUSI JAWA TENGAH & DIY',
        id_up3: 52150,
        nama_up3: 'UP3 MAGELANG',
        id_ulp: 52156,
        nama_ulp: 'ULP PARAKAN',
        mom_bulan_ini: 2.6786427,
        mom_bulan_kemarin: 1.456847,
        count_mom_bulan_ini: 1002,
        count_mom_bulan_kemarin: 869,
        persen_mom: -83.86575979163318,
        yoy_tahun_ini: 2.5145037,
        yoy_tahun_kemarin: 2.4555247,
        count_yoy_tahun_ini: 3275,
        count_yoy_tahun_kemarin: 3249,
        persen_yoy: -2.401891461059904
      },
      {
        id: 3,
        nama_regional: 'REGIONAL SULMAPANA',
        id_uid: 31,
        nama_uid: 'WILAYAH SULAWESI UTARA,TENGAH DAN GORONTALO',
        id_up3: 31500,
        nama_up3: 'UP3 TOLITOLI',
        id_ulp: 31530,
        nama_ulp: 'ULP BANGKIR',
        mom_bulan_ini: 0.44680852,
        mom_bulan_kemarin: 0.27272728,
        count_mom_bulan_ini: 94,
        count_mom_bulan_kemarin: 99,
        persen_mom: -63.829787234042556,
        yoy_tahun_ini: 0.28164557,
        yoy_tahun_kemarin: 1.2074689,
        count_yoy_tahun_ini: 316,
        count_yoy_tahun_kemarin: 241,
        persen_yoy: 76.67471399364914
      },
      {
        id: 4,
        nama_regional: 'REGIONAL JMB',
        id_uid: 103,
        nama_uid: 'DISTRIBUSI JAWA TIMUR',
        id_up3: 154,
        nama_up3: 'UP3 SITUBONDO',
        id_ulp: 51654,
        nama_ulp: 'ULP WONOSARI',
        mom_bulan_ini: 3.4751463,
        mom_bulan_kemarin: 2.7604356,
        count_mom_bulan_ini: 684,
        count_mom_bulan_kemarin: 551,
        persen_mom: -25.891226532252176,
        yoy_tahun_ini: 3.34143,
        yoy_tahun_kemarin: 4.378579,
        count_yoy_tahun_ini: 2182,
        count_yoy_tahun_kemarin: 1886,
        persen_yoy: 23.686888407963263
      },
      {
        id: 5,
        nama_regional: 'REGIONAL SUMKAL',
        id_uid: 110,
        nama_uid: 'WILAYAH ACEH',
        id_up3: 116,
        nama_up3: 'UP3 SIGLI',
        id_ulp: 11662,
        nama_ulp: 'ULP MEUREUDU',
        mom_bulan_ini: 0.6483146,
        mom_bulan_kemarin: 0.6156424,
        count_mom_bulan_ini: 890,
        count_mom_bulan_kemarin: 895,
        persen_mom: -5.307000550582197,
        yoy_tahun_ini: 0.67312616,
        yoy_tahun_kemarin: 0.6547131,
        count_yoy_tahun_ini: 2735,
        count_yoy_tahun_kemarin: 1952,
        persen_yoy: -2.8123810913418765
      },
      {
        id: 6,
        nama_regional: 'REGIONAL JMB',
        id_uid: 287,
        nama_uid: 'DISTRIBUSI BALI',
        id_up3: 329,
        nama_up3: 'UP3 BALI UTARA',
        id_ulp: 55340,
        nama_ulp: 'ULP GILIMANUK',
        mom_bulan_ini: 5.4121337,
        mom_bulan_kemarin: 6.265075,
        count_mom_bulan_ini: 956,
        count_mom_bulan_kemarin: 796,
        persen_mom: 13.614225438021696,
        yoy_tahun_ini: 5.926926,
        yoy_tahun_kemarin: 5.2659764,
        count_yoy_tahun_ini: 2518,
        count_yoy_tahun_kemarin: 2222,
        persen_yoy: -12.55131924598068
      },
      {
        id: 7,
        nama_regional: 'REGIONAL SUMKAL',
        id_uid: 131,
        nama_uid: 'WILAYAH SUMATERA BARAT',
        id_up3: 13300,
        nama_up3: 'UP3 SOLOK',
        id_ulp: 13334,
        nama_ulp: 'ULP SILUNGKANG',
        mom_bulan_ini: 0.442029,
        mom_bulan_kemarin: 0.31428573,
        count_mom_bulan_ini: 138,
        count_mom_bulan_kemarin: 210,
        persen_mom: -40.645586297760225,
        yoy_tahun_ini: 0.40862423,
        yoy_tahun_kemarin: 0.44198895,
        count_yoy_tahun_ini: 487,
        count_yoy_tahun_kemarin: 724,
        persen_yoy: 7.548767967145785
      },
      {
        id: 8,
        nama_regional: 'REGIONAL SUMKAL',
        id_uid: 221,
        nama_uid: 'WILAYAH KALIMANTAN SELATAN DAN TENGAH',
        id_up3: 2220,
        nama_up3: 'UP3 BARABAI',
        id_ulp: 22230,
        nama_ulp: 'ULP AMUNTAI',
        mom_bulan_ini: 1.9542483,
        mom_bulan_kemarin: 3.2557251,
        count_mom_bulan_ini: 306,
        count_mom_bulan_kemarin: 262,
        persen_mom: 39.97502087978607,
        yoy_tahun_ini: 2.4175258,
        yoy_tahun_kemarin: 0.9059561,
        count_yoy_tahun_ini: 970,
        count_yoy_tahun_kemarin: 957,
        persen_yoy: -166.8480005707559
      },
      {
        id: 9,
        nama_regional: 'REGIONAL SULMAPANA',
        id_uid: 31,
        nama_uid: 'WILAYAH SULAWESI UTARA,TENGAH DAN GORONTALO',
        id_up3: 31700,
        nama_up3: 'UP3 KOTAMOBAGU',
        id_ulp: 31730,
        nama_ulp: 'ULP MODAYAG',
        mom_bulan_ini: 2.0680273,
        mom_bulan_kemarin: 2.3333333,
        count_mom_bulan_ini: 147,
        count_mom_bulan_kemarin: 123,
        persen_mom: 11.370262390670556,
        yoy_tahun_ini: 2.1894484,
        yoy_tahun_kemarin: 5.062814,
        count_yoy_tahun_ini: 417,
        count_yoy_tahun_kemarin: 398,
        persen_yoy: 56.754318629463675
      }
    ]
  }
})
</script>
